diff --git a/README.md b/README.md deleted file mode 100644 index 9454492..0000000 --- a/README.md +++ /dev/null @@ -1,63 +0,0 @@ -# 中文 | [English](https://github.com/Siriling/5G-Modem-Support/blob/main/EngLish.md) - -# 5G模块支持 - -# 目录 - -[一、说明](#一说明) - -[二、源代码地址 ](#二源代码地址) - -# 一、说明 - -## 5G驱动 - -- quectel_Gobinet -- quectel_MHI -- quectel_QMI_WWAN -- quectel_SRPD_PCIE -- fibocom_MHI -- fibocom_QMI_WWAN - -## 拨号工具 - -- quectel_cm_5G -- fibocom-dial - -## 图形化界面设置 - -### 拨号 - -- luci-app-modem(新) - -- luci-app-hypermodem -- luci-app-usbmodem -- luci-app-pcimodem -- luci-app-gobinetmodem -- luci-app-spdmodem - -### 信息插件 - -- rooter - -### 简化版信息插件 - -- luci-app-cpe - -### AT命令工具 - -- sendat -- sms-tool - -### 短信工具 - -- luci-app-sms-tool - -# 二、源代码地址 - -- luci-app-hypermodem:https://github.com/momokind/luci-app-hypermodem - -- sendat:https://github.com/ouyangzq/sendat -- luci-app-cpe:https://github.com/ouyangzq/luci-app-cpe -- sms-tool:https://github.com/obsy/sms_tool - diff --git a/fibocom-dial/Makefile b/fibocom-dial/Makefile deleted file mode 100644 index a454549..0000000 --- a/fibocom-dial/Makefile +++ /dev/null @@ -1,26 +0,0 @@ -include $(TOPDIR)/rules.mk - -PKG_NAME:=fibocom-dial -PKG_RELEASE:=1 - -include $(INCLUDE_DIR)/package.mk - -define Package/fibocom-dial - SECTION:=utils - CATEGORY:=Utilities - TITLE:=Fibocom Dial -endef - -define Build/Prepare - mkdir -p $(PKG_BUILD_DIR) - $(CP) ./src/* $(PKG_BUILD_DIR)/ -endef - -define Package/fibocom-dial/install - $(INSTALL_DIR) $(1)/usr/bin - $(INSTALL_BIN) $(PKG_BUILD_DIR)/fibocom-dial $(1)/usr/bin - $(INSTALL_BIN) $(PKG_BUILD_DIR)/fibo_qmimsg_server $(1)/usr/bin - $(INSTALL_BIN) $(PKG_BUILD_DIR)/multi-pdn-manager $(1)/usr/bin -endef - -$(eval $(call BuildPackage,fibocom-dial)) diff --git a/fibocom-dial/src/GobiNetCM.c b/fibocom-dial/src/GobiNetCM.c deleted file mode 100644 index d1f6464..0000000 --- a/fibocom-dial/src/GobiNetCM.c +++ /dev/null @@ -1,275 +0,0 @@ -#include -#include -#include -#include - -#include "QMIThread.h" - -#ifdef CONFIG_GOBINET - -// IOCTL to generate a client ID for this service type -#define IOCTL_QMI_GET_SERVICE_FILE 0x8BE0 + 1 - -// IOCTL to get the VIDPID of the device -#define IOCTL_QMI_GET_DEVICE_VIDPID 0x8BE0 + 2 - -// IOCTL to get the MEID of the device -#define IOCTL_QMI_GET_DEVICE_MEID 0x8BE0 + 3 - -static int GobiNetSendQMI(PQCQMIMSG pRequest) -{ - int ret, fd; - - static int send_count = 0; - fd = qmiclientId[pRequest->QMIHdr.QMIType]; - - if (fd <= 0) { - dbg_time("%s QMIType: %d has no clientID", __func__, - pRequest->QMIHdr.QMIType); - return -ENODEV; - } - - // Always ready to write -re_write: - if (1 == 1) { - ssize_t nwrites = - le16_to_cpu(pRequest->QMIHdr.Length) + 1 - sizeof(QCQMI_HDR); - ret = write(fd, &pRequest->MUXMsg, nwrites); - if (ret == nwrites) - { - ret = 0; - send_count = 0; - } - else - { - send_count++; - dbg_time("%s write=%d, errno: %d (%s) send_count %d", __func__, ret, errno, strerror(errno), send_count); - if (send_count < 3) - { - sleep(1); - goto re_write; - } - } - - } else { - dbg_time("%s poll=%d, errno: %d (%s)", __func__, ret, errno, - strerror(errno)); - } - - return ret; -} - -static int GobiNetGetClientID(const char *qcqmi, UCHAR QMIType) -{ - int ClientId; - ClientId = open(qcqmi, O_RDWR | O_NONBLOCK | O_NOCTTY); - if (ClientId == -1) { - dbg_time("failed to open %s, errno: %d (%s)", qcqmi, errno, - strerror(errno)); - return -1; - } - - if (ioctl(ClientId, IOCTL_QMI_GET_SERVICE_FILE, QMIType) != 0) { - dbg_time("failed to get ClientID for 0x%02x errno: %d (%s)", QMIType, - errno, strerror(errno)); - close(ClientId); - ClientId = 0; - } - - dbg_time("%s: QMIType = %d clientid %d", __func__, QMIType, ClientId); - - switch (QMIType) { - case QMUX_TYPE_WDS: - dbg_time("Get clientWDS = %d", ClientId); - break; - case QMUX_TYPE_DMS: - dbg_time("Get clientDMS = %d", ClientId); - break; - case QMUX_TYPE_NAS: - dbg_time("Get clientNAS = %d", ClientId); - break; - case QMUX_TYPE_QOS: - dbg_time("Get clientQOS = %d", ClientId); - break; - case QMUX_TYPE_WMS: - dbg_time("Get clientWMS = %d", ClientId); - break; - case QMUX_TYPE_PDS: - dbg_time("Get clientPDS = %d", ClientId); - break; - case QMUX_TYPE_UIM: - dbg_time("Get clientUIM = %d", ClientId); - break; - case QMUX_TYPE_WDS_ADMIN: - dbg_time("Get clientWDA = %d", ClientId); - break; - default: - break; - } - - return ClientId; -} - -static int GobiNetDeInit(void) -{ - unsigned int i; - for (i = 0; i < sizeof(qmiclientId) / sizeof(qmiclientId[0]); i++) { - if (qmiclientId[i] != 0) { - close(qmiclientId[i]); - qmiclientId[i] = 0; - } - } - - return 0; -} -static void *GobiNetThread(void *pData) -{ - PROFILE_T *profile = (PROFILE_T *)pData; - const char *qcqmi = (const char *)profile->qmichannel; - int wait_for_request_quit = 0; - dbg_time("%s %d", __func__, __LINE__); - if (profile->ipv4_flag) - qmiclientId[QMUX_TYPE_WDS] = GobiNetGetClientID(qcqmi, QMUX_TYPE_WDS); - if (profile->ipv6_flag) - qmiclientId[QMUX_TYPE_WDS_IPV6] = GobiNetGetClientID(qcqmi, QMUX_TYPE_WDS); - qmiclientId[QMUX_TYPE_DMS] = GobiNetGetClientID(qcqmi, QMUX_TYPE_DMS); - qmiclientId[QMUX_TYPE_NAS] = GobiNetGetClientID(qcqmi, QMUX_TYPE_NAS); - qmiclientId[QMUX_TYPE_UIM] = GobiNetGetClientID(qcqmi, QMUX_TYPE_UIM); - // qmiclientId[QMUX_TYPE_WDS_ADMIN] = -// GobiNetGetClientID(qcqmi, QMUX_TYPE_WDS_ADMIN); - - //if ((qmiclientId[QMUX_TYPE_WDS] == 0) && (qmiclientId[QMUX_TYPE_WDS_IPV6] == 0)) /*|| (clientWDA == -1)*/ { - - if ((qmiclientId[QMUX_TYPE_DMS] == 0) || - (qmiclientId[QMUX_TYPE_NAS] == 0) || - (qmiclientId[QMUX_TYPE_UIM] == 0) || - (profile->ipv4_flag ? ((qmiclientId[QMUX_TYPE_WDS] == 0) ? 1 : 0):0)|| - (profile->ipv6_flag ? ((qmiclientId[QMUX_TYPE_WDS_IPV6] == 0) ? 1 : 0):0)) - { - GobiNetDeInit(); - dbg_time("%s Failed to open %s, errno: %d (%s)", __func__, qcqmi, errno,strerror(errno)); - qmidevice_send_event_to_main(RIL_INDICATE_DEVICE_DISCONNECTED); - pthread_exit(NULL); - return NULL; - } - - qmidevice_send_event_to_main(RIL_INDICATE_DEVICE_CONNECTED); - - while (1) { - struct pollfd pollfds[16] = {{qmidevice_control_fd[1], POLLIN, 0}}; - int ne, ret, nevents = 1; - unsigned int i; - for (i = 0; i < sizeof(qmiclientId) / sizeof(qmiclientId[0]); i++) { - if (qmiclientId[i] != 0) { - pollfds[nevents].fd = qmiclientId[i]; - pollfds[nevents].events = POLLIN; - pollfds[nevents].revents = 0; - nevents++; - } - } - - do { - ret = poll(pollfds, nevents, wait_for_request_quit ? 1000 : -1); - } while ((ret < 0) && (errno == EINTR)); - - if (ret == 0 && wait_for_request_quit) { - QmiThreadRecvQMI( - NULL); // main thread may pending on QmiThreadSendQMI() - continue; - } - - if (ret <= 0) { - dbg_time("%s poll=%d, errno: %d (%s)", __func__, ret, errno, - strerror(errno)); - break; - } - - for (ne = 0; ne < nevents; ne++) { - int fd = pollfds[ne].fd; - short revents = pollfds[ne].revents; - - if (revents & (POLLERR | POLLHUP | POLLNVAL)) { - dbg_time("%s poll err/hup/inval", __func__); - dbg_time("epoll fd = %d, events = 0x%04x", fd, revents); - if (fd == qmidevice_control_fd[1]) { - } else { - } - if (revents & (POLLERR | POLLHUP | POLLNVAL)) - goto __GobiNetThread_quit; - } - if ((revents & POLLIN) == 0) - continue; - - if (fd == qmidevice_control_fd[1]) { - int triger_event; - if (read(fd, &triger_event, sizeof(triger_event)) == - sizeof(triger_event)) { - // DBG("triger_event = 0x%x", triger_event); - switch (triger_event) { - case RIL_REQUEST_QUIT: - goto __GobiNetThread_quit; - break; - case SIGTERM: - wait_for_request_quit = 1; - break; - default: - break; - } - } - continue; - } - - { - ssize_t nreads; - static UCHAR QMIBuf[4096]; - PQCQMIMSG pResponse = (PQCQMIMSG)QMIBuf; - - nreads = read(fd, &pResponse->MUXMsg, - sizeof(QMIBuf) - sizeof(QCQMI_HDR)); - if (nreads <= 0) { - dbg_time("%s read=%d errno: %d (%s)", __func__, (int)nreads, - errno, strerror(errno)); - break; - } - - for (i = 0; i < sizeof(qmiclientId) / sizeof(qmiclientId[0]); - i++) { - if (qmiclientId[i] == fd) { - pResponse->QMIHdr.QMIType = i; - } - } - - pResponse->QMIHdr.IFType = USB_CTL_MSG_TYPE_QMI; - pResponse->QMIHdr.Length = - cpu_to_le16(nreads + sizeof(QCQMI_HDR) - 1); - pResponse->QMIHdr.CtlFlags = 0x00; - pResponse->QMIHdr.ClientId = fd & 0xFF; - - QmiThreadRecvQMI(pResponse); - } - } - } - -__GobiNetThread_quit: - GobiNetDeInit(); - qmidevice_send_event_to_main(RIL_INDICATE_DEVICE_DISCONNECTED); - QmiThreadRecvQMI(NULL); // main thread may pending on QmiThreadSendQMI() - dbg_time("%s exit", __func__); - pthread_exit(NULL); - return NULL; -} - -#else -static int GobiNetSendQMI(PQCQMIMSG pRequest) { return -1; } -static void *GobiNetThread(void *pData) -{ - dbg_time("please set CONFIG_GOBINET"); - return NULL; -} -#endif - -const struct qmi_device_ops gobi_qmidev_ops = { - .deinit = GobiNetDeInit, - .send = GobiNetSendQMI, - .read = GobiNetThread, -}; diff --git a/fibocom-dial/src/MPQCTL.h b/fibocom-dial/src/MPQCTL.h deleted file mode 100644 index d9b4268..0000000 --- a/fibocom-dial/src/MPQCTL.h +++ /dev/null @@ -1,363 +0,0 @@ -/*=========================================================================== - - M P Q C T L. H -DESCRIPTION: - - This module contains QMI QCTL module. - -INITIALIZATION AND SEQUENCING REQUIREMENTS: - -Copyright (C) 2011 by Qualcomm Technologies, Incorporated. All Rights Reserved. -===========================================================================*/ - -#ifndef MPQCTL_H -#define MPQCTL_H - -#include "MPQMI.h" - -#pragma pack(push, 1) - -// ================= QMICTL ================== - -// QMICTL Control Flags -#define QMICTL_CTL_FLAG_CMD 0x00 -#define QMICTL_CTL_FLAG_RSP 0x01 -#define QMICTL_CTL_FLAG_IND 0x02 - -#if 0 -typedef struct _QMICTL_TRANSACTION_ITEM -{ - LIST_ENTRY List; - UCHAR TransactionId; // QMICTL transaction id - PVOID Context; // Adapter or IocDev - PIRP Irp; -} QMICTL_TRANSACTION_ITEM, *PQMICTL_TRANSACTION_ITEM; -#endif - -typedef struct _QCQMICTL_MSG_HDR { - UCHAR CtlFlags; // 00-cmd, 01-rsp, 10-ind - UCHAR TransactionId; - USHORT QMICTLType; - USHORT Length; -} __attribute__((packed)) QCQMICTL_MSG_HDR, *PQCQMICTL_MSG_HDR; - -#define QCQMICTL_MSG_HDR_SIZE sizeof(QCQMICTL_MSG_HDR) - -typedef struct _QCQMICTL_MSG_HDR_RESP { - UCHAR CtlFlags; // 00-cmd, 01-rsp, 10-ind - UCHAR TransactionId; - USHORT QMICTLType; - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT -} __attribute__((packed)) QCQMICTL_MSG_HDR_RESP, *PQCQMICTL_MSG_HDR_RESP; - -typedef struct _QCQMICTL_MSG { - UCHAR CtlFlags; // 00-cmd, 01-rsp, 10-ind - UCHAR TransactionId; - USHORT QMICTLType; - USHORT Length; - UCHAR Payload; -} __attribute__((packed)) QCQMICTL_MSG, *PQCQMICTL_MSG; - -// TLV Header -typedef struct _QCQMICTL_TLV_HDR { - UCHAR TLVType; - USHORT TLVLength; -} __attribute__((packed)) QCQMICTL_TLV_HDR, *PQCQMICTL_TLV_HDR; - -#define QCQMICTL_TLV_HDR_SIZE sizeof(QCQMICTL_TLV_HDR) - -// QMICTL Type -#define QMICTL_SET_INSTANCE_ID_REQ 0x0020 -#define QMICTL_SET_INSTANCE_ID_RESP 0x0020 -#define QMICTL_GET_VERSION_REQ 0x0021 -#define QMICTL_GET_VERSION_RESP 0x0021 -#define QMICTL_GET_CLIENT_ID_REQ 0x0022 -#define QMICTL_GET_CLIENT_ID_RESP 0x0022 -#define QMICTL_RELEASE_CLIENT_ID_REQ 0x0023 -#define QMICTL_RELEASE_CLIENT_ID_RESP 0x0023 -#define QMICTL_REVOKE_CLIENT_ID_IND 0x0024 -#define QMICTL_INVALID_CLIENT_ID_IND 0x0025 -#define QMICTL_SET_DATA_FORMAT_REQ 0x0026 -#define QMICTL_SET_DATA_FORMAT_RESP 0x0026 -#define QMICTL_SYNC_REQ 0x0027 -#define QMICTL_SYNC_RESP 0x0027 -#define QMICTL_SYNC_IND 0x0027 - -#define QMICTL_FLAG_REQUEST 0x00 -#define QMICTL_FLAG_RESPONSE 0x01 -#define QMICTL_FLAG_INDICATION 0x02 - -// QMICTL Message Definitions - -typedef struct _QMICTL_SET_INSTANCE_ID_REQ_MSG { - UCHAR CtlFlags; // QMICTL_FLAG_REQUEST - UCHAR TransactionId; - USHORT QMICTLType; // QMICTL_SET_INSTANCE_ID_REQ - USHORT Length; // 4 - UCHAR TLVType; // QCTLV_TYPE_REQUIRED_PARAMETER - USHORT TLVLength; // 1 - UCHAR Value; // Host-unique QMI instance for this device driver -} __attribute__((packed)) QMICTL_SET_INSTANCE_ID_REQ_MSG, - *PQMICTL_SET_INSTANCE_ID_REQ_MSG; - -typedef struct _QMICTL_SET_INSTANCE_ID_RESP_MSG { - UCHAR CtlFlags; // QMICTL_FLAG_RESPONSE - UCHAR TransactionId; - USHORT QMICTLType; // QMICTL_SET_INSTANCE_ID_RESP - USHORT Length; - UCHAR TLVType; // QCTLV_TYPE_RESULT_CODE - USHORT TLVLength; // 0x0004 - USHORT QMIResult; - USHORT QMIError; - UCHAR TLV2Type; // QCTLV_TYPE_REQUIRED_PARAMETER - USHORT TLV2Length; // 0x0002 - USHORT QMI_ID; // Upper byte is assigned by MSM, - // lower assigned by host -} __attribute__((packed)) QMICTL_SET_INSTANCE_ID_RESP_MSG, - *PQMICTL_SET_INSTANCE_ID_RESP_MSG; - -typedef struct _QMICTL_GET_VERSION_REQ_MSG { - UCHAR CtlFlags; // QMICTL_FLAG_REQUEST - UCHAR TransactionId; - USHORT QMICTLType; // QMICTL_GET_VERSION_REQ - USHORT Length; // 0 - UCHAR TLVType; // QCTLV_TYPE_REQUIRED_PARAMETER - USHORT TLVLength; // var - UCHAR QMUXTypes; // List of one byte QMUX_TYPE values - // 0xFF returns a list of versions for all - // QMUX_TYPEs implemented on the device -} __attribute__((packed)) QMICTL_GET_VERSION_REQ_MSG, - *PQMICTL_GET_VERSION_REQ_MSG; - -typedef struct _QMUX_TYPE_VERSION_STRUCT { - UCHAR QMUXType; - USHORT MajorVersion; - USHORT MinorVersion; -} __attribute__((packed)) QMUX_TYPE_VERSION_STRUCT, *PQMUX_TYPE_VERSION_STRUCT; - -typedef struct _ADDENDUM_VERSION_PREAMBLE { - UCHAR LabelLength; - UCHAR Label; -} __attribute__((packed)) ADDENDUM_VERSION_PREAMBLE, - *PADDENDUM_VERSION_PREAMBLE; - -#define QMICTL_GET_VERSION_RSP_TLV_TYPE_VERSION 0x01 -#define QMICTL_GET_VERSION_RSP_TLV_TYPE_ADD_VERSION 0x10 - -typedef struct _QMICTL_GET_VERSION_RESP_MSG { - UCHAR CtlFlags; // QMICTL_FLAG_RESPONSE - UCHAR TransactionId; - USHORT QMICTLType; // QMICTL_GET_VERSION_RESP - USHORT Length; - UCHAR TLVType; // QCTLV_TYPE_RESULT_CODE - USHORT TLVLength; // 0x0004 - USHORT QMIResult; - USHORT QMIError; - UCHAR TLV2Type; // QCTLV_TYPE_REQUIRED_PARAMETER - USHORT TLV2Length; // var - UCHAR NumElements; // Num of QMUX_TYPE_VERSION_STRUCT - QMUX_TYPE_VERSION_STRUCT TypeVersion[0]; -} __attribute__((packed)) QMICTL_GET_VERSION_RESP_MSG, - *PQMICTL_GET_VERSION_RESP_MSG; - -typedef struct _QMICTL_GET_CLIENT_ID_REQ_MSG { - UCHAR CtlFlags; // QMICTL_FLAG_REQUEST - UCHAR TransactionId; - USHORT QMICTLType; // QMICTL_GET_CLIENT_ID_REQ - USHORT Length; - UCHAR TLVType; // QCTLV_TYPE_REQUIRED_PARAMETER - USHORT TLVLength; // 1 - UCHAR QMIType; // QMUX type -} __attribute__((packed)) QMICTL_GET_CLIENT_ID_REQ_MSG, - *PQMICTL_GET_CLIENT_ID_REQ_MSG; - -typedef struct _QMICTL_GET_CLIENT_ID_RESP_MSG { - UCHAR CtlFlags; // QMICTL_FLAG_RESPONSE - UCHAR TransactionId; - USHORT QMICTLType; // QMICTL_GET_CLIENT_ID_RESP - USHORT Length; - UCHAR TLVType; // QCTLV_TYPE_RESULT_CODE - USHORT TLVLength; // 0x0004 - USHORT QMIResult; // result code - USHORT QMIError; // error code - UCHAR TLV2Type; // QCTLV_TYPE_REQUIRED_PARAMETER - USHORT TLV2Length; // 2 - UCHAR QMIType; - UCHAR ClientId; -} __attribute__((packed)) QMICTL_GET_CLIENT_ID_RESP_MSG, - *PQMICTL_GET_CLIENT_ID_RESP_MSG; - -typedef struct _QMICTL_RELEASE_CLIENT_ID_REQ_MSG { - UCHAR CtlFlags; // QMICTL_FLAG_REQUEST - UCHAR TransactionId; - USHORT QMICTLType; // QMICTL_RELEASE_CLIENT_ID_REQ - USHORT Length; - UCHAR TLVType; // QCTLV_TYPE_REQUIRED_PARAMETER - USHORT TLVLength; // 0x0002 - UCHAR QMIType; - UCHAR ClientId; -} __attribute__((packed)) QMICTL_RELEASE_CLIENT_ID_REQ_MSG, - *PQMICTL_RELEASE_CLIENT_ID_REQ_MSG; - -typedef struct _QMICTL_RELEASE_CLIENT_ID_RESP_MSG { - UCHAR CtlFlags; // QMICTL_FLAG_RESPONSE - UCHAR TransactionId; - USHORT QMICTLType; // QMICTL_RELEASE_CLIENT_ID_RESP - USHORT Length; - UCHAR TLVType; // QCTLV_TYPE_RESULT_CODE - USHORT TLVLength; // 0x0004 - USHORT QMIResult; // result code - USHORT QMIError; // error code - UCHAR TLV2Type; // QCTLV_TYPE_REQUIRED_PARAMETER - USHORT TLV2Length; // 2 - UCHAR QMIType; - UCHAR ClientId; -} __attribute__((packed)) QMICTL_RELEASE_CLIENT_ID_RESP_MSG, - *PQMICTL_RELEASE_CLIENT_ID_RESP_MSG; - -typedef struct _QMICTL_REVOKE_CLIENT_ID_IND_MSG { - UCHAR CtlFlags; // QMICTL_FLAG_INDICATION - UCHAR TransactionId; - USHORT QMICTLType; // QMICTL_REVOKE_CLIENT_ID_IND - USHORT Length; - UCHAR TLVType; // QCTLV_TYPE_REQUIRED_PARAMETER - USHORT TLVLength; // 0x0002 - UCHAR QMIType; - UCHAR ClientId; -} __attribute__((packed)) QMICTL_REVOKE_CLIENT_ID_IND_MSG, - *PQMICTL_REVOKE_CLIENT_ID_IND_MSG; - -typedef struct _QMICTL_INVALID_CLIENT_ID_IND_MSG { - UCHAR CtlFlags; // QMICTL_FLAG_INDICATION - UCHAR TransactionId; - USHORT QMICTLType; // QMICTL_REVOKE_CLIENT_ID_IND - USHORT Length; - UCHAR TLVType; // QCTLV_TYPE_REQUIRED_PARAMETER - USHORT TLVLength; // 0x0002 - UCHAR QMIType; - UCHAR ClientId; -} __attribute__((packed)) QMICTL_INVALID_CLIENT_ID_IND_MSG, - *PQMICTL_INVALID_CLIENT_ID_IND_MSG; - -typedef struct _QMICTL_SET_DATA_FORMAT_REQ_MSG { - UCHAR CtlFlags; // QMICTL_FLAG_REQUEST - UCHAR TransactionId; - USHORT QMICTLType; // QMICTL_SET_DATA_FORMAT_REQ - USHORT Length; - UCHAR TLVType; // QCTLV_TYPE_REQUIRED_PARAMETER - USHORT TLVLength; // 1 - UCHAR DataFormat; // 0-default; 1-QoS hdr present -} __attribute__((packed)) QMICTL_SET_DATA_FORMAT_REQ_MSG, - *PQMICTL_SET_DATA_FORMAT_REQ_MSG; - -#ifdef QC_IP_MODE -#define SET_DATA_FORMAT_TLV_TYPE_LINK_PROTO 0x10 -#define SET_DATA_FORMAT_LINK_PROTO_ETH 0x0001 -#define SET_DATA_FORMAT_LINK_PROTO_IP 0x0002 -typedef struct _QMICTL_SET_DATA_FORMAT_TLV_LINK_PROT { - UCHAR TLVType; // Link-Layer Protocol - USHORT TLVLength; // 2 - USHORT LinkProt; // 0x1: ETH; 0x2: IP -} QMICTL_SET_DATA_FORMAT_TLV_LINK_PROT, *PQMICTL_SET_DATA_FORMAT_TLV_LINK_PROT; - -#ifdef QCMP_UL_TLP -#define SET_DATA_FORMAT_TLV_TYPE_UL_TLP 0x11 -typedef struct _QMICTL_SET_DATA_FORMAT_TLV_UL_TLP { - UCHAR TLVType; // 0x11, Uplink TLP Setting - USHORT TLVLength; // 1 - UCHAR UlTlpSetting; // 0x0: Disable; 0x01: Enable -} QMICTL_SET_DATA_FORMAT_TLV_UL_TLP, *PQMICTL_SET_DATA_FORMAT_TLV_UL_TLP; -#endif // QCMP_UL_TLP - -#ifdef QCMP_DL_TLP -#define SET_DATA_FORMAT_TLV_TYPE_DL_TLP 0x13 -typedef struct _QMICTL_SET_DATA_FORMAT_TLV_DL_TLP { - UCHAR TLVType; // 0x11, Uplink TLP Setting - USHORT TLVLength; // 1 - UCHAR DlTlpSetting; // 0x0: Disable; 0x01: Enable -} QMICTL_SET_DATA_FORMAT_TLV_DL_TLP, *PQMICTL_SET_DATA_FORMAT_TLV_DL_TLP; -#endif // QCMP_DL_TLP - -#endif // QC_IP_MODE - -#ifdef MP_QCQOS_ENABLED -#define SET_DATA_FORMAT_TLV_TYPE_QOS_SETTING 0x12 -typedef struct _QMICTL_SET_DATA_FORMAT_TLV_QOS_SETTING { - UCHAR TLVType; // 0x12, QoS setting - USHORT TLVLength; // 1 - UCHAR QosSetting; // 0x0: Disable; 0x01: Enable -} QMICTL_SET_DATA_FORMAT_TLV_QOS_SETTING, - *PQMICTL_SET_DATA_FORMAT_TLV_QOS_SETTING; -#endif // MP_QCQOS_ENABLED - -typedef struct _QMICTL_SET_DATA_FORMAT_RESP_MSG { - UCHAR CtlFlags; // QMICTL_FLAG_RESPONSE - UCHAR TransactionId; - USHORT QMICTLType; // QMICTL_SET_DATA_FORMAT_RESP - USHORT Length; - UCHAR TLVType; // QCTLV_TYPE_RESULT_CODE - USHORT TLVLength; // 0x0004 - USHORT QMIResult; // result code - USHORT QMIError; // error code -} __attribute__((packed)) QMICTL_SET_DATA_FORMAT_RESP_MSG, - *PQMICTL_SET_DATA_FORMAT_RESP_MSG; - -typedef struct _QMICTL_SYNC_REQ_MSG { - UCHAR CtlFlags; // QMICTL_FLAG_REQUEST - UCHAR TransactionId; - USHORT QMICTLType; // QMICTL_CTL_SYNC_REQ - USHORT Length; // 0 -} __attribute__((packed)) QMICTL_SYNC_REQ_MSG, *PQMICTL_SYNC_REQ_MSG; - -typedef struct _QMICTL_SYNC_RESP_MSG { - UCHAR CtlFlags; // QMICTL_FLAG_RESPONSE - UCHAR TransactionId; - USHORT QMICTLType; // QMICTL_CTL_SYNC_RESP - USHORT Length; - UCHAR TLVType; // QCTLV_TYPE_RESULT_CODE - USHORT TLVLength; // 0x0004 - USHORT QMIResult; - USHORT QMIError; -} __attribute__((packed)) QMICTL_SYNC_RESP_MSG, *PQMICTL_SYNC_RESP_MSG; - -typedef struct _QMICTL_SYNC_IND_MSG { - UCHAR CtlFlags; // QMICTL_FLAG_INDICATION - UCHAR TransactionId; - USHORT QMICTLType; // QMICTL_REVOKE_CLIENT_ID_IND - USHORT Length; -} __attribute__((packed)) QMICTL_SYNC_IND_MSG, *PQMICTL_SYNC_IND_MSG; - -typedef struct _QMICTL_MSG { - union { - // Message Header - QCQMICTL_MSG_HDR QMICTLMsgHdr; - QCQMICTL_MSG_HDR_RESP QMICTLMsgHdrRsp; - - // QMICTL Message - QMICTL_SET_INSTANCE_ID_REQ_MSG SetInstanceIdReq; - QMICTL_SET_INSTANCE_ID_RESP_MSG SetInstanceIdRsp; - QMICTL_GET_VERSION_REQ_MSG GetVersionReq; - QMICTL_GET_VERSION_RESP_MSG GetVersionRsp; - QMICTL_GET_CLIENT_ID_REQ_MSG GetClientIdReq; - QMICTL_GET_CLIENT_ID_RESP_MSG GetClientIdRsp; - QMICTL_RELEASE_CLIENT_ID_REQ_MSG ReleaseClientIdReq; - QMICTL_RELEASE_CLIENT_ID_RESP_MSG ReleaseClientIdRsp; - QMICTL_REVOKE_CLIENT_ID_IND_MSG RevokeClientIdInd; - QMICTL_INVALID_CLIENT_ID_IND_MSG InvalidClientIdInd; - QMICTL_SET_DATA_FORMAT_REQ_MSG SetDataFormatReq; - QMICTL_SET_DATA_FORMAT_RESP_MSG SetDataFormatRsp; - QMICTL_SYNC_REQ_MSG SyncReq; - QMICTL_SYNC_RESP_MSG SyncRsp; - QMICTL_SYNC_IND_MSG SyncInd; - }; -} __attribute__((packed)) QMICTL_MSG, *PQMICTL_MSG; - -#endif // MPQCTL_H diff --git a/fibocom-dial/src/MPQMI.h b/fibocom-dial/src/MPQMI.h deleted file mode 100644 index f0063af..0000000 --- a/fibocom-dial/src/MPQMI.h +++ /dev/null @@ -1,287 +0,0 @@ -/*=========================================================================== - - M P Q M I. H -DESCRIPTION: - - This module contains forward references to the QMI module. - -INITIALIZATION AND SEQUENCING REQUIREMENTS: - -Copyright (C) 2011 by Qualcomm Technologies, Incorporated. All Rights Reserved. -===========================================================================*/ -/*=========================================================================== - - EDIT HISTORY FOR FILE - $Header: //depot/QMI/win/qcdrivers/ndis/MPQMI.h#3 $ - -when who what, where, why --------- --- ---------------------------------------------------------- -11/20/04 hg Initial version. -===========================================================================*/ - -#ifndef USBQMI_H -#define USBQMI_H - -typedef char CHAR; -typedef unsigned char UCHAR; -typedef unsigned short USHORT; -typedef int INT; -typedef unsigned int UINT; -typedef long LONG; -typedef unsigned int ULONG; -typedef unsigned long long ULONG64; -typedef char *PCHAR; -typedef unsigned char *PUCHAR; -typedef int *PINT; -typedef int BOOL; - -#define TRUE (1 == 1) -#define FALSE (1 != 1) - -#define QMICTL_SUPPORTED_MAJOR_VERSION 1 -#define QMICTL_SUPPORTED_MINOR_VERSION 0 - -#pragma pack(push, 1) - -// ========= USB Control Message ========== - -#define USB_CTL_MSG_TYPE_QMI 0x01 - -// USB Control Message -typedef struct _QCUSB_CTL_MSG_HDR { - UCHAR IFType; -} __attribute__((packed)) QCUSB_CTL_MSG_HDR, *PQCUSB_CTL_MSG_HDR; - -#define QCUSB_CTL_MSG_HDR_SIZE sizeof(QCUSB_CTL_MSG_HDR) - -typedef struct _QCUSB_CTL_MSG { - UCHAR IFType; - UCHAR Message; -} __attribute__((packed)) QCUSB_CTL_MSG, *PQCUSB_CTL_MSG; - -#define QCTLV_TYPE_REQUIRED_PARAMETER 0x01 -#define QCTLV_TYPE_RESULT_CODE 0x02 - -// ================= QMI ================== - -// Define QMI Type -typedef enum _QMI_SERVICE_TYPE { - QMUX_TYPE_CTL = 0x00, - QMUX_TYPE_WDS = 0x01, - QMUX_TYPE_DMS = 0x02, - QMUX_TYPE_NAS = 0x03, - QMUX_TYPE_QOS = 0x04, - QMUX_TYPE_WMS = 0x05, - QMUX_TYPE_PDS = 0x06, - QMUX_TYPE_UIM = 0x0B, - QMUX_TYPE_WDS_IPV6 = 0x11, - QMUX_TYPE_WDS_ADMIN = 0x1A, - QMUX_TYPE_MAX = 0xFF, - QMUX_TYPE_ALL = 0xFF -} QMI_SERVICE_TYPE; - -typedef enum _QMI_RESULT_CODE_TYPE { - QMI_RESULT_SUCCESS = 0x0000, - QMI_RESULT_FAILURE = 0x0001 -} QMI_RESULT_CODE_TYPE; - -typedef enum _QMI_ERROR_CODE_TYPE { - QMI_ERR_NONE = 0x0000, - QMI_ERR_MALFORMED_MSG = 0x0001, - QMI_ERR_NO_MEMORY = 0x0002, - QMI_ERR_INTERNAL = 0x0003, - QMI_ERR_ABORTED = 0x0004, - QMI_ERR_CLIENT_IDS_EXHAUSTED = 0x0005, - QMI_ERR_UNABORTABLE_TRANSACTION = 0x0006, - QMI_ERR_INVALID_CLIENT_ID = 0x0007, - QMI_ERR_NO_THRESHOLDS = 0x0008, - QMI_ERR_INVALID_HANDLE = 0x0009, - QMI_ERR_INVALID_PROFILE = 0x000A, - QMI_ERR_INVALID_PINID = 0x000B, - QMI_ERR_INCORRECT_PIN = 0x000C, - QMI_ERR_NO_NETWORK_FOUND = 0x000D, - QMI_ERR_CALL_FAILED = 0x000E, - QMI_ERR_OUT_OF_CALL = 0x000F, - QMI_ERR_NOT_PROVISIONED = 0x0010, - QMI_ERR_MISSING_ARG = 0x0011, - QMI_ERR_ARG_TOO_LONG = 0x0013, - QMI_ERR_INVALID_TX_ID = 0x0016, - QMI_ERR_DEVICE_IN_USE = 0x0017, - QMI_ERR_OP_NETWORK_UNSUPPORTED = 0x0018, - QMI_ERR_OP_DEVICE_UNSUPPORTED = 0x0019, - QMI_ERR_NO_EFFECT = 0x001A, - QMI_ERR_NO_FREE_PROFILE = 0x001B, - QMI_ERR_INVALID_PDP_TYPE = 0x001C, - QMI_ERR_INVALID_TECH_PREF = 0x001D, - QMI_ERR_INVALID_PROFILE_TYPE = 0x001E, - QMI_ERR_INVALID_SERVICE_TYPE = 0x001F, - QMI_ERR_INVALID_REGISTER_ACTION = 0x0020, - QMI_ERR_INVALID_PS_ATTACH_ACTION = 0x0021, - QMI_ERR_AUTHENTICATION_FAILED = 0x0022, - QMI_ERR_PIN_BLOCKED = 0x0023, - QMI_ERR_PIN_PERM_BLOCKED = 0x0024, - QMI_ERR_SIM_NOT_INITIALIZED = 0x0025, - QMI_ERR_MAX_QOS_REQUESTS_IN_USE = 0x0026, - QMI_ERR_INCORRECT_FLOW_FILTER = 0x0027, - QMI_ERR_NETWORK_QOS_UNAWARE = 0x0028, - QMI_ERR_INVALID_QOS_ID = 0x0029, - QMI_ERR_INVALID_ID = 0x0029, - QMI_ERR_REQUESTED_NUM_UNSUPPORTED = 0x002A, - QMI_ERR_INTERFACE_NOT_FOUND = 0x002B, - QMI_ERR_FLOW_SUSPENDED = 0x002C, - QMI_ERR_INVALID_DATA_FORMAT = 0x002D, - QMI_ERR_GENERAL = 0x002E, - QMI_ERR_UNKNOWN = 0x002F, - QMI_ERR_INVALID_ARG = 0x0030, - QMI_ERR_INVALID_INDEX = 0x0031, - QMI_ERR_NO_ENTRY = 0x0032, - QMI_ERR_DEVICE_STORAGE_FULL = 0x0033, - QMI_ERR_DEVICE_NOT_READY = 0x0034, - QMI_ERR_NETWORK_NOT_READY = 0x0035, - QMI_ERR_CAUSE_CODE = 0x0036, - QMI_ERR_MESSAGE_NOT_SENT = 0x0037, - QMI_ERR_MESSAGE_DELIVERY_FAILURE = 0x0038, - QMI_ERR_INVALID_MESSAGE_ID = 0x0039, - QMI_ERR_ENCODING = 0x003A, - QMI_ERR_AUTHENTICATION_LOCK = 0x003B, - QMI_ERR_INVALID_TRANSITION = 0x003C, - QMI_ERR_NOT_A_MCAST_IFACE = 0x003D, - QMI_ERR_MAX_MCAST_REQUESTS_IN_USE = 0x003E, - QMI_ERR_INVALID_MCAST_HANDLE = 0x003F, - QMI_ERR_INVALID_IP_FAMILY_PREF = 0x0040, - QMI_ERR_SESSION_INACTIVE = 0x0041, - QMI_ERR_SESSION_INVALID = 0x0042, - QMI_ERR_SESSION_OWNERSHIP = 0x0043, - QMI_ERR_INSUFFICIENT_RESOURCES = 0x0044, - QMI_ERR_DISABLED = 0x0045, - QMI_ERR_INVALID_OPERATION = 0x0046, - QMI_ERR_INVALID_QMI_CMD = 0x0047, - QMI_ERR_TPDU_TYPE = 0x0048, - QMI_ERR_SMSC_ADDR = 0x0049, - QMI_ERR_INFO_UNAVAILABLE = 0x004A, - QMI_ERR_SEGMENT_TOO_LONG = 0x004B, - QMI_ERR_SEGMENT_ORDER = 0x004C, - QMI_ERR_BUNDLING_NOT_SUPPORTED = 0x004D, - QMI_ERR_OP_PARTIAL_FAILURE = 0x004E, - QMI_ERR_POLICY_MISMATCH = 0x004F, - QMI_ERR_SIM_FILE_NOT_FOUND = 0x0050, - QMI_ERR_EXTENDED_INTERNAL = 0x0051, - QMI_ERR_ACCESS_DENIED = 0x0052, - QMI_ERR_HARDWARE_RESTRICTED = 0x0053, - QMI_ERR_ACK_NOT_SENT = 0x0054, - QMI_ERR_INJECT_TIMEOUT = 0x0055, - QMI_ERR_INCOMPATIBLE_STATE = 0x005A, - QMI_ERR_FDN_RESTRICT = 0x005B, - QMI_ERR_SUPS_FAILURE_CAUSE = 0x005C, - QMI_ERR_NO_RADIO = 0x005D, - QMI_ERR_NOT_SUPPORTED = 0x005E, - QMI_ERR_NO_SUBSCRIPTION = 0x005F, - QMI_ERR_CARD_CALL_CONTROL_FAILED = 0x0060, - QMI_ERR_NETWORK_ABORTED = 0x0061, - QMI_ERR_MSG_BLOCKED = 0x0062, - QMI_ERR_INVALID_SESSION_TYPE = 0x0064, - QMI_ERR_INVALID_PB_TYPE = 0x0065, - QMI_ERR_NO_SIM = 0x0066, - QMI_ERR_PB_NOT_READY = 0x0067, - QMI_ERR_PIN_RESTRICTION = 0x0068, - QMI_ERR_PIN2_RESTRICTION = 0x0069, - QMI_ERR_PUK_RESTRICTION = 0x006A, - QMI_ERR_PUK2_RESTRICTION = 0x006B, - QMI_ERR_PB_ACCESS_RESTRICTED = 0x006C, - QMI_ERR_PB_DELETE_IN_PROG = 0x006D, - QMI_ERR_PB_TEXT_TOO_LONG = 0x006E, - QMI_ERR_PB_NUMBER_TOO_LONG = 0x006F, - QMI_ERR_PB_HIDDEN_KEY_RESTRICTION = 0x0070 -} QMI_ERROR_CODE_TYPE; - -#define QCQMI_CTL_FLAG_SERVICE 0x80 -#define QCQMI_CTL_FLAG_CTL_POINT 0x00 - -typedef struct _QCQMI_HDR { - UCHAR IFType; - USHORT Length; - UCHAR CtlFlags; // reserved - UCHAR QMIType; - UCHAR ClientId; -} __attribute__((packed)) QCQMI_HDR, *PQCQMI_HDR; - -#define QCQMI_HDR_SIZE (sizeof(QCQMI_HDR) - 1) - -typedef struct _QCQMI { - UCHAR IFType; - USHORT Length; - UCHAR CtlFlags; // reserved - UCHAR QMIType; - UCHAR ClientId; - UCHAR SDU; -} __attribute__((packed)) QCQMI, *PQCQMI; - -typedef struct _QMI_SERVICE_VERSION { - USHORT Major; - USHORT Minor; - USHORT AddendumMajor; - USHORT AddendumMinor; -} __attribute__((packed)) QMI_SERVICE_VERSION, *PQMI_SERVICE_VERSION; - -// ================= QMUX ================== - -#define QMUX_MSG_OVERHEAD_BYTES 4 // Type(USHORT) Length(USHORT) -- header - -#define QMUX_BROADCAST_CID 0xFF - -typedef struct _QCQMUX_HDR { - UCHAR CtlFlags; // 0: single QMUX Msg; 1: - USHORT TransactionId; -} __attribute__((packed)) QCQMUX_HDR, *PQCQMUX_HDR; - -typedef struct _QCQMUX { - UCHAR CtlFlags; // 0: single QMUX Msg; 1: - USHORT TransactionId; - UCHAR Message; // Type(2), Length(2), Value -} __attribute__((packed)) QCQMUX, *PQCQMUX; - -#define QCQMUX_HDR_SIZE sizeof(QCQMUX_HDR) - -typedef struct _QCQMUX_MSG_HDR { - USHORT Type; - USHORT Length; -} __attribute__((packed)) QCQMUX_MSG_HDR, *PQCQMUX_MSG_HDR; - -#define QCQMUX_MSG_HDR_SIZE sizeof(QCQMUX_MSG_HDR) - -typedef struct _QCQMUX_MSG_HDR_RESP { - USHORT Type; - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT -} __attribute__((packed)) QCQMUX_MSG_HDR_RESP, *PQCQMUX_MSG_HDR_RESP; - -typedef struct _QCQMUX_TLV { - UCHAR Type; - USHORT Length; - UCHAR Value; -} __attribute__((packed)) QCQMUX_TLV, *PQCQMUX_TLV; - -typedef struct _QMI_TLV_HDR { - UCHAR TLVType; - USHORT TLVLength; -} __attribute__((packed)) QMI_TLV_HDR, *PQMI_TLV_HDR; - -// QMUX Message Definitions -- QMI SDU -#define QMUX_CTL_FLAG_SINGLE_MSG 0x00 -#define QMUX_CTL_FLAG_COMPOUND_MSG 0x01 -#define QMUX_CTL_FLAG_TYPE_CMD 0x00 -#define QMUX_CTL_FLAG_TYPE_RSP 0x02 -#define QMUX_CTL_FLAG_TYPE_IND 0x04 -#define QMUX_CTL_FLAG_MASK_COMPOUND 0x01 -#define QMUX_CTL_FLAG_MASK_TYPE 0x06 // 00-cmd, 01-rsp, 10-ind - -#pragma pack(pop) - -#endif // USBQMI_H diff --git a/fibocom-dial/src/MPQMUX.c b/fibocom-dial/src/MPQMUX.c deleted file mode 100644 index 2fd59e5..0000000 --- a/fibocom-dial/src/MPQMUX.c +++ /dev/null @@ -1,437 +0,0 @@ -#include "QMIThread.h" -static char line[1024]; -static pthread_mutex_t dumpQMIMutex = PTHREAD_MUTEX_INITIALIZER; -#undef dbg -#define dbg(format, arg...) \ - do { \ - if (strlen(line) < sizeof(line)) \ - snprintf(&line[strlen(line)], sizeof(line) - strlen(line), format, \ - ##arg); \ - } while (0) - -PQMI_TLV_HDR GetTLV(PQCQMUX_MSG_HDR pQMUXMsgHdr, int TLVType); - -typedef struct { - UINT type; - const char *name; -} QMI_NAME_T; - -#define qmi_name_item(type) \ - { \ - type, #type \ - } - -static const QMI_NAME_T qmux_ctl_QMICTLType[] = { - // QMICTL Type - qmi_name_item(QMICTL_SET_INSTANCE_ID_REQ), // 0x0020 - qmi_name_item(QMICTL_SET_INSTANCE_ID_RESP), // 0x0020 - qmi_name_item(QMICTL_GET_VERSION_REQ), // 0x0021 - qmi_name_item(QMICTL_GET_VERSION_RESP), // 0x0021 - qmi_name_item(QMICTL_GET_CLIENT_ID_REQ), // 0x0022 - qmi_name_item(QMICTL_GET_CLIENT_ID_RESP), // 0x0022 - qmi_name_item(QMICTL_RELEASE_CLIENT_ID_REQ), // 0x0023 - qmi_name_item(QMICTL_RELEASE_CLIENT_ID_RESP), // 0x0023 - qmi_name_item(QMICTL_REVOKE_CLIENT_ID_IND), // 0x0024 - qmi_name_item(QMICTL_INVALID_CLIENT_ID_IND), // 0x0025 - qmi_name_item(QMICTL_SET_DATA_FORMAT_REQ), // 0x0026 - qmi_name_item(QMICTL_SET_DATA_FORMAT_RESP), // 0x0026 - qmi_name_item(QMICTL_SYNC_REQ), // 0x0027 - qmi_name_item(QMICTL_SYNC_RESP), // 0x0027 - qmi_name_item(QMICTL_SYNC_IND), // 0x0027 -}; - -static const QMI_NAME_T qmux_CtlFlags[] = { - qmi_name_item(QMUX_CTL_FLAG_TYPE_CMD), - qmi_name_item(QMUX_CTL_FLAG_TYPE_RSP), - qmi_name_item(QMUX_CTL_FLAG_TYPE_IND), -}; - -static const QMI_NAME_T qmux_wds_Type[] = { - qmi_name_item(QMIWDS_SET_EVENT_REPORT_REQ), // 0x0001 - qmi_name_item(QMIWDS_SET_EVENT_REPORT_RESP), // 0x0001 - qmi_name_item(QMIWDS_EVENT_REPORT_IND), // 0x0001 - qmi_name_item(QMIWDS_START_NETWORK_INTERFACE_REQ), // 0x0020 - qmi_name_item(QMIWDS_START_NETWORK_INTERFACE_RESP), // 0x0020 - qmi_name_item(QMIWDS_STOP_NETWORK_INTERFACE_REQ), // 0x0021 - qmi_name_item(QMIWDS_STOP_NETWORK_INTERFACE_RESP), // 0x0021 - qmi_name_item(QMIWDS_GET_PKT_SRVC_STATUS_REQ), // 0x0022 - qmi_name_item(QMIWDS_GET_PKT_SRVC_STATUS_RESP), // 0x0022 - qmi_name_item(QMIWDS_GET_PKT_SRVC_STATUS_IND), // 0x0022 - qmi_name_item(QMIWDS_GET_CURRENT_CHANNEL_RATE_REQ), // 0x0023 - qmi_name_item(QMIWDS_GET_CURRENT_CHANNEL_RATE_RESP), // 0x0023 - qmi_name_item(QMIWDS_GET_PKT_STATISTICS_REQ), // 0x0024 - qmi_name_item(QMIWDS_GET_PKT_STATISTICS_RESP), // 0x0024 -//begin modified by zhangkaibo add create profile qmi. mantis 0049137,0048741 20200610 - qmi_name_item(QMIWDS_CREATE_PROFILE_SETTINGS_REQ), // 0x0027 - qmi_name_item(QMIWDS_CREATE_PROFILE_SETTINGS_RESP), // 0x0027 -//end modified by zhangkaibo add create profile qmi. mantis 0049137,0048741 20200610 - qmi_name_item(QMIWDS_MODIFY_PROFILE_SETTINGS_REQ), // 0x0028 - qmi_name_item(QMIWDS_MODIFY_PROFILE_SETTINGS_RESP), // 0x0028 - qmi_name_item(QMIWDS_GET_PROFILE_SETTINGS_REQ), // 0x002B - qmi_name_item(QMIWDS_GET_PROFILE_SETTINGS_RESP), // 0x002BD - qmi_name_item(QMIWDS_GET_DEFAULT_SETTINGS_REQ), // 0x002C - qmi_name_item(QMIWDS_GET_DEFAULT_SETTINGS_RESP), // 0x002C - qmi_name_item(QMIWDS_GET_RUNTIME_SETTINGS_REQ), // 0x002D - qmi_name_item(QMIWDS_GET_RUNTIME_SETTINGS_RESP), // 0x002D - qmi_name_item(QMIWDS_GET_MIP_MODE_REQ), // 0x002F - qmi_name_item(QMIWDS_GET_MIP_MODE_RESP), // 0x002F - qmi_name_item(QMIWDS_GET_DATA_BEARER_REQ), // 0x0037 - qmi_name_item(QMIWDS_GET_DATA_BEARER_RESP), // 0x0037 - qmi_name_item(QMIWDS_DUN_CALL_INFO_REQ), // 0x0038 - qmi_name_item(QMIWDS_DUN_CALL_INFO_RESP), // 0x0038 - qmi_name_item(QMIWDS_DUN_CALL_INFO_IND), // 0x0038 - qmi_name_item(QMIWDS_SET_CLIENT_IP_FAMILY_PREF_REQ), // 0x004D - qmi_name_item(QMIWDS_SET_CLIENT_IP_FAMILY_PREF_RESP), // 0x004D - qmi_name_item(QMIWDS_SET_AUTO_CONNECT_REQ), // 0x0051 - qmi_name_item(QMIWDS_SET_AUTO_CONNECT_RESP), // 0x0051 - qmi_name_item(QMIWDS_BIND_MUX_DATA_PORT_REQ), // 0x00A2 - qmi_name_item(QMIWDS_BIND_MUX_DATA_PORT_RESP), // 0x00A2 -}; - -static const QMI_NAME_T qmux_dms_Type[] = { - // ======================= DMS ============================== - qmi_name_item(QMIDMS_SET_EVENT_REPORT_REQ), // 0x0001 - qmi_name_item(QMIDMS_SET_EVENT_REPORT_RESP), // 0x0001 - qmi_name_item(QMIDMS_EVENT_REPORT_IND), // 0x0001 - qmi_name_item(QMIDMS_GET_DEVICE_CAP_REQ), // 0x0020 - qmi_name_item(QMIDMS_GET_DEVICE_CAP_RESP), // 0x0020 - qmi_name_item(QMIDMS_GET_DEVICE_MFR_REQ), // 0x0021 - qmi_name_item(QMIDMS_GET_DEVICE_MFR_RESP), // 0x0021 - qmi_name_item(QMIDMS_GET_DEVICE_MODEL_ID_REQ), // 0x0022 - qmi_name_item(QMIDMS_GET_DEVICE_MODEL_ID_RESP), // 0x0022 - qmi_name_item(QMIDMS_GET_DEVICE_REV_ID_REQ), // 0x0023 - qmi_name_item(QMIDMS_GET_DEVICE_REV_ID_RESP), // 0x0023 - qmi_name_item(QMIDMS_GET_MSISDN_REQ), // 0x0024 - qmi_name_item(QMIDMS_GET_MSISDN_RESP), // 0x0024 - qmi_name_item(QMIDMS_GET_DEVICE_SERIAL_NUMBERS_REQ), // 0x0025 - qmi_name_item(QMIDMS_GET_DEVICE_SERIAL_NUMBERS_RESP), // 0x0025 - qmi_name_item(QMIDMS_UIM_SET_PIN_PROTECTION_REQ), // 0x0027 - qmi_name_item(QMIDMS_UIM_SET_PIN_PROTECTION_RESP), // 0x0027 - qmi_name_item(QMIDMS_UIM_VERIFY_PIN_REQ), // 0x0028 - qmi_name_item(QMIDMS_UIM_VERIFY_PIN_RESP), // 0x0028 - qmi_name_item(QMIDMS_UIM_UNBLOCK_PIN_REQ), // 0x0029 - qmi_name_item(QMIDMS_UIM_UNBLOCK_PIN_RESP), // 0x0029 - qmi_name_item(QMIDMS_UIM_CHANGE_PIN_REQ), // 0x002A - qmi_name_item(QMIDMS_UIM_CHANGE_PIN_RESP), // 0x002A - qmi_name_item(QMIDMS_UIM_GET_PIN_STATUS_REQ), // 0x002B - qmi_name_item(QMIDMS_UIM_GET_PIN_STATUS_RESP), // 0x002B - qmi_name_item(QMIDMS_GET_DEVICE_HARDWARE_REV_REQ), // 0x002C - qmi_name_item(QMIDMS_GET_DEVICE_HARDWARE_REV_RESP), // 0x002C - qmi_name_item(QMIDMS_GET_OPERATING_MODE_REQ), // 0x002D - qmi_name_item(QMIDMS_GET_OPERATING_MODE_RESP), // 0x002D - qmi_name_item(QMIDMS_SET_OPERATING_MODE_REQ), // 0x002E - qmi_name_item(QMIDMS_SET_OPERATING_MODE_RESP), // 0x002E - qmi_name_item(QMIDMS_GET_ACTIVATED_STATUS_REQ), // 0x0031 - qmi_name_item(QMIDMS_GET_ACTIVATED_STATUS_RESP), // 0x0031 - qmi_name_item(QMIDMS_ACTIVATE_AUTOMATIC_REQ), // 0x0032 - qmi_name_item(QMIDMS_ACTIVATE_AUTOMATIC_RESP), // 0x0032 - qmi_name_item(QMIDMS_ACTIVATE_MANUAL_REQ), // 0x0033 - qmi_name_item(QMIDMS_ACTIVATE_MANUAL_RESP), // 0x0033 - qmi_name_item(QMIDMS_UIM_GET_ICCID_REQ), // 0x003C - qmi_name_item(QMIDMS_UIM_GET_ICCID_RESP), // 0x003C - qmi_name_item(QMIDMS_UIM_GET_CK_STATUS_REQ), // 0x0040 - qmi_name_item(QMIDMS_UIM_GET_CK_STATUS_RESP), // 0x0040 - qmi_name_item(QMIDMS_UIM_SET_CK_PROTECTION_REQ), // 0x0041 - qmi_name_item(QMIDMS_UIM_SET_CK_PROTECTION_RESP), // 0x0041 - qmi_name_item(QMIDMS_UIM_UNBLOCK_CK_REQ), // 0x0042 - qmi_name_item(QMIDMS_UIM_UNBLOCK_CK_RESP), // 0x0042 - qmi_name_item(QMIDMS_UIM_GET_IMSI_REQ), // 0x0043 - qmi_name_item(QMIDMS_UIM_GET_IMSI_RESP), // 0x0043 - qmi_name_item(QMIDMS_UIM_GET_STATE_REQ), // 0x0044 - qmi_name_item(QMIDMS_UIM_GET_STATE_RESP), // 0x0044 - qmi_name_item(QMIDMS_GET_BAND_CAP_REQ), // 0x0045 - qmi_name_item(QMIDMS_GET_BAND_CAP_RESP), // 0x0045 -}; - -static const QMI_NAME_T qmux_nas_Type[] = { - // ======================= NAS ============================== - qmi_name_item(QMINAS_SET_EVENT_REPORT_REQ), // 0x0002 - qmi_name_item(QMINAS_SET_EVENT_REPORT_RESP), // 0x0002 - qmi_name_item(QMINAS_EVENT_REPORT_IND), // 0x0002 - qmi_name_item(QMINAS_GET_SIGNAL_STRENGTH_REQ), // 0x0020 - qmi_name_item(QMINAS_GET_SIGNAL_STRENGTH_RESP), // 0x0020 - qmi_name_item(QMINAS_PERFORM_NETWORK_SCAN_REQ), // 0x0021 - qmi_name_item(QMINAS_PERFORM_NETWORK_SCAN_RESP), // 0x0021 - qmi_name_item(QMINAS_INITIATE_NW_REGISTER_REQ), // 0x0022 - qmi_name_item(QMINAS_INITIATE_NW_REGISTER_RESP), // 0x0022 - qmi_name_item(QMINAS_INITIATE_ATTACH_REQ), // 0x0023 - qmi_name_item(QMINAS_INITIATE_ATTACH_RESP), // 0x0023 - qmi_name_item(QMINAS_GET_SERVING_SYSTEM_REQ), // 0x0024 - qmi_name_item(QMINAS_GET_SERVING_SYSTEM_RESP), // 0x0024 - qmi_name_item(QMINAS_SERVING_SYSTEM_IND), // 0x0024 - qmi_name_item(QMINAS_GET_HOME_NETWORK_REQ), // 0x0025 - qmi_name_item(QMINAS_GET_HOME_NETWORK_RESP), // 0x0025 - qmi_name_item(QMINAS_GET_PREFERRED_NETWORK_REQ), // 0x0026 - qmi_name_item(QMINAS_GET_PREFERRED_NETWORK_RESP), // 0x0026 - qmi_name_item(QMINAS_SET_PREFERRED_NETWORK_REQ), // 0x0027 - qmi_name_item(QMINAS_SET_PREFERRED_NETWORK_RESP), // 0x0027 - qmi_name_item(QMINAS_GET_FORBIDDEN_NETWORK_REQ), // 0x0028 - qmi_name_item(QMINAS_GET_FORBIDDEN_NETWORK_RESP), // 0x0028 - qmi_name_item(QMINAS_SET_FORBIDDEN_NETWORK_REQ), // 0x0029 - qmi_name_item(QMINAS_SET_FORBIDDEN_NETWORK_RESP), // 0x0029 - qmi_name_item(QMINAS_SET_TECHNOLOGY_PREF_REQ), // 0x002A - qmi_name_item(QMINAS_SET_TECHNOLOGY_PREF_RESP), // 0x002A - qmi_name_item(QMINAS_GET_RF_BAND_INFO_REQ), // 0x0031 - qmi_name_item(QMINAS_GET_RF_BAND_INFO_RESP), // 0x0031 - qmi_name_item(QMINAS_GET_PLMN_NAME_REQ), // 0x0044 - qmi_name_item(QMINAS_GET_PLMN_NAME_RESP), // 0x0044 - qmi_name_item(FIBO_PACKET_TRANSFER_START_IND), // 0X100 - qmi_name_item(FIBO_PACKET_TRANSFER_END_IND), // 0X101 - qmi_name_item(QMINAS_GET_SYS_INFO_REQ), // 0x004D - qmi_name_item(QMINAS_GET_SYS_INFO_RESP), // 0x004D - qmi_name_item(QMINAS_SYS_INFO_IND), // 0x004D -}; - -static const QMI_NAME_T qmux_wms_Type[] = { - // ======================= WMS ============================== - qmi_name_item(QMIWMS_SET_EVENT_REPORT_REQ), // 0x0001 - qmi_name_item(QMIWMS_SET_EVENT_REPORT_RESP), // 0x0001 - qmi_name_item(QMIWMS_EVENT_REPORT_IND), // 0x0001 - qmi_name_item(QMIWMS_RAW_SEND_REQ), // 0x0020 - qmi_name_item(QMIWMS_RAW_SEND_RESP), // 0x0020 - qmi_name_item(QMIWMS_RAW_WRITE_REQ), // 0x0021 - qmi_name_item(QMIWMS_RAW_WRITE_RESP), // 0x0021 - qmi_name_item(QMIWMS_RAW_READ_REQ), // 0x0022 - qmi_name_item(QMIWMS_RAW_READ_RESP), // 0x0022 - qmi_name_item(QMIWMS_MODIFY_TAG_REQ), // 0x0023 - qmi_name_item(QMIWMS_MODIFY_TAG_RESP), // 0x0023 - qmi_name_item(QMIWMS_DELETE_REQ), // 0x0024 - qmi_name_item(QMIWMS_DELETE_RESP), // 0x0024 - qmi_name_item(QMIWMS_GET_MESSAGE_PROTOCOL_REQ), // 0x0030 - qmi_name_item(QMIWMS_GET_MESSAGE_PROTOCOL_RESP), // 0x0030 - qmi_name_item(QMIWMS_LIST_MESSAGES_REQ), // 0x0031 - qmi_name_item(QMIWMS_LIST_MESSAGES_RESP), // 0x0031 - qmi_name_item(QMIWMS_GET_SMSC_ADDRESS_REQ), // 0x0034 - qmi_name_item(QMIWMS_GET_SMSC_ADDRESS_RESP), // 0x0034 - qmi_name_item(QMIWMS_SET_SMSC_ADDRESS_REQ), // 0x0035 - qmi_name_item(QMIWMS_SET_SMSC_ADDRESS_RESP), // 0x0035 - qmi_name_item(QMIWMS_GET_STORE_MAX_SIZE_REQ), // 0x0036 - qmi_name_item(QMIWMS_GET_STORE_MAX_SIZE_RESP), // 0x0036 -}; - -static const QMI_NAME_T qmux_wds_admin_Type[] = { - qmi_name_item(QMIWDS_ADMIN_SET_DATA_FORMAT_REQ), // 0x0020 - qmi_name_item(QMIWDS_ADMIN_SET_DATA_FORMAT_RESP), // 0x0020 - qmi_name_item(QMIWDS_ADMIN_GET_DATA_FORMAT_REQ), // 0x0021 - qmi_name_item(QMIWDS_ADMIN_GET_DATA_FORMAT_RESP), // 0x0021 - qmi_name_item(QMIWDS_ADMIN_SET_QMAP_SETTINGS_REQ), // 0x002B - qmi_name_item(QMIWDS_ADMIN_SET_QMAP_SETTINGS_RESP), // 0x002B - qmi_name_item(QMIWDS_ADMIN_GET_QMAP_SETTINGS_REQ), // 0x002C - qmi_name_item(QMIWDS_ADMIN_GET_QMAP_SETTINGS_RESP), // 0x002C -}; - -static const QMI_NAME_T qmux_uim_Type[] = { - qmi_name_item(QMIUIM_READ_TRANSPARENT_REQ), // 0x0020 - qmi_name_item(QMIUIM_READ_TRANSPARENT_RESP), // 0x0020 - qmi_name_item(QMIUIM_READ_TRANSPARENT_IND), // 0x0020 - qmi_name_item(QMIUIM_READ_RECORD_REQ), // 0x0021 - qmi_name_item(QMIUIM_READ_RECORD_RESP), // 0x0021 - qmi_name_item(QMIUIM_READ_RECORD_IND), // 0x0021 - qmi_name_item(QMIUIM_WRITE_TRANSPARENT_REQ), // 0x0022 - qmi_name_item(QMIUIM_WRITE_TRANSPARENT_RESP), // 0x0022 - qmi_name_item(QMIUIM_WRITE_TRANSPARENT_IND), // 0x0022 - qmi_name_item(QMIUIM_WRITE_RECORD_REQ), // 0x0023 - qmi_name_item(QMIUIM_WRITE_RECORD_RESP), // 0x0023 - qmi_name_item(QMIUIM_WRITE_RECORD_IND), // 0x0023 - qmi_name_item(QMIUIM_SET_PIN_PROTECTION_REQ), // 0x0025 - qmi_name_item(QMIUIM_SET_PIN_PROTECTION_RESP), // 0x0025 - qmi_name_item(QMIUIM_SET_PIN_PROTECTION_IND), // 0x0025 - qmi_name_item(QMIUIM_VERIFY_PIN_REQ), // 0x0026 - qmi_name_item(QMIUIM_VERIFY_PIN_RESP), // 0x0026 - qmi_name_item(QMIUIM_VERIFY_PIN_IND), // 0x0026 - qmi_name_item(QMIUIM_UNBLOCK_PIN_REQ), // 0x0027 - qmi_name_item(QMIUIM_UNBLOCK_PIN_RESP), // 0x0027 - qmi_name_item(QMIUIM_UNBLOCK_PIN_IND), // 0x0027 - qmi_name_item(QMIUIM_CHANGE_PIN_REQ), // 0x0028 - qmi_name_item(QMIUIM_CHANGE_PIN_RESP), // 0x0028 - qmi_name_item(QMIUIM_CHANGE_PIN_IND), // 0x0028 - qmi_name_item(QMIUIM_DEPERSONALIZATION_REQ), // 0x0029 - qmi_name_item(QMIUIM_DEPERSONALIZATION_RESP), // 0x0029 - qmi_name_item(QMIUIM_EVENT_REG_REQ), // 0x002E - qmi_name_item(QMIUIM_EVENT_REG_RESP), // 0x002E - qmi_name_item(QMIUIM_GET_CARD_STATUS_REQ), // 0x002F - qmi_name_item(QMIUIM_GET_CARD_STATUS_RESP), // 0x002F - qmi_name_item(QMIUIM_STATUS_CHANGE_IND), // 0x0032 -}; - -static const char *qmi_name_get(const QMI_NAME_T *table, size_t size, int type, - const char *tag) -{ - static char unknow[40]; - size_t i; - - if (qmux_CtlFlags == table) { - if (!strcmp(tag, "_REQ")) - tag = "_CMD"; - else if (!strcmp(tag, "_RESP")) - tag = "_RSP"; - } - - for (i = 0; i < size; i++) { - if (table[i].type == (UINT)type) { - if (!tag || (strstr(table[i].name, tag))) - return table[i].name; - } - } - sprintf(unknow, "unknow_%x", type); - return unknow; -} - -#define QMI_NAME(table, type) \ - qmi_name_get(table, sizeof(table) / sizeof(table[0]), type, 0) -#define QMUX_NAME(table, type, tag) \ - qmi_name_get(table, sizeof(table) / sizeof(table[0]), type, tag) - -void dump_tlv(PQCQMUX_MSG_HDR pQMUXMsgHdr) -{ - int TLVFind = 0; - int i; - // dbg("QCQMUX_TLV-----------------------------------\n"); - // dbg("{Type,\tLength,\tValue}\n"); - - while (1) { - PQMI_TLV_HDR TLVHdr = GetTLV(pQMUXMsgHdr, 0x1000 + (++TLVFind)); - if (TLVHdr == NULL) - break; - - // if ((TLVHdr->TLVType == 0x02) && ((USHORT *)(TLVHdr+1))[0]) - { - dbg("{%02x,\t%04x,\t", TLVHdr->TLVType, - le16_to_cpu(TLVHdr->TLVLength)); - for (i = 0; i < le16_to_cpu(TLVHdr->TLVLength); i++) { - dbg("%02x ", ((UCHAR *)(TLVHdr + 1))[i]); - } - dbg("}\n"); - } - } // while -} - -void dump_ctl(PQCQMICTL_MSG_HDR CTLHdr) -{ - const char *tag; - - // dbg("QCQMICTL_MSG--------------------------------------------\n"); - // dbg("CtlFlags: %02x\t\t%s\n", CTLHdr->CtlFlags, - // QMI_NAME(qmi_ctl_CtlFlags, CTLHdr->CtlFlags)); - dbg("TransactionId: %02x\n", CTLHdr->TransactionId); - switch (CTLHdr->CtlFlags) { - case QMICTL_FLAG_REQUEST: - tag = "_REQ"; - break; - case QMICTL_FLAG_RESPONSE: - tag = "_RESP"; - break; - case QMICTL_FLAG_INDICATION: - tag = "_IND"; - break; - default: - tag = 0; - break; - } - dbg("QMICTLType: %04x\t%s\n", le16_to_cpu(CTLHdr->QMICTLType), - QMUX_NAME(qmux_ctl_QMICTLType, le16_to_cpu(CTLHdr->QMICTLType), tag)); - dbg("Length: %04x\n", le16_to_cpu(CTLHdr->Length)); - - dump_tlv((PQCQMUX_MSG_HDR)(&CTLHdr->QMICTLType)); -} - -int dump_qmux(QMI_SERVICE_TYPE serviceType, PQCQMUX_HDR QMUXHdr) -{ - PQCQMUX_MSG_HDR QMUXMsgHdr = (PQCQMUX_MSG_HDR)(QMUXHdr + 1); - CHAR *tag; - - // dbg("QCQMUX--------------------------------------------\n"); - switch (QMUXHdr->CtlFlags & QMUX_CTL_FLAG_MASK_TYPE) { - case QMUX_CTL_FLAG_TYPE_CMD: - tag = "_REQ"; - break; - case QMUX_CTL_FLAG_TYPE_RSP: - tag = "_RESP"; - break; - case QMUX_CTL_FLAG_TYPE_IND: - tag = "_IND"; - break; - default: - tag = 0; - break; - } - // dbg("CtlFlags: %02x\t\t%s\n", QMUXHdr->CtlFlags, - // QMUX_NAME(qmux_CtlFlags, QMUXHdr->CtlFlags, tag)); - dbg("TransactionId: %04x\n", le16_to_cpu(QMUXHdr->TransactionId)); - - // dbg("QCQMUX_MSG_HDR-----------------------------------\n"); - switch (serviceType) { - case QMUX_TYPE_DMS: - dbg("Type: %04x\t%s\n", le16_to_cpu(QMUXMsgHdr->Type), - QMUX_NAME(qmux_dms_Type, le16_to_cpu(QMUXMsgHdr->Type), tag)); - break; - case QMUX_TYPE_NAS: - dbg("Type: %04x\t%s\n", le16_to_cpu(QMUXMsgHdr->Type), - QMUX_NAME(qmux_nas_Type, le16_to_cpu(QMUXMsgHdr->Type), tag)); - break; - case QMUX_TYPE_WDS: - dbg("Type: %04x\t%s\n", le16_to_cpu(QMUXMsgHdr->Type), - QMUX_NAME(qmux_wds_Type, le16_to_cpu(QMUXMsgHdr->Type), tag)); - break; - case QMUX_TYPE_WMS: - dbg("Type: %04x\t%s\n", le16_to_cpu(QMUXMsgHdr->Type), - QMUX_NAME(qmux_wms_Type, le16_to_cpu(QMUXMsgHdr->Type), tag)); - break; - case QMUX_TYPE_WDS_ADMIN: - dbg("Type: %04x\t%s\n", le16_to_cpu(QMUXMsgHdr->Type), - QMUX_NAME(qmux_wds_admin_Type, le16_to_cpu(QMUXMsgHdr->Type), tag)); - break; - case QMUX_TYPE_UIM: - dbg("Type: %04x\t%s\n", le16_to_cpu(QMUXMsgHdr->Type), - QMUX_NAME(qmux_uim_Type, le16_to_cpu(QMUXMsgHdr->Type), tag)); - break; - case QMUX_TYPE_PDS: - case QMUX_TYPE_QOS: - case QMUX_TYPE_CTL: - default: - dbg("Type: %04x\t%s\n", le16_to_cpu(QMUXMsgHdr->Type), - "PDS/QOS/CTL/unknown!"); - break; - } - dbg("Length: %04x\n", le16_to_cpu(QMUXMsgHdr->Length)); - - dump_tlv(QMUXMsgHdr); - - return 0; -} - -void dump_qmi(void *dataBuffer, int dataLen) -{ - PQCQMI_HDR QMIHdr = (PQCQMI_HDR)dataBuffer; - PQCQMUX_HDR QMUXHdr = (PQCQMUX_HDR)(QMIHdr + 1); - PQCQMICTL_MSG_HDR CTLHdr = (PQCQMICTL_MSG_HDR)(QMIHdr + 1); - - int i; - - if (!debug_qmi) - return; - - pthread_mutex_lock(&dumpQMIMutex); - line[0] = 0; - for (i = 0; i < dataLen; i++) { - dbg("%02x ", ((unsigned char *)dataBuffer)[i]); - } - dbg_time("%s", line); - line[0] = 0; - - // dbg("QCQMI_HDR-----------------------------------------"); - // dbg("IFType: %02x\t\t%s", QMIHdr->IFType, - // QMI_NAME(qmi_IFType, QMIHdr->IFType)); dbg("Length: %04x", - // le16_to_cpu(QMIHdr->Length)); dbg("CtlFlags: %02x\t\t%s", - // QMIHdr->CtlFlags, QMI_NAME(qmi_CtlFlags, QMIHdr->CtlFlags)); - // dbg("QMIType: %02x\t\t%s", QMIHdr->QMIType, QMI_NAME(qmi_QMIType, - // QMIHdr->QMIType)); dbg("ClientId: %02x", QMIHdr->ClientId); - - if (QMIHdr->QMIType == QMUX_TYPE_CTL) { - dump_ctl(CTLHdr); - } else { - dump_qmux(QMIHdr->QMIType, QMUXHdr); - } - dbg_time("%s", line); - pthread_mutex_unlock(&dumpQMIMutex); -} diff --git a/fibocom-dial/src/MPQMUX.h b/fibocom-dial/src/MPQMUX.h deleted file mode 100644 index bae0c4e..0000000 --- a/fibocom-dial/src/MPQMUX.h +++ /dev/null @@ -1,3671 +0,0 @@ -/*=========================================================================== - - M P Q M U X. H -DESCRIPTION: - - This file provides support for QMUX. - -INITIALIZATION AND SEQUENCING REQUIREMENTS: - -Copyright (C) 2011 by Qualcomm Technologies, Incorporated. All Rights Reserved. -===========================================================================*/ - -#ifndef MPQMUX_H -#define MPQMUX_H - -#include "MPQMI.h" - -#pragma pack(push, 1) - -#define QMIWDS_SET_EVENT_REPORT_REQ 0x0001 -#define QMIWDS_SET_EVENT_REPORT_RESP 0x0001 -#define QMIWDS_EVENT_REPORT_IND 0x0001 -#define QMIWDS_START_NETWORK_INTERFACE_REQ 0x0020 -#define QMIWDS_START_NETWORK_INTERFACE_RESP 0x0020 -#define QMIWDS_STOP_NETWORK_INTERFACE_REQ 0x0021 -#define QMIWDS_STOP_NETWORK_INTERFACE_RESP 0x0021 -#define QMIWDS_GET_PKT_SRVC_STATUS_REQ 0x0022 -#define QMIWDS_GET_PKT_SRVC_STATUS_RESP 0x0022 -#define QMIWDS_GET_PKT_SRVC_STATUS_IND 0x0022 -#define QMIWDS_GET_CURRENT_CHANNEL_RATE_REQ 0x0023 -#define QMIWDS_GET_CURRENT_CHANNEL_RATE_RESP 0x0023 -#define QMIWDS_GET_PKT_STATISTICS_REQ 0x0024 -#define QMIWDS_GET_PKT_STATISTICS_RESP 0x0024 -//begin modified by zhangkaibo add create profile qmi. mantis 0049137,0048741 20200610 -#define QMIWDS_CREATE_PROFILE_SETTINGS_REQ 0x0027 -#define QMIWDS_CREATE_PROFILE_SETTINGS_RESP 0x0027 -//end modified by zhangkaibo add create profile qmi. mantis 0049137,0048741 20200610 -#define QMIWDS_MODIFY_PROFILE_SETTINGS_REQ 0x0028 -#define QMIWDS_MODIFY_PROFILE_SETTINGS_RESP 0x0028 -#define QMIWDS_GET_PROFILE_SETTINGS_REQ 0x002B -#define QMIWDS_GET_PROFILE_SETTINGS_RESP 0x002B -#define QMIWDS_GET_DEFAULT_SETTINGS_REQ 0x002C -#define QMIWDS_GET_DEFAULT_SETTINGS_RESP 0x002C -#define QMIWDS_GET_RUNTIME_SETTINGS_REQ 0x002D -#define QMIWDS_GET_RUNTIME_SETTINGS_RESP 0x002D -#define QMIWDS_GET_MIP_MODE_REQ 0x002F -#define QMIWDS_GET_MIP_MODE_RESP 0x002F -#define QMIWDS_GET_DATA_BEARER_REQ 0x0037 -#define QMIWDS_GET_DATA_BEARER_RESP 0x0037 -#define QMIWDS_DUN_CALL_INFO_REQ 0x0038 -#define QMIWDS_DUN_CALL_INFO_RESP 0x0038 -#define QMIWDS_DUN_CALL_INFO_IND 0x0038 -#define QMIWDS_SET_CLIENT_IP_FAMILY_PREF_REQ 0x004D -#define QMIWDS_SET_CLIENT_IP_FAMILY_PREF_RESP 0x004D -#define QMIWDS_SET_AUTO_CONNECT_REQ 0x0051 -#define QMIWDS_SET_AUTO_CONNECT_RESP 0x0051 -#define QMIWDS_BIND_MUX_DATA_PORT_REQ 0x00A2 -#define QMIWDS_BIND_MUX_DATA_PORT_RESP 0x00A2 - -// Stats masks -#define QWDS_STAT_MASK_TX_PKT_OK 0x00000001 -#define QWDS_STAT_MASK_RX_PKT_OK 0x00000002 -#define QWDS_STAT_MASK_TX_PKT_ER 0x00000004 -#define QWDS_STAT_MASK_RX_PKT_ER 0x00000008 -#define QWDS_STAT_MASK_TX_PKT_OF 0x00000010 -#define QWDS_STAT_MASK_RX_PKT_OF 0x00000020 - -// TLV Types for xfer statistics -#define TLV_WDS_TX_GOOD_PKTS 0x10 -#define TLV_WDS_RX_GOOD_PKTS 0x11 -#define TLV_WDS_TX_ERROR 0x12 -#define TLV_WDS_RX_ERROR 0x13 -#define TLV_WDS_TX_OVERFLOW 0x14 -#define TLV_WDS_RX_OVERFLOW 0x15 -#define TLV_WDS_CHANNEL_RATE 0x16 -#define TLV_WDS_DATA_BEARER 0x17 -#define TLV_WDS_DORMANCY_STATUS 0x18 - -#define QWDS_PKT_DATA_DISCONNECTED 0x01 -#define QWDS_PKT_DATA_CONNECTED 0x02 -#define QWDS_PKT_DATA_SUSPENDED 0x03 -#define QWDS_PKT_DATA_AUTHENTICATING 0x04 - -#define QMIWDS_ADMIN_SET_DATA_FORMAT_REQ 0x0020 -#define QMIWDS_ADMIN_SET_DATA_FORMAT_RESP 0x0020 -#define QMIWDS_ADMIN_GET_DATA_FORMAT_REQ 0x0021 -#define QMIWDS_ADMIN_GET_DATA_FORMAT_RESP 0x0021 -#define QMIWDS_ADMIN_SET_QMAP_SETTINGS_REQ 0x002B -#define QMIWDS_ADMIN_SET_QMAP_SETTINGS_RESP 0x002B -#define QMIWDS_ADMIN_GET_QMAP_SETTINGS_REQ 0x002C -#define QMIWDS_ADMIN_GET_QMAP_SETTINGS_RESP 0x002C - -#define NETWORK_DESC_ENCODING_OCTET 0x00 -#define NETWORK_DESC_ENCODING_EXTPROTOCOL 0x01 -#define NETWORK_DESC_ENCODING_7BITASCII 0x02 -#define NETWORK_DESC_ENCODING_IA5 0x03 -#define NETWORK_DESC_ENCODING_UNICODE 0x04 -#define NETWORK_DESC_ENCODING_SHIFTJIS 0x05 -#define NETWORK_DESC_ENCODING_KOREAN 0x06 -#define NETWORK_DESC_ENCODING_LATINH 0x07 -#define NETWORK_DESC_ENCODING_LATIN 0x08 -#define NETWORK_DESC_ENCODING_GSM7BIT 0x09 -#define NETWORK_DESC_ENCODING_GSMDATA 0x0A -#define NETWORK_DESC_ENCODING_UNKNOWN 0xFF - -typedef struct _QMIWDS_ADMIN_SET_DATA_FORMAT { - USHORT Type; // QMUX type 0x0000 - USHORT Length; -} __attribute__((packed)) QMIWDS_ADMIN_SET_DATA_FORMAT, - *PQMIWDS_ADMIN_SET_DATA_FORMAT; - -typedef struct _QMIWDS_ADMIN_SET_DATA_FORMAT_TLV_QOS { - UCHAR TLVType; - USHORT TLVLength; - UCHAR QOSSetting; -} __attribute__((packed)) QMIWDS_ADMIN_SET_DATA_FORMAT_TLV_QOS, - *PQMIWDS_ADMIN_SET_DATA_FORMAT_TLV_QOS; - -typedef struct _QMIWDS_ADMIN_SET_DATA_FORMAT_TLV { - UCHAR TLVType; - USHORT TLVLength; - ULONG Value; -} __attribute__((packed)) QMIWDS_ADMIN_SET_DATA_FORMAT_TLV, - *PQMIWDS_ADMIN_SET_DATA_FORMAT_TLV; - -typedef struct _QMIWDS_ENDPOINT_TLV { - UCHAR TLVType; - USHORT TLVLength; - ULONG ep_type; - ULONG iface_id; -} __attribute__((packed)) QMIWDS_ENDPOINT_TLV, *PQMIWDS_ENDPOINT_TLV; - -typedef struct _QMIWDS_ADMIN_SET_DATA_FORMAT_REQ_MSG { - USHORT Type; - USHORT Length; - QMIWDS_ADMIN_SET_DATA_FORMAT_TLV_QOS QosDataFormatTlv; - QMIWDS_ADMIN_SET_DATA_FORMAT_TLV UnderlyingLinkLayerProtocolTlv; - QMIWDS_ADMIN_SET_DATA_FORMAT_TLV UplinkDataAggregationProtocolTlv; - QMIWDS_ADMIN_SET_DATA_FORMAT_TLV DownlinkDataAggregationProtocolTlv; - QMIWDS_ADMIN_SET_DATA_FORMAT_TLV DownlinkDataAggregationMaxDatagramsTlv; - QMIWDS_ADMIN_SET_DATA_FORMAT_TLV DownlinkDataAggregationMaxSizeTlv; -#if 0 - QMIWDS_ADMIN_SET_DATA_FORMAT_TLV UplinkDataAggregationMaxDatagramsTlv; - QMIWDS_ADMIN_SET_DATA_FORMAT_TLV UplinkDataAggregationMaxSizeTlv; -#else - QMIWDS_ENDPOINT_TLV epTlv; -#endif -} __attribute__((packed)) QMIWDS_ADMIN_SET_DATA_FORMAT_REQ_MSG, - *PQMIWDS_ADMIN_SET_DATA_FORMAT_REQ_MSG; - -#if 0 -typedef enum _QMI_RETURN_CODES { - QMI_SUCCESS = 0, - QMI_SUCCESS_NOT_COMPLETE, - QMI_FAILURE -}QMI_RETURN_CODES; - -typedef struct _QMIWDS_GET_PKT_SRVC_STATUS_REQ_MSG -{ - USHORT Type; // 0x0022 - USHORT Length; // 0x0000 -} QMIWDS_GET_PKT_SRVC_STATUS_REQ_MSG, *PQMIWDS_GET_PKT_SRVC_STATUS_REQ_MSG; - -typedef struct _QMIWDS_GET_PKT_SRVC_STATUS_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; - UCHAR TLVType2; - USHORT TLVLength2; - UCHAR ConnectionStatus; // 0x01: QWDS_PKT_DATAC_DISCONNECTED - // 0x02: QWDS_PKT_DATA_CONNECTED - // 0x03: QWDS_PKT_DATA_SUSPENDED - // 0x04: QWDS_PKT_DATA_AUTHENTICATING -} QMIWDS_GET_PKT_SRVC_STATUS_RESP_MSG, *PQMIWDS_GET_PKT_SRVC_STATUS_RESP_MSG; - -typedef struct _QMIWDS_GET_PKT_SRVC_STATUS_IND_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - UCHAR ConnectionStatus; // 0x01: QWDS_PKT_DATAC_DISCONNECTED - // 0x02: QWDS_PKT_DATA_CONNECTED - // 0x03: QWDS_PKT_DATA_SUSPENDED - UCHAR ReconfigRequired; // 0x00: No need to reconfigure - // 0x01: Reconfiguration required -} QMIWDS_GET_PKT_SRVC_STATUS_IND_MSG, *PQMIWDS_GET_PKT_SRVC_STATUS_IND_MSG; - -typedef struct _WDS_PKT_SRVC_IP_FAMILY_TLV -{ - UCHAR TLVType; // 0x12 - USHORT TLVLength; // 1 - UCHAR IpFamily; // IPV4-0x04, IPV6-0x06 -} WDS_PKT_SRVC_IP_FAMILY_TLV, *PWDS_PKT_SRVC_IP_FAMILY_TLV; - -typedef struct _QMIWDS_DUN_CALL_INFO_REQ_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - ULONG Mask; - UCHAR TLV2Type; - USHORT TLV2Length; - UCHAR ReportConnectionStatus; -} QMIWDS_DUN_CALL_INFO_REQ_MSG, *PQMIWDS_DUN_CALL_INFO_REQ_MSG; - -typedef struct _QMIWDS_DUN_CALL_INFO_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; -} QMIWDS_DUN_CALL_INFO_RESP_MSG, *PQMIWDS_DUN_CALL_INFO_RESP_MSG; - -typedef struct _QMIWDS_DUN_CALL_INFO_IND_MSG -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR ConnectionStatus; -} QMIWDS_DUN_CALL_INFO_IND_MSG, *PQMIWDS_DUN_CALL_INFO_IND_MSG; - -typedef struct _QMIWDS_GET_CURRENT_CHANNEL_RATE_REQ_MSG -{ - USHORT Type; // QMUX type 0x0040 - USHORT Length; -} QMIWDS_GET_CURRENT_CHANNEL_RATE_REQ_MSG, *PQMIWDS_GET_CURRENT_CHANNEL_RATE_REQ_MSG; - -typedef struct _QMIWDS_GET_CURRENT_CHANNEL_RATE_RESP_MSG -{ - USHORT Type; // QMUX type 0x0040 - USHORT Length; - UCHAR TLVType; // 0x02 - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT - - UCHAR TLV2Type; // 0x01 - USHORT TLV2Length; // 16 - //ULONG CallHandle; // Context corresponding to reported channel - ULONG CurrentTxRate; // bps - ULONG CurrentRxRate; // bps - ULONG ServingSystemTxRate; // bps - ULONG ServingSystemRxRate; // bps - -} QMIWDS_GET_CURRENT_CHANNEL_RATE_RESP_MSG, *PQMIWDS_GET_CURRENT_CHANNEL_RATE_RESP; - -#define QWDS_EVENT_REPORT_MASK_RATES 0x01 -#define QWDS_EVENT_REPORT_MASK_STATS 0x02 - -#ifdef QCUSB_MUX_PROTOCOL -#error code not present -#endif // QCUSB_MUX_PROTOCOL - -typedef struct _QMIWDS_SET_EVENT_REPORT_REQ_MSG -{ - USHORT Type; // QMUX type 0x0042 - USHORT Length; - - UCHAR TLVType; // 0x10 -- current channel rate indicator - USHORT TLVLength; // 1 - UCHAR Mode; // 0-do not report; 1-report when rate changes - - UCHAR TLV2Type; // 0x11 - USHORT TLV2Length; // 5 - UCHAR StatsPeriod; // seconds between reports; 0-do not report - ULONG StatsMask; // - - UCHAR TLV3Type; // 0x12 -- current data bearer indicator - USHORT TLV3Length; // 1 - UCHAR Mode3; // 0-do not report; 1-report when changes - - UCHAR TLV4Type; // 0x13 -- dormancy status indicator - USHORT TLV4Length; // 1 - UCHAR DormancyStatus; // 0-do not report; 1-report when changes -} QMIWDS_SET_EVENT_REPORT_REQ_MSG, *PQMIWDS_SET_EVENT_REPORT_REQ_MSG; - -typedef struct _QMIWDS_SET_EVENT_REPORT_RESP_MSG -{ - USHORT Type; // QMUX type 0x0042 - USHORT Length; - - UCHAR TLVType; // 0x02 result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_NO_BATTERY - // QMI_ERR_FAULT -} QMIWDS_SET_EVENT_REPORT_RESP_MSG, *PQMIWDS_SET_EVENT_REPORT_RESP_MSG; - -typedef struct _QMIWDS_EVENT_REPORT_IND_MSG -{ - USHORT Type; // QMUX type 0x0001 - USHORT Length; -} QMIWDS_EVENT_REPORT_IND_MSG, *PQMIWDS_EVENT_REPORT_IND_MSG; - -// PQCTLV_PKT_STATISTICS - -typedef struct _QMIWDS_EVENT_REPORT_IND_CHAN_RATE_TLV -{ - UCHAR Type; - USHORT Length; // 8 - ULONG TxRate; - ULONG RxRate; -} QMIWDS_EVENT_REPORT_IND_CHAN_RATE_TLV, *PQMIWDS_EVENT_REPORT_IND_CHAN_RATE_TLV; - -#ifdef QCUSB_MUX_PROTOCOL -#error code not present -#endif // QCUSB_MUX_PROTOCOL - -typedef struct _QMIWDS_GET_PKT_STATISTICS_REQ_MSG -{ - USHORT Type; // QMUX type 0x0041 - USHORT Length; - UCHAR TLVType; // 0x01 - USHORT TLVLength; // 4 - ULONG StateMask; // 0x00000001 tx success packets - // 0x00000002 rx success packets - // 0x00000004 rx packet errors (checksum) - // 0x00000008 rx packets dropped (memory) - -} QMIWDS_GET_PKT_STATISTICS_REQ_MSG, *PQMIWDS_GET_PKT_STATISTICS_REQ_MSG; - -typedef struct _QMIWDS_GET_PKT_STATISTICS_RESP_MSG -{ - USHORT Type; // QMUX type 0x0041 - USHORT Length; - UCHAR TLVType; // 0x02 - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT -} QMIWDS_GET_PKT_STATISTICS_RESP_MSG, *PQMIWDS_GET_PKT_STATISTICS_RESP_MSG; - -// optional TLV for stats -typedef struct _QCTLV_PKT_STATISTICS -{ - UCHAR TLVType; // see above definitions for TLV types - USHORT TLVLength; // 4 - ULONG Count; -} QCTLV_PKT_STATISTICS, *PQCTLV_PKT_STATISTICS; -#endif - -//#ifdef QC_IP_MODE - -#define QMIWDS_GET_RUNTIME_SETTINGS_MASK_IPV4DNS_ADDR 0x0010 -#define QMIWDS_GET_RUNTIME_SETTINGS_MASK_IPV4_ADDR 0x0100 -#define QMIWDS_GET_RUNTIME_SETTINGS_MASK_IPV4GATEWAY_ADDR 0x0200 -#define QMIWDS_GET_RUNTIME_SETTINGS_MASK_MTU 0x2000 - -typedef struct _QMIWDS_GET_RUNTIME_SETTINGS_REQ_MSG { - USHORT Type; // QMIWDS_GET_RUNTIME_SETTINGS_REQ - USHORT Length; - UCHAR TLVType; // 0x10 - USHORT TLVLength; // 0x0004 - ULONG Mask; // mask, bit 8: IP addr -- 0x0100 -} __attribute__((packed)) QMIWDS_GET_RUNTIME_SETTINGS_REQ_MSG, - *PQMIWDS_GET_RUNTIME_SETTINGS_REQ_MSG; - -typedef struct _QMIWDS_BIND_MUX_DATA_PORT_REQ_MSG { - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - ULONG ep_type; - ULONG iface_id; - UCHAR TLV2Type; - USHORT TLV2Length; - UCHAR MuxId; - UCHAR TLV3Type; - USHORT TLV3Length; - ULONG client_type; -} __attribute__((packed)) QMIWDS_BIND_MUX_DATA_PORT_REQ_MSG, - *PQMIWDS_BIND_MUX_DATA_PORT_REQ_MSG; - -#define QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV4PRIMARYDNS 0x15 -#define QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV4SECONDARYDNS 0x16 -#define QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV4 0x1E -#define QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV4GATEWAY 0x20 -#define QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV4SUBNET 0x21 - -#define QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV6 0x25 -#define QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV6GATEWAY 0x26 -#define QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV6PRIMARYDNS 0x27 -#define QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV6SECONDARYDNS 0x28 -#define QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_MTU 0x29 - -typedef struct _QMIWDS_GET_RUNTIME_SETTINGS_TLV_MTU { - UCHAR TLVType; // QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_MTU - USHORT TLVLength; // 4 - ULONG Mtu; // MTU -} __attribute__((packed)) QMIWDS_GET_RUNTIME_SETTINGS_TLV_MTU, - *PQMIWDS_GET_RUNTIME_SETTINGS_TLV_MTU; - -typedef struct _QMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV4_ADDR { - UCHAR TLVType; // QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV4 - USHORT TLVLength; // 4 - ULONG IPV4Address; // address -} __attribute__((packed)) QMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV4_ADDR, - *PQMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV4_ADDR; - -typedef struct _QMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV6_ADDR { - UCHAR TLVType; // QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV6 - USHORT TLVLength; // 16 - UCHAR IPV6Address[16]; // address - UCHAR PrefixLength; // prefix length -} __attribute__((packed)) QMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV6_ADDR, - *PQMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV6_ADDR; - - typedef struct _QMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV6_DNS_ADDR { - UCHAR TLVType; // QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV6 - USHORT TLVLength; // 16 - UCHAR IPV6Address[16]; // address - } __attribute__((packed)) QMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV6_DNS_ADDR, - *PQMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV6_DNS_ADDR; - -typedef struct _QMIWDS_GET_RUNTIME_SETTINGS_RESP_MSG { - USHORT Type; // QMIWDS_GET_RUNTIME_SETTINGS_RESP - USHORT Length; - UCHAR TLVType; // QCTLV_TYPE_RESULT_CODE - USHORT TLVLength; // 0x0004 - USHORT QMUXResult; // result code - USHORT QMUXError; // error code -} __attribute__((packed)) QMIWDS_GET_RUNTIME_SETTINGS_RESP_MSG, - *PQMIWDS_GET_RUNTIME_SETTINGS_RESP_MSG; - -//#endif // QC_IP_MODE - -typedef struct _QMIWDS_IP_FAMILY_TLV { - UCHAR TLVType; // 0x12 - USHORT TLVLength; // 1 - UCHAR IpFamily; // IPV4-0x04, IPV6-0x06 -} __attribute__((packed)) QMIWDS_IP_FAMILY_TLV, *PQMIWDS_IP_FAMILY_TLV; - -typedef struct _QMIWDS_PKT_SRVC_TLV { - UCHAR TLVType; - USHORT TLVLength; - UCHAR ConnectionStatus; - UCHAR ReconfigReqd; -} __attribute__((packed)) QMIWDS_PKT_SRVC_TLV, *PQMIWDS_PKT_SRVC_TLV; - -typedef struct _QMIWDS_CALL_END_REASON_TLV { - UCHAR TLVType; - USHORT TLVLength; - USHORT CallEndReason; -} __attribute__((packed)) QMIWDS_CALL_END_REASON_TLV, - *PQMIWDS_CALL_END_REASON_TLV; - -typedef struct _QMIWDS_CALL_END_REASON_V_TLV { - UCHAR TLVType; - USHORT TLVLength; - USHORT CallEndReasonType; - USHORT CallEndReason; -} __attribute__((packed)) QMIWDS_CALL_END_REASON_V_TLV, - *PQMIWDS_CALL_END_REASON_V_TLV; - -typedef struct _QMIWDS_SET_CLIENT_IP_FAMILY_PREF_REQ_MSG { - USHORT Type; // QMUX type 0x004D - USHORT Length; - UCHAR TLVType; // 0x01 - USHORT TLVLength; // 1 - UCHAR IpPreference; // IPV4-0x04, IPV6-0x06 -} __attribute__((packed)) QMIWDS_SET_CLIENT_IP_FAMILY_PREF_REQ_MSG, - *PQMIWDS_SET_CLIENT_IP_FAMILY_PREF_REQ_MSG; - -typedef struct _QMIWDS_SET_CLIENT_IP_FAMILY_PREF_RESP_MSG { - USHORT Type; // QMUX type 0x0037 - USHORT Length; - UCHAR TLVType; // 0x02 - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS, QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INTERNAL, QMI_ERR_MALFORMED_MSG, - // QMI_ERR_INVALID_ARG -} __attribute__((packed)) QMIWDS_SET_CLIENT_IP_FAMILY_PREF_RESP_MSG, - *PQMIWDS_SET_CLIENT_IP_FAMILY_PREF_RESP_MSG; - -typedef struct _QMIWDS_SET_AUTO_CONNECT_REQ_MSG { - USHORT Type; // QMUX type 0x0051 - USHORT Length; - UCHAR TLVType; // 0x01 - USHORT TLVLength; // 1 - UCHAR autoconnect_setting; // 0x00 ?C Disabled, 0x01 ?C Enabled, 0x02 ?C - // Paused (resume on power cycle) -} __attribute__((packed)) QMIWDS_SET_AUTO_CONNECT_REQ_MSG, - *PQMIWDS_SET_AUTO_CONNECT_REQ_MSG; - -#if 0 -typedef struct _QMIWDS_GET_MIP_MODE_REQ_MSG -{ - USHORT Type; // QMUX type 0x0040 - USHORT Length; -} QMIWDS_GET_MIP_MODE_REQ_MSG, *PQMIWDS_GET_MIP_MODE_REQ_MSG; - -typedef struct _QMIWDS_GET_MIP_MODE_RESP_MSG -{ - USHORT Type; // QMUX type 0x0040 - USHORT Length; - UCHAR TLVType; // 0x02 - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT - - UCHAR TLV2Type; // 0x01 - USHORT TLV2Length; // 20 - UCHAR MipMode; // -} QMIWDS_GET_MIP_MODE_RESP_MSG, *PQMIWDS_GET_MIP_MODE_RESP_MSG; -#endif - -typedef struct _QMIWDS_TECHNOLOGY_PREFERECE { - UCHAR TLVType; - USHORT TLVLength; - UCHAR TechPreference; -} __attribute__((packed)) QMIWDS_TECHNOLOGY_PREFERECE, - *PQMIWDS_TECHNOLOGY_PREFERECE; - -typedef struct _QMIWDS_PROFILE_IDENTIFIER { - UCHAR TLVType; - USHORT TLVLength; - UCHAR ProfileIndex; -} __attribute__((packed)) QMIWDS_PROFILE_IDENTIFIER, - *PQMIWDS_PROFILE_IDENTIFIER; - -#if 0 -typedef struct _QMIWDS_IPADDRESS -{ - UCHAR TLVType; - USHORT TLVLength; - ULONG IPv4Address; -}QMIWDS_IPADDRESS, *PQMIWDS_IPADDRESS; - -/* -typedef struct _QMIWDS_UMTS_QOS -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR TrafficClass; - ULONG MaxUplinkBitRate; - ULONG MaxDownlinkBitRate; - ULONG GuarUplinkBitRate; - ULONG GuarDownlinkBitRate; - UCHAR QOSDevOrder; - ULONG MAXSDUSize; - UCHAR SDUErrorRatio; - UCHAR ResidualBerRatio; - UCHAR DeliveryErrorSDUs; - ULONG TransferDelay; - ULONG TrafficHndPri; -}QMIWDS_UMTS_QOS, *PQMIWDS_UMTS_QOS; - -typedef struct _QMIWDS_GPRS_QOS -{ - UCHAR TLVType; - USHORT TLVLength; - ULONG PrecedenceClass; - ULONG DelayClass; - ULONG ReliabilityClass; - ULONG PeekThroClass; - ULONG MeanThroClass; -}QMIWDS_GPRS_QOS, *PQMIWDS_GPRS_QOS; -*/ -#endif - -typedef struct _QMIWDS_PROFILENAME { - UCHAR TLVType; - USHORT TLVLength; - UCHAR ProfileName; -} __attribute__((packed)) QMIWDS_PROFILENAME, *PQMIWDS_PROFILENAME; - -typedef struct _QMIWDS_PDPTYPE { - UCHAR TLVType; - USHORT TLVLength; - // 0 ?C PDP-IP (IPv4) - // 1 ?C PDP-PPP - // 2 ?C PDP-IPv6 - // 3 ?C PDP-IPv4v6 - UCHAR PdpType; -} __attribute__((packed)) QMIWDS_PDPTYPE, *PQMIWDS_PDPTYPE; - -typedef struct _QMIWDS_USERNAME { - UCHAR TLVType; - USHORT TLVLength; - UCHAR UserName; -} __attribute__((packed)) QMIWDS_USERNAME, *PQMIWDS_USERNAME; - -typedef struct _QMIWDS_PASSWD { - UCHAR TLVType; - USHORT TLVLength; - UCHAR Passwd; -} __attribute__((packed)) QMIWDS_PASSWD, *PQMIWDS_PASSWD; - -typedef struct _QMIWDS_AUTH_PREFERENCE { - UCHAR TLVType; - USHORT TLVLength; - UCHAR AuthPreference; -} __attribute__((packed)) QMIWDS_AUTH_PREFERENCE, *PQMIWDS_AUTH_PREFERENCE; - -typedef struct _QMIWDS_APNNAME { - UCHAR TLVType; - USHORT TLVLength; - UCHAR ApnName; -} __attribute__((packed)) QMIWDS_APNNAME, *PQMIWDS_APNNAME; - -typedef struct _QMIWDS_AUTOCONNECT { - UCHAR TLVType; - USHORT TLVLength; - UCHAR AutoConnect; -} __attribute__((packed)) QMIWDS_AUTOCONNECT, *PQMIWDS_AUTOCONNECT; - -typedef struct _QMIWDS_START_NETWORK_INTERFACE_REQ_MSG { - USHORT Type; - USHORT Length; -} __attribute__((packed)) QMIWDS_START_NETWORK_INTERFACE_REQ_MSG, - *PQMIWDS_START_NETWORK_INTERFACE_REQ_MSG; - -typedef struct _QMIWDS_CALLENDREASON { - UCHAR TLVType; - USHORT TLVLength; - USHORT Reason; -} __attribute__((packed)) QMIWDS_CALLENDREASON, *PQMIWDS_CALLENDREASON; - -typedef struct _QMIWDS_START_NETWORK_INTERFACE_RESP_MSG { - USHORT Type; // QMUX type 0x0040 - USHORT Length; - UCHAR TLVType; // 0x02 - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT - - UCHAR TLV2Type; // 0x01 - USHORT TLV2Length; // 20 - ULONG Handle; // -} __attribute__((packed)) QMIWDS_START_NETWORK_INTERFACE_RESP_MSG, - *PQMIWDS_START_NETWORK_INTERFACE_RESP_MSG; - -typedef struct _QMIWDS_STOP_NETWORK_INTERFACE_REQ_MSG { - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - ULONG Handle; -} __attribute__((packed)) QMIWDS_STOP_NETWORK_INTERFACE_REQ_MSG, - *PQMIWDS_STOP_NETWORK_INTERFACE_REQ_MSG; - -typedef struct _QMIWDS_STOP_NETWORK_INTERFACE_RESP_MSG { - USHORT Type; // QMUX type 0x0040 - USHORT Length; - UCHAR TLVType; // 0x02 - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT - -} __attribute__((packed)) QMIWDS_STOP_NETWORK_INTERFACE_RESP_MSG, - *PQMIWDS_STOP_NETWORK_INTERFACE_RESP_MSG; - -typedef struct _QMIWDS_GET_DEFAULT_SETTINGS_REQ_MSG { - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - UCHAR ProfileType; -} __attribute__((packed)) QMIWDS_GET_DEFAULT_SETTINGS_REQ_MSG, - *PQMIWDS_GET_DEFAULT_SETTINGS_REQ_MSG; - -typedef struct _QMIWDS_GET_DEFAULT_SETTINGS_RESP_MSG { - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; -} __attribute__((packed)) QMIWDS_GET_DEFAULT_SETTINGS_RESP_MSG, - *PQMIWDS_GET_DEFAULT_SETTINGS_RESP_MSG; -//begin modified by zhangkaibo add create profile qmi. mantis 0049137,0048741 20200610 -typedef struct _QMIWDS_CREATE_PROFILE_SETTINGS_REQ_MSG { - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - UCHAR ProfileType; -} __attribute__((packed)) QMIWDS_CREATE_PROFILE_SETTINGS_REQ_MSG, - *PQMIWDS_CREATE_PROFILE_SETTINGS_REQ_MSG; - - -typedef struct _QMIWDS_CREATE_PROFILE_SETTINGS_RESP_MSG { - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; -} __attribute__((packed)) QMIWDS_CREATE_PROFILE_SETTINGS_RESP_MSG, - *PQMIWDS_CREATE_PROFILE_SETTINGS_RESP_MSG; -//end modified by zhangkaibo add create profile qmi. mantis 0049137,0048741 20200610 -typedef struct _QMIWDS_MODIFY_PROFILE_SETTINGS_REQ_MSG { - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - UCHAR ProfileType; - UCHAR ProfileIndex; -} __attribute__((packed)) QMIWDS_MODIFY_PROFILE_SETTINGS_REQ_MSG, - *PQMIWDS_MODIFY_PROFILE_SETTINGS_REQ_MSG; - -typedef struct _QMIWDS_MODIFY_PROFILE_SETTINGS_RESP_MSG { - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; -} __attribute__((packed)) QMIWDS_MODIFY_PROFILE_SETTINGS_RESP_MSG, - *PQMIWDS_MODIFY_PROFILE_SETTINGS_RESP_MSG; - -typedef struct _QMIWDS_GET_PROFILE_SETTINGS_REQ_MSG { - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - UCHAR ProfileType; - UCHAR ProfileIndex; -} __attribute__((packed)) QMIWDS_GET_PROFILE_SETTINGS_REQ_MSG, - *PQMIWDS_GET_PROFILE_SETTINGS_REQ_MSG; - -#if 0 -typedef struct _QMIWDS_EVENT_REPORT_IND_DATA_BEARER_TLV -{ - UCHAR Type; - USHORT Length; - UCHAR DataBearer; -} QMIWDS_EVENT_REPORT_IND_DATA_BEARER_TLV, *PQMIWDS_EVENT_REPORT_IND_DATA_BEARER_TLV; - -typedef struct _QMIWDS_EVENT_REPORT_IND_DORMANCY_STATUS_TLV -{ - UCHAR Type; - USHORT Length; - UCHAR DormancyStatus; -} QMIWDS_EVENT_REPORT_IND_DORMANCY_STATUS_TLV, *PQMIWDS_EVENT_REPORT_IND_DORMANCY_STATUS_TLV; - - -typedef struct _QMIWDS_GET_DATA_BEARER_REQ_MSG -{ - USHORT Type; // QMUX type 0x0037 - USHORT Length; -} QMIWDS_GET_DATA_BEARER_REQ_MSG, *PQMIWDS_GET_DATA_BEARER_REQ_MSG; - -typedef struct _QMIWDS_GET_DATA_BEARER_RESP_MSG -{ - USHORT Type; // QMUX type 0x0037 - USHORT Length; - UCHAR TLVType; // 0x02 - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INTERNAL - // QMI_ERR_MALFORMED_MSG - // QMI_ERR_NO_MEMORY - // QMI_ERR_OUT_OF_CALL - // QMI_ERR_INFO_UNAVAILABLE - UCHAR TLV2Type; // 0x01 - USHORT TLV2Length; // - UCHAR Technology; // -} QMIWDS_GET_DATA_BEARER_RESP_MSG, *PQMIWDS_GET_DATA_BEARER_RESP_MSG; -#endif - -// ======================= DMS ============================== -#define QMIDMS_SET_EVENT_REPORT_REQ 0x0001 -#define QMIDMS_SET_EVENT_REPORT_RESP 0x0001 -#define QMIDMS_EVENT_REPORT_IND 0x0001 -#define QMIDMS_GET_DEVICE_CAP_REQ 0x0020 -#define QMIDMS_GET_DEVICE_CAP_RESP 0x0020 -#define QMIDMS_GET_DEVICE_MFR_REQ 0x0021 -#define QMIDMS_GET_DEVICE_MFR_RESP 0x0021 -#define QMIDMS_GET_DEVICE_MODEL_ID_REQ 0x0022 -#define QMIDMS_GET_DEVICE_MODEL_ID_RESP 0x0022 -#define QMIDMS_GET_DEVICE_REV_ID_REQ 0x0023 -#define QMIDMS_GET_DEVICE_REV_ID_RESP 0x0023 -#define QMIDMS_GET_MSISDN_REQ 0x0024 -#define QMIDMS_GET_MSISDN_RESP 0x0024 -#define QMIDMS_GET_DEVICE_SERIAL_NUMBERS_REQ 0x0025 -#define QMIDMS_GET_DEVICE_SERIAL_NUMBERS_RESP 0x0025 -#define QMIDMS_UIM_SET_PIN_PROTECTION_REQ 0x0027 -#define QMIDMS_UIM_SET_PIN_PROTECTION_RESP 0x0027 -#define QMIDMS_UIM_VERIFY_PIN_REQ 0x0028 -#define QMIDMS_UIM_VERIFY_PIN_RESP 0x0028 -#define QMIDMS_UIM_UNBLOCK_PIN_REQ 0x0029 -#define QMIDMS_UIM_UNBLOCK_PIN_RESP 0x0029 -#define QMIDMS_UIM_CHANGE_PIN_REQ 0x002A -#define QMIDMS_UIM_CHANGE_PIN_RESP 0x002A -#define QMIDMS_UIM_GET_PIN_STATUS_REQ 0x002B -#define QMIDMS_UIM_GET_PIN_STATUS_RESP 0x002B -#define QMIDMS_GET_DEVICE_HARDWARE_REV_REQ 0x002C -#define QMIDMS_GET_DEVICE_HARDWARE_REV_RESP 0x002C -#define QMIDMS_GET_OPERATING_MODE_REQ 0x002D -#define QMIDMS_GET_OPERATING_MODE_RESP 0x002D -#define QMIDMS_SET_OPERATING_MODE_REQ 0x002E -#define QMIDMS_SET_OPERATING_MODE_RESP 0x002E -#define QMIDMS_GET_ACTIVATED_STATUS_REQ 0x0031 -#define QMIDMS_GET_ACTIVATED_STATUS_RESP 0x0031 -#define QMIDMS_ACTIVATE_AUTOMATIC_REQ 0x0032 -#define QMIDMS_ACTIVATE_AUTOMATIC_RESP 0x0032 -#define QMIDMS_ACTIVATE_MANUAL_REQ 0x0033 -#define QMIDMS_ACTIVATE_MANUAL_RESP 0x0033 -#define QMIDMS_UIM_GET_ICCID_REQ 0x003C -#define QMIDMS_UIM_GET_ICCID_RESP 0x003C -#define QMIDMS_UIM_GET_CK_STATUS_REQ 0x0040 -#define QMIDMS_UIM_GET_CK_STATUS_RESP 0x0040 -#define QMIDMS_UIM_SET_CK_PROTECTION_REQ 0x0041 -#define QMIDMS_UIM_SET_CK_PROTECTION_RESP 0x0041 -#define QMIDMS_UIM_UNBLOCK_CK_REQ 0x0042 -#define QMIDMS_UIM_UNBLOCK_CK_RESP 0x0042 -#define QMIDMS_UIM_GET_IMSI_REQ 0x0043 -#define QMIDMS_UIM_GET_IMSI_RESP 0x0043 -#define QMIDMS_UIM_GET_STATE_REQ 0x0044 -#define QMIDMS_UIM_GET_STATE_RESP 0x0044 -#define QMIDMS_GET_BAND_CAP_REQ 0x0045 -#define QMIDMS_GET_BAND_CAP_RESP 0x0045 - -#if 0 -typedef struct _QMIDMS_GET_DEVICE_MFR_REQ_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; -} QMIDMS_GET_DEVICE_MFR_REQ_MSG, *PQMIDMS_GET_DEVICE_MFR_REQ_MSG; - -typedef struct _QMIDMS_GET_DEVICE_MFR_RESP_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT - UCHAR TLV2Type; // 0x01 - required parameter - USHORT TLV2Length; // length of the mfr string - UCHAR DeviceManufacturer; // first byte of string -} QMIDMS_GET_DEVICE_MFR_RESP_MSG, *PQMIDMS_GET_DEVICE_MFR_RESP_MSG; - -typedef struct _QMIDMS_GET_DEVICE_MODEL_ID_REQ_MSG -{ - USHORT Type; // QMUX type 0x0004 - USHORT Length; -} QMIDMS_GET_DEVICE_MODEL_ID_REQ_MSG, *PQMIDMS_GET_DEVICE_MODEL_ID_REQ_MSG; - -typedef struct _QMIDMS_GET_DEVICE_MODEL_ID_RESP_MSG -{ - USHORT Type; // QMUX type 0x0004 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT - UCHAR TLV2Type; // 0x01 - required parameter - USHORT TLV2Length; // length of the modem id string - UCHAR DeviceModelID; // device model id -} QMIDMS_GET_DEVICE_MODEL_ID_RESP_MSG, *PQMIDMS_GET_DEVICE_MODEL_ID_RESP_MSG; -#endif - -typedef struct _QMIDMS_GET_DEVICE_REV_ID_REQ_MSG { - USHORT Type; // QMUX type 0x0005 - USHORT Length; -} __attribute__((packed)) QMIDMS_GET_DEVICE_REV_ID_REQ_MSG, - *PQMIDMS_GET_DEVICE_REV_ID_REQ_MSG; - -typedef struct _DEVICE_REV_ID { - UCHAR TLVType; - USHORT TLVLength; - UCHAR RevisionID; -} __attribute__((packed)) DEVICE_REV_ID, *PDEVICE_REV_ID; - -#if 0 -typedef struct _QMIDMS_GET_DEVICE_REV_ID_RESP_MSG -{ - USHORT Type; // QMUX type 0x0023 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT -} QMIDMS_GET_DEVICE_REV_ID_RESP_MSG, *PQMIDMS_GET_DEVICE_REV_ID_RESP_MSG; - -typedef struct _QMIDMS_GET_MSISDN_REQ_MSG -{ - USHORT Type; // QMUX type 0x0024 - USHORT Length; -} QMIDMS_GET_MSISDN_REQ_MSG, *PQMIDMS_GET_MSISDN_REQ_MSG; - -typedef struct _QCTLV_DEVICE_VOICE_NUMBERS -{ - UCHAR TLVType; // as defined above - USHORT TLVLength; // 4/7/7 - UCHAR VoideNumberString; // ESN, IMEI, or MEID - -} QCTLV_DEVICE_VOICE_NUMBERS, *PQCTLV_DEVICE_VOICE_NUMBERS; - - -typedef struct _QMIDMS_GET_MSISDN_RESP_MSG -{ - USHORT Type; // QMUX type 0x0024 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG -} QMIDMS_GET_MSISDN_RESP_MSG, *PQMIDMS_GET_MSISDN_RESP_MSG; -#endif - -typedef struct _QMIDMS_UIM_GET_IMSI_REQ_MSG { - USHORT Type; - USHORT Length; -} __attribute__((packed)) QMIDMS_UIM_GET_IMSI_REQ_MSG, - *PQMIDMS_UIM_GET_IMSI_REQ_MSG; - -typedef struct _QMIDMS_UIM_GET_IMSI_RESP_MSG { - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; - UCHAR TLV2Type; - USHORT TLV2Length; - UCHAR IMSI; -} __attribute__((packed)) QMIDMS_UIM_GET_IMSI_RESP_MSG, - *PQMIDMS_UIM_GET_IMSI_RESP_MSG; - -#if 0 -typedef struct _QMIDMS_GET_DEVICE_SERIAL_NUMBERS_REQ_MSG -{ - USHORT Type; // QMUX type 0x0007 - USHORT Length; -} QMIDMS_GET_DEVICE_SERIAL_NUMBERS_REQ_MSG, *PQMIDMS_GET_DEVICE_SERIAL_NUMBERS_REQ_MSG; - -#define QCTLV_TYPE_SER_NUM_ESN 0x10 -#define QCTLV_TYPE_SER_NUM_IMEI 0x11 -#define QCTLV_TYPE_SER_NUM_MEID 0x12 - -typedef struct _QCTLV_DEVICE_SERIAL_NUMBER -{ - UCHAR TLVType; // as defined above - USHORT TLVLength; // 4/7/7 - UCHAR SerialNumberString; // ESN, IMEI, or MEID - -} QCTLV_DEVICE_SERIAL_NUMBER, *PQCTLV_DEVICE_SERIAL_NUMBER; - -typedef struct _QMIDMS_GET_DEVICE_SERIAL_NUMBERS_RESP_MSG -{ - USHORT Type; // QMUX type 0x0007 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT - // followed by optional TLV -} QMIDMS_GET_DEVICE_SERIAL_NUMBERS_RESP_MSG, *PQMIDMS_GET_DEVICE_SERIAL_NUMBERS_RESP; - -typedef struct _QMIDMS_GET_DMS_BAND_CAP -{ - USHORT Type; - USHORT Length; -} QMIDMS_GET_BAND_CAP_REQ_MSG, *PQMIDMS_GET_BAND_CAP_REQ_MSG; - -typedef struct _QMIDMS_GET_BAND_CAP_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_NONE - // QMI_ERR_INTERNAL - // QMI_ERR_MALFORMED_MSG - // QMI_ERR_NO_MEMORY - - UCHAR TLV2Type; // 0x01 - USHORT TLV2Length; // 2 - ULONG64 BandCap; -} QMIDMS_GET_BAND_CAP_RESP_MSG, *PQMIDMS_GET_BAND_CAP_RESP; - -typedef struct _QMIDMS_GET_DEVICE_CAP_REQ_MSG -{ - USHORT Type; // QMUX type 0x0002 - USHORT Length; -} QMIDMS_GET_DEVICE_CAP_REQ_MSG, *PQMIDMS_GET_DEVICE_CAP_REQ_MSG; - -typedef struct _QMIDMS_GET_DEVICE_CAP_RESP_MSG -{ - USHORT Type; // QMUX type 0x0002 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMUX_RESULT_SUCCESS - // QMUX_RESULT_FAILURE - USHORT QMUXError; // QMUX_ERR_INVALID_ARG - // QMUX_ERR_NO_MEMORY - // QMUX_ERR_INTERNAL - // QMUX_ERR_FAULT - UCHAR TLV2Type; // 0x01 - USHORT TLV2Length; // 2 - - ULONG MaxTxChannelRate; - ULONG MaxRxChannelRate; - UCHAR VoiceCap; - UCHAR SimCap; - - UCHAR RadioIfListCnt; // #elements in radio interface list - UCHAR RadioIfList; // N 1-byte elements -} QMIDMS_GET_DEVICE_CAP_RESP_MSG, *PQMIDMS_GET_DEVICE_CAP_RESP_MSG; - -typedef struct _QMIDMS_GET_ACTIVATED_STATUS_REQ_MSG -{ - USHORT Type; // QMUX type 0x0002 - USHORT Length; -} QMIDMS_GET_ACTIVATED_STATUS_REQ_MSG, *PQMIDMS_GET_ACTIVATES_STATUD_REQ_MSG; - -typedef struct _QMIDMS_GET_ACTIVATED_STATUS_RESP_MSG -{ - USHORT Type; // QMUX type 0x0002 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMUX_RESULT_SUCCESS - // QMUX_RESULT_FAILURE - USHORT QMUXError; // QMUX_ERR_INVALID_ARG - // QMUX_ERR_NO_MEMORY - // QMUX_ERR_INTERNAL - // QMUX_ERR_FAULT - UCHAR TLV2Type; // 0x01 - USHORT TLV2Length; // 2 - - USHORT ActivatedStatus; -} QMIDMS_GET_ACTIVATED_STATUS_RESP_MSG, *PQMIDMS_GET_ACTIVATED_STATUS_RESP_MSG; - -typedef struct _QMIDMS_GET_OPERATING_MODE_REQ_MSG -{ - USHORT Type; // QMUX type 0x0002 - USHORT Length; -} QMIDMS_GET_OPERATING_MODE_REQ_MSG, *PQMIDMS_GET_OPERATING_MODE_REQ_MSG; - -typedef struct _OFFLINE_REASON -{ - UCHAR TLVType; - USHORT TLVLength; - USHORT OfflineReason; -} OFFLINE_REASON, *POFFLINE_REASON; - -typedef struct _HARDWARE_RESTRICTED_MODE -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR HardwareControlledMode; -} HARDWARE_RESTRICTED_MODE, *PHARDWARE_RESTRICTED_MODE; - -typedef struct _QMIDMS_GET_OPERATING_MODE_RESP_MSG -{ - USHORT Type; // QMUX type 0x0002 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMUX_RESULT_SUCCESS - // QMUX_RESULT_FAILURE - USHORT QMUXError; // QMUX_ERR_INVALID_ARG - // QMUX_ERR_NO_MEMORY - // QMUX_ERR_INTERNAL - // QMUX_ERR_FAULT - UCHAR TLV2Type; // 0x01 - USHORT TLV2Length; // 2 - - UCHAR OperatingMode; -} QMIDMS_GET_OPERATING_MODE_RESP_MSG, *PQMIDMS_GET_OPERATING_MODE_RESP_MSG; - -typedef struct _QMIDMS_UIM_GET_ICCID_REQ_MSG -{ - USHORT Type; // QMUX type 0x0024 - USHORT Length; -} QMIDMS_UIM_GET_ICCID_REQ_MSG, *PQMIDMS_UIM_GET_ICCID_REQ_MSG; - -typedef struct _QMIDMS_UIM_GET_ICCID_RESP_MSG -{ - USHORT Type; // QMUX type 0x0024 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT - UCHAR TLV2Type; // 0x01 - required parameter - USHORT TLV2Length; // var - UCHAR ICCID; // String of voice number -} QMIDMS_UIM_GET_ICCID_RESP_MSG, *PQMIDMS_UIM_GET_ICCID_RESP_MSG; -#endif - -typedef struct _QMIDMS_SET_OPERATING_MODE_REQ_MSG { - USHORT Type; // QMUX type 0x0002 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - UCHAR OperatingMode; -} __attribute__((packed)) QMIDMS_SET_OPERATING_MODE_REQ_MSG, - *PQMIDMS_SET_OPERATING_MODE_REQ_MSG; - -typedef struct _QMIDMS_SET_OPERATING_MODE_RESP_MSG { - USHORT Type; // QMUX type 0x0002 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMUX_RESULT_SUCCESS - // QMUX_RESULT_FAILURE - USHORT QMUXError; // QMUX_ERR_INVALID_ARG - // QMUX_ERR_NO_MEMORY - // QMUX_ERR_INTERNAL - // QMUX_ERR_FAULT -} __attribute__((packed)) QMIDMS_SET_OPERATING_MODE_RESP_MSG, - *PQMIDMS_SET_OPERATING_MODE_RESP_MSG; - -#if 0 -typedef struct _QMIDMS_ACTIVATE_AUTOMATIC_REQ_MSG -{ - USHORT Type; // QMUX type 0x0024 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // - UCHAR ActivateCodelen; - UCHAR ActivateCode; -} QMIDMS_ACTIVATE_AUTOMATIC_REQ_MSG, *PQMIDMS_ACTIVATE_AUTOMATIC_REQ_MSG; - -typedef struct _QMIDMS_ACTIVATE_AUTOMATIC_RESP_MSG -{ - USHORT Type; // QMUX type 0x0024 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT -} QMIDMS_ACTIVATE_AUTOMATIC_RESP_MSG, *PQMIDMS_ACTIVATE_AUTOMATIC_RESP_MSG; - - -typedef struct _SPC_MSG -{ - UCHAR SPC[6]; - USHORT SID; -} SPC_MSG, *PSPC_MSG; - -typedef struct _MDN_MSG -{ - UCHAR MDNLEN; - UCHAR MDN; -} MDN_MSG, *PMDN_MSG; - -typedef struct _MIN_MSG -{ - UCHAR MINLEN; - UCHAR MIN; -} MIN_MSG, *PMIN_MSG; - -typedef struct _PRL_MSG -{ - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // - USHORT PRLLEN; - UCHAR PRL; -} PRL_MSG, *PPRL_MSG; - -typedef struct _MN_HA_KEY_MSG -{ - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // - UCHAR MN_HA_KEY_LEN; - UCHAR MN_HA_KEY; -} MN_HA_KEY_MSG, *PMN_HA_KEY_MSG; - -typedef struct _MN_AAA_KEY_MSG -{ - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // - UCHAR MN_AAA_KEY_LEN; - UCHAR MN_AAA_KEY; -} MN_AAA_KEY_MSG, *PMN_AAA_KEY_MSG; - -typedef struct _QMIDMS_ACTIVATE_MANUAL_REQ_MSG -{ - USHORT Type; // QMUX type 0x0024 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // - UCHAR Value; -} QMIDMS_ACTIVATE_MANUAL_REQ_MSG, *PQMIDMS_ACTIVATE_MANUAL_REQ_MSG; - -typedef struct _QMIDMS_ACTIVATE_MANUAL_RESP_MSG -{ - USHORT Type; // QMUX type 0x0024 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT -} QMIDMS_ACTIVATE_MANUAL_RESP_MSG, *PQMIDMS_ACTIVATE_MANUAL_RESP_MSG; -#endif - -typedef struct _QMIDMS_UIM_GET_STATE_REQ_MSG { - USHORT Type; - USHORT Length; -} __attribute__((packed)) QMIDMS_UIM_GET_STATE_REQ_MSG, - *PQMIDMS_UIM_GET_STATE_REQ_MSG; - -typedef struct _QMIDMS_UIM_GET_STATE_RESP_MSG { - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; - UCHAR TLV2Type; - USHORT TLV2Length; - UCHAR UIMState; -} __attribute__((packed)) QMIDMS_UIM_GET_STATE_RESP_MSG, - *PQMIDMS_UIM_GET_STATE_RESP_MSG; - -typedef struct _QMIDMS_UIM_GET_PIN_STATUS_REQ_MSG { - USHORT Type; // QMUX type 0x0024 - USHORT Length; -} __attribute__((packed)) QMIDMS_UIM_GET_PIN_STATUS_REQ_MSG, - *PQMIDMS_UIM_GET_PIN_STATUS_REQ_MSG; - -typedef struct _QMIDMS_UIM_PIN_STATUS { - UCHAR TLVType; - USHORT TLVLength; - UCHAR PINStatus; - UCHAR PINVerifyRetriesLeft; - UCHAR PINUnblockRetriesLeft; -} __attribute__((packed)) QMIDMS_UIM_PIN_STATUS, *PQMIDMS_UIM_PIN_STATUS; - -#define QMI_PIN_STATUS_NOT_INIT 0 -#define QMI_PIN_STATUS_NOT_VERIF 1 -#define QMI_PIN_STATUS_VERIFIED 2 -#define QMI_PIN_STATUS_DISABLED 3 -#define QMI_PIN_STATUS_BLOCKED 4 -#define QMI_PIN_STATUS_PERM_BLOCKED 5 -#define QMI_PIN_STATUS_UNBLOCKED 6 -#define QMI_PIN_STATUS_CHANGED 7 - -typedef struct _QMIDMS_UIM_GET_PIN_STATUS_RESP_MSG { - USHORT Type; // QMUX type 0x0024 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT - UCHAR PinStatus; -} __attribute__((packed)) QMIDMS_UIM_GET_PIN_STATUS_RESP_MSG, - *PQMIDMS_UIM_GET_PIN_STATUS_RESP_MSG; - -#if 0 -typedef struct _QMIDMS_UIM_GET_CK_STATUS_REQ_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - UCHAR Facility; -} QMIDMS_UIM_GET_CK_STATUS_REQ_MSG, *PQMIDMS_UIM_GET_CK_STATUS_REQ_MSG; - - -typedef struct _QMIDMS_UIM_CK_STATUS -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR FacilityStatus; - UCHAR FacilityVerifyRetriesLeft; - UCHAR FacilityUnblockRetriesLeft; -} QMIDMS_UIM_CK_STATUS, *PQMIDMS_UIM_CK_STATUS; - -typedef struct _QMIDMS_UIM_CK_OPERATION_STATUS -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR OperationBlocking; -} QMIDMS_UIM_CK_OPERATION_STATUS, *PQMIDMS_UIM_CK_OPERATION_STATUS; - -typedef struct _QMIDMS_UIM_GET_CK_STATUS_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; - UCHAR CkStatus; -} QMIDMS_UIM_GET_CK_STATUS_RESP_MSG, *PQMIDMS_UIM_GET_CK_STATUS_RESP_MSG; -#endif - -typedef struct _QMIDMS_UIM_VERIFY_PIN_REQ_MSG { - USHORT Type; // QMUX type 0x0024 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - UCHAR PINID; - UCHAR PINLen; - UCHAR PINValue; -} __attribute__((packed)) QMIDMS_UIM_VERIFY_PIN_REQ_MSG, - *PQMIDMS_UIM_VERIFY_PIN_REQ_MSG; - -typedef struct _QMIDMS_UIM_VERIFY_PIN_RESP_MSG { - USHORT Type; // QMUX type 0x0024 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT - UCHAR TLV2Type; - USHORT TLV2Length; - UCHAR PINVerifyRetriesLeft; - UCHAR PINUnblockRetriesLeft; -} __attribute__((packed)) QMIDMS_UIM_VERIFY_PIN_RESP_MSG, - *PQMIDMS_UIM_VERIFY_PIN_RESP_MSG; - -#if 0 -typedef struct _QMIDMS_UIM_SET_PIN_PROTECTION_REQ_MSG -{ - USHORT Type; // QMUX type 0x0024 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - UCHAR PINID; - UCHAR ProtectionSetting; - UCHAR PINLen; - UCHAR PINValue; -} QMIDMS_UIM_SET_PIN_PROTECTION_REQ_MSG, *PQMIDMS_UIM_SET_PIN_PROTECTION_REQ_MSG; - -typedef struct _QMIDMS_UIM_SET_PIN_PROTECTION_RESP_MSG -{ - USHORT Type; // QMUX type 0x0024 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT - UCHAR TLV2Type; - USHORT TLV2Length; - UCHAR PINVerifyRetriesLeft; - UCHAR PINUnblockRetriesLeft; -} QMIDMS_UIM_SET_PIN_PROTECTION_RESP_MSG, *PQMIDMS_UIM_SET_PIN_PROTECTION_RESP_MSG; - -typedef struct _QMIDMS_UIM_SET_CK_PROTECTION_REQ_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - UCHAR Facility; - UCHAR FacilityState; - UCHAR FacliltyLen; - UCHAR FacliltyValue; -} QMIDMS_UIM_SET_CK_PROTECTION_REQ_MSG, *PQMIDMS_UIM_SET_CK_PROTECTION_REQ_MSG; - -typedef struct _QMIDMS_UIM_SET_CK_PROTECTION_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; - UCHAR TLV2Type; - USHORT TLV2Length; - UCHAR FacilityRetriesLeft; -} QMIDMS_UIM_SET_CK_PROTECTION_RESP_MSG, *PQMIDMS_UIM_SET_CK_PROTECTION_RESP_MSG; - - -typedef struct _UIM_PIN -{ - UCHAR PinLength; - UCHAR PinValue; -} UIM_PIN, *PUIM_PIN; - -typedef struct _QMIDMS_UIM_CHANGE_PIN_REQ_MSG -{ - USHORT Type; // QMUX type 0x0024 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - UCHAR PINID; - UCHAR PinDetails; -} QMIDMS_UIM_CHANGE_PIN_REQ_MSG, *PQMIDMS_UIM_CHANGE_PIN_REQ_MSG; - -typedef struct QMIDMS_UIM_CHANGE_PIN_RESP_MSG -{ - USHORT Type; // QMUX type 0x0024 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT - UCHAR TLV2Type; - USHORT TLV2Length; - UCHAR PINVerifyRetriesLeft; - UCHAR PINUnblockRetriesLeft; -} QMIDMS_UIM_CHANGE_PIN_RESP_MSG, *PQMIDMS_UIM_CHANGE_PIN_RESP_MSG; - -typedef struct _UIM_PUK -{ - UCHAR PukLength; - UCHAR PukValue; -} UIM_PUK, *PUIM_PUK; - -typedef struct _QMIDMS_UIM_UNBLOCK_PIN_REQ_MSG -{ - USHORT Type; // QMUX type 0x0024 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - UCHAR PINID; - UCHAR PinDetails; -} QMIDMS_UIM_UNBLOCK_PIN_REQ_MSG, *PQMIDMS_UIM_BLOCK_PIN_REQ_MSG; - -typedef struct QMIDMS_UIM_UNBLOCK_PIN_RESP_MSG -{ - USHORT Type; // QMUX type 0x0024 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT - UCHAR TLV2Type; - USHORT TLV2Length; - UCHAR PINVerifyRetriesLeft; - UCHAR PINUnblockRetriesLeft; -} QMIDMS_UIM_UNBLOCK_PIN_RESP_MSG, *PQMIDMS_UIM_UNBLOCK_PIN_RESP_MSG; - -typedef struct _QMIDMS_UIM_UNBLOCK_CK_REQ_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - UCHAR Facility; - UCHAR FacliltyUnblockLen; - UCHAR FacliltyUnblockValue; -} QMIDMS_UIM_UNBLOCK_CK_REQ_MSG, *PQMIDMS_UIM_BLOCK_CK_REQ_MSG; - -typedef struct QMIDMS_UIM_UNBLOCK_CK_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; - UCHAR TLV2Type; - USHORT TLV2Length; - UCHAR FacilityUnblockRetriesLeft; -} QMIDMS_UIM_UNBLOCK_CK_RESP_MSG, *PQMIDMS_UIM_UNBLOCK_CK_RESP_MSG; - -typedef struct _QMIDMS_SET_EVENT_REPORT_REQ_MSG -{ - USHORT Type; - USHORT Length; -} QMIDMS_SET_EVENT_REPORT_REQ_MSG, *PQMIDMS_SET_EVENT_REPORT_REQ_MSG; - -typedef struct _QMIDMS_SET_EVENT_REPORT_RESP_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG -} QMIDMS_SET_EVENT_REPORT_RESP_MSG, *PQMIDMS_SET_EVENT_REPORT_RESP_MSG; - -typedef struct _PIN_STATUS -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR ReportPinState; -} PIN_STATUS, *PPIN_STATUS; - -typedef struct _POWER_STATUS -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR PowerStatus; - UCHAR BatteryLvl; -} POWER_STATUS, *PPOWER_STATUS; - -typedef struct _ACTIVATION_STATE -{ - UCHAR TLVType; - USHORT TLVLength; - USHORT ActivationState; -} ACTIVATION_STATE, *PACTIVATION_STATE; - -typedef struct _ACTIVATION_STATE_REQ -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR ActivationState; -} ACTIVATION_STATE_REQ, *PACTIVATION_STATE_REQ; - -typedef struct _OPERATING_MODE -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR OperatingMode; -} OPERATING_MODE, *POPERATING_MODE; - -typedef struct _UIM_STATE -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR UIMState; -} UIM_STATE, *PUIM_STATE; - -typedef struct _WIRELESS_DISABLE_STATE -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR WirelessDisableState; -} WIRELESS_DISABLE_STATE, *PWIRELESS_DISABLE_STATE; - -typedef struct _QMIDMS_EVENT_REPORT_IND_MSG -{ - USHORT Type; - USHORT Length; -} QMIDMS_EVENT_REPORT_IND_MSG, *PQMIDMS_EVENT_REPORT_IND_MSG; -#endif - -// ============================ END OF DMS =============================== - -// ======================= QOS ============================== -typedef struct _MPIOC_DEV_INFO MPIOC_DEV_INFO, *PMPIOC_DEV_INFO; - -#define QMI_QOS_SET_EVENT_REPORT_REQ 0x0001 -#define QMI_QOS_SET_EVENT_REPORT_RESP 0x0001 -#define QMI_QOS_EVENT_REPORT_IND 0x0001 - -#if 0 -typedef struct _QMI_QOS_SET_EVENT_REPORT_REQ_MSG -{ - USHORT Type; // QMUX type 0x0001 - USHORT Length; - // UCHAR TLVType; // 0x01 - physical link state - // USHORT TLVLength; // 1 - // UCHAR PhyLinkStatusRpt; // 0-enable; 1-disable - UCHAR TLVType2; // 0x02 = global flow reporting - USHORT TLVLength2; // 1 - UCHAR GlobalFlowRpt; // 1-enable; 0-disable -} QMI_QOS_SET_EVENT_REPORT_REQ_MSG, *PQMI_QOS_SET_EVENT_REPORT_REQ_MSG; - -typedef struct _QMI_QOS_SET_EVENT_REPORT_RESP_MSG -{ - USHORT Type; // QMUX type 0x0010 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMUX_RESULT_SUCCESS - // QMUX_RESULT_FAILURE - USHORT QMUXError; // QMUX_ERR_INVALID_ARG - // QMUX_ERR_NO_MEMORY - // QMUX_ERR_INTERNAL - // QMUX_ERR_FAULT -} QMI_QOS_SET_EVENT_REPORT_RESP_MSG, *PQMI_QOS_SET_EVENT_REPORT_RESP_MSG; - -typedef struct _QMI_QOS_EVENT_REPORT_IND_MSG -{ - USHORT Type; // QMUX type 0x0001 - USHORT Length; - UCHAR TLVs; -} QMI_QOS_EVENT_REPORT_IND_MSG, *PQMI_QOS_EVENT_REPORT_IND_MSG; - -#define QOS_EVENT_RPT_IND_FLOW_ACTIVATED 0x01 -#define QOS_EVENT_RPT_IND_FLOW_MODIFIED 0x02 -#define QOS_EVENT_RPT_IND_FLOW_DELETED 0x03 -#define QOS_EVENT_RPT_IND_FLOW_SUSPENDED 0x04 -#define QOS_EVENT_RPT_IND_FLOW_ENABLED 0x05 -#define QOS_EVENT_RPT_IND_FLOW_DISABLED 0x06 - -#define QOS_EVENT_RPT_IND_TLV_PHY_LINK_STATE_TYPE 0x01 -#define QOS_EVENT_RPT_IND_TLV_GLOBAL_FL_RPT_STATE 0x10 -#define QOS_EVENT_RPT_IND_TLV_GLOBAL_FL_RPT_TYPE 0x10 -#define QOS_EVENT_RPT_IND_TLV_TX_FLOW_TYPE 0x11 -#define QOS_EVENT_RPT_IND_TLV_RX_FLOW_TYPE 0x12 -#define QOS_EVENT_RPT_IND_TLV_TX_FILTER_TYPE 0x13 -#define QOS_EVENT_RPT_IND_TLV_RX_FILTER_TYPE 0x14 -#define QOS_EVENT_RPT_IND_TLV_FLOW_SPEC 0x10 -#define QOS_EVENT_RPT_IND_TLV_FILTER_SPEC 0x10 - -typedef struct _QOS_EVENT_RPT_IND_TLV_PHY_LINK_STATE -{ - UCHAR TLVType; // 0x01 - USHORT TLVLength; // 1 - UCHAR PhyLinkState; // 0-dormant, 1-active -} QOS_EVENT_RPT_IND_TLV_PHY_LINK_STATE, *PQOS_EVENT_RPT_IND_TLV_PHY_LINK_STATE; - -typedef struct _QOS_EVENT_RPT_IND_TLV_GLOBAL_FL_RPT -{ - UCHAR TLVType; // 0x10 - USHORT TLVLength; // 6 - ULONG QosId; - UCHAR NewFlow; // 1: newly added flow; 0: existing flow - UCHAR StateChange; // 1: activated; 2: modified; 3: deleted; - // 4: suspended(delete); 5: enabled; 6: disabled -} QOS_EVENT_RPT_IND_TLV_GLOBAL_FL_RPT, *PQOS_EVENT_RPT_IND_TLV_GLOBAL_FL_RPT; - -// QOS Flow - -typedef struct _QOS_EVENT_RPT_IND_TLV_FLOW -{ - UCHAR TLVType; // 0x10-TX flow; 0x11-RX flow - USHORT TLVLength; // var - // embedded TLV's -} QOS_EVENT_RPT_IND_TLV_TX_FLOW, *PQOS_EVENT_RPT_IND_TLV_TX_FLOW; - -#define QOS_FLOW_TLV_IP_FLOW_IDX_TYPE 0x10 -#define QOS_FLOW_TLV_IP_FLOW_TRAFFIC_CLASS_TYPE 0x11 -#define QOS_FLOW_TLV_IP_FLOW_DATA_RATE_MIN_MAX_TYPE 0x12 -#define QOS_FLOW_TLV_IP_FLOW_DATA_RATE_TOKEN_BUCKET_TYPE 0x13 -#define QOS_FLOW_TLV_IP_FLOW_LATENCY_TYPE 0x14 -#define QOS_FLOW_TLV_IP_FLOW_JITTER_TYPE 0x15 -#define QOS_FLOW_TLV_IP_FLOW_PKT_ERR_RATE_TYPE 0x16 -#define QOS_FLOW_TLV_IP_FLOW_MIN_PKT_SIZE_TYPE 0x17 -#define QOS_FLOW_TLV_IP_FLOW_MAX_PKT_SIZE_TYPE 0x18 -#define QOS_FLOW_TLV_IP_FLOW_3GPP_BIT_ERR_RATE_TYPE 0x19 -#define QOS_FLOW_TLV_IP_FLOW_3GPP_TRAF_PRIORITY_TYPE 0x1A -#define QOS_FLOW_TLV_IP_FLOW_3GPP2_PROFILE_ID_TYPE 0x1B - -typedef struct _QOS_FLOW_TLV_IP_FLOW_IDX -{ - UCHAR TLVType; // 0x10 - USHORT TLVLength; // 1 - UCHAR IpFlowIndex; -} QOS_FLOW_TLV_IP_FLOW_IDX, *PQOS_FLOW_TLV_IP_FLOW_IDX; - -typedef struct _QOS_FLOW_TLV_IP_FLOW_TRAFFIC_CLASS -{ - UCHAR TLVType; // 0x11 - USHORT TLVLength; // 1 - UCHAR TrafficClass; -} QOS_FLOW_TLV_IP_FLOW_TRAFFIC_CLASS, *PQOS_FLOW_TLV_IP_FLOW_TRAFFIC_CLASS; - -typedef struct _QOS_FLOW_TLV_IP_FLOW_DATA_RATE_MIN_MAX -{ - UCHAR TLVType; // 0x12 - USHORT TLVLength; // 8 - ULONG DataRateMax; - ULONG GuaranteedRate; -} QOS_FLOW_TLV_IP_FLOW_DATA_RATE_MIN_MAX, *PQOS_FLOW_TLV_IP_FLOW_DATA_RATE_MIN_MAX; - -typedef struct _QOS_FLOW_TLV_IP_FLOW_DATA_RATE_TOKEN_BUCKET -{ - UCHAR TLVType; // 0x13 - USHORT TLVLength; // 12 - ULONG PeakRate; - ULONG TokenRate; - ULONG BucketSize; -} QOS_FLOW_TLV_IP_FLOW_DATA_RATE_TOKEN_BUCKET, *PQOS_FLOW_TLV_IP_FLOW_DATA_RATE_TOKEN_BUCKET; - -typedef struct _QOS_FLOW_TLV_IP_FLOW_LATENCY -{ - UCHAR TLVType; // 0x14 - USHORT TLVLength; // 4 - ULONG IpFlowLatency; -} QOS_FLOW_TLV_IP_FLOW_LATENCY, *PQOS_FLOW_TLV_IP_FLOW_LATENCY; - -typedef struct _QOS_FLOW_TLV_IP_FLOW_JITTER -{ - UCHAR TLVType; // 0x15 - USHORT TLVLength; // 4 - ULONG IpFlowJitter; -} QOS_FLOW_TLV_IP_FLOW_JITTER, *PQOS_FLOW_TLV_IP_FLOW_JITTER; - -typedef struct _QOS_FLOW_TLV_IP_FLOW_PKT_ERR_RATE -{ - UCHAR TLVType; // 0x16 - USHORT TLVLength; // 4 - USHORT ErrRateMultiplier; - USHORT ErrRateExponent; -} QOS_FLOW_TLV_IP_FLOW_PKT_ERR_RATE, *PQOS_FLOW_TLV_IP_FLOW_PKT_ERR_RATE; - -typedef struct _QOS_FLOW_TLV_IP_FLOW_MIN_PKT_SIZE -{ - UCHAR TLVType; // 0x17 - USHORT TLVLength; // 4 - ULONG MinPolicedPktSize; -} QOS_FLOW_TLV_IP_FLOW_MIN_PKT_SIZE, *PQOS_FLOW_TLV_IP_FLOW_MIN_PKT_SIZE; - -typedef struct _QOS_FLOW_TLV_IP_FLOW_MAX_PKT_SIZE -{ - UCHAR TLVType; // 0x18 - USHORT TLVLength; // 4 - ULONG MaxAllowedPktSize; -} QOS_FLOW_TLV_IP_FLOW_MAX_PKT_SIZE, *PQOS_FLOW_TLV_IP_FLOW_MAX_PKT_SIZE; - -typedef struct _QOS_FLOW_TLV_IP_FLOW_3GPP_BIT_ERR_RATE -{ - UCHAR TLVType; // 0x19 - USHORT TLVLength; // 1 - UCHAR ResidualBitErrorRate; -} QOS_FLOW_TLV_IP_FLOW_3GPP_BIT_ERR_RATE, *PQOS_FLOW_TLV_IP_FLOW_3GPP_BIT_ERR_RATE; - -typedef struct _QOS_FLOW_TLV_IP_FLOW_3GPP_TRAF_PRIORITY -{ - UCHAR TLVType; // 0x1A - USHORT TLVLength; // 1 - UCHAR TrafficHandlingPriority; -} QOS_FLOW_TLV_IP_FLOW_3GPP_TRAF_PRIORITY, *PQOS_FLOW_TLV_IP_FLOW_3GPP_TRAF_PRIORITY; - -typedef struct _QOS_FLOW_TLV_IP_FLOW_3GPP2_PROFILE_ID -{ - UCHAR TLVType; // 0x1B - USHORT TLVLength; // 2 - USHORT ProfileId; -} QOS_FLOW_TLV_IP_FLOW_3GPP2_PROFILE_ID, *PQOS_FLOW_TLV_IP_FLOW_3GPP2_PROFILE_ID; - -// QOS Filter - -#define QOS_FILTER_TLV_IP_FILTER_IDX_TYPE 0x10 -#define QOS_FILTER_TLV_IP_VERSION_TYPE 0x11 -#define QOS_FILTER_TLV_IPV4_SRC_ADDR_TYPE 0x12 -#define QOS_FILTER_TLV_IPV4_DEST_ADDR_TYPE 0x13 -#define QOS_FILTER_TLV_NEXT_HDR_PROTOCOL_TYPE 0x14 -#define QOS_FILTER_TLV_IPV4_TYPE_OF_SERVICE_TYPE 0x15 -#define QOS_FILTER_TLV_TCP_UDP_PORT_SRC_TCP_TYPE 0x1B -#define QOS_FILTER_TLV_TCP_UDP_PORT_DEST_TCP_TYPE 0x1C -#define QOS_FILTER_TLV_TCP_UDP_PORT_SRC_UDP_TYPE 0x1D -#define QOS_FILTER_TLV_TCP_UDP_PORT_DEST_UDP_TYPE 0x1E -#define QOS_FILTER_TLV_ICMP_FILTER_MSG_TYPE_TYPE 0x1F -#define QOS_FILTER_TLV_ICMP_FILTER_MSG_CODE_TYPE 0x20 -#define QOS_FILTER_TLV_TCP_UDP_PORT_SRC_TYPE 0x24 -#define QOS_FILTER_TLV_TCP_UDP_PORT_DEST_TYPE 0x25 - -typedef struct _QOS_EVENT_RPT_IND_TLV_FILTER -{ - UCHAR TLVType; // 0x12-TX filter; 0x13-RX filter - USHORT TLVLength; // var - // embedded TLV's -} QOS_EVENT_RPT_IND_TLV_RX_FILTER, *PQOS_EVENT_RPT_IND_TLV_RX_FILTER; - -typedef struct _QOS_FILTER_TLV_IP_FILTER_IDX -{ - UCHAR TLVType; // 0x10 - USHORT TLVLength; // 1 - UCHAR IpFilterIndex; -} QOS_FILTER_TLV_IP_FILTER_IDX, *PQOS_FILTER_TLV_IP_FILTER_IDX; - -typedef struct _QOS_FILTER_TLV_IP_VERSION -{ - UCHAR TLVType; // 0x11 - USHORT TLVLength; // 1 - UCHAR IpVersion; -} QOS_FILTER_TLV_IP_VERSION, *PQOS_FILTER_TLV_IP_VERSION; - -typedef struct _QOS_FILTER_TLV_IPV4_SRC_ADDR -{ - UCHAR TLVType; // 0x12 - USHORT TLVLength; // 8 - ULONG IpSrcAddr; - ULONG IpSrcSubnetMask; -} QOS_FILTER_TLV_IPV4_SRC_ADDR, *PQOS_FILTER_TLV_IPV4_SRC_ADDR; - -typedef struct _QOS_FILTER_TLV_IPV4_DEST_ADDR -{ - UCHAR TLVType; // 0x13 - USHORT TLVLength; // 8 - ULONG IpDestAddr; - ULONG IpDestSubnetMask; -} QOS_FILTER_TLV_IPV4_DEST_ADDR, *PQOS_FILTER_TLV_IPV4_DEST_ADDR; - -typedef struct _QOS_FILTER_TLV_NEXT_HDR_PROTOCOL -{ - UCHAR TLVType; // 0x14 - USHORT TLVLength; // 1 - UCHAR NextHdrProtocol; -} QOS_FILTER_TLV_NEXT_HDR_PROTOCOL, *PQOS_FILTER_TLV_NEXT_HDR_PROTOCOL; - -typedef struct _QOS_FILTER_TLV_IPV4_TYPE_OF_SERVICE -{ - UCHAR TLVType; // 0x15 - USHORT TLVLength; // 2 - UCHAR Ipv4TypeOfService; - UCHAR Ipv4TypeOfServiceMask; -} QOS_FILTER_TLV_IPV4_TYPE_OF_SERVICE, *PQOS_FILTER_TLV_IPV4_TYPE_OF_SERVICE; - -typedef struct _QOS_FILTER_TLV_TCP_UDP_PORT -{ - UCHAR TLVType; // source port: 0x1B-TCP; 0x1D-UDP - // dest port: 0x1C-TCP; 0x1E-UDP - USHORT TLVLength; // 4 - USHORT FilterPort; - USHORT FilterPortRange; -} QOS_FILTER_TLV_TCP_UDP_PORT, *PQOS_FILTER_TLV_TCP_UDP_PORT; - -typedef struct _QOS_FILTER_TLV_ICMP_FILTER_MSG_TYPE -{ - UCHAR TLVType; // 0x1F - USHORT TLVLength; // 1 - UCHAR IcmpFilterMsgType; -} QOS_FILTER_TLV_ICMP_FILTER_MSG_TYPE, *PQOS_FILTER_TLV_ICMP_FILTER_MSG_TYPE; - -typedef struct _QOS_FILTER_TLV_ICMP_FILTER_MSG_CODE -{ - UCHAR TLVType; // 0x20 - USHORT TLVLength; // 1 - UCHAR IcmpFilterMsgCode; -} QOS_FILTER_TLV_ICMP_FILTER_MSG_CODE, *PQOS_FILTER_TLV_ICMP_FILTER_MSG_CODE; - -#define QOS_FILTER_PRECEDENCE_INVALID 256 -#define QOS_FILTER_TLV_PRECEDENCE_TYPE 0x22 -#define QOS_FILTER_TLV_ID_TYPE 0x23 - -typedef struct _QOS_FILTER_TLV_PRECEDENCE -{ - UCHAR TLVType; // 0x22 - USHORT TLVLength; // 2 - USHORT Precedence; // precedence of the filter -} QOS_FILTER_TLV_PRECEDENCE, *PQOS_FILTER_TLV_PRECEDENCE; - -typedef struct _QOS_FILTER_TLV_ID -{ - UCHAR TLVType; // 0x23 - USHORT TLVLength; // 2 - USHORT FilterId; // filter ID -} QOS_FILTER_TLV_ID, *PQOS_FILTER_TLV_ID; - -#ifdef QCQOS_IPV6 - -#define QOS_FILTER_TLV_IPV6_SRC_ADDR_TYPE 0x16 -#define QOS_FILTER_TLV_IPV6_DEST_ADDR_TYPE 0x17 -#define QOS_FILTER_TLV_IPV6_NEXT_HDR_PROTOCOL_TYPE 0x14 // same as IPV4 -#define QOS_FILTER_TLV_IPV6_TRAFFIC_CLASS_TYPE 0x19 -#define QOS_FILTER_TLV_IPV6_FLOW_LABEL_TYPE 0x1A - -typedef struct _QOS_FILTER_TLV_IPV6_SRC_ADDR -{ - UCHAR TLVType; // 0x16 - USHORT TLVLength; // 17 - UCHAR IpSrcAddr[16]; - UCHAR IpSrcAddrPrefixLen; // [0..128] -} QOS_FILTER_TLV_IPV6_SRC_ADDR, *PQOS_FILTER_TLV_IPV6_SRC_ADDR; - -typedef struct _QOS_FILTER_TLV_IPV6_DEST_ADDR -{ - UCHAR TLVType; // 0x17 - USHORT TLVLength; // 17 - UCHAR IpDestAddr[16]; - UCHAR IpDestAddrPrefixLen; // [0..128] -} QOS_FILTER_TLV_IPV6_DEST_ADDR, *PQOS_FILTER_TLV_IPV6_DEST_ADDR; - -#define QOS_FILTER_IPV6_NEXT_HDR_PROTOCOL_TCP 0x06 -#define QOS_FILTER_IPV6_NEXT_HDR_PROTOCOL_UDP 0x11 - -typedef struct _QOS_FILTER_TLV_IPV6_TRAFFIC_CLASS -{ - UCHAR TLVType; // 0x19 - USHORT TLVLength; // 2 - UCHAR TrafficClass; - UCHAR TrafficClassMask; // compare the first 6 bits only -} QOS_FILTER_TLV_IPV6_TRAFFIC_CLASS, *PQOS_FILTER_TLV_IPV6_TRAFFIC_CLASS; - -typedef struct _QOS_FILTER_TLV_IPV6_FLOW_LABEL -{ - UCHAR TLVType; // 0x1A - USHORT TLVLength; // 4 - ULONG FlowLabel; -} QOS_FILTER_TLV_IPV6_FLOW_LABEL, *PQOS_FILTER_TLV_IPV6_FLOW_LABEL; - -#endif // QCQOS_IPV6 -#endif - -// ======================= WMS ============================== -#define QMIWMS_SET_EVENT_REPORT_REQ 0x0001 -#define QMIWMS_SET_EVENT_REPORT_RESP 0x0001 -#define QMIWMS_EVENT_REPORT_IND 0x0001 -#define QMIWMS_RAW_SEND_REQ 0x0020 -#define QMIWMS_RAW_SEND_RESP 0x0020 -#define QMIWMS_RAW_WRITE_REQ 0x0021 -#define QMIWMS_RAW_WRITE_RESP 0x0021 -#define QMIWMS_RAW_READ_REQ 0x0022 -#define QMIWMS_RAW_READ_RESP 0x0022 -#define QMIWMS_MODIFY_TAG_REQ 0x0023 -#define QMIWMS_MODIFY_TAG_RESP 0x0023 -#define QMIWMS_DELETE_REQ 0x0024 -#define QMIWMS_DELETE_RESP 0x0024 -#define QMIWMS_GET_MESSAGE_PROTOCOL_REQ 0x0030 -#define QMIWMS_GET_MESSAGE_PROTOCOL_RESP 0x0030 -#define QMIWMS_LIST_MESSAGES_REQ 0x0031 -#define QMIWMS_LIST_MESSAGES_RESP 0x0031 -#define QMIWMS_GET_SMSC_ADDRESS_REQ 0x0034 -#define QMIWMS_GET_SMSC_ADDRESS_RESP 0x0034 -#define QMIWMS_SET_SMSC_ADDRESS_REQ 0x0035 -#define QMIWMS_SET_SMSC_ADDRESS_RESP 0x0035 -#define QMIWMS_GET_STORE_MAX_SIZE_REQ 0x0036 -#define QMIWMS_GET_STORE_MAX_SIZE_RESP 0x0036 - -#define WMS_MESSAGE_PROTOCOL_CDMA 0x00 -#define WMS_MESSAGE_PROTOCOL_WCDMA 0x01 - -#if 0 -typedef struct _QMIWMS_GET_MESSAGE_PROTOCOL_REQ_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; -} QMIWMS_GET_MESSAGE_PROTOCOL_REQ_MSG, *PQMIWMS_GET_MESSAGE_PROTOCOL_REQ_MSG; - -typedef struct _QMIWMS_GET_MESSAGE_PROTOCOL_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; - UCHAR TLV2Type; - USHORT TLV2Length; - UCHAR MessageProtocol; -} QMIWMS_GET_MESSAGE_PROTOCOL_RESP_MSG, *PQMIWMS_GET_MESSAGE_PROTOCOL_RESP_MSG; - -typedef struct _QMIWMS_GET_STORE_MAX_SIZE_REQ_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - UCHAR StorageType; -} QMIWMS_GET_STORE_MAX_SIZE_REQ_MSG, *PQMIWMS_GET_STORE_MAX_SIZE_REQ_MSG; - -typedef struct _QMIWMS_GET_STORE_MAX_SIZE_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; - UCHAR TLV2Type; - USHORT TLV2Length; - ULONG MemStoreMaxSize; -} QMIWMS_GET_STORE_MAX_SIZE_RESP_MSG, *PQMIWMS_GET_STORE_MAX_SIZE_RESP_MSG; - -typedef struct _REQUEST_TAG -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR TagType; -} REQUEST_TAG, *PREQUEST_TAG; - -typedef struct _QMIWMS_LIST_MESSAGES_REQ_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - UCHAR StorageType; -} QMIWMS_LIST_MESSAGES_REQ_MSG, *PQMIWMS_LIST_MESSAGES_REQ_MSG; - -typedef struct _QMIWMS_MESSAGE -{ - ULONG MessageIndex; - UCHAR TagType; -} QMIWMS_MESSAGE, *PQMIWMS_MESSAGE; - -typedef struct _QMIWMS_LIST_MESSAGES_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; - UCHAR TLV2Type; - USHORT TLV2Length; - ULONG NumMessages; -} QMIWMS_LIST_MESSAGES_RESP_MSG, *PQMIWMS_LIST_MESSAGES_RESP_MSG; - -typedef struct _QMIWMS_RAW_READ_REQ_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - UCHAR StorageType; - ULONG MemoryIndex; -} QMIWMS_RAW_READ_REQ_MSG, *PQMIWMS_RAW_READ_REQ_MSG; - -typedef struct _QMIWMS_RAW_READ_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; - UCHAR TLV2Type; - USHORT TLV2Length; - UCHAR TagType; - UCHAR Format; - USHORT MessageLength; - UCHAR Message; -} QMIWMS_RAW_READ_RESP_MSG, *PQMIWMS_RAW_READ_RESP_MSG; - -typedef struct _QMIWMS_MODIFY_TAG_REQ_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - UCHAR StorageType; - ULONG MemoryIndex; - UCHAR TagType; -} QMIWMS_MODIFY_TAG_REQ_MSG, *PQMIWMS_MODIFY_TAG_REQ_MSG; - -typedef struct _QMIWMS_MODIFY_TAG_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; -} QMIWMS_MODIFY_TAG_RESP_MSG, *PQMIWMS_MODIFY_TAG_RESP_MSG; - -typedef struct _QMIWMS_RAW_SEND_REQ_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - UCHAR SmsFormat; - USHORT SmsLength; - UCHAR SmsMessage; -} QMIWMS_RAW_SEND_REQ_MSG, *PQMIWMS_RAW_SEND_REQ_MSG; - -typedef struct _RAW_SEND_CAUSE_CODE -{ - UCHAR TLVType; - USHORT TLVLength; - USHORT CauseCode; -} RAW_SEND_CAUSE_CODE, *PRAW_SEND_CAUSE_CODE; - - -typedef struct _QMIWMS_RAW_SEND_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; -} QMIWMS_RAW_SEND_RESP_MSG, *PQMIWMS_RAW_SEND_RESP_MSG; - - -typedef struct _WMS_DELETE_MESSAGE_INDEX -{ - UCHAR TLVType; - USHORT TLVLength; - ULONG MemoryIndex; -} WMS_DELETE_MESSAGE_INDEX, *PWMS_DELETE_MESSAGE_INDEX; - -typedef struct _WMS_DELETE_MESSAGE_TAG -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR MessageTag; -} WMS_DELETE_MESSAGE_TAG, *PWMS_DELETE_MESSAGE_TAG; - -typedef struct _QMIWMS_DELETE_REQ_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - UCHAR StorageType; -} QMIWMS_DELETE_REQ_MSG, *PQMIWMS_DELETE_REQ_MSG; - -typedef struct _QMIWMS_DELETE_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; -} QMIWMS_DELETE_RESP_MSG, *PQMIWMS_DELETE_RESP_MSG; - - -typedef struct _QMIWMS_GET_SMSC_ADDRESS_REQ_MSG -{ - USHORT Type; - USHORT Length; -} QMIWMS_GET_SMSC_ADDRESS_REQ_MSG, *PQMIWMS_GET_SMSC_ADDRESS_REQ_MSG; - -typedef struct _QMIWMS_SMSC_ADDRESS -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR SMSCAddressType[3]; - UCHAR SMSCAddressLength; - UCHAR SMSCAddressDigits; -} QMIWMS_SMSC_ADDRESS, *PQMIWMS_SMSC_ADDRESS; - - -typedef struct _QMIWMS_GET_SMSC_ADDRESS_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; - UCHAR SMSCAddress; -} QMIWMS_GET_SMSC_ADDRESS_RESP_MSG, *PQMIWMS_GET_SMSC_ADDRESS_RESP_MSG; - -typedef struct _QMIWMS_SET_SMSC_ADDRESS_REQ_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - UCHAR SMSCAddress; -} QMIWMS_SET_SMSC_ADDRESS_REQ_MSG, *PQMIWMS_SET_SMSC_ADDRESS_REQ_MSG; - -typedef struct _QMIWMS_SET_SMSC_ADDRESS_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; -} QMIWMS_SET_SMSC_ADDRESS_RESP_MSG, *PQMIWMS_SET_SMSC_ADDRESS_RESP_MSG; - -typedef struct _QMIWMS_SET_EVENT_REPORT_REQ_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - UCHAR ReportNewMessage; -} QMIWMS_SET_EVENT_REPORT_REQ_MSG, *PQMIWMS_SET_EVENT_REPORT_REQ_MSG; - -typedef struct _QMIWMS_SET_EVENT_REPORT_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; -} QMIWMS_SET_EVENT_REPORT_RESP_MSG, *PQMIWMS_SET_EVENT_REPORT_RESP_MSG; - -typedef struct _QMIWMS_EVENT_REPORT_IND_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - UCHAR StorageType; - ULONG StorageIndex; -} QMIWMS_EVENT_REPORT_IND_MSG, *PQMIWMS_EVENT_REPORT_IND_MSG; -#endif - -// ======================= End of WMS ============================== - -// ======================= NAS ============================== -#define QMINAS_SET_EVENT_REPORT_REQ 0x0002 -#define QMINAS_SET_EVENT_REPORT_RESP 0x0002 -#define QMINAS_EVENT_REPORT_IND 0x0002 -#define QMINAS_GET_SIGNAL_STRENGTH_REQ 0x0020 -#define QMINAS_GET_SIGNAL_STRENGTH_RESP 0x0020 -#define QMINAS_PERFORM_NETWORK_SCAN_REQ 0x0021 -#define QMINAS_PERFORM_NETWORK_SCAN_RESP 0x0021 -#define QMINAS_INITIATE_NW_REGISTER_REQ 0x0022 -#define QMINAS_INITIATE_NW_REGISTER_RESP 0x0022 -#define QMINAS_INITIATE_ATTACH_REQ 0x0023 -#define QMINAS_INITIATE_ATTACH_RESP 0x0023 -#define QMINAS_GET_SERVING_SYSTEM_REQ 0x0024 -#define QMINAS_GET_SERVING_SYSTEM_RESP 0x0024 -#define QMINAS_SERVING_SYSTEM_IND 0x0024 -#define QMINAS_GET_HOME_NETWORK_REQ 0x0025 -#define QMINAS_GET_HOME_NETWORK_RESP 0x0025 -#define QMINAS_GET_PREFERRED_NETWORK_REQ 0x0026 -#define QMINAS_GET_PREFERRED_NETWORK_RESP 0x0026 -#define QMINAS_SET_PREFERRED_NETWORK_REQ 0x0027 -#define QMINAS_SET_PREFERRED_NETWORK_RESP 0x0027 -#define QMINAS_GET_FORBIDDEN_NETWORK_REQ 0x0028 -#define QMINAS_GET_FORBIDDEN_NETWORK_RESP 0x0028 -#define QMINAS_SET_FORBIDDEN_NETWORK_REQ 0x0029 -#define QMINAS_SET_FORBIDDEN_NETWORK_RESP 0x0029 -#define QMINAS_SET_TECHNOLOGY_PREF_REQ 0x002A -#define QMINAS_SET_TECHNOLOGY_PREF_RESP 0x002A -#define QMINAS_GET_RF_BAND_INFO_REQ 0x0031 -#define QMINAS_GET_RF_BAND_INFO_RESP 0x0031 -#define QMINAS_GET_PLMN_NAME_REQ 0x0044 -#define QMINAS_GET_PLMN_NAME_RESP 0x0044 -#define FIBO_PACKET_TRANSFER_START_IND 0X100 -#define FIBO_PACKET_TRANSFER_END_IND 0X101 -#define QMINAS_GET_SYS_INFO_REQ 0x004D -#define QMINAS_GET_SYS_INFO_RESP 0x004D -#define QMINAS_SYS_INFO_IND 0x004D - -typedef struct _QMINAS_GET_HOME_NETWORK_REQ_MSG { - USHORT Type; // QMUX type 0x0003 - USHORT Length; -} __attribute__((packed)) QMINAS_GET_HOME_NETWORK_REQ_MSG, - *PQMINAS_GET_HOME_NETWORK_REQ_MSG; - -typedef struct _HOME_NETWORK_SYSTEMID { - UCHAR TLVType; - USHORT TLVLength; - USHORT SystemID; - USHORT NetworkID; -} __attribute__((packed)) HOME_NETWORK_SYSTEMID, *PHOME_NETWORK_SYSTEMID; - -typedef struct _HOME_NETWORK { - UCHAR TLVType; - USHORT TLVLength; - USHORT MobileCountryCode; - USHORT MobileNetworkCode; - UCHAR NetworkDesclen; - UCHAR NetworkDesc; -} __attribute__((packed)) HOME_NETWORK, *PHOME_NETWORK; - -#if 0 -typedef struct _HOME_NETWORK_EXT -{ - UCHAR TLVType; - USHORT TLVLength; - USHORT MobileCountryCode; - USHORT MobileNetworkCode; - UCHAR NetworkDescDisp; - UCHAR NetworkDescEncoding; - UCHAR NetworkDesclen; - UCHAR NetworkDesc; -} HOME_NETWORK_EXT, *PHOME_NETWORK_EXT; - -typedef struct _QMINAS_GET_HOME_NETWORK_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; -} QMINAS_GET_HOME_NETWORK_RESP_MSG, *PQMINAS_GET_HOME_NETWORK_RESP_MSG; - -typedef struct _QMINAS_GET_PREFERRED_NETWORK_REQ_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; -} QMINAS_GET_PREFERRED_NETWORK_REQ_MSG, *PQMINAS_GET_PREFERRED_NETWORK_REQ_MSG; - - -typedef struct _PREFERRED_NETWORK -{ - USHORT MobileCountryCode; - USHORT MobileNetworkCode; - USHORT RadioAccess; -} PREFERRED_NETWORK, *PPREFERRED_NETWORK; - -typedef struct _QMINAS_GET_PREFERRED_NETWORK_RESP_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT - UCHAR TLV2Type; // 0x01 - required parameter - USHORT TLV2Length; // length of the mfr string - USHORT NumPreferredNetwork; -} QMINAS_GET_PREFERRED_NETWORK_RESP_MSG, *PQMINAS_GET_PREFERRED_NETWORK_RESP_MSG; - -typedef struct _QMINAS_GET_FORBIDDEN_NETWORK_REQ_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; -} QMINAS_GET_FORBIDDEN_NETWORK_REQ_MSG, *PQMINAS_GET_FORBIDDEN_NETWORK_REQ_MSG; - -typedef struct _FORBIDDEN_NETWORK -{ - USHORT MobileCountryCode; - USHORT MobileNetworkCode; -} FORBIDDEN_NETWORK, *PFORBIDDEN_NETWORK; - -typedef struct _QMINAS_GET_FORBIDDEN_NETWORK_RESP_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT - UCHAR TLV2Type; // 0x01 - required parameter - USHORT TLV2Length; // length of the mfr string - USHORT NumForbiddenNetwork; -} QMINAS_GET_FORBIDDEN_NETWORK_RESP_MSG, *PQMINAS_GET_FORBIDDEN_NETWORK_RESP_MSG; - -typedef struct _QMINAS_GET_SERVING_SYSTEM_REQ_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; -} QMINAS_GET_SERVING_SYSTEM_REQ_MSG, *PQMINAS_GET_SERVING_SYSTEM_REQ_MSG; - -typedef struct _QMINAS_ROAMING_INDICATOR_MSG -{ - UCHAR TLVType; // 0x01 - required parameter - USHORT TLVLength; // length of the mfr string - UCHAR RoamingIndicator; -} QMINAS_ROAMING_INDICATOR_MSG, *PQMINAS_ROAMING_INDICATOR_MSG; -#endif - -typedef struct _QMINAS_DATA_CAP { - UCHAR TLVType; // 0x01 - required parameter - USHORT TLVLength; // length of the mfr string - UCHAR DataCapListLen; - UCHAR DataCap; -} __attribute__((packed)) QMINAS_DATA_CAP, *PQMINAS_DATA_CAP; - -typedef struct _QMINAS_CURRENT_PLMN_MSG { - UCHAR TLVType; // 0x01 - required parameter - USHORT TLVLength; // length of the mfr string - USHORT MobileCountryCode; - USHORT MobileNetworkCode; - UCHAR NetworkDesclen; - UCHAR NetworkDesc; -} __attribute__((packed)) QMINAS_CURRENT_PLMN_MSG, *PQMINAS_CURRENT_PLMN_MSG; - -typedef struct _QMINAS_GET_SERVING_SYSTEM_RESP_MSG { - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; -} __attribute__((packed)) QMINAS_GET_SERVING_SYSTEM_RESP_MSG, - *PQMINAS_GET_SERVING_SYSTEM_RESP_MSG; - -typedef struct _SERVING_SYSTEM { - UCHAR TLVType; - USHORT TLVLength; - UCHAR RegistrationState; - UCHAR CSAttachedState; - UCHAR PSAttachedState; - UCHAR RegistredNetwork; - UCHAR InUseRadioIF; - UCHAR RadioIF; -} __attribute__((packed)) SERVING_SYSTEM, *PSERVING_SYSTEM; - -typedef struct _QMINAS_GET_SYS_INFO_RESP_MSG { - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; -} __attribute__((packed)) QMINAS_GET_SYS_INFO_RESP_MSG, - *PQMINAS_GET_SYS_INFO_RESP_MSG; - -typedef struct _QMINAS_SYS_INFO_IND_MSG { - USHORT Type; - USHORT Length; -} __attribute__((packed)) QMINAS_SYS_INFO_IND_MSG, *PQMINAS_SYS_INFO_IND_MSG; - -typedef struct _SERVICE_STATUS_INFO { - UCHAR TLVType; - USHORT TLVLength; - UCHAR SrvStatus; - UCHAR true_srv_status; - UCHAR IsPrefDataPath; -} __attribute__((packed)) SERVICE_STATUS_INFO, *PSERVICE_STATUS_INFO; - -typedef struct _CDMA_SYSTEM_INFO { - UCHAR TLVType; - USHORT TLVLength; - UCHAR SrvDomainValid; - UCHAR SrvDomain; - UCHAR SrvCapabilityValid; - UCHAR SrvCapability; - UCHAR RoamStatusValid; - UCHAR RoamStatus; - UCHAR IsSysForbiddenValid; - UCHAR IsSysForbidden; - UCHAR IsSysPrlMatchValid; - UCHAR IsSysPrlMatch; - UCHAR PRevInUseValid; - UCHAR PRevInUse; - UCHAR BSPRevValid; - UCHAR BSPRev; - UCHAR CCSSupportedValid; - UCHAR CCSSupported; - UCHAR CDMASysIdValid; - USHORT SID; - USHORT NID; - UCHAR BSInfoValid; - USHORT BaseID; - ULONG BaseLAT; - ULONG BaseLONG; - UCHAR PacketZoneValid; - USHORT PacketZone; - UCHAR NetworkIdValid; - UCHAR MCC[3]; - UCHAR MNC[3]; -} __attribute__((packed)) CDMA_SYSTEM_INFO, *PCDMA_SYSTEM_INFO; - -typedef struct _HDR_SYSTEM_INFO { - UCHAR TLVType; - USHORT TLVLength; - UCHAR SrvDomainValid; - UCHAR SrvDomain; - UCHAR SrvCapabilityValid; - UCHAR SrvCapability; - UCHAR RoamStatusValid; - UCHAR RoamStatus; - UCHAR IsSysForbiddenValid; - UCHAR IsSysForbidden; - UCHAR IsSysPrlMatchValid; - UCHAR IsSysPrlMatch; - UCHAR HdrPersonalityValid; - UCHAR HdrPersonality; - UCHAR HdrActiveProtValid; - UCHAR HdrActiveProt; - UCHAR is856SysIdValid; - UCHAR is856SysId[16]; -} __attribute__((packed)) HDR_SYSTEM_INFO, *PHDR_SYSTEM_INFO; - -typedef struct _GSM_SYSTEM_INFO { - UCHAR TLVType; - USHORT TLVLength; - UCHAR SrvDomainValid; - UCHAR SrvDomain; - UCHAR SrvCapabilityValid; - UCHAR SrvCapability; - UCHAR RoamStatusValid; - UCHAR RoamStatus; - UCHAR IsSysForbiddenValid; - UCHAR IsSysForbidden; - UCHAR LacValid; - USHORT Lac; - UCHAR CellIdValid; - ULONG CellId; - UCHAR RegRejectInfoValid; - UCHAR RejectSrvDomain; - UCHAR RejCause; - UCHAR NetworkIdValid; - UCHAR MCC[3]; - UCHAR MNC[3]; - UCHAR EgprsSuppValid; - UCHAR EgprsSupp; - UCHAR DtmSuppValid; - UCHAR DtmSupp; -} __attribute__((packed)) GSM_SYSTEM_INFO, *PGSM_SYSTEM_INFO; - -typedef struct _WCDMA_SYSTEM_INFO { - UCHAR TLVType; - USHORT TLVLength; - UCHAR SrvDomainValid; - UCHAR SrvDomain; - UCHAR SrvCapabilityValid; - UCHAR SrvCapability; - UCHAR RoamStatusValid; - UCHAR RoamStatus; - UCHAR IsSysForbiddenValid; - UCHAR IsSysForbidden; - UCHAR LacValid; - USHORT Lac; - UCHAR CellIdValid; - ULONG CellId; - UCHAR RegRejectInfoValid; - UCHAR RejectSrvDomain; - UCHAR RejCause; - UCHAR NetworkIdValid; - UCHAR MCC[3]; - UCHAR MNC[3]; - UCHAR HsCallStatusValid; - UCHAR HsCallStatus; - UCHAR HsIndValid; - UCHAR HsInd; - UCHAR PscValid; - UCHAR Psc; -} __attribute__((packed)) WCDMA_SYSTEM_INFO, *PWCDMA_SYSTEM_INFO; - -typedef struct _LTE_SYSTEM_INFO { - UCHAR TLVType; - USHORT TLVLength; - UCHAR SrvDomainValid; - UCHAR SrvDomain; - UCHAR SrvCapabilityValid; - UCHAR SrvCapability; - UCHAR RoamStatusValid; - UCHAR RoamStatus; - UCHAR IsSysForbiddenValid; - UCHAR IsSysForbidden; - UCHAR LacValid; - USHORT Lac; - UCHAR CellIdValid; - ULONG CellId; - UCHAR RegRejectInfoValid; - UCHAR RejectSrvDomain; - UCHAR RejCause; - UCHAR NetworkIdValid; - UCHAR MCC[3]; - UCHAR MNC[3]; - UCHAR TacValid; - USHORT Tac; -} __attribute__((packed)) LTE_SYSTEM_INFO, *PLTE_SYSTEM_INFO; -//begin modified by zhangkaibo add 5G network detect feature on x55 platform. 20200605 -typedef struct _NR5G_SYSTEM_INFO { - UCHAR TLVType; - USHORT TLVLength; - UCHAR SrvDomainValid; - UCHAR SrvDomain; - UCHAR SrvCapabilityValid; - UCHAR SrvCapability; - UCHAR RoamStatusValid; - UCHAR RoamStatus; - UCHAR IsSysForbiddenValid; - UCHAR IsSysForbidden; - UCHAR LacValid; - USHORT Lac; - UCHAR CellIdValid; - ULONG CellId; - UCHAR RegRejectInfoValid; - UCHAR RejectSrvDomain; - UCHAR RejCause; - UCHAR NetworkIdValid; - UCHAR MCC[3]; - UCHAR MNC[3]; - UCHAR TacValid; - USHORT Tac; -} __attribute__((packed)) NR5G_SYSTEM_INFO, *PNR5G_SYSTEM_INFO; - -//end modified by zhangkaibo add 5G network detect feature on x55 platform. 20200605 -typedef struct _TDSCDMA_SYSTEM_INFO { - UCHAR TLVType; - USHORT TLVLength; - UCHAR SrvDomainValid; - UCHAR SrvDomain; - UCHAR SrvCapabilityValid; - UCHAR SrvCapability; - UCHAR RoamStatusValid; - UCHAR RoamStatus; - UCHAR IsSysForbiddenValid; - UCHAR IsSysForbidden; - UCHAR LacValid; - USHORT Lac; - UCHAR CellIdValid; - ULONG CellId; - UCHAR RegRejectInfoValid; - UCHAR RejectSrvDomain; - UCHAR RejCause; - UCHAR NetworkIdValid; - UCHAR MCC[3]; - UCHAR MNC[3]; - UCHAR HsCallStatusValid; - UCHAR HsCallStatus; - UCHAR HsIndValid; - UCHAR HsInd; - UCHAR CellParameterIdValid; - USHORT CellParameterId; - UCHAR CellBroadcastCapValid; - ULONG CellBroadcastCap; - UCHAR CsBarStatusValid; - ULONG CsBarStatus; - UCHAR PsBarStatusValid; - ULONG PsBarStatus; - UCHAR CipherDomainValid; - UCHAR CipherDomain; -} __attribute__((packed)) TDSCDMA_SYSTEM_INFO, *PTDSCDMA_SYSTEM_INFO; - -#if 0 -typedef struct _QMINAS_SERVING_SYSTEM_IND_MSG -{ - USHORT Type; - USHORT Length; -} QMINAS_SERVING_SYSTEM_IND_MSG, *PQMINAS_SERVING_SYSTEM_IND_MSG; - -typedef struct _QMINAS_SET_PREFERRED_NETWORK_REQ_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT NumPreferredNetwork; - USHORT MobileCountryCode; - USHORT MobileNetworkCode; - USHORT RadioAccess; -} QMINAS_SET_PREFERRED_NETWORK_REQ_MSG, *PQMINAS_SET_PREFERRED_NETWORK_REQ_MSG; - -typedef struct _QMINAS_SET_PREFERRED_NETWORK_RESP_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT -} QMINAS_SET_PREFERRED_NETWORK_RESP_MSG, *PQMINAS_SET_PREFERRED_NETWORK_RESP_MSG; - -typedef struct _QMINAS_SET_FORBIDDEN_NETWORK_REQ_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT NumForbiddenNetwork; - USHORT MobileCountryCode; - USHORT MobileNetworkCode; -} QMINAS_SET_FORBIDDEN_NETWORK_REQ_MSG, *PQMINAS_SET_FORBIDDEN_NETWORK_REQ_MSG; - -typedef struct _QMINAS_SET_FORBIDDEN_NETWORK_RESP_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT -} QMINAS_SET_FORBIDDEN_NETWORK_RESP_MSG, *PQMINAS_SET_FORBIDDEN_NETWORK_RESP_MSG; - -typedef struct _QMINAS_PERFORM_NETWORK_SCAN_REQ_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; -} QMINAS_PERFORM_NETWORK_SCAN_REQ_MSG, *PQMINAS_PERFORM_NETWORK_SCAN_REQ_MSG; - -typedef struct _VISIBLE_NETWORK -{ - USHORT MobileCountryCode; - USHORT MobileNetworkCode; - UCHAR NetworkStatus; - UCHAR NetworkDesclen; -} VISIBLE_NETWORK, *PVISIBLE_NETWORK; - -typedef struct _QMINAS_PERFORM_NETWORK_SCAN_RESP_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT -} QMINAS_PERFORM_NETWORK_SCAN_RESP_MSG, *PQMINAS_PERFORM_NETWORK_SCAN_RESP_MSG; - -typedef struct _QMINAS_PERFORM_NETWORK_SCAN_NETWORK_INFO -{ - UCHAR TLVType; // 0x010 - required parameter - USHORT TLVLength; // length - USHORT NumNetworkInstances; -} QMINAS_PERFORM_NETWORK_SCAN_NETWORK_INFO, *PQMINAS_PERFORM_NETWORK_SCAN_NETWORK_INFO; - -typedef struct _QMINAS_PERFORM_NETWORK_SCAN_RAT_INFO -{ - UCHAR TLVType; // 0x011 - required parameter - USHORT TLVLength; // length - USHORT NumInst; -} QMINAS_PERFORM_NETWORK_SCAN_RAT_INFO, *PQMINAS_PERFORM_NETWORK_SCAN_RAT_INFO; - -typedef struct _QMINAS_PERFORM_NETWORK_SCAN_RAT -{ - USHORT MCC; - USHORT MNC; - UCHAR RAT; -} QMINAS_PERFORM_NETWORK_SCAN_RAT, *PQMINAS_PERFORM_NETWORK_SCAN_RAT; - - -typedef struct _QMINAS_MANUAL_NW_REGISTER -{ - UCHAR TLV2Type; // 0x02 - result code - USHORT TLV2Length; // 4 - USHORT MobileCountryCode; - USHORT MobileNetworkCode; - UCHAR RadioAccess; -} QMINAS_MANUAL_NW_REGISTER, *PQMINAS_MANUAL_NW_REGISTER; - -typedef struct _QMINAS_INITIATE_NW_REGISTER_REQ_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - UCHAR RegisterAction; -} QMINAS_INITIATE_NW_REGISTER_REQ_MSG, *PQMINAS_INITIATE_NW_REGISTER_REQ_MSG; - -typedef struct _QMINAS_INITIATE_NW_REGISTER_RESP_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT -} QMINAS_INITIATE_NW_REGISTER_RESP_MSG, *PQMINAS_INITIATE_NW_REGISTER_RESP_MSG; - -typedef struct _QMINAS_SET_TECHNOLOGY_PREF_REQ_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT TechPref; - UCHAR Duration; -} QMINAS_SET_TECHNOLOGY_PREF_REQ_MSG, *PQMINAS_SET_TECHNOLOGY_PREF_REQ_MSG; - -typedef struct _QMINAS_SET_TECHNOLOGY_PREF_RESP_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT -} QMINAS_SET_TECHNOLOGY_PREF_RESP_MSG, *PQMINAS_SET_TECHNOLOGY_PREF_RESP_MSG; - -typedef struct _QMINAS_GET_SIGNAL_STRENGTH_REQ_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; -} QMINAS_GET_SIGNAL_STRENGTH_REQ_MSG, *PQMINAS_GET_SIGNAL_STRENGTH_REQ_MSG; - -typedef struct _QMINAS_SIGNAL_STRENGTH -{ - CHAR SigStrength; - UCHAR RadioIf; -} QMINAS_SIGNAL_STRENGTH, *PQMINAS_SIGNAL_STRENGTH; - -typedef struct _QMINAS_SIGNAL_STRENGTH_LIST -{ - UCHAR TLV3Type; - USHORT TLV3Length; - USHORT NumInstance; -} QMINAS_SIGNAL_STRENGTH_LIST, *PQMINAS_SIGNAL_STRENGTH_LIST; - - -typedef struct _QMINAS_GET_SIGNAL_STRENGTH_RESP_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT - UCHAR TLV2Type; - USHORT TLV2Length; - CHAR SignalStrength; - UCHAR RadioIf; -} QMINAS_GET_SIGNAL_STRENGTH_RESP_MSG, *PQMINAS_GET_SIGNAL_STRENGTH_RESP_MSG; - - -typedef struct _QMINAS_SET_EVENT_REPORT_REQ_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - UCHAR ReportSigStrength; - UCHAR NumTresholds; - CHAR TresholdList[2]; -} QMINAS_SET_EVENT_REPORT_REQ_MSG, *PQMINAS_SET_EVENT_REPORT_REQ_MSG; - -typedef struct _QMINAS_SET_EVENT_REPORT_RESP_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT -} QMINAS_SET_EVENT_REPORT_RESP_MSG, *PQMINAS_SET_EVENT_REPORT_RESP_MSG; - -typedef struct _QMINAS_SIGNAL_STRENGTH_TLV -{ - UCHAR TLVType; - USHORT TLVLength; - CHAR SigStrength; - UCHAR RadioIf; -} QMINAS_SIGNAL_STRENGTH_TLV, *PQMINAS_SIGNAL_STRENGTH_TLV; - -typedef struct _QMINAS_REJECT_CAUSE_TLV -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR ServiceDomain; - USHORT RejectCause; -} QMINAS_REJECT_CAUSE_TLV, *PQMINAS_REJECT_CAUSE_TLV; - -typedef struct _QMINAS_EVENT_REPORT_IND_MSG -{ - USHORT Type; - USHORT Length; -} QMINAS_EVENT_REPORT_IND_MSG, *PQMINAS_EVENT_REPORT_IND_MSG; - -typedef struct _QMINAS_GET_RF_BAND_INFO_REQ_MSG -{ - USHORT Type; - USHORT Length; -} QMINAS_GET_RF_BAND_INFO_REQ_MSG, *PQMINAS_GET_RF_BAND_INFO_REQ_MSG; - -typedef struct _QMINASRF_BAND_INFO -{ - UCHAR RadioIf; - USHORT ActiveBand; - USHORT ActiveChannel; -} QMINASRF_BAND_INFO, *PQMINASRF_BAND_INFO; - -typedef struct _QMINAS_GET_RF_BAND_INFO_RESP_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT - UCHAR TLV2Type; - USHORT TLV2Length; - UCHAR NumInstances; -} QMINAS_GET_RF_BAND_INFO_RESP_MSG, *PQMINAS_GET_RF_BAND_INFO_RESP_MSG; - - -typedef struct _QMINAS_GET_PLMN_NAME_REQ_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT MCC; - USHORT MNC; -} QMINAS_GET_PLMN_NAME_REQ_MSG, *PQMINAS_GET_PLMN_NAME_REQ_MSG; - -typedef struct _QMINAS_GET_PLMN_NAME_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT -} QMINAS_GET_PLMN_NAME_RESP_MSG, *PQMINAS_GET_PLMN_NAME_RESP_MSG; - -typedef struct _QMINAS_GET_PLMN_NAME_SPN -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR SPN_Enc; - UCHAR SPN_Len; -} QMINAS_GET_PLMN_NAME_SPN, *PQMINAS_GET_PLMN_NAME_SPN; - -typedef struct _QMINAS_GET_PLMN_NAME_PLMN -{ - UCHAR PLMN_Enc; - UCHAR PLMN_Ci; - UCHAR PLMN_SpareBits; - UCHAR PLMN_Len; -} QMINAS_GET_PLMN_NAME_PLMN, *PQMINAS_GET_PLMN_NAME_PLMN; - -typedef struct _QMINAS_INITIATE_ATTACH_REQ_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - UCHAR PsAttachAction; -} QMINAS_INITIATE_ATTACH_REQ_MSG, *PQMINAS_INITIATE_ATTACH_REQ_MSG; - -typedef struct _QMINAS_INITIATE_ATTACH_RESP_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT -} QMINAS_INITIATE_ATTACH_RESP_MSG, *PQMINAS_INITIATE_ATTACH_RESP_MSG; -#endif -// ======================= End of NAS ============================== - -// ======================= UIM ============================== -#define QMIUIM_READ_TRANSPARENT_REQ 0x0020 -#define QMIUIM_READ_TRANSPARENT_RESP 0x0020 -#define QMIUIM_READ_TRANSPARENT_IND 0x0020 -#define QMIUIM_READ_RECORD_REQ 0x0021 -#define QMIUIM_READ_RECORD_RESP 0x0021 -#define QMIUIM_READ_RECORD_IND 0x0021 -#define QMIUIM_WRITE_TRANSPARENT_REQ 0x0022 -#define QMIUIM_WRITE_TRANSPARENT_RESP 0x0022 -#define QMIUIM_WRITE_TRANSPARENT_IND 0x0022 -#define QMIUIM_WRITE_RECORD_REQ 0x0023 -#define QMIUIM_WRITE_RECORD_RESP 0x0023 -#define QMIUIM_WRITE_RECORD_IND 0x0023 -#define QMIUIM_SET_PIN_PROTECTION_REQ 0x0025 -#define QMIUIM_SET_PIN_PROTECTION_RESP 0x0025 -#define QMIUIM_SET_PIN_PROTECTION_IND 0x0025 -#define QMIUIM_VERIFY_PIN_REQ 0x0026 -#define QMIUIM_VERIFY_PIN_RESP 0x0026 -#define QMIUIM_VERIFY_PIN_IND 0x0026 -#define QMIUIM_UNBLOCK_PIN_REQ 0x0027 -#define QMIUIM_UNBLOCK_PIN_RESP 0x0027 -#define QMIUIM_UNBLOCK_PIN_IND 0x0027 -#define QMIUIM_CHANGE_PIN_REQ 0x0028 -#define QMIUIM_CHANGE_PIN_RESP 0x0028 -#define QMIUIM_CHANGE_PIN_IND 0x0028 -#define QMIUIM_DEPERSONALIZATION_REQ 0x0029 -#define QMIUIM_DEPERSONALIZATION_RESP 0x0029 -#define QMIUIM_EVENT_REG_REQ 0x002E -#define QMIUIM_EVENT_REG_RESP 0x002E -#define QMIUIM_GET_CARD_STATUS_REQ 0x002F -#define QMIUIM_GET_CARD_STATUS_RESP 0x002F -#define QMIUIM_STATUS_CHANGE_IND 0x0032 - -typedef struct _QMIUIM_GET_CARD_STATUS_RESP_MSG { - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; -} __attribute__((packed)) QMIUIM_GET_CARD_STATUS_RESP_MSG, - *PQMIUIM_GET_CARD_STATUS_RESP_MSG; - -typedef struct _QMIUIM_PIN_STATE { - UCHAR UnivPIN; - UCHAR PIN1State; - UCHAR PIN1Retries; - UCHAR PUK1Retries; - UCHAR PIN2State; - UCHAR PIN2Retries; - UCHAR PUK2Retries; -} __attribute__((packed)) QMIUIM_PIN_STATE, *PQMIUIM_PIN_STATE; - -typedef struct _QMIUIM_APP_STATUS { - UCHAR AppType; - UCHAR AppState; - UCHAR PersoState; - UCHAR PersoFeature; - UCHAR PersoRetries; - UCHAR PersoUnblockRetries; - UCHAR AIDLength; - UCHAR AIDValue[16]; - QMIUIM_PIN_STATE PinState; -} __attribute__((packed)) QMIUIM_APP_STATUS, *PQMIUIM_APP_STATUS; - -//2021-03-24 willa.liu@fibocom.com changed begin for support mantis 0071817 -typedef struct _instance{ - UCHAR CardState; - UCHAR UPINState; - UCHAR UPINRetries; - UCHAR UPUKRetries; - UCHAR ErrorCode; - UCHAR NumApp; -}Instance; - -typedef struct _QMIUIM_CARD_STATUS { - UCHAR TLVType; - USHORT TLVLength; - USHORT IndexGWPri; - USHORT Index1XPri; - USHORT IndexGWSec; - USHORT Index1XSec; - UCHAR NumSlot; -/* - UCHAR CardState; - UCHAR UPINState; - UCHAR UPINRetries; - UCHAR UPUKRetries; - UCHAR ErrorCode; - UCHAR NumApp; - QMIUIM_APP_STATUS AppStatus[8]; -*/ -}__attribute__((packed)) QMIUIM_CARD_STATUS, *PQMIUIM_CARD_STATUS; -//2021-03-24 willa.liu@fibocom.com changed end for support mantis 0071817 - -typedef struct _QMIUIM_VERIFY_PIN_REQ_MSG { - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - UCHAR Session_Type; - UCHAR Aid_Len; - UCHAR TLV2Type; - USHORT TLV2Length; - UCHAR PINID; - UCHAR PINLen; - UCHAR PINValue; -} __attribute__((packed)) QMIUIM_VERIFY_PIN_REQ_MSG, - *PQMIUIM_VERIFY_PIN_REQ_MSG; - -typedef struct _QMIUIM_VERIFY_PIN_RESP_MSG { - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; - UCHAR TLV2Type; - USHORT TLV2Length; - UCHAR PINVerifyRetriesLeft; - UCHAR PINUnblockRetriesLeft; -} __attribute__((packed)) QMIUIM_VERIFY_PIN_RESP_MSG, - *PQMIUIM_VERIFY_PIN_RESP_MSG; - -//2021-03-24 willa.liu@fibocom.com changed begin for support mantis 0071817 -typedef struct _QMIUIM_BIND_PIN_REQ_MSG { - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - uint8_t Value; -} __attribute__((packed)) QMIUIM_BIND_PIN_REQ_MSG, *PQMIUIM_BIND_PIN_REQ_MSG; - -typedef struct _QMIUIM_BIND_PIN_REQ_MSG_4 { - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - UINT Value; -} __attribute__((packed)) QMIUIM_BIND_PIN_REQ_MSG_4; -//2021-03-24 willa.liu@fibocom.com changed end for support mantis 0071817 - -typedef struct _QMIUIM_READ_TRANSPARENT_REQ_MSG { - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - UCHAR Session_Type; - UCHAR Aid_Len; - UCHAR TLV2Type; - USHORT TLV2Length; - USHORT file_id; - UCHAR path_len; - UCHAR path[]; -} __attribute__((packed)) QMIUIM_READ_TRANSPARENT_REQ_MSG, - *PQMIUIM_READ_TRANSPARENT_REQ_MSG; - -typedef struct _READ_TRANSPARENT_TLV { - UCHAR TLVType; - USHORT TLVLength; - USHORT Offset; - USHORT Length; -} __attribute__((packed)) READ_TRANSPARENT_TLV, *PREAD_TRANSPARENT_TLV; - -typedef struct _QMIUIM_CONTENT { - UCHAR TLVType; - USHORT TLVLength; - USHORT content_len; - UCHAR content[]; -} __attribute__((packed)) QMIUIM_CONTENT, *PQMIUIM_CONTENT; - -typedef struct _QMIUIM_READ_TRANSPARENT_RESP_MSG { - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; -} __attribute__((packed)) QMIUIM_READ_TRANSPARENT_RESP_MSG, - *PQMIUIM_READ_TRANSPARENT_RESP_MSG; - -typedef struct _QMUX_MSG { - QCQMUX_HDR QMUXHdr; - union { - // Message Header - QCQMUX_MSG_HDR QMUXMsgHdr; - QCQMUX_MSG_HDR_RESP QMUXMsgHdrResp; - - // QMIWDS Message -#if 0 - QMIWDS_GET_PKT_SRVC_STATUS_REQ_MSG PacketServiceStatusReq; - QMIWDS_GET_PKT_SRVC_STATUS_RESP_MSG PacketServiceStatusRsp; - QMIWDS_GET_PKT_SRVC_STATUS_IND_MSG PacketServiceStatusInd; - QMIWDS_EVENT_REPORT_IND_MSG EventReportInd; - QMIWDS_GET_CURRENT_CHANNEL_RATE_REQ_MSG GetCurrChannelRateReq; - QMIWDS_GET_CURRENT_CHANNEL_RATE_RESP_MSG GetCurrChannelRateRsp; - QMIWDS_GET_PKT_STATISTICS_REQ_MSG GetPktStatsReq; - QMIWDS_GET_PKT_STATISTICS_RESP_MSG GetPktStatsRsp; - QMIWDS_SET_EVENT_REPORT_REQ_MSG EventReportReq; - QMIWDS_SET_EVENT_REPORT_RESP_MSG EventReportRsp; -#endif - //#ifdef QC_IP_MODE - QMIWDS_GET_RUNTIME_SETTINGS_REQ_MSG GetRuntimeSettingsReq; - QMIWDS_GET_RUNTIME_SETTINGS_RESP_MSG GetRuntimeSettingsRsp; - //#endif // QC_IP_MODE - QMIWDS_SET_CLIENT_IP_FAMILY_PREF_REQ_MSG SetClientIpFamilyPrefReq; - QMIWDS_SET_CLIENT_IP_FAMILY_PREF_RESP_MSG SetClientIpFamilyPrefResp; - QMIWDS_SET_AUTO_CONNECT_REQ_MSG SetAutoConnectReq; -#if 0 - QMIWDS_GET_MIP_MODE_REQ_MSG GetMipModeReq; - QMIWDS_GET_MIP_MODE_RESP_MSG GetMipModeResp; -#endif - QMIWDS_START_NETWORK_INTERFACE_REQ_MSG StartNwInterfaceReq; - QMIWDS_START_NETWORK_INTERFACE_RESP_MSG StartNwInterfaceResp; - QMIWDS_STOP_NETWORK_INTERFACE_REQ_MSG StopNwInterfaceReq; - QMIWDS_STOP_NETWORK_INTERFACE_RESP_MSG StopNwInterfaceResp; - QMIWDS_GET_DEFAULT_SETTINGS_REQ_MSG GetDefaultSettingsReq; - QMIWDS_GET_DEFAULT_SETTINGS_RESP_MSG GetDefaultSettingsResp; -//begin modified by zhangkaibo add create profile qmi. mantis 0049137,0048741 20200610 - QMIWDS_CREATE_PROFILE_SETTINGS_REQ_MSG CreateProfileSettingsReq; - QMIWDS_CREATE_PROFILE_SETTINGS_RESP_MSG CreateProfileSettingsResp; -//end modified by zhangkaibo add create profile qmi. mantis 0049137,0048741 20200610 - QMIWDS_MODIFY_PROFILE_SETTINGS_REQ_MSG ModifyProfileSettingsReq; - QMIWDS_MODIFY_PROFILE_SETTINGS_RESP_MSG ModifyProfileSettingsResp; - QMIWDS_GET_PROFILE_SETTINGS_REQ_MSG GetProfileSettingsReq; -#if 0 - QMIWDS_GET_DATA_BEARER_REQ_MSG GetDataBearerReq; - QMIWDS_GET_DATA_BEARER_RESP_MSG GetDataBearerResp; - QMIWDS_DUN_CALL_INFO_REQ_MSG DunCallInfoReq; - QMIWDS_DUN_CALL_INFO_RESP_MSG DunCallInfoResp; -#endif - QMIWDS_BIND_MUX_DATA_PORT_REQ_MSG BindMuxDataPortReq; - - // QMIDMS Messages -#if 0 - QMIDMS_GET_DEVICE_MFR_REQ_MSG GetDeviceMfrReq; - QMIDMS_GET_DEVICE_MFR_RESP_MSG GetDeviceMfrRsp; - QMIDMS_GET_DEVICE_MODEL_ID_REQ_MSG GetDeviceModeIdReq; - QMIDMS_GET_DEVICE_MODEL_ID_RESP_MSG GetDeviceModeIdRsp; - QMIDMS_GET_DEVICE_REV_ID_REQ_MSG GetDeviceRevIdReq; - QMIDMS_GET_DEVICE_REV_ID_RESP_MSG GetDeviceRevIdRsp; - QMIDMS_GET_MSISDN_REQ_MSG GetMsisdnReq; - QMIDMS_GET_MSISDN_RESP_MSG GetMsisdnRsp; - QMIDMS_GET_DEVICE_SERIAL_NUMBERS_REQ_MSG GetDeviceSerialNumReq; - QMIDMS_GET_DEVICE_SERIAL_NUMBERS_RESP_MSG GetDeviceSerialNumRsp; - QMIDMS_GET_DEVICE_CAP_REQ_MSG GetDeviceCapReq; - QMIDMS_GET_DEVICE_CAP_RESP_MSG GetDeviceCapResp; - QMIDMS_GET_BAND_CAP_REQ_MSG GetBandCapReq; - QMIDMS_GET_BAND_CAP_RESP_MSG GetBandCapRsp; - QMIDMS_GET_ACTIVATED_STATUS_REQ_MSG GetActivatedStatusReq; - QMIDMS_GET_ACTIVATED_STATUS_RESP_MSG GetActivatedStatusResp; - QMIDMS_GET_OPERATING_MODE_REQ_MSG GetOperatingModeReq; - QMIDMS_GET_OPERATING_MODE_RESP_MSG GetOperatingModeResp; -#endif - QMIDMS_SET_OPERATING_MODE_REQ_MSG SetOperatingModeReq; - QMIDMS_SET_OPERATING_MODE_RESP_MSG SetOperatingModeResp; -#if 0 - QMIDMS_UIM_GET_ICCID_REQ_MSG GetICCIDReq; - QMIDMS_UIM_GET_ICCID_RESP_MSG GetICCIDResp; - QMIDMS_ACTIVATE_AUTOMATIC_REQ_MSG ActivateAutomaticReq; - QMIDMS_ACTIVATE_AUTOMATIC_RESP_MSG ActivateAutomaticResp; - QMIDMS_ACTIVATE_MANUAL_REQ_MSG ActivateManualReq; - QMIDMS_ACTIVATE_MANUAL_RESP_MSG ActivateManualResp; -#endif - QMIDMS_UIM_GET_PIN_STATUS_REQ_MSG UIMGetPinStatusReq; - QMIDMS_UIM_GET_PIN_STATUS_RESP_MSG UIMGetPinStatusResp; - QMIDMS_UIM_VERIFY_PIN_REQ_MSG UIMVerifyPinReq; - QMIDMS_UIM_VERIFY_PIN_RESP_MSG UIMVerifyPinResp; -#if 0 - QMIDMS_UIM_SET_PIN_PROTECTION_REQ_MSG UIMSetPinProtectionReq; - QMIDMS_UIM_SET_PIN_PROTECTION_RESP_MSG UIMSetPinProtectionResp; - QMIDMS_UIM_CHANGE_PIN_REQ_MSG UIMChangePinReq; - QMIDMS_UIM_CHANGE_PIN_RESP_MSG UIMChangePinResp; - QMIDMS_UIM_UNBLOCK_PIN_REQ_MSG UIMUnblockPinReq; - QMIDMS_UIM_UNBLOCK_PIN_RESP_MSG UIMUnblockPinResp; - QMIDMS_SET_EVENT_REPORT_REQ_MSG DmsSetEventReportReq; - QMIDMS_SET_EVENT_REPORT_RESP_MSG DmsSetEventReportResp; - QMIDMS_EVENT_REPORT_IND_MSG DmsEventReportInd; -#endif - QMIDMS_UIM_GET_STATE_REQ_MSG UIMGetStateReq; - QMIDMS_UIM_GET_STATE_RESP_MSG UIMGetStateResp; - QMIDMS_UIM_GET_IMSI_REQ_MSG UIMGetIMSIReq; - QMIDMS_UIM_GET_IMSI_RESP_MSG UIMGetIMSIResp; -#if 0 - QMIDMS_UIM_GET_CK_STATUS_REQ_MSG UIMGetCkStatusReq; - QMIDMS_UIM_GET_CK_STATUS_RESP_MSG UIMGetCkStatusResp; - QMIDMS_UIM_SET_CK_PROTECTION_REQ_MSG UIMSetCkProtectionReq; - QMIDMS_UIM_SET_CK_PROTECTION_RESP_MSG UIMSetCkProtectionResp; - QMIDMS_UIM_UNBLOCK_CK_REQ_MSG UIMUnblockCkReq; - QMIDMS_UIM_UNBLOCK_CK_RESP_MSG UIMUnblockCkResp; -#endif - - // QMIQOS Messages -#if 0 - QMI_QOS_SET_EVENT_REPORT_REQ_MSG QosSetEventReportReq; - QMI_QOS_SET_EVENT_REPORT_RESP_MSG QosSetEventReportRsp; - QMI_QOS_EVENT_REPORT_IND_MSG QosEventReportInd; -#endif - - // QMIWMS Messages -#if 0 - QMIWMS_GET_MESSAGE_PROTOCOL_REQ_MSG GetMessageProtocolReq; - QMIWMS_GET_MESSAGE_PROTOCOL_RESP_MSG GetMessageProtocolResp; - QMIWMS_GET_SMSC_ADDRESS_REQ_MSG GetSMSCAddressReq; - QMIWMS_GET_SMSC_ADDRESS_RESP_MSG GetSMSCAddressResp; - QMIWMS_SET_SMSC_ADDRESS_REQ_MSG SetSMSCAddressReq; - QMIWMS_SET_SMSC_ADDRESS_RESP_MSG SetSMSCAddressResp; - QMIWMS_GET_STORE_MAX_SIZE_REQ_MSG GetStoreMaxSizeReq; - QMIWMS_GET_STORE_MAX_SIZE_RESP_MSG GetStoreMaxSizeResp; - QMIWMS_LIST_MESSAGES_REQ_MSG ListMessagesReq; - QMIWMS_LIST_MESSAGES_RESP_MSG ListMessagesResp; - QMIWMS_RAW_READ_REQ_MSG RawReadMessagesReq; - QMIWMS_RAW_READ_RESP_MSG RawReadMessagesResp; - QMIWMS_SET_EVENT_REPORT_REQ_MSG WmsSetEventReportReq; - QMIWMS_SET_EVENT_REPORT_RESP_MSG WmsSetEventReportResp; - QMIWMS_EVENT_REPORT_IND_MSG WmsEventReportInd; - QMIWMS_DELETE_REQ_MSG WmsDeleteReq; - QMIWMS_DELETE_RESP_MSG WmsDeleteResp; - QMIWMS_RAW_SEND_REQ_MSG RawSendMessagesReq; - QMIWMS_RAW_SEND_RESP_MSG RawSendMessagesResp; - QMIWMS_MODIFY_TAG_REQ_MSG WmsModifyTagReq; - QMIWMS_MODIFY_TAG_RESP_MSG WmsModifyTagResp; -#endif - - // QMINAS Messages -#if 0 - QMINAS_GET_HOME_NETWORK_REQ_MSG GetHomeNetworkReq; - QMINAS_GET_HOME_NETWORK_RESP_MSG GetHomeNetworkResp; - QMINAS_GET_PREFERRED_NETWORK_REQ_MSG GetPreferredNetworkReq; - QMINAS_GET_PREFERRED_NETWORK_RESP_MSG GetPreferredNetworkResp; - QMINAS_GET_FORBIDDEN_NETWORK_REQ_MSG GetForbiddenNetworkReq; - QMINAS_GET_FORBIDDEN_NETWORK_RESP_MSG GetForbiddenNetworkResp; - QMINAS_GET_SERVING_SYSTEM_REQ_MSG GetServingSystemReq; -#endif - QMINAS_GET_SERVING_SYSTEM_RESP_MSG GetServingSystemResp; - QMINAS_GET_SYS_INFO_RESP_MSG GetSysInfoResp; - QMINAS_SYS_INFO_IND_MSG NasSysInfoInd; -#if 0 - QMINAS_SERVING_SYSTEM_IND_MSG NasServingSystemInd; - QMINAS_SET_PREFERRED_NETWORK_REQ_MSG SetPreferredNetworkReq; - QMINAS_SET_PREFERRED_NETWORK_RESP_MSG SetPreferredNetworkResp; - QMINAS_SET_FORBIDDEN_NETWORK_REQ_MSG SetForbiddenNetworkReq; - QMINAS_SET_FORBIDDEN_NETWORK_RESP_MSG SetForbiddenNetworkResp; - QMINAS_PERFORM_NETWORK_SCAN_REQ_MSG PerformNetworkScanReq; - QMINAS_PERFORM_NETWORK_SCAN_RESP_MSG PerformNetworkScanResp; - QMINAS_INITIATE_NW_REGISTER_REQ_MSG InitiateNwRegisterReq; - QMINAS_INITIATE_NW_REGISTER_RESP_MSG InitiateNwRegisterResp; - QMINAS_SET_TECHNOLOGY_PREF_REQ_MSG SetTechnologyPrefReq; - QMINAS_SET_TECHNOLOGY_PREF_RESP_MSG SetTechnologyPrefResp; - QMINAS_GET_SIGNAL_STRENGTH_REQ_MSG GetSignalStrengthReq; - QMINAS_GET_SIGNAL_STRENGTH_RESP_MSG GetSignalStrengthResp; - QMINAS_SET_EVENT_REPORT_REQ_MSG SetEventReportReq; - QMINAS_SET_EVENT_REPORT_RESP_MSG SetEventReportResp; - QMINAS_EVENT_REPORT_IND_MSG NasEventReportInd; - QMINAS_GET_RF_BAND_INFO_REQ_MSG GetRFBandInfoReq; - QMINAS_GET_RF_BAND_INFO_RESP_MSG GetRFBandInfoResp; - QMINAS_INITIATE_ATTACH_REQ_MSG InitiateAttachReq; - QMINAS_INITIATE_ATTACH_RESP_MSG InitiateAttachResp; - QMINAS_GET_PLMN_NAME_REQ_MSG GetPLMNNameReq; - QMINAS_GET_PLMN_NAME_RESP_MSG GetPLMNNameResp; -#endif - - // QMIUIM Messages - QMIUIM_GET_CARD_STATUS_RESP_MSG UIMGetCardStatus; - QMIUIM_VERIFY_PIN_REQ_MSG UIMUIMVerifyPinReq; - QMIUIM_VERIFY_PIN_RESP_MSG UIMUIMVerifyPinResp; -//2021-03-24 willa.liu@fibocom.com changed begin for support mantis 0071817 - QMIUIM_BIND_PIN_REQ_MSG UIMUIMBindPinReq; - QMIUIM_BIND_PIN_REQ_MSG_4 UIMUIMBindPinReq_4; -//2021-03-24 willa.liu@fibocom.com changed end for support mantis 0071817 -#if 0 - QMIUIM_SET_PIN_PROTECTION_REQ_MSG UIMUIMSetPinProtectionReq; - QMIUIM_SET_PIN_PROTECTION_RESP_MSG UIMUIMSetPinProtectionResp; - QMIUIM_CHANGE_PIN_REQ_MSG UIMUIMChangePinReq; - QMIUIM_CHANGE_PIN_RESP_MSG UIMUIMChangePinResp; - QMIUIM_UNBLOCK_PIN_REQ_MSG UIMUIMUnblockPinReq; - QMIUIM_UNBLOCK_PIN_RESP_MSG UIMUIMUnblockPinResp; -#endif - QMIUIM_READ_TRANSPARENT_REQ_MSG UIMUIMReadTransparentReq; - QMIUIM_READ_TRANSPARENT_RESP_MSG UIMUIMReadTransparentResp; - - QMIWDS_ADMIN_SET_DATA_FORMAT_REQ_MSG SetDataFormatReq; - }; -} __attribute__((packed)) QMUX_MSG, *PQMUX_MSG; - -//2021-03-24 willa.liu@fibocom.com changed begin for support mantis 0071817 -#define QMI_WDS_BIND_SUBSCRIPTION_REQ_V01 0x00AF -#define QMI_WDS_BIND_SUBSCRIPTION_RESP_V01 0x00AF -#define QMI_DMS_BIND_SUBSCRIPTION_REQ_V01 0x0054 -#define QMI_DMS_BIND_SUBSCRIPTION_RESP_V01 0x0054 -#define QMI_NAS_BIND_SUBSCRIPTION_REQ_V01 0x0045 -#define QMI_NAS_BIND_SUBSCRIPTION_RESP_V01 0x0045 -#define QMI_QOS_BIND_SUBSCRIPTION_REQ_V01 0x002D -#define QMI_QOS_BIND_SUBSCRIPTION_RESP_V01 0x002D -#define QMI_WMS_BIND_SUBSCRIPTION_REQ_V01 0x004C -#define QMI_WMS_BIND_SUBSCRIPTION_RESP_V01 0x004C - -typedef enum { - QMI_RESULT_TYPE_MIN_ENUM_VAL_V01 = -2147483647, /**< To force a 32 bit signed enum. Do not change or use*/ - QMI_RESULT_SUCCESS_V01 = 0, - QMI_RESULT_FAILURE_V01 = 1, - QMI_RESULT_TYPE_MAX_ENUM_VAL_V01 = 2147483647 /**< To force a 32 bit signed enum. Do not change or use*/ -}qmi_result_type_v01; - -typedef enum { - QMI_ERROR_TYPE_MIN_ENUM_VAL_V01 = -2147483647, /**< To force a 32 bit signed enum. Do not change or use*/ - QMI_ERR_NONE_V01 = 0x0000, - QMI_ERR_MALFORMED_MSG_V01 = 0x0001, - QMI_ERR_NO_MEMORY_V01 = 0x0002, - QMI_ERR_INTERNAL_V01 = 0x0003, - QMI_ERR_ABORTED_V01 = 0x0004, - QMI_ERR_CLIENT_IDS_EXHAUSTED_V01 = 0x0005, - QMI_ERR_UNABORTABLE_TRANSACTION_V01 = 0x0006, - QMI_ERR_INVALID_CLIENT_ID_V01 = 0x0007, - QMI_ERR_NO_THRESHOLDS_V01 = 0x0008, - QMI_ERR_INVALID_HANDLE_V01 = 0x0009, - QMI_ERR_INVALID_PROFILE_V01 = 0x000A, - QMI_ERR_INVALID_PINID_V01 = 0x000B, - QMI_ERR_INCORRECT_PIN_V01 = 0x000C, - QMI_ERR_NO_NETWORK_FOUND_V01 = 0x000D, - QMI_ERR_CALL_FAILED_V01 = 0x000E, - QMI_ERR_OUT_OF_CALL_V01 = 0x000F, - QMI_ERR_NOT_PROVISIONED_V01 = 0x0010, - QMI_ERR_MISSING_ARG_V01 = 0x0011, - QMI_ERR_ARG_TOO_LONG_V01 = 0x0013, - QMI_ERR_INVALID_TX_ID_V01 = 0x0016, - QMI_ERR_DEVICE_IN_USE_V01 = 0x0017, - QMI_ERR_OP_NETWORK_UNSUPPORTED_V01 = 0x0018, - QMI_ERR_OP_DEVICE_UNSUPPORTED_V01 = 0x0019, - QMI_ERR_NO_EFFECT_V01 = 0x001A, - QMI_ERR_NO_FREE_PROFILE_V01 = 0x001B, - QMI_ERR_INVALID_PDP_TYPE_V01 = 0x001C, - QMI_ERR_INVALID_TECH_PREF_V01 = 0x001D, - QMI_ERR_INVALID_PROFILE_TYPE_V01 = 0x001E, - QMI_ERR_INVALID_SERVICE_TYPE_V01 = 0x001F, - QMI_ERR_INVALID_REGISTER_ACTION_V01 = 0x0020, - QMI_ERR_INVALID_PS_ATTACH_ACTION_V01 = 0x0021, - QMI_ERR_AUTHENTICATION_FAILED_V01 = 0x0022, - QMI_ERR_PIN_BLOCKED_V01 = 0x0023, - QMI_ERR_PIN_PERM_BLOCKED_V01 = 0x0024, - QMI_ERR_SIM_NOT_INITIALIZED_V01 = 0x0025, - QMI_ERR_MAX_QOS_REQUESTS_IN_USE_V01 = 0x0026, - QMI_ERR_INCORRECT_FLOW_FILTER_V01 = 0x0027, - QMI_ERR_NETWORK_QOS_UNAWARE_V01 = 0x0028, - QMI_ERR_INVALID_ID_V01 = 0x0029, - QMI_ERR_INVALID_QOS_ID_V01 = 0x0029, - QMI_ERR_REQUESTED_NUM_UNSUPPORTED_V01 = 0x002A, - QMI_ERR_INTERFACE_NOT_FOUND_V01 = 0x002B, - QMI_ERR_FLOW_SUSPENDED_V01 = 0x002C, - QMI_ERR_INVALID_DATA_FORMAT_V01 = 0x002D, - QMI_ERR_GENERAL_V01 = 0x002E, - QMI_ERR_UNKNOWN_V01 = 0x002F, - QMI_ERR_INVALID_ARG_V01 = 0x0030, - QMI_ERR_INVALID_INDEX_V01 = 0x0031, - QMI_ERR_NO_ENTRY_V01 = 0x0032, - QMI_ERR_DEVICE_STORAGE_FULL_V01 = 0x0033, - QMI_ERR_DEVICE_NOT_READY_V01 = 0x0034, - QMI_ERR_NETWORK_NOT_READY_V01 = 0x0035, - QMI_ERR_CAUSE_CODE_V01 = 0x0036, - QMI_ERR_MESSAGE_NOT_SENT_V01 = 0x0037, - QMI_ERR_MESSAGE_DELIVERY_FAILURE_V01 = 0x0038, - QMI_ERR_INVALID_MESSAGE_ID_V01 = 0x0039, - QMI_ERR_ENCODING_V01 = 0x003A, - QMI_ERR_AUTHENTICATION_LOCK_V01 = 0x003B, - QMI_ERR_INVALID_TRANSITION_V01 = 0x003C, - QMI_ERR_NOT_A_MCAST_IFACE_V01 = 0x003D, - QMI_ERR_MAX_MCAST_REQUESTS_IN_USE_V01 = 0x003E, - QMI_ERR_INVALID_MCAST_HANDLE_V01 = 0x003F, - QMI_ERR_INVALID_IP_FAMILY_PREF_V01 = 0x0040, - QMI_ERR_SESSION_INACTIVE_V01 = 0x0041, - QMI_ERR_SESSION_INVALID_V01 = 0x0042, - QMI_ERR_SESSION_OWNERSHIP_V01 = 0x0043, - QMI_ERR_INSUFFICIENT_RESOURCES_V01 = 0x0044, - QMI_ERR_DISABLED_V01 = 0x0045, - QMI_ERR_INVALID_OPERATION_V01 = 0x0046, - QMI_ERR_INVALID_QMI_CMD_V01 = 0x0047, - QMI_ERR_TPDU_TYPE_V01 = 0x0048, - QMI_ERR_SMSC_ADDR_V01 = 0x0049, - QMI_ERR_INFO_UNAVAILABLE_V01 = 0x004A, - QMI_ERR_SEGMENT_TOO_LONG_V01 = 0x004B, - QMI_ERR_SEGMENT_ORDER_V01 = 0x004C, - QMI_ERR_BUNDLING_NOT_SUPPORTED_V01 = 0x004D, - QMI_ERR_OP_PARTIAL_FAILURE_V01 = 0x004E, - QMI_ERR_POLICY_MISMATCH_V01 = 0x004F, - QMI_ERR_SIM_FILE_NOT_FOUND_V01 = 0x0050, - QMI_ERR_EXTENDED_INTERNAL_V01 = 0x0051, - QMI_ERR_ACCESS_DENIED_V01 = 0x0052, - QMI_ERR_HARDWARE_RESTRICTED_V01 = 0x0053, - QMI_ERR_ACK_NOT_SENT_V01 = 0x0054, - QMI_ERR_INJECT_TIMEOUT_V01 = 0x0055, - QMI_ERR_INCOMPATIBLE_STATE_V01 = 0x005A, - QMI_ERR_FDN_RESTRICT_V01 = 0x005B, - QMI_ERR_SUPS_FAILURE_CAUSE_V01 = 0x005C, - QMI_ERR_NO_RADIO_V01 = 0x005D, - QMI_ERR_NOT_SUPPORTED_V01 = 0x005E, - QMI_ERR_NO_SUBSCRIPTION_V01 = 0x005F, - QMI_ERR_CARD_CALL_CONTROL_FAILED_V01 = 0x0060, - QMI_ERR_NETWORK_ABORTED_V01 = 0x0061, - QMI_ERR_MSG_BLOCKED_V01 = 0x0062, - QMI_ERR_INVALID_SESSION_TYPE_V01 = 0x0064, - QMI_ERR_INVALID_PB_TYPE_V01 = 0x0065, - QMI_ERR_NO_SIM_V01 = 0x0066, - QMI_ERR_PB_NOT_READY_V01 = 0x0067, - QMI_ERR_PIN_RESTRICTION_V01 = 0x0068, - QMI_ERR_PIN2_RESTRICTION_V01 = 0x0069, - QMI_ERR_PUK_RESTRICTION_V01 = 0x006A, - QMI_ERR_PUK2_RESTRICTION_V01 = 0x006B, - QMI_ERR_PB_ACCESS_RESTRICTED_V01 = 0x006C, - QMI_ERR_PB_DELETE_IN_PROG_V01 = 0x006D, - QMI_ERR_PB_TEXT_TOO_LONG_V01 = 0x006E, - QMI_ERR_PB_NUMBER_TOO_LONG_V01 = 0x006F, - QMI_ERR_PB_HIDDEN_KEY_RESTRICTION_V01 = 0x0070, - QMI_ERR_PB_NOT_AVAILABLE_V01 = 0x0071, - QMI_ERR_DEVICE_MEMORY_ERROR_V01 = 0x0072, - QMI_ERR_NO_PERMISSION_V01 = 0x0073, - QMI_ERR_TOO_SOON_V01 = 0x0074, - QMI_ERR_TIME_NOT_ACQUIRED_V01 = 0x0075, - QMI_ERR_OP_IN_PROGRESS_V01 = 0x0076, - QMI_ERR_EPERM_V01 = 0x101, /**< Operation not permitted */ - QMI_ERR_ENOENT_V01 = 0x102, /**< No such file or directory */ - QMI_ERR_ESRCH_V01 = 0x103, /**< No such process */ - QMI_ERR_EINTR_V01 = 0x104, /**< Interrupted system call */ - QMI_ERR_EIO_V01 = 0x105, /**< I/O error */ - QMI_ERR_ENXIO_V01 = 0x106, /**< No such device or address */ - QMI_ERR_E2BIG_V01 = 0x107, /**< Argument list too long */ - QMI_ERR_ENOEXEC_V01 = 0x108, /**< Exec format error */ - QMI_ERR_EBADF_V01 = 0x109, /**< Bad file number */ - QMI_ERR_ECHILD_V01 = 0x10A, /**< No child processes */ - QMI_ERR_EAGAIN_V01 = 0x10B, /**< Try again */ - QMI_ERR_ENOMEM_V01 = 0x10C, /**< Out of memory */ - QMI_ERR_EACCES_V01 = 0x10D, /**< Permission denied */ - QMI_ERR_EFAULT_V01 = 0x10E, /**< Bad address */ - QMI_ERR_ENOTBLK_V01 = 0x10F, /**< Block device required */ - QMI_ERR_EBUSY_V01 = 0x110, /**< Device or resource busy */ - QMI_ERR_EEXIST_V01 = 0x111, /**< File exists */ - QMI_ERR_EXDEV_V01 = 0x112, /**< Cross-device link */ - QMI_ERR_ENODEV_V01 = 0x113, /**< No such device */ - QMI_ERR_ENOTDIR_V01 = 0x114, /**< Not a directory */ - QMI_ERR_EISDIR_V01 = 0x115, /**< Is a directory */ - QMI_ERR_EINVAL_V01 = 0x116, /**< Invalid argument */ - QMI_ERR_ENFILE_V01 = 0x117, /**< File table overflow */ - QMI_ERR_EMFILE_V01 = 0x118, /**< Too many open files */ - QMI_ERR_ENOTTY_V01 = 0x119, /**< Not a typewriter */ - QMI_ERR_ETXTBSY_V01 = 0x11A, /**< Text file busy */ - QMI_ERR_EFBIG_V01 = 0x11B, /**< File too large */ - QMI_ERR_ENOSPC_V01 = 0x11C, /**< No space left on device */ - QMI_ERR_ESPIPE_V01 = 0x11D, /**< Illegal seek */ - QMI_ERR_EROFS_V01 = 0x11E, /**< Read-only file system */ - QMI_ERR_EMLINK_V01 = 0x11F, /**< Too many links */ - QMI_ERR_EPIPE_V01 = 0x120, /**< Broken pipe */ - QMI_ERR_EDOM_V01 = 0x121, /**< Math argument out of domain of func */ - QMI_ERR_ERANGE_V01 = 0x122, /**< Math result not representable */ - QMI_ERR_EDEADLK_V01 = 0x123, /**< Resource deadlock would occur */ - QMI_ERR_ENAMETOOLONG_V01 = 0x124, /**< File name too long */ - QMI_ERR_ENOLCK_V01 = 0x125, /**< No record locks available */ - QMI_ERR_ENOSYS_V01 = 0x126, /**< Function not implemented */ - QMI_ERR_ENOTEMPTY_V01 = 0x127, /**< Directory not empty */ - QMI_ERR_ELOOP_V01 = 0x128, /**< Too many symbolic links encountered */ - QMI_ERR_EWOULDBLOCK_V01 = 0x10B, /**< Operation would block */ - QMI_ERR_ENOMSG_V01 = 0x12A, /**< No message of desired type */ - QMI_ERR_EIDRM_V01 = 0x12B, /**< Identifier removed */ - QMI_ERR_ECHRNG_V01 = 0x12C, /**< Channel number out of range */ - QMI_ERR_EL2NSYNC_V01 = 0x12D, /**< Level 2 not synchronized */ - QMI_ERR_EL3HLT_V01 = 0x12E, /**< Level 3 halted */ - QMI_ERR_EL3RST_V01 = 0x12F, /**< Level 3 reset */ - QMI_ERR_ELNRNG_V01 = 0x130, /**< Link number out of range */ - QMI_ERR_EUNATCH_V01 = 0x131, /**< Protocol driver not attached */ - QMI_ERR_ENOCSI_V01 = 0x132, /**< No CSI structure available */ - QMI_ERR_EL2HLT_V01 = 0x133, /**< Level 2 halted */ - QMI_ERR_EBADE_V01 = 0x134, /**< Invalid exchange */ - QMI_ERR_EBADR_V01 = 0x135, /**< Invalid request descriptor */ - QMI_ERR_EXFULL_V01 = 0x136, /**< Exchange full */ - QMI_ERR_ENOANO_V01 = 0x137, /**< No anode */ - QMI_ERR_EBADRQC_V01 = 0x138, /**< Invalid request code */ - QMI_ERR_EBADSLT_V01 = 0x139, /**< Invalid slot */ - QMI_ERR_EDEADLOCK_V01 = 0x123, /**< Resource deadlock would occur */ - QMI_ERR_EBFONT_V01 = 0x13B, /**< Bad font file format */ - QMI_ERR_ENOSTR_V01 = 0x13C, /**< Device not a stream */ - QMI_ERR_ENODATA_V01 = 0x13D, /**< No data available */ - QMI_ERR_ETIME_V01 = 0x13E, /**< Timer expired */ - QMI_ERR_ENOSR_V01 = 0x13F, /**< Out of streams resources */ - QMI_ERR_ENONET_V01 = 0x140, /**< Machine is not on the network */ - QMI_ERR_ENOPKG_V01 = 0x141, /**< Package not installed */ - QMI_ERR_EREMOTE_V01 = 0x142, /**< Object is remote */ - QMI_ERR_ENOLINK_V01 = 0x143, /**< Link has been severed */ - QMI_ERR_EADV_V01 = 0x144, /**< Advertise error */ - QMI_ERR_ESRMNT_V01 = 0x145, /**< Srmount error */ - QMI_ERR_ECOMM_V01 = 0x146, /**< Communication error on send */ - QMI_ERR_EPROTO_V01 = 0x147, /**< Protocol error */ - QMI_ERR_EMULTIHOP_V01 = 0x148, /**< Multihop attempted */ - QMI_ERR_EDOTDOT_V01 = 0x149, /**< RFS specific error */ - QMI_ERR_EBADMSG_V01 = 0x14A, /**< Not a data message */ - QMI_ERR_EOVERFLOW_V01 = 0x14B, /**< Value too large for defined data type */ - QMI_ERR_ENOTUNIQ_V01 = 0x14C, /**< Name not unique on network */ - QMI_ERR_EBADFD_V01 = 0x14D, /**< File descriptor in bad state */ - QMI_ERR_EREMCHG_V01 = 0x14E, /**< Remote address changed */ - QMI_ERR_ELIBACC_V01 = 0x14F, /**< Can not access a needed shared library */ - QMI_ERR_ELIBBAD_V01 = 0x150, /**< Accessing a corrupted shared library */ - QMI_ERR_ELIBSCN_V01 = 0x151, /**< .lib section in a.out corrupted */ - QMI_ERR_ELIBMAX_V01 = 0x152, /**< Attempting to link in too many shared libraries */ - QMI_ERR_ELIBEXEC_V01 = 0x153, /**< Cannot exec a shared library directly */ - QMI_ERR_EILSEQ_V01 = 0x154, /**< Illegal byte sequence */ - QMI_ERR_ERESTART_V01 = 0x155, /**< Interrupted system call should be restarted */ - QMI_ERR_ESTRPIPE_V01 = 0x156, /**< Streams pipe error */ - QMI_ERR_EUSERS_V01 = 0x157, /**< Too many users */ - QMI_ERR_ENOTSOCK_V01 = 0x158, /**< Socket operation on non-socket */ - QMI_ERR_EDESTADDRREQ_V01 = 0x159, /**< Destination address required */ - QMI_ERR_EMSGSIZE_V01 = 0x15A, /**< Message too long */ - QMI_ERR_EPROTOTYPE_V01 = 0x15B, /**< Protocol wrong type for socket */ - QMI_ERR_ENOPROTOOPT_V01 = 0x15C, /**< Protocol not available */ - QMI_ERR_EPROTONOSUPPORT_V01 = 0x15D, /**< Protocol not supported */ - QMI_ERR_ESOCKTNOSUPPORT_V01 = 0x15E, /**< Socket type not supported */ - QMI_ERR_EOPNOTSUPP_V01 = 0x15F, /**< Operation not supported on transport endpoint */ - QMI_ERR_EPFNOSUPPORT_V01 = 0x160, /**< Protocol family not supported */ - QMI_ERR_EAFNOSUPPORT_V01 = 0x161, /**< Address family not supported by protocol */ - QMI_ERR_EADDRINUSE_V01 = 0x162, /**< Address already in use */ - QMI_ERR_EADDRNOTAVAIL_V01 = 0x163, /**< Cannot assign requested address */ - QMI_ERR_ENETDOWN_V01 = 0x164, /**< Network is down */ - QMI_ERR_ENETUNREACH_V01 = 0x165, /**< Network is unreachable */ - QMI_ERR_ENETRESET_V01 = 0x166, /**< Network dropped connection because of reset */ - QMI_ERR_ECONNABORTED_V01 = 0x167, /**< Software caused connection abort */ - QMI_ERR_ECONNRESET_V01 = 0x168, /**< Connection reset by peer */ - QMI_ERR_ENOBUFS_V01 = 0x169, /**< No buffer space available */ - QMI_ERR_EISCONN_V01 = 0x16A, /**< Transport endpoint is already connected */ - QMI_ERR_ENOTCONN_V01 = 0x16B, /**< Transport endpoint is not connected */ - QMI_ERR_ESHUTDOWN_V01 = 0x16C, /**< Cannot send after transport endpoint shutdown */ - QMI_ERR_ETOOMANYREFS_V01 = 0x16D, /**< Too many references: cannot splice */ - QMI_ERR_ETIMEDOUT_V01 = 0x16E, /**< Connection timed out */ - QMI_ERR_ECONNREFUSED_V01 = 0x16F, /**< Connection refused */ - QMI_ERR_EHOSTDOWN_V01 = 0x170, /**< Host is down */ - QMI_ERR_EHOSTUNREACH_V01 = 0x171, /**< No route to host */ - QMI_ERR_EALREADY_V01 = 0x172, /**< Operation already in progress */ - QMI_ERR_EINPROGRESS_V01 = 0x173, /**< Operation now in progress */ - QMI_ERR_ESTALE_V01 = 0x174, /**< Stale NFS file handle */ - QMI_ERR_EUCLEAN_V01 = 0x175, /**< Structure needs cleaning */ - QMI_ERR_ENOTNAM_V01 = 0x176, /**< Not a XENIX named type file */ - QMI_ERR_ENAVAIL_V01 = 0x177, /**< No XENIX semaphores available */ - QMI_ERR_EISNAM_V01 = 0x178, /**< Is a named type file */ - QMI_ERR_EREMOTEIO_V01 = 0x179, /**< Remote I/O error */ - QMI_ERR_EDQUOT_V01 = 0x17A, /**< Quota exceeded */ - QMI_ERR_ENOMEDIUM_V01 = 0x17B, /**< No medium found */ - QMI_ERR_EMEDIUMTYPE_V01 = 0x17C, /**< Wrong medium type */ - QMI_ERR_ECANCELED_V01 = 0x17D, /**< Operation Canceled */ - QMI_ERR_ENOKEY_V01 = 0x17E, /**< Required key not available */ - QMI_ERR_EKEYEXPIRED_V01 = 0x17F, /**< Key has expired */ - QMI_ERR_EKEYREVOKED_V01 = 0x180, /**< Key has been revoked */ - QMI_ERR_EKEYREJECTED_V01 = 0x181, /**< Key was rejected by service */ - QMI_ERR_EOWNERDEAD_V01 = 0x182, /**< Owner died */ - QMI_ERR_ENOTRECOVERABLE_V01 = 0x183, /**< State not recoverable */ - QMI_ERROR_TYPE_MAX_ENUM_VAL_V01 = 2147483647 /**< To force a 32 bit signed enum. Do not change or use*/ -}qmi_error_type_v01; - -typedef struct { - qmi_result_type_v01 result; - qmi_error_type_v01 error; -}qmi_response_type_v01; /* Type */ - -typedef enum { - NAS_SUBS_TYPE_ENUM_MIN_ENUM_VAL_V01 = -2147483647, /**< To force a 32 bit signed enum. Do not change or use*/ - NAS_PRIMARY_SUBSCRIPTION_V01 = 0x00, /**< Primary subscription \n */ - NAS_SECONDARY_SUBSCRIPTION_V01 = 0x01, /**< Secondary subscription \n */ - NAS_TERTIARY_SUBSCRIPTION_V01 = 0x02, /**< Tertiary subscription */ - NAS_SUBS_TYPE_ENUM_MAX_ENUM_VAL_V01 = 2147483647 /**< To force a 32 bit signed enum. Do not change or use*/ -}nas_subs_type_enum_v01; - -typedef struct { - nas_subs_type_enum_v01 subs_type; -}nas_bind_subscription_req_msg_v01; /* Message */ -//2021-03-24 willa.liu@fibocom.com changed end for support mantis 0071817 -#pragma pack(pop) - -#endif// MPQMUX_H diff --git a/fibocom-dial/src/Makefile b/fibocom-dial/src/Makefile deleted file mode 100644 index 992b951..0000000 --- a/fibocom-dial/src/Makefile +++ /dev/null @@ -1,42 +0,0 @@ -ifneq ($(CROSS_COMPILE),) -CROSS-COMPILE:=$(CROSS_COMPILE) -endif - -CFLAGS += -DGHT_FEATURE_PCIE_AUTO - -ifeq ($(CC),cc) -CC:=$(CROSS-COMPILE)gcc -endif -LD:=$(CROSS-COMPILE)ld - -SRC=QmiWwanCM.c GobiNetCM.c main.c MPQMUX.c QMIThread.c util.c qmap_bridge_mode.c query_pcie_mode.c - -FB_DHCP=udhcpc.c - -FIBO_PROXY_SRC=fibo_qmimsg_server.c - -LIBMNL=libmnl/ifutils.c libmnl/attr.c libmnl/callback.c libmnl/nlmsg.c libmnl/socket.c -FB_NDHCP=udhcpc_netlink.c -FB_NDHCP+=${LIBMNL} - -release: clean - $(CC) $(CFLAGS) -Wall -s ${SRC} ${FB_NDHCP} -o fibocom-dial -lpthread -ldl - $(CC) -Wall -s multi-pdn-manager.c query_pcie_mode.c util.c -o multi-pdn-manager -lpthread -ldl - $(CC) -Wall -s ${FIBO_PROXY_SRC} -o fibo_qmimsg_server -lpthread -ldl - -dhcp: clean - $(CC) $(CFLAGS) -Wall -s ${SRC} ${FB_DHCP} -o fibocom-dial -lpthread -ldl - $(CC) -Wall -s multi-pdn-manager.c query_pcie_mode.c util.c -o multi-pdn-manager -lpthread -ldl - $(CC) -Wall -s ${FIBO_PROXY_SRC} -o fibo_qmimsg_server -lpthread -ldl - -ndhcp: clean - $(CC) $(CFLAGS) -Wall -s ${SRC} ${FB_NDHCP} -o fibocom-dial -lpthread -ldl - $(CC) -Wall -s multi-pdn-manager.c query_pcie_mode.cutil.c -o multi-pdn-manager -lpthread -ldl - $(CC) -Wall -s ${FIBO_PROXY_SRC} -o fibo_qmimsg_server -lpthread -ldl - -qmi-proxy: - $(CC) -Wall -s fibo-qmi-proxy.c -o fibo-qmi-proxy -lpthread -ldl - -clean: - rm -rf fibocom-dial *~ multi-pdn-manager fibo_qmimsg_server - diff --git a/fibocom-dial/src/QMIThread.c b/fibocom-dial/src/QMIThread.c deleted file mode 100644 index ecce6b9..0000000 --- a/fibocom-dial/src/QMIThread.c +++ /dev/null @@ -1,2551 +0,0 @@ -#include "QMIThread.h" -#include "query_pcie_mode.h" -extern char *strndup(const char *__string, size_t __n); - -//2021-03-24 willa.liu@fibocom.com changed begin for support mantis 0071817 -//extern int *speed_arr; -//extern int *name_arr; - -PQCQMIMSG pResponse; -PQMUX_MSG pMUXMsg; -//2021-03-24 willa.liu@fibocom.com changed end for support mantis 0071817 - -#define qmi_rsp_check_and_return()\ - do { \ - if (err < 0 || pResponse == NULL) { \ - dbg_time("%s err = %d", __func__, err); \ - return err; \ - } \ - pMUXMsg = &pResponse->MUXMsg; \ - if (le16_to_cpu(pMUXMsg->QMUXMsgHdrResp.QMUXResult) || \ - le16_to_cpu(pMUXMsg->QMUXMsgHdrResp.QMUXError)) { \ - USHORT QMUXError = le16_to_cpu(pMUXMsg->QMUXMsgHdrResp.QMUXError); \ - dbg_time("%s QMUXResult = 0x%x, QMUXError = 0x%x", __func__, \ - le16_to_cpu(pMUXMsg->QMUXMsgHdrResp.QMUXResult), \ - QMUXError); \ - free(pResponse); \ - return QMUXError; \ - } \ - } while (0) - -#define qmi_rsp_check() \ - do { \ - if (err < 0 || pResponse == NULL) { \ - dbg_time("%s err = %d", __func__, err); \ - return err; \ - } \ - pMUXMsg = &pResponse->MUXMsg; \ - if (le16_to_cpu(pMUXMsg->QMUXMsgHdrResp.QMUXResult) || \ - le16_to_cpu(pMUXMsg->QMUXMsgHdrResp.QMUXError)) { \ - USHORT QMUXError = le16_to_cpu(pMUXMsg->QMUXMsgHdrResp.QMUXError); \ - dbg_time("%s QMUXResult = 0x%x, QMUXError = 0x%x", __func__, \ - le16_to_cpu(pMUXMsg->QMUXMsgHdrResp.QMUXResult), \ - QMUXError); \ - } \ - } while (0) - -int qmiclientId[QMUX_TYPE_WDS_ADMIN + - 1]; // GobiNet use fd to indicate client ID, so type of - // qmiclientId must be int -static uint32_t WdsConnectionIPv4Handle = 0; -static uint32_t WdsConnectionIPv6Handle = 0; -static int s_is_cdma = 0; -static int s_hdr_personality = 0; // 0x01-HRPD, 0x02-eHRPD -static char *qstrcpy(char *to, const char *from) -{ // no __strcpy_chk - char *save = to; - for (; (*to = *from) != '\0'; ++from, ++to) - ; - return (save); -} - - - -typedef USHORT (*CUSTOMQMUX)(PQMUX_MSG pMUXMsg, void *arg); - -// To retrieve the ith (Index) TLV -PQMI_TLV_HDR GetTLV(PQCQMUX_MSG_HDR pQMUXMsgHdr, int TLVType) -{ - int TLVFind = 0; - USHORT Length = le16_to_cpu(pQMUXMsgHdr->Length); - PQMI_TLV_HDR pTLVHdr = (PQMI_TLV_HDR)(pQMUXMsgHdr + 1); - - while (Length >= sizeof(QMI_TLV_HDR)) { - TLVFind++; - if (TLVType > 0x1000) { - if ((TLVFind + 0x1000) == TLVType) - return pTLVHdr; - } else if (pTLVHdr->TLVType == TLVType) { - return pTLVHdr; - } - - Length -= (le16_to_cpu((pTLVHdr->TLVLength)) + sizeof(QMI_TLV_HDR)); - pTLVHdr = (PQMI_TLV_HDR)(((UCHAR *)pTLVHdr) + - le16_to_cpu(pTLVHdr->TLVLength) + - sizeof(QMI_TLV_HDR)); - } - - return NULL; -} - -static USHORT GetQMUXTransactionId(void) -{ - static int TransactionId = 0; - if (++TransactionId > 0xFFFF) - TransactionId = 1; - return TransactionId; -} - -static PQCQMIMSG ComposeQMUXMsg(UCHAR QMIType, USHORT Type, - CUSTOMQMUX customQmuxMsgFunction, void *arg) -{ - UCHAR QMIBuf[WDM_DEFAULT_BUFSIZE]; - PQCQMIMSG pRequest = (PQCQMIMSG)QMIBuf; - int Length; - - memset(QMIBuf, 0x00, sizeof(QMIBuf)); - pRequest->QMIHdr.IFType = USB_CTL_MSG_TYPE_QMI; - pRequest->QMIHdr.CtlFlags = 0x00; - pRequest->QMIHdr.QMIType = QMIType; - pRequest->QMIHdr.ClientId = qmiclientId[QMIType] & 0xFF; - - if (qmiclientId[QMIType] == 0) { - dbg_time("QMIType %d has no clientID", QMIType); - return NULL; - } - - pRequest->MUXMsg.QMUXHdr.CtlFlags = - QMUX_CTL_FLAG_SINGLE_MSG | QMUX_CTL_FLAG_TYPE_CMD; - pRequest->MUXMsg.QMUXHdr.TransactionId = - cpu_to_le16(GetQMUXTransactionId()); - pRequest->MUXMsg.QMUXMsgHdr.Type = cpu_to_le16(Type); - if (customQmuxMsgFunction) - pRequest->MUXMsg.QMUXMsgHdr.Length = - cpu_to_le16(customQmuxMsgFunction(&pRequest->MUXMsg, arg) - - sizeof(QCQMUX_MSG_HDR)); - else - pRequest->MUXMsg.QMUXMsgHdr.Length = cpu_to_le16(0x0000); - - pRequest->QMIHdr.Length = cpu_to_le16( - le16_to_cpu(pRequest->MUXMsg.QMUXMsgHdr.Length) + - sizeof(QCQMUX_MSG_HDR) + sizeof(QCQMUX_HDR) + sizeof(QCQMI_HDR) - 1); - Length = le16_to_cpu(pRequest->QMIHdr.Length) + 1; - - pRequest = (PQCQMIMSG)malloc(Length); - if (pRequest == NULL) { - dbg_time("%s fail to malloc", __func__); - } else { - memcpy(pRequest, QMIBuf, Length); - } - - return pRequest; -} - -static USHORT WdsStartNwInterfaceReq(PQMUX_MSG pMUXMsg, void *arg) -{ - PQMIWDS_TECHNOLOGY_PREFERECE pTechPref; - PQMIWDS_AUTH_PREFERENCE pAuthPref; - PQMIWDS_USERNAME pUserName; - PQMIWDS_PASSWD pPasswd; - PQMIWDS_APNNAME pApnName; - PQMIWDS_IP_FAMILY_TLV pIpFamily; - USHORT TLVLength = 0; - UCHAR *pTLV; - PROFILE_T *profile = (PROFILE_T *)arg; - const char *profile_user = profile->user; - const char *profile_password = profile->password; - int profile_auth = profile->auth; - - if (s_is_cdma && (profile_user == NULL || profile_user[0] == '\0') && - (profile_password == NULL || profile_password[0] == '\0')) { - profile_user = "ctnet@mycdma.cn"; - profile_password = "vnet.mobi"; - profile_auth = 2; // chap - } - - pTLV = (UCHAR *)(&pMUXMsg->StartNwInterfaceReq + 1); - pMUXMsg->StartNwInterfaceReq.Length = 0; - - // Set technology Preferece - pTechPref = (PQMIWDS_TECHNOLOGY_PREFERECE)(pTLV + TLVLength); - pTechPref->TLVType = 0x30; - pTechPref->TLVLength = cpu_to_le16(0x01); - if (s_is_cdma == 0) - pTechPref->TechPreference = 0x01; - else - pTechPref->TechPreference = 0x02; - TLVLength += (le16_to_cpu(pTechPref->TLVLength) + sizeof(QCQMICTL_TLV_HDR)); - - // Set APN Name - if (profile->apn && !s_is_cdma) { // cdma no apn - pApnName = (PQMIWDS_APNNAME)(pTLV + TLVLength); - pApnName->TLVType = 0x14; - pApnName->TLVLength = cpu_to_le16(strlen(profile->apn)); - qstrcpy((char *)&pApnName->ApnName, profile->apn); - TLVLength += - (le16_to_cpu(pApnName->TLVLength) + sizeof(QCQMICTL_TLV_HDR)); - } - - // Set User Name - if (profile_user) { - pUserName = (PQMIWDS_USERNAME)(pTLV + TLVLength); - pUserName->TLVType = 0x17; - pUserName->TLVLength = cpu_to_le16(strlen(profile_user)); - qstrcpy((char *)&pUserName->UserName, profile_user); - TLVLength += - (le16_to_cpu(pUserName->TLVLength) + sizeof(QCQMICTL_TLV_HDR)); - } - - // Set Password - if (profile_password) { - pPasswd = (PQMIWDS_PASSWD)(pTLV + TLVLength); - pPasswd->TLVType = 0x18; - pPasswd->TLVLength = cpu_to_le16(strlen(profile_password)); - qstrcpy((char *)&pPasswd->Passwd, profile_password); - TLVLength += - (le16_to_cpu(pPasswd->TLVLength) + sizeof(QCQMICTL_TLV_HDR)); - } - - // Set Auth Protocol - if (profile_user && profile_password) { - pAuthPref = (PQMIWDS_AUTH_PREFERENCE)(pTLV + TLVLength); - pAuthPref->TLVType = 0x16; - pAuthPref->TLVLength = cpu_to_le16(0x01); - pAuthPref->AuthPreference = - profile_auth; // 0 ~ None, 1 ~ Pap, 2 ~ Chap, 3 ~ MsChapV2 - TLVLength += - (le16_to_cpu(pAuthPref->TLVLength) + sizeof(QCQMICTL_TLV_HDR)); - } - - // Add IP Family Preference - pIpFamily = (PQMIWDS_IP_FAMILY_TLV)(pTLV + TLVLength); - pIpFamily->TLVType = 0x19; - pIpFamily->TLVLength = cpu_to_le16(0x01); - pIpFamily->IpFamily = profile->curIpFamily; - TLVLength += (le16_to_cpu(pIpFamily->TLVLength) + sizeof(QCQMICTL_TLV_HDR)); - - // Set Profile Index - if (profile->pdp && !s_is_cdma) { // cdma only support one pdp, so no need - // to set profile index - PQMIWDS_PROFILE_IDENTIFIER pProfileIndex = - (PQMIWDS_PROFILE_IDENTIFIER)(pTLV + TLVLength); - pProfileIndex->TLVLength = cpu_to_le16(0x01); - pProfileIndex->TLVType = 0x31; - pProfileIndex->ProfileIndex = profile->pdpindex; - if (s_is_cdma && s_hdr_personality == 0x02) { - pProfileIndex->TLVType = 0x32; // profile_index_3gpp2 - pProfileIndex->ProfileIndex = 101; - } - TLVLength += - (le16_to_cpu(pProfileIndex->TLVLength) + sizeof(QCQMICTL_TLV_HDR)); - } - - return sizeof(QMIWDS_START_NETWORK_INTERFACE_REQ_MSG) + TLVLength; -} - -static USHORT WdsStopNwInterfaceReq(PQMUX_MSG pMUXMsg, void *arg) -{ - pMUXMsg->StopNwInterfaceReq.TLVType = 0x01; - pMUXMsg->StopNwInterfaceReq.TLVLength = cpu_to_le16(0x04); - if (*((int *)arg) == IpFamilyV4) - pMUXMsg->StopNwInterfaceReq.Handle = - cpu_to_le32(WdsConnectionIPv4Handle); - else - pMUXMsg->StopNwInterfaceReq.Handle = - cpu_to_le32(WdsConnectionIPv6Handle); - return sizeof(QMIWDS_STOP_NETWORK_INTERFACE_REQ_MSG); -} - -static USHORT WdsSetClientIPFamilyPref(PQMUX_MSG pMUXMsg, void *arg) -{ - pMUXMsg->SetClientIpFamilyPrefReq.TLVType = 0x01; - pMUXMsg->SetClientIpFamilyPrefReq.TLVLength = cpu_to_le16(0x01); - pMUXMsg->SetClientIpFamilyPrefReq.IpPreference = *((UCHAR *)arg); - return sizeof(QMIWDS_SET_CLIENT_IP_FAMILY_PREF_REQ_MSG); -} - -static USHORT WdsSetAutoConnect(PQMUX_MSG pMUXMsg, void *arg) -{ - pMUXMsg->SetAutoConnectReq.TLVType = 0x01; - pMUXMsg->SetAutoConnectReq.TLVLength = cpu_to_le16(0x01); - pMUXMsg->SetAutoConnectReq.autoconnect_setting = *((UCHAR *)arg); - return sizeof(QMIWDS_SET_AUTO_CONNECT_REQ_MSG); -} - -enum peripheral_ep_type { - DATA_EP_TYPE_RESERVED = 0x0, - DATA_EP_TYPE_HSIC = 0x1, - DATA_EP_TYPE_HSUSB = 0x2, - DATA_EP_TYPE_PCIE = 0x3, - DATA_EP_TYPE_EMBEDDED = 0x4, - DATA_EP_TYPE_BAM_DMUX = 0x5, -}; - -typedef struct { - UINT rx_urb_size; - enum peripheral_ep_type ep_type; - UINT iface_id; - UCHAR MuxId; -} QMAP_SETTING; -static USHORT WdsSetQMUXBindMuxDataPort(PQMUX_MSG pMUXMsg, void *arg) -{ - QMAP_SETTING *qmap_settings = (QMAP_SETTING *)arg; - - pMUXMsg->BindMuxDataPortReq.TLVType = 0x10; - pMUXMsg->BindMuxDataPortReq.TLVLength = cpu_to_le16(0x08); - pMUXMsg->BindMuxDataPortReq.ep_type = cpu_to_le32(qmap_settings->ep_type); - pMUXMsg->BindMuxDataPortReq.iface_id = cpu_to_le32(qmap_settings->iface_id); - pMUXMsg->BindMuxDataPortReq.TLV2Type = 0x11; - pMUXMsg->BindMuxDataPortReq.TLV2Length = cpu_to_le16(0x01); - pMUXMsg->BindMuxDataPortReq.MuxId = qmap_settings->MuxId; - pMUXMsg->BindMuxDataPortReq.TLV3Type = 0x13; - pMUXMsg->BindMuxDataPortReq.TLV3Length = cpu_to_le16(0x04); - pMUXMsg->BindMuxDataPortReq.client_type = - cpu_to_le32(1); // WDS_CLIENT_TYPE_TETHERED - - return sizeof(QMIWDS_BIND_MUX_DATA_PORT_REQ_MSG); -} - -static USHORT WdaSetDataFormat(PQMUX_MSG pMUXMsg, void *arg) -{ - QMAP_SETTING *qmap_settings = (QMAP_SETTING *)arg; - - if (qmap_settings->rx_urb_size == 0) { - PQMIWDS_ADMIN_SET_DATA_FORMAT_TLV_QOS pWdsAdminQosTlv; - PQMIWDS_ADMIN_SET_DATA_FORMAT_TLV linkProto; - PQMIWDS_ADMIN_SET_DATA_FORMAT_TLV dlTlp; - - pWdsAdminQosTlv = - (PQMIWDS_ADMIN_SET_DATA_FORMAT_TLV_QOS)(&pMUXMsg->QMUXMsgHdr + 1); - pWdsAdminQosTlv->TLVType = 0x10; - pWdsAdminQosTlv->TLVLength = cpu_to_le16(0x0001); - pWdsAdminQosTlv->QOSSetting = 0; /* no-QOS header */ - - linkProto = (PQMIWDS_ADMIN_SET_DATA_FORMAT_TLV)(pWdsAdminQosTlv + 1); - linkProto->TLVType = 0x11; - linkProto->TLVLength = cpu_to_le16(4); - linkProto->Value = cpu_to_le32(0x01); /* Set Ethernet mode */ - - dlTlp = (PQMIWDS_ADMIN_SET_DATA_FORMAT_TLV)(linkProto + 1); - ; - dlTlp->TLVType = 0x13; - dlTlp->TLVLength = cpu_to_le16(4); - dlTlp->Value = cpu_to_le32(0x00); - - if (sizeof(*linkProto) != 7) - dbg_time("%s sizeof(*linkProto) = %d, is not 7!", __func__, - sizeof(*linkProto)); - - return sizeof(QCQMUX_MSG_HDR) + sizeof(*pWdsAdminQosTlv) + - sizeof(*linkProto) + sizeof(*dlTlp); - } else { - // Indicates whether the Quality of Service(QOS) data format is used by - // the client. - pMUXMsg->SetDataFormatReq.QosDataFormatTlv.TLVType = 0x10; - pMUXMsg->SetDataFormatReq.QosDataFormatTlv.TLVLength = - cpu_to_le16(0x0001); - pMUXMsg->SetDataFormatReq.QosDataFormatTlv.QOSSetting = - 0; /* no-QOS header */ - // Underlying Link Layer Protocol - pMUXMsg->SetDataFormatReq.UnderlyingLinkLayerProtocolTlv.TLVType = 0x11; - pMUXMsg->SetDataFormatReq.UnderlyingLinkLayerProtocolTlv.TLVLength = - cpu_to_le16(4); - pMUXMsg->SetDataFormatReq.UnderlyingLinkLayerProtocolTlv.Value = - cpu_to_le32(0x02); /* Set IP mode */ - // Uplink (UL) data aggregation protocol to be used for uplink data - // transfer. - pMUXMsg->SetDataFormatReq.UplinkDataAggregationProtocolTlv.TLVType = - 0x12; - pMUXMsg->SetDataFormatReq.UplinkDataAggregationProtocolTlv.TLVLength = - cpu_to_le16(4); - pMUXMsg->SetDataFormatReq.UplinkDataAggregationProtocolTlv.Value = - cpu_to_le32(0x05); // UL QMAP is enabled - // Downlink (DL) data aggregation protocol to be used for downlink data - // transfer - pMUXMsg->SetDataFormatReq.DownlinkDataAggregationProtocolTlv.TLVType = - 0x13; - pMUXMsg->SetDataFormatReq.DownlinkDataAggregationProtocolTlv.TLVLength = - cpu_to_le16(4); - pMUXMsg->SetDataFormatReq.DownlinkDataAggregationProtocolTlv.Value = - cpu_to_le32(0x05); // UL QMAP is enabled - // Maximum number of datagrams in a single aggregated packet on downlink - pMUXMsg->SetDataFormatReq.DownlinkDataAggregationMaxDatagramsTlv - .TLVType = 0x15; - pMUXMsg->SetDataFormatReq.DownlinkDataAggregationMaxDatagramsTlv - .TLVLength = cpu_to_le16(4); - pMUXMsg->SetDataFormatReq.DownlinkDataAggregationMaxDatagramsTlv.Value = - cpu_to_le32(qmap_settings->rx_urb_size / 512); - // Maximum size in bytes of a single aggregated packet allowed on - // downlink - pMUXMsg->SetDataFormatReq.DownlinkDataAggregationMaxSizeTlv.TLVType = - 0x16; - pMUXMsg->SetDataFormatReq.DownlinkDataAggregationMaxSizeTlv.TLVLength = - cpu_to_le16(4); - pMUXMsg->SetDataFormatReq.DownlinkDataAggregationMaxSizeTlv.Value = - cpu_to_le32(qmap_settings->rx_urb_size); - // Peripheral End Point ID - pMUXMsg->SetDataFormatReq.epTlv.TLVType = 0x17; - pMUXMsg->SetDataFormatReq.epTlv.TLVLength = cpu_to_le16(8); - pMUXMsg->SetDataFormatReq.epTlv.ep_type = - cpu_to_le32(qmap_settings->ep_type); - pMUXMsg->SetDataFormatReq.epTlv.iface_id = - cpu_to_le32(qmap_settings->iface_id); - - return sizeof(QMIWDS_ADMIN_SET_DATA_FORMAT_REQ_MSG); - } -} - -#ifdef CONFIG_SIM - -static USHORT UimVerifyPinReqSend(PQMUX_MSG pMUXMsg, void *arg) -{ - pMUXMsg->UIMUIMVerifyPinReq.TLVType = 0x01; - pMUXMsg->UIMUIMVerifyPinReq.TLVLength = cpu_to_le16(0x02); - pMUXMsg->UIMUIMVerifyPinReq.Session_Type = 0x00; - pMUXMsg->UIMUIMVerifyPinReq.Aid_Len = 0x00; - pMUXMsg->UIMUIMVerifyPinReq.TLV2Type = 0x02; - pMUXMsg->UIMUIMVerifyPinReq.TLV2Length = - cpu_to_le16(2 + strlen((const char *)arg)); - pMUXMsg->UIMUIMVerifyPinReq.PINID = 0x01; // Pin1, not Puk - pMUXMsg->UIMUIMVerifyPinReq.PINLen = strlen((const char *)arg); - qstrcpy((PCHAR)&pMUXMsg->UIMUIMVerifyPinReq.PINValue, ((const char *)arg)); - return sizeof(QMIUIM_VERIFY_PIN_REQ_MSG) + (strlen((const char *)arg) - 1); -} -//2021-03-24 willa.liu@fibocom.com changed begin for support mantis 0071817 -static USHORT UimBindPinReqSend_NAS_WMS(PQMUX_MSG pMUXMsg, void *arg) -{ - pMUXMsg->UIMUIMBindPinReq.TLVType = 0x01; - pMUXMsg->UIMUIMBindPinReq.TLVLength = cpu_to_le16(0x01); - pMUXMsg->UIMUIMBindPinReq.Value = 0x01; - return sizeof(QMIUIM_BIND_PIN_REQ_MSG); -} - -static USHORT UimBindPinReqSend_WDS_DMS_QOS(PQMUX_MSG pMUXMsg, void *arg) -{ - pMUXMsg->UIMUIMBindPinReq_4.TLVType = 0x01; - pMUXMsg->UIMUIMBindPinReq_4.TLVLength = cpu_to_le16(0x04); - pMUXMsg->UIMUIMBindPinReq_4.Value = 0x0002; - return sizeof(QMIUIM_BIND_PIN_REQ_MSG_4); -} -//2021-03-24 willa.liu@fibocom.com changed end for support mantis 0071817 -#ifdef CONFIG_IMSI_ICCID -static USHORT UimReadTransparentIMSIReqSend(PQMUX_MSG pMUXMsg, void *arg) -{ - PREAD_TRANSPARENT_TLV pReadTransparent; - - pMUXMsg->UIMUIMReadTransparentReq.TLVType = 0x01; - pMUXMsg->UIMUIMReadTransparentReq.TLVLength = cpu_to_le16(0x02); - if (!strcmp((char *)arg, "EF_ICCID")) { - pMUXMsg->UIMUIMReadTransparentReq.Session_Type = 0x06; - pMUXMsg->UIMUIMReadTransparentReq.Aid_Len = 0x00; - - pMUXMsg->UIMUIMReadTransparentReq.TLV2Type = 0x02; - pMUXMsg->UIMUIMReadTransparentReq.file_id = cpu_to_le16(0x2FE2); - pMUXMsg->UIMUIMReadTransparentReq.path_len = 0x02; - pMUXMsg->UIMUIMReadTransparentReq.path[0] = 0x00; - pMUXMsg->UIMUIMReadTransparentReq.path[1] = 0x3F; - } else if (!strcmp((char *)arg, "EF_IMSI")) { - pMUXMsg->UIMUIMReadTransparentReq.Session_Type = 0x00; - pMUXMsg->UIMUIMReadTransparentReq.Aid_Len = 0x00; - - pMUXMsg->UIMUIMReadTransparentReq.TLV2Type = 0x02; - pMUXMsg->UIMUIMReadTransparentReq.file_id = cpu_to_le16(0x6F07); - pMUXMsg->UIMUIMReadTransparentReq.path_len = 0x04; - pMUXMsg->UIMUIMReadTransparentReq.path[0] = 0x00; - pMUXMsg->UIMUIMReadTransparentReq.path[1] = 0x3F; - pMUXMsg->UIMUIMReadTransparentReq.path[2] = 0xFF; - pMUXMsg->UIMUIMReadTransparentReq.path[3] = 0x7F; - } - - pMUXMsg->UIMUIMReadTransparentReq.TLV2Length = - cpu_to_le16(3 + pMUXMsg->UIMUIMReadTransparentReq.path_len); - - pReadTransparent = (PREAD_TRANSPARENT_TLV)( - &pMUXMsg->UIMUIMReadTransparentReq - .path[pMUXMsg->UIMUIMReadTransparentReq.path_len]); - pReadTransparent->TLVType = 0x03; - pReadTransparent->TLVLength = cpu_to_le16(0x04); - pReadTransparent->Offset = cpu_to_le16(0x00); - pReadTransparent->Length = cpu_to_le16(0x00); - - return (sizeof(QMIUIM_READ_TRANSPARENT_REQ_MSG) + - pMUXMsg->UIMUIMReadTransparentReq.path_len + - sizeof(READ_TRANSPARENT_TLV)); -} -#endif -#endif - -#ifdef CONFIG_APN -static USHORT WdsGetProfileSettingsReqSend(PQMUX_MSG pMUXMsg, void *arg) -{ - PROFILE_T *profile = (PROFILE_T *)arg; - pMUXMsg->GetProfileSettingsReq.Length = - cpu_to_le16(sizeof(QMIWDS_GET_PROFILE_SETTINGS_REQ_MSG) - 4); - pMUXMsg->GetProfileSettingsReq.TLVType = 0x01; - pMUXMsg->GetProfileSettingsReq.TLVLength = cpu_to_le16(0x02); - pMUXMsg->GetProfileSettingsReq.ProfileType = 0x00; // 0 ~ 3GPP, 1 ~ 3GPP2 - pMUXMsg->GetProfileSettingsReq.ProfileIndex = profile->pdpindex; - return sizeof(QMIWDS_GET_PROFILE_SETTINGS_REQ_MSG); -} -//begin modified by zhangkaibo add create profile qmi. mantis 0049137,0048741 20200610 -static USHORT WdsCreateProfileSettingsReq(PQMUX_MSG pMUXMsg, void *arg) -{ - USHORT TLVLength = 0; - UCHAR *pTLV; - PROFILE_T *profile = (PROFILE_T *)arg; - PQMIWDS_PDPTYPE pPdpType; - - pMUXMsg->CreateProfileSettingsReq.Length = - cpu_to_le16(sizeof(QMIWDS_CREATE_PROFILE_SETTINGS_REQ_MSG) - 4); - pMUXMsg->CreateProfileSettingsReq.TLVType = 0x01; - pMUXMsg->CreateProfileSettingsReq.TLVLength = cpu_to_le16(0x01); - pMUXMsg->CreateProfileSettingsReq.ProfileType = - 0x00; // 0 ~ 3GPP, 1 ~ 3GPP2 - - pTLV = (UCHAR *)(&pMUXMsg->CreateProfileSettingsReq + 1); - - pPdpType = (PQMIWDS_PDPTYPE)(pTLV + TLVLength); - pPdpType->TLVType = 0x11; - pPdpType->TLVLength = cpu_to_le16(0x01); - // 0 ?C PDP-IP (IPv4) - // 1 ?C PDP-PPP - // 2 ?C PDP-IPv6 - // 3 ?C PDP-IPv4v6 - if (profile->ipv4_flag && profile->ipv6_flag) - pPdpType->PdpType = 3; - else if (profile->ipv6_flag) - pPdpType->PdpType = 2; - else - pPdpType->PdpType = 0; - TLVLength += (le16_to_cpu(pPdpType->TLVLength) + sizeof(QCQMICTL_TLV_HDR)); - - // Set APN Name - if (profile->apn) { - PQMIWDS_APNNAME pApnName = (PQMIWDS_APNNAME)(pTLV + TLVLength); - pApnName->TLVType = 0x14; - pApnName->TLVLength = cpu_to_le16(strlen(profile->apn)); - qstrcpy((char *)&pApnName->ApnName, profile->apn); - TLVLength += - (le16_to_cpu(pApnName->TLVLength) + sizeof(QCQMICTL_TLV_HDR)); - } - - // Set User Name - if (profile->user) { - PQMIWDS_USERNAME pUserName = (PQMIWDS_USERNAME)(pTLV + TLVLength); - pUserName->TLVType = 0x1B; - - pUserName->TLVLength = cpu_to_le16(strlen(profile->user)); - qstrcpy((char *)&pUserName->UserName, profile->user); - TLVLength += - (le16_to_cpu(pUserName->TLVLength) + sizeof(QCQMICTL_TLV_HDR)); - } - - // Set Password - if (profile->password) { - PQMIWDS_PASSWD pPasswd = (PQMIWDS_PASSWD)(pTLV + TLVLength); - pPasswd->TLVType = 0x1C; - pPasswd->TLVLength = cpu_to_le16(strlen(profile->password)); - qstrcpy((char *)&pPasswd->Passwd, profile->password); - TLVLength += - (le16_to_cpu(pPasswd->TLVLength) + sizeof(QCQMICTL_TLV_HDR)); - } - - // Set Auth Protocol - if (profile->user && profile->password) { - PQMIWDS_AUTH_PREFERENCE pAuthPref = - (PQMIWDS_AUTH_PREFERENCE)(pTLV + TLVLength); - pAuthPref->TLVType = 0x1D; - pAuthPref->TLVLength = cpu_to_le16(0x01); - pAuthPref->AuthPreference = - profile->auth; // 0 ~ None, 1 ~ Pap, 2 ~ Chap, 3 ~ MsChapV2 - TLVLength += - (le16_to_cpu(pAuthPref->TLVLength) + sizeof(QCQMICTL_TLV_HDR)); - } - - return sizeof(QMIWDS_CREATE_PROFILE_SETTINGS_REQ_MSG) + TLVLength; -} -//end modified by zhangkaibo add create profile qmi. mantis 0049137,0048741 20200610 -static USHORT WdsModifyProfileSettingsReq(PQMUX_MSG pMUXMsg, void *arg) -{ - USHORT TLVLength = 0; - UCHAR *pTLV; - PROFILE_T *profile = (PROFILE_T *)arg; - PQMIWDS_PDPTYPE pPdpType; - - pMUXMsg->ModifyProfileSettingsReq.Length = - cpu_to_le16(sizeof(QMIWDS_MODIFY_PROFILE_SETTINGS_REQ_MSG) - 4); - pMUXMsg->ModifyProfileSettingsReq.TLVType = 0x01; - pMUXMsg->ModifyProfileSettingsReq.TLVLength = cpu_to_le16(0x02); - pMUXMsg->ModifyProfileSettingsReq.ProfileType = - 0x00; // 0 ~ 3GPP, 1 ~ 3GPP2 - pMUXMsg->ModifyProfileSettingsReq.ProfileIndex = profile->pdpindex; - - pTLV = (UCHAR *)(&pMUXMsg->ModifyProfileSettingsReq + 1); - - pPdpType = (PQMIWDS_PDPTYPE)(pTLV + TLVLength); - pPdpType->TLVType = 0x11; - pPdpType->TLVLength = cpu_to_le16(0x01); - // 0 ?C PDP-IP (IPv4) - // 1 ?C PDP-PPP - // 2 ?C PDP-IPv6 - // 3 ?C PDP-IPv4v6 - if (profile->ipv6_flag && profile->ipv4_flag) - pPdpType->PdpType = 3; - else if (profile->ipv6_flag) - pPdpType->PdpType = 2; - else - pPdpType->PdpType = 0; - TLVLength += (le16_to_cpu(pPdpType->TLVLength) + sizeof(QCQMICTL_TLV_HDR)); - - // Set APN Name - if (profile->apn) { - PQMIWDS_APNNAME pApnName = (PQMIWDS_APNNAME)(pTLV + TLVLength); - pApnName->TLVType = 0x14; - pApnName->TLVLength = cpu_to_le16(strlen(profile->apn)); - qstrcpy((char *)&pApnName->ApnName, profile->apn); - TLVLength += - (le16_to_cpu(pApnName->TLVLength) + sizeof(QCQMICTL_TLV_HDR)); - } - - // Set User Name - if (profile->user) { - PQMIWDS_USERNAME pUserName = (PQMIWDS_USERNAME)(pTLV + TLVLength); - pUserName->TLVType = 0x1B; - pUserName->TLVLength = cpu_to_le16(strlen(profile->user)); - qstrcpy((char *)&pUserName->UserName, profile->user); - TLVLength += - (le16_to_cpu(pUserName->TLVLength) + sizeof(QCQMICTL_TLV_HDR)); - } - - // Set Password - if (profile->password) { - PQMIWDS_PASSWD pPasswd = (PQMIWDS_PASSWD)(pTLV + TLVLength); - pPasswd->TLVType = 0x1C; - pPasswd->TLVLength = cpu_to_le16(strlen(profile->password)); - qstrcpy((char *)&pPasswd->Passwd, profile->password); - TLVLength += - (le16_to_cpu(pPasswd->TLVLength) + sizeof(QCQMICTL_TLV_HDR)); - } - - // Set Auth Protocol - if (profile->user && profile->password) { - PQMIWDS_AUTH_PREFERENCE pAuthPref = - (PQMIWDS_AUTH_PREFERENCE)(pTLV + TLVLength); - pAuthPref->TLVType = 0x1D; - pAuthPref->TLVLength = cpu_to_le16(0x01); - pAuthPref->AuthPreference = - profile->auth; // 0 ~ None, 1 ~ Pap, 2 ~ Chap, 3 ~ MsChapV2 - TLVLength += - (le16_to_cpu(pAuthPref->TLVLength) + sizeof(QCQMICTL_TLV_HDR)); - } - - return sizeof(QMIWDS_MODIFY_PROFILE_SETTINGS_REQ_MSG) + TLVLength; -} -#endif - -static USHORT WdsGetRuntimeSettingReq(PQMUX_MSG pMUXMsg, void *arg) -{ - pMUXMsg->GetRuntimeSettingsReq.TLVType = 0x10; - pMUXMsg->GetRuntimeSettingsReq.TLVLength = cpu_to_le16(0x04); - // the following mask also applies to IPV6 - pMUXMsg->GetRuntimeSettingsReq.Mask = - cpu_to_le32(QMIWDS_GET_RUNTIME_SETTINGS_MASK_IPV4DNS_ADDR | - QMIWDS_GET_RUNTIME_SETTINGS_MASK_IPV4_ADDR | - QMIWDS_GET_RUNTIME_SETTINGS_MASK_MTU | - QMIWDS_GET_RUNTIME_SETTINGS_MASK_IPV4GATEWAY_ADDR); // | - // QMIWDS_GET_RUNTIME_SETTINGS_MASK_PCSCF_SV_ADDR | - // QMIWDS_GET_RUNTIME_SETTINGS_MASK_PCSCF_DOM_NAME; - - return sizeof(QMIWDS_GET_RUNTIME_SETTINGS_REQ_MSG); -} - -static PQCQMIMSG s_pRequest; -static PQCQMIMSG s_pResponse; -static pthread_mutex_t s_commandmutex = PTHREAD_MUTEX_INITIALIZER; -static pthread_cond_t s_commandcond = PTHREAD_COND_INITIALIZER; - -static int is_response(const PQCQMIMSG pRequest, const PQCQMIMSG pResponse) -{ - if ((pRequest->QMIHdr.QMIType == pResponse->QMIHdr.QMIType) && - (pRequest->QMIHdr.ClientId == pResponse->QMIHdr.ClientId)) { - USHORT requestTID, responseTID; - if (pRequest->QMIHdr.QMIType == QMUX_TYPE_CTL) { - requestTID = pRequest->CTLMsg.QMICTLMsgHdr.TransactionId; - responseTID = pResponse->CTLMsg.QMICTLMsgHdr.TransactionId; - } else { - requestTID = le16_to_cpu(pRequest->MUXMsg.QMUXHdr.TransactionId); - responseTID = le16_to_cpu(pResponse->MUXMsg.QMUXHdr.TransactionId); - } - return (requestTID == responseTID); - } - return 0; -} - -int (*qmidev_send)(PQCQMIMSG pRequest); - -int QmiThreadSendQMITimeout(PQCQMIMSG pRequest, PQCQMIMSG *ppResponse, - unsigned msecs) -{ - int ret; - - if (!pRequest) { - return -EINVAL; - } - - pthread_mutex_lock(&s_commandmutex); - - if (ppResponse) - *ppResponse = NULL; - - dump_qmi(pRequest, le16_to_cpu(pRequest->QMIHdr.Length) + 1); - - s_pRequest = pRequest; - s_pResponse = NULL; - - ret = qmidev_send(pRequest); - - if (ret == 0) { - ret = pthread_cond_timeout_np(&s_commandcond, &s_commandmutex, msecs); - if (!ret) { - if (s_pResponse && ppResponse) { - *ppResponse = s_pResponse; - } else { - if (s_pResponse) { - free(s_pResponse); - s_pResponse = NULL; - } - } - } else { - dbg_time("%s pthread_cond_timeout_np=%d, errno: %d (%s)", __func__, - ret, errno, strerror(errno)); - } - } - - pthread_mutex_unlock(&s_commandmutex); - - return ret; -} - -int QmiThreadSendQMI(PQCQMIMSG pRequest, PQCQMIMSG *ppResponse) -{ - return QmiThreadSendQMITimeout(pRequest, ppResponse, 30 * 1000); -} - -void QmiThreadRecvQMI(PQCQMIMSG pResponse) -{ - pthread_mutex_lock(&s_commandmutex); - if (pResponse == NULL) { - if (s_pRequest) { - free(s_pRequest); - s_pRequest = NULL; - s_pResponse = NULL; - pthread_cond_signal(&s_commandcond); - } - pthread_mutex_unlock(&s_commandmutex); - return; - } - dump_qmi(pResponse, le16_to_cpu(pResponse->QMIHdr.Length) + 1); - if (s_pRequest && is_response(s_pRequest, pResponse)) { - free(s_pRequest); - s_pRequest = NULL; - s_pResponse = malloc(le16_to_cpu(pResponse->QMIHdr.Length) + 1); - if (s_pResponse != NULL) { - memcpy(s_pResponse, pResponse, - le16_to_cpu(pResponse->QMIHdr.Length) + 1); - } - pthread_cond_signal(&s_commandcond); - } else if ((pResponse->QMIHdr.QMIType == QMUX_TYPE_NAS) && - (le16_to_cpu(pResponse->MUXMsg.QMUXMsgHdrResp.Type) == - QMINAS_SERVING_SYSTEM_IND)) { - qmidevice_send_event_to_main( - RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED); - } else if ((pResponse->QMIHdr.QMIType == QMUX_TYPE_WDS) && - (le16_to_cpu(pResponse->MUXMsg.QMUXMsgHdrResp.Type) == - QMIWDS_GET_PKT_SRVC_STATUS_IND)) { - qmidevice_send_event_to_main(RIL_UNSOL_DATA_CALL_LIST_CHANGED); - } else if ((pResponse->QMIHdr.QMIType == QMUX_TYPE_WDS_IPV6) && - (le16_to_cpu(pResponse->MUXMsg.QMUXMsgHdrResp.Type) == - QMIWDS_GET_PKT_SRVC_STATUS_IND)) { - qmidevice_send_event_to_main(RIL_UNSOL_DATA_CALL_LIST_CHANGED); - } else if ((pResponse->QMIHdr.QMIType == QMUX_TYPE_NAS) && - (le16_to_cpu(pResponse->MUXMsg.QMUXMsgHdrResp.Type) == - QMINAS_SYS_INFO_IND)) { - qmidevice_send_event_to_main( - RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED); - } else { - if (debug_qmi) - dbg_time("nobody care this qmi msg!!"); - } - pthread_mutex_unlock(&s_commandmutex); -} - -int requestSetEthMode(PROFILE_T *profile) -{ - PQCQMIMSG pRequest; - PQCQMIMSG pResponse = NULL; - PQMUX_MSG pMUXMsg; - int err; - PQMIWDS_ADMIN_SET_DATA_FORMAT_TLV linkProto; - UCHAR IpPreference; - UCHAR autoconnect_setting = 0; - QMAP_SETTING qmap_settings = {0, 0, 0, 0}; - - if (profile->qmap_mode) { - profile->rawIP = 1; - - - qmap_settings.MuxId = profile->muxid; - - if (qmidev_is_pciemhi(profile->qmichannel)) { // SDX20_PCIE - qmap_settings.rx_urb_size = 32*1024; //SDX24&SDX55 support 32KB - qmap_settings.ep_type = DATA_EP_TYPE_PCIE; - qmap_settings.iface_id = 0x04; - } else { // for MDM9x07&MDM9x40&SDX20 USB - qmap_settings.rx_urb_size = profile->qmap_size; - //profile->qmap_size; // SDX24&SDX55 support 32KB - qmap_settings.ep_type = DATA_EP_TYPE_HSUSB; -//2021-02-08 zhangkaibo@fibocom.com changed begin for mantis 0070613 - qmap_settings.iface_id = profile->interfacenum; -//2021-02-08 zhangkaibo@fibocom.com changed end for mantis 0070613 - } - - if (qmidev_is_gobinet( - profile->qmichannel)) { // GobiNet set data format - // in GobiNet driver - goto skip_WdaSetDataFormat; - } else if (profile->qmap_mode > - 1) { // QMAP MUX enabled, set data format in fibo-qmi-proxy - -//2021-06-03 willa.liu@fibocom.com changed begin for support mantis 0079541 -//2021-01-27 willa.liu@fibocom.com changed begin for support mantis 0068849 - //goto skip_WdaSetDataFormat; - goto skip_WdaSetDataFormat; -//2021-01-27 willa.liu@fibocom.com changed end for support mantis 0068849 -//2021-06-03 willa.liu@fibocom.com changed end for support mantis 0079541 - - } - } - - pRequest = - ComposeQMUXMsg(QMUX_TYPE_WDS_ADMIN, QMIWDS_ADMIN_SET_DATA_FORMAT_REQ, - WdaSetDataFormat, (void *)&qmap_settings); - err = QmiThreadSendQMI(pRequest, &pResponse); - qmi_rsp_check_and_return(); - - linkProto = (PQMIWDS_ADMIN_SET_DATA_FORMAT_TLV)GetTLV( - &pResponse->MUXMsg.QMUXMsgHdr, 0x11); - if (linkProto != NULL) { - profile->rawIP = (le32_to_cpu(linkProto->Value) == 2); - } - - linkProto = (PQMIWDS_ADMIN_SET_DATA_FORMAT_TLV)GetTLV( - &pResponse->MUXMsg.QMUXMsgHdr, 0x16); - if (linkProto != NULL && profile->qmap_mode) { - qmap_settings.rx_urb_size = le32_to_cpu(linkProto->Value); - dbg_time( - "qmap_settings.rx_urb_size = %d", - qmap_settings.rx_urb_size); // must same as rx_urb_size defined - // in GobiNet&qmi_wwan driver - } - - free(pResponse); - -skip_WdaSetDataFormat: -//bind v4 client - // set ipv4 - if(profile->ipv4_flag) - { -/* IpPreference = IpFamilyV4; - pRequest = - ComposeQMUXMsg(QMUX_TYPE_WDS, QMIWDS_SET_CLIENT_IP_FAMILY_PREF_REQ, - WdsSetClientIPFamilyPref, (void *)&IpPreference); - err = QmiThreadSendQMI(pRequest, &pResponse); - if (pResponse) - free(pResponse); -*/ - if (profile->qmapnet_adapter) { - // bind wds mux data port - pRequest = ComposeQMUXMsg( - QMUX_TYPE_WDS, QMIWDS_BIND_MUX_DATA_PORT_REQ, - WdsSetQMUXBindMuxDataPort, (void *)&qmap_settings); - err = QmiThreadSendQMI(pRequest, &pResponse); - qmi_rsp_check_and_return(); - if (pResponse) - free(pResponse); - } -// set auto connect - pRequest = ComposeQMUXMsg(QMUX_TYPE_WDS, QMIWDS_SET_AUTO_CONNECT_REQ, - WdsSetAutoConnect, (void *)&autoconnect_setting); - QmiThreadSendQMI(pRequest, &pResponse); - if (pResponse) - free(pResponse); - } - -//bind v6 client - if(profile->ipv6_flag) - { - IpPreference = IpFamilyV6; - pRequest = ComposeQMUXMsg( - QMUX_TYPE_WDS_IPV6, QMIWDS_SET_CLIENT_IP_FAMILY_PREF_REQ, - WdsSetClientIPFamilyPref, (void *)&IpPreference); - err = QmiThreadSendQMI(pRequest, &pResponse); - qmi_rsp_check_and_return(); - if (pResponse) - free(pResponse); - - if (profile->qmapnet_adapter) { - // bind wds mux data port - pRequest = ComposeQMUXMsg( - QMUX_TYPE_WDS_IPV6, QMIWDS_BIND_MUX_DATA_PORT_REQ, - WdsSetQMUXBindMuxDataPort, (void *)&qmap_settings); - err = QmiThreadSendQMI(pRequest, &pResponse); - qmi_rsp_check_and_return(); - if (pResponse) - free(pResponse); - } - IpPreference = IpFamilyV6; - pRequest = ComposeQMUXMsg( - QMUX_TYPE_WDS_IPV6, QMIWDS_SET_CLIENT_IP_FAMILY_PREF_REQ, - WdsSetClientIPFamilyPref, (void *)&IpPreference); - err = QmiThreadSendQMI(pRequest, &pResponse); - qmi_rsp_check_and_return(); - if (pResponse) - free(pResponse); - -// set auto connect - pRequest = ComposeQMUXMsg(QMUX_TYPE_WDS_IPV6, QMIWDS_SET_AUTO_CONNECT_REQ, - WdsSetAutoConnect, (void *)&autoconnect_setting); - QmiThreadSendQMI(pRequest, &pResponse); - if (pResponse) - free(pResponse); - } - return 0; -} - -#ifdef CONFIG_SIM -int requestGetPINStatus(SIM_Status *pSIMStatus) -{ - PQCQMIMSG pRequest; - PQCQMIMSG pResponse; - PQMUX_MSG pMUXMsg; - int err; - PQMIDMS_UIM_PIN_STATUS pPin1Status = NULL; - // PQMIDMS_UIM_PIN_STATUS pPin2Status = NULL; - - - pRequest = ComposeQMUXMsg(QMUX_TYPE_UIM, QMIUIM_GET_CARD_STATUS_REQ, - NULL, NULL); - - err = QmiThreadSendQMI(pRequest, &pResponse); - qmi_rsp_check_and_return(); - - pPin1Status = - (PQMIDMS_UIM_PIN_STATUS)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x11); - // pPin2Status = - // (PQMIDMS_UIM_PIN_STATUS)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x12); - - if (pPin1Status != NULL) { - if (pPin1Status->PINStatus == QMI_PIN_STATUS_NOT_VERIF) { - *pSIMStatus = SIM_PIN; - } else if (pPin1Status->PINStatus == QMI_PIN_STATUS_BLOCKED) { - *pSIMStatus = SIM_PUK; - } else if (pPin1Status->PINStatus == QMI_PIN_STATUS_PERM_BLOCKED) { - *pSIMStatus = SIM_BAD; - } - } - - free(pResponse); - return 0; -} - -static int requestGetSIMMode(PROFILE_T *profile) -{ - int i; - int fd; - int ret; - int len; - char buffer[1024] = {0}; - char *sendbuffer = "AT+GTDUALSIMEN?"; - int totallen = 0; - fd_set readfds; - struct timeval timeout; - struct termios tiosfd, tio; - int timeoutVal = 5; - char *dev = NULL; - if(qmidev_is_gobinet(profile->qmichannel)) - { - dev = "/dev/ttyUSB1"; //The port under Linux is operated by opening the device file - } - else - { - dev = "/dev/mhi_DUN"; //The port under Linux is operated by opening the device file - } - - fd = open(dev, O_RDWR | O_NOCTTY | O_NONBLOCK); - if(fd < 0) - goto ERR; - fcntl(fd, F_SETFL, O_RDWR); - xget1(fd, &tio, &tiosfd); - - if(xset1(fd, &tio, dev)) - goto ERR; - - tcflush(fd, TCIOFLUSH); - - FD_ZERO(&readfds); - FD_SET(fd, &readfds); - - sprintf(buffer, "%s\r", sendbuffer); - ret = write (fd, buffer, strlen(buffer)); - if(ret < 0) - { - dbg_time("write failed\n"); - goto ERR; - } - dbg_time("dev: %s\nsendbuffer:%s\n", dev, sendbuffer); - sleep(3); - - while(1) - { - timeout.tv_sec = timeoutVal; - timeout.tv_usec = 0; - - ret = select(fd+1, &readfds, (fd_set *)0, (fd_set *)0, &timeout); - if(ret > 0) - { - ret = read(fd, buffer+totallen, sizeof(buffer)-totallen-1); - if(ret < 0) - { - dbg_time("read failed\n"); - goto ERR; - } - - if(ret == 0) - { - goto ERR; - } - - totallen += ret; - buffer[totallen] = '\0'; - dbg_time("read %d %s", ret, &buffer[totallen-ret]); - -//current buffer is return value - if(strstr(buffer, "+GTDUALSIMEN: 1")) - { - close(fd); - dbg_time("read 1\n"); - return 1; - } - else - { - close(fd); - dbg_time("read 0/2/3\n"); - return 0; - } - } - else - { - dbg_time("select timeout\n"); - goto ERR; - } - - } - - close(fd); - -ERR: - if(fd > 0) - close(fd); - return -1; -} - - -//2021-03-24 willa.liu@fibocom.com changed begin for support mantis 0071817 -int requestGetSIMCardNumber(PROFILE_T *profile) -{ - int i; - int fd; - int ret; - int len; - char buffer[1024] = {0}; - int rate; - char *sendbuffer; - int totallen = 0; - fd_set readfds; - struct timeval timeout; - struct termios tiosfd, tio; - int timeoutVal = 5; - char *dev = NULL; - if(qmidev_is_gobinet(profile->qmichannel)) - { - dev = "/dev/ttyUSB1"; //The port under Linux is operated by opening the device file - } - else - { - dev = "/dev/mhi_DUN"; //The port under Linux is operated by opening the device file - } - rate = 115200; - sendbuffer = "AT+GTDUALSIM?"; - if(requestGetSIMMode(profile) != 1) - { - return 0; - } - fd = open(dev, O_RDWR | O_NOCTTY | O_NONBLOCK); - if(fd < 0) - goto ERR; - fcntl(fd, F_SETFL, O_RDWR); - xget1(fd, &tio, &tiosfd); - - if(xset1(fd, &tio, dev)) - goto ERR; - - tcflush(fd, TCIOFLUSH); - - FD_ZERO(&readfds); - FD_SET(fd, &readfds); - - sprintf(buffer, "%s\r", sendbuffer); - ret = write (fd, buffer, strlen(buffer)); - if(ret < 0) - { - dbg_time("write failed\n"); - goto ERR; - } - dbg_time("dev: %s\nrate:%d\nsendbuffer:%s\n", dev, rate, sendbuffer); - sleep(3); - goto read_result; - while(1) - { - timeout.tv_sec = timeoutVal; - timeout.tv_usec = 0; - - //ret = select(fd+1, &readfds, (fd_set *)0, (fd_set *)0, &timeout); - //if(ret > 0) - { - read_result: - ret = read(fd, buffer+totallen, sizeof(buffer)-totallen-1); - if(ret < 0) - { - dbg_time("read failed\n"); - goto ERR; - } - - if(ret == 0) - { - goto ERR; - } - - totallen += ret; - buffer[totallen] = '\0'; - dbg_time("read %d %s", ret, &buffer[totallen-ret]); - -//current buffer is return value - if(strstr(buffer, "+GTDUALSIM: 0")) - { - close(fd); - dbg_time("read 0\n"); - return 0; - } - else if(strstr(buffer, "+GTDUALSIM: 1")) - { - close(fd); - dbg_time("read 1\n"); - return 1; - } - else - continue; - } - //else - { - //dbg_time("select timeout\n"); - //goto ERR; - } - - } - - close(fd); - -ERR: - if(fd > 0) - close(fd); - return -1; -} - -int requestSimBindSubscription_NAS_WMS() -{ - PQCQMIMSG pRequest_nas; - PQCQMIMSG pResponse_nas; - int err; - - pRequest_nas = ComposeQMUXMsg(QMUX_TYPE_NAS, QMI_NAS_BIND_SUBSCRIPTION_REQ_V01, - UimBindPinReqSend_NAS_WMS, NULL); - err = QmiThreadSendQMI(pRequest_nas, &pResponse_nas); - free(pResponse_nas); - - return 0; -} - -int requestSimBindSubscription_WDS_DMS_QOS() -{ - PQCQMIMSG pRequest_wds; - PQCQMIMSG pRequest_dms; - - PQCQMIMSG pResponse_wds; - PQCQMIMSG pResponse_dms; - int err; - - pRequest_wds = ComposeQMUXMsg(QMUX_TYPE_WDS, QMI_WDS_BIND_SUBSCRIPTION_REQ_V01, - UimBindPinReqSend_WDS_DMS_QOS, NULL); - err = QmiThreadSendQMI(pRequest_wds, &pResponse_wds); - - pRequest_dms = ComposeQMUXMsg(QMUX_TYPE_DMS, QMI_DMS_BIND_SUBSCRIPTION_REQ_V01, - UimBindPinReqSend_WDS_DMS_QOS, NULL); - err = QmiThreadSendQMI(pRequest_dms, &pResponse_dms); - - free(pResponse_wds); - free(pResponse_dms); - - return 0; -} - -//int requestGetSIMStatus(SIM_Status *pSIMStatus) -int requestGetSIMStatus(SIM_Status *pSIMStatus, const int sim_select) -{ // RIL_REQUEST_GET_SIM_STATUS - int i; - dbg_time("sim_select = %d\n", sim_select); - PQCQMIMSG pRequest; - PQCQMIMSG pResponse; - PQMUX_MSG pMUXMsg; - int err; - const char *SIM_Status_String[] = { - "SIM_ABSENT", - "SIM_NOT_READY", - "SIM_READY", /* SIM_READY means the radio state is RADIO_STATE_SIM_READY - */ - "SIM_PIN", - "SIM_PUK", - "SIM_NETWORK_PERSONALIZATION"}; - - pRequest = ComposeQMUXMsg(QMUX_TYPE_UIM, QMIUIM_GET_CARD_STATUS_REQ, - NULL, NULL); - - err = QmiThreadSendQMI(pRequest, &pResponse); - qmi_rsp_check_and_return(); - - *pSIMStatus = SIM_ABSENT; - PQMIUIM_CARD_STATUS pCardStatus = NULL; - PQMIUIM_PIN_STATE pPINState = NULL; - UCHAR CardState = 0x01; - UCHAR PIN1State = QMI_PIN_STATUS_NOT_VERIF; - // UCHAR PIN1Retries; - // UCHAR PUK1Retries; - // UCHAR PIN2State; - // UCHAR PIN2Retries; - // UCHAR PUK2Retries; - - void *temp = NULL; - QMIUIM_APP_STATUS * curr_app = NULL; - Instance * curr_ints = NULL; - - pCardStatus = - (PQMIUIM_CARD_STATUS)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x10); - if(sim_select == 0) - { - temp =(void*)pCardStatus + sizeof(QMIUIM_CARD_STATUS); - curr_ints = temp; - dbg_time("curr_ints_sim1 %s", curr_ints); - temp = temp + sizeof(Instance); - curr_app = temp; - } - else - { - temp = (void*)pCardStatus + sizeof(QMIUIM_CARD_STATUS); - temp = temp + sizeof(Instance) + (sizeof(QMIUIM_APP_STATUS)*(((Instance *)temp)->NumApp)); - curr_ints = temp; - dbg_time("curr_ints_sim2 %s", curr_ints); - curr_app = temp + sizeof(Instance); - } -/* - if (pCardStatus != NULL) { - - for (i = 0; i < pCardStatus->NumApp; i++) { - if (pCardStatus->AppStatus[i].AppType == 2) { - pPINState = &(pCardStatus->AppStatus[i].PinState); - break; - } - } - if (i == pCardStatus->NumApp) { - dbg_time("no USIM Card info"); - return -1; - } - - CardState = pCardStatus->CardState; - if (pPINState->UnivPIN == 1) { - PIN1State = pCardStatus->UPINState; -*/ - if (curr_ints != NULL) { - dbg_time("curr_ints->CardState is %d", curr_ints->CardState); - dbg_time("curr_ints->NumApp is %d", curr_ints->NumApp); - for (i = 0; i < curr_ints->NumApp; i++) { - dbg_time("AppType = %d\n", curr_app[i].AppType); - if (curr_app[i].AppType == 2) { - pPINState = &(curr_app[i].PinState); - break; - } - } - if (i == curr_ints->NumApp) { - dbg_time("no USIM Card info"); - return -1; - } - - //CardState = pCardStatus->CardState; - CardState = curr_ints->CardState; - if (pPINState->UnivPIN == 1) { - PIN1State = curr_ints->UPINState; - // PIN1Retries = pCardStatus->UPINRetries; - // PUK1Retries = pCardStatus->UPUKRetries; - } else { - PIN1State = pPINState->PIN1State; - // PIN1Retries = pPINState->PIN1Retries; - // PUK1Retries = pPINState->PUK1Retries; - } - // PIN2State = pPINState->PIN2State; - // PIN2Retries = pPINState->PIN2Retries; - // PUK2Retries = pPINState->PUK2Retries; - } -//2021-03-24 willa.liu@fibocom.com changed end for support mantis 0071817 - *pSIMStatus = SIM_ABSENT; - if ((CardState == 0x01) && ((PIN1State == QMI_PIN_STATUS_VERIFIED) || - (PIN1State == QMI_PIN_STATUS_DISABLED))) { - *pSIMStatus = SIM_READY; - } else if (CardState == 0x01) { - if (PIN1State == QMI_PIN_STATUS_NOT_VERIF) { - *pSIMStatus = SIM_PIN; - } - if (PIN1State == QMI_PIN_STATUS_BLOCKED) { - *pSIMStatus = SIM_PUK; - } else if (PIN1State == QMI_PIN_STATUS_PERM_BLOCKED) { - *pSIMStatus = SIM_BAD; - } else if (PIN1State == QMI_PIN_STATUS_NOT_INIT || - PIN1State == QMI_PIN_STATUS_VERIFIED || - PIN1State == QMI_PIN_STATUS_DISABLED) { - *pSIMStatus = SIM_READY; - } - } else if (CardState == 0x00 || CardState == 0x02) { - } else { - } - - dbg_time("%s SIMStatus: %s", __func__, SIM_Status_String[*pSIMStatus]); - - free(pResponse); - - return 0; -} - -int requestEnterSimPin(const CHAR *pPinCode) -{ - PQCQMIMSG pRequest; - PQCQMIMSG pResponse; - PQMUX_MSG pMUXMsg; - int err; - - pRequest = ComposeQMUXMsg(QMUX_TYPE_UIM, QMIUIM_VERIFY_PIN_REQ, - UimVerifyPinReqSend, (void *)pPinCode); - - err = QmiThreadSendQMI(pRequest, &pResponse); - qmi_rsp_check_and_return(); - - free(pResponse); - return 0; -} - -#ifdef CONFIG_IMSI_ICCID -int requestGetICCID(void) -{ // RIL_REQUEST_GET_IMSI - PQCQMIMSG pRequest; - PQCQMIMSG pResponse; - PQMUX_MSG pMUXMsg; - PQMIUIM_CONTENT pUimContent; - int err; - - pRequest = - ComposeQMUXMsg(QMUX_TYPE_UIM, QMIUIM_READ_TRANSPARENT_REQ, - UimReadTransparentIMSIReqSend, (void *)"EF_ICCID"); - err = QmiThreadSendQMI(pRequest, &pResponse); - - - qmi_rsp_check_and_return(); - - pUimContent = (PQMIUIM_CONTENT)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x11); - if (pUimContent != NULL) { - static char DeviceICCID[32] = {'\0'}; - int i = 0, j = 0; - - for (i = 0, j = 0; i < le16_to_cpu(pUimContent->content_len); ++i) { - char charmaps[] = "0123456789ABCDEF"; - - DeviceICCID[j++] = charmaps[(pUimContent->content[i] & 0x0F)]; - DeviceICCID[j++] = - charmaps[((pUimContent->content[i] & 0xF0) >> 0x04)]; - } - DeviceICCID[j] = '\0'; - - dbg_time("%s DeviceICCID: %s", __func__, DeviceICCID); - } - - free(pResponse); - return 0; -} - -int requestGetIMSI(void) -{ // RIL_REQUEST_GET_IMSI - PQCQMIMSG pRequest; - PQCQMIMSG pResponse; - PQMUX_MSG pMUXMsg; - PQMIUIM_CONTENT pUimContent; - int err; - - pRequest = - ComposeQMUXMsg(QMUX_TYPE_UIM, QMIUIM_READ_TRANSPARENT_REQ, - UimReadTransparentIMSIReqSend, (void *)"EF_IMSI"); - err = QmiThreadSendQMI(pRequest, &pResponse); - - - qmi_rsp_check_and_return(); - - pUimContent = (PQMIUIM_CONTENT)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x11); - if (pUimContent != NULL) { - static char DeviceIMSI[32] = {'\0'}; - int i = 0, j = 0; - - for (i = 0, j = 0; i < le16_to_cpu(pUimContent->content[0]); ++i) { - if (i != 0) - DeviceIMSI[j++] = (pUimContent->content[i + 1] & 0x0F) + '0'; - DeviceIMSI[j++] = - ((pUimContent->content[i + 1] & 0xF0) >> 0x04) + '0'; - } - DeviceIMSI[j] = '\0'; - - dbg_time("%s DeviceIMSI: %s", __func__, DeviceIMSI); - } - - free(pResponse); - return 0; -} -#endif -#endif - -static void fibo_convert_cdma_mcc_2_ascii_mcc(USHORT *p_mcc, USHORT mcc) -{ - unsigned int d1, d2, d3, buf = mcc + 111; - - if (mcc == 0x3FF) // wildcard - { - *p_mcc = 3; - } else { - d3 = buf % 10; - buf = (d3 == 0) ? (buf - 10) / 10 : buf / 10; - - d2 = buf % 10; - buf = (d2 == 0) ? (buf - 10) / 10 : buf / 10; - - d1 = (buf == 10) ? 0 : buf; - - // dbg_time("d1:%d, d2:%d,d3:%d",d1,d2,d3); - if (d1 < 10 && d2 < 10 && d3 < 10) { - *p_mcc = d1 * 100 + d2 * 10 + d3; - } else { - // dbg_time( "invalid digits %d %d %d", d1, d2, d3 ); - *p_mcc = 0; - } - } -} - -static void fibo_convert_cdma_mnc_2_ascii_mnc(USHORT *p_mnc, USHORT imsi_11_12) -{ - unsigned int d1, d2, buf = imsi_11_12 + 11; - - if (imsi_11_12 == 0x7F) // wildcard - { - *p_mnc = 7; - } else { - d2 = buf % 10; - buf = (d2 == 0) ? (buf - 10) / 10 : buf / 10; - - d1 = (buf == 10) ? 0 : buf; - - if (d1 < 10 && d2 < 10) { - *p_mnc = d1 * 10 + d2; - } else { - // dbg_time( "invalid digits %d %d", d1, d2, 0 ); - *p_mnc = 0; - } - } -} - -int requestGetHomeNetwork(USHORT *p_mcc, USHORT *p_mnc, USHORT *p_sid, - USHORT *p_nid) -{ - PQCQMIMSG pRequest; - PQCQMIMSG pResponse; - PQMUX_MSG pMUXMsg; - int err; - PHOME_NETWORK pHomeNetwork; - PHOME_NETWORK_SYSTEMID pHomeNetworkSystemID; - - pRequest = - ComposeQMUXMsg(QMUX_TYPE_NAS, QMINAS_GET_HOME_NETWORK_REQ, NULL, NULL); - err = QmiThreadSendQMI(pRequest, &pResponse); - qmi_rsp_check_and_return(); - - pHomeNetwork = (PHOME_NETWORK)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x01); - if (pHomeNetwork && p_mcc && p_mnc) { - *p_mcc = le16_to_cpu(pHomeNetwork->MobileCountryCode); - *p_mnc = le16_to_cpu(pHomeNetwork->MobileNetworkCode); - // dbg_time("%s MobileCountryCode: %d, MobileNetworkCode: %d", __func__, - // *pMobileCountryCode, *pMobileNetworkCode); - } - - pHomeNetworkSystemID = - (PHOME_NETWORK_SYSTEMID)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x10); - if (pHomeNetworkSystemID && p_sid && p_nid) { - *p_sid = le16_to_cpu( - pHomeNetworkSystemID->SystemID); // china-hefei: sid 14451 - *p_nid = le16_to_cpu(pHomeNetworkSystemID->NetworkID); - // dbg_time("%s SystemID: %d, NetworkID: %d", __func__, *pSystemID, - // *pNetworkID); - } - - free(pResponse); - - return 0; -} - -struct wwan_data_class_str class2str[] = { - {WWAN_DATA_CLASS_NONE, "UNKNOWN"}, - {WWAN_DATA_CLASS_GPRS, "GPRS"}, - {WWAN_DATA_CLASS_EDGE, "EDGE"}, - {WWAN_DATA_CLASS_UMTS, "UMTS"}, - {WWAN_DATA_CLASS_HSDPA, "HSDPA"}, - {WWAN_DATA_CLASS_HSUPA, "HSUPA"}, - {WWAN_DATA_CLASS_LTE, "LTE"}, - {WWAN_DATA_CLASS_1XRTT, "1XRTT"}, - {WWAN_DATA_CLASS_1XEVDO, "1XEVDO"}, - {WWAN_DATA_CLASS_1XEVDO_REVA, "1XEVDO_REVA"}, - {WWAN_DATA_CLASS_1XEVDV, "1XEVDV"}, - {WWAN_DATA_CLASS_3XRTT, "3XRTT"}, - {WWAN_DATA_CLASS_1XEVDO_REVB, "1XEVDO_REVB"}, - {WWAN_DATA_CLASS_UMB, "UMB"}, - {WWAN_DATA_CLASS_CUSTOM, "CUSTOM"}, -//begin modified by zhangkaibo add 5G network detect feature on x55 platform. 20200605 - {WWAN_DATA_CLASS_5G, "NR5G"}, -//end modified by zhangkaibo add 5G network detect feature on x55 platform. 20200605 -}; - -CHAR *wwan_data_class2str(ULONG class) -{ - unsigned int i = 0; - for (i = 0; i < sizeof(class2str) / sizeof(class2str[0]); i++) { - if (class2str[i].class == class) { - return class2str[i].str; - } - } - return "UNKNOWN"; -} - -int requestRegistrationState2(UCHAR *pPSAttachedState) -{ - PQCQMIMSG pRequest; - PQCQMIMSG pResponse; - PQMUX_MSG pMUXMsg; - int err; - USHORT MobileCountryCode = 0; - USHORT MobileNetworkCode = 0; - const char *pDataCapStr = "UNKNOW"; - LONG remainingLen; - PSERVICE_STATUS_INFO pServiceStatusInfo; - int is_lte = 0; - PCDMA_SYSTEM_INFO pCdmaSystemInfo; - PHDR_SYSTEM_INFO pHdrSystemInfo; - PGSM_SYSTEM_INFO pGsmSystemInfo; - PWCDMA_SYSTEM_INFO pWcdmaSystemInfo; - PLTE_SYSTEM_INFO pLteSystemInfo; -//begin modified by zhangkaibo add 5G network detect feature on x55 platform. 20200605 - PNR5G_SYSTEM_INFO pNr5gSystemInfo; -//end modified by zhangkaibo add 5G network detect feature on x55 platform. 20200605 - PTDSCDMA_SYSTEM_INFO pTdscdmaSystemInfo; - UCHAR DeviceClass = 0; - ULONG DataCapList = 0; - - *pPSAttachedState = 0; - pRequest = - ComposeQMUXMsg(QMUX_TYPE_NAS, QMINAS_GET_SYS_INFO_REQ, NULL, NULL); - err = QmiThreadSendQMI(pRequest, &pResponse); - qmi_rsp_check_and_return(); - - pServiceStatusInfo = (PSERVICE_STATUS_INFO)( - ((PCHAR)&pMUXMsg->GetSysInfoResp) + QCQMUX_MSG_HDR_SIZE); - remainingLen = le16_to_cpu(pMUXMsg->GetSysInfoResp.Length); - - s_is_cdma = 0; - s_hdr_personality = 0; - while (remainingLen > 0) { - switch (pServiceStatusInfo->TLVType) { - case 0x10: // CDMA - if (pServiceStatusInfo->SrvStatus == 0x02) { - DataCapList = WWAN_DATA_CLASS_1XRTT | WWAN_DATA_CLASS_1XEVDO | - WWAN_DATA_CLASS_1XEVDO_REVA | - WWAN_DATA_CLASS_1XEVDV | - WWAN_DATA_CLASS_1XEVDO_REVB; - DeviceClass = DEVICE_CLASS_CDMA; - s_is_cdma = (0 == is_lte); - } - break; - case 0x11: // HDR - if (pServiceStatusInfo->SrvStatus == 0x02) { - DataCapList = WWAN_DATA_CLASS_3XRTT | WWAN_DATA_CLASS_UMB; - DeviceClass = DEVICE_CLASS_CDMA; - s_is_cdma = (0 == is_lte); - } - break; - case 0x12: // GSM - if (pServiceStatusInfo->SrvStatus == 0x02) { - DataCapList = WWAN_DATA_CLASS_GPRS | WWAN_DATA_CLASS_EDGE; - DeviceClass = DEVICE_CLASS_GSM; - } - break; - case 0x13: // WCDMA - if (pServiceStatusInfo->SrvStatus == 0x02) { - DataCapList = WWAN_DATA_CLASS_UMTS; - DeviceClass = DEVICE_CLASS_GSM; - } - break; -//begin modified by zhangkaibo add 5G network detect feature on x55 platform. 20200605 - case 0x4A: // NR5G - if (pServiceStatusInfo->SrvStatus == 0x02) { - DataCapList = WWAN_DATA_CLASS_5G; - DeviceClass = DEVICE_CLASS_GSM; - is_lte = 1; - s_is_cdma = 0; - } - break; -//end modified by zhangkaibo add 5G network detect feature on x55 platform. 20200605 - case 0x14: // LTE - if (pServiceStatusInfo->SrvStatus == 0x02) { - DataCapList = WWAN_DATA_CLASS_LTE; - DeviceClass = DEVICE_CLASS_GSM; - is_lte = 1; - s_is_cdma = 0; - } - break; - case 0x24: // TDSCDMA - if (pServiceStatusInfo->SrvStatus == 0x02) { - pDataCapStr = "TD-SCDMA"; - } - break; - case 0x15: // CDMA - // CDMA_SYSTEM_INFO - pCdmaSystemInfo = (PCDMA_SYSTEM_INFO)pServiceStatusInfo; - if (pCdmaSystemInfo->SrvDomainValid == 0x01) { - *pPSAttachedState = 0; - if (pCdmaSystemInfo->SrvDomain & 0x02) { - *pPSAttachedState = 1; - s_is_cdma = (0 == is_lte); - } - } -#if 0 - if (pCdmaSystemInfo->SrvCapabilityValid == 0x01) { - *pPSAttachedState = 0; - if (pCdmaSystemInfo->SrvCapability & 0x02) { - *pPSAttachedState = 1; - s_is_cdma = (0 == is_lte); - } - } -#endif - if (pCdmaSystemInfo->NetworkIdValid == 0x01) { - int i; - CHAR temp[10]; - strncpy(temp, (CHAR *)pCdmaSystemInfo->MCC, 3); - temp[3] = '\0'; - for (i = 0; i < 4; i++) { - if ((UCHAR)temp[i] == 0xFF) { - temp[i] = '\0'; - } - } - MobileCountryCode = (USHORT)atoi(temp); - - strncpy(temp, (CHAR *)pCdmaSystemInfo->MNC, 3); - temp[3] = '\0'; - for (i = 0; i < 4; i++) { - if ((UCHAR)temp[i] == 0xFF) { - temp[i] = '\0'; - } - } - MobileNetworkCode = (USHORT)atoi(temp); - } - break; - case 0x16: // HDR - // HDR_SYSTEM_INFO - pHdrSystemInfo = (PHDR_SYSTEM_INFO)pServiceStatusInfo; - if (pHdrSystemInfo->SrvDomainValid == 0x01) { - *pPSAttachedState = 0; - if (pHdrSystemInfo->SrvDomain & 0x02) { - *pPSAttachedState = 1; - s_is_cdma = (0 == is_lte); - } - } -#if 0 - if (pHdrSystemInfo->SrvCapabilityValid == 0x01) { - *pPSAttachedState = 0; - if (pHdrSystemInfo->SrvCapability & 0x02) { - *pPSAttachedState = 1; - s_is_cdma = (0 == is_lte); - } - } -#endif - if (*pPSAttachedState && - pHdrSystemInfo->HdrPersonalityValid == 0x01) { - if (pHdrSystemInfo->HdrPersonality == 0x03) - s_hdr_personality = 0x02; - // else if (pHdrSystemInfo->HdrPersonality == 0x02) - // s_hdr_personality = 0x01; - } - USHORT cmda_mcc = 0, cdma_mnc = 0; - if (!requestGetHomeNetwork(&cmda_mcc, &cdma_mnc, NULL, NULL) && - cmda_mcc) { - fibo_convert_cdma_mcc_2_ascii_mcc(&MobileCountryCode, cmda_mcc); - fibo_convert_cdma_mnc_2_ascii_mnc(&MobileNetworkCode, cdma_mnc); - } - break; - case 0x17: // GSM - // GSM_SYSTEM_INFO - pGsmSystemInfo = (PGSM_SYSTEM_INFO)pServiceStatusInfo; - if (pGsmSystemInfo->SrvDomainValid == 0x01) { - *pPSAttachedState = 0; - if (pGsmSystemInfo->SrvDomain & 0x02) { - *pPSAttachedState = 1; - } - } -#if 0 - if (pGsmSystemInfo->SrvCapabilityValid == 0x01) { - *pPSAttachedState = 0; - if (pGsmSystemInfo->SrvCapability & 0x02) { - *pPSAttachedState = 1; - } - } -#endif - if (pGsmSystemInfo->NetworkIdValid == 0x01) { - int i; - CHAR temp[10]; - strncpy(temp, (CHAR *)pGsmSystemInfo->MCC, 3); - temp[3] = '\0'; - for (i = 0; i < 4; i++) { - if ((UCHAR)temp[i] == 0xFF) { - temp[i] = '\0'; - } - } - MobileCountryCode = (USHORT)atoi(temp); - - strncpy(temp, (CHAR *)pGsmSystemInfo->MNC, 3); - temp[3] = '\0'; - for (i = 0; i < 4; i++) { - if ((UCHAR)temp[i] == 0xFF) { - temp[i] = '\0'; - } - } - MobileNetworkCode = (USHORT)atoi(temp); - } - break; - case 0x18: // WCDMA - // WCDMA_SYSTEM_INFO - pWcdmaSystemInfo = (PWCDMA_SYSTEM_INFO)pServiceStatusInfo; - if (pWcdmaSystemInfo->SrvDomainValid == 0x01) { - *pPSAttachedState = 0; - if (pWcdmaSystemInfo->SrvDomain & 0x02) { - *pPSAttachedState = 1; - } - } -#if 0 - if (pWcdmaSystemInfo->SrvCapabilityValid == 0x01) { - *pPSAttachedState = 0; - if (pWcdmaSystemInfo->SrvCapability & 0x02) { - *pPSAttachedState = 1; - } - } -#endif - if (pWcdmaSystemInfo->NetworkIdValid == 0x01) { - int i; - CHAR temp[10]; - strncpy(temp, (CHAR *)pWcdmaSystemInfo->MCC, 3); - temp[3] = '\0'; - for (i = 0; i < 4; i++) { - if ((UCHAR)temp[i] == 0xFF) { - temp[i] = '\0'; - } - } - MobileCountryCode = (USHORT)atoi(temp); - - strncpy(temp, (CHAR *)pWcdmaSystemInfo->MNC, 3); - temp[3] = '\0'; - for (i = 0; i < 4; i++) { - if ((UCHAR)temp[i] == 0xFF) { - temp[i] = '\0'; - } - } - MobileNetworkCode = (USHORT)atoi(temp); - } - break; - case 0x19: // LTE_SYSTEM_INFO - // LTE_SYSTEM_INFO - pLteSystemInfo = (PLTE_SYSTEM_INFO)pServiceStatusInfo; - if (pLteSystemInfo->SrvDomainValid == 0x01) { - *pPSAttachedState = 0; - if (pLteSystemInfo->SrvDomain & 0x02) { - *pPSAttachedState = 1; - is_lte = 1; - s_is_cdma = 0; - } - } -#if 0 - if (pLteSystemInfo->SrvCapabilityValid == 0x01) { - *pPSAttachedState = 0; - if (pLteSystemInfo->SrvCapability & 0x02) { - *pPSAttachedState = 1; - is_lte = 1; - s_is_cdma = 0; - } - } -#endif - if (pLteSystemInfo->NetworkIdValid == 0x01) { - int i; - CHAR temp[10]; - strncpy(temp, (CHAR *)pLteSystemInfo->MCC, 3); - temp[3] = '\0'; - for (i = 0; i < 4; i++) { - if ((UCHAR)temp[i] == 0xFF) { - temp[i] = '\0'; - } - } - MobileCountryCode = (USHORT)atoi(temp); - - strncpy(temp, (CHAR *)pLteSystemInfo->MNC, 3); - temp[3] = '\0'; - for (i = 0; i < 4; i++) { - if ((UCHAR)temp[i] == 0xFF) { - temp[i] = '\0'; - } - } - MobileNetworkCode = (USHORT)atoi(temp); - } - break; -//begin modified by zhangkaibo add 5G network detect feature on x55 platform. 20200605 - case 0x4b: // NR5G_SYSTEM_INFO - // NR5G_SYSTEM_INFO - pNr5gSystemInfo = (PNR5G_SYSTEM_INFO)pServiceStatusInfo; - if (pNr5gSystemInfo->SrvDomainValid == 0x01) { - *pPSAttachedState = 0; - if (pNr5gSystemInfo->SrvDomain & 0x02) { - *pPSAttachedState = 1; - is_lte = 1; - s_is_cdma = 0; - } - } - - if (pNr5gSystemInfo->NetworkIdValid == 0x01) { - int i; - CHAR temp[10]; - strncpy(temp, (CHAR *)pNr5gSystemInfo->MCC, 3); - temp[3] = '\0'; - for (i = 0; i < 4; i++) { - if ((UCHAR)temp[i] == 0xFF) { - temp[i] = '\0'; - } - } - MobileCountryCode = (USHORT)atoi(temp); - - strncpy(temp, (CHAR *)pNr5gSystemInfo->MNC, 3); - temp[3] = '\0'; - for (i = 0; i < 4; i++) { - if ((UCHAR)temp[i] == 0xFF) { - temp[i] = '\0'; - } - } - MobileNetworkCode = (USHORT)atoi(temp); - } - break; -//end modified by zhangkaibo add 5G network detect feature on x55 platform. 20200605 - case 0x25: // TDSCDMA - // TDSCDMA_SYSTEM_INFO - pTdscdmaSystemInfo = (PTDSCDMA_SYSTEM_INFO)pServiceStatusInfo; - if (pTdscdmaSystemInfo->SrvDomainValid == 0x01) { - *pPSAttachedState = 0; - if (pTdscdmaSystemInfo->SrvDomain & 0x02) { - *pPSAttachedState = 1; - } - } -#if 0 - if (pTdscdmaSystemInfo->SrvCapabilityValid == 0x01) { - *pPSAttachedState = 0; - if (pTdscdmaSystemInfo->SrvCapability & 0x02) { - *pPSAttachedState = 1; - } - } -#endif - if (pTdscdmaSystemInfo->NetworkIdValid == 0x01) { - int i; - CHAR temp[10]; - strncpy(temp, (CHAR *)pTdscdmaSystemInfo->MCC, 3); - temp[3] = '\0'; - for (i = 0; i < 4; i++) { - if ((UCHAR)temp[i] == 0xFF) { - temp[i] = '\0'; - } - } - MobileCountryCode = (USHORT)atoi(temp); - - strncpy(temp, (CHAR *)pTdscdmaSystemInfo->MNC, 3); - temp[3] = '\0'; - for (i = 0; i < 4; i++) { - if ((UCHAR)temp[i] == 0xFF) { - temp[i] = '\0'; - } - } - MobileNetworkCode = (USHORT)atoi(temp); - } - break; - default: - break; - } /* switch (pServiceStatusInfo->TLYType) */ - remainingLen -= (le16_to_cpu(pServiceStatusInfo->TLVLength) + 3); - pServiceStatusInfo = (PSERVICE_STATUS_INFO)( - (PCHAR)&pServiceStatusInfo->TLVLength + - le16_to_cpu(pServiceStatusInfo->TLVLength) + sizeof(USHORT)); - } /* while (remainingLen > 0) */ - - if (DeviceClass == DEVICE_CLASS_CDMA) { - if (s_hdr_personality == 2) { - pDataCapStr = s_hdr_personality == 2 ? "eHRPD" : "HRPD"; - } else if (DataCapList & WWAN_DATA_CLASS_1XEVDO_REVB) { - pDataCapStr = wwan_data_class2str(WWAN_DATA_CLASS_1XEVDO_REVB); - } else if (DataCapList & WWAN_DATA_CLASS_1XEVDO_REVA) { - pDataCapStr = wwan_data_class2str(WWAN_DATA_CLASS_1XEVDO_REVA); - } else if (DataCapList & WWAN_DATA_CLASS_1XEVDO) { - pDataCapStr = wwan_data_class2str(WWAN_DATA_CLASS_1XEVDO); - } else if (DataCapList & WWAN_DATA_CLASS_1XRTT) { - pDataCapStr = wwan_data_class2str(WWAN_DATA_CLASS_1XRTT); - } else if (DataCapList & WWAN_DATA_CLASS_3XRTT) { - pDataCapStr = wwan_data_class2str(WWAN_DATA_CLASS_3XRTT); - } else if (DataCapList & WWAN_DATA_CLASS_UMB) { - pDataCapStr = wwan_data_class2str(WWAN_DATA_CLASS_UMB); - } - } else { - if (DataCapList & WWAN_DATA_CLASS_LTE) { - pDataCapStr = wwan_data_class2str(WWAN_DATA_CLASS_LTE); - } else if ((DataCapList & WWAN_DATA_CLASS_HSDPA) && - (DataCapList & WWAN_DATA_CLASS_HSUPA)) { - pDataCapStr = "HSDPA_HSUPA"; - } else if (DataCapList & WWAN_DATA_CLASS_HSDPA) { - pDataCapStr = wwan_data_class2str(WWAN_DATA_CLASS_HSDPA); - } else if (DataCapList & WWAN_DATA_CLASS_HSUPA) { - pDataCapStr = wwan_data_class2str(WWAN_DATA_CLASS_HSUPA); - } else if (DataCapList & WWAN_DATA_CLASS_UMTS) { - pDataCapStr = wwan_data_class2str(WWAN_DATA_CLASS_UMTS); - } else if (DataCapList & WWAN_DATA_CLASS_EDGE) { - pDataCapStr = wwan_data_class2str(WWAN_DATA_CLASS_EDGE); - } else if (DataCapList & WWAN_DATA_CLASS_GPRS) { - pDataCapStr = wwan_data_class2str(WWAN_DATA_CLASS_GPRS); -//begin modified by zhangkaibo add 5G network detect feature on x55 platform. 20200605 - } else if (DataCapList & WWAN_DATA_CLASS_5G) { - pDataCapStr = wwan_data_class2str(WWAN_DATA_CLASS_5G); -//end modified by zhangkaibo add 5G network detect feature on x55 platform. 20200605 - } - } - g_MobileCountryCode = MobileCountryCode; - g_MobileNetworkCode = MobileNetworkCode; - dbg_time("%s MCC: %d, MNC: %d, PS: %s, DataCap: %s", __func__, - MobileCountryCode, MobileNetworkCode, - (*pPSAttachedState == 1) ? "Attached" : "Detached", pDataCapStr); - - free(pResponse); - - return 0; -} - -int requestRegistrationState(UCHAR *pPSAttachedState) -{ - PQCQMIMSG pRequest; - PQCQMIMSG pResponse; - PQMUX_MSG pMUXMsg; - int err; - PQMINAS_CURRENT_PLMN_MSG pCurrentPlmn; - PSERVING_SYSTEM pServingSystem; - PQMINAS_DATA_CAP pDataCap; - USHORT MobileCountryCode = 0; - USHORT MobileNetworkCode = 0; - const char *pDataCapStr = "UNKNOW"; -//begin modified by zhangkaibo add 5G network detect feature on x55 platform. 20200605 - /* - for 9x07 later, QMINAS_GET_SERVING_SYSTEM_REQ has been declara as Deprecated - so sdx55 NR5G register info can not get by QMINAS_GET_SERVING_SYSTEM_REQ. - coninue use QMINAS_GET_SERVING_SYSTEM_REQ, fibocom-dial will show network as UNKNOWN - */ - //begin modified by zhaofei delete incorrect registration interface on x55/x24 platform. 20200603 -// #if 0 -// if (s_9x07) { -//eturn requestRegistrationState2(pPSAttachedState); -// } -// #endif - //end modified by zhaofei delete incorrect registration interface on x55/x24 platform.20200603 -//begin modified by zhangkaibo add 5G network detect feature on x55 platform. 20200605 - pRequest = ComposeQMUXMsg(QMUX_TYPE_NAS, QMINAS_GET_SERVING_SYSTEM_REQ, - NULL, NULL); - err = QmiThreadSendQMI(pRequest, &pResponse); - qmi_rsp_check_and_return(); - - pCurrentPlmn = - (PQMINAS_CURRENT_PLMN_MSG)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x12); - if (pCurrentPlmn) { - MobileCountryCode = le16_to_cpu(pCurrentPlmn->MobileCountryCode); - MobileNetworkCode = le16_to_cpu(pCurrentPlmn->MobileNetworkCode); - } - - *pPSAttachedState = 0; - pServingSystem = - (PSERVING_SYSTEM)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x01); - if (pServingSystem) { - // Packet-switched domain attach state of the mobile. - // 0x00 PS_UNKNOWN ?Unknown or not applicable - // 0x01 PS_ATTACHED ?Attached - // 0x02 PS_DETACHED ?Detached - *pPSAttachedState = pServingSystem->RegistrationState; - if (pServingSystem->RegistrationState == - 0x01) // 0x01 ?C REGISTERED ?C Registered with a network - *pPSAttachedState = pServingSystem->PSAttachedState; - else { - // MobileCountryCode = MobileNetworkCode = 0; - *pPSAttachedState = 0x02; - } - } - - pDataCap = (PQMINAS_DATA_CAP)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x11); - if (pDataCap && pDataCap->DataCapListLen) { - UCHAR *DataCap = &pDataCap->DataCap; - if (pDataCap->DataCapListLen == 2) { - if ((DataCap[0] == 0x06) && - ((DataCap[1] == 0x08) || (DataCap[1] == 0x0A))) - DataCap[0] = DataCap[1]; - } - switch (DataCap[0]) { - case 0x01: - pDataCapStr = "GPRS"; - break; - case 0x02: - pDataCapStr = "EDGE"; - break; - case 0x03: - pDataCapStr = "HSDPA"; - break; - case 0x04: - pDataCapStr = "HSUPA"; - break; - case 0x05: - pDataCapStr = "UMTS"; - break; - case 0x06: - pDataCapStr = "1XRTT"; - break; - case 0x07: - pDataCapStr = "1XEVDO"; - break; - case 0x08: - pDataCapStr = "1XEVDO_REVA"; - break; - case 0x09: - pDataCapStr = "GPRS"; - break; - case 0x0A: - pDataCapStr = "1XEVDO_REVB"; - break; - case 0x0B: - pDataCapStr = "LTE"; - break; - case 0x0C: - pDataCapStr = "HSDPA"; - break; - case 0x0D: - pDataCapStr = "HSDPA"; - break; - default: - pDataCapStr = "UNKNOW"; - break; - } - } - - if (pServingSystem && pServingSystem->RegistrationState == 0x01 && - pServingSystem->InUseRadioIF && pServingSystem->RadioIF == 0x09) { - pDataCapStr = "TD-SCDMA"; - } - - s_is_cdma = 0; - if (pServingSystem && pServingSystem->RegistrationState == 0x01 && - pServingSystem->InUseRadioIF && - (pServingSystem->RadioIF == 0x01 || pServingSystem->RadioIF == 0x02)) { - USHORT cmda_mcc = 0, cdma_mnc = 0; - s_is_cdma = 1; - if (!requestGetHomeNetwork(&cmda_mcc, &cdma_mnc, NULL, NULL) && - cmda_mcc) { - fibo_convert_cdma_mcc_2_ascii_mcc(&MobileCountryCode, cmda_mcc); - fibo_convert_cdma_mnc_2_ascii_mnc(&MobileNetworkCode, cdma_mnc); - } - if (1) { - PQCQMUX_TLV pTLV = - (PQCQMUX_TLV)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x23); - if (pTLV) - s_hdr_personality = pTLV->Value; - else - s_hdr_personality = 0; - if (s_hdr_personality == 2) - pDataCapStr = "eHRPD"; - } - } - - dbg_time("%s MCC: %d, MNC: %d, PS: %s, DataCap: %s", __func__, - MobileCountryCode, MobileNetworkCode, - (*pPSAttachedState == 1) ? "Attached" : "Detached", pDataCapStr); - - free(pResponse); - - return 0; -} - -int requestQueryDataCall(UCHAR *pConnectionStatus, int curIpFamily) -{ - PQCQMIMSG pRequest; - PQCQMIMSG pResponse; - PQMUX_MSG pMUXMsg; - int err; - PQMIWDS_PKT_SRVC_TLV pPktSrvc; - UCHAR oldConnectionStatus = *pConnectionStatus; - UCHAR QMIType = - (curIpFamily == IpFamilyV4) ? QMUX_TYPE_WDS : QMUX_TYPE_WDS_IPV6; - - pRequest = - ComposeQMUXMsg(QMIType, QMIWDS_GET_PKT_SRVC_STATUS_REQ, NULL, NULL); - err = QmiThreadSendQMI(pRequest, &pResponse); - qmi_rsp_check_and_return(); - - *pConnectionStatus = QWDS_PKT_DATA_DISCONNECTED; - pPktSrvc = - (PQMIWDS_PKT_SRVC_TLV)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x01); - if (pPktSrvc) { - *pConnectionStatus = pPktSrvc->ConnectionStatus; - if ((le16_to_cpu(pPktSrvc->TLVLength) == 2) && - (pPktSrvc->ReconfigReqd == 0x01)) - *pConnectionStatus = QWDS_PKT_DATA_DISCONNECTED; - } - - if (*pConnectionStatus == QWDS_PKT_DATA_DISCONNECTED) { - if (curIpFamily == IpFamilyV4) - WdsConnectionIPv4Handle = 0; - else - WdsConnectionIPv6Handle = 0; - } - - if (oldConnectionStatus != *pConnectionStatus || debug_qmi) { - dbg_time("%s %sConnectionStatus: %s", __func__, - (curIpFamily == IpFamilyV4) ? "IPv4" : "IPv6", - (*pConnectionStatus == QWDS_PKT_DATA_CONNECTED) - ? "CONNECTED" - : "DISCONNECTED"); - } - - free(pResponse); - return 0; -} - -int requestSetupDataCall(PROFILE_T *profile, int curIpFamily) -{ - PQCQMIMSG pRequest; - PQCQMIMSG pResponse; - PQMUX_MSG pMUXMsg; - int err = 0; - UCHAR QMIType = - (curIpFamily == IpFamilyV4) ? QMUX_TYPE_WDS : QMUX_TYPE_WDS_IPV6; - - // DualIPSupported means can get ipv4 & ipv6 address at the same time, one - // wds for ipv4, the other wds for ipv6 - profile->curIpFamily = curIpFamily; - pRequest = ComposeQMUXMsg(QMIType, QMIWDS_START_NETWORK_INTERFACE_REQ, - WdsStartNwInterfaceReq, profile); - err = QmiThreadSendQMITimeout(pRequest, &pResponse, 120 * 1000); - qmi_rsp_check(); - - if (le16_to_cpu(pMUXMsg->QMUXMsgHdrResp.QMUXResult) || - le16_to_cpu(pMUXMsg->QMUXMsgHdrResp.QMUXError)) { - PQMI_TLV_HDR pTLVHdr; - - pTLVHdr = GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x10); - if (pTLVHdr) { - uint16_t *data16 = (uint16_t *)(pTLVHdr + 1); - uint16_t call_end_reason = le16_to_cpu(data16[0]); - dbg_time("call_end_reason is %d", call_end_reason); - } - - pTLVHdr = GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x11); - if (pTLVHdr) { - uint16_t *data16 = (uint16_t *)(pTLVHdr + 1); - uint16_t call_end_reason_type = le16_to_cpu(data16[0]); - uint16_t verbose_call_end_reason = le16_to_cpu(data16[1]); - - dbg_time("call_end_reason_type is %d", call_end_reason_type); - dbg_time("call_end_reason_verbose is %d", verbose_call_end_reason); - } - - free(pResponse); - return le16_to_cpu(pMUXMsg->QMUXMsgHdrResp.QMUXError); - } - - if (curIpFamily == IpFamilyV4) { - WdsConnectionIPv4Handle = - le32_to_cpu(pResponse->MUXMsg.StartNwInterfaceResp.Handle); - dbg_time("%s WdsConnectionIPv4Handle: 0x%08x", __func__, - WdsConnectionIPv4Handle); - } else { - WdsConnectionIPv6Handle = - le32_to_cpu(pResponse->MUXMsg.StartNwInterfaceResp.Handle); - dbg_time("%s WdsConnectionIPv6Handle: 0x%08x", __func__, - WdsConnectionIPv6Handle); - } - - free(pResponse); - - return 0; -} - -int requestDeactivateDefaultPDP(PROFILE_T *profile, int curIpFamily) -{ - PQCQMIMSG pRequest; - PQCQMIMSG pResponse; - PQMUX_MSG pMUXMsg; - int err; - UCHAR QMIType = (curIpFamily == 0x04) ? QMUX_TYPE_WDS : QMUX_TYPE_WDS_IPV6; - - if (curIpFamily == IpFamilyV4 && WdsConnectionIPv4Handle == 0) - return 0; - if (curIpFamily == IpFamilyV6 && WdsConnectionIPv6Handle == 0) - return 0; - - pRequest = ComposeQMUXMsg(QMIType, QMIWDS_STOP_NETWORK_INTERFACE_REQ, - WdsStopNwInterfaceReq, &curIpFamily); - err = QmiThreadSendQMI(pRequest, &pResponse); - qmi_rsp_check_and_return(); - - if (curIpFamily == IpFamilyV4) - WdsConnectionIPv4Handle = 0; - else - WdsConnectionIPv6Handle = 0; - free(pResponse); - return 0; -} - -int requestGetIPAddress(PROFILE_T *profile, int curIpFamily) -{ - PQCQMIMSG pRequest; - PQCQMIMSG pResponse; - PQMUX_MSG pMUXMsg; - int err; - PQMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV4_ADDR pIpv4Addr; - PQMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV6_ADDR pIpv6Addr = NULL; - PQMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV6_DNS_ADDR pIpv6DNSAddr = NULL; - PQMIWDS_GET_RUNTIME_SETTINGS_TLV_MTU pMtu; - IPV4_T *pIpv4 = &profile->ipv4; - IPV6_T *pIpv6 = &profile->ipv6; - UCHAR QMIType = (curIpFamily == 0x04) ? QMUX_TYPE_WDS : QMUX_TYPE_WDS_IPV6; - - if (curIpFamily == IpFamilyV4) { - memset(pIpv4, 0x00, sizeof(IPV4_T)); - if (WdsConnectionIPv4Handle == 0) - return 0; - } else if (curIpFamily == IpFamilyV6) { - memset(pIpv6, 0x00, sizeof(IPV6_T)); - if (WdsConnectionIPv6Handle == 0) - return 0; - } - - pRequest = ComposeQMUXMsg(QMIType, QMIWDS_GET_RUNTIME_SETTINGS_REQ, - WdsGetRuntimeSettingReq, NULL); - err = QmiThreadSendQMI(pRequest, &pResponse); - qmi_rsp_check_and_return(); - - pIpv4Addr = (PQMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV4_ADDR)GetTLV( - &pResponse->MUXMsg.QMUXMsgHdr, - QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV4PRIMARYDNS); - if (pIpv4Addr) { - pIpv4->DnsPrimary = pIpv4Addr->IPV4Address; - } - - pIpv4Addr = (PQMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV4_ADDR)GetTLV( - &pResponse->MUXMsg.QMUXMsgHdr, - QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV4SECONDARYDNS); - if (pIpv4Addr) { - pIpv4->DnsSecondary = pIpv4Addr->IPV4Address; - } - - pIpv4Addr = (PQMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV4_ADDR)GetTLV( - &pResponse->MUXMsg.QMUXMsgHdr, - QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV4GATEWAY); - if (pIpv4Addr) { - pIpv4->Gateway = pIpv4Addr->IPV4Address; - } - - pIpv4Addr = (PQMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV4_ADDR)GetTLV( - &pResponse->MUXMsg.QMUXMsgHdr, - QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV4SUBNET); - if (pIpv4Addr) { - pIpv4->SubnetMask = pIpv4Addr->IPV4Address; - } - - pIpv4Addr = (PQMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV4_ADDR)GetTLV( - &pResponse->MUXMsg.QMUXMsgHdr, - QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV4); - if (pIpv4Addr) { - pIpv4->Address = pIpv4Addr->IPV4Address; - } - - pIpv6DNSAddr = (PQMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV6_DNS_ADDR)GetTLV( - &pResponse->MUXMsg.QMUXMsgHdr, - QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV6PRIMARYDNS); - if (pIpv6DNSAddr) { - memcpy(pIpv6->DnsPrimary, pIpv6DNSAddr->IPV6Address, 16); - } - - pIpv6DNSAddr = (PQMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV6_DNS_ADDR)GetTLV( - &pResponse->MUXMsg.QMUXMsgHdr, - QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV6SECONDARYDNS); - if (pIpv6DNSAddr) { - memcpy(pIpv6->DnsSecondary, pIpv6DNSAddr->IPV6Address, 16); - } - -//2021-02-25 willa.liu@fibocom.com changed begin for support eipd SN-20210129001 - -/* - pIpv6Addr = (PQMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV6_ADDR)GetTLV( - &pResponse->MUXMsg.QMUXMsgHdr, - QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV6GATEWAY); - if(pIpv6Addr) { - memcpy(pIpv6->Gateway, pIpv6Addr->IPV6Address, 16); - pIpv6->PrefixLengthGateway = pIpv6Addr->PrefixLength; - } -*/ - - if(profile->ipv6_prigateway_flag == 1) - { - char localip6gateway[1024] = {0}; - get_private_gateway(localip6gateway); - int length = sizeof(localip6gateway)/sizeof(localip6gateway[0]); - if (pIpv6Addr) - { - int i = 0; - char *token = strtok(localip6gateway, "."); - while(token != NULL) - { - pIpv6->Gateway[i++] = atoi(token); - //printf("token:%s, pIpv6->Gateway[%d]:%d\n", token, i-1, pIpv6->Gateway[i-1]); - token = strtok(NULL, "."); - } - pIpv6->PrefixLengthGateway = 16; - } - } - else - { - pIpv6Addr = (PQMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV6_ADDR)GetTLV( - &pResponse->MUXMsg.QMUXMsgHdr, - QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV6GATEWAY); - if(pIpv6Addr) - { - memcpy(pIpv6->Gateway, pIpv6Addr->IPV6Address, 16); - pIpv6->PrefixLengthGateway = pIpv6Addr->PrefixLength; - } - } -//2021-02-25 willa.liu@fibocom.com changed end for support eipd SN-20210129001 - - - pIpv6Addr = (PQMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV6_ADDR)GetTLV( - &pResponse->MUXMsg.QMUXMsgHdr, - QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV6); - if (pIpv6Addr) { - memcpy(pIpv6->Address, pIpv6Addr->IPV6Address, 16); - pIpv6->PrefixLengthIPAddr = pIpv6Addr->PrefixLength; - } - - pMtu = (PQMIWDS_GET_RUNTIME_SETTINGS_TLV_MTU)GetTLV( - &pResponse->MUXMsg.QMUXMsgHdr, - QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_MTU); - if (pMtu) { - pIpv4->Mtu = pIpv6->Mtu = le32_to_cpu(pMtu->Mtu); - } - - free(pResponse); - return 0; -} - -#ifdef CONFIG_APN -int requestSetProfile(PROFILE_T *profile) -{ - PQCQMIMSG pRequest; - PQCQMIMSG pResponse; - PQMUX_MSG pMUXMsg; - int err; - - if (!profile->pdp) - return 0; - - dbg_time("%s[%d] %s/%s/%s/%d", __func__, profile->pdpindex, profile->apn, - profile->user, profile->password, profile->auth); - - UCHAR QMIType = (profile->ipv4_flag) ? QMUX_TYPE_WDS : QMUX_TYPE_WDS_IPV6; - pRequest = ComposeQMUXMsg(QMIType, QMIWDS_MODIFY_PROFILE_SETTINGS_REQ, - WdsModifyProfileSettingsReq, profile); - err = QmiThreadSendQMI(pRequest, &pResponse); -//begin modified by zhangkaibo add create profile qmi. mantis 0049137,0048741 20200610 - //modify profile no check return value, try create - qmi_rsp_check(); - if(le16_to_cpu(pMUXMsg->QMUXMsgHdrResp.QMUXError)) - { - pRequest = ComposeQMUXMsg(QMIType, QMIWDS_CREATE_PROFILE_SETTINGS_REQ, - WdsCreateProfileSettingsReq, profile); - err = QmiThreadSendQMI(pRequest, &pResponse); - qmi_rsp_check(); - if(le16_to_cpu(pMUXMsg->QMUXMsgHdrResp.QMUXError)){ - free(pResponse); - return -1; - } - dbg_time("WdsCreateProfileSettingsReq[%d] %s/%s/%s/%d", profile->pdpindex, profile->apn, - profile->user, profile->password, profile->auth); - } -//end modified by zhangkaibo add create profile qmi. mantis 0049137,0048741 20200610 - free(pResponse); - return 0; -} - -int requestGetProfile(PROFILE_T *profile) -{ - PQCQMIMSG pRequest; - PQCQMIMSG pResponse; - PQMUX_MSG pMUXMsg; - int err; - char *apn = NULL; - char *user = NULL; - char *password = NULL; - int auth = 0; - PQMIWDS_APNNAME pApnName; - PQMIWDS_USERNAME pUserName; - PQMIWDS_PASSWD pPassWd; - PQMIWDS_AUTH_PREFERENCE pAuthPref; - - if (!profile->pdp) - return 0; - - UCHAR QMIType = (profile->ipv4_flag) ? QMUX_TYPE_WDS : QMUX_TYPE_WDS_IPV6; - pRequest = ComposeQMUXMsg(QMIType, QMIWDS_GET_PROFILE_SETTINGS_REQ, - WdsGetProfileSettingsReqSend, profile); - err = QmiThreadSendQMI(pRequest, &pResponse); - qmi_rsp_check_and_return(); - - pApnName = (PQMIWDS_APNNAME)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x14); - pUserName = (PQMIWDS_USERNAME)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x1B); - pPassWd = (PQMIWDS_PASSWD)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x1C); - pAuthPref = - (PQMIWDS_AUTH_PREFERENCE)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x1D); - - if (pApnName /* && le16_to_cpu(pApnName->TLVLength)*/) - apn = strndup((const char *)(&pApnName->ApnName), - le16_to_cpu(pApnName->TLVLength)); - if (pUserName /* && pUserName->UserName*/) - user = strndup((const char *)(&pUserName->UserName), - le16_to_cpu(pUserName->TLVLength)); - if (pPassWd /* && le16_to_cpu(pPassWd->TLVLength)*/) - password = strndup((const char *)(&pPassWd->Passwd), - le16_to_cpu(pPassWd->TLVLength)); - if (pAuthPref /* && le16_to_cpu(pAuthPref->TLVLength)*/) { - auth = pAuthPref->AuthPreference; - } - -#if 0 - if (profile) { - profile->apn = apn; - profile->user = user; - profile->password = password; - profile->auth = auth; - } -#endif - - dbg_time("%s[%d] %s/%s/%s/%d", __func__, profile->pdpindex, apn, user, password, - auth); - - free(pResponse); - return 0; -} -#endif - -#ifdef CONFIG_VERSION -int requestBaseBandVersion(const char **pp_reversion) -{ - PQCQMIMSG pRequest; - PQCQMIMSG pResponse; - PQMUX_MSG pMUXMsg; - PDEVICE_REV_ID revId; - int err; - - if (pp_reversion) - *pp_reversion = NULL; - - pRequest = - ComposeQMUXMsg(QMUX_TYPE_DMS, QMIDMS_GET_DEVICE_REV_ID_REQ, NULL, NULL); - err = QmiThreadSendQMI(pRequest, &pResponse); - qmi_rsp_check_and_return(); - - revId = (PDEVICE_REV_ID)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x01); - - if (revId && le16_to_cpu(revId->TLVLength)) { - char *DeviceRevisionID = strndup((const char *)(&revId->RevisionID), - le16_to_cpu(revId->TLVLength)); - dbg_time("%s %s", __func__, DeviceRevisionID); - - if (pp_reversion) - *pp_reversion = DeviceRevisionID; - } - - free(pResponse); - return 0; -} -#endif - -#ifdef CONFIG_RESET_RADIO -static USHORT DmsSetOperatingModeReq(PQMUX_MSG pMUXMsg, void *arg) -{ - pMUXMsg->SetOperatingModeReq.TLVType = 0x01; - pMUXMsg->SetOperatingModeReq.TLVLength = cpu_to_le16(1); - pMUXMsg->SetOperatingModeReq.OperatingMode = *((UCHAR *)arg); - - return sizeof(QMIDMS_SET_OPERATING_MODE_REQ_MSG); -} - -int requestSetOperatingMode(UCHAR OperatingMode) -{ - PQCQMIMSG pRequest; - PQCQMIMSG pResponse; - PQMUX_MSG pMUXMsg; - int err; - - dbg_time("%s(%d)", __func__, OperatingMode); - - pRequest = ComposeQMUXMsg(QMUX_TYPE_DMS, QMIDMS_SET_OPERATING_MODE_REQ, - DmsSetOperatingModeReq, &OperatingMode); - err = QmiThreadSendQMI(pRequest, &pResponse); - qmi_rsp_check_and_return(); - - free(pResponse); - return 0; -} -#endif diff --git a/fibocom-dial/src/QMIThread.h b/fibocom-dial/src/QMIThread.h deleted file mode 100644 index d3c8008..0000000 --- a/fibocom-dial/src/QMIThread.h +++ /dev/null @@ -1,260 +0,0 @@ -#ifndef __QMI_THREAD_H__ -#define __QMI_THREAD_H__ - -#define CONFIG_GOBINET -#define CONFIG_QMIWWAN -#define CONFIG_SIM -#define CONFIG_APN -#define CONFIG_VERSION -//2021-03-24 willa.liu@fibocom.com changed begin for support mantis 0071817 -#define CONFIG_IMSI_ICCID -//2021-03-24 willa.liu@fibocom.com changed end for support mantis 0071817 -#define CONFIG_DEFAULT_PDP 1 -#define CONFIG_DEFAULT_PDPINDEX 1 -//#define CONFIG_IMSI_ICCID - -#define CONFIG_RESET_RADIO \ - (45) // Reset Radiao(AT+CFUN=4,AT+CFUN=1) when cann not register network or - // setup data call in 45 seconds - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "MPQCTL.h" -#include "MPQMI.h" -#include "MPQMUX.h" - -#define DEVICE_CLASS_UNKNOWN 0 -#define DEVICE_CLASS_CDMA 1 -#define DEVICE_CLASS_GSM 2 - -#define WWAN_DATA_CLASS_NONE 0x00000000 -#define WWAN_DATA_CLASS_GPRS 0x00000001 -#define WWAN_DATA_CLASS_EDGE 0x00000002 /* EGPRS */ -#define WWAN_DATA_CLASS_UMTS 0x00000004 -#define WWAN_DATA_CLASS_HSDPA 0x00000008 -#define WWAN_DATA_CLASS_HSUPA 0x00000010 -#define WWAN_DATA_CLASS_LTE 0x00000020 -//begin modified by zhangkaibo add 5G network detect feature on x55 platform. 20200605 -#define WWAN_DATA_CLASS_5G 0x00000040 -//end modified by zhangkaibo add 5G network detect feature on x55 platform. 20200605 -#define WWAN_DATA_CLASS_1XRTT 0x00010000 -#define WWAN_DATA_CLASS_1XEVDO 0x00020000 -#define WWAN_DATA_CLASS_1XEVDO_REVA 0x00040000 -#define WWAN_DATA_CLASS_1XEVDV 0x00080000 -#define WWAN_DATA_CLASS_3XRTT 0x00100000 -#define WWAN_DATA_CLASS_1XEVDO_REVB 0x00200000 /* for future use */ -#define WWAN_DATA_CLASS_UMB 0x00400000 -#define WWAN_DATA_CLASS_CUSTOM 0x80000000 - -struct wwan_data_class_str { - ULONG class; - CHAR *str; -}; - -#pragma pack(push, 1) - -typedef struct _QCQMIMSG { - QCQMI_HDR QMIHdr; - union { - QMICTL_MSG CTLMsg; - QMUX_MSG MUXMsg; -//2021-03-24 willa.liu@fibocom.com changed begin for support mantis 0071817 - QMUX_MSG QMUXMsgHdrResp; -//2021-03-24 willa.liu@fibocom.com changed end for support mantis 0071817 - }; -} __attribute__((packed)) QCQMIMSG, *PQCQMIMSG; - -#pragma pack(pop) - -typedef struct __IPV4 { - uint32_t Address; - uint32_t Gateway; - uint32_t SubnetMask; - uint32_t DnsPrimary; - uint32_t DnsSecondary; - uint32_t Mtu; -} IPV4_T; - -typedef struct __IPV6 { - UCHAR Address[16]; - UCHAR Gateway[16]; - UCHAR SubnetMask[16]; - UCHAR DnsPrimary[16]; - UCHAR DnsSecondary[16]; - UCHAR PrefixLengthIPAddr; - UCHAR PrefixLengthGateway; - ULONG Mtu; -} IPV6_T; - -#define IpFamilyV4 (0x04) -#define IpFamilyV6 (0x06) - -struct __PROFILE; -struct qmi_device_ops { - int (*init)(struct __PROFILE *profile); - int (*deinit)(void); - int (*send)(PQCQMIMSG pRequest); - void *(*read)(void *pData); -}; -extern int (*qmidev_send)(PQCQMIMSG pRequest); - -#ifndef bool -#define bool uint8_t -#endif -//2021-03-15 zhangkaibo@fibocom.com changed begin for oa 20210311037 -typedef struct { - unsigned int size; - unsigned int rx_urb_size; - unsigned int ep_type; - unsigned int iface_id; - unsigned int qmap_mode; - unsigned int qmap_version; - unsigned int dl_minimum_padding; - char ifname[8][16]; - unsigned char mux_id[8]; -} RMNET_INFO; -//2021-03-15 zhangkaibo@fibocom.com changed end for oa 20210311037 - -typedef struct __PROFILE { - char *qmichannel; - char *usbnet_adapter; - char *qmapnet_adapter; - const char *driver_name; - int qmap_mode; - int qmap_size; - int qmap_version; - const char *apn; - const char *user; - const char *password; - const char *pincode; - int auth; - int pdp; - int pdpindex; - int pdpnum; - int curIpFamily; - int rawIP; - int muxid; - IPV4_T ipv4; - IPV6_T ipv6; - int ipv4_flag; - int ipv6_flag; - -//2021-02-25 willa.liu@fibocom.com changed begin for support eipd SN-20210129001 - int ipv6_prigateway_flag; -//2021-02-25 willa.liu@fibocom.com changed begin for support eipd SN-20210129001 - - int dual_flag; - int apntype; - const struct qmi_device_ops *qmi_ops; - bool loopback_state; - int replication_factor; -//2021-02-08 zhangkaibo@fibocom.com changed begin for mantis 0070613 - int interfacenum; -//2021-02-08 zhangkaibo@fibocom.com changed end for mantis 0070613 -//2021-03-15 zhangkaibo@fibocom.com changed begin for oa 20210311037 - RMNET_INFO rmnet_info; -//2021-03-15 zhangkaibo@fibocom.com changed end for oa 20210311037 -} PROFILE_T; - -typedef enum { - SIM_ABSENT = 0, - SIM_NOT_READY = 1, - SIM_READY = - 2, /* SIM_READY means the radio state is RADIO_STATE_SIM_READY */ - SIM_PIN = 3, - SIM_PUK = 4, - SIM_NETWORK_PERSONALIZATION = 5, - SIM_BAD = 6, -} SIM_Status; -//2021-03-24 willa.liu@fibocom.com changed begin for support mantis 0071817 -typedef enum { - SIM_Card0 = 0, - SIM_Card1 = 1 -} SIM_Select; -//2021-03-24 willa.liu@fibocom.com changed end for support mantis 0071817 -#define WDM_DEFAULT_BUFSIZE 256 -#define RIL_REQUEST_QUIT 0x1000 -#define RIL_INDICATE_DEVICE_CONNECTED 0x1002 -#define RIL_INDICATE_DEVICE_DISCONNECTED 0x1003 -#define RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED 0x1004 -#define RIL_UNSOL_DATA_CALL_LIST_CHANGED 0x1005 - -extern int pthread_cond_timeout_np(pthread_cond_t *cond, pthread_mutex_t *mutex, - unsigned msecs); -extern int QmiThreadSendQMI(PQCQMIMSG pRequest, PQCQMIMSG *ppResponse); -extern int QmiThreadSendQMITimeout(PQCQMIMSG pRequest, PQCQMIMSG *ppResponse, - unsigned msecs); -extern void QmiThreadRecvQMI(PQCQMIMSG pResponse); -extern int fibo_raw_ip_mode_check(const char *ifname); -extern void udhcpc_start(PROFILE_T *profile); -extern void udhcpc_stop(PROFILE_T *profile); -extern void udhcpc_start_pcie(PROFILE_T *profile); -extern void udhcpc_stop_pcie(PROFILE_T *profile); - -extern void dump_qmi(void *dataBuffer, int dataLen); -extern void qmidevice_send_event_to_main(int triger_event); -extern int requestSetEthMode(PROFILE_T *profile); -//2021-03-24 willa.liu@fibocom.com changed begin for support mantis 0071817 -//extern int requestGetSIMStatus(SIM_Status *pSIMStatus); -extern int requestGetSIMStatus(SIM_Status *pSIMStatus , const int sim_select); -//2021-03-24 willa.liu@fibocom.com changed end for support mantis 0071817 -extern int requestEnterSimPin(const CHAR *pPinCode); -extern int requestGetICCID(void); -extern int requestGetIMSI(void); -extern int requestRegistrationState(UCHAR *pPSAttachedState); -extern int requestQueryDataCall(UCHAR *pConnectionStatus, int curIpFamily); -extern int requestSetupDataCall(PROFILE_T *profile, int curIpFamily); -extern int requestDeactivateDefaultPDP(PROFILE_T *profile, int curIpFamily); -extern int requestSetProfile(PROFILE_T *profile); -extern int requestGetProfile(PROFILE_T *profile); -extern int requestBaseBandVersion(const char **pp_reversion); -extern int requestGetIPAddress(PROFILE_T *profile, int curIpFamily); -extern int requestSetOperatingMode(UCHAR OperatingMode); -int requestRegistrationState2(UCHAR *pPSAttachedState); - -extern int fibo_qmap_mode_set(PROFILE_T *profile); -extern int fibo_bridge_mode_detect(PROFILE_T *profile); -extern int fibo_qmap_mode_detect(PROFILE_T *profile); -extern const struct qmi_device_ops qmiwwan_qmidev_ops; - -#define qmidev_is_gobinet(_qmichannel) \ - (strncmp(_qmichannel, "/dev/qcqmi", strlen("/dev/qcqmi")) == 0) -#define qmidev_is_qmiwwan(_qmichannel) \ - (strncmp(_qmichannel, "/dev/cdc-wdm", strlen("/dev/cdc-wdm")) == 0) -#define qmidev_is_pciemhi(_qmichannel) \ - (strncmp(_qmichannel, "/dev/mhi_", strlen("/dev/mhi_")) == 0) - -#define driver_is_qmi(_drv_name) \ - (strncasecmp(_drv_name, "qmi_wwan", strlen("qmi_wwan")) == 0) -#define driver_is_mbim(_drv_name) \ - (strncasecmp(_drv_name, "cdc_mbim", strlen("cdc_mbim")) == 0) - -extern FILE *logfilefp; -extern int debug_qmi; -extern USHORT g_MobileCountryCode; -extern USHORT g_MobileNetworkCode; -extern int qmidevice_control_fd[2]; -extern int qmiclientId[QMUX_TYPE_WDS_ADMIN + 1]; -extern void dbg_time(const char *fmt, ...); -extern USHORT le16_to_cpu(USHORT v16); -extern UINT le32_to_cpu(UINT v32); -extern USHORT cpu_to_le16(USHORT v16); -extern UINT cpu_to_le32(UINT v32); -#endif diff --git a/fibocom-dial/src/QmiWwanCM.c b/fibocom-dial/src/QmiWwanCM.c deleted file mode 100644 index ed1cccd..0000000 --- a/fibocom-dial/src/QmiWwanCM.c +++ /dev/null @@ -1,426 +0,0 @@ -#include -#include -#include -#include -typedef unsigned short sa_family_t; -#include - -#include "QMIThread.h" - -#ifdef CONFIG_QMIWWAN -#define FIBO_QMI_PROXY "fibo_qmimsg_server" -static int cdc_wdm_fd = -1; - -static UCHAR GetQCTLTransactionId(void) -{ - static int TransactionId = 0; - if (++TransactionId > 0xFF) - TransactionId = 1; - return TransactionId; -} - -typedef USHORT (*CUSTOMQCTL)(PQMICTL_MSG pCTLMsg, void *arg); - -static PQCQMIMSG ComposeQCTLMsg(USHORT QMICTLType, - CUSTOMQCTL customQctlMsgFunction, void *arg) -{ - UCHAR QMIBuf[WDM_DEFAULT_BUFSIZE]; - PQCQMIMSG pRequest = (PQCQMIMSG)QMIBuf; - int Length; - - pRequest->QMIHdr.IFType = USB_CTL_MSG_TYPE_QMI; - pRequest->QMIHdr.CtlFlags = 0x00; - pRequest->QMIHdr.QMIType = QMUX_TYPE_CTL; - pRequest->QMIHdr.ClientId = 0x00; - - pRequest->CTLMsg.QMICTLMsgHdr.CtlFlags = QMICTL_FLAG_REQUEST; - pRequest->CTLMsg.QMICTLMsgHdr.TransactionId = GetQCTLTransactionId(); - pRequest->CTLMsg.QMICTLMsgHdr.QMICTLType = cpu_to_le16(QMICTLType); - if (customQctlMsgFunction) - pRequest->CTLMsg.QMICTLMsgHdr.Length = - cpu_to_le16(customQctlMsgFunction(&pRequest->CTLMsg, arg) - - sizeof(QCQMICTL_MSG_HDR)); - else - pRequest->CTLMsg.QMICTLMsgHdr.Length = cpu_to_le16(0x0000); - - pRequest->QMIHdr.Length = - cpu_to_le16(le16_to_cpu(pRequest->CTLMsg.QMICTLMsgHdr.Length) + - sizeof(QCQMICTL_MSG_HDR) + sizeof(QCQMI_HDR) - 1); - Length = le16_to_cpu(pRequest->QMIHdr.Length) + 1; - - pRequest = (PQCQMIMSG)malloc(Length); - if (pRequest == NULL) { - dbg_time("%s fail to malloc", __func__); - } else { - memcpy(pRequest, QMIBuf, Length); - } - - return pRequest; -} - -static USHORT CtlGetVersionReq(PQMICTL_MSG QCTLMsg, void *arg) -{ - QCTLMsg->GetVersionReq.TLVType = QCTLV_TYPE_REQUIRED_PARAMETER; - QCTLMsg->GetVersionReq.TLVLength = cpu_to_le16(0x0001); - QCTLMsg->GetVersionReq.QMUXTypes = QMUX_TYPE_ALL; - return sizeof(QMICTL_GET_VERSION_REQ_MSG); -} - -static USHORT CtlGetClientIdReq(PQMICTL_MSG QCTLMsg, void *arg) -{ - QCTLMsg->GetClientIdReq.TLVType = QCTLV_TYPE_REQUIRED_PARAMETER; - QCTLMsg->GetClientIdReq.TLVLength = cpu_to_le16(0x0001); - QCTLMsg->GetClientIdReq.QMIType = ((UCHAR *)arg)[0]; - return sizeof(QMICTL_GET_CLIENT_ID_REQ_MSG); -} - -static USHORT CtlReleaseClientIdReq(PQMICTL_MSG QCTLMsg, void *arg) -{ - QCTLMsg->ReleaseClientIdReq.TLVType = QCTLV_TYPE_REQUIRED_PARAMETER; - QCTLMsg->ReleaseClientIdReq.TLVLength = cpu_to_le16(0x0002); - QCTLMsg->ReleaseClientIdReq.QMIType = ((UCHAR *)arg)[0]; - QCTLMsg->ReleaseClientIdReq.ClientId = ((UCHAR *)arg)[1]; - return sizeof(QMICTL_RELEASE_CLIENT_ID_REQ_MSG); -} - -static int QmiWwanSendQMI(PQCQMIMSG pRequest) -{ - struct pollfd pollfds[] = {{cdc_wdm_fd, POLLOUT, 0}}; - int ret; - - if (cdc_wdm_fd == -1) { - dbg_time("%s cdc_wdm_fd = -1", __func__); - return -ENODEV; - } - - if (pRequest->QMIHdr.QMIType == QMUX_TYPE_WDS_IPV6) - pRequest->QMIHdr.QMIType = QMUX_TYPE_WDS; - - do { - ret = poll(pollfds, sizeof(pollfds) / sizeof(pollfds[0]), 5000); - } while ((ret < 0) && (errno == EINTR)); - - if (pollfds[0].revents & POLLOUT) { - ssize_t nwrites = le16_to_cpu(pRequest->QMIHdr.Length) + 1; - ret = write(cdc_wdm_fd, pRequest, nwrites); - if (ret == nwrites) { - ret = 0; - } else { - dbg_time("%s write=%d, errno: %d (%s)", __func__, ret, errno, - strerror(errno)); - } - } else { - dbg_time("%s poll=%d, revents = 0x%x, errno: %d (%s)", __func__, ret, - pollfds[0].revents, errno, strerror(errno)); - } - - return ret; -} - -static int QmiWwanGetClientID(UCHAR QMIType) -{ - PQCQMIMSG pResponse; - - QmiThreadSendQMI( - ComposeQCTLMsg(QMICTL_GET_CLIENT_ID_REQ, CtlGetClientIdReq, &QMIType), - &pResponse); - - if (pResponse) { - USHORT QMUXResult = cpu_to_le16(pResponse->CTLMsg.QMICTLMsgHdrRsp - .QMUXResult); // QMI_RESULT_SUCCESS - USHORT QMUXError = cpu_to_le16(pResponse->CTLMsg.QMICTLMsgHdrRsp - .QMUXError); // QMI_ERR_INVALID_ARG - // UCHAR QMIType = pResponse->CTLMsg.GetClientIdRsp.QMIType; - UCHAR ClientId = pResponse->CTLMsg.GetClientIdRsp.ClientId; - - dbg_time("%s: QMIType = %d clientid %d", __func__, QMIType, ClientId); - - if (!QMUXResult && !QMUXError && - (QMIType == pResponse->CTLMsg.GetClientIdRsp.QMIType)) { - switch (QMIType) { - case QMUX_TYPE_WDS: - dbg_time("Get clientWDS = %d", ClientId); - break; - case QMUX_TYPE_DMS: - dbg_time("Get clientDMS = %d", ClientId); - break; - case QMUX_TYPE_NAS: - dbg_time("Get clientNAS = %d", ClientId); - break; - case QMUX_TYPE_QOS: - dbg_time("Get clientQOS = %d", ClientId); - break; - case QMUX_TYPE_WMS: - dbg_time("Get clientWMS = %d", ClientId); - break; - case QMUX_TYPE_PDS: - dbg_time("Get clientPDS = %d", ClientId); - break; - case QMUX_TYPE_UIM: - dbg_time("Get clientUIM = %d", ClientId); - break; - case QMUX_TYPE_WDS_ADMIN: - dbg_time("Get clientWDA = %d", ClientId); - break; - default: - break; - } - return ClientId; - } - } - return 0; -} - -static int QmiWwanReleaseClientID(QMI_SERVICE_TYPE QMIType, UCHAR ClientId) -{ - UCHAR argv[] = {QMIType, ClientId}; - QmiThreadSendQMI(ComposeQCTLMsg(QMICTL_RELEASE_CLIENT_ID_REQ, - CtlReleaseClientIdReq, argv), - NULL); - return 0; -} - -static int QmiWwanInit(PROFILE_T *profile) -{ - unsigned i; - int ret; - PQCQMIMSG pResponse; - - if (profile->qmap_mode == 0 || profile->qmap_mode == 1) { - for (i = 0; i < 10; i++) { - ret = QmiThreadSendQMITimeout( - ComposeQCTLMsg(QMICTL_SYNC_REQ, NULL, NULL), NULL, 1 * 1000); - if (!ret) - break; - sleep(1); - } - if (ret) - return ret; - } - - QmiThreadSendQMI( - ComposeQCTLMsg(QMICTL_GET_VERSION_REQ, CtlGetVersionReq, NULL), - &pResponse); - if (profile->qmap_mode) { - if (pResponse) { - if (pResponse->CTLMsg.QMICTLMsgHdrRsp.QMUXResult == 0 && - pResponse->CTLMsg.QMICTLMsgHdrRsp.QMUXError == 0) { - uint8_t NumElements = 0; - - for (NumElements = 0; - NumElements < pResponse->CTLMsg.GetVersionRsp.NumElements; - NumElements++) { - if (pResponse->CTLMsg.GetVersionRsp.TypeVersion[NumElements] - .QMUXType == QMUX_TYPE_WDS_ADMIN) - profile->qmap_version = (pResponse->CTLMsg.GetVersionRsp - .TypeVersion[NumElements] - .MinorVersion > 16); - } - } - } - } - if (pResponse) - free(pResponse); - if (profile->ipv4_flag) - qmiclientId[QMUX_TYPE_WDS] = QmiWwanGetClientID(QMUX_TYPE_WDS); - if (profile->ipv6_flag) - qmiclientId[QMUX_TYPE_WDS_IPV6] = QmiWwanGetClientID(QMUX_TYPE_WDS); - qmiclientId[QMUX_TYPE_DMS] = QmiWwanGetClientID(QMUX_TYPE_DMS); - qmiclientId[QMUX_TYPE_NAS] = QmiWwanGetClientID(QMUX_TYPE_NAS); - qmiclientId[QMUX_TYPE_UIM] = QmiWwanGetClientID(QMUX_TYPE_UIM); - if (profile->qmap_mode == 0 || profile->qmap_mode == 1) - qmiclientId[QMUX_TYPE_WDS_ADMIN] = - QmiWwanGetClientID(QMUX_TYPE_WDS_ADMIN); - - return 0; -} - -static int QmiWwanDeInit(void) -{ - unsigned int i; - for (i = 0; i < sizeof(qmiclientId) / sizeof(qmiclientId[0]); i++) { - if (qmiclientId[i] != 0) { - QmiWwanReleaseClientID(i, qmiclientId[i]); - qmiclientId[i] = 0; - } - } - - return 0; -} - -static int qmi_proxy_open(const char *name) -{ - int sockfd = -1; - int reuse_addr = 1; - struct sockaddr_un sockaddr; - socklen_t alen; - - /*Create server socket*/ - (sockfd = socket(AF_LOCAL, SOCK_STREAM, 0)); - if (sockfd < 0) - return sockfd; - - memset(&sockaddr, 0, sizeof(sockaddr)); - sockaddr.sun_family = AF_LOCAL; - sockaddr.sun_path[0] = 0; - memcpy(sockaddr.sun_path + 1, name, strlen(name)); - - alen = strlen(name) + offsetof(struct sockaddr_un, sun_path) + 1; - if (connect(sockfd, (struct sockaddr *)&sockaddr, alen) < 0) { - close(sockfd); - dbg_time("%s connect %s errno: %d (%s)\n", __func__, name, errno, - strerror(errno)); - return -1; - } - (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &reuse_addr, - sizeof(reuse_addr))); - - dbg_time("connect to %s sockfd = %d\n", name, sockfd); - - return sockfd; -} - -static ssize_t qmi_proxy_read(int fd, void *buf, size_t size) -{ - ssize_t nreads; - PQCQMI_HDR pHdr = (PQCQMI_HDR)buf; - - nreads = read(fd, pHdr, sizeof(QCQMI_HDR)); - if (nreads == sizeof(QCQMI_HDR)) { - nreads += read(fd, pHdr + 1, - le16_to_cpu(pHdr->Length) + 1 - sizeof(QCQMI_HDR)); - } - - return nreads; -} - -static void *QmiWwanThread(void *pData) -{ - PROFILE_T *profile = (PROFILE_T *)pData; - const char *cdc_wdm = (const char *)profile->qmichannel; - - if (profile->qmap_mode == 0 || profile->qmap_mode == 1) - cdc_wdm_fd = open(cdc_wdm, O_RDWR | O_NONBLOCK | O_NOCTTY); - else - cdc_wdm_fd = qmi_proxy_open(FIBO_QMI_PROXY); - - if (cdc_wdm_fd == -1) { - dbg_time("%s Failed to open %s, errno: %d (%s)", __func__, cdc_wdm, - errno, strerror(errno)); - qmidevice_send_event_to_main(RIL_INDICATE_DEVICE_DISCONNECTED); - pthread_exit(NULL); - return NULL; - } - - fcntl(cdc_wdm_fd, F_SETFL, fcntl(cdc_wdm_fd, F_GETFL) | O_NONBLOCK); - fcntl(cdc_wdm_fd, F_SETFD, FD_CLOEXEC); - - dbg_time("cdc_wdm_fd = %d", cdc_wdm_fd); - - qmidevice_send_event_to_main(RIL_INDICATE_DEVICE_CONNECTED); - - while (1) { - struct pollfd pollfds[] = {{qmidevice_control_fd[1], POLLIN, 0}, - {cdc_wdm_fd, POLLIN, 0}}; - int ne, ret, nevents = sizeof(pollfds) / sizeof(pollfds[0]); - - do { - ret = poll(pollfds, nevents, -1); - } while ((ret < 0) && (errno == EINTR)); - - if (ret <= 0) { - dbg_time("%s poll=%d, errno: %d (%s)", __func__, ret, errno, - strerror(errno)); - break; - } - - for (ne = 0; ne < nevents; ne++) { - int fd = pollfds[ne].fd; - short revents = pollfds[ne].revents; - - // dbg_time("{%d, %x, %x}", pollfds[ne].fd, pollfds[ne].events, - // pollfds[ne].revents); - - if (revents & (POLLERR | POLLHUP | POLLNVAL)) { - dbg_time("%s poll err/hup/inval", __func__); - dbg_time("poll fd = %d, events = 0x%04x", fd, revents); - if (fd == cdc_wdm_fd) { - } else { - } - if (revents & - (POLLHUP | POLLNVAL)) // EC20 bug, Can get POLLERR - goto __QmiWwanThread_quit; - } - - if ((revents & POLLIN) == 0) - continue; - - if (fd == qmidevice_control_fd[1]) { - int triger_event; - if (read(fd, &triger_event, sizeof(triger_event)) == - sizeof(triger_event)) { - // DBG("triger_event = 0x%x", triger_event); - switch (triger_event) { - case RIL_REQUEST_QUIT: - goto __QmiWwanThread_quit; - break; - case SIGTERM: - case SIGHUP: - case SIGINT: - QmiThreadRecvQMI(NULL); - break; - default: - break; - } - } - } - - if (fd == cdc_wdm_fd) { - ssize_t nreads; - UCHAR QMIBuf[4096]; - PQCQMIMSG pResponse = (PQCQMIMSG)QMIBuf; - - if (profile->qmap_mode == 0 || profile->qmap_mode == 1) - nreads = read(fd, QMIBuf, sizeof(QMIBuf)); - else - nreads = qmi_proxy_read(fd, QMIBuf, sizeof(QMIBuf)); - // dbg_time("%s read=%d errno: %d (%s)", __func__, (int)nreads, - // errno, strerror(errno)); - if (nreads <= 0) { - dbg_time("%s read=%d errno: %d (%s)", __func__, (int)nreads, - errno, strerror(errno)); - break; - } - - if (nreads != (le16_to_cpu(pResponse->QMIHdr.Length) + 1)) { - dbg_time("%s nreads=%d, pQCQMI->QMIHdr.Length = %d", - __func__, (int)nreads, - le16_to_cpu(pResponse->QMIHdr.Length)); - continue; - } - - QmiThreadRecvQMI(pResponse); - } - } - } - -__QmiWwanThread_quit: - if (cdc_wdm_fd != -1) { - close(cdc_wdm_fd); - cdc_wdm_fd = -1; - } - qmidevice_send_event_to_main(RIL_INDICATE_DEVICE_DISCONNECTED); - QmiThreadRecvQMI(NULL); // main thread may pending on QmiThreadSendQMI() - dbg_time("%s exit", __func__); - pthread_exit(NULL); - return NULL; -} - -#endif - -const struct qmi_device_ops qmiwwan_qmidev_ops = { - .init = QmiWwanInit, - .deinit = QmiWwanDeInit, - .send = QmiWwanSendQMI, - .read = QmiWwanThread, -}; diff --git a/fibocom-dial/src/default.script b/fibocom-dial/src/default.script deleted file mode 100644 index 26b95c1..0000000 --- a/fibocom-dial/src/default.script +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/sh -# Busybox udhcpc dispatcher script. Copyright (C) 2009 by Axel Beckert. -# -# Based on the busybox example scripts and the old udhcp source -# package default.* scripts. - -RESOLV_CONF="/etc/resolv.conf" - -case $1 in - bound|renew) - [ -n "$broadcast" ] && BROADCAST="broadcast $broadcast" - [ -n "$subnet" ] && NETMASK="netmask $subnet" - - /sbin/ifconfig $interface $ip $BROADCAST $NETMASK - - if [ -n "$router" ]; then - echo "$0: Resetting default routes" - while /sbin/route del default gw 0.0.0.0 dev $interface; do :; done - - metric=0 - for i in $router; do - /sbin/route add default gw $i dev $interface metric $metric - metric=$(($metric + 1)) - done - fi - - # Update resolver configuration file - R="" - [ -n "$domain" ] && R="domain $domain -" - for i in $dns; do - echo "$0: Adding DNS $i" - R="${R}nameserver $i -" - done - - if [ -x /sbin/resolvconf ]; then - echo -n "$R" | resolvconf -a "${interface}.udhcpc" - else - echo -n "$R" > "$RESOLV_CONF" - fi - ;; - - deconfig) - if [ -x /sbin/resolvconf ]; then - resolvconf -d "${interface}.udhcpc" - fi - /sbin/ifconfig $interface 0.0.0.0 - ;; - - leasefail) - echo "$0: Lease failed: $message" - ;; - - nak) - echo "$0: Received a NAK: $message" - ;; - - *) - echo "$0: Unknown udhcpc command: $1"; - exit 1; - ;; -esac diff --git a/fibocom-dial/src/fibo_qmimsg_server.c b/fibocom-dial/src/fibo_qmimsg_server.c deleted file mode 100644 index a7a29ef..0000000 --- a/fibocom-dial/src/fibo_qmimsg_server.c +++ /dev/null @@ -1,1331 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -typedef unsigned char uint8_t; -typedef unsigned short uint16_t; -typedef unsigned int uint32_t; - -#define cpu_to_le16(x) (x) -#define cpu_to_le32(x) (x) -#define le16_to_cpu(x) (x) -#define le32_to_cpu(x) (x) - -#define dprintf(fmt, arg...) do { printf(fmt, ##arg); } while(0) -#define SYSCHECK(c) do{if((c)<0) {dprintf("%s %d error: '%s' (code: %d)\n", __func__, __LINE__, strerror(errno), errno); return -1;}}while(0) -#define cfmakenoblock(fd) do{fcntl(fd, F_SETFL, fcntl(fd,F_GETFL) | O_NONBLOCK);}while(0) - -#define qmidev_is_pciemhi(_qmichannel) (strncmp(_qmichannel, "/dev/mhi_", strlen("/dev/mhi_")) == 0) - -typedef struct _QCQMI_HDR -{ - uint8_t IFType; - uint16_t Length; - uint8_t CtlFlags; // reserved - uint8_t QMIType; - uint8_t ClientId; -} __attribute__ ((packed)) QCQMI_HDR, *PQCQMI_HDR; - -typedef struct _QMICTL_SYNC_REQ_MSG -{ - uint8_t CtlFlags; // QMICTL_FLAG_REQUEST - uint8_t TransactionId; - uint16_t QMICTLType; // QMICTL_CTL_SYNC_REQ - uint16_t Length; // 0 -} __attribute__ ((packed)) QMICTL_SYNC_REQ_MSG, *PQMICTL_SYNC_REQ_MSG; - -typedef struct _QMICTL_SYNC_RESP_MSG -{ - uint8_t CtlFlags; // QMICTL_FLAG_RESPONSE - uint8_t TransactionId; - uint16_t QMICTLType; // QMICTL_CTL_SYNC_RESP - uint16_t Length; - uint8_t TLVType; // QCTLV_TYPE_RESULT_CODE - uint16_t TLVLength; // 0x0004 - uint16_t QMIResult; - uint16_t QMIError; -} __attribute__ ((packed)) QMICTL_SYNC_RESP_MSG, *PQMICTL_SYNC_RESP_MSG; - -typedef struct _QMICTL_SYNC_IND_MSG -{ - uint8_t CtlFlags; // QMICTL_FLAG_INDICATION - uint8_t TransactionId; - uint16_t QMICTLType; // QMICTL_REVOKE_CLIENT_ID_IND - uint16_t Length; -} __attribute__ ((packed)) QMICTL_SYNC_IND_MSG, *PQMICTL_SYNC_IND_MSG; - -typedef struct _QMICTL_GET_CLIENT_ID_REQ_MSG -{ - uint8_t CtlFlags; // QMICTL_FLAG_REQUEST - uint8_t TransactionId; - uint16_t QMICTLType; // QMICTL_GET_CLIENT_ID_REQ - uint16_t Length; - uint8_t TLVType; // QCTLV_TYPE_REQUIRED_PARAMETER - uint16_t TLVLength; // 1 - uint8_t QMIType; // QMUX type -} __attribute__ ((packed)) QMICTL_GET_CLIENT_ID_REQ_MSG, *PQMICTL_GET_CLIENT_ID_REQ_MSG; - -typedef struct _QMICTL_GET_CLIENT_ID_RESP_MSG -{ - uint8_t CtlFlags; // QMICTL_FLAG_RESPONSE - uint8_t TransactionId; - uint16_t QMICTLType; // QMICTL_GET_CLIENT_ID_RESP - uint16_t Length; - uint8_t TLVType; // QCTLV_TYPE_RESULT_CODE - uint16_t TLVLength; // 0x0004 - uint16_t QMIResult; // result code - uint16_t QMIError; // error code - uint8_t TLV2Type; // QCTLV_TYPE_REQUIRED_PARAMETER - uint16_t TLV2Length; // 2 - uint8_t QMIType; - uint8_t ClientId; -} __attribute__ ((packed)) QMICTL_GET_CLIENT_ID_RESP_MSG, *PQMICTL_GET_CLIENT_ID_RESP_MSG; - -typedef struct _QMICTL_RELEASE_CLIENT_ID_REQ_MSG -{ - uint8_t CtlFlags; // QMICTL_FLAG_REQUEST - uint8_t TransactionId; - uint16_t QMICTLType; // QMICTL_RELEASE_CLIENT_ID_REQ - uint16_t Length; - uint8_t TLVType; // QCTLV_TYPE_REQUIRED_PARAMETER - uint16_t TLVLength; // 0x0002 - uint8_t QMIType; - uint8_t ClientId; -} __attribute__ ((packed)) QMICTL_RELEASE_CLIENT_ID_REQ_MSG, *PQMICTL_RELEASE_CLIENT_ID_REQ_MSG; - -typedef struct _QMICTL_RELEASE_CLIENT_ID_RESP_MSG -{ - uint8_t CtlFlags; // QMICTL_FLAG_RESPONSE - uint8_t TransactionId; - uint16_t QMICTLType; // QMICTL_RELEASE_CLIENT_ID_RESP - uint16_t Length; - uint8_t TLVType; // QCTLV_TYPE_RESULT_CODE - uint16_t TLVLength; // 0x0004 - uint16_t QMIResult; // result code - uint16_t QMIError; // error code - uint8_t TLV2Type; // QCTLV_TYPE_REQUIRED_PARAMETER - uint16_t TLV2Length; // 2 - uint8_t QMIType; - uint8_t ClientId; -} __attribute__ ((packed)) QMICTL_RELEASE_CLIENT_ID_RESP_MSG, *PQMICTL_RELEASE_CLIENT_ID_RESP_MSG; - -// QMICTL Control Flags -#define QMICTL_CTL_FLAG_CMD 0x00 -#define QMICTL_CTL_FLAG_RSP 0x01 -#define QMICTL_CTL_FLAG_IND 0x02 - -typedef struct _QCQMICTL_MSG_HDR -{ - uint8_t CtlFlags; // 00-cmd, 01-rsp, 10-ind - uint8_t TransactionId; - uint16_t QMICTLType; - uint16_t Length; -} __attribute__ ((packed)) QCQMICTL_MSG_HDR, *PQCQMICTL_MSG_HDR; - -#define QCQMICTL_MSG_HDR_SIZE sizeof(QCQMICTL_MSG_HDR) - -typedef struct _QCQMICTL_MSG_HDR_RESP -{ - uint8_t CtlFlags; // 00-cmd, 01-rsp, 10-ind - uint8_t TransactionId; - uint16_t QMICTLType; - uint16_t Length; - uint8_t TLVType; // 0x02 - result code - uint16_t TLVLength; // 4 - uint16_t QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - uint16_t QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT -} __attribute__ ((packed)) QCQMICTL_MSG_HDR_RESP, *PQCQMICTL_MSG_HDR_RESP; - -typedef struct _QMICTL_GET_VERSION_REQ_MSG -{ - uint8_t CtlFlags; // QMICTL_FLAG_REQUEST - uint8_t TransactionId; - uint16_t QMICTLType; // QMICTL_GET_VERSION_REQ - uint16_t Length; // 0 - uint8_t TLVType; // QCTLV_TYPE_REQUIRED_PARAMETER - uint16_t TLVLength; // var - uint8_t QMUXTypes; // List of one byte QMUX_TYPE values - // 0xFF returns a list of versions for all - // QMUX_TYPEs implemented on the device -} __attribute__ ((packed)) QMICTL_GET_VERSION_REQ_MSG, *PQMICTL_GET_VERSION_REQ_MSG; - -typedef struct _QMUX_TYPE_VERSION_STRUCT -{ - uint8_t QMUXType; - uint16_t MajorVersion; - uint16_t MinorVersion; -} __attribute__ ((packed)) QMUX_TYPE_VERSION_STRUCT, *PQMUX_TYPE_VERSION_STRUCT; - -typedef struct _QMICTL_GET_VERSION_RESP_MSG -{ - uint8_t CtlFlags; // QMICTL_FLAG_RESPONSE - uint8_t TransactionId; - uint16_t QMICTLType; // QMICTL_GET_VERSION_RESP - uint16_t Length; - uint8_t TLVType; // QCTLV_TYPE_RESULT_CODE - uint16_t TLVLength; // 0x0004 - uint16_t QMIResult; - uint16_t QMIError; - uint8_t TLV2Type; // QCTLV_TYPE_REQUIRED_PARAMETER - uint16_t TLV2Length; // var - uint8_t NumElements; // Num of QMUX_TYPE_VERSION_STRUCT - QMUX_TYPE_VERSION_STRUCT TypeVersion[0]; -} __attribute__ ((packed)) QMICTL_GET_VERSION_RESP_MSG, *PQMICTL_GET_VERSION_RESP_MSG; - - -typedef struct _QMICTL_MSG -{ - union - { - // Message Header - QCQMICTL_MSG_HDR QMICTLMsgHdr; - QCQMICTL_MSG_HDR_RESP QMICTLMsgHdrRsp; - - // QMICTL Message - //QMICTL_SET_INSTANCE_ID_REQ_MSG SetInstanceIdReq; - //QMICTL_SET_INSTANCE_ID_RESP_MSG SetInstanceIdRsp; - QMICTL_GET_VERSION_REQ_MSG GetVersionReq; - QMICTL_GET_VERSION_RESP_MSG GetVersionRsp; - QMICTL_GET_CLIENT_ID_REQ_MSG GetClientIdReq; - QMICTL_GET_CLIENT_ID_RESP_MSG GetClientIdRsp; - //QMICTL_RELEASE_CLIENT_ID_REQ_MSG ReleaseClientIdReq; - QMICTL_RELEASE_CLIENT_ID_RESP_MSG ReleaseClientIdRsp; - //QMICTL_REVOKE_CLIENT_ID_IND_MSG RevokeClientIdInd; - //QMICTL_INVALID_CLIENT_ID_IND_MSG InvalidClientIdInd; - //QMICTL_SET_DATA_FORMAT_REQ_MSG SetDataFormatReq; - //QMICTL_SET_DATA_FORMAT_RESP_MSG SetDataFormatRsp; - QMICTL_SYNC_REQ_MSG SyncReq; - QMICTL_SYNC_RESP_MSG SyncRsp; - QMICTL_SYNC_IND_MSG SyncInd; - }; -} __attribute__ ((packed)) QMICTL_MSG, *PQMICTL_MSG; - -typedef struct _QCQMUX_MSG_HDR -{ - uint8_t CtlFlags; // 0: single QMUX Msg; 1: - uint16_t TransactionId; - uint16_t Type; - uint16_t Length; - uint8_t payload[0]; -} __attribute__ ((packed)) QCQMUX_MSG_HDR, *PQCQMUX_MSG_HDR; - -typedef struct _QCQMUX_MSG_HDR_RESP -{ - uint8_t CtlFlags; // 0: single QMUX Msg; 1: - uint16_t TransactionId; - uint16_t Type; - uint16_t Length; - uint8_t TLVType; // 0x02 - result code - uint16_t TLVLength; // 4 - uint16_t QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - uint16_t QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT -} __attribute__ ((packed)) QCQMUX_MSG_HDR_RESP, *PQCQMUX_MSG_HDR_RESP; - -typedef struct _QMIWDS_ADMIN_SET_DATA_FORMAT -{ - uint16_t Type; // QMUX type 0x0000 - uint16_t Length; -} __attribute__ ((packed)) QMIWDS_ADMIN_SET_DATA_FORMAT, *PQMIWDS_ADMIN_SET_DATA_FORMAT; - -typedef struct _QMIWDS_ADMIN_SET_DATA_FORMAT_TLV_QOS -{ - uint8_t TLVType; - uint16_t TLVLength; - uint8_t QOSSetting; -} __attribute__ ((packed)) QMIWDS_ADMIN_SET_DATA_FORMAT_TLV_QOS, *PQMIWDS_ADMIN_SET_DATA_FORMAT_TLV_QOS; - -typedef struct _QMIWDS_ADMIN_SET_DATA_FORMAT_TLV -{ - uint8_t TLVType; - uint16_t TLVLength; - uint32_t Value; -} __attribute__ ((packed)) QMIWDS_ADMIN_SET_DATA_FORMAT_TLV, *PQMIWDS_ADMIN_SET_DATA_FORMAT_TLV; - -typedef struct _QMIWDS_ENDPOINT_TLV -{ - uint8_t TLVType; - uint16_t TLVLength; - uint32_t ep_type; - uint32_t iface_id; -} __attribute__ ((packed)) QMIWDS_ENDPOINT_TLV, *PQMIWDS_ENDPOINT_TLV; - -typedef struct _QMIWDS_ADMIN_SET_DATA_FORMAT_REQ_MSG -{ - uint8_t CtlFlags; // 0: single QMUX Msg; 1: - uint16_t TransactionId; - uint16_t Type; - uint16_t Length; - QMIWDS_ADMIN_SET_DATA_FORMAT_TLV_QOS QosDataFormatTlv; - QMIWDS_ADMIN_SET_DATA_FORMAT_TLV UnderlyingLinkLayerProtocolTlv; - QMIWDS_ADMIN_SET_DATA_FORMAT_TLV UplinkDataAggregationProtocolTlv; - QMIWDS_ADMIN_SET_DATA_FORMAT_TLV DownlinkDataAggregationProtocolTlv; - QMIWDS_ADMIN_SET_DATA_FORMAT_TLV DownlinkDataAggregationMaxDatagramsTlv; - QMIWDS_ADMIN_SET_DATA_FORMAT_TLV DownlinkDataAggregationMaxSizeTlv; - QMIWDS_ENDPOINT_TLV epTlv; -} __attribute__ ((packed)) QMIWDS_ADMIN_SET_DATA_FORMAT_REQ_MSG, *PQMIWDS_ADMIN_SET_DATA_FORMAT_REQ_MSG; - -typedef struct _QCQMUX_TLV -{ - uint8_t Type; - uint16_t Length; - uint8_t Value[0]; -} __attribute__ ((packed)) QCQMUX_TLV, *PQCQMUX_TLV; - -typedef struct _QMUX_MSG -{ - union - { - // Message Header - QCQMUX_MSG_HDR QMUXMsgHdr; - QCQMUX_MSG_HDR_RESP QMUXMsgHdrResp; - QMIWDS_ADMIN_SET_DATA_FORMAT_REQ_MSG SetDataFormatReq; - }; -} __attribute__ ((packed)) QMUX_MSG, *PQMUX_MSG; - -typedef struct _QCQMIMSG { - QCQMI_HDR QMIHdr; -//2021-03-24 willa.liu@fibocom.com changed begin for support mantis 0071817 - //QMUX_MSG QMUXMsgHdrResp; -//2021-03-24 willa.liu@fibocom.com changed begin for support mantis 0071817 - union { - QMICTL_MSG CTLMsg; - QMUX_MSG MUXMsg; - }; -} __attribute__ ((packed)) QCQMIMSG, *PQCQMIMSG; - -// QMUX Message Definitions -- QMI SDU -#define QMUX_CTL_FLAG_SINGLE_MSG 0x00 -#define QMUX_CTL_FLAG_COMPOUND_MSG 0x01 -#define QMUX_CTL_FLAG_TYPE_CMD 0x00 -#define QMUX_CTL_FLAG_TYPE_RSP 0x02 -#define QMUX_CTL_FLAG_TYPE_IND 0x04 -#define QMUX_CTL_FLAG_MASK_COMPOUND 0x01 -#define QMUX_CTL_FLAG_MASK_TYPE 0x06 // 00-cmd, 01-rsp, 10-ind - -#define USB_CTL_MSG_TYPE_QMI 0x01 - -#define QMICTL_FLAG_REQUEST 0x00 -#define QMICTL_FLAG_RESPONSE 0x01 -#define QMICTL_FLAG_INDICATION 0x02 - -// QMICTL Type -#define QMICTL_SET_INSTANCE_ID_REQ 0x0020 -#define QMICTL_SET_INSTANCE_ID_RESP 0x0020 -#define QMICTL_GET_VERSION_REQ 0x0021 -#define QMICTL_GET_VERSION_RESP 0x0021 -#define QMICTL_GET_CLIENT_ID_REQ 0x0022 -#define QMICTL_GET_CLIENT_ID_RESP 0x0022 -#define QMICTL_RELEASE_CLIENT_ID_REQ 0x0023 -#define QMICTL_RELEASE_CLIENT_ID_RESP 0x0023 -#define QMICTL_REVOKE_CLIENT_ID_IND 0x0024 -#define QMICTL_INVALID_CLIENT_ID_IND 0x0025 -#define QMICTL_SET_DATA_FORMAT_REQ 0x0026 -#define QMICTL_SET_DATA_FORMAT_RESP 0x0026 -#define QMICTL_SYNC_REQ 0x0027 -#define QMICTL_SYNC_RESP 0x0027 -#define QMICTL_SYNC_IND 0x0027 - -#define QCTLV_TYPE_REQUIRED_PARAMETER 0x01 - -// Define QMI Type -typedef enum _QMI_SERVICE_TYPE -{ - QMUX_TYPE_CTL = 0x00, - QMUX_TYPE_WDS = 0x01, - QMUX_TYPE_DMS = 0x02, - QMUX_TYPE_NAS = 0x03, - QMUX_TYPE_QOS = 0x04, - QMUX_TYPE_WMS = 0x05, - QMUX_TYPE_PDS = 0x06, - QMUX_TYPE_UIM = 0x0B, - QMUX_TYPE_WDS_IPV6 = 0x11, - QMUX_TYPE_WDS_ADMIN = 0x1A, - QMUX_TYPE_MAX = 0xFF, - QMUX_TYPE_ALL = 0xFF -} QMI_SERVICE_TYPE; - -#define QMIWDS_ADMIN_SET_DATA_FORMAT_REQ 0x0020 -#define QMIWDS_ADMIN_SET_DATA_FORMAT_RESP 0x0020 - -struct qlistnode -{ - struct qlistnode *next; - struct qlistnode *prev; -}; - -#define qnode_to_item(node, container, member) \ - (container *) (((char*) (node)) - offsetof(container, member)) - -#define qlist_for_each(node, list) \ - for (node = (list)->next; node != (list); node = node->next) - -#define qlist_empty(list) ((list) == (list)->next) -#define qlist_head(list) ((list)->next) -#define qlist_tail(list) ((list)->prev) - -typedef struct { - struct qlistnode qnode; - uint8_t ClientFd; - QCQMIMSG qmi[0]; -} QMI_PROXY_MSG; - -typedef struct { - struct qlistnode qnode; - uint8_t QMIType; - uint8_t ClientId; - unsigned AccessTime; -} QMI_PROXY_CLINET; - -typedef struct { - struct qlistnode qnode; - struct qlistnode client_qnode; - uint8_t ClientFd; - unsigned AccessTime; -} QMI_PROXY_CONNECTION; - -static int qmi_proxy_quit = 0; -static pthread_t thread_id = 0; -static int cdc_wdm_fd = -1; -static int qmi_proxy_server_fd = -1; -static struct qlistnode qmi_proxy_connection; -static struct qlistnode qmi_proxy_ctl_msg; -static PQCQMIMSG s_pCtlReq; -static PQCQMIMSG s_pCtlRsq; -static pthread_mutex_t s_ctlmutex = PTHREAD_MUTEX_INITIALIZER; -static pthread_cond_t s_ctlcond = PTHREAD_COND_INITIALIZER; -static int verbose_debug = 0; - -static void qlist_init(struct qlistnode *node) -{ - node->next = node; - node->prev = node; -} - -static void qlist_add_tail(struct qlistnode *head, struct qlistnode *item) -{ - item->next = head; - item->prev = head->prev; - head->prev->next = item; - head->prev = item; -} - -static void qlist_remove(struct qlistnode *item) -{ - item->next->prev = item->prev; - item->prev->next = item->next; -} - - - -static void setTimespecRelative(struct timespec *p_ts, long long msec) -{ - struct timeval tv; - - gettimeofday(&tv, (struct timezone *) NULL); - - /* what's really funny about this is that I know - pthread_cond_timedwait just turns around and makes this - a relative time again */ - p_ts->tv_sec = tv.tv_sec + (msec / 1000); - p_ts->tv_nsec = (tv.tv_usec + (msec % 1000) * 1000L ) * 1000L; -} - -static int pthread_cond_timeout_np(pthread_cond_t *cond, pthread_mutex_t * mutex, unsigned msecs) { - if (msecs != 0) { - struct timespec ts; - setTimespecRelative(&ts, msecs); - return pthread_cond_timedwait(cond, mutex, &ts); - } else { - return pthread_cond_wait(cond, mutex); - } -} - -static int create_local_server(const char *name) { - int sockfd = -1; - int reuse_addr = 1; - struct sockaddr_un sockaddr; - socklen_t alen; - - /*Create server socket*/ - SYSCHECK(sockfd = socket(AF_LOCAL, SOCK_STREAM, 0)); - - memset(&sockaddr, 0, sizeof(sockaddr)); - sockaddr.sun_family = AF_LOCAL; - sockaddr.sun_path[0] = 0; - memcpy(sockaddr.sun_path + 1, name, strlen(name) ); - - alen = strlen(name) + offsetof(struct sockaddr_un, sun_path) + 1; - SYSCHECK(setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &reuse_addr,sizeof(reuse_addr))); - if(bind(sockfd, (struct sockaddr *)&sockaddr, alen) < 0) { - close(sockfd); - dprintf("%s bind %s errno: %d (%s)\n", __func__, name, errno, strerror(errno)); - return -1; - } - - dprintf("local server: %s sockfd = %d\n", name, sockfd); - cfmakenoblock(sockfd); - listen(sockfd, 1); - - return sockfd; -} - -static void accept_qmi_connection(int serverfd) { - int clientfd = -1; - unsigned char addr[128]; - socklen_t alen = sizeof(addr); - QMI_PROXY_CONNECTION *qmi_con; - - clientfd = accept(serverfd, (struct sockaddr *)addr, &alen); - - qmi_con = (QMI_PROXY_CONNECTION *)malloc(sizeof(QMI_PROXY_CONNECTION)); - if (qmi_con) { - qlist_init(&qmi_con->qnode); - qlist_init(&qmi_con->client_qnode); - qmi_con->ClientFd= clientfd; - qmi_con->AccessTime = 0; - dprintf("+++ ClientFd=%d\n", qmi_con->ClientFd); - qlist_add_tail(&qmi_proxy_connection, &qmi_con->qnode); - } - - cfmakenoblock(clientfd); -} - -static void cleanup_qmi_connection(int clientfd) { - struct qlistnode *con_node, *qmi_node; - - qlist_for_each(con_node, &qmi_proxy_connection) { - QMI_PROXY_CONNECTION *qmi_con = qnode_to_item(con_node, QMI_PROXY_CONNECTION, qnode); - - if (qmi_con->ClientFd == clientfd) { - while (!qlist_empty(&qmi_con->client_qnode)) { - QMI_PROXY_CLINET *qmi_client = qnode_to_item(qlist_head(&qmi_con->client_qnode), QMI_PROXY_CLINET, qnode); - - dprintf("xxx ClientFd=%d QMIType=%d ClientId=%d\n", qmi_con->ClientFd, qmi_client->QMIType, qmi_client->ClientId); - - qlist_remove(&qmi_client->qnode); - free(qmi_client); - } - - qlist_for_each(qmi_node, &qmi_proxy_ctl_msg) { - QMI_PROXY_MSG *qmi_msg = qnode_to_item(qmi_node, QMI_PROXY_MSG, qnode); - - if (qmi_msg->ClientFd == qmi_con->ClientFd) { - qlist_remove(&qmi_msg->qnode); - free(qmi_msg); - break; - } - } - - dprintf("--- ClientFd=%d\n", qmi_con->ClientFd); - close(qmi_con->ClientFd); - qlist_remove(&qmi_con->qnode); - free(qmi_con); - break; - } - } -} - -static void get_client_id(QMI_PROXY_CONNECTION *qmi_con, PQMICTL_GET_CLIENT_ID_RESP_MSG pClient) { - if (pClient->QMIResult == 0 && pClient->QMIError == 0) { - QMI_PROXY_CLINET *qmi_client = (QMI_PROXY_CLINET *)malloc(sizeof(QMI_PROXY_CLINET)); - - qlist_init(&qmi_client->qnode); - qmi_client->QMIType = pClient->QMIType; - qmi_client->ClientId = pClient->ClientId; - qmi_client->AccessTime = 0; - - dprintf("+++ ClientFd=%d QMIType=%d ClientId=%d\n", qmi_con->ClientFd, qmi_client->QMIType, qmi_client->ClientId); - qlist_add_tail(&qmi_con->client_qnode, &qmi_client->qnode); - } -} - -static void release_client_id(QMI_PROXY_CONNECTION *qmi_con, PQMICTL_RELEASE_CLIENT_ID_RESP_MSG pClient) { - struct qlistnode *client_node; - - if (pClient->QMIResult == 0 && pClient->QMIError == 0) { - qlist_for_each (client_node, &qmi_con->client_qnode) { - QMI_PROXY_CLINET *qmi_client = qnode_to_item(client_node, QMI_PROXY_CLINET, qnode); - - if (pClient->QMIType == qmi_client->QMIType && pClient->ClientId == qmi_client->ClientId) { - dprintf("--- ClientFd=%d QMIType=%d ClientId=%d\n", qmi_con->ClientFd, qmi_client->QMIType, qmi_client->ClientId); - qlist_remove(&qmi_client->qnode); - free(qmi_client); - break; - } - } - } -} - - -static int send_qmi_to_cdc_wdm(PQCQMIMSG pQMI) { - struct pollfd pollfds[]= {{cdc_wdm_fd, POLLOUT, 0}}; - ssize_t ret = 0; - - do { - ret = poll(pollfds, sizeof(pollfds)/sizeof(pollfds[0]), 5000); - } while ((ret < 0) && (errno == EINTR)); - - if (pollfds[0].revents & POLLOUT) { - ssize_t size = le16_to_cpu(pQMI->QMIHdr.Length) + 1; - ret = write(cdc_wdm_fd, pQMI, size); - if (verbose_debug) - { - ssize_t i; - printf("w %d %zd: ", cdc_wdm_fd, ret); - for (i = 0; i < 16; i++) - printf("%02x ", ((uint8_t *)pQMI)[i]); - printf("\n"); - } - } - - return ret; -} - -static int send_qmi_to_client(PQCQMIMSG pQMI, int clientFd) { - struct pollfd pollfds[]= {{clientFd, POLLOUT, 0}}; - ssize_t ret = 0; - - do { - ret = poll(pollfds, sizeof(pollfds)/sizeof(pollfds[0]), 5000); - } while ((ret < 0) && (errno == EINTR)); - - if (pollfds[0].revents & POLLOUT) { - ssize_t size = le16_to_cpu(pQMI->QMIHdr.Length) + 1; - ret = write(clientFd, pQMI, size); - if (verbose_debug) - { - ssize_t i; - printf("w %d %zd: ", clientFd, ret); - for (i = 0; i < 16; i++) - printf("%02x ", ((uint8_t *)pQMI)[i]); - printf("\n"); - } - } - - return ret; -} - - -static void recv_qmi(PQCQMIMSG pQMI, unsigned size) { - struct qlistnode *con_node, *client_node; - - if (qmi_proxy_server_fd <= 0) { - pthread_mutex_lock(&s_ctlmutex); - - if (s_pCtlReq != NULL) { - if (pQMI->QMIHdr.QMIType == QMUX_TYPE_CTL - && s_pCtlReq->CTLMsg.QMICTLMsgHdrRsp.TransactionId == pQMI->CTLMsg.QMICTLMsgHdrRsp.TransactionId) { - s_pCtlRsq = malloc(size); - memcpy(s_pCtlRsq, pQMI, size); - pthread_cond_signal(&s_ctlcond); - } - else if (pQMI->QMIHdr.QMIType != QMUX_TYPE_CTL - && s_pCtlReq->MUXMsg.QMUXMsgHdr.TransactionId == pQMI->MUXMsg.QMUXMsgHdr.TransactionId) { - s_pCtlRsq = malloc(size); - memcpy(s_pCtlRsq, pQMI, size); - pthread_cond_signal(&s_ctlcond); - } - } - - pthread_mutex_unlock(&s_ctlmutex); - } - else if (pQMI->QMIHdr.QMIType == QMUX_TYPE_CTL) { - if (pQMI->CTLMsg.QMICTLMsgHdr.CtlFlags == QMICTL_CTL_FLAG_RSP) { - if (!qlist_empty(&qmi_proxy_ctl_msg)) { - QMI_PROXY_MSG *qmi_msg = qnode_to_item(qlist_head(&qmi_proxy_ctl_msg), QMI_PROXY_MSG, qnode); - - qlist_for_each(con_node, &qmi_proxy_connection) { - QMI_PROXY_CONNECTION *qmi_con = qnode_to_item(con_node, QMI_PROXY_CONNECTION, qnode); - - if (qmi_con->ClientFd == qmi_msg->ClientFd) { - send_qmi_to_client(pQMI, qmi_msg->ClientFd); - - if (pQMI->CTLMsg.QMICTLMsgHdrRsp.QMICTLType == QMICTL_GET_CLIENT_ID_RESP) - get_client_id(qmi_con, &pQMI->CTLMsg.GetClientIdRsp); - else if (pQMI->CTLMsg.QMICTLMsgHdrRsp.QMICTLType == QMICTL_RELEASE_CLIENT_ID_RESP) - release_client_id(qmi_con, &pQMI->CTLMsg.ReleaseClientIdRsp); - else { - } - } - } - - qlist_remove(&qmi_msg->qnode); - free(qmi_msg); - } - } - - if (!qlist_empty(&qmi_proxy_ctl_msg)) { - QMI_PROXY_MSG *qmi_msg = qnode_to_item(qlist_head(&qmi_proxy_ctl_msg), QMI_PROXY_MSG, qnode); - - qlist_for_each(con_node, &qmi_proxy_connection) { - QMI_PROXY_CONNECTION *qmi_con = qnode_to_item(con_node, QMI_PROXY_CONNECTION, qnode); - - if (qmi_con->ClientFd == qmi_msg->ClientFd) { - send_qmi_to_cdc_wdm(qmi_msg->qmi); - } - } - } - } - else { - qlist_for_each(con_node, &qmi_proxy_connection) { - QMI_PROXY_CONNECTION *qmi_con = qnode_to_item(con_node, QMI_PROXY_CONNECTION, qnode); - - qlist_for_each(client_node, &qmi_con->client_qnode) { - QMI_PROXY_CLINET *qmi_client = qnode_to_item(client_node, QMI_PROXY_CLINET, qnode); - if (pQMI->QMIHdr.QMIType == qmi_client->QMIType) { - if (pQMI->QMIHdr.ClientId == 0 || pQMI->QMIHdr.ClientId == qmi_client->ClientId) { - send_qmi_to_client(pQMI, qmi_con->ClientFd); - } - } - } - } - } -} - -static int send_qmi(PQCQMIMSG pQMI, unsigned size, int clientfd) { - if (qmi_proxy_server_fd <= 0) { - send_qmi_to_cdc_wdm(pQMI); - } - else if (pQMI->QMIHdr.QMIType == QMUX_TYPE_CTL) { - QMI_PROXY_MSG *qmi_msg; - - if (qlist_empty(&qmi_proxy_ctl_msg)) - send_qmi_to_cdc_wdm(pQMI); - - qmi_msg = malloc(sizeof(QMI_PROXY_MSG) + size); - qlist_init(&qmi_msg->qnode); - qmi_msg->ClientFd = clientfd; - memcpy(qmi_msg->qmi, pQMI, size); - qlist_add_tail(&qmi_proxy_ctl_msg, &qmi_msg->qnode); - } - else { - send_qmi_to_cdc_wdm(pQMI); - } - - return 0; -} - -static int send_qmi_timeout(PQCQMIMSG pRequest, PQCQMIMSG *ppResponse, unsigned mseconds) { - int ret; - - pthread_mutex_lock(&s_ctlmutex); - - s_pCtlReq = pRequest; - s_pCtlRsq = NULL; - if (ppResponse) *ppResponse = NULL; - - send_qmi_to_cdc_wdm(pRequest); - ret = pthread_cond_timeout_np(&s_ctlcond, &s_ctlmutex, mseconds); - if (!ret) { - if (s_pCtlRsq && ppResponse) { - *ppResponse = s_pCtlRsq; - } else if (s_pCtlRsq) { - free(s_pCtlRsq); - } - } else { - dprintf("%s ret=%d\n", __func__, ret); - } - - s_pCtlReq = NULL; - pthread_mutex_unlock(&s_ctlmutex); - - return ret; -} - -static PQCQMUX_TLV qmi_find_tlv (PQCQMIMSG pQMI, uint8_t TLVType) { - int Length = 0; - - while (Length < le16_to_cpu(pQMI->MUXMsg.QMUXMsgHdr.Length)) { - PQCQMUX_TLV pTLV = (PQCQMUX_TLV)(&pQMI->MUXMsg.QMUXMsgHdr.payload[Length]); - - //dprintf("TLV {%02x, %04x}\n", pTLV->Type, pTLV->Length); - if (pTLV->Type == TLVType) { - return pTLV; - } - - Length += (le16_to_cpu((pTLV->Length)) + sizeof(QCQMUX_TLV)); - } - - return NULL; -} - -static int qmi_proxy_init(char *qmi_device, char* getidproduct) { - unsigned i; - int ret; - QCQMIMSG _QMI; - PQCQMIMSG pQMI = &_QMI; - PQCQMIMSG pRsp; - uint8_t TransactionId = 0xC1; - uint8_t WDAClientId = 0; - unsigned rx_urb_size = 0; - unsigned ep_type, iface_id; - - dprintf("%s enter\n", __func__); - - pQMI->QMIHdr.IFType = USB_CTL_MSG_TYPE_QMI; - pQMI->QMIHdr.CtlFlags = 0x00; - pQMI->QMIHdr.QMIType = QMUX_TYPE_CTL; - pQMI->QMIHdr.ClientId= 0x00; - - pQMI->CTLMsg.QMICTLMsgHdr.CtlFlags = QMICTL_FLAG_REQUEST; - - for (i = 0; i < 10; i++) { - pQMI->CTLMsg.SyncReq.TransactionId = TransactionId++; - pQMI->CTLMsg.SyncReq.QMICTLType = QMICTL_SYNC_REQ; - pQMI->CTLMsg.SyncReq.Length = 0; - - pQMI->QMIHdr.Length = pQMI->CTLMsg.QMICTLMsgHdr.Length + sizeof(QCQMI_HDR) + sizeof(QCQMICTL_MSG_HDR) - 1; - - ret = send_qmi_timeout(pQMI, NULL, 1000); - if (!ret) - break; - } - - if (ret) - goto qmi_proxy_init_fail; - - pQMI->CTLMsg.GetVersionReq.TransactionId = TransactionId++; - pQMI->CTLMsg.GetVersionReq.QMICTLType = QMICTL_GET_VERSION_REQ; - pQMI->CTLMsg.GetVersionReq.Length = 0x0004; - pQMI->CTLMsg.GetVersionReq.TLVType= QCTLV_TYPE_REQUIRED_PARAMETER; - pQMI->CTLMsg.GetVersionReq.TLVLength = 0x0001; - pQMI->CTLMsg.GetVersionReq.QMUXTypes = QMUX_TYPE_ALL; - - pQMI->QMIHdr.Length = pQMI->CTLMsg.QMICTLMsgHdr.Length + sizeof(QCQMI_HDR) + sizeof(QCQMICTL_MSG_HDR) - 1; - - ret = send_qmi_timeout(pQMI, &pRsp, 3000); - if (ret || (pRsp == NULL)) - goto qmi_proxy_init_fail; - - if (pRsp) { - uint8_t NumElements = 0; - if (pRsp->CTLMsg.QMICTLMsgHdrRsp.QMUXResult ||pRsp->CTLMsg.QMICTLMsgHdrRsp.QMUXError) { - dprintf("QMICTL_GET_VERSION_REQ QMUXResult=%d, QMUXError=%d\n", - pRsp->CTLMsg.QMICTLMsgHdrRsp.QMUXResult, pRsp->CTLMsg.QMICTLMsgHdrRsp.QMUXError); - goto qmi_proxy_init_fail; - } - - for (NumElements = 0; NumElements < pRsp->CTLMsg.GetVersionRsp.NumElements; NumElements++) { - if (verbose_debug) - dprintf("QMUXType = %02x Version = %d.%d\n", - pRsp->CTLMsg.GetVersionRsp.TypeVersion[NumElements].QMUXType, - pRsp->CTLMsg.GetVersionRsp.TypeVersion[NumElements].MajorVersion, - pRsp->CTLMsg.GetVersionRsp.TypeVersion[NumElements].MinorVersion); - } - } - free(pRsp); - - pQMI->CTLMsg.GetClientIdReq.TransactionId = TransactionId++; - pQMI->CTLMsg.GetClientIdReq.QMICTLType = QMICTL_GET_CLIENT_ID_REQ; - pQMI->CTLMsg.GetClientIdReq.Length = 0x0004; - pQMI->CTLMsg.GetClientIdReq.TLVType= QCTLV_TYPE_REQUIRED_PARAMETER; - pQMI->CTLMsg.GetClientIdReq.TLVLength = 0x0001; - pQMI->CTLMsg.GetClientIdReq.QMIType = QMUX_TYPE_WDS_ADMIN; - - pQMI->QMIHdr.Length = pQMI->CTLMsg.QMICTLMsgHdr.Length + sizeof(QCQMI_HDR) + sizeof(QCQMICTL_MSG_HDR) - 1; - - ret = send_qmi_timeout(pQMI, &pRsp, 3000); - if (ret || (pRsp == NULL)) - goto qmi_proxy_init_fail; - - if (pRsp) { - if (pRsp->CTLMsg.QMICTLMsgHdrRsp.QMUXResult ||pRsp->CTLMsg.QMICTLMsgHdrRsp.QMUXError) { - dprintf("QMICTL_GET_CLIENT_ID_REQ QMUXResult=%d, QMUXError=%d\n", - pRsp->CTLMsg.QMICTLMsgHdrRsp.QMUXResult, pRsp->CTLMsg.QMICTLMsgHdrRsp.QMUXError); - goto qmi_proxy_init_fail; - } - - WDAClientId = pRsp->CTLMsg.GetClientIdRsp.ClientId; - if (verbose_debug) dprintf("WDAClientId = %d\n", WDAClientId); - } - free(pRsp); - - if(qmidev_is_pciemhi(qmi_device)) - { - rx_urb_size = 32*1024; //must same as rx_urb_size defined in GobiNet&qmi_wwan driver //SDX24&SDX55 support 32KB - ep_type = 0x03; - } - else - { - rx_urb_size = 4*1024; //must same as rx_urb_size defined in GobiNet&qmi_wwan driver //SDX24&SDX55 support 32KB - ep_type = 0x02; - } - - printf("getidproduct=%s\n", getidproduct); - if(!strncasecmp(getidproduct, "0104", 4)|| !strncasecmp(getidproduct, "1001", 4) || !strncasecmp(getidproduct, "9025", 4)) - iface_id = 0x04; - else if(!strncasecmp(getidproduct, "0109", 4) || !strncasecmp(getidproduct, "1000", 4)) - iface_id = 0x02; - else if(!strncasecmp(getidproduct, "0113", 4)) - iface_id = 0x00; - - /*begin added by minchao.zhao@fibocom.com for mantis 91283 on 2021-09-27*/ - if(qmidev_is_pciemhi(qmi_device)) - iface_id = 0x04; //mhi_QMI0 enumeration arrangement - /*end added by minchao.zhao@fibocom.com for mantis 91283 on 2021-09-27*/ - printf("iface_id=%d\n", iface_id); - - pQMI->QMIHdr.IFType = USB_CTL_MSG_TYPE_QMI; - pQMI->QMIHdr.CtlFlags = 0x00; - pQMI->QMIHdr.QMIType = QMUX_TYPE_WDS_ADMIN; - pQMI->QMIHdr.ClientId= WDAClientId; - - pQMI->MUXMsg.QMUXMsgHdr.CtlFlags = QMICTL_FLAG_REQUEST; - pQMI->MUXMsg.QMUXMsgHdr.TransactionId = TransactionId++; - - pQMI->MUXMsg.SetDataFormatReq.Type = QMIWDS_ADMIN_SET_DATA_FORMAT_REQ; - pQMI->MUXMsg.SetDataFormatReq.Length = sizeof(QMIWDS_ADMIN_SET_DATA_FORMAT_REQ_MSG) - sizeof(QCQMUX_MSG_HDR); - -//Indicates whether the Quality of Service(QOS) data format is used by the client. - pQMI->MUXMsg.SetDataFormatReq.QosDataFormatTlv.TLVType = 0x10; - pQMI->MUXMsg.SetDataFormatReq.QosDataFormatTlv.TLVLength = cpu_to_le16(0x0001); - pQMI->MUXMsg.SetDataFormatReq.QosDataFormatTlv.QOSSetting = 0; /* no-QOS header */ -//Underlying Link Layer Protocol - pQMI->MUXMsg.SetDataFormatReq.UnderlyingLinkLayerProtocolTlv.TLVType = 0x11; - pQMI->MUXMsg.SetDataFormatReq.UnderlyingLinkLayerProtocolTlv.TLVLength = cpu_to_le16(4); - pQMI->MUXMsg.SetDataFormatReq.UnderlyingLinkLayerProtocolTlv.Value = cpu_to_le32(0x02); /* Set IP mode */ -//Uplink (UL) data aggregation protocol to be used for uplink data transfer. - pQMI->MUXMsg.SetDataFormatReq.UplinkDataAggregationProtocolTlv.TLVType = 0x12; - pQMI->MUXMsg.SetDataFormatReq.UplinkDataAggregationProtocolTlv.TLVLength = cpu_to_le16(4); - pQMI->MUXMsg.SetDataFormatReq.UplinkDataAggregationProtocolTlv.Value = cpu_to_le32(0x05); //UL QMAP is enabled -//Downlink (DL) data aggregation protocol to be used for downlink data transfer - pQMI->MUXMsg.SetDataFormatReq.DownlinkDataAggregationProtocolTlv.TLVType = 0x13; - pQMI->MUXMsg.SetDataFormatReq.DownlinkDataAggregationProtocolTlv.TLVLength = cpu_to_le16(4); - pQMI->MUXMsg.SetDataFormatReq.DownlinkDataAggregationProtocolTlv.Value = cpu_to_le32(0x05); //UL QMAP is enabled -//Maximum number of datagrams in a single aggregated packet on downlink - pQMI->MUXMsg.SetDataFormatReq.DownlinkDataAggregationMaxDatagramsTlv.TLVType = 0x15; - pQMI->MUXMsg.SetDataFormatReq.DownlinkDataAggregationMaxDatagramsTlv.TLVLength = cpu_to_le16(4); - if(qmidev_is_pciemhi(qmi_device)) - { - pQMI->MUXMsg.SetDataFormatReq.DownlinkDataAggregationMaxDatagramsTlv.Value = cpu_to_le32((rx_urb_size>2048)?(rx_urb_size/512):1); - } - else - { - pQMI->MUXMsg.SetDataFormatReq.DownlinkDataAggregationMaxDatagramsTlv.Value = cpu_to_le32((rx_urb_size>2048)?(rx_urb_size/1024):1); - } -//Maximum size in bytes of a single aggregated packet allowed on downlink - pQMI->MUXMsg.SetDataFormatReq.DownlinkDataAggregationMaxSizeTlv.TLVType = 0x16; - pQMI->MUXMsg.SetDataFormatReq.DownlinkDataAggregationMaxSizeTlv.TLVLength = cpu_to_le16(4); - pQMI->MUXMsg.SetDataFormatReq.DownlinkDataAggregationMaxSizeTlv.Value = cpu_to_le32(rx_urb_size); -//Peripheral End Point ID - pQMI->MUXMsg.SetDataFormatReq.epTlv.TLVType = 0x17; - pQMI->MUXMsg.SetDataFormatReq.epTlv.TLVLength = cpu_to_le16(8); - pQMI->MUXMsg.SetDataFormatReq.epTlv.ep_type = cpu_to_le32(ep_type); // DATA_EP_TYPE_BAM_DMUX - pQMI->MUXMsg.SetDataFormatReq.epTlv.iface_id = cpu_to_le32(iface_id); - - pQMI->QMIHdr.Length = pQMI->MUXMsg.QMUXMsgHdr.Length + sizeof(QCQMI_HDR) + sizeof(QCQMUX_MSG_HDR) - 1; - - ret = send_qmi_timeout(pQMI, &pRsp, 3000); - if (ret || (pRsp == NULL)) - goto qmi_proxy_init_fail; - - if (pRsp) { - PQMIWDS_ADMIN_SET_DATA_FORMAT_TLV pFormat; - - if (pRsp->MUXMsg.QMUXMsgHdrResp.QMUXResult || pRsp->MUXMsg.QMUXMsgHdrResp.QMUXError) { - dprintf("QMIWDS_ADMIN_SET_DATA_FORMAT_REQ QMUXResult=%d, QMUXError=%d\n", - pRsp->MUXMsg.QMUXMsgHdrResp.QMUXResult, pRsp->MUXMsg.QMUXMsgHdrResp.QMUXError); - goto qmi_proxy_init_fail; - } - - pFormat = (PQMIWDS_ADMIN_SET_DATA_FORMAT_TLV)qmi_find_tlv(pRsp, 0x11); - if (pFormat) - dprintf("link_prot %d\n", le32_to_cpu(pFormat->Value)); - pFormat = (PQMIWDS_ADMIN_SET_DATA_FORMAT_TLV)qmi_find_tlv(pRsp, 0x12); - if (pFormat) - dprintf("ul_data_aggregation_protocol %d\n", le32_to_cpu(pFormat->Value)); - pFormat = (PQMIWDS_ADMIN_SET_DATA_FORMAT_TLV)qmi_find_tlv(pRsp, 0x13); - if (pFormat) - dprintf("dl_data_aggregation_protocol %d\n", le32_to_cpu(pFormat->Value)); - pFormat = (PQMIWDS_ADMIN_SET_DATA_FORMAT_TLV)qmi_find_tlv(pRsp, 0x15); - if (pFormat) - dprintf("dl_data_aggregation_max_datagrams %d\n", le32_to_cpu(pFormat->Value)); - pFormat = (PQMIWDS_ADMIN_SET_DATA_FORMAT_TLV)qmi_find_tlv(pRsp, 0x16); - if (pFormat) { - dprintf("dl_data_aggregation_max_size %d\n", le32_to_cpu(pFormat->Value)); - rx_urb_size = le32_to_cpu(pFormat->Value); - } - pFormat = (PQMIWDS_ADMIN_SET_DATA_FORMAT_TLV)qmi_find_tlv(pRsp, 0x17); - if (pFormat) - dprintf("ul_data_aggregation_max_datagrams %d\n", le32_to_cpu(pFormat->Value)); - pFormat = (PQMIWDS_ADMIN_SET_DATA_FORMAT_TLV)qmi_find_tlv(pRsp, 0x18); - if (pFormat) - dprintf("ul_data_aggregation_max_size %d\n", le32_to_cpu(pFormat->Value)); - } - free(pRsp); - - dprintf("%s finished, rx_urb_size is %u\n", __func__, rx_urb_size); - return 0; - -qmi_proxy_init_fail: - dprintf("%s failed\n", __func__); - return -1; -} -//2021-06-03 willa.liu@fibocom.com changed begin -static void qmi_start_server(void) { - qmi_proxy_server_fd = create_local_server("fibo_qmimsg_server"); - printf("%s: qmi_proxy_server_fd = %d\n", __func__, qmi_proxy_server_fd); - if (qmi_proxy_server_fd == -1) { - dprintf("%s Failed to create %s, errno: %d (%s)\n", __func__, "fibocom-qmi-proxy", errno, strerror(errno)); - } -} - -static void qmi_close_server(void) { - if (qmi_proxy_server_fd != -1) { - dprintf("%s %s close server\n", __func__, "fibocom-qmi-proxy"); - close(qmi_proxy_server_fd); - qmi_proxy_server_fd = -1; - } -} -//2021-06-03 willa.liu@fibocom.com changed end -static void *qmi_proxy_loop(void *param) -{ - static uint8_t qmi_buf[2048]; - PQCQMIMSG pQMI = (PQCQMIMSG)qmi_buf; - struct qlistnode *con_node; - QMI_PROXY_CONNECTION *qmi_con; - - dprintf("%s enter thread_id %ld\n", __func__, pthread_self()); - - qlist_init(&qmi_proxy_connection); - qlist_init(&qmi_proxy_ctl_msg); - - while (cdc_wdm_fd > 0 && qmi_proxy_quit == 0) { - struct pollfd pollfds[2+64]; - int ne, ret, nevents = 0; - ssize_t nreads; - - pollfds[nevents].fd = cdc_wdm_fd; - pollfds[nevents].events = POLLIN; - pollfds[nevents].revents= 0; - nevents++; - - if (qmi_proxy_server_fd > 0) { - pollfds[nevents].fd = qmi_proxy_server_fd; - pollfds[nevents].events = POLLIN; - pollfds[nevents].revents= 0; - nevents++; - } - - qlist_for_each(con_node, &qmi_proxy_connection) { - qmi_con = qnode_to_item(con_node, QMI_PROXY_CONNECTION, qnode); - - pollfds[nevents].fd = qmi_con->ClientFd; - pollfds[nevents].events = POLLIN; - pollfds[nevents].revents= 0; - nevents++; - - if (nevents == (sizeof(pollfds)/sizeof(pollfds[0]))) - break; - } - - do { - //ret = poll(pollfds, nevents, -1); - ret = poll(pollfds, nevents, (qmi_proxy_server_fd > 0) ? -1 : 200); - } while (ret < 0 && errno == EINTR && qmi_proxy_quit == 0); - - if (ret < 0) { - dprintf("%s poll=%d, errno: %d (%s)\n", __func__, ret, errno, strerror(errno)); - goto qmi_proxy_loop_exit; - } - - for (ne = 0; ne < nevents; ne++) { - int fd = pollfds[ne].fd; - short revents = pollfds[ne].revents; - - if (revents & (POLLERR | POLLHUP | POLLNVAL)) { - dprintf("%s poll fd = %d, revents = %04x\n", __func__, fd, revents); - if (fd == cdc_wdm_fd) { - goto qmi_proxy_loop_exit; - } else if(fd == qmi_proxy_server_fd) { - - } else { - cleanup_qmi_connection(fd); - } - - continue; - } - - if (!(pollfds[ne].revents & POLLIN)) { - continue; - } - - if (fd == qmi_proxy_server_fd) { - accept_qmi_connection(fd); - } - else if (fd == cdc_wdm_fd) { - nreads = read(fd, pQMI, sizeof(qmi_buf)); - if (verbose_debug) - { - ssize_t i; - printf("r %d %zd: ", fd, nreads); - for (i = 0; i < 16; i++) - printf("%02x ", ((uint8_t *)pQMI)[i]); - printf("\n"); - } - if (nreads <= 0) { - dprintf("%s read=%d errno: %d (%s)\n", __func__, (int)nreads, errno, strerror(errno)); - goto qmi_proxy_loop_exit; - } - - if (nreads != ((pQMI->QMIHdr.Length) + 1)) { - dprintf("%s nreads=%d, pQCQMI->QMIHdr.Length = %d\n", __func__, (int)nreads, (pQMI->QMIHdr.Length)); - continue; - } - - recv_qmi(pQMI, nreads); - } - else { - nreads = read(fd, pQMI, sizeof(qmi_buf)); - if (verbose_debug) - { - ssize_t i; - printf("r %d %zd: ", fd, nreads); - for (i = 0; i < 16; i++) - printf("%02x ", ((uint8_t *)pQMI)[i]); - printf("\n"); - } - if (nreads <= 0) { - dprintf("%s read=%d errno: %d (%s)", __func__, (int)nreads, errno, strerror(errno)); - cleanup_qmi_connection(fd); - break; - } - - if (nreads != ((pQMI->QMIHdr.Length) + 1)) { - dprintf("%s nreads=%d, pQCQMI->QMIHdr.Length = %d\n", __func__, (int)nreads, (pQMI->QMIHdr.Length)); - continue; - } - - send_qmi(pQMI, nreads, fd); - } - } - } - -qmi_proxy_loop_exit: - while (!qlist_empty(&qmi_proxy_connection)) { - QMI_PROXY_CONNECTION *qmi_con = qnode_to_item(qlist_head(&qmi_proxy_connection), QMI_PROXY_CONNECTION, qnode); - - cleanup_qmi_connection(qmi_con->ClientFd); - } - - dprintf("%s exit, thread_id %ld\n", __func__, pthread_self()); - - return NULL; -} - -static void qmidevice_detect(char **device_name, char **idproduct) { - struct dirent* ent = NULL; - DIR *pDir; - - char dir[255] = "/sys/bus/usb/devices"; - pDir = opendir(dir); - if (pDir) { - struct { - char subdir[255 * 2]; - char qmifile[255 * 2]; - } *pl; - pl = (typeof(pl)) malloc(sizeof(*pl)); - memset(pl, 0x00, sizeof(*pl)); - - while ((ent = readdir(pDir)) != NULL) { - struct dirent* subent = NULL; - DIR *psubDir; - char idVendor[4+1] = {0}; - char idProduct[4+1] = {0}; - int fd = 0; - - memset(pl, 0x00, sizeof(*pl)); - snprintf(pl->subdir, sizeof(pl->subdir), "%s/%s/idVendor", dir, ent->d_name); - fd = open(pl->subdir, O_RDONLY); - if (fd > 0) { - read(fd, idVendor, 4); - close(fd); - } - - snprintf(pl->subdir, sizeof(pl->subdir), "%s/%s/idProduct", dir, ent->d_name); - fd = open(pl->subdir, O_RDONLY); - if (fd > 0) { - read(fd, idProduct, 4); - close(fd); - } - - - if (strncasecmp(idVendor, "05c6", 4) && strncasecmp(idVendor, "2cb7", 4) && strncasecmp(idVendor, "1508", 4)) - continue; - - dprintf("Find %s/%s idVendor=%s idProduct=%s\n", dir, ent->d_name, idVendor, idProduct); - - if(((!strncasecmp(idVendor, "2cb7", 4)) && (!strncasecmp(idProduct, "0104", 4))) || ((!strncasecmp(idVendor, "1508", 4)) && (!strncasecmp(idProduct, "1001", 4))) || ((!strncasecmp(idVendor, "05c6", 4)) && (!strncasecmp(idProduct, "9025", 4)))) - { - snprintf(pl->subdir, sizeof(pl->subdir), "%s/%s:1.4/usbmisc", dir, ent->d_name); - if (access(pl->subdir, R_OK)) { - snprintf(pl->subdir, sizeof(pl->subdir), "%s/%s:1.4/usb", dir, ent->d_name); - if (access(pl->subdir, R_OK)) { - dprintf("no GobiQMI/usbmic/usb found in %s/%s:1.4\n", dir, ent->d_name); - continue; - } - } - } - else if((!strncasecmp(idVendor, "2cb7", 4) && !strncasecmp(idProduct, "0109", 4)) || (!strncasecmp(idVendor, "1508", 4) && !strncasecmp(idProduct, "1000", 4))) - { - snprintf(pl->subdir, sizeof(pl->subdir), "%s/%s:1.2/usbmisc", dir, ent->d_name); - if (access(pl->subdir, R_OK)) { - snprintf(pl->subdir, sizeof(pl->subdir), "%s/%s:1.2/usb", dir, ent->d_name); - if (access(pl->subdir, R_OK)) { - dprintf("no GobiQMI/usbmic/usb found in %s/%s:1.2\n", dir, ent->d_name); - continue; - } - } - } - else if(!strncasecmp(idVendor, "2cb7", 4) && !strncasecmp(idProduct, "0113", 4)) - { - snprintf(pl->subdir, sizeof(pl->subdir), "%s/%s:1.0/usbmisc", dir, ent->d_name); - if (access(pl->subdir, R_OK)) { - snprintf(pl->subdir, sizeof(pl->subdir), "%s/%s:1.0/usb", dir, ent->d_name); - if (access(pl->subdir, R_OK)) { - dprintf("no GobiQMI/usbmic/usb found in %s/%s:1.0\n", dir, ent->d_name); - continue; - } - } - } - - strncpy(idproduct,idProduct, sizeof(idProduct)); - psubDir = opendir(pl->subdir); - if (pDir == NULL) { - dprintf("Cannot open directory: %s, errno: %d (%s)\n", dir, errno, strerror(errno)); - continue; - } - - while ((subent = readdir(psubDir)) != NULL) { - if (subent->d_name[0] == '.') - continue; - dprintf("Find %s/%s\n", pl->subdir, subent->d_name); - snprintf(pl->qmifile, sizeof(pl->qmifile), "/dev/%s", subent->d_name); - break; - } - *device_name = strdup(pl->qmifile); - closedir(psubDir); - } - closedir(pDir); - free(pl); - } -} - -static void usage(void) { - dprintf(" -d A valid qmi device\n" - " default /dev/cdc-wdm0, but cdc-wdm0 may be invalid\n" - " -v Will show all details\n"); -} - -static void sig_action(int sig) { - if (qmi_proxy_quit == 0) { - qmi_proxy_quit = 1; - if (thread_id) - pthread_kill(thread_id, sig); - } -} - -int main(int argc, char *argv[]) { - int opt; - char *cdc_wdm = NULL; - int retry_times = 0; - char getidproduct[5] = {0}; - optind = 1; - - signal(SIGINT, sig_action); - - while ( -1 != (opt = getopt(argc, argv, "d:v"))) { - switch (opt) { - case 'd': - cdc_wdm = strdup(optarg); - break; - case 'v': - verbose_debug = 1; - break; - default: - usage(); - break; - } - } - - if (cdc_wdm == NULL) - qmidevice_detect(&cdc_wdm, &getidproduct); - if (cdc_wdm == NULL) { - dprintf("Fail to find any /dev/cdc-wdm device. break\n"); - return -1; - } - - if (access(cdc_wdm, R_OK | W_OK)) { - dprintf("Fail to access %s, errno: %d (%s). break\n", cdc_wdm, errno, strerror(errno)); - free(cdc_wdm); - return -1; - } - - while (qmi_proxy_quit == 0) { - if (access(cdc_wdm, R_OK | W_OK)) { - dprintf("Fail to access %s, errno: %d (%s). continue\n", cdc_wdm, errno, strerror(errno)); - // wait device - sleep(3); - continue; - } - - dprintf("Will use cdc-wdm %s\n", cdc_wdm); - - cdc_wdm_fd = open(cdc_wdm, O_RDWR | O_NONBLOCK | O_NOCTTY); - if (cdc_wdm_fd == -1) { - dprintf("Failed to open %s, errno: %d (%s). break\n", cdc_wdm, errno, strerror(errno)); - return -1; - } - cfmakenoblock(cdc_wdm_fd); - - /* no qmi_proxy_loop lives, create one */ - pthread_create(&thread_id, NULL, qmi_proxy_loop, NULL); - /* try to redo init if failed, init function must be successfully */ - while (qmi_proxy_init(cdc_wdm, getidproduct) != 0) { - if (retry_times < 5) { - dprintf("fail to init proxy, try again in 2 seconds.\n"); - sleep(2); - retry_times++; - } else { - dprintf("has failed too much times, restart the modem and have a try...\n"); - break; - } - /* break loop if modem is detached */ - if (access(cdc_wdm, F_OK|R_OK|W_OK)) - break; - } - retry_times = 0; - qmi_start_server(); - pthread_join(thread_id, NULL); - - /* close local server at last */ - qmi_close_server(); - close(cdc_wdm_fd); - } - - if (cdc_wdm) { - free(cdc_wdm); - } - return 0; -} diff --git a/fibocom-dial/src/libmnl/README b/fibocom-dial/src/libmnl/README deleted file mode 100644 index fbac9d2..0000000 --- a/fibocom-dial/src/libmnl/README +++ /dev/null @@ -1,28 +0,0 @@ -= What is libmnl? = - -libmnl is a minimalistic user-space library oriented to Netlink developers. -There are a lot of common tasks in parsing, validating, constructing of -both the Netlink header and TLVs that are repetitive and easy to get wrong. -This library aims to provide simple helpers that allows you to re-use code -and to avoid re-inventing the wheel. The main features of this library are: - -* Small: the shared library requires around 30KB for an x86-based computer. -* Simple: this library avoids complexity and elaborated abstractions that -tend to hide Netlink details. -* Easy to use: the library simplifies the work for Netlink-wise developers. -It provides functions to make socket handling, message building, validating, -parsing and sequence tracking, easier. -* Easy to re-use: you can use the library to build your own abstraction layer -on top of this library. -* Decoupling: the interdependency of the main bricks that compose the library -is reduced, i.e. the library provides many helpers, but the programmer is not -forced to use them. - -= Example files = - -You can find several example files under examples/ that you can compile by -invoking `make check'. - --- -08/sep/2010 -Pablo Neira Ayuso diff --git a/fibocom-dial/src/libmnl/attr.c b/fibocom-dial/src/libmnl/attr.c deleted file mode 100644 index 30eb537..0000000 --- a/fibocom-dial/src/libmnl/attr.c +++ /dev/null @@ -1,722 +0,0 @@ -/* - * (C) 2008-2012 by Pablo Neira Ayuso - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - */ -#include /* for INT_MAX */ -#include -#include - -#include "libmnl.h" - -/** - * \defgroup attr Netlink attribute helpers - * - * Netlink Type-Length-Value (TLV) attribute: - * \verbatim - |<-- 2 bytes -->|<-- 2 bytes -->|<-- variable -->| - ------------------------------------------------- - | length | type | value | - ------------------------------------------------- - |<--------- header ------------>|<-- payload --->| -\endverbatim - * The payload of the Netlink message contains sequences of attributes that are - * expressed in TLV format. - * - * @{ - */ - -/** - * mnl_attr_get_type - get type of netlink attribute - * \param attr pointer to netlink attribute - * - * This function returns the attribute type. - */ -uint16_t mnl_attr_get_type(const struct nlattr *attr) -{ - return attr->nla_type & NLA_TYPE_MASK; -} - -/** - * mnl_attr_get_len - get length of netlink attribute - * \param attr pointer to netlink attribute - * - * This function returns the attribute length that is the attribute header - * plus the attribute payload. - */ -uint16_t mnl_attr_get_len(const struct nlattr *attr) -{ - return attr->nla_len; -} - -/** - * mnl_attr_get_payload_len - get the attribute payload-value length - * \param attr pointer to netlink attribute - * - * This function returns the attribute payload-value length. - */ -uint16_t mnl_attr_get_payload_len(const struct nlattr *attr) -{ - return attr->nla_len - MNL_ATTR_HDRLEN; -} - -/** - * mnl_attr_get_payload - get pointer to the attribute payload - * \param attr pointer to netlink attribute - * - * This function return a pointer to the attribute payload. - */ -void *mnl_attr_get_payload(const struct nlattr *attr) -{ - return (void *)attr + MNL_ATTR_HDRLEN; -} - -/** - * mnl_attr_ok - check if there is room for an attribute in a buffer - * \param attr attribute that we want to check if there is room for - * \param len remaining bytes in a buffer that contains the attribute - * - * This function is used to check that a buffer, which is supposed to contain - * an attribute, has enough room for the attribute that it stores, i.e. this - * function can be used to verify that an attribute is neither malformed nor - * truncated. - * - * This function does not set errno in case of error since it is intended - * for iterations. Thus, it returns true on success and false on error. - * - * The len parameter may be negative in the case of malformed messages during - * attribute iteration, that is why we use a signed integer. - */ -bool mnl_attr_ok(const struct nlattr *attr, int len) -{ - return len >= (int)sizeof(struct nlattr) && - attr->nla_len >= sizeof(struct nlattr) && - (int)attr->nla_len <= len; -} - -/** - * mnl_attr_next - get the next attribute in the payload of a netlink message - * \param attr pointer to the current attribute - * - * This function returns a pointer to the next attribute after the one passed - * as parameter. You have to use mnl_attr_ok() to ensure that the next - * attribute is valid. - */ -struct nlattr *mnl_attr_next(const struct nlattr *attr) -{ - return (struct nlattr *)((void *)attr + MNL_ALIGN(attr->nla_len)); -} - -/** - * mnl_attr_type_valid - check if the attribute type is valid - * \param attr pointer to attribute to be checked - * \param max maximum attribute type - * - * This function allows to check if the attribute type is higher than the - * maximum supported type. If the attribute type is invalid, this function - * returns -1 and errno is explicitly set. On success, this function returns 1. - * - * Strict attribute checking in user-space is not a good idea since you may - * run an old application with a newer kernel that supports new attributes. - * This leads to backward compatibility breakages in user-space. Better check - * if you support an attribute, if not, skip it. - */ -int mnl_attr_type_valid(const struct nlattr *attr, uint16_t max) -{ - if (mnl_attr_get_type(attr) > max) { - errno = EOPNOTSUPP; - return -1; - } - return 1; -} - -static int __mnl_attr_validate(const struct nlattr *attr, - enum mnl_attr_data_type type, size_t exp_len) -{ - uint16_t attr_len = mnl_attr_get_payload_len(attr); - const char *attr_data = mnl_attr_get_payload(attr); - - if (attr_len < exp_len) { - errno = ERANGE; - return -1; - } - switch(type) { - case MNL_TYPE_FLAG: - if (attr_len > 0) { - errno = ERANGE; - return -1; - } - break; - case MNL_TYPE_NUL_STRING: - if (attr_len == 0) { - errno = ERANGE; - return -1; - } - if (attr_data[attr_len-1] != '\0') { - errno = EINVAL; - return -1; - } - break; - case MNL_TYPE_STRING: - if (attr_len == 0) { - errno = ERANGE; - return -1; - } - break; - case MNL_TYPE_NESTED: - /* empty nested attributes are OK. */ - if (attr_len == 0) - break; - /* if not empty, they must contain one header, eg. flag */ - if (attr_len < MNL_ATTR_HDRLEN) { - errno = ERANGE; - return -1; - } - break; - default: - /* make gcc happy. */ - break; - } - if (exp_len && attr_len > exp_len) { - errno = ERANGE; - return -1; - } - return 0; -} - -static const size_t mnl_attr_data_type_len[MNL_TYPE_MAX] = { - [MNL_TYPE_U8] = sizeof(uint8_t), - [MNL_TYPE_U16] = sizeof(uint16_t), - [MNL_TYPE_U32] = sizeof(uint32_t), - [MNL_TYPE_U64] = sizeof(uint64_t), - [MNL_TYPE_MSECS] = sizeof(uint64_t), -}; - -/** - * mnl_attr_validate - validate netlink attribute (simplified version) - * \param attr pointer to netlink attribute that we want to validate - * \param type data type (see enum mnl_attr_data_type) - * - * The validation is based on the data type. Specifically, it checks that - * integers (u8, u16, u32 and u64) have enough room for them. This function - * returns -1 in case of error, and errno is explicitly set. - */ -int mnl_attr_validate(const struct nlattr *attr, enum mnl_attr_data_type type) -{ - int exp_len; - - if (type >= MNL_TYPE_MAX) { - errno = EINVAL; - return -1; - } - exp_len = mnl_attr_data_type_len[type]; - return __mnl_attr_validate(attr, type, exp_len); -} - -/** - * mnl_attr_validate2 - validate netlink attribute (extended version) - * \param attr pointer to netlink attribute that we want to validate - * \param type attribute type (see enum mnl_attr_data_type) - * \param exp_len expected attribute data size - * - * This function allows to perform a more accurate validation for attributes - * whose size is variable. If the size of the attribute is not what we expect, - * this functions returns -1 and errno is explicitly set. - */ -int mnl_attr_validate2(const struct nlattr *attr, - enum mnl_attr_data_type type, - size_t exp_len) -{ - if (type >= MNL_TYPE_MAX) { - errno = EINVAL; - return -1; - } - return __mnl_attr_validate(attr, type, exp_len); -} - -/** - * mnl_attr_parse - parse attributes - * \param nlh pointer to netlink message - * \param offset offset to start parsing from (if payload is after any header) - * \param cb callback function that is called for each attribute - * \param data pointer to data that is passed to the callback function - * - * This function allows to iterate over the sequence of attributes that compose - * the Netlink message. You can then put the attribute in an array as it - * usually happens at this stage or you can use any other data structure (such - * as lists or trees). - * - * This function propagates the return value of the callback, which can be - * MNL_CB_ERROR, MNL_CB_OK or MNL_CB_STOP. - */ -int mnl_attr_parse(const struct nlmsghdr *nlh, - unsigned int offset, mnl_attr_cb_t cb, - void *data) -{ - int ret = MNL_CB_OK; - const struct nlattr *attr; - - mnl_attr_for_each(attr, nlh, offset) - if ((ret = cb(attr, data)) <= MNL_CB_STOP) - return ret; - return ret; -} - -/** - * mnl_attr_parse_nested - parse attributes inside a nest - * \param nested pointer to netlink attribute that contains a nest - * \param cb callback function that is called for each attribute in the nest - * \param data pointer to data passed to the callback function - * - * This function allows to iterate over the sequence of attributes that compose - * the Netlink message. You can then put the attribute in an array as it - * usually happens at this stage or you can use any other data structure (such - * as lists or trees). - * - * This function propagates the return value of the callback, which can be - * MNL_CB_ERROR, MNL_CB_OK or MNL_CB_STOP. - */ -int mnl_attr_parse_nested(const struct nlattr *nested, - mnl_attr_cb_t cb, void *data) -{ - int ret = MNL_CB_OK; - const struct nlattr *attr; - - mnl_attr_for_each_nested(attr, nested) - if ((ret = cb(attr, data)) <= MNL_CB_STOP) - return ret; - return ret; -} - -/** - * mnl_attr_parse_payload - parse attributes in payload of Netlink message - * \param payload pointer to payload of the Netlink message - * \param payload_len payload length that contains the attributes - * \param cb callback function that is called for each attribute - * \param data pointer to data that is passed to the callback function - * - * This function takes a pointer to the area that contains the attributes, - * commonly known as the payload of the Netlink message. Thus, you have to - * pass a pointer to the Netlink message payload, instead of the entire - * message. - * - * This function allows you to iterate over the sequence of attributes that are - * located at some payload offset. You can then put the attributes in one array - * as usual, or you can use any other data structure (such as lists or trees). - * - * This function propagates the return value of the callback, which can be - * MNL_CB_ERROR, MNL_CB_OK or MNL_CB_STOP. - */ -int mnl_attr_parse_payload(const void *payload, - size_t payload_len, - mnl_attr_cb_t cb, void *data) -{ - int ret = MNL_CB_OK; - const struct nlattr *attr; - - mnl_attr_for_each_payload(payload, payload_len) - if ((ret = cb(attr, data)) <= MNL_CB_STOP) - return ret; - return ret; -} - -/** - * mnl_attr_get_u8 - returns 8-bit unsigned integer attribute payload - * \param attr pointer to netlink attribute - * - * This function returns the 8-bit value of the attribute payload. - */ -uint8_t mnl_attr_get_u8(const struct nlattr *attr) -{ - return *((uint8_t *)mnl_attr_get_payload(attr)); -} - -/** - * mnl_attr_get_u16 - returns 16-bit unsigned integer attribute payload - * \param attr pointer to netlink attribute - * - * This function returns the 16-bit value of the attribute payload. - */ -uint16_t mnl_attr_get_u16(const struct nlattr *attr) -{ - return *((uint16_t *)mnl_attr_get_payload(attr)); -} - -/** - * mnl_attr_get_u32 - returns 32-bit unsigned integer attribute payload - * \param attr pointer to netlink attribute - * - * This function returns the 32-bit value of the attribute payload. - */ -uint32_t mnl_attr_get_u32(const struct nlattr *attr) -{ - return *((uint32_t *)mnl_attr_get_payload(attr)); -} - -/** - * mnl_attr_get_u64 - returns 64-bit unsigned integer attribute. - * \param attr pointer to netlink attribute - * - * This function returns the 64-bit value of the attribute payload. This - * function is align-safe, since accessing 64-bit Netlink attributes is a - * common source of alignment issues. - */ -uint64_t mnl_attr_get_u64(const struct nlattr *attr) -{ - uint64_t tmp; - memcpy(&tmp, mnl_attr_get_payload(attr), sizeof(tmp)); - return tmp; -} - -/** - * mnl_attr_get_str - returns pointer to string attribute. - * \param attr pointer to netlink attribute - * - * This function returns the payload of string attribute value. - */ -const char *mnl_attr_get_str(const struct nlattr *attr) -{ - return mnl_attr_get_payload(attr); -} - -/** - * mnl_attr_put - add an attribute to netlink message - * \param nlh pointer to the netlink message - * \param type netlink attribute type that you want to add - * \param len netlink attribute payload length - * \param data pointer to the data that will be stored by the new attribute - * - * This function updates the length field of the Netlink message (nlmsg_len) - * by adding the size (header + payload) of the new attribute. - */ -void mnl_attr_put(struct nlmsghdr *nlh, uint16_t type, - size_t len, const void *data) -{ - struct nlattr *attr = mnl_nlmsg_get_payload_tail(nlh); - uint16_t payload_len = MNL_ALIGN(sizeof(struct nlattr)) + len; - int pad; - - attr->nla_type = type; - attr->nla_len = payload_len; - memcpy(mnl_attr_get_payload(attr), data, len); - pad = MNL_ALIGN(len) - len; - if (pad > 0) - memset(mnl_attr_get_payload(attr) + len, 0, pad); - - nlh->nlmsg_len += MNL_ALIGN(payload_len); -} - -/** - * mnl_attr_put_u8 - add 8-bit unsigned integer attribute to netlink message - * \param nlh pointer to the netlink message - * \param type netlink attribute type - * \param data 8-bit unsigned integer data that is stored by the new attribute - * - * This function updates the length field of the Netlink message (nlmsg_len) - * by adding the size (header + payload) of the new attribute. - */ -void mnl_attr_put_u8(struct nlmsghdr *nlh, uint16_t type, - uint8_t data) -{ - mnl_attr_put(nlh, type, sizeof(uint8_t), &data); -} - -/** - * mnl_attr_put_u16 - add 16-bit unsigned integer attribute to netlink message - * \param nlh pointer to the netlink message - * \param type netlink attribute type - * \param data 16-bit unsigned integer data that is stored by the new attribute - * - * This function updates the length field of the Netlink message (nlmsg_len) - * by adding the size (header + payload) of the new attribute. - */ -void mnl_attr_put_u16(struct nlmsghdr *nlh, uint16_t type, - uint16_t data) -{ - mnl_attr_put(nlh, type, sizeof(uint16_t), &data); -} - -/** - * mnl_attr_put_u32 - add 32-bit unsigned integer attribute to netlink message - * \param nlh pointer to the netlink message - * \param type netlink attribute type - * \param data 32-bit unsigned integer data that is stored by the new attribute - * - * This function updates the length field of the Netlink message (nlmsg_len) - * by adding the size (header + payload) of the new attribute. - */ -void mnl_attr_put_u32(struct nlmsghdr *nlh, uint16_t type, - uint32_t data) -{ - mnl_attr_put(nlh, type, sizeof(uint32_t), &data); -} - -/** - * mnl_attr_put_u64 - add 64-bit unsigned integer attribute to netlink message - * \param nlh pointer to the netlink message - * \param type netlink attribute type - * \param data 64-bit unsigned integer data that is stored by the new attribute - * - * This function updates the length field of the Netlink message (nlmsg_len) - * by adding the size (header + payload) of the new attribute. - */ -void mnl_attr_put_u64(struct nlmsghdr *nlh, uint16_t type, - uint64_t data) -{ - mnl_attr_put(nlh, type, sizeof(uint64_t), &data); -} - -/** - * mnl_attr_put_str - add string attribute to netlink message - * \param nlh pointer to the netlink message - * \param type netlink attribute type - * \param data pointer to string data that is stored by the new attribute - * - * This function updates the length field of the Netlink message (nlmsg_len) - * by adding the size (header + payload) of the new attribute. - */ -void mnl_attr_put_str(struct nlmsghdr *nlh, uint16_t type, - const char *data) -{ - mnl_attr_put(nlh, type, strlen(data), data); -} - -/** - * mnl_attr_put_strz - add string attribute to netlink message - * \param nlh pointer to the netlink message - * \param type netlink attribute type - * \param data pointer to string data that is stored by the new attribute - * - * This function is similar to mnl_attr_put_str, but it includes the - * NUL/zero ('\0') terminator at the end of the string. - * - * This function updates the length field of the Netlink message (nlmsg_len) - * by adding the size (header + payload) of the new attribute. - */ -void mnl_attr_put_strz(struct nlmsghdr *nlh, uint16_t type, - const char *data) -{ - mnl_attr_put(nlh, type, strlen(data)+1, data); -} - -/** - * mnl_attr_nest_start - start an attribute nest - * \param nlh pointer to the netlink message - * \param type netlink attribute type - * - * This function adds the attribute header that identifies the beginning of - * an attribute nest. This function always returns a valid pointer to the - * beginning of the nest. - */ -struct nlattr *mnl_attr_nest_start(struct nlmsghdr *nlh, - uint16_t type) -{ - struct nlattr *start = mnl_nlmsg_get_payload_tail(nlh); - - /* set start->nla_len in mnl_attr_nest_end() */ - start->nla_type = NLA_F_NESTED | type; - nlh->nlmsg_len += MNL_ALIGN(sizeof(struct nlattr)); - - return start; -} - -/** - * mnl_attr_put_check - add an attribute to netlink message - * \param nlh pointer to the netlink message - * \param buflen size of buffer which stores the message - * \param type netlink attribute type that you want to add - * \param len netlink attribute payload length - * \param data pointer to the data that will be stored by the new attribute - * - * This function first checks that the data can be added to the message - * (fits into the buffer) and then updates the length field of the Netlink - * message (nlmsg_len) by adding the size (header + payload) of the new - * attribute. The function returns true if the attribute could be added - * to the message, otherwise false is returned. - */ -bool mnl_attr_put_check(struct nlmsghdr *nlh, size_t buflen, - uint16_t type, size_t len, - const void *data) -{ - if (nlh->nlmsg_len + MNL_ATTR_HDRLEN + MNL_ALIGN(len) > buflen) - return false; - mnl_attr_put(nlh, type, len, data); - return true; -} - -/** - * mnl_attr_put_u8_check - add 8-bit unsigned int attribute to netlink message - * \param nlh pointer to the netlink message - * \param buflen size of buffer which stores the message - * \param type netlink attribute type - * \param data 8-bit unsigned integer data that is stored by the new attribute - * - * This function first checks that the data can be added to the message - * (fits into the buffer) and then updates the length field of the Netlink - * message (nlmsg_len) by adding the size (header + payload) of the new - * attribute. The function returns true if the attribute could be added - * to the message, otherwise false is returned. - */ -bool mnl_attr_put_u8_check(struct nlmsghdr *nlh, size_t buflen, - uint16_t type, uint8_t data) -{ - return mnl_attr_put_check(nlh, buflen, type, sizeof(uint8_t), &data); -} - -/** - * mnl_attr_put_u16_check - add 16-bit unsigned int attribute to netlink message - * \param nlh pointer to the netlink message - * \param buflen size of buffer which stores the message - * \param type netlink attribute type - * \param data 16-bit unsigned integer data that is stored by the new attribute - * - * This function first checks that the data can be added to the message - * (fits into the buffer) and then updates the length field of the Netlink - * message (nlmsg_len) by adding the size (header + payload) of the new - * attribute. The function returns true if the attribute could be added - * to the message, otherwise false is returned. - * This function updates the length field of the Netlink message (nlmsg_len) - * by adding the size (header + payload) of the new attribute. - */ -bool mnl_attr_put_u16_check(struct nlmsghdr *nlh, size_t buflen, - uint16_t type, uint16_t data) -{ - return mnl_attr_put_check(nlh, buflen, type, sizeof(uint16_t), &data); -} - -/** - * mnl_attr_put_u32_check - add 32-bit unsigned int attribute to netlink message - * \param nlh pointer to the netlink message - * \param buflen size of buffer which stores the message - * \param type netlink attribute type - * \param data 32-bit unsigned integer data that is stored by the new attribute - * - * This function first checks that the data can be added to the message - * (fits into the buffer) and then updates the length field of the Netlink - * message (nlmsg_len) by adding the size (header + payload) of the new - * attribute. The function returns true if the attribute could be added - * to the message, otherwise false is returned. - * This function updates the length field of the Netlink message (nlmsg_len) - * by adding the size (header + payload) of the new attribute. - */ -bool mnl_attr_put_u32_check(struct nlmsghdr *nlh, size_t buflen, - uint16_t type, uint32_t data) -{ - return mnl_attr_put_check(nlh, buflen, type, sizeof(uint32_t), &data); -} - -/** - * mnl_attr_put_u64_check - add 64-bit unsigned int attribute to netlink message - * \param nlh pointer to the netlink message - * \param buflen size of buffer which stores the message - * \param type netlink attribute type - * \param data 64-bit unsigned integer data that is stored by the new attribute - * - * This function first checks that the data can be added to the message - * (fits into the buffer) and then updates the length field of the Netlink - * message (nlmsg_len) by adding the size (header + payload) of the new - * attribute. The function returns true if the attribute could be added - * to the message, otherwise false is returned. - * This function updates the length field of the Netlink message (nlmsg_len) - * by adding the size (header + payload) of the new attribute. - */ -bool mnl_attr_put_u64_check(struct nlmsghdr *nlh, size_t buflen, - uint16_t type, uint64_t data) -{ - return mnl_attr_put_check(nlh, buflen, type, sizeof(uint64_t), &data); -} - -/** - * mnl_attr_put_str_check - add string attribute to netlink message - * \param nlh pointer to the netlink message - * \param buflen size of buffer which stores the message - * \param type netlink attribute type - * \param data pointer to string data that is stored by the new attribute - * - * This function first checks that the data can be added to the message - * (fits into the buffer) and then updates the length field of the Netlink - * message (nlmsg_len) by adding the size (header + payload) of the new - * attribute. The function returns true if the attribute could be added - * to the message, otherwise false is returned. - * This function updates the length field of the Netlink message (nlmsg_len) - * by adding the size (header + payload) of the new attribute. - */ -bool mnl_attr_put_str_check(struct nlmsghdr *nlh, size_t buflen, - uint16_t type, const char *data) -{ - return mnl_attr_put_check(nlh, buflen, type, strlen(data), data); -} - -/** - * mnl_attr_put_strz_check - add string attribute to netlink message - * \param nlh pointer to the netlink message - * \param buflen size of buffer which stores the message - * \param type netlink attribute type - * \param data pointer to string data that is stored by the new attribute - * - * This function is similar to mnl_attr_put_str, but it includes the - * NUL/zero ('\0') terminator at the end of the string. - * - * This function first checks that the data can be added to the message - * (fits into the buffer) and then updates the length field of the Netlink - * message (nlmsg_len) by adding the size (header + payload) of the new - * attribute. The function returns true if the attribute could be added - * to the message, otherwise false is returned. - */ -bool mnl_attr_put_strz_check(struct nlmsghdr *nlh, size_t buflen, - uint16_t type, const char *data) -{ - return mnl_attr_put_check(nlh, buflen, type, strlen(data)+1, data); -} - -/** - * mnl_attr_nest_start_check - start an attribute nest - * \param buflen size of buffer which stores the message - * \param nlh pointer to the netlink message - * \param type netlink attribute type - * - * This function adds the attribute header that identifies the beginning of - * an attribute nest. If the nested attribute cannot be added then NULL, - * otherwise valid pointer to the beginning of the nest is returned. - */ -struct nlattr *mnl_attr_nest_start_check(struct nlmsghdr *nlh, - size_t buflen, - uint16_t type) -{ - if (nlh->nlmsg_len + MNL_ATTR_HDRLEN > buflen) - return NULL; - return mnl_attr_nest_start(nlh, type); -} - -/** - * mnl_attr_nest_end - end an attribute nest - * \param nlh pointer to the netlink message - * \param start pointer to the attribute nest returned by mnl_attr_nest_start() - * - * This function updates the attribute header that identifies the nest. - */ -void mnl_attr_nest_end(struct nlmsghdr *nlh, - struct nlattr *start) -{ - start->nla_len = mnl_nlmsg_get_payload_tail(nlh) - (void *)start; -} - -/** - * mnl_attr_nest_cancel - cancel an attribute nest - * \param nlh pointer to the netlink message - * \param start pointer to the attribute nest returned by mnl_attr_nest_start() - * - * This function updates the attribute header that identifies the nest. - */ -void mnl_attr_nest_cancel(struct nlmsghdr *nlh, - struct nlattr *start) -{ - nlh->nlmsg_len -= mnl_nlmsg_get_payload_tail(nlh) - (void *)start; -} - -/** - * @} - */ diff --git a/fibocom-dial/src/libmnl/callback.c b/fibocom-dial/src/libmnl/callback.c deleted file mode 100644 index 8283a93..0000000 --- a/fibocom-dial/src/libmnl/callback.c +++ /dev/null @@ -1,167 +0,0 @@ -/* - * (C) 2008-2010 by Pablo Neira Ayuso - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - */ - -#include - -#include "libmnl.h" - -static int mnl_cb_noop(const struct nlmsghdr *nlh, void *data) -{ - return MNL_CB_OK; -} - -static int mnl_cb_error(const struct nlmsghdr *nlh, void *data) -{ - const struct nlmsgerr *err = mnl_nlmsg_get_payload(nlh); - - if (nlh->nlmsg_len < mnl_nlmsg_size(sizeof(struct nlmsgerr))) { - errno = EBADMSG; - return MNL_CB_ERROR; - } - /* Netlink subsystems returns the errno value with different signess */ - if (err->error < 0) - errno = -err->error; - else - errno = err->error; - - return err->error == 0 ? MNL_CB_STOP : MNL_CB_ERROR; -} - -static int mnl_cb_stop(const struct nlmsghdr *nlh, void *data) -{ - return MNL_CB_STOP; -} - -static const mnl_cb_t default_cb_array[NLMSG_MIN_TYPE] = { - [NLMSG_NOOP] = mnl_cb_noop, - [NLMSG_ERROR] = mnl_cb_error, - [NLMSG_DONE] = mnl_cb_stop, - [NLMSG_OVERRUN] = mnl_cb_noop, -}; - -static inline int __mnl_cb_run(const void *buf, size_t numbytes, - unsigned int seq, unsigned int portid, - mnl_cb_t cb_data, void *data, - const mnl_cb_t *cb_ctl_array, - unsigned int cb_ctl_array_len) -{ - int ret = MNL_CB_OK, len = numbytes; - const struct nlmsghdr *nlh = buf; - - while (mnl_nlmsg_ok(nlh, len)) { - /* check message source */ - if (!mnl_nlmsg_portid_ok(nlh, portid)) { - errno = ESRCH; - return -1; - } - /* perform sequence tracking */ - if (!mnl_nlmsg_seq_ok(nlh, seq)) { - errno = EPROTO; - return -1; - } - - /* dump was interrupted */ - if (nlh->nlmsg_flags & NLM_F_DUMP_INTR) { - errno = EINTR; - return -1; - } - - /* netlink data message handling */ - if (nlh->nlmsg_type >= NLMSG_MIN_TYPE) { - if (cb_data){ - ret = cb_data(nlh, data); - if (ret <= MNL_CB_STOP) - goto out; - } - } else if (nlh->nlmsg_type < cb_ctl_array_len) { - if (cb_ctl_array && cb_ctl_array[nlh->nlmsg_type]) { - ret = cb_ctl_array[nlh->nlmsg_type](nlh, data); - if (ret <= MNL_CB_STOP) - goto out; - } - } else if (default_cb_array[nlh->nlmsg_type]) { - ret = default_cb_array[nlh->nlmsg_type](nlh, data); - if (ret <= MNL_CB_STOP) - goto out; - } - nlh = mnl_nlmsg_next(nlh, &len); - } -out: - return ret; -} - -/** - * \defgroup callback Callback helpers - * @{ - */ - -/** - * mnl_cb_run2 - callback runqueue for netlink messages - * \param buf buffer that contains the netlink messages - * \param numbytes number of bytes stored in the buffer - * \param seq sequence number that we expect to receive - * \param portid Netlink PortID that we expect to receive - * \param cb_data callback handler for data messages - * \param data pointer to data that will be passed to the data callback handler - * \param cb_ctl_array array of custom callback handlers from control messages - * \param cb_ctl_array_len array length of custom control callback handlers - * - * You can set the cb_ctl_array to NULL if you want to use the default control - * callback handlers, in that case, the parameter cb_ctl_array_len is not - * checked. - * - * Your callback may return three possible values: - * - MNL_CB_ERROR (<=-1): an error has occurred. Stop callback runqueue. - * - MNL_CB_STOP (=0): stop callback runqueue. - * - MNL_CB_OK (>=1): no problem has occurred. - * - * This function propagates the callback return value. On error, it returns - * -1 and errno is explicitly set. If the portID is not the expected, errno - * is set to ESRCH. If the sequence number is not the expected, errno is set - * to EPROTO. If the dump was interrupted, errno is set to EINTR and you should - * request a new fresh dump again. - */ -int mnl_cb_run2(const void *buf, size_t numbytes, - unsigned int seq, unsigned int portid, - mnl_cb_t cb_data, void *data, - const mnl_cb_t *cb_ctl_array, - unsigned int cb_ctl_array_len) -{ - return __mnl_cb_run(buf, numbytes, seq, portid, cb_data, data, - cb_ctl_array, cb_ctl_array_len); -} - -/** - * mnl_cb_run - callback runqueue for netlink messages (simplified version) - * \param buf buffer that contains the netlink messages - * \param numbytes number of bytes stored in the buffer - * \param seq sequence number that we expect to receive - * \param portid Netlink PortID that we expect to receive - * \param cb_data callback handler for data messages - * \param data pointer to data that will be passed to the data callback handler - * - * This function is like mnl_cb_run2() but it does not allow you to set - * the control callback handlers. - * - * Your callback may return three possible values: - * - MNL_CB_ERROR (<=-1): an error has occurred. Stop callback runqueue. - * - MNL_CB_STOP (=0): stop callback runqueue. - * - MNL_CB_OK (>=1): no problems has occurred. - * - * This function propagates the callback return value. - */ -int mnl_cb_run(const void *buf, size_t numbytes, unsigned int seq, - unsigned int portid, mnl_cb_t cb_data, void *data) -{ - return __mnl_cb_run(buf, numbytes, seq, portid, cb_data, data, NULL, 0); -} - -/** - * @} - */ diff --git a/fibocom-dial/src/libmnl/dhcp/dhcp.h b/fibocom-dial/src/libmnl/dhcp/dhcp.h deleted file mode 100644 index f480285..0000000 --- a/fibocom-dial/src/libmnl/dhcp/dhcp.h +++ /dev/null @@ -1,5 +0,0 @@ -#ifndef __DHCP_H__ -#define __DHCP_H__ - -int do_dhcp(char *iname); -#endif //__DHCP_H__ \ No newline at end of file diff --git a/fibocom-dial/src/libmnl/dhcp/dhcpclient.c b/fibocom-dial/src/libmnl/dhcp/dhcpclient.c deleted file mode 100644 index ccb71b5..0000000 --- a/fibocom-dial/src/libmnl/dhcp/dhcpclient.c +++ /dev/null @@ -1,515 +0,0 @@ -/* - * Copyright 2008, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../ifutils.h" -#include "dhcpmsg.h" -#include "packet.h" - -#define VERBOSE 2 - -static int verbose = 1; -static char errmsg[2048]; - -typedef unsigned long long msecs_t; -#if VERBOSE -void dump_dhcp_msg(); -#endif - -msecs_t get_msecs(void) -{ - struct timespec ts; - - if (clock_gettime(CLOCK_MONOTONIC, &ts)) { - return 0; - } else { - return (((msecs_t) ts.tv_sec) * ((msecs_t) 1000)) + - (((msecs_t) ts.tv_nsec) / ((msecs_t) 1000000)); - } -} - -void printerr(char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - vsnprintf(errmsg, sizeof(errmsg), fmt, ap); - va_end(ap); - - printf("%s\n", errmsg); -} - -const char *dhcp_lasterror() -{ - return errmsg; -} - -int fatal(const char *reason) -{ - printerr("%s: %s\n", reason, strerror(errno)); - return -1; -// exit(1); -} - -typedef struct dhcp_info dhcp_info; - -struct dhcp_info { - uint32_t type; - - uint32_t ipaddr; - uint32_t gateway; - uint32_t prefixLength; - - uint32_t dns1; - uint32_t dns2; - - uint32_t serveraddr; - uint32_t lease; -}; - -dhcp_info last_good_info; - -void get_dhcp_info(uint32_t *ipaddr, uint32_t *gateway, uint32_t *prefixLength, - uint32_t *dns1, uint32_t *dns2, uint32_t *server, - uint32_t *lease) -{ - *ipaddr = last_good_info.ipaddr; - *gateway = last_good_info.gateway; - *prefixLength = last_good_info.prefixLength; - *dns1 = last_good_info.dns1; - *dns2 = last_good_info.dns2; - *server = last_good_info.serveraddr; - *lease = last_good_info.lease; -} - -static int dhcp_configure(const char *ifname, dhcp_info *info) -{ - last_good_info = *info; - return if_set_network_v4(ifname, info->ipaddr, info->prefixLength, info->gateway, - info->dns1, info->dns2); -} - -static const char *dhcp_type_to_name(uint32_t type) -{ - switch(type) { - case DHCPDISCOVER: return "discover"; - case DHCPOFFER: return "offer"; - case DHCPREQUEST: return "request"; - case DHCPDECLINE: return "decline"; - case DHCPACK: return "ack"; - case DHCPNAK: return "nak"; - case DHCPRELEASE: return "release"; - case DHCPINFORM: return "inform"; - default: return "???"; - } -} - -void dump_dhcp_info(dhcp_info *info) -{ - char addr[20], gway[20]; - printf("--- dhcp %s (%d) ---\n", - dhcp_type_to_name(info->type), info->type); - strcpy(addr, ipaddr_to_string_v4(info->ipaddr)); - strcpy(gway, ipaddr_to_string_v4(info->gateway)); - printf("ip %s gw %s prefixLength %d\n", addr, gway, info->prefixLength); - if (info->dns1) printf("dns1: %s\n", ipaddr_to_string_v4(info->dns1)); - if (info->dns2) printf("dns2: %s\n", ipaddr_to_string_v4(info->dns2)); - printf("server %s, lease %d seconds\n", - ipaddr_to_string_v4(info->serveraddr), info->lease); -} - - -int decode_dhcp_msg(dhcp_msg *msg, int len, dhcp_info *info) -{ - uint8_t *x; - unsigned int opt; - int optlen; - - memset(info, 0, sizeof(dhcp_info)); - if (len < (DHCP_MSG_FIXED_SIZE + 4)) return -1; - - len -= (DHCP_MSG_FIXED_SIZE + 4); - - if (msg->options[0] != OPT_COOKIE1) return -1; - if (msg->options[1] != OPT_COOKIE2) return -1; - if (msg->options[2] != OPT_COOKIE3) return -1; - if (msg->options[3] != OPT_COOKIE4) return -1; - - x = msg->options + 4; - - while (len > 2) { - opt = *x++; - if (opt == OPT_PAD) { - len--; - continue; - } - if (opt == OPT_END) { - break; - } - optlen = *x++; - len -= 2; - if (optlen > len) { - break; - } - switch(opt) { - case OPT_SUBNET_MASK: - if (optlen >= 4) { - in_addr_t mask; - memcpy(&mask, x, 4); - info->prefixLength = mask_to_prefix_v4(mask); - } - break; - case OPT_GATEWAY: - if (optlen >= 4) memcpy(&info->gateway, x, 4); - break; - case OPT_DNS: - if (optlen >= 4) memcpy(&info->dns1, x + 0, 4); - if (optlen >= 8) memcpy(&info->dns2, x + 4, 4); - break; - case OPT_LEASE_TIME: - if (optlen >= 4) { - memcpy(&info->lease, x, 4); - info->lease = ntohl(info->lease); - } - break; - case OPT_SERVER_ID: - if (optlen >= 4) memcpy(&info->serveraddr, x, 4); - break; - case OPT_MESSAGE_TYPE: - info->type = *x; - break; - default: - break; - } - x += optlen; - len -= optlen; - } - - info->ipaddr = msg->yiaddr; - - return 0; -} - -#if VERBOSE - -static void hex2str(char *buf, size_t buf_size, const unsigned char *array, int len) -{ - int i; - char *cp = buf; - char *buf_end = buf + buf_size; - for (i = 0; i < len; i++) { - cp += snprintf(cp, buf_end - cp, " %02x ", array[i]); - } -} - -void dump_dhcp_msg(dhcp_msg *msg, int len) -{ - unsigned char *x; - unsigned int n,c; - int optsz; - const char *name; - char buf[2048]; - - if (len < DHCP_MSG_FIXED_SIZE) { - printf("Invalid length %d, should be %d", len, DHCP_MSG_FIXED_SIZE); - return; - } - - len -= DHCP_MSG_FIXED_SIZE; - - if (msg->op == OP_BOOTREQUEST) - name = "BOOTREQUEST"; - else if (msg->op == OP_BOOTREPLY) - name = "BOOTREPLY"; - else - name = "????"; - - c = msg->hlen > 16 ? 16 : msg->hlen; - hex2str(buf, sizeof(buf), msg->chaddr, c); - - for (n = 0; n < 64; n++) { - unsigned char x = msg->sname[n]; - if ((x < ' ') || (x > 127)) { - if (x == 0) break; - msg->sname[n] = '.'; - } - } - msg->sname[63] = 0; - - for (n = 0; n < 128; n++) { - unsigned char x = msg->file[n]; - if ((x < ' ') || (x > 127)) { - if (x == 0) break; - msg->file[n] = '.'; - } - } - msg->file[127] = 0; - - if (len < 4) return; - len -= 4; - x = msg->options + 4; - - while (len > 2) { - if (*x == 0) { - x++; - len--; - continue; - } - if (*x == OPT_END) { - break; - } - len -= 2; - optsz = x[1]; - if (optsz > len) break; - if (x[0] == OPT_DOMAIN_NAME || x[0] == OPT_MESSAGE) { - if ((unsigned int)optsz < sizeof(buf) - 1) { - n = optsz; - } else { - n = sizeof(buf) - 1; - } - memcpy(buf, &x[2], n); - buf[n] = '\0'; - } else { - hex2str(buf, sizeof(buf), &x[2], optsz); - } - if (x[0] == OPT_MESSAGE_TYPE) - name = dhcp_type_to_name(x[2]); - else - name = NULL; - len -= optsz; - x = x + optsz + 2; - } -} - -#endif - -static int send_message(int sock, int if_index, dhcp_msg *msg, int size) -{ -#if VERBOSE > 1 - dump_dhcp_msg(msg, size); -#endif - return send_packet(sock, if_index, msg, size, INADDR_ANY, INADDR_BROADCAST, - PORT_BOOTP_CLIENT, PORT_BOOTP_SERVER); -} - -static int is_valid_reply(dhcp_msg *msg, dhcp_msg *reply, int sz) -{ - if (sz < DHCP_MSG_FIXED_SIZE) { - if (verbose) printf("Wrong size %d != %d\n", sz, DHCP_MSG_FIXED_SIZE); - return 0; - } - if (reply->op != OP_BOOTREPLY) { - if (verbose) printf("Wrong Op %d != %d\n", reply->op, OP_BOOTREPLY); - return 0; - } - if (reply->xid != msg->xid) { - if (verbose) printf("Wrong Xid 0x%x != 0x%x\n", ntohl(reply->xid), - ntohl(msg->xid)); - return 0; - } - if (reply->htype != msg->htype) { - if (verbose) printf("Wrong Htype %d != %d\n", reply->htype, msg->htype); - return 0; - } - if (reply->hlen != msg->hlen) { - if (verbose) printf("Wrong Hlen %d != %d\n", reply->hlen, msg->hlen); - return 0; - } - if (memcmp(msg->chaddr, reply->chaddr, msg->hlen)) { - if (verbose) printf("Wrong chaddr %x != %x\n", *(reply->chaddr),*(msg->chaddr)); - return 0; - } - return 1; -} - -#define STATE_SELECTING 1 -#define STATE_REQUESTING 2 - -#define TIMEOUT_INITIAL 4000 -#define TIMEOUT_MAX 32000 - -int dhcp_init_ifc(const char *ifname) -{ - dhcp_msg discover_msg; - dhcp_msg request_msg; - dhcp_msg reply; - dhcp_msg *msg; - dhcp_info info; - int s, r, size; - int valid_reply; - uint32_t xid; - unsigned char hwaddr[6]; - struct pollfd pfd; - unsigned int state; - unsigned int timeout; - int if_index; - - xid = (uint32_t) get_msecs(); - - if (if_get_hwaddr(ifname, hwaddr)) { - return fatal("cannot obtain interface address"); - } - if ((if_index = if_nametoindex(ifname)) == 0) { - return fatal("cannot obtain interface index"); - } - - s = open_raw_socket(ifname, hwaddr, if_index); - - timeout = TIMEOUT_INITIAL; - state = STATE_SELECTING; - info.type = 0; - goto transmit; - - for (;;) { - pfd.fd = s; - pfd.events = POLLIN; - pfd.revents = 0; - r = poll(&pfd, 1, timeout); - - if (r == 0) { -#if VERBOSE - printerr("TIMEOUT\n"); -#endif - if (timeout >= TIMEOUT_MAX) { - printerr("timed out\n"); - if ( info.type == DHCPOFFER ) { - printerr("no acknowledgement from DHCP server\nconfiguring %s with offered parameters\n", ifname); - return dhcp_configure(ifname, &info); - } - errno = ETIME; - close(s); - return -1; - } - timeout = timeout * 2; - - transmit: - size = 0; - msg = NULL; - switch(state) { - case STATE_SELECTING: - msg = &discover_msg; - size = init_dhcp_discover_msg(msg, hwaddr, xid); - break; - case STATE_REQUESTING: - msg = &request_msg; - size = init_dhcp_request_msg(msg, hwaddr, xid, info.ipaddr, info.serveraddr); - break; - default: - r = 0; - } - if (size != 0) { - r = send_message(s, if_index, msg, size); - if (r < 0) { - printerr("error sending dhcp msg: %s\n", strerror(errno)); - } - } - continue; - } - - if (r < 0) { - if ((errno == EAGAIN) || (errno == EINTR)) { - continue; - } - return fatal("poll failed"); - } - - errno = 0; - r = receive_packet(s, &reply); - if (r < 0) { - if (errno != 0) { - printf("receive_packet failed (%d): %s", r, strerror(errno)); - if (errno == ENETDOWN || errno == ENXIO) { - return -1; - } - } - continue; - } - -#if VERBOSE > 1 - dump_dhcp_msg(&reply, r); -#endif - decode_dhcp_msg(&reply, r, &info); - - if (state == STATE_SELECTING) { - valid_reply = is_valid_reply(&discover_msg, &reply, r); - } else { - valid_reply = is_valid_reply(&request_msg, &reply, r); - } - if (!valid_reply) { - printerr("invalid reply\n"); - continue; - } - - if (verbose) dump_dhcp_info(&info); - - switch(state) { - case STATE_SELECTING: - if (info.type == DHCPOFFER) { - state = STATE_REQUESTING; - timeout = TIMEOUT_INITIAL; - xid++; - goto transmit; - } - break; - case STATE_REQUESTING: - if (info.type == DHCPACK) { - printerr("configuring %s\n", ifname); - close(s); - return dhcp_configure(ifname, &info); - } else if (info.type == DHCPNAK) { - printerr("configuration request denied\n"); - close(s); - return -1; - } else { - printerr("ignoring %s message in state %d\n", - dhcp_type_to_name(info.type), state); - } - break; - } - } - close(s); - return 0; -} - -int do_dhcp(char *iname) -{ - if (if_set_addr_v4(iname, 0, 32)) { - printerr("failed to set ip addr for %s to 0.0.0.0: %s\n", iname, strerror(errno)); - return -1; - } - - if (if_link_up(iname)) { - printerr("failed to bring up interface %s: %s\n", iname, strerror(errno)); - return -1; - } - - return dhcp_init_ifc(iname); -} diff --git a/fibocom-dial/src/libmnl/dhcp/dhcpmsg.c b/fibocom-dial/src/libmnl/dhcp/dhcpmsg.c deleted file mode 100644 index 1e0a233..0000000 --- a/fibocom-dial/src/libmnl/dhcp/dhcpmsg.c +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright 2008, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include - -#include "dhcpmsg.h" - -static void *init_dhcp_msg(dhcp_msg *msg, int type, void *hwaddr, uint32_t xid) -{ - uint8_t *x; - - memset(msg, 0, sizeof(dhcp_msg)); - - msg->op = OP_BOOTREQUEST; - msg->htype = HTYPE_ETHER; - msg->hlen = 6; - msg->hops = 0; - - msg->flags = htons(FLAGS_BROADCAST); - - msg->xid = xid; - - memcpy(msg->chaddr, hwaddr, 6); - - x = msg->options; - - *x++ = OPT_COOKIE1; - *x++ = OPT_COOKIE2; - *x++ = OPT_COOKIE3; - *x++ = OPT_COOKIE4; - - *x++ = OPT_MESSAGE_TYPE; - *x++ = 1; - *x++ = type; - - return x; -} - -int init_dhcp_discover_msg(dhcp_msg *msg, void *hwaddr, uint32_t xid) -{ - uint8_t *x; - - x = init_dhcp_msg(msg, DHCPDISCOVER, hwaddr, xid); - - *x++ = OPT_PARAMETER_LIST; - *x++ = 4; - *x++ = OPT_SUBNET_MASK; - *x++ = OPT_GATEWAY; - *x++ = OPT_DNS; - *x++ = OPT_BROADCAST_ADDR; - - *x++ = OPT_END; - - return DHCP_MSG_FIXED_SIZE + (x - msg->options); -} - -int init_dhcp_request_msg(dhcp_msg *msg, void *hwaddr, uint32_t xid, - uint32_t ipaddr, uint32_t serveraddr) -{ - uint8_t *x; - - x = init_dhcp_msg(msg, DHCPREQUEST, hwaddr, xid); - - *x++ = OPT_PARAMETER_LIST; - *x++ = 4; - *x++ = OPT_SUBNET_MASK; - *x++ = OPT_GATEWAY; - *x++ = OPT_DNS; - *x++ = OPT_BROADCAST_ADDR; - - *x++ = OPT_REQUESTED_IP; - *x++ = 4; - memcpy(x, &ipaddr, 4); - x += 4; - - *x++ = OPT_SERVER_ID; - *x++ = 4; - memcpy(x, &serveraddr, 4); - x += 4; - - *x++ = OPT_END; - - return DHCP_MSG_FIXED_SIZE + (x - msg->options); -} diff --git a/fibocom-dial/src/libmnl/dhcp/dhcpmsg.h b/fibocom-dial/src/libmnl/dhcp/dhcpmsg.h deleted file mode 100644 index fb99490..0000000 --- a/fibocom-dial/src/libmnl/dhcp/dhcpmsg.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright 2008, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _WIFI_DHCP_H_ -#define _WIFI_DHCP_H_ - -#include - -#define PORT_BOOTP_SERVER 67 -#define PORT_BOOTP_CLIENT 68 - -/* RFC 2131 p 9 */ -typedef struct dhcp_msg dhcp_msg; - -#define OP_BOOTREQUEST 1 -#define OP_BOOTREPLY 2 - -#define FLAGS_BROADCAST 0x8000 - -#define HTYPE_ETHER 1 - -struct dhcp_msg -{ - uint8_t op; /* BOOTREQUEST / BOOTREPLY */ - uint8_t htype; /* hw addr type */ - uint8_t hlen; /* hw addr len */ - uint8_t hops; /* client set to 0 */ - - uint32_t xid; /* transaction id */ - - uint16_t secs; /* seconds since start of acq */ - uint16_t flags; - - uint32_t ciaddr; /* client IP addr */ - uint32_t yiaddr; /* your (client) IP addr */ - uint32_t siaddr; /* ip addr of next server */ - /* (DHCPOFFER and DHCPACK) */ - uint32_t giaddr; /* relay agent IP addr */ - - uint8_t chaddr[16]; /* client hw addr */ - char sname[64]; /* asciiz server hostname */ - char file[128]; /* asciiz boot file name */ - - uint8_t options[1024]; /* optional parameters */ -}; - -#define DHCP_MSG_FIXED_SIZE 236 - -/* first four bytes of options are a cookie to indicate that -** the payload are DHCP options as opposed to some other BOOTP -** extension. -*/ -#define OPT_COOKIE1 0x63 -#define OPT_COOKIE2 0x82 -#define OPT_COOKIE3 0x53 -#define OPT_COOKIE4 0x63 - -/* BOOTP/DHCP options - see RFC 2132 */ -#define OPT_PAD 0 - -#define OPT_SUBNET_MASK 1 /* 4 */ -#define OPT_TIME_OFFSET 2 /* 4 */ -#define OPT_GATEWAY 3 /* 4*n * n */ -#define OPT_DNS 6 /* 4*n * n */ -#define OPT_DOMAIN_NAME 15 /* n */ -#define OPT_BROADCAST_ADDR 28 /* 4 */ - -#define OPT_REQUESTED_IP 50 /* 4 */ -#define OPT_LEASE_TIME 51 /* 4 */ -#define OPT_MESSAGE_TYPE 53 /* 1 */ -#define OPT_SERVER_ID 54 /* 4 */ -#define OPT_PARAMETER_LIST 55 /* n * n */ -#define OPT_MESSAGE 56 /* n */ -#define OPT_CLASS_ID 60 /* n */ -#define OPT_CLIENT_ID 61 /* n */ -#define OPT_END 255 - -/* DHCP message types */ -#define DHCPDISCOVER 1 -#define DHCPOFFER 2 -#define DHCPREQUEST 3 -#define DHCPDECLINE 4 -#define DHCPACK 5 -#define DHCPNAK 6 -#define DHCPRELEASE 7 -#define DHCPINFORM 8 - -int init_dhcp_discover_msg(dhcp_msg *msg, void *hwaddr, uint32_t xid); - -int init_dhcp_request_msg(dhcp_msg *msg, void *hwaddr, uint32_t xid, - uint32_t ipaddr, uint32_t serveraddr); - -#endif diff --git a/fibocom-dial/src/libmnl/dhcp/packet.c b/fibocom-dial/src/libmnl/dhcp/packet.c deleted file mode 100644 index 9515dd1..0000000 --- a/fibocom-dial/src/libmnl/dhcp/packet.c +++ /dev/null @@ -1,247 +0,0 @@ -/* - * Copyright 2008, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "dhcpmsg.h" - -int fatal(); - -int open_raw_socket(const char *ifname __attribute__((unused)), uint8_t *hwaddr, int if_index) -{ - int s; - struct sockaddr_ll bindaddr; - - if((s = socket(PF_PACKET, SOCK_DGRAM, htons(ETH_P_IP))) < 0) { - return fatal("socket(PF_PACKET)"); - } - - memset(&bindaddr, 0, sizeof(bindaddr)); - bindaddr.sll_family = AF_PACKET; - bindaddr.sll_protocol = htons(ETH_P_IP); - bindaddr.sll_halen = ETH_ALEN; - memcpy(bindaddr.sll_addr, hwaddr, ETH_ALEN); - bindaddr.sll_ifindex = if_index; - - if (bind(s, (struct sockaddr *)&bindaddr, sizeof(bindaddr)) < 0) { - return fatal("Cannot bind raw socket to interface"); - } - - return s; -} - -static uint32_t checksum(void *buffer, unsigned int count, uint32_t startsum) -{ - uint16_t *up = (uint16_t *)buffer; - uint32_t sum = startsum; - uint32_t upper16; - - while (count > 1) { - sum += *up++; - count -= 2; - } - if (count > 0) { - sum += (uint16_t) *(uint8_t *)up; - } - while ((upper16 = (sum >> 16)) != 0) { - sum = (sum & 0xffff) + upper16; - } - return sum; -} - -static uint32_t finish_sum(uint32_t sum) -{ - return ~sum & 0xffff; -} - -int send_packet(int s, int if_index, struct dhcp_msg *msg, int size, - uint32_t saddr, uint32_t daddr, uint32_t sport, uint32_t dport) -{ - struct iphdr ip; - struct udphdr udp; - struct iovec iov[3]; - uint32_t udpsum; - uint16_t temp; - struct msghdr msghdr; - struct sockaddr_ll destaddr; - - ip.version = IPVERSION; - ip.ihl = sizeof(ip) >> 2; - ip.tos = 0; - ip.tot_len = htons(sizeof(ip) + sizeof(udp) + size); - ip.id = 0; - ip.frag_off = 0; - ip.ttl = IPDEFTTL; - ip.protocol = IPPROTO_UDP; - ip.check = 0; - ip.saddr = saddr; - ip.daddr = daddr; - ip.check = finish_sum(checksum(&ip, sizeof(ip), 0)); - - udp.source = htons(sport); - udp.dest = htons(dport); - udp.len = htons(sizeof(udp) + size); - udp.check = 0; - - /* Calculate checksum for pseudo header */ - udpsum = checksum(&ip.saddr, sizeof(ip.saddr), 0); - udpsum = checksum(&ip.daddr, sizeof(ip.daddr), udpsum); - temp = htons(IPPROTO_UDP); - udpsum = checksum(&temp, sizeof(temp), udpsum); - temp = udp.len; - udpsum = checksum(&temp, sizeof(temp), udpsum); - - /* Add in the checksum for the udp header */ - udpsum = checksum(&udp, sizeof(udp), udpsum); - - /* Add in the checksum for the data */ - udpsum = checksum(msg, size, udpsum); - udp.check = finish_sum(udpsum); - - iov[0].iov_base = (char *)&ip; - iov[0].iov_len = sizeof(ip); - iov[1].iov_base = (char *)&udp; - iov[1].iov_len = sizeof(udp); - iov[2].iov_base = (char *)msg; - iov[2].iov_len = size; - memset(&destaddr, 0, sizeof(destaddr)); - destaddr.sll_family = AF_PACKET; - destaddr.sll_protocol = htons(ETH_P_IP); - destaddr.sll_ifindex = if_index; - destaddr.sll_halen = ETH_ALEN; - memcpy(destaddr.sll_addr, "\xff\xff\xff\xff\xff\xff", ETH_ALEN); - - msghdr.msg_name = &destaddr; - msghdr.msg_namelen = sizeof(destaddr); - msghdr.msg_iov = iov; - msghdr.msg_iovlen = sizeof(iov) / sizeof(struct iovec); - msghdr.msg_flags = 0; - msghdr.msg_control = 0; - msghdr.msg_controllen = 0; - return sendmsg(s, &msghdr, 0); -} - -int receive_packet(int s, struct dhcp_msg *msg) -{ - int nread; - int is_valid; - struct dhcp_packet { - struct iphdr ip; - struct udphdr udp; - struct dhcp_msg dhcp; - } packet; - int dhcp_size; - uint32_t sum; - uint16_t temp; - uint32_t saddr, daddr; - - nread = read(s, &packet, sizeof(packet)); - if (nread < 0) { - return -1; - } - /* - * The raw packet interface gives us all packets received by the - * network interface. We need to filter out all packets that are - * not meant for us. - */ - is_valid = 0; - if (nread < (int)(sizeof(struct iphdr) + sizeof(struct udphdr))) { -#if VERBOSE - ALOGD("Packet is too small (%d) to be a UDP datagram", nread); -#endif - } else if (packet.ip.version != IPVERSION || packet.ip.ihl != (sizeof(packet.ip) >> 2)) { -#if VERBOSE - ALOGD("Not a valid IP packet"); -#endif - } else if (nread < ntohs(packet.ip.tot_len)) { -#if VERBOSE - ALOGD("Packet was truncated (read %d, needed %d)", nread, ntohs(packet.ip.tot_len)); -#endif - } else if (packet.ip.protocol != IPPROTO_UDP) { -#if VERBOSE - ALOGD("IP protocol (%d) is not UDP", packet.ip.protocol); -#endif - } else if (packet.udp.dest != htons(PORT_BOOTP_CLIENT)) { -#if VERBOSE - ALOGD("UDP dest port (%d) is not DHCP client", ntohs(packet.udp.dest)); -#endif - } else { - is_valid = 1; - } - - if (!is_valid) { - return -1; - } - - /* Seems like it's probably a valid DHCP packet */ - /* validate IP header checksum */ - sum = finish_sum(checksum(&packet.ip, sizeof(packet.ip), 0)); - if (sum != 0) { - printf("IP header checksum failure (0x%x)\n", packet.ip.check); - return -1; - } - /* - * Validate the UDP checksum. - * Since we don't need the IP header anymore, we "borrow" it - * to construct the pseudo header used in the checksum calculation. - */ - dhcp_size = ntohs(packet.udp.len) - sizeof(packet.udp); - /* - * check validity of dhcp_size. - * 1) cannot be negative or zero. - * 2) src buffer contains enough bytes to copy - * 3) cannot exceed destination buffer - */ - if ((dhcp_size <= 0) || - ((int)(nread - sizeof(struct iphdr) - sizeof(struct udphdr)) < dhcp_size) || - ((int)sizeof(struct dhcp_msg) < dhcp_size)) { -#if VERBOSE - printf("Malformed Packet\n"); -#endif - return -1; - } - saddr = packet.ip.saddr; - daddr = packet.ip.daddr; - nread = ntohs(packet.ip.tot_len); - memset(&packet.ip, 0, sizeof(packet.ip)); - packet.ip.saddr = saddr; - packet.ip.daddr = daddr; - packet.ip.protocol = IPPROTO_UDP; - packet.ip.tot_len = packet.udp.len; - temp = packet.udp.check; - packet.udp.check = 0; - sum = finish_sum(checksum(&packet, nread, 0)); - packet.udp.check = temp; - if (!sum) - sum = finish_sum(sum); - if (temp != sum) { - printf("UDP header checksum failure (0x%x should be 0x%x)\n", sum, temp); - return -1; - } - memcpy(msg, &packet.dhcp, dhcp_size); - return dhcp_size; -} diff --git a/fibocom-dial/src/libmnl/dhcp/packet.h b/fibocom-dial/src/libmnl/dhcp/packet.h deleted file mode 100644 index aade392..0000000 --- a/fibocom-dial/src/libmnl/dhcp/packet.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2008, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _WIFI_PACKET_H_ -#define _WIFI_PACKET_H_ - -int open_raw_socket(const char *ifname, uint8_t *hwaddr, int if_index); -int send_packet(int s, int if_index, struct dhcp_msg *msg, int size, - uint32_t saddr, uint32_t daddr, uint32_t sport, uint32_t dport); -int receive_packet(int s, struct dhcp_msg *msg); - -#endif diff --git a/fibocom-dial/src/libmnl/ifutils.c b/fibocom-dial/src/libmnl/ifutils.c deleted file mode 100644 index 51ac9d8..0000000 --- a/fibocom-dial/src/libmnl/ifutils.c +++ /dev/null @@ -1,748 +0,0 @@ -/* This example is placed in the public domain. */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -//#include - -#include "libmnl.h" -#include "ifutils.h" - -#define ERRMSG(v...) printf("%s-%d: error=%s %s\n", __func__, __LINE__, strerror(errno), ##v) -extern void dbg_time(const char *fmt, ...); -int mask_to_prefix_v4(uint32_t mask) -{ - int ret = 0; - while (mask) - { - mask = mask & (mask - 1); - ret++; - } - return ret; -} - -const char *ipaddr_to_string_v4(in_addr_t ipaddr) -{ - static char buf[INET6_ADDRSTRLEN] = {'\0'}; - buf[0] = '\0'; - uint32_t addr = ipaddr; - return inet_ntop(AF_INET, &addr, buf, sizeof(buf)); -} - -const char *ipaddr_to_string_v6(uint8_t *ipaddr) -{ - static char buf[INET6_ADDRSTRLEN] = {'\0'}; - buf[0] = '\0'; - return inet_ntop(AF_INET6, ipaddr, buf, sizeof(buf)); -} - -static void ifc_init_ifr(const char *name, struct ifreq *ifr) -{ - memset(ifr, 0, sizeof(struct ifreq)); - strncpy(ifr->ifr_name, name, IFNAMSIZ); - ifr->ifr_name[IFNAMSIZ - 1] = 0; -} - -int if_get_hwaddr(const char *name, void *ptr) -{ - int r; - struct ifreq ifr; - ifc_init_ifr(name, &ifr); - - int ifc_ctl_sock = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0); - if (ifc_ctl_sock < 0) - { - return -1; - } - r = ioctl(ifc_ctl_sock, SIOCGIFHWADDR, &ifr); - if (r < 0) - return -1; - - memcpy(ptr, &ifr.ifr_hwaddr.sa_data, ETH_ALEN); - return 0; -} - -static int if_act_on_link(const char *ifname, int state) -{ - struct mnl_socket *nl; - char buf[MNL_SOCKET_BUFFER_SIZE]; - struct nlmsghdr *nlh; - struct ifinfomsg *ifm; - int ret; - unsigned int seq, portid, change = 0, flags = 0; - static int oldstate = -1; - - if (state == oldstate) - return 0; - oldstate = state; - - if (state) - { - change |= IFF_UP; - flags |= IFF_UP; - } - else - { - change |= IFF_UP; - flags &= ~IFF_UP; - } - - nlh = mnl_nlmsg_put_header(buf); - nlh->nlmsg_type = RTM_NEWLINK; - nlh->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; - nlh->nlmsg_seq = seq = time(NULL); - ifm = mnl_nlmsg_put_extra_header(nlh, sizeof(*ifm)); - ifm->ifi_family = AF_UNSPEC; - ifm->ifi_change = change; - ifm->ifi_flags = flags; - - mnl_attr_put_str(nlh, IFLA_IFNAME, ifname); - - nl = mnl_socket_open(NETLINK_ROUTE); - if (nl == NULL) - { - ERRMSG("mnl_socket_open"); - return -1; - } - - if (mnl_socket_bind(nl, 0, MNL_SOCKET_AUTOPID) < 0) - { - ERRMSG(" mnl_socket_bind"); - return -1; - } - portid = mnl_socket_get_portid(nl); - - if (mnl_socket_sendto(nl, nlh, nlh->nlmsg_len) < 0) - { - ERRMSG(" mnl_socket_sendto"); - return -1; - } - - ret = mnl_socket_recvfrom(nl, buf, sizeof(buf)); - if (ret == -1) - { - ERRMSG(" mnl_socket_recvfrom"); - return -1; - } - - ret = mnl_cb_run(buf, ret, seq, portid, NULL, NULL); - if (ret == -1) - { - ERRMSG(" mnl_cb_run"); - return -1; - } - - mnl_socket_close(nl); - - return 0; -} - -int if_link_up(const char *ifname) -{ - dbg_time("if_link_up %s",ifname); - return if_act_on_link(ifname, 1); -} - -int if_link_down(const char *ifname) -{ - - dbg_time("if_link_down %s",ifname); - return if_act_on_link(ifname, 0); -} - -int if_set_mtu(const char *ifname, uint32_t mtu) -{ - char buf[MNL_SOCKET_BUFFER_SIZE]; - unsigned int seq, portid; - struct mnl_socket *nl; - struct nlmsghdr *nlh; - struct ifinfomsg *ifm; - int ret; - int iface; - static uint32_t oldmtu = 1500; - - if (mtu == oldmtu) - return 0; - oldmtu = mtu; - - iface = if_nametoindex(ifname); - if (iface == 0) - { - ERRMSG(" if_nametoindex"); - return -1; - } - - nlh = mnl_nlmsg_put_header(buf); - nlh->nlmsg_type = RTM_NEWLINK; - nlh->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; - nlh->nlmsg_seq = seq = time(NULL); - ifm = mnl_nlmsg_put_extra_header(nlh, sizeof(struct ifinfomsg)); - ifm->ifi_family = AF_UNSPEC; - ifm->ifi_index = iface; - ifm->ifi_change = 0xFFFFFFFF; - ifm->ifi_type = 0; - ifm->ifi_flags = IFF_NOARP | IFF_MULTICAST; - - mnl_attr_put_u32(nlh, IFLA_MTU, mtu); - - nl = mnl_socket_open(NETLINK_ROUTE); - if (nl == NULL) - { - ERRMSG(" mnl_socket_open"); - return -1; - } - - if (mnl_socket_bind(nl, 0, MNL_SOCKET_AUTOPID) < 0) - { - ERRMSG(" mnl_socket_bind"); - return -1; - } - portid = mnl_socket_get_portid(nl); - - if (mnl_socket_sendto(nl, nlh, nlh->nlmsg_len) < 0) - { - ERRMSG(" mnl_socket_sendto"); - return -1; - } - - ret = mnl_socket_recvfrom(nl, buf, sizeof(buf)); - if (ret == -1) - { - ERRMSG(" mnl_socket_recvfrom"); - return -1; - } - - ret = mnl_cb_run(buf, ret, seq, portid, NULL, NULL); - if (ret == -1) - { - ERRMSG(" mnl_cb_run"); - return -1; - } - - mnl_socket_close(nl); - - return 0; -} - -/** - * @brief Set the ip addr object - * - * @param operate - * 0 -> add address on interface - * 1 -> delete address on interface - * @param ifname - * @param ipaddr - * @param prefix - * @return int - */ -static int if_act_on_addr(bool operate, int proto, const char *ifname, addr_t *ipaddr, uint32_t prefix) -{ - struct mnl_socket *nl; - char buf[MNL_SOCKET_BUFFER_SIZE]; - struct nlmsghdr *nlh; - struct ifaddrmsg *ifm; - uint32_t seq, portid; - int ret, family = proto; - - int iface; - - iface = if_nametoindex(ifname); - if (iface == 0) - { - ERRMSG(" if_nametoindex"); - return -1; - } - - nlh = mnl_nlmsg_put_header(buf); - if (operate) - nlh->nlmsg_type = RTM_NEWADDR; - else - nlh->nlmsg_type = RTM_DELADDR; - - nlh->nlmsg_flags = NLM_F_REQUEST | NLM_F_CREATE | NLM_F_REPLACE | NLM_F_ACK; - nlh->nlmsg_seq = seq = time(NULL); - - ifm = mnl_nlmsg_put_extra_header(nlh, sizeof(struct ifaddrmsg)); - - ifm->ifa_family = family; - ifm->ifa_prefixlen = prefix; - ifm->ifa_flags = IFA_F_PERMANENT; - - ifm->ifa_scope = RT_SCOPE_UNIVERSE; - ifm->ifa_index = iface; - - /* - * The exact meaning of IFA_LOCAL and IFA_ADDRESS depend - * on the address family being used and the device type. - * For broadcast devices (like the interfaces we use), - * for IPv4 we specify both and they are used interchangeably. - * For IPv6, only IFA_ADDRESS needs to be set. - */ - if (family == AF_INET) - { - mnl_attr_put_u32(nlh, IFA_LOCAL, ipaddr->ip); - mnl_attr_put_u32(nlh, IFA_ADDRESS, ipaddr->ip); - } - else - { - mnl_attr_put(nlh, IFA_ADDRESS, sizeof(struct in6_addr), ipaddr); - } - - nl = mnl_socket_open(NETLINK_ROUTE); - if (nl == NULL) - { - ERRMSG(" mnl_socket_open"); - return -1; - } - - if (mnl_socket_bind(nl, 0, MNL_SOCKET_AUTOPID) < 0) - { - ERRMSG(" mnl_socket_bind"); - return -1; - } - portid = mnl_socket_get_portid(nl); - - if (mnl_socket_sendto(nl, nlh, nlh->nlmsg_len) < 0) - { - ERRMSG(" mnl_socket_sendto"); - return -1; - } - - ret = mnl_socket_recvfrom(nl, buf, sizeof(buf)); - if (ret < 0) - { - ERRMSG(" mnl_socket_recvfrom"); - return -1; - } - - ret = mnl_cb_run(buf, ret, seq, portid, NULL, NULL); - if (ret < 0) - { - ERRMSG(" mnl_cb_run"); - return -1; - } - - mnl_socket_close(nl); - - return 0; -} - -int if_set_addr_v4(const char *ifname, in_addr_t ipaddr, uint32_t prefix) -{ - addr_t addr; - addr.ip = ipaddr; - return if_act_on_addr(1, AF_INET, ifname, &addr, prefix); -} - -int if_del_addr_v4(const char *ifname, in_addr_t ipaddr, uint32_t prefix) -{ - addr_t addr; - addr.ip = ipaddr; - return if_act_on_addr(0, AF_INET, ifname, &addr, prefix); -} - -int if_set_addr_v6(const char *ifname, uint8_t *ipaddr, uint32_t prefix) -{ - addr_t addr; - memcpy(&addr.ip6, ipaddr, 16); - return if_act_on_addr(1, AF_INET6, ifname, &addr, prefix); -} - -int if_del_addr_v6(const char *ifname, uint8_t *ipaddr, uint32_t prefix) -{ - addr_t addr; - memcpy(&addr.ip6, ipaddr, 16); - return if_act_on_addr(0, AF_INET6, ifname, &addr, prefix); -} - -static int data_attr_cb(const struct nlattr *attr, void *data) -{ - const struct nlattr **tb = data; - int type = mnl_attr_get_type(attr); - - /* skip unsupported attribute in user-space */ - if (mnl_attr_type_valid(attr, IFA_MAX) < 0) - return MNL_CB_OK; - - switch (type) - { - case IFA_ADDRESS: - if (mnl_attr_validate(attr, MNL_TYPE_BINARY) < 0) - { - ERRMSG(" mnl_attr_validate"); - return MNL_CB_ERROR; - } - break; - } - tb[type] = attr; - return MNL_CB_OK; -} - -static int data_cb(const struct nlmsghdr *nlh, void *data) -{ - struct nlattr *tb[IFA_MAX + 1] = {}; - struct ifaddrmsg *ifa = mnl_nlmsg_get_payload(nlh); - struct addrinfo_t *addrinfo = (struct addrinfo_t *)data; - void *addr = NULL; - - mnl_attr_parse(nlh, sizeof(*ifa), data_attr_cb, tb); - if (tb[IFA_ADDRESS]) - { - char out[INET6_ADDRSTRLEN]; - - addr = mnl_attr_get_payload(tb[IFLA_ADDRESS]); - addr = mnl_attr_get_payload(tb[IFA_ADDRESS]); - if (!inet_ntop(ifa->ifa_family, addr, out, sizeof(out))) - ERRMSG("inet_ntop"); - // printf("%d %d-> %d %s\n", addrinfo->iface, ifa->ifa_index, ifa->ifa_scope, out); - - addrinfo->addrs[addrinfo->num].prefix = ifa->ifa_prefixlen; - if (ifa->ifa_index == addrinfo->iface) - { - if (ifa->ifa_family == AF_INET6) - memcpy(addrinfo->addrs[addrinfo->num].address.ip6.s6_addr, addr, 16); - if (ifa->ifa_family == AF_INET) - memcpy(&(addrinfo->addrs[addrinfo->num].address.ip), addr, 4); - addrinfo->num++; - } - } - - // ifa->ifa_scope - // 0: global - // 200: site - // 253: link - // 254: host - // 255: nowhere - - return MNL_CB_OK; -} - -/** - * @brief - * - * @param ifname - * @param proto - * AF_INET -> for IPv4 - * AF_INET6 -> for IPv6 - * @return int - */ -static int if_get_addr(const char *ifname, int proto, struct addrinfo_t *addrinfo) -{ - char buf[MNL_SOCKET_BUFFER_SIZE]; - unsigned int seq, portid; - struct mnl_socket *nl; - struct nlmsghdr *nlh; - struct rtgenmsg *rt; - int ret; - - addrinfo->iface = if_nametoindex(ifname); - if (addrinfo->iface == 0) - { - ERRMSG(" if_nametoindex"); - return -1; - } - - nlh = mnl_nlmsg_put_header(buf); - nlh->nlmsg_type = RTM_GETADDR; - nlh->nlmsg_flags = NLM_F_REQUEST | NLM_F_DUMP; - nlh->nlmsg_seq = seq = time(NULL); - rt = mnl_nlmsg_put_extra_header(nlh, sizeof(struct rtgenmsg)); - if (proto == AF_INET) - rt->rtgen_family = AF_INET; - else if (proto == AF_INET6) - rt->rtgen_family = AF_INET6; - - nl = mnl_socket_open(NETLINK_ROUTE); - if (nl == NULL) - { - ERRMSG(" mnl_socket_open"); - return -1; - } - - if (mnl_socket_bind(nl, 0, MNL_SOCKET_AUTOPID) < 0) - { - ERRMSG(" mnl_socket_bind"); - return -1; - } - portid = mnl_socket_get_portid(nl); - - if (mnl_socket_sendto(nl, nlh, nlh->nlmsg_len) < 0) - { - ERRMSG(" mnl_socket_sendto"); - return -1; - } - - ret = mnl_socket_recvfrom(nl, buf, sizeof(buf)); - while (ret > 0) - { - ret = mnl_cb_run(buf, ret, seq, portid, data_cb, addrinfo); - if (ret <= MNL_CB_STOP) - break; - ret = mnl_socket_recvfrom(nl, buf, sizeof(buf)); - } - if (ret == -1) - { - ERRMSG(" error"); - return -1; - } - mnl_socket_close(nl); - - return 0; -} - -int if_flush_v4_addr(const char *ifname) -{ - struct addrinfo_t addrinfo; - int i = 0; - - memset(&addrinfo, 0, sizeof(struct addrinfo_t)); - if_get_addr(ifname, AF_INET, &addrinfo); - for (; i < addrinfo.num; i++) - { - // printf("remove address: %s\n", ipaddr_to_string_v4(addrinfo.addrs[i].address.ip)); - if_del_addr_v4(ifname, addrinfo.addrs[i].address.ip, addrinfo.addrs[i].prefix); - } - return 0; -} - -int if_flush_v6_addr(const char *ifname) -{ - struct addrinfo_t addrinfo; - int i = 0; - - memset(&addrinfo, 0, sizeof(struct addrinfo_t)); - if_get_addr(ifname, AF_INET6, &addrinfo); - for (; i < addrinfo.num; i++) - { - // printf("remove address: %s\n", ipaddr_to_string_v6(addrinfo.addrs[i].address.ip6.s6_addr)); - if_del_addr_v6(ifname, addrinfo.addrs[i].address.ip6.s6_addr, addrinfo.addrs[i].prefix); - } - return 0; -} - -/** - * @brief Set the route addr object - * Usage: - * iface destination cidr [gateway] - * Example: - * eth0 10.0.1.12 32 10.0.1.11 - * eth0 ffff::10.0.1.12 128 fdff::1 - * @param operate - * add or del - * @param ifname - * @param dstaddr - * @param prefix - * @param gwaddr - * @return int - */ -int if_act_on_route(bool operate, int proto, const char *ifname, addr_t *dstaddr, uint32_t prefix, addr_t *gwaddr) -{ - struct mnl_socket *nl; - char buf[MNL_SOCKET_BUFFER_SIZE]; - struct nlmsghdr *nlh; - struct rtmsg *rtm; - uint32_t seq, portid; - int iface, ret, family = proto; - - iface = if_nametoindex(ifname); - if (iface == 0) - { - ERRMSG(" if_nametoindex"); - return -1; - } - - nlh = mnl_nlmsg_put_header(buf); - if (operate) - nlh->nlmsg_type = RTM_NEWROUTE; - else - nlh->nlmsg_type = RTM_DELROUTE; - - nlh->nlmsg_flags = NLM_F_REQUEST | NLM_F_CREATE | NLM_F_ACK; - nlh->nlmsg_seq = seq = time(NULL); - - rtm = mnl_nlmsg_put_extra_header(nlh, sizeof(struct rtmsg)); - rtm->rtm_family = family; - rtm->rtm_dst_len = prefix; - rtm->rtm_src_len = 0; - rtm->rtm_tos = 0; - rtm->rtm_protocol = RTPROT_STATIC; - rtm->rtm_table = RT_TABLE_MAIN; - rtm->rtm_type = RTN_UNICAST; - /* is there any gateway? */ - rtm->rtm_scope = gwaddr ? RT_SCOPE_UNIVERSE : RT_SCOPE_LINK; - rtm->rtm_flags = 0; - - if (family == AF_INET) - mnl_attr_put_u32(nlh, RTA_DST, dstaddr->ip); - else - mnl_attr_put(nlh, RTA_DST, sizeof(struct in6_addr), dstaddr); - - mnl_attr_put_u32(nlh, RTA_OIF, iface); - if (gwaddr) - { - if (family == AF_INET) - mnl_attr_put_u32(nlh, RTA_GATEWAY, gwaddr->ip); - else - { - mnl_attr_put(nlh, RTA_GATEWAY, sizeof(struct in6_addr), gwaddr); - } - } - - nl = mnl_socket_open(NETLINK_ROUTE); - if (nl == NULL) - { - ERRMSG(" mnl_socket_open"); - return -1; - } - - if (mnl_socket_bind(nl, 0, MNL_SOCKET_AUTOPID) < 0) - { - ERRMSG(" mnl_socket_bind"); - return -1; - } - portid = mnl_socket_get_portid(nl); - - if (mnl_socket_sendto(nl, nlh, nlh->nlmsg_len) < 0) - { - ERRMSG(" mnl_socket_sendto"); - return -1; - } - - ret = mnl_socket_recvfrom(nl, buf, sizeof(buf)); - if (ret < 0) - { - ERRMSG(" mnl_socket_recvfrom"); - return -1; - } - - ret = mnl_cb_run(buf, ret, seq, portid, NULL, NULL); - if (ret < 0) - { - ERRMSG(" mnl_cb_run"); - return -1; - } - - mnl_socket_close(nl); - - return 0; -} - -int if_set_default_route_v4(const char *ifname) -{ - return if_act_on_route(1, AF_INET, ifname, (addr_t *)&in6addr_any, 0, NULL); -} - -int if_del_default_route_v4(const char *ifname) -{ - return if_act_on_route(0, AF_INET, ifname, (addr_t *)&in6addr_any, 0, NULL); -} - -int if_set_default_route_v6(const char *ifname) -{ - return if_act_on_route(1, AF_INET6, ifname, (addr_t *)&in6addr_any, 0, NULL); -} - -int if_del_default_route_v6(const char *ifname) -{ - return if_act_on_route(0, AF_INET6, ifname, (addr_t *)&in6addr_any, 0, NULL); -} - -/** - * @brief Set the default gwaddr object - * set default gw - * @param operate - * @param ifname - * @param gwaddr - * gateway ip - * @return int - */ -int if_set_route_gw_v4(const char *ifname, in_addr_t gwaddr) -{ - addr_t addr; - memset(&addr, 0, sizeof(addr_t)); - addr.ip = gwaddr; - return if_act_on_route(1, AF_INET, ifname, (addr_t *)&in6addr_any, 0, &addr); -} - -int if_del_route_gw_v4(const char *ifname, in_addr_t gwaddr) -{ - addr_t addr; - memset(&addr, 0, sizeof(addr_t)); - addr.ip = gwaddr; - return if_act_on_route(0, AF_INET, ifname, (addr_t *)&in6addr_any, 0, &addr); -} - -int if_set_route_gw_v6(const char *ifname, uint8_t *gwaddr) -{ - addr_t addr; - memset(&addr, 0, sizeof(addr_t)); - memcpy(&addr.ip6, gwaddr, 16); - return if_act_on_route(1, AF_INET6, ifname, (addr_t *)&in6addr_any, 0, &addr); -} - -int if_del_route_gw_v6(const char *ifname, uint8_t *gwaddr) -{ - addr_t addr; - memset(&addr, 0, sizeof(addr_t)); - memcpy(&addr.ip6, gwaddr, 16); - return if_act_on_route(0, AF_INET6, ifname, (addr_t *)&in6addr_any, 0, &addr); -} - -int if_set_dns(const char *dns1, const char *dns2) -{ - int ret = 0; - char buf[128] = {'\0'}; - int fd = open("/etc/resolv.conf", O_CREAT | O_WRONLY | O_TRUNC); - if (fd < 0) - { - ERRMSG(" fail to open /etc/resolv.conf"); - return -1; - } - - if (dns1) - snprintf(buf, sizeof(buf), "nameserver %s\n", dns1); - if (dns2) - snprintf(buf, sizeof(buf), "nameserver %s\n", dns2); - ret = write(fd, buf, strlen(buf)); - if (ret < 0) - { - ERRMSG(" write dns"); - } - close(fd); - return ret > 0 ? 0 : -1; -} - -int if_set_network_v4(const char *ifname, in_addr_t ipaddr, uint32_t prefix, - in_addr_t gwaddr, in_addr_t dns1, in_addr_t dns2) -{ - if_link_up(ifname); - sleep(2); - if_set_addr_v4(ifname, ipaddr, prefix); - if_set_default_route_v4(ifname); - if_set_dns(ipaddr_to_string_v4(dns1), ipaddr_to_string_v4(dns2)); - return 0; -} - -int if_set_network_v6(const char *ifname, uint8_t *ipaddr, uint32_t prefix, - uint8_t *gwaddr, uint8_t *dns1, uint8_t *dns2) -{ - if_link_up(ifname); - sleep(2); - if_set_addr_v6(ifname, ipaddr, prefix); - if_set_default_route_v6(ifname); - if_set_dns(ipaddr_to_string_v6(dns1), ipaddr_to_string_v6(dns2)); - return 0; -} diff --git a/fibocom-dial/src/libmnl/ifutils.h b/fibocom-dial/src/libmnl/ifutils.h deleted file mode 100644 index 4c2b565..0000000 --- a/fibocom-dial/src/libmnl/ifutils.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef __IFUTILS_H__ -#define __IFUTILS_H__ - -typedef union { - in_addr_t ip; - struct in6_addr ip6; -} addr_t; - -#define MAX_IP_NUM 32 -struct addrinfo_t -{ - int iface; - int num; - struct - { - int prefix; - addr_t address; - } addrs[MAX_IP_NUM]; -}; - -const char *ipaddr_to_string_v4(in_addr_t ipaddr); -const char *ipaddr_to_string_v6(uint8_t *ipaddr); -int mask_to_prefix_v4(in_addr_t mask); - -int if_get_hwaddr(const char *name, void *ptr); - -int if_link_down(const char *ifname); -int if_link_up(const char *ifname); -int if_set_mtu(const char *ifname, uint32_t mtu); - -int if_set_addr_v4(const char *name, in_addr_t address, uint32_t prefixlen); -int if_del_addr_v4(const char *name, in_addr_t address, uint32_t prefixlen); -int if_set_addr_v6(const char *name, uint8_t *address, uint32_t prefixlen); -int if_del_addr_v6(const char *name, uint8_t *address, uint32_t prefixlen); -int if_flush_v4_addr(const char *ifname); -int if_flush_v6_addr(const char *ifname); - -int if_set_route_gw_v4(const char *ifname, in_addr_t gwaddr); -int if_del_route_gw_v4(const char *ifname, in_addr_t gwaddr); -int if_set_default_route_v4(const char *ifname); -int if_del_default_route_v4(const char *ifname); - -int if_set_route_gw_v6(const char *ifname, uint8_t *gwaddr); -int if_del_route_gw_v6(const char *ifname, uint8_t *gwaddr); -int if_set_default_route_v6(const char *ifname); -int if_del_default_route_v6(const char *ifname); - -int if_set_network_v4(const char *ifname, in_addr_t ipaddr, uint32_t prefix, - in_addr_t gwaddr, in_addr_t dns1, in_addr_t dns2); -int if_set_network_v6(const char *ifname, uint8_t *ipaddr, uint32_t prefix, - uint8_t *gwaddr, uint8_t *dns1, uint8_t *dns2); - -#endif //__IFUTILS_H__ \ No newline at end of file diff --git a/fibocom-dial/src/libmnl/libmnl.h b/fibocom-dial/src/libmnl/libmnl.h deleted file mode 100644 index 4bd0b92..0000000 --- a/fibocom-dial/src/libmnl/libmnl.h +++ /dev/null @@ -1,202 +0,0 @@ -#ifndef _LIBMNL_H_ -#define _LIBMNL_H_ - -#include -#include -#include -#include -#include /* for sa_family_t */ -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Netlink socket API - */ - -#define MNL_SOCKET_AUTOPID 0 -#define MNL_SOCKET_BUFFER_SIZE (sysconf(_SC_PAGESIZE) < 8192L ? sysconf(_SC_PAGESIZE) : 8192L) -#define MNL_SOCKET_DUMP_SIZE 32768 - -struct mnl_socket; - -extern struct mnl_socket *mnl_socket_open(int bus); -extern struct mnl_socket *mnl_socket_open2(int bus, int flags); -extern struct mnl_socket *mnl_socket_fdopen(int fd); -extern int mnl_socket_bind(struct mnl_socket *nl, unsigned int groups, pid_t pid); -extern int mnl_socket_close(struct mnl_socket *nl); -extern int mnl_socket_get_fd(const struct mnl_socket *nl); -extern unsigned int mnl_socket_get_portid(const struct mnl_socket *nl); -extern ssize_t mnl_socket_sendto(const struct mnl_socket *nl, const void *req, size_t siz); -extern ssize_t mnl_socket_recvfrom(const struct mnl_socket *nl, void *buf, size_t siz); -extern int mnl_socket_setsockopt(const struct mnl_socket *nl, int type, void *buf, socklen_t len); -extern int mnl_socket_getsockopt(const struct mnl_socket *nl, int type, void *buf, socklen_t *len); - -/* - * Netlink message API - */ - -#define MNL_ALIGNTO 4 -#define MNL_ALIGN(len) (((len)+MNL_ALIGNTO-1) & ~(MNL_ALIGNTO-1)) -#define MNL_NLMSG_HDRLEN MNL_ALIGN(sizeof(struct nlmsghdr)) - -extern size_t mnl_nlmsg_size(size_t len); -extern size_t mnl_nlmsg_get_payload_len(const struct nlmsghdr *nlh); - -/* Netlink message header builder */ -extern struct nlmsghdr *mnl_nlmsg_put_header(void *buf); -extern void *mnl_nlmsg_put_extra_header(struct nlmsghdr *nlh, size_t size); - -/* Netlink message iterators */ -extern bool mnl_nlmsg_ok(const struct nlmsghdr *nlh, int len); -extern struct nlmsghdr *mnl_nlmsg_next(const struct nlmsghdr *nlh, int *len); - -/* Netlink sequence tracking */ -extern bool mnl_nlmsg_seq_ok(const struct nlmsghdr *nlh, unsigned int seq); - -/* Netlink portID checking */ -extern bool mnl_nlmsg_portid_ok(const struct nlmsghdr *nlh, unsigned int portid); - -/* Netlink message getters */ -extern void *mnl_nlmsg_get_payload(const struct nlmsghdr *nlh); -extern void *mnl_nlmsg_get_payload_offset(const struct nlmsghdr *nlh, size_t offset); -extern void *mnl_nlmsg_get_payload_tail(const struct nlmsghdr *nlh); - -/* Netlink message printer */ -extern void mnl_nlmsg_fprintf(FILE *fd, const void *data, size_t datalen, size_t extra_header_size); - -/* Message batch helpers */ -struct mnl_nlmsg_batch; -extern struct mnl_nlmsg_batch *mnl_nlmsg_batch_start(void *buf, size_t bufsiz); -extern bool mnl_nlmsg_batch_next(struct mnl_nlmsg_batch *b); -extern void mnl_nlmsg_batch_stop(struct mnl_nlmsg_batch *b); -extern size_t mnl_nlmsg_batch_size(struct mnl_nlmsg_batch *b); -extern void mnl_nlmsg_batch_reset(struct mnl_nlmsg_batch *b); -extern void *mnl_nlmsg_batch_head(struct mnl_nlmsg_batch *b); -extern void *mnl_nlmsg_batch_current(struct mnl_nlmsg_batch *b); -extern bool mnl_nlmsg_batch_is_empty(struct mnl_nlmsg_batch *b); - -/* - * Netlink attributes API - */ -#define MNL_ATTR_HDRLEN MNL_ALIGN(sizeof(struct nlattr)) - -/* TLV attribute getters */ -extern uint16_t mnl_attr_get_type(const struct nlattr *attr); -extern uint16_t mnl_attr_get_len(const struct nlattr *attr); -extern uint16_t mnl_attr_get_payload_len(const struct nlattr *attr); -extern void *mnl_attr_get_payload(const struct nlattr *attr); -extern uint8_t mnl_attr_get_u8(const struct nlattr *attr); -extern uint16_t mnl_attr_get_u16(const struct nlattr *attr); -extern uint32_t mnl_attr_get_u32(const struct nlattr *attr); -extern uint64_t mnl_attr_get_u64(const struct nlattr *attr); -extern const char *mnl_attr_get_str(const struct nlattr *attr); - -/* TLV attribute putters */ -extern void mnl_attr_put(struct nlmsghdr *nlh, uint16_t type, size_t len, const void *data); -extern void mnl_attr_put_u8(struct nlmsghdr *nlh, uint16_t type, uint8_t data); -extern void mnl_attr_put_u16(struct nlmsghdr *nlh, uint16_t type, uint16_t data); -extern void mnl_attr_put_u32(struct nlmsghdr *nlh, uint16_t type, uint32_t data); -extern void mnl_attr_put_u64(struct nlmsghdr *nlh, uint16_t type, uint64_t data); -extern void mnl_attr_put_str(struct nlmsghdr *nlh, uint16_t type, const char *data); -extern void mnl_attr_put_strz(struct nlmsghdr *nlh, uint16_t type, const char *data); - -/* TLV attribute putters with buffer boundary checkings */ -extern bool mnl_attr_put_check(struct nlmsghdr *nlh, size_t buflen, uint16_t type, size_t len, const void *data); -extern bool mnl_attr_put_u8_check(struct nlmsghdr *nlh, size_t buflen, uint16_t type, uint8_t data); -extern bool mnl_attr_put_u16_check(struct nlmsghdr *nlh, size_t buflen, uint16_t type, uint16_t data); -extern bool mnl_attr_put_u32_check(struct nlmsghdr *nlh, size_t buflen, uint16_t type, uint32_t data); -extern bool mnl_attr_put_u64_check(struct nlmsghdr *nlh, size_t buflen, uint16_t type, uint64_t data); -extern bool mnl_attr_put_str_check(struct nlmsghdr *nlh, size_t buflen, uint16_t type, const char *data); -extern bool mnl_attr_put_strz_check(struct nlmsghdr *nlh, size_t buflen, uint16_t type, const char *data); - -/* TLV attribute nesting */ -extern struct nlattr *mnl_attr_nest_start(struct nlmsghdr *nlh, uint16_t type); -extern struct nlattr *mnl_attr_nest_start_check(struct nlmsghdr *nlh, size_t buflen, uint16_t type); -extern void mnl_attr_nest_end(struct nlmsghdr *nlh, struct nlattr *start); -extern void mnl_attr_nest_cancel(struct nlmsghdr *nlh, struct nlattr *start); - -/* TLV validation */ -extern int mnl_attr_type_valid(const struct nlattr *attr, uint16_t maxtype); - -enum mnl_attr_data_type { - MNL_TYPE_UNSPEC, - MNL_TYPE_U8, - MNL_TYPE_U16, - MNL_TYPE_U32, - MNL_TYPE_U64, - MNL_TYPE_STRING, - MNL_TYPE_FLAG, - MNL_TYPE_MSECS, - MNL_TYPE_NESTED, - MNL_TYPE_NESTED_COMPAT, - MNL_TYPE_NUL_STRING, - MNL_TYPE_BINARY, - MNL_TYPE_MAX, -}; - -extern int mnl_attr_validate(const struct nlattr *attr, enum mnl_attr_data_type type); -extern int mnl_attr_validate2(const struct nlattr *attr, enum mnl_attr_data_type type, size_t len); - -/* TLV iterators */ -extern bool mnl_attr_ok(const struct nlattr *attr, int len); -extern struct nlattr *mnl_attr_next(const struct nlattr *attr); - -#define mnl_attr_for_each(attr, nlh, offset) \ - for ((attr) = mnl_nlmsg_get_payload_offset((nlh), (offset)); \ - mnl_attr_ok((attr), (char *)mnl_nlmsg_get_payload_tail(nlh) - (char *)(attr)); \ - (attr) = mnl_attr_next(attr)) - -#define mnl_attr_for_each_nested(attr, nest) \ - for ((attr) = mnl_attr_get_payload(nest); \ - mnl_attr_ok((attr), (char *)mnl_attr_get_payload(nest) + mnl_attr_get_payload_len(nest) - (char *)(attr)); \ - (attr) = mnl_attr_next(attr)) - -#define mnl_attr_for_each_payload(payload, payload_size) \ - for ((attr) = (payload); \ - mnl_attr_ok((attr), (char *)(payload) + payload_size - (char *)(attr)); \ - (attr) = mnl_attr_next(attr)) - -/* TLV callback-based attribute parsers */ -typedef int (*mnl_attr_cb_t)(const struct nlattr *attr, void *data); - -extern int mnl_attr_parse(const struct nlmsghdr *nlh, unsigned int offset, mnl_attr_cb_t cb, void *data); -extern int mnl_attr_parse_nested(const struct nlattr *attr, mnl_attr_cb_t cb, void *data); -extern int mnl_attr_parse_payload(const void *payload, size_t payload_len, mnl_attr_cb_t cb, void *data); - -/* - * callback API - */ -#define MNL_CB_ERROR -1 -#define MNL_CB_STOP 0 -#define MNL_CB_OK 1 - -typedef int (*mnl_cb_t)(const struct nlmsghdr *nlh, void *data); - -extern int mnl_cb_run(const void *buf, size_t numbytes, unsigned int seq, - unsigned int portid, mnl_cb_t cb_data, void *data); - -extern int mnl_cb_run2(const void *buf, size_t numbytes, unsigned int seq, - unsigned int portid, mnl_cb_t cb_data, void *data, - const mnl_cb_t *cb_ctl_array, - unsigned int cb_ctl_array_len); - -/* - * other declarations - */ - -#ifndef SOL_NETLINK -#define SOL_NETLINK 270 -#endif - -#ifndef MNL_ARRAY_SIZE -#define MNL_ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0])) -#endif - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif diff --git a/fibocom-dial/src/libmnl/nlmsg.c b/fibocom-dial/src/libmnl/nlmsg.c deleted file mode 100644 index d960cf3..0000000 --- a/fibocom-dial/src/libmnl/nlmsg.c +++ /dev/null @@ -1,556 +0,0 @@ -/* - * (C) 2008-2010 by Pablo Neira Ayuso - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - */ -#include -#include -#include -#include -#include -#include - -#include "libmnl.h" - -/** - * \defgroup nlmsg Netlink message helpers - * - * Netlink message: - * \verbatim - |<----------------- 4 bytes ------------------->| - |<----- 2 bytes ------>|<------- 2 bytes ------>| - |-----------------------------------------------| - | Message length (including header) | - |-----------------------------------------------| - | Message type | Message flags | - |-----------------------------------------------| - | Message sequence number | - |-----------------------------------------------| - | Netlink PortID | - |-----------------------------------------------| - | | - . Payload . - |_______________________________________________| -\endverbatim - * - * There is usually an extra header after the the Netlink header (at the - * beginning of the payload). This extra header is specific of the Netlink - * subsystem. After this extra header, it comes the sequence of attributes - * that are expressed in Type-Length-Value (TLV) format. - * - * @{ - */ - -/** - * mnl_nlmsg_size - calculate the size of Netlink message (without alignment) - * \param len length of the Netlink payload - * - * This function returns the size of a netlink message (header plus payload) - * without alignment. - */ -size_t mnl_nlmsg_size(size_t len) -{ - return len + MNL_NLMSG_HDRLEN; -} - -/** - * mnl_nlmsg_get_payload_len - get the length of the Netlink payload - * \param nlh pointer to the header of the Netlink message - * - * This function returns the Length of the netlink payload, ie. the length - * of the full message minus the size of the Netlink header. - */ -size_t mnl_nlmsg_get_payload_len(const struct nlmsghdr *nlh) -{ - return nlh->nlmsg_len - MNL_NLMSG_HDRLEN; -} - -/** - * mnl_nlmsg_put_header - reserve and prepare room for Netlink header - * \param buf memory already allocated to store the Netlink header - * - * This function sets to zero the room that is required to put the Netlink - * header in the memory buffer passed as parameter. This function also - * initializes the nlmsg_len field to the size of the Netlink header. This - * function returns a pointer to the Netlink header structure. - */ -struct nlmsghdr *mnl_nlmsg_put_header(void *buf) -{ - int len = MNL_ALIGN(sizeof(struct nlmsghdr)); - struct nlmsghdr *nlh = buf; - - memset(buf, 0, len); - nlh->nlmsg_len = len; - return nlh; -} - -/** - * mnl_nlmsg_put_extra_header - reserve and prepare room for an extra header - * \param nlh pointer to Netlink header - * \param size size of the extra header that we want to put - * - * This function sets to zero the room that is required to put the extra - * header after the initial Netlink header. This function also increases - * the nlmsg_len field. You have to invoke mnl_nlmsg_put_header() before - * you call this function. This function returns a pointer to the extra - * header. - */ -void *mnl_nlmsg_put_extra_header(struct nlmsghdr *nlh, - size_t size) -{ - char *ptr = (char *)nlh + nlh->nlmsg_len; - size_t len = MNL_ALIGN(size); - nlh->nlmsg_len += len; - memset(ptr, 0, len); - return ptr; -} - -/** - * mnl_nlmsg_get_payload - get a pointer to the payload of the netlink message - * \param nlh pointer to a netlink header - * - * This function returns a pointer to the payload of the netlink message. - */ -void *mnl_nlmsg_get_payload(const struct nlmsghdr *nlh) -{ - return (void *)nlh + MNL_NLMSG_HDRLEN; -} - -/** - * mnl_nlmsg_get_payload_offset - get a pointer to the payload of the message - * \param nlh pointer to a netlink header - * \param offset offset to the payload of the attributes TLV set - * - * This function returns a pointer to the payload of the netlink message plus - * a given offset. - */ -void *mnl_nlmsg_get_payload_offset(const struct nlmsghdr *nlh, - size_t offset) -{ - return (void *)nlh + MNL_NLMSG_HDRLEN + MNL_ALIGN(offset); -} - -/** - * mnl_nlmsg_ok - check a there is room for netlink message - * \param nlh netlink message that we want to check - * \param len remaining bytes in a buffer that contains the netlink message - * - * This function is used to check that a buffer that contains a netlink - * message has enough room for the netlink message that it stores, ie. this - * function can be used to verify that a netlink message is not malformed nor - * truncated. - * - * This function does not set errno in case of error since it is intended - * for iterations. Thus, it returns true on success and false on error. - * - * The len parameter may become negative in malformed messages during message - * iteration, that is why we use a signed integer. - */ -bool mnl_nlmsg_ok(const struct nlmsghdr *nlh, int len) -{ - return len >= (int)sizeof(struct nlmsghdr) && - nlh->nlmsg_len >= sizeof(struct nlmsghdr) && - (int)nlh->nlmsg_len <= len; -} - -/** - * mnl_nlmsg_next - get the next netlink message in a multipart message - * \param nlh current netlink message that we are handling - * \param len length of the remaining bytes in the buffer (passed by reference). - * - * This function returns a pointer to the next netlink message that is part - * of a multi-part netlink message. Netlink can batch several messages into - * one buffer so that the receiver has to iterate over the whole set of - * Netlink messages. - * - * You have to use mnl_nlmsg_ok() to check if the next Netlink message is - * valid. - */ -struct nlmsghdr *mnl_nlmsg_next(const struct nlmsghdr *nlh, - int *len) -{ - *len -= MNL_ALIGN(nlh->nlmsg_len); - return (struct nlmsghdr *)((void *)nlh + MNL_ALIGN(nlh->nlmsg_len)); -} - -/** - * mnl_nlmsg_get_payload_tail - get the ending of the netlink message - * \param nlh pointer to netlink message - * - * This function returns a pointer to the netlink message tail. This is useful - * to build a message since we continue adding attributes at the end of the - * message. - */ -void *mnl_nlmsg_get_payload_tail(const struct nlmsghdr *nlh) -{ - return (void *)nlh + MNL_ALIGN(nlh->nlmsg_len); -} - -/** - * mnl_nlmsg_seq_ok - perform sequence tracking - * \param nlh current netlink message that we are handling - * \param seq last sequence number used to send a message - * - * This functions returns true if the sequence tracking is fulfilled, otherwise - * false is returned. We skip the tracking for netlink messages whose sequence - * number is zero since it is usually reserved for event-based kernel - * notifications. On the other hand, if seq is set but the message sequence - * number is not set (i.e. this is an event message coming from kernel-space), - * then we also skip the tracking. This approach is good if we use the same - * socket to send commands to kernel-space (that we want to track) and to - * listen to events (that we do not track). - */ -bool mnl_nlmsg_seq_ok(const struct nlmsghdr *nlh, - unsigned int seq) -{ - return nlh->nlmsg_seq && seq ? nlh->nlmsg_seq == seq : true; -} - -/** - * mnl_nlmsg_portid_ok - perform portID origin check - * \param nlh current netlink message that we are handling - * \param portid netlink portid that we want to check - * - * This functions returns true if the origin is fulfilled, otherwise - * false is returned. We skip the tracking for netlink message whose portID - * is zero since it is reserved for event-based kernel notifications. On the - * other hand, if portid is set but the message PortID is not (i.e. this - * is an event message coming from kernel-space), then we also skip the - * tracking. This approach is good if we use the same socket to send commands - * to kernel-space (that we want to track) and to listen to events (that we - * do not track). - */ -bool mnl_nlmsg_portid_ok(const struct nlmsghdr *nlh, - unsigned int portid) -{ - return nlh->nlmsg_pid && portid ? nlh->nlmsg_pid == portid : true; -} - -static void mnl_nlmsg_fprintf_header(FILE *fd, const struct nlmsghdr *nlh) -{ - fprintf(fd, "----------------\t------------------\n"); - fprintf(fd, "| %.010u |\t| message length |\n", nlh->nlmsg_len); - fprintf(fd, "| %.05u | %c%c%c%c |\t| type | flags |\n", - nlh->nlmsg_type, - nlh->nlmsg_flags & NLM_F_REQUEST ? 'R' : '-', - nlh->nlmsg_flags & NLM_F_MULTI ? 'M' : '-', - nlh->nlmsg_flags & NLM_F_ACK ? 'A' : '-', - nlh->nlmsg_flags & NLM_F_ECHO ? 'E' : '-'); - fprintf(fd, "| %.010u |\t| sequence number|\n", nlh->nlmsg_seq); - fprintf(fd, "| %.010u |\t| port ID |\n", nlh->nlmsg_pid); - fprintf(fd, "----------------\t------------------\n"); -} - -static void mnl_nlmsg_fprintf_payload(FILE *fd, const struct nlmsghdr *nlh, - size_t extra_header_size) -{ - int rem = 0; - unsigned int i; - - for (i=sizeof(struct nlmsghdr); inlmsg_len; i+=4) { - char *b = (char *) nlh; - struct nlattr *attr = (struct nlattr *) (b+i); - - /* netlink control message. */ - if (nlh->nlmsg_type < NLMSG_MIN_TYPE) { - fprintf(fd, "| %.2x %.2x %.2x %.2x |\t", - 0xff & b[i], 0xff & b[i+1], - 0xff & b[i+2], 0xff & b[i+3]); - fprintf(fd, "| |\n"); - /* special handling for the extra header. */ - } else if (extra_header_size > 0) { - extra_header_size -= 4; - fprintf(fd, "| %.2x %.2x %.2x %.2x |\t", - 0xff & b[i], 0xff & b[i+1], - 0xff & b[i+2], 0xff & b[i+3]); - fprintf(fd, "| extra header |\n"); - /* this seems like an attribute header. */ - } else if (rem == 0 && (attr->nla_type & NLA_TYPE_MASK) != 0) { - fprintf(fd, "|%c[%d;%dm" - "%.5u" - "%c[%dm" - "|" - "%c[%d;%dm" - "%c%c" - "%c[%dm" - "|" - "%c[%d;%dm" - "%.5u" - "%c[%dm|\t", - 27, 1, 31, - attr->nla_len, - 27, 0, - 27, 1, 32, - attr->nla_type & NLA_F_NESTED ? 'N' : '-', - attr->nla_type & - NLA_F_NET_BYTEORDER ? 'B' : '-', - 27, 0, - 27, 1, 34, - attr->nla_type & NLA_TYPE_MASK, - 27, 0); - fprintf(fd, "|len |flags| type|\n"); - - if (!(attr->nla_type & NLA_F_NESTED)) { - rem = NLA_ALIGN(attr->nla_len) - - sizeof(struct nlattr); - } - /* this is the attribute payload. */ - } else if (rem > 0) { - rem -= 4; - fprintf(fd, "| %.2x %.2x %.2x %.2x |\t", - 0xff & b[i], 0xff & b[i+1], - 0xff & b[i+2], 0xff & b[i+3]); - fprintf(fd, "| data |"); - fprintf(fd, "\t %c %c %c %c\n", - isprint(b[i]) ? b[i] : ' ', - isprint(b[i+1]) ? b[i+1] : ' ', - isprint(b[i+2]) ? b[i+2] : ' ', - isprint(b[i+3]) ? b[i+3] : ' '); - } - } - fprintf(fd, "----------------\t------------------\n"); -} - -/** - * mnl_nlmsg_fprintf - print netlink message to file - * \param fd pointer to file type - * \param data pointer to the buffer that contains messages to be printed - * \param datalen length of data stored in the buffer - * \param extra_header_size size of the extra header (if any) - * - * This function prints the netlink header to a file handle. - * It may be useful for debugging purposes. One example of the output - * is the following: - * - *\verbatim ----------------- ------------------ -| 0000000040 | | message length | -| 00016 | R-A- | | type | flags | -| 1289148991 | | sequence number| -| 0000000000 | | port ID | ----------------- ------------------ -| 00 00 00 00 | | extra header | -| 00 00 00 00 | | extra header | -| 01 00 00 00 | | extra header | -| 01 00 00 00 | | extra header | -|00008|--|00003| |len |flags| type| -| 65 74 68 30 | | data | e t h 0 ----------------- ------------------ -\endverbatim - * - * This example above shows the netlink message that is send to kernel-space - * to set up the link interface eth0. The netlink and attribute header data - * are displayed in base 10 whereas the extra header and the attribute payload - * are expressed in base 16. The possible flags in the netlink header are: - * - * - R, that indicates that NLM_F_REQUEST is set. - * - M, that indicates that NLM_F_MULTI is set. - * - A, that indicates that NLM_F_ACK is set. - * - E, that indicates that NLM_F_ECHO is set. - * - * The lack of one flag is displayed with '-'. On the other hand, the possible - * attribute flags available are: - * - * - N, that indicates that NLA_F_NESTED is set. - * - B, that indicates that NLA_F_NET_BYTEORDER is set. - */ -void mnl_nlmsg_fprintf(FILE *fd, const void *data, size_t datalen, - size_t extra_header_size) -{ - const struct nlmsghdr *nlh = data; - int len = datalen; - - while (mnl_nlmsg_ok(nlh, len)) { - mnl_nlmsg_fprintf_header(fd, nlh); - mnl_nlmsg_fprintf_payload(fd, nlh, extra_header_size); - nlh = mnl_nlmsg_next(nlh, &len); - } -} - -/** - * @} - */ - -/** - * \defgroup batch Netlink message batch helpers - * - * This library provides helpers to batch several messages into one single - * datagram. These helpers do not perform strict memory boundary checkings. - * - * The following figure represents a Netlink message batch: - * - * |<-------------- MNL_SOCKET_BUFFER_SIZE ------------->| - * |<-------------------- batch ------------------>| | - * |-----------|-----------|-----------|-----------|-----------| - * |<- nlmsg ->|<- nlmsg ->|<- nlmsg ->|<- nlmsg ->|<- nlmsg ->| - * |-----------|-----------|-----------|-----------|-----------| - * ^ ^ - * | | - * message N message N+1 - * - * To start the batch, you have to call mnl_nlmsg_batch_start() and you can - * use mnl_nlmsg_batch_stop() to release it. - * - * You have to invoke mnl_nlmsg_batch_next() to get room for a new message - * in the batch. If this function returns NULL, it means that the last - * message that was added (message N+1 in the figure above) does not fit the - * batch. Thus, you have to send the batch (which includes until message N) - * and, then, you have to call mnl_nlmsg_batch_reset() to re-initialize - * the batch (this moves message N+1 to the head of the buffer). For that - * reason, the buffer that you have to use to store the batch must be double - * of MNL_SOCKET_BUFFER_SIZE to ensure that the last message (message N+1) - * that did not fit into the batch is written inside valid memory boundaries. - * - * @{ - */ - -struct mnl_nlmsg_batch { - /* the buffer that is used to store the batch. */ - void *buf; - size_t limit; - size_t buflen; - /* the current netlink message in the batch. */ - void *cur; - bool overflow; -}; - -/** - * mnl_nlmsg_batch_start - initialize a batch - * \param buf pointer to the buffer that will store this batch - * \param limit maximum size of the batch (should be MNL_SOCKET_BUFFER_SIZE). - * - * The buffer that you pass must be double of MNL_SOCKET_BUFFER_SIZE. The - * limit must be half of the buffer size, otherwise expect funny memory - * corruptions 8-). - * - * You can allocate the buffer that you use to store the batch in the stack or - * the heap, no restrictions in this regard. This function returns NULL on - * error. - */ -struct mnl_nlmsg_batch *mnl_nlmsg_batch_start(void *buf, - size_t limit) -{ - struct mnl_nlmsg_batch *b; - - b = malloc(sizeof(struct mnl_nlmsg_batch)); - if (b == NULL) - return NULL; - - b->buf = buf; - b->limit = limit; - b->buflen = 0; - b->cur = buf; - b->overflow = false; - - return b; -} - -/** - * mnl_nlmsg_batch_stop - release a batch - * \param b pointer to batch - * - * This function releases the batch allocated by mnl_nlmsg_batch_start(). - */ -void mnl_nlmsg_batch_stop(struct mnl_nlmsg_batch *b) -{ - free(b); -} - -/** - * mnl_nlmsg_batch_next - get room for the next message in the batch - * \param b pointer to batch - * - * This function returns false if the last message did not fit into the - * batch. Otherwise, it prepares the batch to provide room for the new - * Netlink message in the batch and returns true. - * - * You have to put at least one message in the batch before calling this - * function, otherwise your application is likely to crash. - */ -bool mnl_nlmsg_batch_next(struct mnl_nlmsg_batch *b) -{ - struct nlmsghdr *nlh = b->cur; - - if (b->buflen + nlh->nlmsg_len > b->limit) { - b->overflow = true; - return false; - } - b->cur = b->buf + b->buflen + nlh->nlmsg_len; - b->buflen += nlh->nlmsg_len; - return true; -} - -/** - * mnl_nlmsg_batch_reset - reset the batch - * \param b pointer to batch - * - * This function allows to reset a batch, so you can reuse it to create a - * new one. This function moves the last message which does not fit the - * batch to the head of the buffer, if any. - */ -void mnl_nlmsg_batch_reset(struct mnl_nlmsg_batch *b) -{ - if (b->overflow) { - struct nlmsghdr *nlh = b->cur; - memcpy(b->buf, b->cur, nlh->nlmsg_len); - b->buflen = nlh->nlmsg_len; - b->cur = b->buf + b->buflen; - b->overflow = false; - } else { - b->buflen = 0; - b->cur = b->buf; - } -} - -/** - * mnl_nlmsg_batch_size - get current size of the batch - * \param b pointer to batch - * - * This function returns the current size of the batch. - */ -size_t mnl_nlmsg_batch_size(struct mnl_nlmsg_batch *b) -{ - return b->buflen; -} - -/** - * mnl_nlmsg_batch_head - get head of this batch - * \param b pointer to batch - * - * This function returns a pointer to the head of the batch, which is the - * beginning of the buffer that is used. - */ -void *mnl_nlmsg_batch_head(struct mnl_nlmsg_batch *b) -{ - return b->buf; -} - -/** - * mnl_nlmsg_batch_current - returns current position in the batch - * \param b pointer to batch - * - * This function returns a pointer to the current position in the buffer - * that is used to store the batch. - */ -void *mnl_nlmsg_batch_current(struct mnl_nlmsg_batch *b) -{ - return b->cur; -} - -/** - * mnl_nlmsg_batch_is_empty - check if there is any message in the batch - * \param b pointer to batch - * - * This function returns true if the batch is empty. - */ -bool mnl_nlmsg_batch_is_empty(struct mnl_nlmsg_batch *b) -{ - return b->buflen == 0; -} - -/** - * @} - */ diff --git a/fibocom-dial/src/libmnl/socket.c b/fibocom-dial/src/libmnl/socket.c deleted file mode 100644 index dd5ab66..0000000 --- a/fibocom-dial/src/libmnl/socket.c +++ /dev/null @@ -1,351 +0,0 @@ -/* - * (C) 2008-2010 by Pablo Neira Ayuso - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - */ - -#include -#include -#include -#include -#include -#include - -#include "libmnl.h" - -/** - * \mainpage - * - * libmnl is a minimalistic user-space library oriented to Netlink developers. - * There are a lot of common tasks in parsing, validating, constructing of - * both the Netlink header and TLVs that are repetitive and easy to get wrong. - * This library aims to provide simple helpers that allows you to avoid - * re-inventing the wheel in common Netlink tasks. - * - * \verbatim -"Simplify, simplify" -- Henry David Thoureau. Walden (1854) -\endverbatim - * - * The acronym libmnl stands for LIBrary Minimalistic NetLink. - * - * libmnl homepage is: - * http://www.netfilter.org/projects/libmnl/ - * - * \section features Main Features - * - Small: the shared library requires around 30KB for an x86-based computer. - * - Simple: this library avoids complex abstractions that tend to hide Netlink - * details. It avoids elaborated object-oriented infrastructure and complex - * callback-based workflow. - * - Easy to use: the library simplifies the work for Netlink-wise developers. - * It provides functions to make socket handling, message building, - * validating, parsing and sequence tracking, easier. - * - Easy to re-use: you can use this library to build your own abstraction - * layer upon this library, if you want to provide another library that - * hides Netlink details to your users. - * - Decoupling: the interdependency of the main bricks that compose this - * library is reduced, i.e. the library provides many helpers, but the - * programmer is not forced to use them. - * - * \section licensing Licensing terms - * This library is released under the LGPLv2.1 or any later (at your option). - * - * \section Dependencies - * You have to install the Linux kernel headers that you want to use to develop - * your application. Moreover, this library requires that you have some basics - * on Netlink. - * - * \section scm Git Tree - * The current development version of libmnl can be accessed at: - * http://git.netfilter.org/cgi-bin/gitweb.cgi?p=libmnl.git;a=summary - * - * \section using Using libmnl - * You can access several example files under examples/ in the libmnl source - * code tree. - */ - -struct mnl_socket { - int fd; - struct sockaddr_nl addr; -}; - -/** - * \defgroup socket Netlink socket helpers - * @{ - */ - -/** - * mnl_socket_get_fd - obtain file descriptor from netlink socket - * \param nl netlink socket obtained via mnl_socket_open() - * - * This function returns the file descriptor of a given netlink socket. - */ -int mnl_socket_get_fd(const struct mnl_socket *nl) -{ - return nl->fd; -} - -/** - * mnl_socket_get_portid - obtain Netlink PortID from netlink socket - * \param nl netlink socket obtained via mnl_socket_open() - * - * This function returns the Netlink PortID of a given netlink socket. - * It's a common mistake to assume that this PortID equals the process ID - * which is not always true. This is the case if you open more than one - * socket that is binded to the same Netlink subsystem from the same process. - */ -unsigned int mnl_socket_get_portid(const struct mnl_socket *nl) -{ - return nl->addr.nl_pid; -} - -static struct mnl_socket *__mnl_socket_open(int bus, int flags) -{ - struct mnl_socket *nl; - - nl = calloc(1, sizeof(struct mnl_socket)); - if (nl == NULL) - return NULL; - - nl->fd = socket(AF_NETLINK, SOCK_RAW | flags, bus); - if (nl->fd == -1) { - free(nl); - return NULL; - } - - return nl; -} - -/** - * mnl_socket_open - open a netlink socket - * \param bus the netlink socket bus ID (see NETLINK_* constants) - * - * On error, it returns NULL and errno is appropriately set. Otherwise, it - * returns a valid pointer to the mnl_socket structure. - */ -struct mnl_socket *mnl_socket_open(int bus) -{ - return __mnl_socket_open(bus, 0); -} - -/** - * mnl_socket_open2 - open a netlink socket with appropriate flags - * \param bus the netlink socket bus ID (see NETLINK_* constants) - * \param flags the netlink socket flags (see SOCK_* constants in socket(2)) - * - * This is similar to mnl_socket_open(), but allows to set flags like - * SOCK_CLOEXEC at socket creation time (useful for multi-threaded programs - * performing exec calls). - * - * On error, it returns NULL and errno is appropriately set. Otherwise, it - * returns a valid pointer to the mnl_socket structure. - */ -struct mnl_socket *mnl_socket_open2(int bus, int flags) -{ - return __mnl_socket_open(bus, flags); -} - -/** - * mnl_socket_fdopen - associates a mnl_socket object with pre-existing socket. - * \param fd pre-existing socket descriptor. - * - * On error, it returns NULL and errno is appropriately set. Otherwise, it - * returns a valid pointer to the mnl_socket structure. It also sets the portID - * if the socket fd is already bound and it is AF_NETLINK. - * - * Note that mnl_socket_get_portid() returns 0 if this function is used with - * non-netlink socket. - */ -struct mnl_socket *mnl_socket_fdopen(int fd) -{ - int ret; - struct mnl_socket *nl; - struct sockaddr_nl addr; - socklen_t addr_len = sizeof(struct sockaddr_nl); - - ret = getsockname(fd, (struct sockaddr *) &addr, &addr_len); - if (ret == -1) - return NULL; - - nl = calloc(1, sizeof(struct mnl_socket)); - if (nl == NULL) - return NULL; - - nl->fd = fd; - if (addr.nl_family == AF_NETLINK) - nl->addr = addr; - - return nl; -} - -/** - * mnl_socket_bind - bind netlink socket - * \param nl netlink socket obtained via mnl_socket_open() - * \param groups the group of message you're interested in - * \param pid the port ID you want to use (use zero for automatic selection) - * - * On error, this function returns -1 and errno is appropriately set. On - * success, 0 is returned. You can use MNL_SOCKET_AUTOPID which is 0 for - * automatic port ID selection. - */ -int mnl_socket_bind(struct mnl_socket *nl, unsigned int groups, - pid_t pid) -{ - int ret; - socklen_t addr_len; - - nl->addr.nl_family = AF_NETLINK; - nl->addr.nl_groups = groups; - nl->addr.nl_pid = pid; - - ret = bind(nl->fd, (struct sockaddr *) &nl->addr, sizeof (nl->addr)); - if (ret < 0) - return ret; - - addr_len = sizeof(nl->addr); - ret = getsockname(nl->fd, (struct sockaddr *) &nl->addr, &addr_len); - if (ret < 0) - return ret; - - if (addr_len != sizeof(nl->addr)) { - errno = EINVAL; - return -1; - } - if (nl->addr.nl_family != AF_NETLINK) { - errno = EINVAL; - return -1; - } - return 0; -} - -/** - * mnl_socket_sendto - send a netlink message of a certain size - * \param nl netlink socket obtained via mnl_socket_open() - * \param buf buffer containing the netlink message to be sent - * \param len number of bytes in the buffer that you want to send - * - * On error, it returns -1 and errno is appropriately set. Otherwise, it - * returns the number of bytes sent. - */ -ssize_t mnl_socket_sendto(const struct mnl_socket *nl, - const void *buf, size_t len) -{ - static const struct sockaddr_nl snl = { - .nl_family = AF_NETLINK - }; - return sendto(nl->fd, buf, len, 0, - (struct sockaddr *) &snl, sizeof(snl)); -} - -/** - * mnl_socket_recvfrom - receive a netlink message - * \param nl netlink socket obtained via mnl_socket_open() - * \param buf buffer that you want to use to store the netlink message - * \param bufsiz size of the buffer passed to store the netlink message - * - * On error, it returns -1 and errno is appropriately set. If errno is set - * to ENOSPC, it means that the buffer that you have passed to store the - * netlink message is too small, so you have received a truncated message. - * To avoid this, you have to allocate a buffer of MNL_SOCKET_BUFFER_SIZE - * (which is 8KB, see linux/netlink.h for more information). Using this - * buffer size ensures that your buffer is big enough to store the netlink - * message without truncating it. - */ -ssize_t mnl_socket_recvfrom(const struct mnl_socket *nl, - void *buf, size_t bufsiz) -{ - ssize_t ret; - struct sockaddr_nl addr; - struct iovec iov = { - .iov_base = buf, - .iov_len = bufsiz, - }; - struct msghdr msg = { - .msg_name = &addr, - .msg_namelen = sizeof(struct sockaddr_nl), - .msg_iov = &iov, - .msg_iovlen = 1, - .msg_control = NULL, - .msg_controllen = 0, - .msg_flags = 0, - }; - ret = recvmsg(nl->fd, &msg, 0); - if (ret == -1) - return ret; - - if (msg.msg_flags & MSG_TRUNC) { - errno = ENOSPC; - return -1; - } - if (msg.msg_namelen != sizeof(struct sockaddr_nl)) { - errno = EINVAL; - return -1; - } - return ret; -} - -/** - * mnl_socket_close - close a given netlink socket - * \param nl netlink socket obtained via mnl_socket_open() - * - * On error, this function returns -1 and errno is appropriately set. - * On success, it returns 0. - */ -int mnl_socket_close(struct mnl_socket *nl) -{ - int ret = close(nl->fd); - free(nl); - return ret; -} - -/** - * mnl_socket_setsockopt - set Netlink socket option - * \param nl netlink socket obtained via mnl_socket_open() - * \param type type of Netlink socket options - * \param buf the buffer that contains the data about this option - * \param len the size of the buffer passed - * - * This function allows you to set some Netlink socket option. As of writing - * this (see linux/netlink.h), the existing options are: - * - * - \#define NETLINK_ADD_MEMBERSHIP 1 - * - \#define NETLINK_DROP_MEMBERSHIP 2 - * - \#define NETLINK_PKTINFO 3 - * - \#define NETLINK_BROADCAST_ERROR 4 - * - \#define NETLINK_NO_ENOBUFS 5 - * - * In the early days, Netlink only supported 32 groups expressed in a - * 32-bits mask. However, since 2.6.14, Netlink may have up to 2^32 multicast - * groups but you have to use setsockopt() with NETLINK_ADD_MEMBERSHIP to - * join a given multicast group. This function internally calls setsockopt() - * to join a given netlink multicast group. You can still use mnl_bind() - * and the 32-bit mask to join a set of Netlink multicast groups. - * - * On error, this function returns -1 and errno is appropriately set. - */ -int mnl_socket_setsockopt(const struct mnl_socket *nl, int type, - void *buf, socklen_t len) -{ - return setsockopt(nl->fd, SOL_NETLINK, type, buf, len); -} - -/** - * mnl_socket_getsockopt - get a Netlink socket option - * \param nl netlink socket obtained via mnl_socket_open() - * \param type type of Netlink socket options - * \param buf pointer to the buffer to store the value of this option - * \param len size of the information written in the buffer - * - * On error, this function returns -1 and errno is appropriately set. - */ -int mnl_socket_getsockopt(const struct mnl_socket *nl, int type, - void *buf, socklen_t *len) -{ - return getsockopt(nl->fd, SOL_NETLINK, type, buf, len); -} - -/** - * @} - */ diff --git a/fibocom-dial/src/main.c b/fibocom-dial/src/main.c deleted file mode 100644 index dd64293..0000000 --- a/fibocom-dial/src/main.c +++ /dev/null @@ -1,1770 +0,0 @@ -#include -#include -#include -#include - -//2021-02-25 willa.liu@fibocom.com changed begin for support eipd SN-20210129001 -#include -#include -//2021-02-25 willa.liu@fibocom.com changed end for support eipd SN-20210129001 - -//2020-12-23 willa.liu@fibocom.com changed begin for support mantis 0065286 -#include -#include -//2020-12-23 willa.liu@fibocom.com changed end for support mantis 0065286 - -#include "QMIThread.h" -#include "util.h" -//2021-03-24 willa.liu@fibocom.com changed begin for support mantis 0071817 -#include "query_pcie_mode.h" -//2021-03-24 willa.liu@fibocom.com changed begin for support mantis 0071817 - -#define MAJOR 2 -#define MINOR 0 -#define REVISION 10 -/* - * Generally, we do not modify version info, so several modifications will share - * the same version code. SUBVERSION is used for customized modification to - * distinguise this version from previous one. SUBVERSION adds up before you - * send the code to customers and it should be set to 0 if VERSION_STRING info - * is changed. - */ -#define SUBVERSION 0 -#define STRINGIFY_HELPER(v) #v -#define STRINGIFY(v) STRINGIFY_HELPER(v) -#define VERSION_STRING() \ - STRINGIFY(MAJOR) "." STRINGIFY(MINOR) "." STRINGIFY(REVISION) -#define MAX_PATH 256 - -//2020-12-23 willa.liu@fibocom.com changed begin for support mantis 0065286 -struct sockaddr_un { - sa_family_t sun_family; - char sun_path[100]; -}; -//2020-12-23 willa.liu@fibocom.com changed end for support mantis 0065286 - -int query_pcie_mode = 0; -int debug_qmi = 0; -int main_loop = 0; -int qmidevice_control_fd[2]; -static int signal_control_fd[2]; -pthread_t gQmiThreadID; -USHORT g_MobileCountryCode = 0; -USHORT g_MobileNetworkCode = 0; - -//2020-12-23 willa.liu@fibocom.com changed begin for support mantis 0065286 -sem_t sem; -int socket_server_fd = 0; -int cli_accept_fd = 0; -char fibo_dial_filepath[100] = {0}; -//2020-12-23 willa.liu@fibocom.com changed end for support mantis 0065286 - -extern const struct qmi_device_ops qmiwwan_qmidev_ops; -extern const struct qmi_device_ops gobi_qmidev_ops; - -//2021-03-24 willa.liu@fibocom.com changed begin for support mantis 0071817 -//extern int *speed_arr; -//extern int *name_arr; -//extern int get_private_gateway_debug; -//2021-03-24 willa.liu@fibocom.com changed end for support mantis 0071817 - -static int s_link = -1; - -static int is_pcie_dial() -{ - return (access("/dev/mhi_QMI0", F_OK) == 0); -} - -//2021-02-25 willa.liu@fibocom.com changed begin for support eipd SN-20210129001 -int split_gateway(char *str ,char* split, int index, char *outgateway) -{ - char chBuffer[1024]; - char *pchStrTmpIn = NULL; - char *pchTmp = NULL; - int i = 1; - strncpy(chBuffer, str, sizeof(chBuffer)-1); - pchTmp = chBuffer; - //printf("pchTmp is [%s]\n", pchTmp); - while(NULL != (pchTmp = strtok_r( pchTmp, split, &pchStrTmpIn))) - { - //printf("line %d::::::::::::[%s]\n", i, pchTmp); - if(i == index) - { - memcpy(outgateway, pchTmp, strlen(pchTmp)); - break; - } - //if(strstr(pchTmp, "+CGCONTRDP") != -1) - i++; - pchTmp = NULL; - } - return strlen(outgateway); -} - -int get_private_gateway(char *outgateway) -{ - int i; - int fd; - int ret; - char buffer[1024] = {0}; - int rate; - char *sendbuffer; - char prigateways[1024*2] = {0}; - char prigateway[256] = {0}; - int totallen = 0; - fd_set readfds; - struct timeval timeout; - struct termios tiosfd, tio; - - int timeoutVal = 5; - - char *dev = "/dev/ttyUSB1"; //The port under Linux is operated by opening the device file - rate = 115200; - sendbuffer = "AT+CGCONTRDP=1"; - - fd = open(dev, O_RDWR | O_NOCTTY | O_NONBLOCK); - if(fd < 0) - goto ERR; - fcntl(fd, F_SETFL, O_RDWR); - - xget1(fd, &tio, &tiosfd); - - for(i = 0; i < sizeof(speed_arr)/sizeof(int); i++) - { - if(rate == name_arr[i])//Judge if the pass is equal to the pass - { - break; - } - } - - if(i >= sizeof(speed_arr)/sizeof(int)) - { - printf("bound rate set failed\n"); - goto ERR; - } - - cfsetspeed(&tio, speed_arr[i]); - if(xset1(fd, &tio, dev)) - goto ERR; - - tcflush(fd, TCIOFLUSH); - - FD_ZERO(&readfds); - FD_SET(fd, &readfds); - - sprintf(buffer, "%s\r", sendbuffer); - ret = write (fd, buffer, strlen(buffer)); - if(ret < 0) - { - printf("write failed\n"); - goto ERR; - } - printf("dev: %s\nrate:%d\nsendbuffer:%s\n", dev, rate, sendbuffer); - sleep(1); - if(get_private_gateway_debug)printf("write %d\n", ret); - while(1) - { - timeout.tv_sec = timeoutVal; - timeout.tv_usec = 0; - - ret = select(fd+1, &readfds, (fd_set *)0, (fd_set *)0, &timeout); - if(ret > 0) - { - ret = read(fd, buffer+totallen, sizeof(buffer)-totallen-1); - if(ret < 0) - { - printf("read failed\n"); - goto ERR; - } - - if(ret == 0) - { - goto ERR; - } - - totallen += ret; - buffer[totallen] = '\0'; - if(get_private_gateway_debug)printf("read %d(%s)\n", ret, &buffer[totallen-ret]); - //printf("buffer is %s\n", buffer); - - if(totallen == sizeof(buffer)-1) - break; - - if(strstr(buffer, "\nOK")) - { - split_gateway(buffer, "\r", 3, prigateways); - //printf("test1 %s\n", prigateways); - split_gateway(prigateways, ",", 5, prigateway); - //printf("test2 %s\n", prigateway); - break; - } - else - { - goto ERR; - } - - } - else - { - printf("select timeout\n"); - goto ERR; - } - - } - - tcsetattr(fd, TCSAFLUSH, &tiosfd); - if(strstr(buffer, "\nERROR") || strstr(buffer, "\n+CME ERROR:") || strstr(buffer, "\n+CMS ERROR:")) - goto ERR; - - close(fd); - - memcpy(outgateway, prigateway+1, strlen(prigateway)-2); - printf("private gateway is %s\n", outgateway); - return 0; -ERR: - if(fd > 0) - close(fd); - return -1; -} -//2021-02-25 willa.liu@fibocom.com changed end for support eipd SN-20210129001 - -// UINT ifc_get_addr(const char *ifname); -static void usbnet_link_change(int link, PROFILE_T *profile) -{ - // static int s_link = 0; - dbg_time("%s :link:%d ", __func__, link); - - if (s_link == link) - return; - - s_link = link; - - if (link) { - if (profile->ipv4_flag) - requestGetIPAddress(profile, IpFamilyV4); - if (profile->ipv6_flag) - requestGetIPAddress(profile, IpFamilyV6); - if (qmidev_is_pciemhi(profile->qmichannel)) - udhcpc_start_pcie(profile); - else - udhcpc_start(profile); - } else { - if (qmidev_is_pciemhi(profile->qmichannel)) - udhcpc_stop_pcie(profile); - else - udhcpc_stop(profile); - } -} - -static int check_address(PROFILE_T *now_profile,int ipfamily) -{ - PROFILE_T new_profile_v; - PROFILE_T *new_profile = &new_profile_v; - static int time_out_count = 0; - int ret = 0; - #define QMITHREADSENDQMITIMEOUT 110 - - memcpy(new_profile, now_profile, sizeof(PROFILE_T)); - if(ipfamily == IpFamilyV4) - { - ret = requestGetIPAddress(new_profile, 0x04); - if (ret == 0) - { - time_out_count = 0; - if (new_profile->ipv4.Address != now_profile->ipv4.Address || debug_qmi) - { - unsigned char *l = (unsigned char *)&now_profile->ipv4.Address; - unsigned char *r = (unsigned char *)&new_profile->ipv4.Address; - dbg_time("localIP: %d.%d.%d.%d VS remoteIP: %d.%d.%d.%d", l[3], - l[2], l[1], l[0], r[3], r[2], r[1], r[0]); - } - return (new_profile->ipv4.Address == now_profile->ipv4.Address); - } - else if (ret == QMITHREADSENDQMITIMEOUT) - { - time_out_count++; - dbg_time("%s %d time_out_count %d\n", __func__, __LINE__, time_out_count); - if (time_out_count >= 3) - { - return 0; - } - else - { - return 1; - } - } - } - if(ipfamily == IpFamilyV6) - { - return 1; - } - - return 0; -} - -static void main_send_event_to_qmidevice(int triger_event) -{ - write(qmidevice_control_fd[0], &triger_event, sizeof(triger_event)); -} - -static void send_signo_to_main(int signo) -{ - write(signal_control_fd[0], &signo, sizeof(signo)); - dbg_time("write signo: %d to signal_control_fd",signo); -} - -void qmidevice_send_event_to_main(int triger_event) -{ - write(qmidevice_control_fd[1], &triger_event, sizeof(triger_event)); - dbg_time("write triger_event: %d to qmidevice_control_fd",triger_event); -} - -static int ls_dir(const char *dir, - int (*match)(const char *dir, const char *file, void *argv[]), - void *argv[]) -{ - DIR *pDir; - struct dirent *ent = NULL; - int match_times = 0; - - pDir = opendir(dir); - if (pDir == NULL) { - dbg_time("Cannot open directory: %s, errno: %d (%s)", dir, errno, - strerror(errno)); - return 0; - } - - while ((ent = readdir(pDir)) != NULL) { - match_times += match(dir, ent->d_name, argv); - } - closedir(pDir); - - return match_times; -} - -static int is_same_linkfile(const char *dir, const char *file, void *argv[]) -{ - const char *qmichannel = (const char *)argv[1]; - char linkname[MAX_PATH]; - char filename[MAX_PATH]; - int linksize; - - snprintf(linkname, MAX_PATH, "%s/%s", dir, file); - linksize = readlink(linkname, filename, MAX_PATH); - if (linksize <= 0) - return 0; - - filename[linksize] = 0; - if (strcmp(filename, qmichannel)) - return 0; - - dbg_time("%s -> %s", linkname, filename); - return 1; -} - -static int is_brother_process(const char *dir, const char *file, void *argv[]) -{ - // const char *myself = (const char *)argv[0]; - char linkname[MAX_PATH]; - char filename[MAX_PATH]; - int linksize; - int i = 0, kill_timeout = 15; - pid_t pid; - - // dbg_time("%s", file); - while (file[i]) { - if (!isdigit(file[i])) - break; - i++; - } - - if (file[i]) { - // dbg_time("%s not digit", file); - return 0; - } - - snprintf(linkname, MAX_PATH, "%s/%s/exe", dir, file); - linksize = readlink(linkname, filename, MAX_PATH); - if (linksize <= 0) - return 0; - - filename[linksize] = 0; - - pid = atoi(file); - if (pid >= getpid()) - return 0; - - snprintf(linkname, MAX_PATH, "%s/%s/fd", dir, file); - if (!ls_dir(linkname, is_same_linkfile, argv)) - return 0; - - dbg_time("%s/%s/exe -> %s", dir, file, filename); - while (kill_timeout-- && !kill(pid, 0)) { - kill(pid, SIGTERM); - sleep(1); - } - if (!kill(pid, 0)) { - dbg_time("force kill %s/%s/exe -> %s", dir, file, filename); - kill(pid, SIGKILL); - sleep(1); - } - - return 1; -} - -static int kill_brothers(const char *qmichannel) -{ - char myself[MAX_PATH]; - int filenamesize; - void *argv[2] = {myself, (void *)qmichannel}; - - filenamesize = readlink("/proc/self/exe", myself, MAX_PATH); - if (filenamesize <= 0) - return 0; - myself[filenamesize] = 0; - - if (ls_dir("/proc", is_brother_process, argv)) - sleep(1); - - return 0; -} - -static void fibo_sigaction(int signo) -{ - if (SIGCHLD == signo) - waitpid(-1, NULL, WNOHANG); - else if (SIGALRM == signo) - send_signo_to_main(SIGUSR1); - else { - if (SIGTERM == signo || SIGHUP == signo || SIGINT == signo) - main_loop = 0; - send_signo_to_main(signo); - main_send_event_to_qmidevice(signo); // main may be wating qmi response - } -} - -static int usage(const char *progname) -{ - dbg_time("Usage: %s [options]", progname); - dbg_time( - "-s [apn [user password auth]] Set " - "apn/user/password/auth get from your network provider"); - dbg_time( - "-p pincode Verify sim card pin if " - "sim card is locked"); - dbg_time( - "-f logfilename Save log message of this " - "program to file"); - dbg_time( - "-i interface Specify network " - "interface(default auto-detect)"); - dbg_time("-4 IPv4 protocol"); - dbg_time("-6 IPv6 protocol"); - -//2021-02-25 willa.liu@fibocom.com changed begin for support eipd SN-20210129001 - dbg_time("-g IPv6 private gateway"); -//2021-02-25 willa.liu@fibocom.com changed begin for support eipd SN-20210129001 - -//2020-12-29 willa.liu@fibocom.com changed begin for support mantis 0066901 - //dbg_time( - //"-P profile index Specify profile index " - //"when start network data connection(default 1)."); -//2020-12-29 willa.liu@fibocom.com changed end for support mantis 0066901 - - dbg_time( - "-m muxID Specify muxid when set " - "multi-pdn data connection."); - dbg_time( - "-n channelID Specify channelID when " - "set multi-pdn data connection(default 1)."); - dbg_time( - "-N Number of channel Specify total channels " - "when set multi-pdn data connection(default 1)."); - -//2020-12-23 willa.liu@fibocom.com changed begin for support mantis 0065286 - dbg_time( - "-k number kill specified process "); -//2020-12-23 willa.liu@fibocom.com changed end for support mantis 0065286 - - dbg_time("[Examples]"); - dbg_time("Example 1: %s ", progname); - dbg_time("Example 2: %s -s 3gnet ", progname); - dbg_time("Example 3: %s -s 3gnet carl 1234 0 -p 1234 -f gobinet_log.txt", - progname); - return 0; -} - -static int charsplit(const char *src, char *desc, int n, const char *splitStr) -{ - char *p; - char *p1; - int len; - - len = strlen(splitStr); - p = strstr(src, splitStr); - if (p == NULL) - return -1; - p1 = strstr(p, "\n"); - if (p1 == NULL) - return -1; - memset(desc, 0, n); - memcpy(desc, p + len, p1 - p - len); - - return 0; -} - -static int get_dev_major_minor(char *path, int *major, int *minor) -{ - int fd = -1; - char desc[128] = {0}; - char devmajor[64], devminor[64]; - int n = 0; - if (access(path, R_OK | W_OK)) { - return 1; - } - if ((fd = open(path, O_RDWR)) < 0) { - return 1; - } - n = read(fd, desc, sizeof(desc)); - if (n == sizeof(desc)) { - dbg_time("may be overflow"); - } - close(fd); - if (charsplit(desc, devmajor, 64, "MAJOR=") == -1 || - charsplit(desc, devminor, 64, "MINOR=") == -1) { - return 2; - } - *major = atoi(devmajor); - *minor = atoi(devminor); - return 0; -} -#ifdef GHT_FEATURE_PCIE_AUTO -//begin modified by zhangkaibo add PCIe auto detect feature on x55/x24 platform. 20200605 -static int qmipciedevice_detect(char **pp_qmichannel, char **pp_usbnet_adapter) -{ - struct dirent *ent = NULL; - DIR *pDir; - char dir[255] = "/sys/bus/pci/devices"; - - struct { - char subdir[255 * 2]; - char subdir2[255 * 3 + 16]; - char qmifile[255 * 2]; - } * pl; - pl = (typeof(pl))malloc(sizeof(*pl)); - memset(pl, 0x00, sizeof(*pl)); - - pDir = opendir(dir); - if (pDir) { - while ((ent = readdir(pDir)) != NULL) { - - struct dirent *subent = NULL; - DIR *psubDir; - char idVendor[4 + 1] = {0}; - char idDevice[4 + 1] = {0}; - char tempNetpath[256] = {0}; - int fd = 0; - char netcard[32] = "\0"; - - memset(pl, 0x00, sizeof(*pl)); - snprintf(pl->subdir, sizeof(pl->subdir), "%s/%s/vendor", dir, - ent->d_name); - fd = open(pl->subdir, O_RDONLY); - if (fd > 0) { - read(fd, idVendor, 6); - close(fd); - } - - snprintf(pl->subdir, sizeof(pl->subdir), "%s/%s/device", dir, - ent->d_name); - fd = open(pl->subdir, O_RDONLY); - if (fd > 0) { - read(fd, idDevice, 6); - close(fd); - } - - if (!strncasecmp(idVendor, "0x17cb", 6)) - ; - else - continue; - - dbg_time("Find %s/%s vendor=%s device=%s", dir, ent->d_name, - idVendor,idDevice); - //find pcie netdevicename - snprintf(tempNetpath,256,"%s%s_IP_HW0", idDevice+2 , ent->d_name+2); - snprintf(pl->subdir, sizeof(pl->subdir), "%s/%s/%s/net", dir, - ent->d_name,tempNetpath); - psubDir = opendir(pl->subdir); - if (psubDir == NULL) { - dbg_time("Cannot open directory: %s, errno: %d (%s)", - pl->subdir, errno, strerror(errno)); - continue; - } - - while ((subent = readdir(psubDir)) != NULL) { - if (subent->d_name[0] == '.') - continue; - dbg_time("Find pcienet_adapter = %s", subent->d_name); - strcpy(netcard, subent->d_name); - break; - } - - closedir(psubDir); - - if (netcard[0]) { - } else { - continue; - } - - *pp_usbnet_adapter = strdup(netcard); - break; - } - closedir(pDir); - } - //find pcie qmi control name - if ((pDir = opendir("/dev")) == NULL) { - dbg_time("Cannot open directory: %s, errno:%d (%s)", "/dev", errno, - strerror(errno)); - return -ENODEV; - } - - while ((ent = readdir(pDir)) != NULL) { - if ( strncmp(ent->d_name, "mhi_QMI", strlen("mhi_QMI")) == 0 ) { - *pp_qmichannel = (char *)malloc(32); - sprintf(*pp_qmichannel, "/dev/%s", ent->d_name); - dbg_time("Find qmichannel = %s", *pp_qmichannel); - break; - } - } - closedir(pDir); - free(pl); - - return (*pp_qmichannel && *pp_usbnet_adapter); -} -//end modified by zhangkaibo add PCIe auto detect feature on x55/x24 platform. 20200605 -#endif -static int qmidevice_detect(char **pp_qmichannel, char **pp_usbnet_adapter,PROFILE_T *profile) -{ - struct dirent *ent = NULL; - DIR *pDir; - char dir[255] = "/sys/bus/usb/devices"; - int major = 0, minor = 0; - int indexid = 4; - struct { - char subdir[255 * 3]; - char subdir2[255 * 4 + 16]; - char qmifile[255 * 2]; - } * pl; -#ifdef GHT_FEATURE_PCIE_AUTO -//begin modified by zhangkaibo add PCIe auto detect feature on x55/x24 platform. 20200605 - if (qmipciedevice_detect(pp_qmichannel, pp_usbnet_adapter)) - { - return (*pp_qmichannel && *pp_usbnet_adapter); - } -//end modified by zhangkaibo add PCIe auto detect feature on x55/x24 platform. 20200605 -#endif - pl = (typeof(pl))malloc(sizeof(*pl)); - memset(pl, 0x00, sizeof(*pl)); - - pDir = opendir(dir); - if (pDir) { - while ((ent = readdir(pDir)) != NULL) { - struct dirent *subent = NULL; - DIR *psubDir; - char idVendor[4 + 1] = {0}; - char idProduct[4 + 1] = {0}; - int fd = 0; - char netcard[32] = "\0"; - - memset(pl, 0x00, sizeof(*pl)); - - snprintf(pl->subdir, sizeof(pl->subdir), "%s/%s/idVendor", dir, - ent->d_name); - fd = open(pl->subdir, O_RDONLY); - if (fd > 0) { - read(fd, idVendor, 4); - close(fd); - } - - snprintf(pl->subdir, sizeof(pl->subdir), "%s/%s/idProduct", dir, - ent->d_name); - fd = open(pl->subdir, O_RDONLY); - if (fd > 0) { - read(fd, idProduct, 4); - close(fd); - } - - if (!strncasecmp(idVendor, "05c6", 4) || - !strncasecmp(idVendor, "2cb7", 4)) - ; - else - continue; - - dbg_time("Find %s/%s idVendor=%s idProduct=%s", dir, ent->d_name, - idVendor, idProduct); -//2021-02-08 zhangkaibo@fibocom.com changed start for mantis 0070613 - if(!strncasecmp(idProduct, "0109", 4)) - { - indexid = 2; - profile->interfacenum = 2; - } -//2021-09-09 willa.liu@fibocom.com changed start for mantis 0086219 - else if(!strncasecmp(idProduct, "0113", 4)) - { - indexid = 0; - profile->interfacenum = 0; - } -//2021-09-09 willa.liu@fibocom.com changed end for mantis 0086219 - else - { - profile->interfacenum = 4; - } - snprintf(pl->subdir, sizeof(pl->subdir), "%s/%s:1.%d/net", dir, - ent->d_name,indexid); - psubDir = opendir(pl->subdir); - if (psubDir == NULL) { - dbg_time("Cannot open directory: %s, errno: %d (%s)", - pl->subdir, errno, strerror(errno)); - continue; - } - - while ((subent = readdir(psubDir)) != NULL) { - if (subent->d_name[0] == '.') - continue; - dbg_time("Find %s/%s", pl->subdir, subent->d_name); - dbg_time("Find usbnet_adapter = %s", subent->d_name); - strcpy(netcard, subent->d_name); - break; - } - - closedir(psubDir); - - if (netcard[0]) { - } else { - continue; - } - - if (*pp_usbnet_adapter && strcmp(*pp_usbnet_adapter, netcard)) - continue; - - snprintf(pl->subdir, sizeof(pl->subdir), "%s/%s:1.%d/GobiQMI", dir, - ent->d_name,indexid); - if (access(pl->subdir, R_OK)) { - snprintf(pl->subdir, sizeof(pl->subdir), "%s/%s:1.%d/usbmisc", - dir, ent->d_name,indexid); - if (access(pl->subdir, R_OK)) { - snprintf(pl->subdir, sizeof(pl->subdir), "%s/%s:1.%d/usb", - dir, ent->d_name,indexid); - if (access(pl->subdir, R_OK)) { - dbg_time("no GobiQMI/usbmic/usb found in %s/%s:1.%d", - dir, ent->d_name,indexid); - continue; - } - } - } - -//2021-02-08 zhangkaibo@fibocom.com changed end for mantis 0070613 - - psubDir = opendir(pl->subdir); - if (pDir == NULL) { - dbg_time("Cannot open directory: %s, errno: %d (%s)", dir, - errno, strerror(errno)); - continue; - } - - while ((subent = readdir(psubDir)) != NULL) { - if (subent->d_name[0] == '.') - continue; - dbg_time("Find %s/%s", pl->subdir, subent->d_name); - dbg_time("Find qmichannel = /dev/%s", subent->d_name); - snprintf(pl->qmifile, sizeof(pl->qmifile), "/dev/%s", - subent->d_name); - - // get major minor - snprintf(pl->subdir2, sizeof(pl->subdir2), "%s/%s/uevent", - pl->subdir, subent->d_name); - if (!get_dev_major_minor(pl->subdir2, &major, &minor)) { - // dbg_time("%s major = %d, minor = %d\n",pl->qmifile, - // major, minor); - } else { - dbg_time("get %s major and minor failed\n", pl->qmifile); - } - // get major minor - - if ((fd = open(pl->qmifile, R_OK)) < 0) { - dbg_time("%s open failed", pl->qmifile); - dbg_time("please mknod %s c %d %d", pl->qmifile, major, - minor); - } else { - close(fd); - } - break; - } - - closedir(psubDir); - - if (netcard[0] && pl->qmifile[0]) { - *pp_qmichannel = strdup(pl->qmifile); - *pp_usbnet_adapter = strdup(netcard); - closedir(pDir); - return 1; - } - } - - closedir(pDir); - } - - if ((pDir = opendir("/dev")) == NULL) { - dbg_time("Cannot open directory: %s, errno:%d (%s)", "/dev", errno, - strerror(errno)); - return -ENODEV; - } - - while ((ent = readdir(pDir)) != NULL) { - if ((strncmp(ent->d_name, "cdc-wdm", strlen("cdc-wdm")) == 0) || - (strncmp(ent->d_name, "qcqmi", strlen("qcqmi")) == 0)) { - char net_path[255*2]; - - *pp_qmichannel = (char *)malloc(32); - sprintf(*pp_qmichannel, "/dev/%s", ent->d_name); - dbg_time("Find qmichannel = %s", *pp_qmichannel); - - if (strncmp(ent->d_name, "cdc-wdm", strlen("cdc-wdm")) == 0) - sprintf(net_path, "/sys/class/net/wwan%s", - &ent->d_name[strlen("cdc-wdm")]); - else { - sprintf(net_path, "/sys/class/net/usb%s", - &ent->d_name[strlen("qcqmi")]); - - if (access(net_path, R_OK) && errno == ENOENT) - sprintf(net_path, "/sys/class/net/eth%s", - &ent->d_name[strlen("qcqmi")]); - } - - if (access(net_path, R_OK) == 0) { - if (*pp_usbnet_adapter && - strcmp(*pp_usbnet_adapter, - (net_path + strlen("/sys/class/net/")))) { - free(*pp_qmichannel); - *pp_qmichannel = NULL; - continue; - } - *pp_usbnet_adapter = - strdup(net_path + strlen("/sys/class/net/")); - dbg_time("Find usbnet_adapter = %s", *pp_usbnet_adapter); - break; - } else { - dbg_time("Failed to access %s, errno:%d (%s)", net_path, errno, - strerror(errno)); - free(*pp_qmichannel); - *pp_qmichannel = NULL; - } - } - } - closedir(pDir); - free(pl); - - return (*pp_qmichannel && *pp_usbnet_adapter); -} -//begin modified by zhangkaibo limit input parameters. mantis 0048965 20200605 -int IsInt(char* str) -{ - int len; - len = strlen(str); - int i=0; - for(; i < len ; i++) - { - if(!(isdigit(str[i]))) - return 0; - } - return 1; -} -//end modified by zhangkaibo limit input parameters. mantis 0048965 20200605 - -//2020-12-23 willa.liu@fibocom.com changed begin for support mantis 0065286 -int rdwr_init(int clienfd, char * msg) -{ - char buf[512]; - int rv = 0; - memset(buf, 0, 512); - while(1) - { - if ((rv = read(clienfd, buf, 512)) < 0) - { - dbg_time("Read by socket[%d] error:%s", clienfd, strerror(errno)); - goto STOP; - } - else if (0 == rv) - { - goto STOP; - } - else if (rv > 0) - { - dbg_time("Read %d bytes data from client, there are :[%s]", rv, buf); - } - if ((rv =write(clienfd, msg, strlen(msg))) < 0) - { - dbg_time("write to cilent by socket[%d] error:%s",clienfd, strerror(errno)); - goto STOP; - } - } -STOP: - dbg_time("The socket[%d] will exit!", clienfd); - return 0; -} - -void *thread_socket_server(void *args) -{ - int on = 1; - int rv = 0; - struct sockaddr_un serv_addr; - struct sockaddr_un cli_addr; - socklen_t len = sizeof(serv_addr); - sprintf(fibo_dial_filepath,"/tmp/fibocom_dial_%d",*(int*)args); - char* msg = "receive quit request\n"; - if ((socket_server_fd = socket(AF_UNIX,SOCK_STREAM,0))< 0) - { - dbg_time("Socket error:%s\a\n", strerror(errno)); - return ; - } - dbg_time("socket[%d] successfuly!", socket_server_fd); - if (!access(fibo_dial_filepath, F_OK)) - { - unlink(fibo_dial_filepath); - } - setsockopt(socket_server_fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); - memset(&serv_addr, 0, sizeof(serv_addr)); - serv_addr.sun_family = AF_UNIX; - strncpy(serv_addr.sun_path, fibo_dial_filepath, sizeof(serv_addr.sun_path) - 1); - if ((rv = bind(socket_server_fd, (struct sockaddr *)&serv_addr, len)) < 0) - { - dbg_time("Bind error %s", strerror(errno)); - goto EXIT; - } - if ((rv = listen(socket_server_fd, 13)) < 0) - { - dbg_time("Listen error:%s", strerror(errno)); - goto EXIT; - } - dbg_time("Waiting client to connect....."); - sem_post(&sem); - while(1) - { - if ((cli_accept_fd = accept(socket_server_fd, (struct sockaddr *)&cli_addr, &len))< 0) - { - dbg_time("accept error:%s", strerror(errno)); - goto EXIT; - } - dbg_time("client to connected"); - rv = rdwr_init(cli_accept_fd, msg); - goto EXIT; - } -EXIT: - unlink(fibo_dial_filepath); - close(socket_server_fd ); - close(cli_accept_fd ); - send_signo_to_main(SIGTERM); - return ((void *)0); - -} - -//2020-12-29 willa.liu@fibocom.com changed begin for support mantis 0066901 -int startSocketserver(int pdpindex) -{ - pthread_t ntid; - //sem_init(&sem, 0, 2); - sem_init(&sem, 0, 0); - if (pthread_create(&ntid, 0, thread_socket_server, - (void *)(&pdpindex)) != 0) { - dbg_time("%s Failed to create QMIThread: %d (%s)", __func__, errno, - strerror(errno)); - } - sem_wait(&sem); - sem_destroy(&sem); - return 0; -} -//2020-12-29 willa.liu@fibocom.com changed begin for support mantis 0066901 - -int startSocketclient(int pdpindex) -{ - int socket_client_fd; - int rv = -1; - struct sockaddr_un servaddr; - char fibo_dial_filepath[100] = {0}; - sprintf(fibo_dial_filepath,"/tmp/fibocom_dial_%d",pdpindex); - dbg_time("enter startSocketclient %s.",fibo_dial_filepath); - char* message = "fibocom-dial quit request"; - char buf[1024]; - - if(access(fibo_dial_filepath, F_OK) != 0) - { - return -1; - } - socket_client_fd = socket(AF_UNIX,SOCK_STREAM,0); - if(socket_client_fd < 0) - { - dbg_time("Cearte socket failure :%s\a",strerror(errno)); - return -1; - } - dbg_time("Create socket [%d] sucessfully.",socket_client_fd); - memset(&servaddr,0,sizeof(servaddr)); - servaddr.sun_family = AF_UNIX; - strncpy(servaddr.sun_path, fibo_dial_filepath, sizeof(servaddr.sun_path) - 1); - rv = connect(socket_client_fd,(struct sockaddr *)&servaddr,sizeof(servaddr)); - if(rv <0) - { - dbg_time("connect to server [%s] failure :%s\a",fibo_dial_filepath,strerror(errno)); - return -2; - } - dbg_time("connect to server [%s] successfully!",fibo_dial_filepath); - rv = write(socket_client_fd,message,strlen(message)); - if(rv <0) - { - dbg_time("Write to server failure by socket[%d] failure: %s",socket_client_fd,strerror(errno)); - return -3; - } - else - { - dbg_time("Write [%s] to server by socket[%d] successfuly!", message, socket_client_fd); - } - memset(buf,0,sizeof(buf)); - rv = read(socket_client_fd,buf,1024); - if(rv < 0) - { - dbg_time("Read to server socket[%d] failure: %s",socket_client_fd,strerror(errno)); - return -4; - } - else if(rv == 0) - { - dbg_time("socket [%d] get disconnected",socket_client_fd); - return -4; - } - else if(rv >0) - { - dbg_time("Read [%d] bytes data from Server: [%s]",rv,buf); - } - close(socket_client_fd); - unlink(fibo_dial_filepath); - - return 0; -} -//2020-12-23 willa.liu@fibocom.com changed begin for support mantis 0065286 - -int main(int argc, char *argv[]) -{ - int triger_event = 0; - int opt = 1; - int signo; -//2021-03-24 willa.liu@fibocom.com changed begin for support mantis 0071817 - int sim_number = 0; -//begin modified by zhangkaibo limit input parameters. mantis 0048965 20200605 - char argvtemp[256] = {0}; -//end modified by zhangkaibo limit input parameters. mantis 0048965 20200605 - -//2020-12-23 willa.liu@fibocom.com changed begin for support mantis 0065286 - int killnumber = -1; -//2020-12-23 willa.liu@fibocom.com changed end for support mantis 0065286 - -#ifdef CONFIG_SIM - SIM_Select SIMNumber; -//2021-03-24 willa.liu@fibocom.com changed end for support mantis 0071817 - SIM_Status SIMStatus; -#endif - UCHAR PSAttachedState; - UCHAR IPv4ConnectionStatus = 0xff; // unknow state - UCHAR IPV6ConnectionStatus = 0xff; // unknow state - int qmierr = 0; - char *save_usbnet_adapter = NULL; - PROFILE_T profile; -#ifdef CONFIG_RESET_RADIO - struct timeval resetRadioTime = {0}; - struct timeval FailDailRadioTime = {0}; - struct timeval nowTime; - gettimeofday(&resetRadioTime, (struct timezone *)NULL); -#endif - - dbg_time("Fibocom-dial_Linux_Tool_V%s", VERSION_STRING()); - memset(&profile, 0x00, sizeof(profile)); - profile.pdp = CONFIG_DEFAULT_PDP; - profile.pdpindex = CONFIG_DEFAULT_PDPINDEX; - profile.pdpnum = 1; - - if (!strcmp(argv[argc - 1], "&")) - argc--; - - opt = 1; - while (opt < argc) { - if (argv[opt][0] != '-') - return usage(argv[0]); - - switch (argv[opt++][1]) { -#define has_more_argv() ((opt < argc) && (argv[opt][0] != '-')) - case 's': - profile.apn = profile.user = profile.password = ""; - if (has_more_argv()) - profile.apn = argv[opt++]; - if (has_more_argv()) - profile.user = argv[opt++]; - if (has_more_argv()) { - profile.password = argv[opt++]; - if (profile.password && profile.password[0]) - profile.auth = 2; // default chap, customers may miss auth - } - if (has_more_argv()) -//begin modified by zhangkaibo limit input parameters. mantis 0048965 20200605 - { - memset(argvtemp,0,256); - strcpy(argvtemp,argv[opt++]); - if(strlen(argvtemp) > 1 || !IsInt(argvtemp)) - { - dbg_time("Invalid parament for \"-s\""); - return -1; - } - profile.auth = argvtemp[0] - '0'; -//begin modified by zhangkaibo limit input parameters. mantis 0077949 20200513 - if(profile.auth < 0 || profile.auth > 3) - { - dbg_time("auth must be 0~3"); -//end modified by zhangkaibo limit input parameters. mantis 0077949 20200513 - return -1; - } - } -//end modified by zhangkaibo limit input parameters. mantis 0048965 20200605 - break; - - case 'm': - if (has_more_argv()) - { - if (is_pcie_dial()) - profile.muxid = argv[opt++][0] - '0'; - else - { - memset(argvtemp,0,256); - strcpy(argvtemp,argv[opt++]); - if(strlen(argvtemp) > 1 || !IsInt(argvtemp)) - { - dbg_time("Invalid parament for \"-P\""); - return -1; - } - profile.pdpindex = argvtemp[0] - '0'; - if(profile.pdpindex < 1 || profile.pdpindex > 10) - { - dbg_time("pdpindex must be 1~10"); - return -1; - } - } - } - break; - - case 'p': - if (has_more_argv()) - profile.pincode = argv[opt++]; - break; -#if 0 - case 'P': - if (has_more_argv()) -//begin modified by zhangkaibo limit input parameters. mantis 0048965 20200605 - { - memset(argvtemp,0,256); - strcpy(argvtemp,argv[opt++]); - if(strlen(argvtemp) > 1 || !IsInt(argvtemp)) - { - dbg_time("Invalid parament for \"-P\""); - return -1; - } - profile.pdpindex = argvtemp[0] - '0'; - if(profile.pdpindex < 1 || profile.pdpindex > 10) - { - dbg_time("pdpindex must be 1~10"); - return -1; - } - } -//end modified by zhangkaibo limit input parameters. mantis 0048965 20200605 - break; -#endif - case 'n': - if (has_more_argv()) -//begin modified by zhangkaibo limit input parameters. mantis 0048965 20200605 - { - memset(argvtemp,0,256); - strcpy(argvtemp,argv[opt++]); - if(strlen(argvtemp) > 1 || !IsInt(argvtemp)) - { - dbg_time("Invalid parament for \"-n\""); - return -1; - } - profile.pdp = argvtemp[0] - '0'; - if(profile.pdp < 1 || profile.pdp > 8) - { - dbg_time("pdpindex must be 1~8"); - return -1; - } - - if (is_pcie_dial()) - profile.pdpindex = profile.pdp; - } - break; -//end modified by zhangkaibo limit input parameters. mantis 0048965 20200605 - case 'N': - if (has_more_argv()) -//begin modified by zhangkaibo limit input parameters. mantis 0048965 20200605 - { - memset(argvtemp,0,256); - strcpy(argvtemp,argv[opt++]); - if(strlen(argvtemp) > 1 || !IsInt(argvtemp)) - { - dbg_time("Invalid parament for \"-N\""); - return -1; - } - profile.pdpnum = argvtemp[0] - '0'; - if(profile.pdpnum < 0 || profile.pdpnum > 8) - { - dbg_time("pdpnum must be 0~8"); - return -1; - } - } -//end modified by zhangkaibo limit input parameters. mantis 0048965 20200605 - break; - - case 'f': - if (has_more_argv()) { - const char *filename = argv[opt++]; - logfilefp = fopen(filename, "a+"); - if (!logfilefp) { - dbg_time("Fail to open %s, errno: %d(%s)", filename, errno, - strerror(errno)); - } - } - break; - - case 'i': - if (has_more_argv()) - profile.usbnet_adapter = save_usbnet_adapter = argv[opt++]; - break; - - case 'v': - debug_qmi = 1; - break; - - case 'l': - if (has_more_argv()) { - profile.replication_factor = atoi(argv[opt++]); - if (profile.replication_factor > 0) - profile.loopback_state = 1; - } - else - main_loop = 1; - - break; - - case '4': - profile.ipv4_flag = 1; - break; - - case '6': - profile.ipv6_flag = 1; - break; - -//2021-02-25 willa.liu@fibocom.com changed begin for support eipd SN-20210129001 - case 'g': - profile.ipv6_prigateway_flag = 1; - break; -//2021-02-25 willa.liu@fibocom.com changed end for support eipd SN-20210129001 - - case 'd': - if (has_more_argv()) { - profile.qmichannel = argv[opt++]; - if (qmidev_is_pciemhi(profile.qmichannel)) - profile.usbnet_adapter = "pcie_mhi0"; - } - break; - - case 'U': - query_pcie_mode = 1; - break; - -//2020-12-23 willa.liu@fibocom.com changed begin for support mantis 0065286 - case 'k': - if (has_more_argv()) - { - memset(argvtemp,0,256); - strcpy(argvtemp,argv[opt++]); - if(strlen(argvtemp) > 1 || !IsInt(argvtemp)) - { - dbg_time("Invalid parament for \"-n\""); - return -1; - } - killnumber = argvtemp[0] - '0'; -//2021-02-01 willa.liu@fibocom.com changed begin for support mantis 0069837 - //if(killnumber < 1 || killnumber > 5) - if(killnumber < 1 || killnumber > 8) - { - dbg_time("pdpindex must be 1~8"); - return -1; - } -//2021-02-01 willa.liu@fibocom.com changed end for support mantis 0069837 - } - break; -//2020-12-23 willa.liu@fibocom.com changed end for support mantis 0065286 - - default: - return usage(argv[0]); - break; - } - } - - if (profile.ipv4_flag != 1 && - profile.ipv6_flag != 1) { // default enable IPv4 - profile.ipv4_flag = 1; - } - - dbg_time("%s profile[%d] = %s/%s/%s/%d, pincode = %s", argv[0], profile.pdp, - profile.apn, profile.user, profile.password, profile.auth, - profile.pincode); - signal(SIGUSR1, fibo_sigaction); - signal(SIGUSR2, fibo_sigaction); - signal(SIGINT, fibo_sigaction); - signal(SIGTERM, fibo_sigaction); - signal(SIGHUP, fibo_sigaction); - signal(SIGCHLD, fibo_sigaction); - signal(SIGALRM, fibo_sigaction); - - //2020-12-23 willa.liu@fibocom.com changed begin for support mantis 0065286 - if(killnumber == -1) - { - startSocketserver(profile.pdp); - } - else{ - startSocketclient(killnumber); - return 0; - } - //2020-12-23 willa.liu@fibocom.com changed end for support mantis 0065286 - - if (socketpair(AF_LOCAL, SOCK_STREAM, 0, signal_control_fd) < 0) { - dbg_time("%s Faild to create main_control_fd: %d (%s)", __func__, errno, - strerror(errno)); - return -1; - } - - if (socketpair(AF_LOCAL, SOCK_STREAM, 0, qmidevice_control_fd) < 0) { - dbg_time("%s Failed to create thread control socket pair: %d (%s)", - __func__, errno, strerror(errno)); - return 0; - } - -// sudo apt-get install udhcpc -// sudo apt-get remove ModemManager -__main_loop: - while (!profile.qmichannel) { -//2021-02-08 zhangkaibo@fibocom.com changed start for mantis 0070613 - if (qmidevice_detect(&profile.qmichannel, &profile.usbnet_adapter,&profile)) -//2021-02-08 zhangkaibo@fibocom.com changed end for mantis 0070613 - { - if (query_pcie_mode) - get_pcie_mode(); - break; - } - if (main_loop) { - int wait_for_device = 3000; - dbg_time("Wait for fibo modules connect"); - while (wait_for_device && main_loop) { - wait_for_device -= 100; - usleep(100 * 1000); - } - continue; - } - dbg_time( - "Cannot find qmichannel(%s) usbnet_adapter(%s) for fibo modules", - profile.qmichannel, profile.usbnet_adapter); - return -ENODEV; - } - - if (access(profile.qmichannel, R_OK | W_OK)) { - dbg_time("Fail to access %s, errno: %d (%s)", profile.qmichannel, errno, - strerror(errno)); - return errno; - } - dbg_time( - "qmichannel(%s) usbnet_adapter(%s) ", - profile.qmichannel, profile.usbnet_adapter); - - if (qmidev_is_gobinet(profile.qmichannel)) { - profile.qmi_ops = &gobi_qmidev_ops; - dbg_time("usb rmnet mode"); - } else { - profile.qmi_ops = &qmiwwan_qmidev_ops; - dbg_time("pcie mode"); - } - qmidev_send = profile.qmi_ops->send; - fibo_qmap_mode_detect(&profile); - if (profile.pdpnum > 1 && profile.pdpnum != profile.qmap_mode && !qmidev_is_pciemhi(profile.qmichannel)) { - if (profile.qmap_mode > 1) { - dbg_time("qmap_mode=%d,profile.pdpnum %d",profile.qmap_mode,profile.pdpnum); - kill_brothers(profile.qmichannel); - } - fibo_qmap_mode_set(&profile); - } - fibo_qmap_mode_detect(&profile); -//begin modified by zhangkaibo limit input parameters. mantis 0048965 20200605 - if(profile.qmap_mode < profile.pdp && profile.qmap_mode > 0 && !qmidev_is_pciemhi(profile.qmichannel)) - { - dbg_time("invalid pdpindex"); - return -1; - } -//end modified by zhangkaibo limit input parameters. mantis 0048965 20200605 - if (profile.qmap_mode == 0 || profile.qmap_mode == 1) - { - dbg_time("qmap_mode=%d",profile.qmap_mode); - kill_brothers(profile.qmichannel); - } - if (pthread_create(&gQmiThreadID, 0, profile.qmi_ops->read, - (void *)&profile) != 0) { - dbg_time("%s Failed to create QMIThread: %d (%s)", __func__, errno, - strerror(errno)); - return 0; - } - - if ((read(qmidevice_control_fd[0], &triger_event, sizeof(triger_event)) != - sizeof(triger_event)) || - (triger_event != RIL_INDICATE_DEVICE_CONNECTED)) { - dbg_time("%s Failed to init QMIThread: %d (%s)", __func__, errno, - strerror(errno)); - return 0; - } - - if (profile.qmi_ops->init && profile.qmi_ops->init(&profile)) { - dbg_time("%s Failed to qmi init: %d (%s)", __func__, errno, - strerror(errno)); - return 0; - } - -#ifdef CONFIG_VERSION - requestBaseBandVersion(NULL); -#endif - requestSetEthMode(&profile); - -#ifdef CONFIG_SIM -//2021-03-24 willa.liu@fibocom.com changed begin for support mantis 0071817 - sim_number = requestGetSIMCardNumber(&profile); - if(sim_number == 1){ - requestSimBindSubscription_NAS_WMS(); - requestSimBindSubscription_WDS_DMS_QOS(); - } - //qmierr = requestGetSIMStatus(&SIMStatus); - qmierr = requestGetSIMStatus(&SIMStatus, sim_number); - while (qmierr == QMI_ERR_OP_DEVICE_UNSUPPORTED) { - sleep(1); - //qmierr = requestGetSIMStatus(&SIMStatus); - qmierr = requestGetSIMStatus(&SIMStatus, sim_number); -//2021-03-24 willa.liu@fibocom.com changed begin for support mantis 0071817 - } - if ((SIMStatus == SIM_PIN) && profile.pincode) { - requestEnterSimPin(profile.pincode); - } -#ifdef CONFIG_IMSI_ICCID - if (SIMStatus == SIM_READY) { - requestGetICCID(); - requestGetIMSI(); - } -#endif -#endif -#ifdef CONFIG_APN - if (profile.apn || profile.user || profile.password) { - requestSetProfile(&profile); - } - requestGetProfile(&profile); -#endif - requestRegistrationState2(&PSAttachedState); - /* - if (!requestQueryDataCall(&IPv4ConnectionStatus, IpFamilyV4) && - (QWDS_PKT_DATA_CONNECTED == IPv4ConnectionStatus)) usbnet_link_change(1, - &profile); else usbnet_link_change(0, &profile); - */ - send_signo_to_main(SIGUSR2); - - while (1) { - struct pollfd pollfds[] = {{signal_control_fd[1], POLLIN, 0}, - {qmidevice_control_fd[0], POLLIN, 0}}; - int ne, ret, nevents = sizeof(pollfds) / sizeof(pollfds[0]); - - do { - ret = poll(pollfds, nevents, 15 * 1000); - } while ((ret < 0) && (errno == EINTR)); - - if (ret == 0) { - send_signo_to_main(SIGUSR2); - continue; - } - - if (ret <= 0) { - dbg_time("%s poll=%d, errno: %d (%s)", __func__, ret, errno, - strerror(errno)); - goto __main_quit; - } - - for (ne = 0; ne < nevents; ne++) { - int fd = pollfds[ne].fd; - short revents = pollfds[ne].revents; - dbg_time("epoll fd = %d, events = 0x%04x", fd, revents); - if (revents & (POLLERR | POLLHUP | POLLNVAL)) { - dbg_time("%s poll err/hup", __func__); - dbg_time("epoll fd = %d, events = 0x%04x", fd, revents); - main_send_event_to_qmidevice(RIL_REQUEST_QUIT); - if (revents & POLLHUP) - goto __main_quit; - } - - if ((revents & POLLIN) == 0) - continue; - - if (fd == signal_control_fd[1]) { - if (read(fd, &signo, sizeof(signo)) == sizeof(signo)) { - alarm(0); - dbg_time("get signo: %d ",signo); - switch (signo) { - case SIGUSR1: - { - if(profile.ipv4_flag) - { - if (QWDS_PKT_DATA_CONNECTED != IPv4ConnectionStatus) { - usbnet_link_change(0, &profile); - requestRegistrationState2(&PSAttachedState); - -//2021-02-05 willa.liu@fibocom.com changed begin for support mantis 0070460 - //if (PSAttachedState == 1 || profile.loopback_state == 0) { - if (PSAttachedState == 1 || profile.loopback_state == 1) { - qmierr = - requestSetupDataCall(&profile, IpFamilyV4); - - if ((qmierr > 0) && profile.user && - profile.user[0] && profile.password && - profile.password[0]) { - int old_auto = profile.auth; - - // may be fail because wrong auth mode, try - // pap->chap, or chap->pap - profile.auth = (profile.auth == 1) ? 2 : 1; - qmierr = requestSetupDataCall(&profile, - IpFamilyV4); - - if (qmierr) - profile.auth = - old_auto; // still fail, restore - // old auth moe - } - if (!qmierr) { - requestGetIPAddress(&profile, IpFamilyV4); - } - if (!qmierr){ - IPv4ConnectionStatus = QWDS_PKT_DATA_CONNECTED; - FailDailRadioTime.tv_sec = 0; - } - else if(FailDailRadioTime.tv_sec == 0) { - gettimeofday(&FailDailRadioTime, (struct timezone *)NULL); - } - } - } - } - if(profile.ipv6_flag) - { - if (QWDS_PKT_DATA_CONNECTED != IPV6ConnectionStatus) { - if(!profile.ipv4_flag) - { - usbnet_link_change(0, &profile); - requestRegistrationState2(&PSAttachedState); - } - else - { - profile.dual_flag = 1; - //PSAttachedState = 1; // for dual stack - requestRegistrationState2(&PSAttachedState); - } -//2021-02-05 willa.liu@fibocom.com changed end for support mantis 0070460 - - if (PSAttachedState == 1) { - qmierr = - requestSetupDataCall(&profile, IpFamilyV6); - if ((g_MobileCountryCode == 460) && (g_MobileNetworkCode == 1 || g_MobileNetworkCode == 6)) { - if (qmierr > 0 && profile.dual_flag == 1) { - profile.dual_flag = 0; - profile.ipv6_flag = 0; - dbg_time("%s Dual stack dial IPv6 failed, quit", __func__); - break; - } - } - if ((qmierr > 0) && profile.user && - profile.user[0] && profile.password && - profile.password[0]) { - int old_auto = profile.auth; - - // may be fail because wrong auth mode, try - // pap->chap, or chap->pap - profile.auth = (profile.auth == 1) ? 2 : 1; - qmierr = requestSetupDataCall(&profile, - IpFamilyV6); - - if (qmierr) - profile.auth = - old_auto; // still fail, restore - // old auth moe - } - if (!qmierr) { - requestGetIPAddress(&profile, IpFamilyV6); - } - - if (!qmierr){ - IPV6ConnectionStatus = QWDS_PKT_DATA_CONNECTED; - FailDailRadioTime.tv_sec = 0; - } - else if(FailDailRadioTime.tv_sec == 0) { - gettimeofday(&FailDailRadioTime, (struct timezone *)NULL); - } - } - } - } -#ifdef CONFIG_RESET_RADIO - if( ((profile.ipv4_flag)&&(IPv4ConnectionStatus != QWDS_PKT_DATA_CONNECTED))|| - ((profile.ipv6_flag)&&(IPV6ConnectionStatus != QWDS_PKT_DATA_CONNECTED))) - { - gettimeofday(&nowTime, (struct timezone *)NULL); - if( ((abs(nowTime.tv_sec - FailDailRadioTime.tv_sec) > CONFIG_RESET_RADIO)) - &&(FailDailRadioTime.tv_sec > resetRadioTime.tv_sec)){ - resetRadioTime = nowTime; - // requestSetOperatingMode(0x06); //same as - // AT+CFUN=0 - requestSetOperatingMode( - 0x01); // same as AT+CFUN=4 - requestSetOperatingMode( - 0x00); // same as AT+CFUN=1 - } - } -#endif - alarm(5); // try to setup data call 5 seconds later - } - break; - - case SIGUSR2: - { - - if (profile.ipv4_flag) - { - requestQueryDataCall(&IPv4ConnectionStatus, IpFamilyV4); - //local ip is different with remote ip - if (QWDS_PKT_DATA_CONNECTED == IPv4ConnectionStatus && check_address(&profile,IpFamilyV4) == 0) { - requestDeactivateDefaultPDP(&profile, IpFamilyV4); - IPv4ConnectionStatus = QWDS_PKT_DATA_DISCONNECTED; - } - } - else - IPv4ConnectionStatus = QWDS_PKT_DATA_DISCONNECTED; - if (profile.ipv6_flag) - requestQueryDataCall(&IPV6ConnectionStatus, IpFamilyV6); - else - IPV6ConnectionStatus = QWDS_PKT_DATA_DISCONNECTED; - if(IPv4ConnectionStatus == QWDS_PKT_DATA_DISCONNECTED && IPV6ConnectionStatus == QWDS_PKT_DATA_DISCONNECTED) - { - usbnet_link_change(0, &profile); - } - if((profile.ipv6_flag && profile.ipv6_flag ) && ((IPv4ConnectionStatus == QWDS_PKT_DATA_CONNECTED && IPV6ConnectionStatus == QWDS_PKT_DATA_CONNECTED)) ) - { - usbnet_link_change(1, &profile); - } - else - if(IPv4ConnectionStatus == QWDS_PKT_DATA_CONNECTED || IPV6ConnectionStatus == QWDS_PKT_DATA_CONNECTED) - { - usbnet_link_change(1, &profile); - } - if((profile.ipv4_flag && IPv4ConnectionStatus == QWDS_PKT_DATA_DISCONNECTED ) || - (profile.ipv6_flag && IPV6ConnectionStatus == QWDS_PKT_DATA_DISCONNECTED )) - { - send_signo_to_main(SIGUSR1); - } - } - break; - - case SIGTERM: - case SIGHUP: - case SIGINT: - if(profile.ipv4_flag && IPv4ConnectionStatus == QWDS_PKT_DATA_CONNECTED) - requestDeactivateDefaultPDP(&profile, IpFamilyV4); - if(profile.ipv6_flag && IPV6ConnectionStatus == QWDS_PKT_DATA_CONNECTED) - requestDeactivateDefaultPDP(&profile, IpFamilyV6); - - usbnet_link_change(0, &profile); - if (profile.qmi_ops->deinit) - profile.qmi_ops->deinit(); - main_send_event_to_qmidevice(RIL_REQUEST_QUIT); - goto __main_quit; - break; - - default: - break; - } - } - } - - if (fd == qmidevice_control_fd[0]) { - if (read(fd, &triger_event, sizeof(triger_event)) == - sizeof(triger_event)) { - switch (triger_event) { - case RIL_INDICATE_DEVICE_DISCONNECTED: - usbnet_link_change(0, &profile); - if (main_loop) { - if (pthread_join(gQmiThreadID, NULL)) { - dbg_time( - "%s Error joining to listener thread (%s)", - __func__, strerror(errno)); - } - profile.qmichannel = NULL; - profile.usbnet_adapter = save_usbnet_adapter; - goto __main_loop; - } - goto __main_quit; - break; - - case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED: - requestRegistrationState2(&PSAttachedState); - if (PSAttachedState == 1) - { -//begin modify for mantis 0050112 by kaibo.zhangkaibo@fibocom.com - if((profile.ipv4_flag && IPv4ConnectionStatus == QWDS_PKT_DATA_DISCONNECTED) - ||(profile.ipv6_flag && IPV6ConnectionStatus == QWDS_PKT_DATA_DISCONNECTED)) -//end modify for mantis 0050112 by kaibo.zhangkaibo@fibocom.com - send_signo_to_main(SIGUSR1); - } - break; - - case RIL_UNSOL_DATA_CALL_LIST_CHANGED: - if (IPv4ConnectionStatus == QWDS_PKT_DATA_CONNECTED || IPV6ConnectionStatus == QWDS_PKT_DATA_CONNECTED) - send_signo_to_main(SIGUSR2); - break; - - default: - break; - } - } - } - } - } - -__main_quit: - usbnet_link_change(0, &profile); - if (pthread_join(gQmiThreadID, NULL)) { - dbg_time("%s Error joining to listener thread (%s)", __func__, - strerror(errno)); - } - close(signal_control_fd[0]); - close(signal_control_fd[1]); - close(qmidevice_control_fd[0]); - close(qmidevice_control_fd[1]); - dbg_time("%s exit", __func__); - if (logfilefp) - fclose(logfilefp); - -//2020-12-23 willa.liu@fibocom.com changed begin for support mantis 0065286 - unlink(fibo_dial_filepath); - close(socket_server_fd ); - close(cli_accept_fd ); -//2020-12-23 willa.liu@fibocom.com changed end for support mantis 0065286 - - return 0; -} diff --git a/fibocom-dial/src/multi-pdn-manager.c b/fibocom-dial/src/multi-pdn-manager.c deleted file mode 100644 index 20d05e7..0000000 --- a/fibocom-dial/src/multi-pdn-manager.c +++ /dev/null @@ -1,1019 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -//begin modified by zhangkaibo get qmap_num process flow. mantis 0048920,0048917 20200605 -#include -//end modified by zhangkaibo get qmap_num process flow. mantis 0048920,0048917 20200605 -#include "util.h" -#include "query_pcie_mode.h" -#define MAJOR 1 -#define MINOR 0 -#define REVISION 4 -/* - * Generally, we do not modify version info, so several modifications will share - * the same version code. SUBVERSION is used for customized modification to - * distinguise this version from previous one. SUBVERSION adds up before you - * send the code to customers and it should be set to 0 if VERSION_STRING info - * is changed. - */ -#define SUBVERSION 0 -#define STRINGIFY_HELPER(v) #v -#define STRINGIFY(v) STRINGIFY_HELPER(v) -#define VERSION_STRING() \ - STRINGIFY(MAJOR) "." STRINGIFY(MINOR) "." STRINGIFY(REVISION) -#define MAX_PATH 256 - -#define _PARAM_GLOBALS_ -#include -#include -#include -#include -#include -#include -#include -#include -#include -//begin modified by zhangkaibo get qmap_num process flow. mantis 0048920,0048917 20200605 -#include -//end modified by zhangkaibo get qmap_num process flow. mantis 0048920,0048917 20200605 -#define SECTION_MAX_LEN 256 -#define STRVALUE_MAX_LEN 256 -#define LINE_CONTENT_MAX_LEN 256 -#define READ_STR_ERR -1 -#define READ_STR_OK 0 -//begin modified by zhangkaibo get qmap_num process flow. mantis 0048920,0048917 20200605 - -//2021-03-24 willa.liu@fibocom.com changed begin for support mantis 0071817 -//#include "query_pcie_mode.h" -//2021-03-24 willa.liu@fibocom.com changed end for support mantis 0071817 - -static int is_pcie_dial() -{ - return (access("/dev/mhi_QMI0", F_OK) == 0); -} - -static int is_gobinet_dial() -{ - return (access("/dev/qcqmi0", F_OK) == 0); -} - -static int is_qmiwwan_dial() -{ - return (access("/dev/cdc-wdm0", F_OK) == 0); -} - -static size_t fibo_fread(const char *filename, void *buf, size_t size) -{ - FILE *fp = fopen(filename, "r"); - size_t n = 0; - - memset(buf, 0x00, size); - - if (fp) { - n = fread(buf, 1, size, fp); - if (n <= 0 || n == size) { - dbg_time( - "warnning: fail to fread(%s), fread=%zd, buf_size=%zd, " - "errno: %d (%s)", - __func__, filename, n, size, errno, strerror(errno)); - } - fclose(fp); - } - - return n > 0 ? n : 0; -} - -int get_qmap_num() -{ - int n; - int qmap_num=-1; - char buf[128]; - struct { - char filename[255 * 2]; - char linkname[255 * 2]; - } * pl; - - if (is_pcie_dial()) - return 8; - - pl = (typeof(pl))malloc(sizeof(*pl)); - - if(is_gobinet_dial()) - { - snprintf(pl->linkname, sizeof(pl->linkname), - "/sys/class/net/usb0/device/driver"); - n = readlink(pl->linkname, pl->filename, sizeof(pl->filename)); - pl->filename[n] = '\0'; - while (pl->filename[n] != '/') n--; - - snprintf(pl->filename, sizeof(pl->filename), "/sys/class/net/usb0/qmap_num"); - //2021-02-22 kaibo.zhangkaibo@fibocom.com changed begin for support mantis 0071171 - if (access(pl->filename, F_OK) == 0) { - dbg_time("access %s", pl->filename); - if (errno != ENOENT) { - dbg_time("fail to access %s, errno: %d (%s)", pl->filename, errno, - strerror(errno)); - goto _out; - } - } - else - { - snprintf(pl->filename, sizeof(pl->filename), "/sys/class/net/usb0/qmap_mode"); - if (access(pl->filename, F_OK) == 0) { - dbg_time("access %s", pl->filename); - if (errno != ENOENT) { - dbg_time("fail to access %s, errno: %d (%s)", pl->filename, errno, - strerror(errno)); - goto _out; - } - } - } - } - if(is_qmiwwan_dial()) - { - snprintf(pl->linkname, sizeof(pl->linkname), - "/sys/class/net/wwan0/device/driver"); - n = readlink(pl->linkname, pl->filename, sizeof(pl->filename)); - pl->filename[n] = '\0'; - while (pl->filename[n] != '/') n--; - - snprintf(pl->filename, sizeof(pl->filename), "/sys/class/net/wwan0/qmap_mode"); - if (access(pl->filename, F_OK) == 0) { - dbg_time("access %s", pl->filename); - if (errno != ENOENT) { - dbg_time("fail to access %s, errno: %d (%s)", pl->filename, errno, - strerror(errno)); - goto _out; - } - } - } - - dbg_time("access %s", pl->filename); - - if (!access(pl->filename, R_OK)) { - n = fibo_fread(pl->filename, buf, sizeof(buf)); - if (n > 0) { - qmap_num = atoi(buf); - } - } -_out: - free(pl); - - return qmap_num; -} -//end modified by zhangkaibo get qmap_num process flow. mantis 0048920,0048917 20200605 -//begin modified by zhangkaibo limit input parameters. mantis 0048965 20200605 -int IsInt(char* str) -{ - int len; - len = strlen(str-1); - len = len>=1?len:1; - int i=0; - for(; i < len ; i++) - { - if(!(isdigit(str[i]))) - return 0; - } - return 1; -} - -//end modified by zhangkaibo limit input parameters. mantis 0048965 20200605 -// read value from .ini -void IniReadValue(char *section, char *key, char *val, const char *file) -{ - FILE *fp; - int i = 0; - int lineContentLen = 0; - int position = 0; - char lineContent[LINE_CONTENT_MAX_LEN]; - bool bFoundSection = false; - bool bFoundKey = false; - fp = fopen(file, "r"); - if (fp == NULL) { - printf("%s: Opent file %s failed.\n", __FILE__, file); - return; - } - while (feof(fp) == 0) { - memset(lineContent, 0, LINE_CONTENT_MAX_LEN); - fgets(lineContent, LINE_CONTENT_MAX_LEN, fp); - if ((lineContent[0] == ';') || (lineContent[0] == '\0') || - (lineContent[0] == '\r') || (lineContent[0] == '\n')) { - continue; - } - - // check section - if (strncmp(lineContent, section, strlen(section)) == 0) { - bFoundSection = true; - // printf("Found section = %s\n", lineContent); - while (feof(fp) == 0) { - memset(lineContent, 0, LINE_CONTENT_MAX_LEN); - fgets(lineContent, LINE_CONTENT_MAX_LEN, fp); - // check key - if (strncmp(lineContent, key, strlen(key)) == 0) { - bFoundKey = true; - lineContentLen = strlen(lineContent); - // find value - for (i = strlen(key); i < lineContentLen; i++) { - if (lineContent[i] == '=') { - position = i + 1; - break; - } - } - if (i >= lineContentLen) - break; - strncpy(val, lineContent + position, - strlen(lineContent + position)); - lineContentLen = strlen(val); - for (i = 0; i < lineContentLen; i++) { - if ((val[i] == '\0') || (val[i] == '\r') || - (val[i] == '\n')) { - val[i] = '\0'; - // break; - } - } - } else if (lineContent[0] == '[') { - break; - } - } - break; - } - } - if (!bFoundSection) { - printf("No section = %s\n", section); - } else if (!bFoundKey) { - printf("No key = %s\n", key); - } - - fclose(fp); -} - -int readStringValue(const char *section, char *key, char *val, const char *file) -{ - char sect[SECTION_MAX_LEN]; - // printf("section = %s, key = %s, file = %s\n", section, key, file); - if (section == NULL || key == NULL || val == NULL || file == NULL) { - printf("%s: input parameter(s) is NULL!\n", __func__); - return READ_STR_ERR; - } - - memset(sect, 0, SECTION_MAX_LEN); - sprintf(sect, "[%s]", section); - // printf("reading value...\n"); - IniReadValue(sect, key, val, file); - - return READ_STR_OK; -} - -char fileContents[80][LINE_CONTENT_MAX_LEN]; -int fileIndex = 0; - -void IniWriteValue(const char *section, char *key, char *val, const char *file) -{ - int err = 0; - char lineContent[LINE_CONTENT_MAX_LEN]; - char strWrite[LINE_CONTENT_MAX_LEN]; - bool bFoundSection = false; - bool bFoundKey = false; - int fileIndextemp = 0; - memset(lineContent, '\0', LINE_CONTENT_MAX_LEN); - memset(strWrite, '\0', LINE_CONTENT_MAX_LEN); - sprintf(strWrite, "%s=%s\n", key, val); - - while (fileIndextemp <= fileIndex) { - memset(lineContent, 0, LINE_CONTENT_MAX_LEN); - memcpy(lineContent, fileContents[fileIndextemp++], - LINE_CONTENT_MAX_LEN); - if ((lineContent[0] == ';') || (lineContent[0] == '\0') || - (lineContent[0] == '\r') || (lineContent[0] == '\n')) { - continue; - } - // check section - if (strncmp(lineContent, section, strlen(section)) == 0) { - bFoundSection = true; - while (fileIndextemp <= fileIndex) { - memset(lineContent, 0, LINE_CONTENT_MAX_LEN); - memcpy(lineContent, fileContents[fileIndextemp], - LINE_CONTENT_MAX_LEN); - // check key - if (strncmp(lineContent, key, strlen(key)) == 0) { - bFoundKey = true; - // printf("%s: %s=%s\n", __func__, key, val); - memset(fileContents[fileIndextemp], 0, - LINE_CONTENT_MAX_LEN); - memcpy(fileContents[fileIndextemp], strWrite, - strlen(strWrite)); - // printf("%s\n",strWrite); - if (err < 0) { - printf("%s err.\n", __func__); - } - break; - } else if (lineContent[0] == '[') { - fileIndextemp++; - break; - } - fileIndextemp++; - } - break; - } - } - if (!bFoundSection) { - printf("No section = %s\n", section); - } else if (!bFoundKey) { - printf("No key = %s\n", key); - } -} - -int writeStringVlaue(const char *section, char *key, char *val, - const char *file) -{ - char sect[SECTION_MAX_LEN]; - - // printf("section = %s, key = %s, value=%s , file = %s\n", section, key, - // val, file); - if (section == NULL || key == NULL || val == NULL || file == NULL) { - printf("%s: input parameter(s) is NULL!\n", __func__); - return READ_STR_ERR; - } - memset(sect, '\0', SECTION_MAX_LEN); - sprintf(sect, "[%s]", section); - IniWriteValue(sect, key, val, file); - return READ_STR_OK; -} - -int writeIntValue(const char *section, char *key, int val, const char *file) -{ - char strValue[STRVALUE_MAX_LEN]; - memset(strValue, '\0', STRVALUE_MAX_LEN); - sprintf(strValue, "%d", val); - - return writeStringVlaue(section, key, strValue, file); -} - -int readIntValue(const char *section, char *key, const char *file) -{ - char strValue[STRVALUE_MAX_LEN]; - memset(strValue, '\0', STRVALUE_MAX_LEN); - if (readStringValue(section, key, strValue, file) != READ_STR_OK) { - printf("%s: error", __func__); - return 0; - } - return (atoi(strValue)); -} - -int mygetch() -{ - struct termios oldt, newt; - int ch; - tcgetattr(STDIN_FILENO, &oldt); - newt = oldt; - newt.c_lflag &= ~(ICANON | ECHO); - tcsetattr(STDIN_FILENO, TCSANOW, &newt); - ch = getchar(); - tcsetattr(STDIN_FILENO, TCSANOW, &oldt); - return ch; -} - -#define CONFIG_FILE "multi-pdn.ini" -#define DIAL_PROCESS "fibocom-dial" -#define MAX_QMAP_NUM 8 - -struct profile { - char apn[MAX_PATH]; - char user[MAX_PATH]; - char password[MAX_PATH]; - int auth; - int ipfamily; -//begin modified by zhangkaibo add sim pin operate. mantis 0049142 20200612 - char pin[MAX_PATH]; -//end modified by zhangkaibo add sim pin operate. mantis 0049142 20200612 -}; - -int shmid; -void *shm; -int qmap_num = -1; - -bool connectState[MAX_QMAP_NUM]; -int lock_file = -1; - -void initShareMemory() -{ - shmid = shmget((key_t)9527, sizeof(int) * 8, 0666 | IPC_CREAT); - if (shmid == -1) { - fprintf(stderr, "shmget failed\n"); - exit(EXIT_FAILURE); - } - shm = shmat(shmid, 0, 0); - if (shm == (void *)-1) { - fprintf(stderr, "shmat failed\n"); - exit(EXIT_FAILURE); - } -} - -void destoryShareMemory() -{ - if (shmdt(shm) == -1) { - fprintf(stderr, "shmdt failed\n"); - exit(EXIT_FAILURE); - } - - if (shmctl(shmid, IPC_RMID, 0) == -1) { - fprintf(stderr, "shmctl(IPC_RMID) failed\n"); - exit(EXIT_FAILURE); - } -} - -void SIGINT_handle(int sig_num) - -{ - printf("reveice signal %d \n", sig_num); - { - int *connectPids = (int *)shm; - int cIndex; - for(cIndex = 1 ; cIndex <= qmap_num ; cIndex++) - { - dbg_time("kill pid %d", connectPids[cIndex - 1]); - kill(connectPids[cIndex - 1], SIGINT); - connectState[cIndex - 1] = false; - } - } - destoryShareMemory(); - close(lock_file); // 不要忘记释放文件指针 - exit(0); -} - -int loadConfigFromIni(struct profile *profileList, bool *connectState) -{ - int profileIndex; -//begin modified by zhangkaibo get qmap_num process flow. mantis 0048920,0048917 20200605 - //qmap_num = readIntValue("Setting", "qmap_num", CONFIG_FILE); - qmap_num = get_qmap_num(); - if (qmap_num == 0 || qmap_num == -1 ) - return -1; -//end modified by zhangkaibo get qmap_num process flow. mantis 0048920,0048917 20200605 - for (profileIndex = 0; profileIndex < 8; profileIndex++) { - char profilename[MAX_PATH]; - sprintf(profilename, "profile%d", profileIndex + 1); - memset(profileList[profileIndex].apn, 0, MAX_PATH); - readStringValue(profilename, "apn", profileList[profileIndex].apn, - CONFIG_FILE); - memset(profileList[profileIndex].user, 0, MAX_PATH); - readStringValue(profilename, "user", profileList[profileIndex].user, - CONFIG_FILE); - memset(profileList[profileIndex].password, 0, MAX_PATH); - readStringValue(profilename, "password", - profileList[profileIndex].password, CONFIG_FILE); - profileList[profileIndex].auth = - readIntValue(profilename, "auth", CONFIG_FILE); - profileList[profileIndex].ipfamily = - readIntValue(profilename, "ipfamily", CONFIG_FILE); -//begin modified by zhangkaibo add sim pin operate. mantis 0049142 20200612 - memset(profileList[profileIndex].pin, 0, MAX_PATH); - readStringValue(profilename, "pin", profileList[profileIndex].pin, - CONFIG_FILE); -//end modified by zhangkaibo add sim pin operate. mantis 0049142 20200612 - } - FILE *fp; - fileIndex = 0; - char lineContent[LINE_CONTENT_MAX_LEN]; - fp = fopen(CONFIG_FILE, "r+"); - if (fp == NULL) { - printf("%s: Opent file %s failed.\n", __FILE__, CONFIG_FILE); - return -2; - } - // read all - while (feof(fp) == 0) { - memset(lineContent, 0, LINE_CONTENT_MAX_LEN); - fgets(lineContent, LINE_CONTENT_MAX_LEN, fp); - memcpy(fileContents[fileIndex], lineContent, strlen(lineContent)); - // printf("%s",fileContents[fileIndex]); - fileIndex++; - } - fclose(fp); - return 0; -} - -void saveConfigToIni() -{ - FILE *fp; - fp = fopen(CONFIG_FILE, "w"); - int fileIndextemp = 0; - fseek(fp, 0, SEEK_SET); - while (fileIndextemp <= fileIndex) { - fwrite(fileContents[fileIndextemp], strlen(fileContents[fileIndextemp]), - 1, fp); - // printf("%s",fileContents[fileIndextemp]); - fileIndextemp++; - } - fclose(fp); -} - -void modifyProfile(struct profile *profileList) -{ - int profileIndex; -//begin modified by zhangkaibo limit input parameters. mantis 0048965 20200605 - struct profile tempprofile; -//end modified by zhangkaibo limit input parameters. mantis 0048965 20200605 - char *f; - // show current fprfile setting - for (profileIndex = 0; profileIndex < 8; profileIndex++) { - dbg_time( - "Fibocom manager \nprofile%d apn:\"%s\" username:\"%s\" password: " - "\"%s\" auth: \"%d\" ip family: \"%d\"", - profileIndex + 1, profileList[profileIndex].apn, - profileList[profileIndex].user, profileList[profileIndex].password, - profileList[profileIndex].auth, profileList[profileIndex].ipfamily); - } - // select instance to be set - int connectProfile; - printf("set profile index:"); - f = malloc(sizeof(f)); - fgets(f,sizeof(f),stdin); - connectProfile = atoi(f); -//begin modified by zhangkaibo limit input parameters. mantis 0048965 20200605 - if(!IsInt(f)){ - dbg_time("invalid input"); - return; - } -//end modified by zhangkaibo limit input parameters. mantis 0048965 20200605 - if (connectProfile < 0 || connectProfile > 8) { - dbg_time("error profile id"); - return; - } - free(f); - /* - * Begin: 2020-11-16, Lizhengyang for multi-pdn-manager, - * Solve the problem of setting length - * of apn/username/password, mantis 0062495. - */ - printf("profile apn:"); - f = malloc(MAX_PATH); - if (f == NULL) - { - printf("profile apn f malloc null\n"); - return; - } - fgets(f, MAX_PATH, stdin); - f[strlen(f) - 1] = '\0'; - strcpy(tempprofile.apn, f); - free(f); - - printf("profile username:"); - f = malloc(MAX_PATH); - if (f == NULL) - { - printf("profile username f malloc null\n"); - return; - } - fgets(f, MAX_PATH, stdin); - f[strlen(f) - 1] = '\0'; - strcpy(tempprofile.user, f); - free(f); - - printf("profile password:"); - f = malloc(MAX_PATH); - if (f == NULL) - { - printf("profile password f malloc null\n"); - return; - } - fgets(f, MAX_PATH, stdin); - f[strlen(f) - 1] = '\0'; - strcpy(tempprofile.password, f); - free(f); - /* - * End: 2020-11-16, Lizhengyang for multi-pdn-manager, - * Solve the problem of setting length - * of apn/username/password, mantis 0062495. - */ - printf("profile auth[0-3]:"); - f = malloc(sizeof(f)); - fgets(f,sizeof(f),stdin); -//begin modified by zhangkaibo limit input parameters. mantis 0048965 20200605 - tempprofile.auth = atoi(f); - if(!IsInt(f)){ - dbg_time("invalid input"); - return; - } - if(tempprofile.auth < 0 || tempprofile.auth > 3){ - dbg_time("invalid auth type"); - return; - } -//end modified by zhangkaibo limit input parameters. mantis 0048965 20200605 - free(f); - - printf("profile ipfamily[1-3]:"); - f = malloc(sizeof(f)); - fgets(f,sizeof(f),stdin); -//begin modified by zhangkaibo limit input parameters. mantis 0048965 20200605 - tempprofile.ipfamily = atoi(f); - if(!IsInt(f)){ - dbg_time("invalid input"); - return; - } - free(f); - if(tempprofile.ipfamily < 1 || tempprofile.ipfamily > 3){ - dbg_time("invalid auth type"); - return; - } -//begin modified by zhangkaibo add sim pin operate. mantis 0049142 20200612 - printf("pin:"); - f = malloc(sizeof(f)); - fgets(f,sizeof(f),stdin); - f[strlen(f)-1]='\0'; - strcpy(tempprofile.pin, f); - free(f); -//end modified by zhangkaibo add sim pin operate. mantis 0049142 20200612 - memset(profileList[connectProfile-1].apn, 0, MAX_PATH); - memset(profileList[connectProfile-1].user, 0, MAX_PATH); - memset(profileList[connectProfile-1].password, 0, MAX_PATH); - - strcpy(profileList[connectProfile-1].apn , tempprofile.apn); - strcpy(profileList[connectProfile-1].user , tempprofile.user); - strcpy(profileList[connectProfile-1].password , tempprofile.password); - profileList[connectProfile-1].auth = tempprofile.auth; - profileList[connectProfile-1].ipfamily = tempprofile.ipfamily; -//end modified by zhangkaibo limit input parameters. mantis 0048965 20200605 -//begin modified by zhangkaibo add sim pin operate. mantis 0049142 20200612 - //strcpy(profileList[connectProfile].pin , tempprofile.pin); - strcpy(profileList[connectProfile-1].pin , tempprofile.pin); -//end modified by zhangkaibo add sim pin operate. mantis 0049142 20200612 - // save in - for (profileIndex = 0; profileIndex < qmap_num; profileIndex++) { - dbg_time( - "Fibocom manager \nprofile%d apn:\"%s\" username:\"%s\" pawssword: " - "\"%s\" auth: \"%d\" ip family: \"%d\"", - profileIndex + 1, profileList[profileIndex].apn, - profileList[profileIndex].user, profileList[profileIndex].password, - profileList[profileIndex].auth, profileList[profileIndex].ipfamily); - char profilename[MAX_PATH]; - sprintf(profilename, "profile%d", profileIndex + 1); - writeStringVlaue(profilename, "apn", profileList[profileIndex].apn, - CONFIG_FILE); - writeStringVlaue(profilename, "user", profileList[profileIndex].user, - CONFIG_FILE); - writeStringVlaue(profilename, "password", - profileList[profileIndex].password, CONFIG_FILE); - writeIntValue(profilename, "auth", profileList[profileIndex].auth, - CONFIG_FILE); - writeIntValue(profilename, "ipfamily", - profileList[profileIndex].ipfamily, CONFIG_FILE); -//begin modified by zhangkaibo add sim pin operate. mantis 0049142 20200612 - writeStringVlaue(profilename, "pin", - profileList[profileIndex].pin, CONFIG_FILE); -//end modified by zhangkaibo add sim pin operate. mantis 0049142 20200612 - } -} - -void startConnectCM(struct profile *profileList, bool *connectState) -{ - int connectIndex; - int connectProfile; - char *f; - printf("connect visual net interface use:"); - f = malloc(sizeof(f)); - fgets(f,sizeof(f),stdin); - connectIndex = atoi(f); - free(f); - if (connectIndex < 1 || connectIndex > qmap_num) { - dbg_time("error visual net interface "); - return; - } - printf("connect profile use:"); - f = malloc(sizeof(f)); - fgets(f,sizeof(f),stdin); - connectProfile = atoi(f); - free(f); - if (connectProfile < 1 || connectProfile > 8) { - dbg_time("error profile id"); - return; - } -//begin modified by zhangkaibo modify mantis0048806. 20200605 - if (connectState[connectIndex - 1] == true) { - dbg_time( - "visual net interface %d now is connected", - connectIndex); - return; - } -//end modified by zhangkaibo modify mantis0048806. 20200605 - dbg_time("Start connect network use instance %d profile %d", connectIndex, - connectProfile); - char cmd[1024]; - //./fibicom-dial -n -s -s apn user password auth -4 -6 - - sprintf(cmd, "-n %d -m %d -s %s %s %s %d", connectIndex, connectProfile, - profileList[connectProfile - 1].apn, - profileList[connectProfile - 1].user, - profileList[connectProfile - 1].password, - profileList[connectProfile - 1].auth); - char *argvCmd[30]; - int index = 0; - // DIAL_PROCESS,","-N","4,""-n","2","-m","1","-s","ctnet","","","","-4","-6","-f","temp.txt",NULL; - argvCmd[index] = malloc(256); - sprintf(argvCmd[index++], "%s", DIAL_PROCESS); - argvCmd[index] = malloc(5); - sprintf(argvCmd[index++], "-N"); - argvCmd[index] = malloc(256); - sprintf(argvCmd[index++], "%d", qmap_num); - argvCmd[index] = malloc(5); - sprintf(argvCmd[index++], "-n"); - argvCmd[index] = malloc(256); - sprintf(argvCmd[index++], "%d", connectIndex); - argvCmd[index] = malloc(5); - sprintf(argvCmd[index++], "-m"); - argvCmd[index] = malloc(256); - sprintf(argvCmd[index++], "%d", connectProfile); - argvCmd[index] = malloc(5); - sprintf(argvCmd[index++], "-s"); - argvCmd[index] = malloc(256); - sprintf(argvCmd[index++], "%s", profileList[connectProfile - 1].apn); - if (strlen(profileList[connectProfile - 1].user) > 0) { - argvCmd[index] = malloc(256); - sprintf(argvCmd[index++], "%s", profileList[connectProfile - 1].user); - argvCmd[index] = malloc(256); - sprintf(argvCmd[index++], "%s", - profileList[connectProfile - 1].password); - argvCmd[index] = malloc(256); - sprintf(argvCmd[index++], "%d", profileList[connectProfile - 1].auth); - } - - if (profileList[connectProfile - 1].ipfamily == 2) { - argvCmd[index] = malloc(5); -//begin modified by zhangkaibo fix ipv6 dial process flow. mantis 0048789 20200605 - sprintf(argvCmd[index++], "-6"); -//end modified by zhangkaibo fix ipv6 dial process flow. mantis 0048789 20200605 - } else if (profileList[connectProfile - 1].ipfamily == 3) { - argvCmd[index] = malloc(5); - sprintf(argvCmd[index++], "-4"); - argvCmd[index] = malloc(5); - sprintf(argvCmd[index++], "-6"); - } else { - argvCmd[index] = malloc(5); - sprintf(argvCmd[index++], "-4"); - } -//begin modified by zhangkaibo add sim pin operate. mantis 0049142 20200612 - if (strlen(profileList[connectProfile - 1].pin) > 0) { - argvCmd[index] = malloc(5); - sprintf(argvCmd[index++], "-p"); - argvCmd[index] = malloc(256); - sprintf(argvCmd[index++], "%s", profileList[connectProfile - 1].pin); - } - - argvCmd[index] = malloc(5); -//end modified by zhangkaibo add sim pin operate. mantis 0049142 20200612 - sprintf(argvCmd[index++], "-f"); - argvCmd[index] = malloc(256); - sprintf(argvCmd[index++], "instance%d.txt", connectIndex); - argvCmd[index] = NULL; - char temp[MAX_PATH]; - sprintf(temp, "rm -f instance%d.txt", connectIndex); - system(temp); - if (0 == fork()) { - int *connectPids = (int *)shm; - connectPids[connectIndex - 1] = getpid(); - dbg_time("exec pid %d", connectPids[connectIndex - 1]); - char tempcmd[MAX_PATH]; - sprintf(tempcmd, "./%s", DIAL_PROCESS); - execvp(tempcmd, argvCmd); - // system(cmd); -//begin modified by zhangkaibo add sim pin operate. mantis 0049142 20200612 - } -//2021-02-01 willa.liu@fibocom.com changed begin for support mantis 0069837 - //for(int ii=0; ii < index;ii++) - int ii; - for(ii = 0;ii < index;ii++) -//2021-02-01 willa.liu@fibocom.com changed end for support mantis 0069837 - { - printf("%s ",argvCmd[ii]); - free(argvCmd[ii]); - } - printf("\r\n"); - connectState[connectIndex - 1] = true; -} - -int main(int argc, char *argv[]) -{ - struct profile profileList[MAX_QMAP_NUM]; - char *f; - int profileIndex; - int opsCode = -1; - int ret=0; - - /* Exit if the process is already running */ - lock_file = open("/tmp/single_proc.lock", O_CREAT|O_RDWR, 0666); - ret = flock(lock_file, LOCK_EX|LOCK_NB); - if (ret) - { - if (EWOULDBLOCK == errno) - { - dbg_time("The Fibocom multi-pdn-manager is already running! So killall multi-pdn-manager!"); - system("killall -9 fibocom-dial"); - system("killall -9 multi-pdn-manager"); - } - } - else - { - char buffer[64]; - sprintf(buffer, "pid:%d\n", getpid()); - write(lock_file, buffer, strlen(buffer)); - system("killall -9 fibocom-dial"); - dbg_time("Start Fibocom multi-pdn-manager!\n"); - } - - system("clear"); - - get_pcie_mode(); - - signal(SIGCHLD, SIG_IGN); - - // read from config - ret = loadConfigFromIni(profileList, connectState); - if(ret == -1) - { - dbg_time("Fibocom multi-pdn-manager %s", VERSION_STRING()); - dbg_time("Fibocom manager current qmap_num is %d,not support multi-pdn", qmap_num); - dbg_time("please use \"echo 4 > /sys/class/net/usb0/qmap_num\",set driver to multi mode"); - return -1; - } - if(ret == -2) - return -2; - initShareMemory(); - signal(SIGINT, SIGINT_handle); - if (is_pcie_dial()) - { - dbg_time("start qmi proxy server"); - //system("./fibo_qmimsg_server -d /dev/mhi_QMI0 &"); - } - while (1) - { - // show tips - dbg_time("Fibocom multi-pdn-manager %s", VERSION_STRING()); - dbg_time("Fibocom manager current qmap_num is %d", qmap_num); - for (profileIndex = 0; profileIndex < qmap_num; profileIndex++) - { - dbg_time("Fibocom manager sub-instance%d %s", profileIndex + 1, - connectState[profileIndex] ? "Connected" : "Disconnected"); - } - printf("Please select an action[0-9]\n"); - printf("1.show profile setting\n"); - printf("2.set profile setting\n"); - printf("3.connect to network\n"); - printf("4.disconnect to network\n"); - printf("5.show connect log\n"); - printf("6.reload profile setting\n"); - printf("7.save profile setting\n"); - printf("8.show max instance number\n"); - printf("9.set max instance number\n"); - printf("0.exit\n"); - - // get operate - printf("input [0-9]: "); - f = malloc(sizeof(f)); - //begin modified by zhangkaibo limit input parameters. mantis 0048965 20200605 - fgets(f,sizeof(f),stdin); - if(!IsInt(f)) - { - dbg_time("invalid input"); - printf("Press any key to continus"); - getchar(); - system("clear"); - continue; - } - //end modified by zhangkaibo limit input parameters. mantis 0048965 20200605 - opsCode = atoi(f); - free(f); - - // select operate - switch (opsCode) - { - case 1: - //begin modified by zhangkaibo add sim pin operate. mantis 0049142 20200612 - for (profileIndex = 0; profileIndex < qmap_num; profileIndex++) - { - dbg_time( - "Fibocom manager \nprofile%d apn:\"%s\" username:\"%s\" " - "password: \"%s\" auth: \"%d\" ip family: \"%d\" pin:\"%s\"", - profileIndex + 1, profileList[profileIndex].apn, - profileList[profileIndex].user, - profileList[profileIndex].password, - profileList[profileIndex].auth, - profileList[profileIndex].ipfamily, - profileList[profileIndex].pin); - } - //end modified by zhangkaibo add sim pin operate. mantis 0049142 20200612 - break; - case 2: - { - modifyProfile(profileList); - } - break; - case 3: - { - startConnectCM(profileList, connectState); - break; - } - case 4: - { - int connectIndex; - printf("disconnect visual net interface :"); - f = malloc(sizeof(f)); - fgets(f,sizeof(f),stdin); - connectIndex = atoi(f); - free(f); - int *connectPids = (int *)shm; - if (connectIndex < 1 || connectIndex > qmap_num) - { - dbg_time("error visual net interface id"); - break; - } - if (connectState[connectIndex - 1] == false) - { - dbg_time("visual net interface %d now is disconnected", connectIndex); - break; - } - dbg_time("kill pid %d", connectPids[connectIndex - 1]); - kill(connectPids[connectIndex - 1], SIGINT); - connectState[connectIndex - 1] = false; - } - break; - case 5: - { - int connectIndex; - printf("show visual net interface :"); - f = malloc(sizeof(f)); - fgets(f,sizeof(f),stdin); - connectIndex = atoi(f); - free(f); - if (connectIndex < 1 || connectIndex > qmap_num) - { - dbg_time("error visual net interface id"); - break; - } - char temp[MAX_PATH]; - sprintf(temp, "cat instance%d.txt", connectIndex); - system(temp); - } - break; - case 6: - { - loadConfigFromIni(profileList, connectState); - } - break; - case 7: - { - saveConfigToIni(profileList); - } - break; - case 8: - printf("qmap_num : %d", qmap_num); - break; - case 9: - { - int temp_qmap; - printf("set qmap_num :"); - f = malloc(sizeof(f)); - fgets(f,sizeof(f),stdin); - temp_qmap = atoi(f); - free(f); - if (temp_qmap < 1 || temp_qmap > 8) - { - dbg_time("error qmap_num id"); - break; - } - qmap_num = temp_qmap; - } - break; - case 0: - printf("exit? [Y/N] :"); - f = malloc(sizeof(f)); - fgets(f,sizeof(f),stdin); - if (f[0] == 'y' || f[0] == 'Y') - goto __main_exit; - break; - default: - dbg_time("invalid input"); - }; - printf("Press any key to continus"); - getchar(); - system("clear"); - } -__main_exit: - { - int *connectPids = (int *)shm; - int cIndex; - for(cIndex = 1 ; cIndex <= qmap_num ; cIndex++) - { - dbg_time("kill pid %d", connectPids[cIndex - 1]); - kill(connectPids[cIndex - 1], SIGINT); - connectState[cIndex - 1] = false; - } - //system("ps -ef|grep fibo|grep -v grep|cut -c 9-15|xargs kill"); - } - destoryShareMemory(); - close(lock_file); // 不要忘记释放文件指针 - return 0; -} diff --git a/fibocom-dial/src/multi-pdn.ini b/fibocom-dial/src/multi-pdn.ini deleted file mode 100644 index 182a7ef..0000000 --- a/fibocom-dial/src/multi-pdn.ini +++ /dev/null @@ -1,67 +0,0 @@ -[Setting] -qmap_num=4 - -[profile1] -apn=1234567890 -user=qwertyuio -password=asdfghjkl -auth=2 -ipfamily=1 -pin= - -[profile2] -apn=ctnet -user= -password= -auth=0 -ipfamily=1 -pin= - -[profile3] -apn=ctnet -user= -password= -auth=0 -ipfamily=1 -pin= - -[profile4] -apn=ctnet -user= -password= -auth=0 -ipfamily=1 -pin= - -[profile5] -apn=ctnet -user= -password= -auth= -ipfamily=1 -pin= - -[profile6] -apn=ctnet -user= -password= -auth= -ipfamily=1 -pin= - -[profile7] -apn=ctnet -user= -password= -auth= -ipfamily=1 -pin= - -[profile8] -apn=ctnet -user= -password= -auth= -ipfamily=1 -pin= - diff --git a/fibocom-dial/src/qmap_bridge_mode.c b/fibocom-dial/src/qmap_bridge_mode.c deleted file mode 100644 index cabf76d..0000000 --- a/fibocom-dial/src/qmap_bridge_mode.c +++ /dev/null @@ -1,438 +0,0 @@ -#include "QMIThread.h" -//2021-03-15 zhangkaibo@fibocom.com changed begin for oa 20210311037 -#include -//2021-03-15 zhangkaibo@fibocom.com changed end for oa 20210311037 - -static size_t fibo_fread(const char *filename, void *buf, size_t size) -{ - FILE *fp = fopen(filename, "r"); - size_t n = 0; - - memset(buf, 0x00, size); - - if (fp) { - n = fread(buf, 1, size, fp); - if (n <= 0 || n == size) { - dbg_time( - "warnning: fail to fread(%s), fread=%zd, buf_size=%zd, " - "errno: %d (%s)", - __func__, filename, n, size, errno, strerror(errno)); - } - fclose(fp); - } - - return n > 0 ? n : 0; -} - -static size_t fibo_fwrite(const char *filename, const void *buf, size_t size) -{ - FILE *fp = fopen(filename, "w"); - size_t n = 0; - - if (fp) { - n = fwrite(buf, 1, size, fp); - if (n != size) { - dbg_time( - "warnning: fail to fwrite(%s), fwrite=%zd, buf_size=%zd, " - "errno: %d (%s)", - __func__, filename, n, size, errno, strerror(errno)); - } - fclose(fp); - } - - return n > 0 ? n : 0; -} - -static int fibo_iface_is_in_bridge(const char *iface) -{ - char filename[256]; - - snprintf(filename, sizeof(filename), "/sys/class/net/%s/brport", iface); - return (access(filename, F_OK) == 0 || errno != ENOENT); -} - -int fibo_bridge_mode_detect(PROFILE_T *profile) -{ - const char *ifname = profile->qmapnet_adapter ? profile->qmapnet_adapter - : profile->usbnet_adapter; - const char *driver; - char bridge_mode[128]; - char bridge_ipv4[128]; - char ipv4[128]; - char buf[64]; - size_t n; - int in_bridge; - - driver = profile->driver_name; - snprintf(bridge_mode, sizeof(bridge_mode), "/sys/class/net/%s/bridge_mode", - ifname); - snprintf(bridge_ipv4, sizeof(bridge_ipv4), "/sys/class/net/%s/bridge_ipv4", - ifname); - - if (access(bridge_mode, F_OK) && errno == ENOENT) { - snprintf(bridge_mode, sizeof(bridge_mode), - "/sys/module/%s/parameters/bridge_mode", driver); - snprintf(bridge_ipv4, sizeof(bridge_ipv4), - "/sys/module/%s/parameters/bridge_ipv4", driver); - - if (access(bridge_mode, F_OK) && errno == ENOENT) { - bridge_mode[0] = '\0'; - } - } - - in_bridge = fibo_iface_is_in_bridge(ifname); - if (in_bridge) { - dbg_time("notice: iface %s had add to bridge\n", ifname); - } - - if (in_bridge && bridge_mode[0] == '\0') { - dbg_time("warnning: can not find bride_mode file for %s\n", ifname); - return 1; - } - - n = fibo_fread(bridge_mode, buf, sizeof(buf)); - - if (in_bridge) { - if (n <= 0 || buf[0] == '0') { - dbg_time("warnning: should set 1 to bride_mode file for %s\n", - ifname); - return 1; - } - } else { - if (n <= 0 || buf[0] == '0') { - return 0; - } - } - - memset(ipv4, 0, sizeof(ipv4)); - - if (strstr(bridge_ipv4, "/sys/class/net/") || profile->qmap_mode == 0 || - profile->qmap_mode == 1) { - snprintf(ipv4, sizeof(ipv4), "0x%x", profile->ipv4.Address); - dbg_time("echo '%s' > %s", ipv4, bridge_ipv4); - fibo_fwrite(bridge_ipv4, ipv4, strlen(ipv4)); - } else { - snprintf(ipv4, sizeof(ipv4), "0x%x:%d", profile->ipv4.Address, - profile->muxid); - dbg_time("echo '%s' > %s", ipv4, bridge_ipv4); - fibo_fwrite(bridge_ipv4, ipv4, strlen(ipv4)); - } - - return 1; -} -//2021-03-15 zhangkaibo@fibocom.com changed begin for oa 20210311037 -void fibo_get_driver_info(PROFILE_T *profile, RMNET_INFO *rmnet_info) { - int ifc_ctl_sock; - struct ifreq ifr; - int rc; - int request = 0x89F3; - unsigned char data[512]; - - memset(rmnet_info, 0x00, sizeof(*rmnet_info)); - - ifc_ctl_sock = socket(AF_INET, SOCK_DGRAM, 0); - if (ifc_ctl_sock <= 0) { - dbg_time("socket() failed: %s\n", strerror(errno)); - return; - } - - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_name, profile->usbnet_adapter, IFNAMSIZ); - ifr.ifr_name[IFNAMSIZ - 1] = 0; - ifr.ifr_ifru.ifru_data = (void *)data; - rc = ioctl(ifc_ctl_sock, request, &ifr); - if (rc < 0) { - dbg_time("ioctl(0x%x, qmap_settings) failed: %s, rc=%d", request, strerror(errno), rc); - } - else { - memcpy(rmnet_info, data, sizeof(*rmnet_info)); - } - - close(ifc_ctl_sock); -} -//2021-03-15 zhangkaibo@fibocom.com changed end for oa 20210311037 -int fibo_qmap_mode_detect(PROFILE_T *profile) -{ - int n; - char buf[128]; - char qmap_netcard[128]; - struct { - char filename[255 * 2]; - char linkname[255 * 2]; - } * pl; - - pl = (typeof(pl))malloc(sizeof(*pl)); - - snprintf(pl->linkname, sizeof(pl->linkname), - "/sys/class/net/%s/device/driver", profile->usbnet_adapter); - n = readlink(pl->linkname, pl->filename, sizeof(pl->filename)); - pl->filename[n] = '\0'; - while (pl->filename[n] != '/') n--; - profile->driver_name = strdup(&pl->filename[n + 1]); - -//2021-03-15 zhangkaibo@fibocom.com changed begin for oa 20210311037 - fibo_get_driver_info(profile, &profile->rmnet_info); - if (profile->rmnet_info.size) { - profile->qmap_mode = profile->rmnet_info.qmap_mode; - if (profile->qmap_mode) { - int offset_id = profile->pdp - 1; - - if (profile->qmap_mode == 1) - offset_id = 0; - profile->muxid = profile->rmnet_info.mux_id[offset_id]; - profile->qmapnet_adapter = strdup( profile->rmnet_info.ifname[offset_id]); - profile->qmap_size = profile->rmnet_info.rx_urb_size; - profile->qmap_version = profile->rmnet_info.qmap_version; - } - - goto _out; - } -//2021-03-15 zhangkaibo@fibocom.com changed end for oa 20210311037 - - if (qmidev_is_pciemhi(profile->qmichannel)) { - profile->qmap_mode = 1; - - if (profile->muxid == 0 || profile->muxid == 0x81) - { - profile->muxid = 0x81; - } - else - { - if (profile->muxid < 0x80) - profile->muxid += 0x81; - profile->qmap_mode = 2; - } - - profile->qmapnet_adapter = strdup(profile->usbnet_adapter); - goto _final_process; - } - - snprintf(pl->filename, sizeof(pl->filename), "/sys/class/net/%s/qmap_num", - profile->usbnet_adapter); - -//2021-01-27 willa.liu@fibocom.com changed begin for support mantis 0068849 - if (access(pl->filename, F_OK) == 0) { - dbg_time("access %s", pl->filename); - if (errno != ENOENT) { - dbg_time("fail to access %s, errno: %d (%s)", pl->filename, errno, - strerror(errno)); - goto _out; - } -//2021-02-01 willa.liu@fibocom.com changed begin for support mantis 0069837 -/* - snprintf(pl->filename, sizeof(pl->filename), - "/sys/module/%s/parameters/qmap_num", profile->driver_name); - if (access(pl->filename, R_OK)) { - if (errno != ENOENT) { - dbg_time("fail to access %s, errno: %d (%s)", pl->filename, - errno, strerror(errno)); - goto _out; - } - - snprintf( - pl->filename, sizeof(pl->filename), - "/sys/class/net/%s/device/driver/module/parameters/qmap_num", - profile->usbnet_adapter); - if (access(pl->filename, R_OK)) { - if (errno != ENOENT) { - dbg_time("fail to access %s, errno: %d (%s)", pl->filename, - errno, strerror(errno)); - goto _out; - } - } - } -*/ -//2021-02-01 willa.liu@fibocom.com changed end for support mantis 0069837 - } - else - { - snprintf(pl->filename, sizeof(pl->filename), "/sys/class/net/%s/qmap_mode", - profile->usbnet_adapter); - - if (access(pl->filename, F_OK) == 0) { - dbg_time("access %s", pl->filename); - if (errno != ENOENT) { - dbg_time("fail to access %s, errno: %d (%s)", pl->filename, errno, - strerror(errno)); - goto _out; - } - } - } - - if(!access(pl->filename, R_OK)) - { - n = fibo_fread(pl->filename, buf, sizeof(buf)); - if(n > 0) - { - profile->qmap_mode = atoi(buf); - if(profile->qmap_mode >= 1 && qmidev_is_pciemhi(profile->qmichannel)) - { - profile->muxid = - profile->pdp + 0x80; - sprintf(qmap_netcard, "%s.%d", profile->usbnet_adapter,profile->pdp); - profile->qmapnet_adapter = strdup(qmap_netcard); - } - if(qmidev_is_gobinet(profile->qmichannel) || qmidev_is_qmiwwan(profile->qmichannel)) - { - if(profile->qmap_mode > 1) - { - profile->muxid = - profile->pdp + 0x80; - sprintf(qmap_netcard, "%s.%d", profile->usbnet_adapter,profile->pdp); - profile->qmapnet_adapter = strdup(qmap_netcard); - } - if(profile->qmap_mode == 1) - { - profile->muxid = 0x81; - profile->qmapnet_adapter = strdup(profile->usbnet_adapter); - } - } - } - - - if (0) { - profile->qmap_mode = atoi(buf); - - if (profile->qmap_mode > 1 && qmidev_is_gobinet(profile->qmichannel)) { - profile->muxid = - profile->pdp + 0x80; // muxis is 0x8X for PDN-X - sprintf(qmap_netcard, "%s.%d", profile->usbnet_adapter,profile->pdp); - profile->qmapnet_adapter = strdup(qmap_netcard); - } - if (profile->qmap_mode >= 1 && !qmidev_is_gobinet(profile->qmichannel)) { - profile->muxid = - profile->pdp + 0x80; // muxis is 0x8X for PDN-X - sprintf(qmap_netcard, "%s.%d", profile->usbnet_adapter,profile->pdp); - profile->qmapnet_adapter = strdup(qmap_netcard); - } - if (profile->qmap_mode == 1 && qmidev_is_gobinet(profile->qmichannel)) { - profile->muxid = 0x81; - profile->qmapnet_adapter = strdup(profile->usbnet_adapter); -//2021-01-27 willa.liu@fibocom.com changed end for support mantis 0068849 - - } - } - } else if (qmidev_is_qmiwwan(profile->qmichannel)) { - snprintf(pl->filename, sizeof(pl->filename), "/sys/class/net/qmimux%d", - profile->pdp - 1); - if (access(pl->filename, R_OK)) { - if (errno != ENOENT) { - dbg_time("fail to access %s, errno: %d (%s)", pl->filename, - errno, strerror(errno)); - } - goto _out; - } - - // upstream Kernel Style QMAP qmi_wwan.c - snprintf(pl->filename, sizeof(pl->filename), - "/sys/class/net/%s/qmi/add_mux", profile->usbnet_adapter); - n = fibo_fread(pl->filename, buf, sizeof(buf)); - if (n >= 5) { - profile->qmap_mode = n / 5; // 0x81\n0x82\n0x83\n - if (profile->qmap_mode > 1) { - // PDN-X map to qmimux-X - profile->muxid = (buf[5 * (profile->pdp - 1) + 2] - '0') * 16 + - (buf[5 * (profile->pdp - 1) + 3] - '0'); - sprintf(qmap_netcard, "qmimux%d", profile->pdp - 1); - profile->qmapnet_adapter = strdup(qmap_netcard); - } else if (profile->qmap_mode == 1) { - profile->muxid = - (buf[5 * 0 + 2] - '0') * 16 + (buf[5 * 0 + 3] - '0'); - sprintf(qmap_netcard, "qmimux%d", 0); - profile->qmapnet_adapter = strdup(qmap_netcard); - } - } - } - -_out: - if (profile->qmap_mode) { - profile->qmap_size = 16 * 1024; - snprintf(pl->filename, sizeof(pl->filename), - "/sys/class/net/%s/qmap_size", profile->usbnet_adapter); - if (!access(pl->filename, R_OK)) { - size_t n; - char buf[32]; - n = fibo_fread(pl->filename, buf, sizeof(buf)); - if (n > 0) { - profile->qmap_size = atoi(buf); - } - } - } - -_final_process: - if (profile->qmap_mode) - dbg_time("qmap_mode = %d, muxid = 0x%02x, qmap_netcard = %s", - profile->qmap_mode, profile->muxid, profile->qmapnet_adapter); - - free(pl); - - return 0; -} - -int fibo_qmap_mode_set(PROFILE_T *profile) -{ - int n; - char buf[128]; - struct { - char filename[255 * 2]; - char linkname[255 * 2]; - } * pl; - - if (qmidev_is_pciemhi(profile->qmichannel)) - { - dbg_time("pcie mode exit fibo_qmap_mode_set "); - return 0; - } - - pl = (typeof(pl))malloc(sizeof(*pl)); - - snprintf(pl->linkname, sizeof(pl->linkname), - "/sys/class/net/%s/device/driver", profile->usbnet_adapter); - n = readlink(pl->linkname, pl->filename, sizeof(pl->filename)); - pl->filename[n] = '\0'; - while (pl->filename[n] != '/') n--; - profile->driver_name = strdup(&pl->filename[n + 1]); - - snprintf(pl->filename, sizeof(pl->filename), "/sys/class/net/%s/qmap_num", - profile->usbnet_adapter); - if (access(pl->filename, R_OK)) { - if (errno != ENOENT) { - dbg_time("fail to access %s, errno: %d (%s)", pl->filename, errno, - strerror(errno)); - goto _out; - } - - snprintf(pl->filename, sizeof(pl->filename), - "/sys/module/%s/parameters/qmap_mnum", profile->driver_name); - if (access(pl->filename, R_OK)) { - if (errno != ENOENT) { - dbg_time("fail to access %s, errno: %d (%s)", pl->filename, - errno, strerror(errno)); - goto _out; - } - - snprintf( - pl->filename, sizeof(pl->filename), - "/sys/class/net/%s/device/driver/module/parameters/qmap_num", - profile->usbnet_adapter); - if (access(pl->filename, R_OK)) { - if (errno != ENOENT) { - dbg_time("fail to access %s, errno: %d (%s)", pl->filename, - errno, strerror(errno)); - goto _out; - } - } - } - } - - if (!access(pl->filename, R_OK)) { - snprintf(buf, sizeof(buf), "%d", profile->pdpnum); - n = fibo_fwrite(pl->filename, buf, strlen(buf)); - } - -_out: - - free(pl); - - return 0; -} diff --git a/fibocom-dial/src/query_pcie_mode.c b/fibocom-dial/src/query_pcie_mode.c deleted file mode 100644 index de3451d..0000000 --- a/fibocom-dial/src/query_pcie_mode.c +++ /dev/null @@ -1,160 +0,0 @@ -//2021-03-24 willa.liu@fibocom.com changed begin for support mantis 0071817 -#include "QMIThread.h" -#include "query_pcie_mode.h" -int speed_arr[] = { B115200, B19200, B9600, B4800, B2400, B1200, B300,// - B38400, B19200, B9600, B4800, B2400, B1200, B300, - }; -int name_arr[] = {115200, 19200, 9600, 4800, 2400, 1200, 300, - 38400, 19200, 9600, 4800, 2400, 1200, 300, - }; - -int get_pcie_mode_debug = 0; - -//2021-02-24 willa.liu@fibocom.com changed begin for support eipd SN-20210129001 -int get_private_gateway_debug = 1; -//2021-02-24 willa.liu@fibocom.com changed end for support eipd SN-20210129001 - -//static int xset1(int fd, struct termios *tio, const char *device) -int xset1(int fd, struct termios *tio, const char *device) -{ - int ret = tcsetattr(fd, TCSAFLUSH, tio); - - if (ret) { - printf("can't tcsetattr for %s", device); - } - return ret; -} - -// set raw tty mode -//static void xget1(int fd, struct termios *t, struct termios *oldt) -void xget1(int fd, struct termios *t, struct termios *oldt) -{ - tcgetattr(fd, oldt); - *t = *oldt; - cfmakeraw(t); -// t->c_lflag &= ~(ISIG|ICANON|ECHO|IEXTEN); -// t->c_iflag &= ~(BRKINT|IXON|ICRNL); -// t->c_oflag &= ~(ONLCR); -// t->c_cc[VMIN] = 1; -// t->c_cc[VTIME] = 0; -} - -//static int get_pcie_mode() -int get_pcie_mode() -//2021-03-24 willa.liu@fibocom.com changed end for support mantis 0071817 -{ - int i; - int fd; - int ret; - char buffer[409600] = {0}; - int rate; - char* sendbuffer; - int totallen = 0; - fd_set readfds; - struct timeval timeout; - struct termios tio0, tiosfd, tio; - - int timeoutVal = 5; - - char *dev = "/dev/ttyUSB1"; //The port under Linux is operated by opening the device file - rate = 115200; - sendbuffer = "at+gtpcie=3"; - printf ( "dev: %s\nrate:%d\nsendbuffer:%s\n", dev,rate,sendbuffer); - - fd = open(dev, O_RDWR | O_NOCTTY | O_NONBLOCK); - if (fd < 0) - goto ERR; - fcntl(fd, F_SETFL, O_RDWR); - - // put device to "raw mode" - xget1(fd, &tio, &tiosfd); - // set device speed - for ( i = 0;i < sizeof ( speed_arr ) / sizeof ( int );i++ ) - { - if ( rate == name_arr[i] ) //Judge if the pass is equal to the pass - { - break; - } - } - - if(i >= sizeof ( speed_arr ) / sizeof ( int )) - { - printf("bound rate set failed\n"); - goto ERR; - } - - cfsetspeed(&tio, speed_arr[i]); - if (xset1(fd, &tio, dev)) - goto ERR; - - tcflush ( fd, TCIOFLUSH ); - - sprintf(buffer, "%s\r", sendbuffer); - ret = write ( fd, buffer, strlen(buffer) ); - if(ret < 0) - { - printf ( "write failed\n" ); - goto ERR; - } - if(get_pcie_mode_debug)printf("write %d\n", ret); - - FD_ZERO ( &readfds ); - FD_SET ( fd, &readfds ); - - while(1) - { - timeout.tv_sec = timeoutVal; - timeout.tv_usec = 0; - - ret = select ( fd+1, &readfds, ( fd_set * ) 0, ( fd_set * ) 0, &timeout ); - if(ret > 0) - { - ret = read ( fd, buffer+totallen, sizeof(buffer)-totallen-1 ); - if(ret < 0) - { - printf ( "read failed\n" ); - goto ERR; - } - - if(ret == 0) - { - goto ERR; - } - - totallen += ret; - buffer[totallen] = '\0'; - if(get_pcie_mode_debug)printf("read %d(%s)\n", ret, &buffer[totallen-ret]); - if(totallen == sizeof(buffer)-1) - break; - - if(strstr(buffer,"\nOK") || strstr(buffer,"\nERROR") - || strstr(buffer,"\n+CME ERROR:") || strstr(buffer,"\n+CMS ERROR:")) - { - if(get_pcie_mode_debug)printf("match OK/ERROR"); - if(get_pcie_mode_debug)printf("%s", buffer); - break; - } - - } - else - { - printf ( "select timeout\n" ); - goto ERR; - } - - } - - tcsetattr(fd, TCSAFLUSH, &tiosfd); - //printf("buffer:\n %s\n", buffer); - printf("%s\n", buffer); - if(strstr(buffer,"\nERROR") || strstr(buffer,"\n+CME ERROR:") || strstr(buffer,"\n+CMS ERROR:")) - goto ERR; - - close ( fd ); - return 0; - ERR: - if(fd > 0) - close(fd); - return -1; -} - diff --git a/fibocom-dial/src/query_pcie_mode.h b/fibocom-dial/src/query_pcie_mode.h deleted file mode 100644 index c6e9b9d..0000000 --- a/fibocom-dial/src/query_pcie_mode.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef __QUERY_PCIE_MODE__ -#define __QUERY_PCIE_MODE__ - -extern int speed_arr[14]; -extern int name_arr[14]; - -extern int get_pcie_mode_debug; - -extern int get_private_gateway_debug; - -extern int xset1(int fd, struct termios *tio, const char *device); - -// set raw tty mode -extern void xget1(int fd, struct termios *t, struct termios *oldt); -extern int get_pcie_mode(); - -#endif diff --git a/fibocom-dial/src/udhcpc.c b/fibocom-dial/src/udhcpc.c deleted file mode 100644 index 966614b..0000000 --- a/fibocom-dial/src/udhcpc.c +++ /dev/null @@ -1,289 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -#include "QMIThread.h" -#include "util.h" - -static int dibbler_client_alive = 0; - -static int fibo_system(const char *shell_cmd) -{ - int ret = 0; - dbg_time("%s", shell_cmd); - ret = system(shell_cmd); - if (ret) { - // dbg_time("Fail to system(\"%s\") = %d, errno: %d (%s)", shell_cmd, - // ret, errno, strerror(errno)); - } - return ret; -} - -static void fibo_set_mtu(const char *ifname, int ifru_mtu) -{ - int inet_sock; - struct ifreq ifr; - - inet_sock = socket(AF_INET, SOCK_DGRAM, 0); - - if (inet_sock > 0) { - strcpy(ifr.ifr_name, ifname); - - if (!ioctl(inet_sock, SIOCGIFMTU, &ifr)) { - if (ifr.ifr_ifru.ifru_mtu != ifru_mtu) { - dbg_time("change mtu %d -> %d", ifr.ifr_ifru.ifru_mtu, - ifru_mtu); - ifr.ifr_ifru.ifru_mtu = ifru_mtu; - ioctl(inet_sock, SIOCSIFMTU, &ifr); - } - } - - close(inet_sock); - } -} - -static void *udhcpc_thread_function(void *arg) -{ - FILE *udhcpc_fp; - char *udhcpc_cmd = (char *)arg; - - if (udhcpc_cmd == NULL) - return NULL; - - dbg_time("%s", udhcpc_cmd); - udhcpc_fp = popen(udhcpc_cmd, "r"); - free(udhcpc_cmd); - if (udhcpc_fp) { - char buf[0xff]; - - buf[sizeof(buf) - 1] = '\0'; - while ((fgets(buf, sizeof(buf) - 1, udhcpc_fp)) != NULL) { - if ((strlen(buf) > 1) && (buf[strlen(buf) - 1] == '\n')) - buf[strlen(buf) - 1] = '\0'; - dbg_time("%s", buf); - } - - pclose(udhcpc_fp); - } - - return NULL; -} - -void fibo_set_driver_link_state(PROFILE_T *profile, int link_state) -{ - char link_file[128]; - int fd; - int new_state = 0; - dbg_time("enter %s ", __func__); - - snprintf(link_file, sizeof(link_file), "/sys/class/net/%s/link_state", - profile->usbnet_adapter); - fd = open(link_file, O_RDWR | O_NONBLOCK | O_NOCTTY); - if (fd == -1) { - if (errno != ENOENT) - dbg_time("Fail to access %s, errno: %d (%s)", link_file, errno, - strerror(errno)); - return; - } - - if (profile->qmap_mode <= 1) - new_state = !!link_state; - else { - // 0x80 means link off this pdp - new_state = (link_state ? 0x00 : 0x80) + profile->pdp; - } - - snprintf(link_file, sizeof(link_file), "%d\n", new_state); - write(fd, link_file, sizeof(link_file)); - - if (link_state == 0 && profile->qmap_mode > 1) { - size_t rc; - - lseek(fd, 0, SEEK_SET); - rc = read(fd, link_file, sizeof(link_file)); - if (rc > 1 && (!strcasecmp(link_file, "0\n") || - !strcasecmp(link_file, "0x0\n"))) { - // snprintf(link_file, sizeof(link_file), "busybox ifconfig %s down", - // profile->usbnet_adapter); - // fibo_system(link_file); - } - } - - close(fd); -} - -int fibo_raw_ip_mode_check(const char *ifname) -{ - int fd; - char raw_ip[128]; - char shell_cmd[128]; - char mode[2] = "X"; - int mode_change = 0; - - snprintf(raw_ip, sizeof(raw_ip), "/sys/class/net/%s/qmi/raw_ip", ifname); - if (access(raw_ip, F_OK)) - return 0; - - fd = open(raw_ip, O_RDWR | O_NONBLOCK | O_NOCTTY); - if (fd < 0) { - dbg_time("%s %d fail to open(%s), errno:%d (%s)", __FILE__, __LINE__, - raw_ip, errno, strerror(errno)); - return 0; - } - - read(fd, mode, 2); - if (mode[0] == '0' || mode[0] == 'N') { - snprintf(shell_cmd, sizeof(shell_cmd), "busybox ifconfig %s down", ifname); - fibo_system(shell_cmd); - dbg_time("echo Y > /sys/class/net/%s/qmi/raw_ip", ifname); - mode[0] = 'Y'; - write(fd, mode, 2); - mode_change = 1; - snprintf(shell_cmd, sizeof(shell_cmd), "busybox ifconfig %s up", ifname); - fibo_system(shell_cmd); - } - - close(fd); - return mode_change; -} - -void udhcpc_start(PROFILE_T *profile) -{ - char *ifname = profile->usbnet_adapter; - char shell_cmd[128]; - - fibo_set_driver_link_state(profile, 1); - if (profile->qmapnet_adapter) { - ifname = profile->qmapnet_adapter; - } - dbg_time("1 %s", profile->qmichannel); - if (qmidev_is_qmiwwan(profile->qmichannel)) { - dbg_time("2 %s", ifname); - fibo_raw_ip_mode_check(ifname); - } - - if (profile->rawIP && profile->ipv4.Address && profile->ipv4.Mtu) { - fibo_set_mtu(ifname, (profile->ipv4.Mtu)); - } - - fibo_system("echo 1 > /sys/module/fibo_mhi/parameters/macaddr_check"); - -//begin modified by zhangkaibo fix ipv6 dial process flow. mantis 0048789 20200605 -// if (strcmp(ifname, profile->usbnet_adapter)) { -// snprintf(shell_cmd, sizeof(shell_cmd) - 1, "busybox ifconfig %s up", -// profile->usbnet_adapter); -// fibo_system(shell_cmd); -// } -//begin modified by zhangkaibo fix ipv6 dial process flow. mantis 0048789 20200605 - // For IPv6, down & up will send protocol packets, and that's needed. - if (profile->ipv6_flag) { - snprintf(shell_cmd, sizeof(shell_cmd) - 1, "busybox ifconfig %s down", ifname); - fibo_system(shell_cmd); - } - - snprintf(shell_cmd, sizeof(shell_cmd) - 1, "busybox ifconfig %s up", ifname); - fibo_system(shell_cmd); - - //begin modified by zhangming Added NOARP and Multilcast on flag bit commands. mantis 0050106 20200713 - snprintf(shell_cmd, sizeof(shell_cmd) - 1, "ip link set %s arp off multicast on", ifname); - fibo_system(shell_cmd); - //begin modified by zhangming Added NOARP and Multilcast on flag bit commands. mantis 0050106 20200713 - //Modified unicom dual stack dialing unsuccessful problem - - // for bridge mode, only one public IP, so do udhcpc manually - if (fibo_bridge_mode_detect(profile)) { - return; - } - - /* Do DHCP using busybox tools */ - { - char udhcpc_cmd[128]; - pthread_attr_t udhcpc_thread_attr; - pthread_t udhcpc_thread_id; - - pthread_attr_init(&udhcpc_thread_attr); - pthread_attr_setdetachstate(&udhcpc_thread_attr, - PTHREAD_CREATE_DETACHED); - - if (profile->ipv4.Address) { - if (access("/usr/share/udhcpc/default.script", X_OK)) { - dbg_time( - "Fail to access /usr/share/udhcpc/default.script, " - "errno: %d (%s)", - errno, strerror(errno)); - } - - //-f,--foreground Run in foreground - //-b,--background Background if lease is not obtained - //-n,--now Exit if lease is not obtained - //-q,--quit Exit after obtaining lease - //-t,--retries N Send up to N discover packets (default 3) - snprintf(udhcpc_cmd, sizeof(udhcpc_cmd), - "busybox udhcpc -f -n -q -t 5 -i %s", ifname); - - if (!access("/lib/netifd/dhcp.script", X_OK) && - !access("/sbin/ifup", X_OK) && - !access("/sbin/ifstatus", X_OK)) { - dbg_time("you are use OpenWrt?"); - dbg_time("should not calling udhcpc manually?"); - dbg_time("should modify /etc/config/network as below?"); - dbg_time("config interface wan"); - dbg_time("\toption ifname %s", ifname); - dbg_time("\toption proto dhcp"); - dbg_time( - "should use \"/sbin/ifstaus wan\" to check %s 's status?", - ifname); - } - - pthread_create(&udhcpc_thread_id, NULL, udhcpc_thread_function, - (void *)strdup(udhcpc_cmd)); - sleep(1); - } - - if (profile->ipv6.Address[0] && profile->ipv6.PrefixLengthIPAddr) { - // module do not support DHCPv6, only support 'Router Solicit' - // and it seem if enable /proc/sys/net/ipv6/conf/all/forwarding, - // Kernel do not send RS - const char *forward_file = "/proc/sys/net/ipv6/conf/all/forwarding"; - int forward_fd = open(forward_file, O_RDONLY); - if (forward_fd > 0) { - char forward_state[2]; - read(forward_fd, forward_state, 2); - if (forward_state[0] == '1') { - dbg_time( - "%s enabled, kernel maybe donot send 'Router Solicit'", - forward_file); - } - close(forward_fd); - } - } - } -} - -void udhcpc_stop(PROFILE_T *profile) -{ - char *ifname = profile->usbnet_adapter; - char shell_cmd[128]; - char reset_ip[128]; - dbg_time("enter %s ", __func__); - - if (profile->qmapnet_adapter) { - ifname = profile->qmapnet_adapter; - } - - if (dibbler_client_alive) { - system("killall dibbler-client"); - dibbler_client_alive = 0; - } - //snprintf(shell_cmd, sizeof(shell_cmd) - 1, "busybox ifconfig %s down", - // profile->usbnet_adapter); - //fibo_system(shell_cmd); - snprintf(shell_cmd, sizeof(shell_cmd) - 1, "busybox ifconfig %s down", ifname); - fibo_system(shell_cmd); - snprintf(reset_ip, sizeof(reset_ip) - 1, "busybox ifconfig %s 0.0.0.0", ifname); - fibo_system(reset_ip); -} diff --git a/fibocom-dial/src/udhcpc_netlink.c b/fibocom-dial/src/udhcpc_netlink.c deleted file mode 100644 index fddf166..0000000 --- a/fibocom-dial/src/udhcpc_netlink.c +++ /dev/null @@ -1,421 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -#include "libmnl/ifutils.h" -#include "libmnl/dhcp/dhcp.h" -#include "util.h" -#include "QMIThread.h" - -static int fibo_system(const char *shell_cmd) -{ - int ret = 0; - dbg_time("%s", shell_cmd); - ret = system(shell_cmd); - if (ret) { - // dbg_time("Fail to system(\"%s\") = %d, errno: %d (%s)", shell_cmd, - // ret, errno, strerror(errno)); - } - return ret; -} - -int fibo_raw_ip_mode_check(const char *ifname) -{ - int fd; - char raw_ip[128]; - char mode[2] = "X"; - int mode_change = 0; - - snprintf(raw_ip, sizeof(raw_ip), "/sys/class/net/%s/qmi/raw_ip", ifname); - if (access(raw_ip, F_OK)) - return 0; - - fd = open(raw_ip, O_RDWR | O_NONBLOCK | O_NOCTTY); - if (fd < 0) - { - dbg_time("%s %d fail to open(%s), errno:%d (%s)", __FILE__, __LINE__, raw_ip, errno, strerror(errno)); - return 0; - } - - read(fd, mode, 2); - if (mode[0] == '0' || mode[0] == 'N') - { - if_link_down(ifname); - dbg_time("echo Y > /sys/class/net/%s/qmi/raw_ip", ifname); - mode[0] = 'Y'; - write(fd, mode, 2); - mode_change = 1; - if_link_up(ifname); - } - - close(fd); - return mode_change; -} - -static void fibo_set_driver_link_state(PROFILE_T *profile, int link_state) -{ - char link_file[128]; - int fd; - int new_state = 0; - dbg_time("enter %s ", __func__); - - snprintf(link_file, sizeof(link_file), "/sys/class/net/%s/link_state", profile->usbnet_adapter); - fd = open(link_file, O_RDWR | O_NONBLOCK | O_NOCTTY); - if (fd == -1) - { - if (errno != ENOENT) - dbg_time("Fail to access %s, errno: %d (%s)", link_file, errno, strerror(errno)); - return; - } - - if (profile->qmap_mode <= 1) - new_state = !!link_state; - else - { - //0x80 means link off this pdp - new_state = (link_state ? 0x00 : 0x80) + profile->pdp; - } - - snprintf(link_file, sizeof(link_file), "%d\n", new_state); - write(fd, link_file, sizeof(link_file)); - - if (link_state == 0 && profile->qmap_mode > 1) - { - size_t rc; - - lseek(fd, 0, SEEK_SET); - rc = read(fd, link_file, sizeof(link_file)); - if (rc > 1 && (!strcasecmp(link_file, "0\n") || !strcasecmp(link_file, "0x0\n"))) - { - // if_link_down(profile->usbnet_adapter); - } - } - - close(fd); -} - -void udhcpc_start(PROFILE_T *profile) -{ -//2021-02-01 willa.liu@fibocom.com changed begin for support mantis 0069837 - char *ifname = profile->usbnet_adapter; - char shell_cmd[512]; - - fibo_set_driver_link_state(profile, 1); - fibo_raw_ip_mode_check(ifname); - - if (profile->qmapnet_adapter) - { - ifname = profile->qmapnet_adapter; - } - if (profile->rawIP && profile->ipv4.Address && profile->ipv4.Mtu) - { - if_set_mtu(ifname, (profile->ipv4.Mtu)); - } - - if (strcmp(ifname, profile->usbnet_adapter)) - { - //if_link_up(profile->usbnet_adapter); - snprintf(shell_cmd, sizeof(shell_cmd) - 1, "ifconfig %s up", profile->usbnet_adapter); - fibo_system(shell_cmd); - } -//2021-02-01 willa.liu@fibocom.com changed begin for support mantis 0069837 - if_link_up(ifname); - -#if 1 //for bridge mode, only one public IP, so do udhcpc manually - if (fibo_bridge_mode_detect(profile)) - { - return; - } -#endif - // if use DHCP(should make with ${DHCP} src files) - // do_dhcp(ifname); - // return 0; - /* IPv4 Addr Info */ - if (profile->ipv4.Address) - { - dbg_time("IPv4 MTU: %d", profile->ipv4.Mtu); - dbg_time("IPv4 Address: %s", ipaddr_to_string_v4(ntohl(profile->ipv4.Address))); - dbg_time("IPv4 Netmask: %d", mask_to_prefix_v4(ntohl(profile->ipv4.SubnetMask))); - dbg_time("IPv4 Gateway: %s", ipaddr_to_string_v4(ntohl(profile->ipv4.Gateway))); - dbg_time("IPv4 DNS1: %s", ipaddr_to_string_v4(ntohl(profile->ipv4.DnsPrimary))); - dbg_time("IPv4 DNS2: %s", ipaddr_to_string_v4(ntohl(profile->ipv4.DnsSecondary))); - if_set_network_v4(ifname, ntohl(profile->ipv4.Address), - mask_to_prefix_v4(profile->ipv4.SubnetMask), - ntohl(profile->ipv4.Gateway), - ntohl(profile->ipv4.DnsPrimary), - ntohl(profile->ipv4.DnsSecondary)); - } - else - { - dbg_time("The IPv4 Address in profile is NULL"); - } - - if (profile->ipv6.Address && (profile->ipv6.PrefixLengthIPAddr != 0)) - { - //module do not support DHCPv6, only support 'Router Solicit' - //and it seem if enable /proc/sys/net/ipv6/conf/all/forwarding, Kernel do not send RS - const char *forward_file = "/proc/sys/net/ipv6/conf/all/forwarding"; - int forward_fd = open(forward_file, O_RDONLY); - if (forward_fd > 0) - { - char forward_state[2]; - read(forward_fd, forward_state, 2); - if (forward_state[0] == '1') - { - dbg_time("%s enabled, kernel maybe donot send 'Router Solicit'", forward_file); - } - close(forward_fd); - } - - dbg_time("IPv6 MTU: %d", profile->ipv6.Mtu); - dbg_time("IPv6 Address: %s", ipaddr_to_string_v6(profile->ipv6.Address)); - dbg_time("IPv6 PrefixLengthIPAddr: %d", profile->ipv6.PrefixLengthIPAddr); - dbg_time("IPv6 Gateway: %s", ipaddr_to_string_v6(profile->ipv6.Gateway)); - dbg_time("IPv6 DNS1: %s", ipaddr_to_string_v6(profile->ipv6.DnsPrimary)); - dbg_time("IPv6 DNS2: %s", ipaddr_to_string_v6(profile->ipv6.DnsSecondary)); - if_set_network_v6(ifname, profile->ipv6.Address, profile->ipv6.PrefixLengthIPAddr, - profile->ipv6.Gateway, profile->ipv6.DnsPrimary, profile->ipv6.DnsSecondary); - } - else - { - dbg_time("The IPv6 Address in profile is NULL"); - } -} - -void udhcpc_stop(PROFILE_T *profile) -{ - char *ifname = profile->usbnet_adapter; - dbg_time("enter %s ", __func__); - - fibo_set_driver_link_state(profile, 0); - - if (profile->qmapnet_adapter) - { - ifname = profile->qmapnet_adapter; - } - - if_flush_v4_addr(ifname); - if_flush_v6_addr(ifname); - if_link_down(ifname); -} - -static void fibo_set_mtu(const char *ifname, int ifru_mtu) { - int inet_sock; - struct ifreq ifr; - - inet_sock = socket(AF_INET, SOCK_DGRAM, 0); - - if (inet_sock > 0) { - strcpy(ifr.ifr_name, ifname); - - if (!ioctl(inet_sock, SIOCGIFMTU, &ifr)) { - if (ifr.ifr_ifru.ifru_mtu != ifru_mtu) { - dbg_time("change mtu %d -> %d", ifr.ifr_ifru.ifru_mtu , ifru_mtu); - ifr.ifr_ifru.ifru_mtu = ifru_mtu; - ioctl(inet_sock, SIOCSIFMTU, &ifr); - } - } - - close(inet_sock); - } -} - -static void* udhcpc_thread_function(void* arg) { - FILE * udhcpc_fp; - char *udhcpc_cmd = (char *)arg; - - if (udhcpc_cmd == NULL) - return NULL; - - dbg_time("%s", udhcpc_cmd); - udhcpc_fp = popen(udhcpc_cmd, "r"); - free(udhcpc_cmd); - if (udhcpc_fp) { - char buf[0xff]; - - buf[sizeof(buf)-1] = '\0'; - while((fgets(buf, sizeof(buf)-1, udhcpc_fp)) != NULL) { - if ((strlen(buf) > 1) && (buf[strlen(buf) - 1] == '\n')) - buf[strlen(buf) - 1] = '\0'; - dbg_time("%s", buf); - } - - pclose(udhcpc_fp); - } - - return NULL; -} - -void udhcpc_start_pcie(PROFILE_T *profile) { - char *ifname = profile->usbnet_adapter; - char sub_intf_name[100] = {0}; - int intf_id = 0; - char shell_cmd[512]; - dbg_time("enter %s ", __func__); - - if (profile->qmapnet_adapter) { - ifname = profile->qmapnet_adapter; - } - - if (profile->muxid > 0x81) - { - intf_id = profile->muxid - 0x81; - snprintf(sub_intf_name, sizeof(sub_intf_name) - 1, "%s.%d", ifname, intf_id); - } - - if (profile->rawIP && profile->ipv4.Address && profile->ipv4.Mtu) { - fibo_set_mtu(ifname, (profile->ipv4.Mtu)); - } - - fibo_system("echo 1 > /sys/module/fibo_mhi/parameters/macaddr_check"); - - if (strcmp(ifname, profile->usbnet_adapter)) { - snprintf(shell_cmd, sizeof(shell_cmd) - 1, "ifconfig %s up", profile->usbnet_adapter); - fibo_system(shell_cmd); - } - - // For IPv6, down & up will send protocol packets, and that's needed. - if (profile->ipv6_flag && profile->muxid <= 0x81) { - snprintf(shell_cmd, sizeof(shell_cmd) - 1, "ifconfig %s down", ifname); - fibo_system(shell_cmd); - } - - snprintf(shell_cmd, sizeof(shell_cmd) - 1, "ifconfig %s up", ifname); - fibo_system(shell_cmd); - - //for bridge mode, only one public IP, so do udhcpc manually - if (fibo_bridge_mode_detect(profile)) { - return; - } - -/* Do DHCP using busybox tools */ - { - char udhcpc_cmd[128]; - pthread_attr_t udhcpc_thread_attr; - pthread_t udhcpc_thread_id; - - pthread_attr_init(&udhcpc_thread_attr); - pthread_attr_setdetachstate(&udhcpc_thread_attr, PTHREAD_CREATE_DETACHED); - - if (profile->ipv4.Address) - { - char v4add_str[32] = {0}; - char v4gw_str[32] = {0}; - char v4_netmask_str[32] = {0}; - uint32_t Address = ntohl(profile->ipv4.Address); - uint32_t Gateway = ntohl(profile->ipv4.Gateway); - uint32_t SubnetMask = ntohl(profile->ipv4.SubnetMask); - inet_ntop(AF_INET, &Address, v4add_str, sizeof(v4add_str)); - inet_ntop(AF_INET, &Gateway, v4gw_str, sizeof(v4gw_str)); - inet_ntop(AF_INET, &SubnetMask, v4_netmask_str, sizeof(v4_netmask_str)); - - if (profile->muxid == 0x81) - { - snprintf(shell_cmd, sizeof(shell_cmd) - 1, "ifconfig %s %s netmask %s", ifname, v4add_str, v4_netmask_str); - fibo_system(shell_cmd); - - snprintf(shell_cmd, sizeof(shell_cmd) - 1, "route add default gw %s dev %s", v4gw_str, ifname); - fibo_system(shell_cmd); - } - else if (profile->muxid > 0x81) - { - snprintf(shell_cmd, sizeof(shell_cmd) - 1, "ip link add link %s name %s type vlan id %d", ifname, sub_intf_name, intf_id); - fibo_system(shell_cmd); - - snprintf(shell_cmd, sizeof(shell_cmd) - 1, "ip link set %s up", ifname); - fibo_system(shell_cmd); - - snprintf(shell_cmd, sizeof(shell_cmd) - 1, "ip link set %s up", sub_intf_name); - fibo_system(shell_cmd); - - snprintf(shell_cmd, sizeof(shell_cmd) - 1, "ifconfig %s %s netmask %s", sub_intf_name, v4add_str, v4_netmask_str); - fibo_system(shell_cmd); - } - } - - if (profile->ipv6.PrefixLengthIPAddr) - { - //module do not support DHCPv6, only support 'Router Solicit' - //and it seem if enable /proc/sys/net/ipv6/conf/all/forwarding, Kernel do not send RS - const char *forward_file = "/proc/sys/net/ipv6/conf/all/forwarding"; - int forward_fd = open(forward_file, O_RDONLY); - if (forward_fd > 0) { - char forward_state[2]; - read(forward_fd, forward_state, 2); - if (forward_state[0] == '1') { - dbg_time("%s enabled, kernel maybe donot send 'Router Solicit'", forward_file); - } - close(forward_fd); - } - - { - char v6add_str[100] = {0}; - char v6gw_str[100] = {0}; - inet_ntop(AF_INET6, profile->ipv6.Address, v6add_str, sizeof(v6add_str)); - inet_ntop(AF_INET6, profile->ipv6.Gateway, v6gw_str, sizeof(v6gw_str)); - - if (profile->muxid == 0x81) - { - snprintf(shell_cmd, sizeof(shell_cmd) - 1, "ifconfig %s add %s/%d", ifname, v6add_str, profile->ipv6.PrefixLengthIPAddr); - fibo_system(shell_cmd); - - snprintf(shell_cmd, sizeof(shell_cmd) - 1, "route -A inet6 add ::/0 gw %s dev %s", v6gw_str, ifname); - fibo_system(shell_cmd); - } - else if (profile->muxid > 0x81) - { - snprintf(shell_cmd, sizeof(shell_cmd) - 1, "ip link add link %s name %s type vlan id %d", ifname, sub_intf_name, intf_id); - fibo_system(shell_cmd); - - snprintf(shell_cmd, sizeof(shell_cmd) - 1, "ip link set %s up", ifname); - fibo_system(shell_cmd); - - snprintf(shell_cmd, sizeof(shell_cmd) - 1, "ip link set %s up", sub_intf_name); - fibo_system(shell_cmd); - - snprintf(shell_cmd, sizeof(shell_cmd) - 1, "ifconfig %s add %s/%d", sub_intf_name, v6add_str, profile->ipv6.PrefixLengthIPAddr); - fibo_system(shell_cmd); - /* start 2021-01-21 add by haopengfei to fix mantis 69056 */ - snprintf(shell_cmd, sizeof(shell_cmd) - 1, "route -A inet6 add ::/0 gw %s dev %s", v6gw_str, sub_intf_name); - fibo_system(shell_cmd); - /* end 2021-01-21 add by haopengfei to fix mantis 69056 */ - } - } - - } - } -} - -void udhcpc_stop_pcie(PROFILE_T *profile) { - char *ifname = profile->usbnet_adapter; - char shell_cmd[128]; - char reset_ip[128]; - dbg_time("enter %s ", __func__); - - if (profile->qmapnet_adapter) { - ifname = profile->qmapnet_adapter; - } - - if (profile->muxid == 0x81) - { - snprintf(shell_cmd, sizeof(shell_cmd) - 1, "ifconfig %s down", ifname); - fibo_system(shell_cmd); - snprintf(reset_ip, sizeof(reset_ip) - 1, "ifconfig %s 0.0.0.0", ifname); - fibo_system(reset_ip); - } - else if (profile->muxid > 0x81) - { - char sub_intf_name[100]; - int intf_id = profile->muxid - 0x81; - snprintf(sub_intf_name, sizeof(sub_intf_name) - 1, "%s.%d", ifname, intf_id); - - snprintf(shell_cmd, sizeof(shell_cmd) - 1, "ip link del link dev %s", sub_intf_name); - fibo_system(shell_cmd); - } -} - diff --git a/fibocom-dial/src/util.c b/fibocom-dial/src/util.c deleted file mode 100644 index f2a2228..0000000 --- a/fibocom-dial/src/util.c +++ /dev/null @@ -1,142 +0,0 @@ -#include - -#include "QMIThread.h" - -#if defined(__STDC__) -#include -#define __V(x) x -#else -#include -#define __V(x) (va_alist) va_dcl -#define const -#define volatile -#endif - -#include - -#define is_bigendian() ((*(char *)&i) == 0) -FILE *logfilefp = NULL; -static pthread_mutex_t printfMutex = PTHREAD_MUTEX_INITIALIZER; -static char line[1024]; -const int i = 1; - -// defined in atchannel.c -static void setTimespecRelative(struct timespec *p_ts, long long msec) -{ - struct timeval tv; - - gettimeofday(&tv, (struct timezone *)NULL); - - /* what's really funny about this is that I know - pthread_cond_timedwait just turns around and makes this - a relative time again */ - p_ts->tv_sec = tv.tv_sec + (msec / 1000); - p_ts->tv_nsec = (tv.tv_usec + (msec % 1000) * 1000L) * 1000L; -} - -int pthread_cond_timeout_np(pthread_cond_t *cond, pthread_mutex_t *mutex, - unsigned msecs) -{ - if (msecs != 0) { - struct timespec ts; - setTimespecRelative(&ts, msecs); - return pthread_cond_timedwait(cond, mutex, &ts); - } else { - return pthread_cond_wait(cond, mutex); - } -} - -static const char *get_time(void) -{ - static char time_buf[50]; - struct timeval tv; - time_t time; - suseconds_t millitm; - struct tm *ti; - - gettimeofday(&tv, NULL); - - time = tv.tv_sec; - millitm = (tv.tv_usec + 500) / 1000; - - if (millitm == 1000) { - ++time; - millitm = 0; - } - - ti = localtime(&time); - sprintf(time_buf, "[%02d-%02d_%02d:%02d:%02d:%03d]", ti->tm_mon + 1, - ti->tm_mday, ti->tm_hour, ti->tm_min, ti->tm_sec, (int)millitm); - return time_buf; -} - -void dbg_time(const char *fmt, ...) -{ - va_list args; - va_start(args, fmt); - - pthread_mutex_lock(&printfMutex); - - snprintf(line, sizeof(line), "%s ", get_time()); - - vsnprintf(line + strlen(line), sizeof(line) - strlen(line), fmt, args); - fprintf(stdout, "%s\n", line); - - if (logfilefp) { - fprintf(logfilefp, "%s\n", line); - } - fflush(logfilefp); - pthread_mutex_unlock(&printfMutex); -} - -USHORT le16_to_cpu(USHORT v16) -{ - USHORT tmp = v16; - if (is_bigendian()) { - unsigned char *s = (unsigned char *)(&v16); - unsigned char *d = (unsigned char *)(&tmp); - d[0] = s[1]; - d[1] = s[0]; - } - return tmp; -} - -UINT le32_to_cpu(UINT v32) -{ - UINT tmp = v32; - if (is_bigendian()) { - unsigned char *s = (unsigned char *)(&v32); - unsigned char *d = (unsigned char *)(&tmp); - d[0] = s[3]; - d[1] = s[2]; - d[2] = s[1]; - d[3] = s[0]; - } - return tmp; -} - -USHORT cpu_to_le16(USHORT v16) -{ - USHORT tmp = v16; - if (is_bigendian()) { - unsigned char *s = (unsigned char *)(&v16); - unsigned char *d = (unsigned char *)(&tmp); - d[0] = s[1]; - d[1] = s[0]; - } - return tmp; -} - -UINT cpu_to_le32(UINT v32) -{ - UINT tmp = v32; - if (is_bigendian()) { - unsigned char *s = (unsigned char *)(&v32); - unsigned char *d = (unsigned char *)(&tmp); - d[0] = s[3]; - d[1] = s[2]; - d[2] = s[1]; - d[3] = s[0]; - } - return tmp; -} diff --git a/fibocom-dial/src/util.h b/fibocom-dial/src/util.h deleted file mode 100644 index 0a0ec48..0000000 --- a/fibocom-dial/src/util.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _UTILS_H_ -#define _UTILS_H_ - -#include - -struct listnode { - struct listnode *next; - struct listnode *prev; -}; - -#define node_to_item(node, container, member) \ - (container *)(((char *)(node)) - offsetof(container, member)) - -#define list_declare(name) \ - struct listnode name = { \ - .next = &name, \ - .prev = &name, \ - } - -#define list_for_each(node, list) \ - for (node = (list)->next; node != (list); node = node->next) - -#define list_for_each_reverse(node, list) \ - for (node = (list)->prev; node != (list); node = node->prev) -void dbg_time(const char *fmt, ...); -void list_init(struct listnode *list); -void list_add_tail(struct listnode *list, struct listnode *item); -void list_add_head(struct listnode *head, struct listnode *item); -void list_remove(struct listnode *item); - -#define list_empty(list) ((list) == (list)->next) -#define list_head(list) ((list)->next) -#define list_tail(list) ((list)->prev) - -int epoll_register(int epoll_fd, int fd, unsigned int events); -int epoll_deregister(int epoll_fd, int fd); -#endif diff --git a/fibocom_MHI/Makefile b/fibocom_MHI/Makefile deleted file mode 100644 index 156e01b..0000000 --- a/fibocom_MHI/Makefile +++ /dev/null @@ -1,47 +0,0 @@ -# -# Copyright (C) 2015 OpenWrt.org -# -# This is free software, licensed under the GNU General Public License v2. -# See /LICENSE for more information. -# - -include $(TOPDIR)/rules.mk - -PKG_NAME:=pcie_mhi_fb -PKG_VERSION:=3.2 -PKG_RELEASE:=1 - -include $(INCLUDE_DIR)/kernel.mk -include $(INCLUDE_DIR)/package.mk - -define KernelPackage/pcie_mhi_fb - SUBMENU:=WWAN Support - TITLE:=Kernel pcie driver for MHI device - DEPENDS:=+pciids +pciutils +fibocom-dial - FILES:=$(PKG_BUILD_DIR)/pcie_mhi_fb.ko - AUTOLOAD:=$(call AutoLoad,90,pcie_mhi_fb) -endef - -define KernelPackage/pcie_mhi_fb/description - Kernel module for register a custom pciemhi platform device. -endef - -MAKE_OPTS:= \ - ARCH="$(LINUX_KARCH)" \ - CROSS_COMPILE="$(TARGET_CROSS)" \ - CXXFLAGS="$(TARGET_CXXFLAGS)" \ - M="$(PKG_BUILD_DIR)" \ - $(EXTRA_KCONFIG) - -define Build/Prepare - mkdir -p $(PKG_BUILD_DIR) - $(CP) ./src/* $(PKG_BUILD_DIR)/ -endef - -define Build/Compile - $(MAKE) -C "$(LINUX_DIR)" \ - $(MAKE_OPTS) \ - modules -endef - -$(eval $(call KernelPackage,pcie_mhi_fb)) diff --git a/fibocom_MHI/src/Kconfig b/fibocom_MHI/src/Kconfig deleted file mode 100644 index ec1e587..0000000 --- a/fibocom_MHI/src/Kconfig +++ /dev/null @@ -1,14 +0,0 @@ -menu "pcie mhi device Drivers" - -config PCIE_MHI - tristate "MHI dev net interface" - help - This modules enables userspace software clients to communicate - with devices supporting the MHI protocol. Userspace clients - may open the device nodes exposed by MHI UCI and perform - read, write and ioctl operations to communicate with the - attached device. - -endmenu - - diff --git a/fibocom_MHI/src/Makefile b/fibocom_MHI/src/Makefile deleted file mode 100644 index 82ec28f..0000000 --- a/fibocom_MHI/src/Makefile +++ /dev/null @@ -1,29 +0,0 @@ -ccflags-y += -g -Wno-incompatible-pointer-types -Wno-unused-variable -#ccflags-y += -DCONFIG_MHI_NETDEV_MBIM -#obj-${CONFIG_PCIE_MHI} := fibo_mhi.o -obj-m := fibo_mhi.o -fibo_mhi-objs := core/mhi_init.o core/mhi_main.o core/mhi_pm.o core/mhi_boot.o core/mhi_dtr.o devices/mhi_netdev.o devices/mhi_uci.o controllers/mhi_qcom.o - -PWD := $(shell pwd) -ifeq ($(ARCH),) -ARCH := $(shell uname -m) -endif -ifeq ($(CROSS_COMPILE),) -CROSS_COMPILE := -endif -ifeq ($(KDIR),) -KDIR := /lib/modules/$(shell uname -r)/build -endif - - -fibo_mhi: clean -ifeq ($(findstring 86,$(ARCH)), 86) - cp -f $(PWD)/controllers/mhi_qcom_x86.h $(PWD)/controllers/mhi_qcom.h -else - cp -f $(PWD)/controllers/mhi_qcom_arm.h $(PWD)/controllers/mhi_qcom.h -endif - #ln -sf makefile Makefile - $(MAKE) ARCH=${ARCH} CROSS_COMPILE=${CROSS_COMPILE} -C $(KDIR) M=$(PWD) modules - -clean: - $(MAKE) ARCH=${ARCH} CROSS_COMPILE=${CROSS_COMPILE} -C $(KDIR) M=$(PWD) clean diff --git a/fibocom_MHI/src/controllers/mhi_qcom.c b/fibocom_MHI/src/controllers/mhi_qcom.c deleted file mode 100644 index 87e0fd4..0000000 --- a/fibocom_MHI/src/controllers/mhi_qcom.c +++ /dev/null @@ -1,683 +0,0 @@ -/* Copyright (c) 2018, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "../core/mhi.h" -#include "mhi_qcom.h" - - -#ifndef PCI_IRQ_MSI -#define PCI_IRQ_MSI (1 << 1) /* Allow MSI interrupts */ - -#if (LINUX_VERSION_CODE <= KERNEL_VERSION( 3,10,108 )) -int pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec) -{ - int nvec = maxvec; - int rc; - - if (maxvec < minvec) - return -ERANGE; - - do { - rc = pci_enable_msi_block(dev, nvec); - if (rc < 0) { - return rc; - } else if (rc > 0) { - if (rc < minvec) - return -ENOSPC; - nvec = rc; - } - } while (rc); - - return nvec; -} -#endif - -static int fibo_pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs, - unsigned int max_vecs, unsigned int flags) -{ - return pci_enable_msi_range(dev, min_vecs, max_vecs); -} - -static void fibo_pci_free_irq_vectors(struct pci_dev *dev) -{ - pci_disable_msi(dev); -} - -static int fibo_pci_irq_vector(struct pci_dev *dev, unsigned int nr) -{ - return dev->irq + nr; -} -#else -static int fibo_pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs, - unsigned int max_vecs, unsigned int flags) -{ - return pci_alloc_irq_vectors(dev, min_vecs, max_vecs, flags); -} - -static void fibo_pci_free_irq_vectors(struct pci_dev *dev) -{ - pci_free_irq_vectors(dev); -} - -static int fibo_pci_irq_vector(struct pci_dev *dev, unsigned int nr) -{ - return pci_irq_vector(dev, nr); -} -#endif - - -static struct pci_device_id mhi_pcie_device_id[] = { - {PCI_DEVICE(MHI_PCIE_VENDOR_ID, 0x0300)}, - {PCI_DEVICE(MHI_PCIE_VENDOR_ID, 0x0301)}, - {PCI_DEVICE(MHI_PCIE_VENDOR_ID, 0x0302)}, - {PCI_DEVICE(MHI_PCIE_VENDOR_ID, 0x0303)}, - {PCI_DEVICE(MHI_PCIE_VENDOR_ID, 0x0304)},//SDX24 - {PCI_DEVICE(MHI_PCIE_VENDOR_ID, 0x0305)}, - {PCI_DEVICE(MHI_PCIE_VENDOR_ID, 0x0306)}, //SDX55 - {PCI_DEVICE(0x2C7C, 0x0512)}, - {PCI_DEVICE(MHI_PCIE_VENDOR_ID, MHI_PCIE_DEBUG_ID)}, - {0}, -}; - -static struct pci_driver mhi_pcie_driver; - -void mhi_deinit_pci_dev(struct mhi_controller *mhi_cntrl) -{ - struct mhi_dev *mhi_dev = mhi_controller_get_devdata(mhi_cntrl); - struct pci_dev *pci_dev = mhi_dev->pci_dev; - - fibo_pci_free_irq_vectors(pci_dev); - iounmap(mhi_cntrl->regs); - mhi_cntrl->regs = NULL; - pci_clear_master(pci_dev); - pci_release_region(pci_dev, mhi_dev->resn); - pci_disable_device(pci_dev); -} - -static int mhi_init_pci_dev(struct mhi_controller *mhi_cntrl) -{ - struct mhi_dev *mhi_dev = mhi_controller_get_devdata(mhi_cntrl); - struct pci_dev *pci_dev = mhi_dev->pci_dev; - int ret; - resource_size_t start, len; - int i; - - mhi_dev->resn = MHI_PCI_BAR_NUM; - ret = pci_assign_resource(pci_dev, mhi_dev->resn); - if (ret) { - MHI_ERR("Error assign pci resources, ret:%d\n", ret); - return ret; - } - - ret = pci_enable_device(pci_dev); - if (ret) { - MHI_ERR("Error enabling device, ret:%d\n", ret); - goto error_enable_device; - } - - ret = pci_request_region(pci_dev, mhi_dev->resn, "mhi"); - if (ret) { - MHI_ERR("Error pci_request_region, ret:%d\n", ret); - goto error_request_region; - } - - pci_set_master(pci_dev); - - start = pci_resource_start(pci_dev, mhi_dev->resn); - len = pci_resource_len(pci_dev, mhi_dev->resn); - /*begin added by tony.du for mantis 0062018 on 2020-11-10*/ - #if (LINUX_VERSION_CODE < KERNEL_VERSION( 5,6,0 )) - mhi_cntrl->regs = ioremap_nocache(start, len); - #else - mhi_cntrl->regs = ioremap(start, len); - #endif - /*end added by tony.du for mantis 0062018 on 2020-11-10*/ - MHI_LOG("mhi_cntrl->regs = %p\n", mhi_cntrl->regs); - if (!mhi_cntrl->regs) { - MHI_ERR("Error ioremap region\n"); - goto error_ioremap; - } - - ret = fibo_pci_alloc_irq_vectors(pci_dev, 1, mhi_cntrl->msi_required, PCI_IRQ_MSI); - if (IS_ERR_VALUE((ulong)ret) || ret < mhi_cntrl->msi_required) { - if (ret == -ENOSPC) { - } - //imx_4.1.15_2.0.0_ga & DELL_OPTIPLEX_7010 only alloc one msi interrupt for one pcie device - if (ret != 1) { - MHI_ERR("Failed to enable MSI, ret=%d, msi_required=%d\n", ret, mhi_cntrl->msi_required); - goto error_req_msi; - } - } - - mhi_cntrl->msi_allocated = ret; - MHI_LOG("msi_required = %d, msi_allocated = %d, msi_irq = %u\n", mhi_cntrl->msi_required, mhi_cntrl->msi_allocated, pci_dev->irq); - - for (i = 0; i < mhi_cntrl->msi_allocated; i++) { - mhi_cntrl->irq[i] = fibo_pci_irq_vector(pci_dev, i); - if (mhi_cntrl->irq[i] < 0) { - ret = mhi_cntrl->irq[i]; - goto error_get_irq_vec; - } - } - - return 0; - -error_get_irq_vec: - fibo_pci_free_irq_vectors(pci_dev); - -error_req_msi: - iounmap(mhi_cntrl->regs); - -error_ioremap: - pci_clear_master(pci_dev); - -error_request_region: - pci_disable_device(pci_dev); - -error_enable_device: - pci_release_region(pci_dev, mhi_dev->resn); - - return ret; -} - -#ifdef CONFIG_PM -static int mhi_runtime_idle(struct device *dev) -{ - struct mhi_controller *mhi_cntrl = dev_get_drvdata(dev); - - MHI_LOG("Entered returning -EBUSY\n"); - - /* - * RPM framework during runtime resume always calls - * rpm_idle to see if device ready to suspend. - * If dev.power usage_count count is 0, rpm fw will call - * rpm_idle cb to see if device is ready to suspend. - * if cb return 0, or cb not defined the framework will - * assume device driver is ready to suspend; - * therefore, fw will schedule runtime suspend. - * In MHI power management, MHI host shall go to - * runtime suspend only after entering MHI State M2, even if - * usage count is 0. Return -EBUSY to disable automatic suspend. - */ - return -EBUSY; -} - -static int mhi_runtime_suspend(struct device *dev) -{ - int ret = 0; - struct mhi_controller *mhi_cntrl = dev_get_drvdata(dev); - - MHI_LOG("Enter\n"); - - mutex_lock(&mhi_cntrl->pm_mutex); - - ret = mhi_pm_suspend(mhi_cntrl); - if (ret) { - MHI_LOG("Abort due to ret:%d\n", ret); - goto exit_runtime_suspend; - } - - ret = mhi_arch_link_off(mhi_cntrl, true); - if (ret) - MHI_ERR("Failed to Turn off link ret:%d\n", ret); - -exit_runtime_suspend: - mutex_unlock(&mhi_cntrl->pm_mutex); - MHI_LOG("Exited with ret:%d\n", ret); - - return ret; -} - -static int mhi_runtime_resume(struct device *dev) -{ - int ret = 0; - struct mhi_controller *mhi_cntrl = dev_get_drvdata(dev); - struct mhi_dev *mhi_dev = mhi_controller_get_devdata(mhi_cntrl); - - MHI_LOG("Enter\n"); - - mutex_lock(&mhi_cntrl->pm_mutex); - - if (!mhi_dev->powered_on) { - MHI_LOG("Not fully powered, return success\n"); - mutex_unlock(&mhi_cntrl->pm_mutex); - return 0; - } - - /* turn on link */ - ret = mhi_arch_link_on(mhi_cntrl); - if (ret) - goto rpm_resume_exit; - - /* enter M0 state */ - ret = mhi_pm_resume(mhi_cntrl); - -rpm_resume_exit: - mutex_unlock(&mhi_cntrl->pm_mutex); - MHI_LOG("Exited with :%d\n", ret); - - return ret; -} - -static int mhi_system_resume(struct device *dev) -{ - int ret = 0; - struct mhi_controller *mhi_cntrl = dev_get_drvdata(dev); - - ret = mhi_runtime_resume(dev); - if (ret) { - MHI_ERR("Failed to resume link\n"); - } else { - pm_runtime_set_active(dev); - pm_runtime_enable(dev); - } - - return ret; -} - -int mhi_system_suspend(struct device *dev) -{ - struct mhi_controller *mhi_cntrl = dev_get_drvdata(dev); - - MHI_LOG("Entered\n"); - - /* if rpm status still active then force suspend */ - if (!pm_runtime_status_suspended(dev)) - return mhi_runtime_suspend(dev); - - pm_runtime_set_suspended(dev); - pm_runtime_disable(dev); - - MHI_LOG("Exit\n"); - return 0; -} -#endif - -/* checks if link is down */ -static int mhi_link_status(struct mhi_controller *mhi_cntrl, void *priv) -{ - struct mhi_dev *mhi_dev = priv; - u16 dev_id; - int ret; - - /* try reading device id, if dev id don't match, link is down */ - ret = pci_read_config_word(mhi_dev->pci_dev, PCI_DEVICE_ID, &dev_id); - - return (ret || dev_id != mhi_cntrl->dev_id) ? -EIO : 0; -} - -static int mhi_runtime_get(struct mhi_controller *mhi_cntrl, void *priv) -{ - struct mhi_dev *mhi_dev = priv; - struct device *dev = &mhi_dev->pci_dev->dev; - - return pm_runtime_get(dev); -} - -static void mhi_runtime_put(struct mhi_controller *mhi_cntrl, void *priv) -{ - struct mhi_dev *mhi_dev = priv; - struct device *dev = &mhi_dev->pci_dev->dev; - - pm_runtime_put_noidle(dev); -} - -static void mhi_status_cb(struct mhi_controller *mhi_cntrl, - void *priv, - enum MHI_CB reason) -{ - struct mhi_dev *mhi_dev = priv; - struct device *dev = &mhi_dev->pci_dev->dev; - - if (reason == MHI_CB_IDLE) { - MHI_LOG("Schedule runtime suspend 1\n"); - pm_runtime_mark_last_busy(dev); - pm_request_autosuspend(dev); - } -} - -int mhi_debugfs_trigger_m0(void *data, u64 val) -{ - struct mhi_controller *mhi_cntrl = data; - struct mhi_dev *mhi_dev = mhi_controller_get_devdata(mhi_cntrl); - - MHI_LOG("Trigger M3 Exit\n"); - pm_runtime_get(&mhi_dev->pci_dev->dev); - pm_runtime_put(&mhi_dev->pci_dev->dev); - - return 0; -} - -int mhi_debugfs_trigger_m3(void *data, u64 val) -{ - struct mhi_controller *mhi_cntrl = data; - struct mhi_dev *mhi_dev = mhi_controller_get_devdata(mhi_cntrl); - - MHI_LOG("Trigger M3 Entry\n"); - pm_runtime_mark_last_busy(&mhi_dev->pci_dev->dev); - pm_request_autosuspend(&mhi_dev->pci_dev->dev); - - return 0; -} - -DEFINE_SIMPLE_ATTRIBUTE(debugfs_trigger_m0_fops, NULL, - mhi_debugfs_trigger_m0, "%llu\n"); - -DEFINE_SIMPLE_ATTRIBUTE(debugfs_trigger_m3_fops, NULL, - mhi_debugfs_trigger_m3, "%llu\n"); - -static int mhi_init_debugfs_trigger_go(void *data, u64 val) -{ - struct mhi_controller *mhi_cntrl = data; - - MHI_LOG("Trigger power up sequence\n"); - - mhi_async_power_up(mhi_cntrl); - - return 0; -} -DEFINE_SIMPLE_ATTRIBUTE(mhi_init_debugfs_trigger_go_fops, NULL, - mhi_init_debugfs_trigger_go, "%llu\n"); - - -int mhi_init_debugfs_debug_show(struct seq_file *m, void *d) -{ - seq_puts(m, "Enable debug mode to debug external soc\n"); - seq_puts(m, - "Usage: echo 'devid,timeout,domain,smmu_cfg' > debug_mode\n"); - seq_puts(m, "No spaces between parameters\n"); - seq_puts(m, "\t1. devid : 0 or pci device id to register\n"); - seq_puts(m, "\t2. timeout: mhi cmd/state transition timeout\n"); - seq_puts(m, "\t3. domain: Rootcomplex\n"); - seq_puts(m, "\t4. smmu_cfg: smmu configuration mask:\n"); - seq_puts(m, "\t\t- BIT0: ATTACH\n"); - seq_puts(m, "\t\t- BIT1: S1 BYPASS\n"); - seq_puts(m, "\t\t-BIT2: FAST_MAP\n"); - seq_puts(m, "\t\t-BIT3: ATOMIC\n"); - seq_puts(m, "\t\t-BIT4: FORCE_COHERENT\n"); - seq_puts(m, "\t\t-BIT5: GEOMETRY\n"); - seq_puts(m, "\tAll timeout are in ms, enter 0 to keep default\n"); - seq_puts(m, "Examples inputs: '0x307,10000'\n"); - seq_puts(m, "\techo '0,10000,1'\n"); - seq_puts(m, "\techo '0x307,10000,0,0x3d'\n"); - seq_puts(m, "firmware image name will be changed to debug.mbn\n"); - - return 0; -} - -static int mhi_init_debugfs_debug_open(struct inode *node, struct file *file) -{ - return single_open(file, mhi_init_debugfs_debug_show, NULL); -} - -static ssize_t mhi_init_debugfs_debug_write(struct file *fp, - const char __user *ubuf, - size_t count, - loff_t *pos) -{ - char *buf = kmalloc(count + 1, GFP_KERNEL); - /* #,devid,timeout,domain,smmu-cfg */ - int args[5] = {0}; - static char const *dbg_fw = "debug.mbn"; - int ret; - struct mhi_controller *mhi_cntrl = fp->f_inode->i_private; - struct mhi_dev *mhi_dev = mhi_controller_get_devdata(mhi_cntrl); - struct pci_device_id *id; - - if (!buf) - return -ENOMEM; - - ret = copy_from_user(buf, ubuf, count); - if (ret) - goto error_read; - buf[count] = 0; - get_options(buf, ARRAY_SIZE(args), args); - kfree(buf); - - /* override default parameters */ - mhi_cntrl->fw_image = dbg_fw; - mhi_cntrl->edl_image = dbg_fw; - - if (args[0] >= 2 && args[2]) - mhi_cntrl->timeout_ms = args[2]; - - if (args[0] >= 3 && args[3]) - mhi_cntrl->domain = args[3]; - - if (args[0] >= 4 && args[4]) - mhi_dev->smmu_cfg = args[4]; - - /* If it's a new device id register it */ - if (args[0] && args[1]) { - /* find the debug_id and overwrite it */ - for (id = mhi_pcie_device_id; id->vendor; id++) - if (id->device == MHI_PCIE_DEBUG_ID) { - id->device = args[1]; - pci_unregister_driver(&mhi_pcie_driver); - ret = pci_register_driver(&mhi_pcie_driver); - } - } - - mhi_dev->debug_mode = true; - debugfs_create_file("go", 0444, mhi_cntrl->parent, mhi_cntrl, - &mhi_init_debugfs_trigger_go_fops); - pr_info( - "%s: ret:%d pcidev:0x%x smm_cfg:%u timeout:%u\n", - __func__, ret, args[1], mhi_dev->smmu_cfg, - mhi_cntrl->timeout_ms); - return count; - -error_read: - kfree(buf); - return ret; -} - -static const struct file_operations debugfs_debug_ops = { - .open = mhi_init_debugfs_debug_open, - .release = single_release, - .read = seq_read, - .write = mhi_init_debugfs_debug_write, -}; - -static struct mhi_controller * mhi_platform_probe(struct pci_dev *pci_dev) -{ - struct mhi_controller *mhi_cntrl; - struct mhi_dev *mhi_dev; - u64 addr_win[2]; - int ret; - - mhi_cntrl = mhi_alloc_controller(sizeof(*mhi_dev)); - if (!mhi_cntrl) { - pr_err("mhi_alloc_controller fail\n"); - return NULL; - } - - mhi_dev = mhi_controller_get_devdata(mhi_cntrl); - - mhi_cntrl->dev_id = pci_dev->device; - mhi_cntrl->domain = pci_domain_nr(pci_dev->bus); - mhi_cntrl->bus = pci_dev->bus->number; - mhi_cntrl->slot = PCI_SLOT(pci_dev->devfn); - mhi_dev->smmu_cfg = 0; - - addr_win[0] = 0; - addr_win[1] = 0xFFFFFFFFF; //16GB - - mhi_cntrl->iova_start = addr_win[0]; - mhi_cntrl->iova_stop = addr_win[1]; - - mhi_dev->pci_dev = pci_dev; - mhi_cntrl->pci_dev = pci_dev; - - /* setup power management apis */ - mhi_cntrl->status_cb = mhi_status_cb; - mhi_cntrl->runtime_get = mhi_runtime_get; - mhi_cntrl->runtime_put = mhi_runtime_put; - mhi_cntrl->link_status = mhi_link_status; - - ret = mhi_arch_platform_init(mhi_dev); - if (ret) - goto error_probe; - - ret = mhi_register_mhi_controller(mhi_cntrl); - if (ret) - goto error_register; - - if (mhi_cntrl->parent) - debugfs_create_file("debug_mode", 0444, mhi_cntrl->parent, - mhi_cntrl, &debugfs_debug_ops); - - return mhi_cntrl; - -error_register: - mhi_arch_platform_deinit(mhi_dev); - -error_probe: - mhi_free_controller(mhi_cntrl); - - return NULL; -} - -int mhi_pci_probe(struct pci_dev *pci_dev, - const struct pci_device_id *device_id) -{ - struct mhi_controller *mhi_cntrl = NULL; - u32 domain = pci_domain_nr(pci_dev->bus); - u32 bus = pci_dev->bus->number; - u32 slot = PCI_SLOT(pci_dev->devfn); - struct mhi_dev *mhi_dev; - int ret; - - pr_err("INFO:%s pci_dev->name = %s, domain=%d, bus=%d, slot=%d, vendor=%04X, device=%04X\n", - __func__, dev_name(&pci_dev->dev), domain, bus, slot, pci_dev->vendor, pci_dev->device); - - mhi_cntrl = mhi_platform_probe(pci_dev); - if (!mhi_cntrl) { - pr_err("mhi_platform_probe fail\n"); - return -EPROBE_DEFER; - } - - mhi_cntrl->dev_id = pci_dev->device; - mhi_dev = mhi_controller_get_devdata(mhi_cntrl); - mhi_dev->pci_dev = pci_dev; - mhi_dev->powered_on = true; - - ret = mhi_arch_pcie_init(mhi_cntrl); - if (ret) { - MHI_ERR("Error mhi_arch_pcie_init, ret:%d\n", ret); - return ret; - } - - ret = mhi_arch_iommu_init(mhi_cntrl); - if (ret) { - MHI_ERR("Error mhi_arch_iommu_init, ret:%d\n", ret); - goto error_iommu_init; - } - - ret = mhi_init_pci_dev(mhi_cntrl); - if (ret) { - MHI_ERR("Error mhi_init_pci_dev, ret:%d\n", ret); - goto error_init_pci; - } - - /* start power up sequence if not in debug mode */ - if (!mhi_dev->debug_mode) { - ret = mhi_async_power_up(mhi_cntrl); - if (ret) { - MHI_ERR("Error mhi_async_power_up, ret:%d\n", ret); - goto error_power_up; - } - } - - if (mhi_cntrl->dentry) { - debugfs_create_file("m0", 0444, mhi_cntrl->dentry, mhi_cntrl, - &debugfs_trigger_m0_fops); - debugfs_create_file("m3", 0444, mhi_cntrl->dentry, mhi_cntrl, - &debugfs_trigger_m3_fops); - } - - dev_set_drvdata(&pci_dev->dev, mhi_cntrl); - MHI_LOG("Return successful\n"); - - return 0; - -error_power_up: - mhi_deinit_pci_dev(mhi_cntrl); - -error_init_pci: - mhi_arch_iommu_deinit(mhi_cntrl); - -error_iommu_init: - mhi_arch_pcie_deinit(mhi_cntrl); - - return ret; -} - -static void mhi_pci_remove(struct pci_dev *pci_dev) -{ - struct mhi_controller *mhi_cntrl = (struct mhi_controller *)dev_get_drvdata(&pci_dev->dev); - - if (mhi_cntrl && mhi_cntrl->pci_dev == pci_dev) { - struct mhi_dev *mhi_dev = mhi_controller_get_devdata(mhi_cntrl); - MHI_LOG("%s\n", dev_name(&pci_dev->dev)); - if (!mhi_dev->debug_mode) { - mhi_power_down(mhi_cntrl, 1); - } - mhi_deinit_pci_dev(mhi_cntrl); - mhi_arch_iommu_deinit(mhi_cntrl); - mhi_arch_pcie_deinit(mhi_cntrl); - mhi_unregister_mhi_controller(mhi_cntrl); - } -} - -static const struct dev_pm_ops pm_ops = { - SET_RUNTIME_PM_OPS(mhi_runtime_suspend, - mhi_runtime_resume, - mhi_runtime_idle) - SET_SYSTEM_SLEEP_PM_OPS(mhi_system_suspend, mhi_system_resume) -}; - -static struct pci_driver mhi_pcie_driver = { - .name = "mhi", - .id_table = mhi_pcie_device_id, - .probe = mhi_pci_probe, - .remove = mhi_pci_remove, - .driver = { - .pm = &pm_ops - } -}; - -int __init mhi_controller_qcom_init(void) -{ - return pci_register_driver(&mhi_pcie_driver); -}; - -void mhi_controller_qcom_exit(void) -{ - pr_err("INFO:%s enter\n", __func__); - pci_unregister_driver(&mhi_pcie_driver); - pr_err("INFO:%s exit\n", __func__); -} diff --git a/fibocom_MHI/src/controllers/mhi_qcom.h b/fibocom_MHI/src/controllers/mhi_qcom.h deleted file mode 100644 index 4a80026..0000000 --- a/fibocom_MHI/src/controllers/mhi_qcom.h +++ /dev/null @@ -1,92 +0,0 @@ -/* Copyright (c) 2018, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ -#ifndef _MHI_QCOM_ -#define _MHI_QCOM_ - -/* iova cfg bitmask */ -#define MHI_SMMU_ATTACH BIT(0) -#define MHI_SMMU_S1_BYPASS BIT(1) -#define MHI_SMMU_FAST BIT(2) -#define MHI_SMMU_ATOMIC BIT(3) -#define MHI_SMMU_FORCE_COHERENT BIT(4) - -#define MHI_PCIE_VENDOR_ID (0x17cb) -#define MHI_PCIE_DEBUG_ID (0xffff) -#define MHI_RPM_SUSPEND_TMR_MS (3000) -#define MHI_PCI_BAR_NUM (0) - -struct mhi_dev { - struct pci_dev *pci_dev; - u32 smmu_cfg; - int resn; - void *arch_info; - bool powered_on; - bool debug_mode; -}; - -void mhi_deinit_pci_dev(struct mhi_controller *mhi_cntrl); -int mhi_pci_probe(struct pci_dev *pci_dev, - const struct pci_device_id *device_id); - -#if (LINUX_VERSION_CODE <= KERNEL_VERSION( 3,10,108 )) -static inline int dma_set_mask_and_coherent(struct device *dev, u64 mask) -{ - int rc = dma_set_mask(dev, mask); - if (rc == 0) - dma_set_coherent_mask(dev, mask); - return rc; -} -#endif - -static inline int mhi_arch_iommu_init(struct mhi_controller *mhi_cntrl) -{ - struct mhi_dev *mhi_dev = mhi_controller_get_devdata(mhi_cntrl); - - mhi_cntrl->dev = &mhi_dev->pci_dev->dev; - - return dma_set_mask_and_coherent(mhi_cntrl->dev, DMA_BIT_MASK(64)); -} - -static inline void mhi_arch_iommu_deinit(struct mhi_controller *mhi_cntrl) -{ -} - -static inline int mhi_arch_pcie_init(struct mhi_controller *mhi_cntrl) -{ - return 0; -} - -static inline void mhi_arch_pcie_deinit(struct mhi_controller *mhi_cntrl) -{ -} - -static inline int mhi_arch_platform_init(struct mhi_dev *mhi_dev) -{ - return 0; -} - -static inline void mhi_arch_platform_deinit(struct mhi_dev *mhi_dev) -{ -} - -static inline int mhi_arch_link_off(struct mhi_controller *mhi_cntrl, - bool graceful) -{ - return 0; -} - -static inline int mhi_arch_link_on(struct mhi_controller *mhi_cntrl) -{ - return 0; -} - -#endif /* _MHI_QCOM_ */ diff --git a/fibocom_MHI/src/controllers/mhi_qcom_arm.h b/fibocom_MHI/src/controllers/mhi_qcom_arm.h deleted file mode 100644 index 4a80026..0000000 --- a/fibocom_MHI/src/controllers/mhi_qcom_arm.h +++ /dev/null @@ -1,92 +0,0 @@ -/* Copyright (c) 2018, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ -#ifndef _MHI_QCOM_ -#define _MHI_QCOM_ - -/* iova cfg bitmask */ -#define MHI_SMMU_ATTACH BIT(0) -#define MHI_SMMU_S1_BYPASS BIT(1) -#define MHI_SMMU_FAST BIT(2) -#define MHI_SMMU_ATOMIC BIT(3) -#define MHI_SMMU_FORCE_COHERENT BIT(4) - -#define MHI_PCIE_VENDOR_ID (0x17cb) -#define MHI_PCIE_DEBUG_ID (0xffff) -#define MHI_RPM_SUSPEND_TMR_MS (3000) -#define MHI_PCI_BAR_NUM (0) - -struct mhi_dev { - struct pci_dev *pci_dev; - u32 smmu_cfg; - int resn; - void *arch_info; - bool powered_on; - bool debug_mode; -}; - -void mhi_deinit_pci_dev(struct mhi_controller *mhi_cntrl); -int mhi_pci_probe(struct pci_dev *pci_dev, - const struct pci_device_id *device_id); - -#if (LINUX_VERSION_CODE <= KERNEL_VERSION( 3,10,108 )) -static inline int dma_set_mask_and_coherent(struct device *dev, u64 mask) -{ - int rc = dma_set_mask(dev, mask); - if (rc == 0) - dma_set_coherent_mask(dev, mask); - return rc; -} -#endif - -static inline int mhi_arch_iommu_init(struct mhi_controller *mhi_cntrl) -{ - struct mhi_dev *mhi_dev = mhi_controller_get_devdata(mhi_cntrl); - - mhi_cntrl->dev = &mhi_dev->pci_dev->dev; - - return dma_set_mask_and_coherent(mhi_cntrl->dev, DMA_BIT_MASK(64)); -} - -static inline void mhi_arch_iommu_deinit(struct mhi_controller *mhi_cntrl) -{ -} - -static inline int mhi_arch_pcie_init(struct mhi_controller *mhi_cntrl) -{ - return 0; -} - -static inline void mhi_arch_pcie_deinit(struct mhi_controller *mhi_cntrl) -{ -} - -static inline int mhi_arch_platform_init(struct mhi_dev *mhi_dev) -{ - return 0; -} - -static inline void mhi_arch_platform_deinit(struct mhi_dev *mhi_dev) -{ -} - -static inline int mhi_arch_link_off(struct mhi_controller *mhi_cntrl, - bool graceful) -{ - return 0; -} - -static inline int mhi_arch_link_on(struct mhi_controller *mhi_cntrl) -{ - return 0; -} - -#endif /* _MHI_QCOM_ */ diff --git a/fibocom_MHI/src/controllers/mhi_qcom_x86.h b/fibocom_MHI/src/controllers/mhi_qcom_x86.h deleted file mode 100644 index 7b8e33e..0000000 --- a/fibocom_MHI/src/controllers/mhi_qcom_x86.h +++ /dev/null @@ -1,92 +0,0 @@ -/* Copyright (c) 2018, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ -#ifndef _MHI_QCOM_ -#define _MHI_QCOM_ - -/* iova cfg bitmask */ -#define MHI_SMMU_ATTACH BIT(0) -#define MHI_SMMU_S1_BYPASS BIT(1) -#define MHI_SMMU_FAST BIT(2) -#define MHI_SMMU_ATOMIC BIT(3) -#define MHI_SMMU_FORCE_COHERENT BIT(4) - -#define MHI_PCIE_VENDOR_ID (0x17cb) -#define MHI_PCIE_DEBUG_ID (0xffff) -#define MHI_RPM_SUSPEND_TMR_MS (3000) -#define MHI_PCI_BAR_NUM (0) - -struct mhi_dev { - struct pci_dev *pci_dev; - u32 smmu_cfg; - int resn; - void *arch_info; - bool powered_on; - bool debug_mode; -}; - -void mhi_deinit_pci_dev(struct mhi_controller *mhi_cntrl); -int mhi_pci_probe(struct pci_dev *pci_dev, - const struct pci_device_id *device_id); - -#if (LINUX_VERSION_CODE <= KERNEL_VERSION( 3,10,108 )) -static inline int dma_set_mask_and_coherent(struct device *dev, u64 mask) -{ - int rc = dma_set_mask(dev, mask); - if (rc == 0) - dma_set_coherent_mask(dev, mask); - return rc; -} -#endif - -static inline int mhi_arch_iommu_init(struct mhi_controller *mhi_cntrl) -{ - struct mhi_dev *mhi_dev = mhi_controller_get_devdata(mhi_cntrl); - - mhi_cntrl->dev = &mhi_dev->pci_dev->dev; - - return dma_set_mask_and_coherent(mhi_cntrl->dev, DMA_BIT_MASK(32)); -} - -static inline void mhi_arch_iommu_deinit(struct mhi_controller *mhi_cntrl) -{ -} - -static inline int mhi_arch_pcie_init(struct mhi_controller *mhi_cntrl) -{ - return 0; -} - -static inline void mhi_arch_pcie_deinit(struct mhi_controller *mhi_cntrl) -{ -} - -static inline int mhi_arch_platform_init(struct mhi_dev *mhi_dev) -{ - return 0; -} - -static inline void mhi_arch_platform_deinit(struct mhi_dev *mhi_dev) -{ -} - -static inline int mhi_arch_link_off(struct mhi_controller *mhi_cntrl, - bool graceful) -{ - return 0; -} - -static inline int mhi_arch_link_on(struct mhi_controller *mhi_cntrl) -{ - return 0; -} - -#endif /* _MHI_QCOM_ */ diff --git a/fibocom_MHI/src/core/mhi.h b/fibocom_MHI/src/core/mhi.h deleted file mode 100644 index f72fd63..0000000 --- a/fibocom_MHI/src/core/mhi.h +++ /dev/null @@ -1,891 +0,0 @@ -/* Copyright (c) 2018, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ -#ifndef _MHI_H_ -#define _MHI_H_ - -#include - -typedef u64 uint64; -typedef u32 uint32; - -typedef enum -{ - MHI_CLIENT_LOOPBACK_OUT = 0, - MHI_CLIENT_LOOPBACK_IN = 1, - MHI_CLIENT_SAHARA_OUT = 2, - MHI_CLIENT_SAHARA_IN = 3, - MHI_CLIENT_DIAG_OUT = 4, - MHI_CLIENT_DIAG_IN = 5, - MHI_CLIENT_SSR_OUT = 6, - MHI_CLIENT_SSR_IN = 7, - MHI_CLIENT_QDSS_OUT = 8, - MHI_CLIENT_QDSS_IN = 9, - MHI_CLIENT_EFS_OUT = 10, - MHI_CLIENT_EFS_IN = 11, - MHI_CLIENT_MBIM_OUT = 12, - MHI_CLIENT_MBIM_IN = 13, - MHI_CLIENT_QMI_OUT = 14, - MHI_CLIENT_QMI_IN = 15, - MHI_CLIENT_QMI_2_OUT = 16, - MHI_CLIENT_QMI_2_IN = 17, - MHI_CLIENT_IP_CTRL_1_OUT = 18, - MHI_CLIENT_IP_CTRL_1_IN = 19, - MHI_CLIENT_IPCR_OUT = 20, - MHI_CLIENT_IPCR_IN = 21, - MHI_CLIENT_TEST_FW_OUT = 22, - MHI_CLIENT_TEST_FW_IN = 23, - MHI_CLIENT_RESERVED_0 = 24, - MHI_CLIENT_BOOT_LOG_IN = 25, - MHI_CLIENT_DCI_OUT = 26, - MHI_CLIENT_DCI_IN = 27, - MHI_CLIENT_QBI_OUT = 28, - MHI_CLIENT_QBI_IN = 29, - MHI_CLIENT_RESERVED_1_LOWER = 30, - MHI_CLIENT_RESERVED_1_UPPER = 31, - MHI_CLIENT_DUN_OUT = 32, - MHI_CLIENT_DUN_IN = 33, - MHI_CLIENT_EDL_OUT = 34, - MHI_CLIENT_EDL_IN = 35, - MHI_CLIENT_ADB_FB_OUT = 36, - MHI_CLIENT_ADB_FB_IN = 37, - MHI_CLIENT_RESERVED_2_LOWER = 38, - MHI_CLIENT_RESERVED_2_UPPER = 41, - MHI_CLIENT_CSVT_OUT = 42, - MHI_CLIENT_CSVT_IN = 43, - MHI_CLIENT_SMCT_OUT = 44, - MHI_CLIENT_SMCT_IN = 45, - MHI_CLIENT_IP_SW_0_OUT = 46, - MHI_CLIENT_IP_SW_0_IN = 47, - MHI_CLIENT_IP_SW_1_OUT = 48, - MHI_CLIENT_IP_SW_1_IN = 49, - MHI_CLIENT_GNSS_OUT = 50, - MHI_CLIENT_GNSS_IN = 51, - MHI_CLIENT_AUDIO_OUT = 52, - MHI_CLIENT_AUDIO_IN = 53, - MHI_CLIENT_RESERVED_3_LOWER = 54, - MHI_CLIENT_RESERVED_3_UPPER = 59, - MHI_CLIENT_TEST_0_OUT = 60, - MHI_CLIENT_TEST_0_IN = 61, - MHI_CLIENT_TEST_1_OUT = 62, - MHI_CLIENT_TEST_1_IN = 63, - MHI_CLIENT_TEST_2_OUT = 64, - MHI_CLIENT_TEST_2_IN = 65, - MHI_CLIENT_TEST_3_OUT = 66, - MHI_CLIENT_TEST_3_IN = 67, - MHI_CLIENT_RESERVED_4_LOWER = 68, - MHI_CLIENT_RESERVED_4_UPPER = 91, - MHI_CLIENT_OEM_0_OUT = 92, - MHI_CLIENT_OEM_0_IN = 93, - MHI_CLIENT_OEM_1_OUT = 94, - MHI_CLIENT_OEM_1_IN = 95, - MHI_CLIENT_OEM_2_OUT = 96, - MHI_CLIENT_OEM_2_IN = 97, - MHI_CLIENT_OEM_3_OUT = 98, - MHI_CLIENT_OEM_3_IN = 99, - MHI_CLIENT_IP_HW_0_OUT = 100, - MHI_CLIENT_IP_HW_0_IN = 101, - MHI_CLIENT_ADPL = 102, - MHI_CLIENT_RESERVED_5_LOWER = 103, - MHI_CLIENT_RESERVED_5_UPPER = 127, - MHI_MAX_CHANNELS = 128 -}MHI_CLIENT_CHANNEL_TYPE; - -#define MHI_VERSION 0x01000000 -#define MHIREGLEN_VALUE 0x100 /* **** WRONG VALUE *** */ -#define MHI_MSI_INDEX 1 -#define MAX_NUM_MHI_DEVICES 1 -#define NUM_MHI_XFER_RINGS 128 -#define NUM_MHI_EVT_RINGS 3 -#define PRIMARY_EVENT_RING 0 -#define IPA_OUT_EVENT_RING 1 -#define IPA_IN_EVENT_RING 2 -#define NUM_MHI_XFER_RING_ELEMENTS 16 -#define NUM_MHI_EVT_RING_ELEMENTS 256 -#define NUM_MHI_IPA_OUT_EVT_RING_ELEMENTS 2048 -#define NUM_MHI_IPA_IN_EVT_RING_ELEMENTS 1024 -#define NUM_MHI_IPA_IN_RING_ELEMENTS 256 -#define NUM_MHI_IPA_OUT_RING_ELEMENTS 256 -#define NUM_MHI_DIAG_IN_RING_ELEMENTS 128 -#define NUM_MHI_CHAN_RING_ELEMENTS 8 -#define MHI_EVT_CMD_QUEUE_SIZE 160 -#define MHI_EVT_STATE_QUEUE_SIZE 128 -#define MHI_EVT_XFER_QUEUE_SIZE 1024 -#define MHI_ALIGN_4BYTE_OFFSET 0x3 -#define MHI_ALIGN_4K_OFFSET 0xFFF -#define MAX_TRB_DATA_SIZE 0xFFFF -#define RESERVED_VALUE_64 0xFFFFFFFFFFFFFFFF -#define RESERVED_VALUE 0xFFFFFFFF -#define PCIE_LINK_DOWN 0xFFFFFFFF -#define SECONDS 1000 -#define MINUTES 60000 - -#define MHI_FILE_MHI 0x4D4849 -#define MHI_FILE_INIT 0x494E4954 -#define MHI_FILE_MSI 0x4D5349 -#define MHI_FILE_OS 0x4F53 -#define MHI_FILE_SM 0x534D -#define MHI_FILE_THREADS 0x54485245 -#define MHI_FILE_TRANSFER 0x5452414E -#define MHI_FILE_UTILS 0x5554494C - - -#define MHI_ER_PRIORITY_HIGH 0 -#define MHI_ER_PRIORITY_MEDIUM 1 -#define MHI_ER_PRIORITY_SPECIAL 2 - -#undef FALSE -#undef TRUE -#define FALSE 0 -#define TRUE 1 - -typedef struct MHI_DEV_CTXT MHI_DEV_CTXT; -typedef struct PCI_CORE_INFO PCI_CORE_INFO; -typedef struct PCIE_DEV_INFO PCIE_DEV_INFO; - -/* Memory Segment Properties */ -typedef struct _MHI_MEM_PROPS -{ - uint64 VirtAligned; - uint64 VirtUnaligned; - uint64 PhysAligned; - uint64 PhysUnaligned; - uint64 Size; - void *Handle; -}MHI_MEM_PROPS, *PMHI_MEM_PROPS; - -/* Device Power State Type */ -typedef enum -{ - POWER_DEVICE_INVALID = 0, - POWER_DEVICE_D0 = 1, - POWER_DEVICE_D1 = 2, - POWER_DEVICE_D2 = 3, - POWER_DEVICE_D3 = 4, - POWER_DEVICE_D3FINAL = 5, // System shutting down - POWER_DEVICE_HIBARNATION = 6, // Entering system state S4 - POWER_DEVICE_MAX = 7 -}PWR_STATE_TYPE; - -/* Channel State */ -typedef enum -{ - CHAN_STATE_DISABLED = 0, - CHAN_STATE_ENABLED = 1, - CHAN_STATE_RUNNING = 2, - CHAN_STATE_SUSPENDED = 3, - CHAN_STATE_STOPPED = 4, - CHAN_STATE_ERROR = 5, - - CHAN_STATE_OTHER = RESERVED_VALUE -}CHAN_STATE_TYPE; - -/* Channel Type */ -typedef enum -{ - INVALID_CHAN = 0, - OUTBOUND_CHAN = 1, - INBOUND_CHAN = 2, - - OTHER_CHAN = RESERVED_VALUE -}CHAN_TYPE; - -/* Ring Type */ -typedef enum -{ - CMD_RING = 0, - XFER_RING = 1, - EVT_RING = 2, -}MHI_RING_TYPE; - -/* Event Ring */ -typedef enum -{ - EVT_RING_INVALID = 0x0, - EVT_RING_VALID = 0x1, - EVT_RING_RESERVED = RESERVED_VALUE -}MHI_EVENT_RING_TYPE; - -#pragma pack(push,1) - -/* MHI Ring Context */ -typedef /*_ALIGN(1)*/ struct _MHI_RING_CTXT_TYPE -{ - uint32 Info; - uint32 Type; - uint32 Index; - uint64 Base; - uint64 Length; - volatile uint64 RP; - uint64 WP; -}MHI_RING_CTXT_TYPE, *PMHI_RING_CTXT_TYPE; - -/* MHI Ring Element */ -typedef /*_ALIGN(1)*/ struct _MHI_ELEMENT_TYPE -{ - uint64 Ptr; - uint32 Status; - uint32 Control; -}MHI_ELEMENT_TYPE, *PMHI_ELEMENT_TYPE; - -#pragma pack(pop) - -/* Command Ring Element Type */ -typedef enum -{ - CMD_NONE = 0, - CMD_NOOP = 1, - CMD_RESET_CHAN = 16, - CMD_STOP_CHAN = 17, - CMD_START_CHAN = 18, - CMD_CANCEL_CHAN_XFERS = 21 -}MHI_CMD_TYPE; - -/* Event Ring Element Type */ -typedef enum -{ - STATE_CHANGE_EVT = 32, - CMD_COMPLETION_EVT = 33, - XFER_COMPLETION_EVT = 34, - EE_STATE_CHANGE_EVT = 64 -} MHI_EVT_TYPE; - -/* Ring Status Type */ -typedef enum -{ - RING_EMPTY = 0, - RING_FULL = 1, - RING_QUEUED = 2, -} MHI_RING_STATUS_TYPE; - -/* XFER Ring Element Type */ -#define XFER_RING_ELEMENT_TYPE 2 - -/* Event Ring Completion Status */ -typedef enum -{ - EVT_COMPLETION_INVALID = 0, - EVT_COMPLETION_SUCCESS = 1, - EVT_COMPLETION_EOT = 2, - EVT_COMPLETION_OVERFLOW = 3, - EVT_COMPLETION_EOB = 4, - EVT_COMPLETION_OOB = 5, /* Out-Of-Buffer */ - EVT_COMPLETION_DB_MODE = 6, - EVT_COMPLETION_UNDEFINED = 16, - EVT_COMPLETION_MALFORMED = 17, - - EVT_COMPLETION_OTHER = RESERVED_VALUE -}EVT_COMPLETION_STATUS_TYPE; - -/* *********************************************************************************************** */ -/* Macros */ -/* *********************************************************************************************** */ -#define ADVANCE_RING_PTR(RingCtxt, Ptr, Size) \ - *Ptr = ((*Ptr - RingCtxt->Base)/sizeof(MHI_ELEMENT_TYPE) == (Size - 1))? \ - RingCtxt->Base: (*Ptr + sizeof(MHI_ELEMENT_TYPE)) - -#define GET_VIRT_ADDR(MhiCtxt, PhysAddr) \ - ((MhiCtxt)->CtrlSegProps.VirtAligned + ((PhysAddr) - (MhiCtxt)->CtrlSegProps.PhysAligned)) \ - -#define GET_PHYS_ADDR(MhiCtxt, VirtAddr) \ - ((MhiCtxt)->CtrlSegProps.PhysAligned + ((VirtAddr) - (MhiCtxt)->CtrlSegProps.VirtAligned)) \ - -#define GET_RING_ELEMENT_INDEX(RingBase, Element) \ - (((Element) - (RingBase))/sizeof(MHI_ELEMENT_TYPE)) - -#define VALID_RING_PTR(Ring, Ptr) \ - (((Ptr) >= (Ring)->Base) && \ - ((Ptr) <= ((Ring)->Base + (Ring)->Length - sizeof(MHI_ELEMENT_TYPE)))) - -#define CHAN_INBOUND(_x) ((_x)%2) - -#define CHAN_SBL(_x) (((_x) == MHI_CLIENT_SAHARA_OUT) || \ - ((_x) == MHI_CLIENT_SAHARA_IN) || \ - ((_x) == MHI_CLIENT_BOOT_LOG_IN)) - -#define CHAN_EDL(_x) (((_x) == MHI_CLIENT_EDL_OUT) || \ - ((_x) == MHI_CLIENT_EDL_IN)) - -#define RESERVED_CHAN(_x) (((_x) == MHI_CLIENT_RESERVED_0) || \ - ((_x) >= MHI_CLIENT_RESERVED_1_LOWER && (_x) <= MHI_CLIENT_RESERVED_1_UPPER) || \ - ((_x) >= MHI_CLIENT_RESERVED_2_LOWER && (_x) <= MHI_CLIENT_RESERVED_2_UPPER) || \ - ((_x) >= MHI_CLIENT_RESERVED_3_LOWER && (_x) <= MHI_CLIENT_RESERVED_3_UPPER) || \ - ((_x) >= MHI_CLIENT_RESERVED_4_LOWER && (_x) <= MHI_CLIENT_RESERVED_4_UPPER) || \ - ((_x) >= MHI_CLIENT_RESERVED_5_LOWER)) - -#define VALID_CHAN(_x) ((((_x) >= 0) && ((_x) < MHI_MAX_CHANNELS))) - -#define MHI_HW_CHAN(_x) ((_x) == MHI_CLIENT_IP_HW_0_OUT || \ - (_x) == MHI_CLIENT_IP_HW_0_IN || \ - (_x) == MHI_CLIENT_ADPL) - -#define MIN(_x,_y) ((_x) < (_y) ? (_x): (_y)) - -struct mhi_chan; -struct mhi_event; -struct mhi_ctxt; -struct mhi_cmd; -struct image_info; -struct bhi_vec_entry; -struct mhi_cntrl_data; - -/** - * enum MHI_CB - MHI callback - * @MHI_CB_IDLE: MHI entered idle state - * @MHI_CB_PENDING_DATA: New data available for client to process - * @MHI_CB_LPM_ENTER: MHI host entered low power mode - * @MHI_CB_LPM_EXIT: MHI host about to exit low power mode - * @MHI_CB_EE_RDDM: MHI device entered RDDM execution enviornment - */ -enum MHI_CB { - MHI_CB_IDLE, - MHI_CB_PENDING_DATA, - MHI_CB_LPM_ENTER, - MHI_CB_LPM_EXIT, - MHI_CB_EE_RDDM, -}; - -/** - * enum MHI_DEBUG_LEVL - various debugging level - */ -enum MHI_DEBUG_LEVEL { - MHI_MSG_LVL_VERBOSE, - MHI_MSG_LVL_INFO, - MHI_MSG_LVL_ERROR, - MHI_MSG_LVL_CRITICAL, - MHI_MSG_LVL_MASK_ALL, -}; - -/** - * enum MHI_FLAGS - Transfer flags - * @MHI_EOB: End of buffer for bulk transfer - * @MHI_EOT: End of transfer - * @MHI_CHAIN: Linked transfer - */ -enum MHI_FLAGS { - MHI_EOB, - MHI_EOT, - MHI_CHAIN, -}; - -/** - * struct image_info - firmware and rddm table table - * @mhi_buf - Contain device firmware and rddm table - * @entries - # of entries in table - */ -struct image_info { - struct mhi_buf *mhi_buf; - struct bhi_vec_entry *bhi_vec; - u32 entries; -}; - -/** - * struct mhi_controller - Master controller structure for external modem - * @dev: Device associated with this controller - * @of_node: DT that has MHI configuration information - * @regs: Points to base of MHI MMIO register space - * @bhi: Points to base of MHI BHI register space - * @wake_db: MHI WAKE doorbell register address - * @dev_id: PCIe device id of the external device - * @domain: PCIe domain the device connected to - * @bus: PCIe bus the device assigned to - * @slot: PCIe slot for the modem - * @iova_start: IOMMU starting address for data - * @iova_stop: IOMMU stop address for data - * @fw_image: Firmware image name for normal booting - * @edl_image: Firmware image name for emergency download mode - * @fbc_download: MHI host needs to do complete image transfer - * @rddm_size: RAM dump size that host should allocate for debugging purpose - * @sbl_size: SBL image size - * @seg_len: BHIe vector size - * @fbc_image: Points to firmware image buffer - * @rddm_image: Points to RAM dump buffer - * @max_chan: Maximum number of channels controller support - * @mhi_chan: Points to channel configuration table - * @lpm_chans: List of channels that require LPM notifications - * @total_ev_rings: Total # of event rings allocated - * @hw_ev_rings: Number of hardware event rings - * @sw_ev_rings: Number of software event rings - * @msi_required: Number of msi required to operate - * @msi_allocated: Number of msi allocated by bus master - * @irq: base irq # to request - * @mhi_event: MHI event ring configurations table - * @mhi_cmd: MHI command ring configurations table - * @mhi_ctxt: MHI device context, shared memory between host and device - * @timeout_ms: Timeout in ms for state transitions - * @pm_state: Power management state - * @ee: MHI device execution environment - * @dev_state: MHI STATE - * @status_cb: CB function to notify various power states to but master - * @link_status: Query link status in case of abnormal value read from device - * @runtime_get: Async runtime resume function - * @runtimet_put: Release votes - * @priv_data: Points to bus master's private data - */ -struct mhi_controller { - struct list_head node; - - /* device node for iommu ops */ - struct device *dev; - struct pci_dev *pci_dev; - - /* mmio base */ - void __iomem *regs; - void __iomem *bhi; - void __iomem *wake_db; - - /* device topology */ - u32 dev_id; - u32 domain; - u32 bus; - u32 slot; - - /* addressing window */ - dma_addr_t iova_start; - dma_addr_t iova_stop; - - /* fw images */ - const char *fw_image; - const char *edl_image; - - /* mhi host manages downloading entire fbc images */ - bool fbc_download; - size_t rddm_size; - size_t sbl_size; - size_t seg_len; - u32 session_id; - u32 sequence_id; - struct image_info *fbc_image; - struct image_info *rddm_image; - - /* physical channel config data */ - u32 max_chan; - struct mhi_chan *mhi_chan; - struct list_head lpm_chans; /* these chan require lpm notification */ - - /* physical event config data */ - u32 total_ev_rings; - u32 hw_ev_rings; - u32 sw_ev_rings; - u32 msi_required; - u32 msi_allocated; - int irq[8]; /* interrupt table */ - struct mhi_event *mhi_event; - - /* cmd rings */ - struct mhi_cmd *mhi_cmd; - - /* mhi context (shared with device) */ - struct mhi_ctxt *mhi_ctxt; - - u32 timeout_ms; - - /* caller should grab pm_mutex for suspend/resume operations */ - struct mutex pm_mutex; - bool pre_init; - rwlock_t pm_lock; - u32 pm_state; - u32 ee; - u32 dev_state; - bool wake_set; - atomic_t dev_wake; - atomic_t alloc_size; - struct list_head transition_list; - spinlock_t transition_lock; - spinlock_t wlock; - - /* debug counters */ - u32 M0, M1, M2, M3; - - /* worker for different state transitions */ - struct work_struct st_worker; - struct work_struct fw_worker; - struct work_struct m1_worker; - struct work_struct syserr_worker; - wait_queue_head_t state_event; - - /* shadow functions */ - void (*status_cb)(struct mhi_controller *mhi_cntrl, void *piv, - enum MHI_CB reason); - int (*link_status)(struct mhi_controller *mhi_cntrl, void *priv); - void (*wake_get)(struct mhi_controller *mhi_cntrl, bool override); - void (*wake_put)(struct mhi_controller *mhi_cntrl, bool override); - int (*runtime_get)(struct mhi_controller *mhi_cntrl, void *priv); - void (*runtime_put)(struct mhi_controller *mhi_cntrl, void *priv); - - /* channel to control DTR messaging */ - struct mhi_device *dtr_dev; - - /* kernel log level */ - enum MHI_DEBUG_LEVEL klog_lvl; - - /* private log level controller driver to set */ - enum MHI_DEBUG_LEVEL log_lvl; - - /* controller specific data */ - void *priv_data; - void *log_buf; - struct dentry *dentry; - struct dentry *parent; - struct mhi_cntrl_data *data; - - struct miscdevice miscdev; -}; - -/** - * struct mhi_device - mhi device structure associated bind to channel - * @dev: Device associated with the channels - * @mtu: Maximum # of bytes controller support - * @ul_chan_id: MHI channel id for UL transfer - * @dl_chan_id: MHI channel id for DL transfer - * @priv: Driver private data - */ -struct mhi_device { - struct device dev; - u32 dev_id; - u32 domain; - u32 bus; - u32 slot; - size_t mtu; - int ul_chan_id; - int dl_chan_id; - int ul_event_id; - int dl_event_id; - const struct mhi_device_id *id; - const char *chan_name; - struct mhi_controller *mhi_cntrl; - struct mhi_chan *ul_chan; - struct mhi_chan *dl_chan; - atomic_t dev_wake; - void *priv_data; - int (*ul_xfer)(struct mhi_device *mhi_dev, struct mhi_chan *mhi_chan, - void *buf, size_t len, enum MHI_FLAGS flags); - int (*dl_xfer)(struct mhi_device *mhi_dev, struct mhi_chan *mhi_chan, - void *buf, size_t len, enum MHI_FLAGS flags); - void (*status_cb)(struct mhi_device *mhi_dev, enum MHI_CB reason); -}; - -/** - * struct mhi_result - Completed buffer information - * @buf_addr: Address of data buffer - * @dir: Channel direction - * @bytes_xfer: # of bytes transferred - * @transaction_status: Status of last trasnferred - */ -struct mhi_result { - void *buf_addr; - enum dma_data_direction dir; - size_t bytes_xferd; - int transaction_status; -}; - -/** - * struct mhi_buf - Describes the buffer - * @buf: cpu address for the buffer - * @phys_addr: physical address of the buffer - * @dma_addr: iommu address for the buffer - * @len: # of bytes - * @name: Buffer label, for offload channel configurations name must be: - * ECA - Event context array data - * CCA - Channel context array data - */ -struct mhi_buf { - void *buf; - phys_addr_t phys_addr; - dma_addr_t dma_addr; - size_t len; - const char *name; /* ECA, CCA */ -}; - -/** - * struct mhi_driver - mhi driver information - * @id_table: NULL terminated channel ID names - * @ul_xfer_cb: UL data transfer callback - * @dl_xfer_cb: DL data transfer callback - * @status_cb: Asynchronous status callback - */ -struct mhi_driver { - const struct mhi_device_id *id_table; - int (*probe)(struct mhi_device *mhi_dev, - const struct mhi_device_id *id); - void (*remove)(struct mhi_device *mhi_dev); - void (*ul_xfer_cb)(struct mhi_device *mhi_dev, - struct mhi_result *result); - void (*dl_xfer_cb)(struct mhi_device *mhi_dev, - struct mhi_result *result); - void (*status_cb)(struct mhi_device *mhi_dev, enum MHI_CB mhi_cb); - struct device_driver driver; -}; - -#define to_mhi_driver(drv) container_of(drv, struct mhi_driver, driver) -#define to_mhi_device(dev) container_of(dev, struct mhi_device, dev) - -static inline void mhi_device_set_devdata(struct mhi_device *mhi_dev, - void *priv) -{ - mhi_dev->priv_data = priv; -} - -static inline void *mhi_device_get_devdata(struct mhi_device *mhi_dev) -{ - return mhi_dev->priv_data; -} - -/** - * mhi_queue_transfer - Queue a buffer to hardware - * All transfers are asyncronous transfers - * @mhi_dev: Device associated with the channels - * @dir: Data direction - * @buf: Data buffer (skb for hardware channels) - * @len: Size in bytes - * @mflags: Interrupt flags for the device - */ -static inline int mhi_queue_transfer(struct mhi_device *mhi_dev, - enum dma_data_direction dir, - void *buf, - size_t len, - enum MHI_FLAGS mflags) -{ - if (dir == DMA_TO_DEVICE) - return mhi_dev->ul_xfer(mhi_dev, mhi_dev->ul_chan, buf, len, - mflags); - else - return mhi_dev->dl_xfer(mhi_dev, mhi_dev->dl_chan, buf, len, - mflags); -} - -static inline void *mhi_controller_get_devdata(struct mhi_controller *mhi_cntrl) -{ - return mhi_cntrl->priv_data; -} - -static inline void mhi_free_controller(struct mhi_controller *mhi_cntrl) -{ - kfree(mhi_cntrl); -} - -/** - * mhi_driver_register - Register driver with MHI framework - * @mhi_drv: mhi_driver structure - */ -int mhi_driver_register(struct mhi_driver *mhi_drv); - -/** - * mhi_driver_unregister - Unregister a driver for mhi_devices - * @mhi_drv: mhi_driver structure - */ -void mhi_driver_unregister(struct mhi_driver *mhi_drv); - -/** - * mhi_device_configure - configure ECA or CCA context - * For offload channels that client manage, call this - * function to configure channel context or event context - * array associated with the channel - * @mhi_div: Device associated with the channels - * @dir: Direction of the channel - * @mhi_buf: Configuration data - * @elements: # of configuration elements - */ -int mhi_device_configure(struct mhi_device *mhi_div, - enum dma_data_direction dir, - struct mhi_buf *mhi_buf, - int elements); - -/** - * mhi_device_get - disable all low power modes - * Only disables lpm, does not immediately exit low power mode - * if controller already in a low power mode - * @mhi_dev: Device associated with the channels - */ -void mhi_device_get(struct mhi_device *mhi_dev); - -/** - * mhi_device_get_sync - disable all low power modes - * Synchronously disable all low power, exit low power mode if - * controller already in a low power state - * @mhi_dev: Device associated with the channels - */ -int mhi_device_get_sync(struct mhi_device *mhi_dev); - -/** - * mhi_device_put - re-enable low power modes - * @mhi_dev: Device associated with the channels - */ -void mhi_device_put(struct mhi_device *mhi_dev); - -/** - * mhi_prepare_for_transfer - setup channel for data transfer - * Moves both UL and DL channel from RESET to START state - * @mhi_dev: Device associated with the channels - */ -int mhi_prepare_for_transfer(struct mhi_device *mhi_dev); - -/** - * mhi_unprepare_from_transfer -unprepare the channels - * Moves both UL and DL channels to RESET state - * @mhi_dev: Device associated with the channels - */ -void mhi_unprepare_from_transfer(struct mhi_device *mhi_dev); - -/** - * mhi_get_no_free_descriptors - Get transfer ring length - * Get # of TD available to queue buffers - * @mhi_dev: Device associated with the channels - * @dir: Direction of the channel - */ -int mhi_get_no_free_descriptors(struct mhi_device *mhi_dev, - enum dma_data_direction dir); - -/** - * mhi_poll - poll for any available data to consume - * This is only applicable for DL direction - * @mhi_dev: Device associated with the channels - * @budget: In descriptors to service before returning - */ -int mhi_poll(struct mhi_device *mhi_dev, u32 budget); - -/** - * mhi_ioctl - user space IOCTL support for MHI channels - * Native support for setting TIOCM - * @mhi_dev: Device associated with the channels - * @cmd: IOCTL cmd - * @arg: Optional parameter, iotcl cmd specific - */ -long mhi_ioctl(struct mhi_device *mhi_dev, unsigned int cmd, unsigned long arg); - -/** - * mhi_alloc_controller - Allocate mhi_controller structure - * Allocate controller structure and additional data for controller - * private data. You may get the private data pointer by calling - * mhi_controller_get_devdata - * @size: # of additional bytes to allocate - */ -struct mhi_controller *mhi_alloc_controller(size_t size); - -/** - * mhi_register_mhi_controller - Register MHI controller - * Registers MHI controller with MHI bus framework. DT must be supported - * @mhi_cntrl: MHI controller to register - */ -int mhi_register_mhi_controller(struct mhi_controller *mhi_cntrl); - -void mhi_unregister_mhi_controller(struct mhi_controller *mhi_cntrl); - -/** - * mhi_bdf_to_controller - Look up a registered controller - * Search for controller based on device identification - * @domain: RC domain of the device - * @bus: Bus device connected to - * @slot: Slot device assigned to - * @dev_id: Device Identification - */ -struct mhi_controller *mhi_bdf_to_controller(u32 domain, u32 bus, u32 slot, - u32 dev_id); - -/** - * mhi_prepare_for_power_up - Do pre-initialization before power up - * This is optional, call this before power up if controller do not - * want bus framework to automatically free any allocated memory during shutdown - * process. - * @mhi_cntrl: MHI controller - */ -int mhi_prepare_for_power_up(struct mhi_controller *mhi_cntrl); - -/** - * mhi_async_power_up - Starts MHI power up sequence - * @mhi_cntrl: MHI controller - */ -int mhi_async_power_up(struct mhi_controller *mhi_cntrl); -int mhi_sync_power_up(struct mhi_controller *mhi_cntrl); - -/** - * mhi_power_down - Start MHI power down sequence - * @mhi_cntrl: MHI controller - * @graceful: link is still accessible, do a graceful shutdown process otherwise - * we will shutdown host w/o putting device into RESET state - */ -void mhi_power_down(struct mhi_controller *mhi_cntrl, bool graceful); - -/** - * mhi_unprepare_after_powre_down - free any allocated memory for power up - * @mhi_cntrl: MHI controller - */ -void mhi_unprepare_after_power_down(struct mhi_controller *mhi_cntrl); - -/** - * mhi_pm_suspend - Move MHI into a suspended state - * Transition to MHI state M3 state from M0||M1||M2 state - * @mhi_cntrl: MHI controller - */ -int mhi_pm_suspend(struct mhi_controller *mhi_cntrl); - -/** - * mhi_pm_resume - Resume MHI from suspended state - * Transition to MHI state M0 state from M3 state - * @mhi_cntrl: MHI controller - */ -int mhi_pm_resume(struct mhi_controller *mhi_cntrl); - -/** - * mhi_download_rddm_img - Download ramdump image from device for - * debugging purpose. - * @mhi_cntrl: MHI controller - * @in_panic: If we trying to capture image while in kernel panic - */ -int mhi_download_rddm_img(struct mhi_controller *mhi_cntrl, bool in_panic); - -/** - * mhi_force_rddm_mode - Force external device into rddm mode - * to collect device ramdump. This is useful if host driver assert - * and we need to see device state as well. - * @mhi_cntrl: MHI controller - */ -int mhi_force_rddm_mode(struct mhi_controller *mhi_cntrl); - -int mhi_cntrl_register_miscdev(struct mhi_controller *mhi_cntrl); -void mhi_cntrl_deregister_miscdev(struct mhi_controller *mhi_cntrl); - -extern int mhi_debug_mask; - -#define MHI_VERB(fmt, ...) do { \ - if (mhi_cntrl->klog_lvl <= MHI_MSG_LVL_VERBOSE) \ - pr_err("VERBOSE:[D][%s] " fmt, __func__, ##__VA_ARGS__);\ -} while (0) - -#define MHI_LOG(fmt, ...) do { \ - if (mhi_cntrl->klog_lvl <= MHI_MSG_LVL_INFO) \ - pr_err("INFO:[I][%s] " fmt, __func__, ##__VA_ARGS__);\ -} while (0) - -#define MHI_ERR(fmt, ...) do { \ - if (mhi_cntrl->klog_lvl <= MHI_MSG_LVL_ERROR) \ - pr_err("[E][%s] " fmt, __func__, ##__VA_ARGS__); \ -} while (0) - -#define MHI_CRITICAL(fmt, ...) do { \ - if (mhi_cntrl->klog_lvl <= MHI_MSG_LVL_CRITICAL) \ - pr_err("ALERT:[C][%s] " fmt, __func__, ##__VA_ARGS__); \ -} while (0) - -#ifndef MHI_NAME_SIZE -#define MHI_NAME_SIZE 32 -/** - * * struct mhi_device_id - MHI device identification - * * @chan: MHI channel name - * * @driver_data: driver data; - * */ -struct mhi_device_id { - const char chan[MHI_NAME_SIZE]; - unsigned long driver_data; -}; -#endif - -#endif /* _MHI_H_ */ diff --git a/fibocom_MHI/src/core/mhi_boot.c b/fibocom_MHI/src/core/mhi_boot.c deleted file mode 100644 index a981841..0000000 --- a/fibocom_MHI/src/core/mhi_boot.c +++ /dev/null @@ -1,878 +0,0 @@ -/* Copyright (c) 2018, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "mhi.h" -#include "mhi_internal.h" - -#define IOCTL_BHI_GETDEVINFO 0x8BE0 + 1 -#define IOCTL_BHI_WRITEIMAGE 0x8BE0 + 2 - -/* Software defines */ -/* BHI Version */ -#define BHI_MAJOR_VERSION 0x1 -#define BHI_MINOR_VERSION 0x1 - -#define MSMHWID_NUMDWORDS 6 /* Number of dwords that make the MSMHWID */ -#define OEMPKHASH_NUMDWORDS 48 /* Number of dwords that make the OEM PK HASH */ - -#define IsPBLExecEnv(ExecEnv) ((ExecEnv == MHI_EE_PBL) || (ExecEnv == MHI_EE_EDL) ) - -typedef u32 ULONG; - -typedef struct _bhi_info_type -{ - ULONG bhi_ver_minor; - ULONG bhi_ver_major; - ULONG bhi_image_address_low; - ULONG bhi_image_address_high; - ULONG bhi_image_size; - ULONG bhi_rsvd1; - ULONG bhi_imgtxdb; - ULONG bhi_rsvd2; - ULONG bhi_msivec; - ULONG bhi_rsvd3; - ULONG bhi_ee; - ULONG bhi_status; - ULONG bhi_errorcode; - ULONG bhi_errdbg1; - ULONG bhi_errdbg2; - ULONG bhi_errdbg3; - ULONG bhi_sernum; - ULONG bhi_sblantirollbackver; - ULONG bhi_numsegs; - ULONG bhi_msmhwid[6]; - ULONG bhi_oempkhash[48]; - ULONG bhi_rsvd5; -}BHI_INFO_TYPE, *PBHI_INFO_TYPE; - -#if 0 -static void PrintBhiInfo(BHI_INFO_TYPE *bhi_info) -{ - ULONG index; - - printk("BHI Device Info...\n"); - printk("BHI Version = { Major = 0x%X Minor = 0x%X}\n", bhi_info->bhi_ver_major, bhi_info->bhi_ver_minor); - printk("BHI Execution Environment = 0x%X\n", bhi_info->bhi_ee); - printk("BHI Status = 0x%X\n", bhi_info->bhi_status); - printk("BHI Error code = 0x%X { Dbg1 = 0x%X Dbg2 = 0x%X Dbg3 = 0x%X }\n", bhi_info->bhi_errorcode, bhi_info->bhi_errdbg1, bhi_info->bhi_errdbg2, bhi_info->bhi_errdbg3); - printk("BHI Serial Number = 0x%X\n", bhi_info->bhi_sernum); - printk("BHI SBL Anti-Rollback Ver = 0x%X\n", bhi_info->bhi_sblantirollbackver); - printk("BHI Number of Segments = 0x%X\n", bhi_info->bhi_numsegs); - printk("BHI MSM HW-Id = "); - for (index = 0; index < 6; index++) - { - printk("0x%X ", bhi_info->bhi_msmhwid[index]); - } - printk("\n"); - - printk("BHI OEM PK Hash = \n"); - for (index = 0; index < 24; index++) - { - printk("0x%X ", bhi_info->bhi_oempkhash[index]); - } - printk("\n"); -} -#endif - -static u32 bhi_read_reg(struct mhi_controller *mhi_cntrl, u32 offset) -{ - u32 out = 0; - int ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->bhi, offset, &out); - - return (ret) ? 0 : out; -} - -static int BhiRead(struct mhi_controller *mhi_cntrl, BHI_INFO_TYPE *bhi_info) -{ - ULONG index; - - memset(bhi_info, 0x00, sizeof(BHI_INFO_TYPE)); - - /* bhi_ver */ - bhi_info->bhi_ver_minor = bhi_read_reg(mhi_cntrl, BHI_BHIVERSION_MINOR); - bhi_info->bhi_ver_major = bhi_read_reg(mhi_cntrl, BHI_BHIVERSION_MINOR); - bhi_info->bhi_image_address_low = bhi_read_reg(mhi_cntrl, BHI_IMGADDR_LOW); - bhi_info->bhi_image_address_high = bhi_read_reg(mhi_cntrl, BHI_IMGADDR_HIGH); - bhi_info->bhi_image_size = bhi_read_reg(mhi_cntrl, BHI_IMGSIZE); - bhi_info->bhi_rsvd1 = bhi_read_reg(mhi_cntrl, BHI_RSVD1); - bhi_info->bhi_imgtxdb = bhi_read_reg(mhi_cntrl, BHI_IMGTXDB); - bhi_info->bhi_rsvd2 = bhi_read_reg(mhi_cntrl, BHI_RSVD2); - bhi_info->bhi_msivec = bhi_read_reg(mhi_cntrl, BHI_INTVEC); - bhi_info->bhi_rsvd3 = bhi_read_reg(mhi_cntrl, BHI_RSVD3); - bhi_info->bhi_ee = bhi_read_reg(mhi_cntrl, BHI_EXECENV); - bhi_info->bhi_status = bhi_read_reg(mhi_cntrl, BHI_STATUS); - bhi_info->bhi_errorcode = bhi_read_reg(mhi_cntrl, BHI_ERRCODE); - bhi_info->bhi_errdbg1 = bhi_read_reg(mhi_cntrl, BHI_ERRDBG1); - bhi_info->bhi_errdbg2 = bhi_read_reg(mhi_cntrl, BHI_ERRDBG2); - bhi_info->bhi_errdbg3 = bhi_read_reg(mhi_cntrl, BHI_ERRDBG3); - bhi_info->bhi_sernum = bhi_read_reg(mhi_cntrl, BHI_SERIALNUM); - bhi_info->bhi_sblantirollbackver = bhi_read_reg(mhi_cntrl, BHI_SBLANTIROLLVER); - bhi_info->bhi_numsegs = bhi_read_reg(mhi_cntrl, BHI_NUMSEG); - for (index = 0; index < MSMHWID_NUMDWORDS; index++) - { - bhi_info->bhi_msmhwid[index] = bhi_read_reg(mhi_cntrl, BHI_MSMHWID(index)); - } - for (index = 0; index < OEMPKHASH_NUMDWORDS; index++) - { - bhi_info->bhi_oempkhash[index] = bhi_read_reg(mhi_cntrl, BHI_OEMPKHASH(index)); - } - bhi_info->bhi_rsvd5 = bhi_read_reg(mhi_cntrl, BHI_RSVD5); - //PrintBhiInfo(bhi_info); - /* Check the Execution Environment */ - if (!IsPBLExecEnv(bhi_info->bhi_ee)) - { - printk("E - EE: 0x%X Expected PBL/EDL\n", bhi_info->bhi_ee); - } - - /* Return the number of bytes read */ - return 0; -} - -/* setup rddm vector table for rddm transfer */ -static void mhi_rddm_prepare(struct mhi_controller *mhi_cntrl, - struct image_info *img_info) -{ - struct mhi_buf *mhi_buf = img_info->mhi_buf; - struct bhi_vec_entry *bhi_vec = img_info->bhi_vec; - int i = 0; - - for (i = 0; i < img_info->entries - 1; i++, mhi_buf++, bhi_vec++) { - MHI_VERB("Setting vector:%pad size:%zu\n", - &mhi_buf->dma_addr, mhi_buf->len); - bhi_vec->dma_addr = mhi_buf->dma_addr; - bhi_vec->size = mhi_buf->len; - } -} - -/* collect rddm during kernel panic */ -static int __mhi_download_rddm_in_panic(struct mhi_controller *mhi_cntrl) -{ - int ret; - struct mhi_buf *mhi_buf; - u32 sequence_id; - u32 rx_status; - enum MHI_EE ee; - struct image_info *rddm_image = mhi_cntrl->rddm_image; - const u32 delayus = 100; - u32 retry = (mhi_cntrl->timeout_ms * 1000) / delayus; - void __iomem *base = mhi_cntrl->bhi; - - MHI_LOG("Entered with pm_state:%s dev_state:%s ee:%s\n", - to_mhi_pm_state_str(mhi_cntrl->pm_state), - TO_MHI_STATE_STR(mhi_cntrl->dev_state), - TO_MHI_EXEC_STR(mhi_cntrl->ee)); - - /* - * This should only be executing during a kernel panic, we expect all - * other cores to shutdown while we're collecting rddm buffer. After - * returning from this function, we expect device to reset. - * - * Normaly, we would read/write pm_state only after grabbing - * pm_lock, since we're in a panic, skipping it. - */ - - if (!MHI_REG_ACCESS_VALID(mhi_cntrl->pm_state)) - return -EIO; - - /* - * There is no gurantee this state change would take effect since - * we're setting it w/o grabbing pmlock, it's best effort - */ - mhi_cntrl->pm_state = MHI_PM_LD_ERR_FATAL_DETECT; - /* update should take the effect immediately */ - smp_wmb(); - - /* setup the RX vector table */ - mhi_rddm_prepare(mhi_cntrl, rddm_image); - mhi_buf = &rddm_image->mhi_buf[rddm_image->entries - 1]; - - MHI_LOG("Starting BHIe programming for RDDM\n"); - - mhi_write_reg(mhi_cntrl, base, BHIE_RXVECADDR_HIGH_OFFS, - upper_32_bits(mhi_buf->dma_addr)); - - mhi_write_reg(mhi_cntrl, base, BHIE_RXVECADDR_LOW_OFFS, - lower_32_bits(mhi_buf->dma_addr)); - - mhi_write_reg(mhi_cntrl, base, BHIE_RXVECSIZE_OFFS, mhi_buf->len); - sequence_id = prandom_u32() & BHIE_RXVECSTATUS_SEQNUM_BMSK; - - if (unlikely(!sequence_id)) - sequence_id = 1; - - - mhi_write_reg_field(mhi_cntrl, base, BHIE_RXVECDB_OFFS, - BHIE_RXVECDB_SEQNUM_BMSK, BHIE_RXVECDB_SEQNUM_SHFT, - sequence_id); - - MHI_LOG("Trigger device into RDDM mode\n"); - mhi_set_mhi_state(mhi_cntrl, MHI_STATE_SYS_ERR); - - MHI_LOG("Waiting for image download completion\n"); - while (retry--) { - ret = mhi_read_reg_field(mhi_cntrl, base, BHIE_RXVECSTATUS_OFFS, - BHIE_RXVECSTATUS_STATUS_BMSK, - BHIE_RXVECSTATUS_STATUS_SHFT, - &rx_status); - if (ret) - return -EIO; - - if (rx_status == BHIE_RXVECSTATUS_STATUS_XFER_COMPL) { - MHI_LOG("RDDM successfully collected\n"); - return 0; - } - - udelay(delayus); - } - - ee = mhi_get_exec_env(mhi_cntrl); - ret = mhi_read_reg(mhi_cntrl, base, BHIE_RXVECSTATUS_OFFS, &rx_status); - - MHI_ERR("Did not complete RDDM transfer\n"); - MHI_ERR("Current EE:%s\n", TO_MHI_EXEC_STR(ee)); - MHI_ERR("RXVEC_STATUS:0x%x, ret:%d\n", rx_status, ret); - - return -EIO; -} - -/* download ramdump image from device */ -int mhi_download_rddm_img(struct mhi_controller *mhi_cntrl, bool in_panic) -{ - void __iomem *base = mhi_cntrl->bhi; - rwlock_t *pm_lock = &mhi_cntrl->pm_lock; - struct image_info *rddm_image = mhi_cntrl->rddm_image; - struct mhi_buf *mhi_buf; - int ret; - u32 rx_status; - u32 sequence_id; - - if (!rddm_image) - return -ENOMEM; - - if (in_panic) - return __mhi_download_rddm_in_panic(mhi_cntrl); - - MHI_LOG("Waiting for device to enter RDDM state from EE:%s\n", - TO_MHI_EXEC_STR(mhi_cntrl->ee)); - - ret = wait_event_timeout(mhi_cntrl->state_event, - mhi_cntrl->ee == MHI_EE_RDDM || - MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state), - msecs_to_jiffies(mhi_cntrl->timeout_ms)); - - if (!ret || MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) { - MHI_ERR("MHI is not in valid state, pm_state:%s ee:%s\n", - to_mhi_pm_state_str(mhi_cntrl->pm_state), - TO_MHI_EXEC_STR(mhi_cntrl->ee)); - return -EIO; - } - - mhi_rddm_prepare(mhi_cntrl, mhi_cntrl->rddm_image); - - /* vector table is the last entry */ - mhi_buf = &rddm_image->mhi_buf[rddm_image->entries - 1]; - - read_lock_bh(pm_lock); - if (!MHI_REG_ACCESS_VALID(mhi_cntrl->pm_state)) { - read_unlock_bh(pm_lock); - return -EIO; - } - - MHI_LOG("Starting BHIe Programming for RDDM\n"); - - mhi_write_reg(mhi_cntrl, base, BHIE_RXVECADDR_HIGH_OFFS, - upper_32_bits(mhi_buf->dma_addr)); - - mhi_write_reg(mhi_cntrl, base, BHIE_RXVECADDR_LOW_OFFS, - lower_32_bits(mhi_buf->dma_addr)); - - mhi_write_reg(mhi_cntrl, base, BHIE_RXVECSIZE_OFFS, mhi_buf->len); - - sequence_id = prandom_u32() & BHIE_RXVECSTATUS_SEQNUM_BMSK; - mhi_write_reg_field(mhi_cntrl, base, BHIE_RXVECDB_OFFS, - BHIE_RXVECDB_SEQNUM_BMSK, BHIE_RXVECDB_SEQNUM_SHFT, - sequence_id); - read_unlock_bh(pm_lock); - - MHI_LOG("Upper:0x%x Lower:0x%x len:0x%zx sequence:%u\n", - upper_32_bits(mhi_buf->dma_addr), - lower_32_bits(mhi_buf->dma_addr), - mhi_buf->len, sequence_id); - MHI_LOG("Waiting for image download completion\n"); - - /* waiting for image download completion */ - wait_event_timeout(mhi_cntrl->state_event, - MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state) || - mhi_read_reg_field(mhi_cntrl, base, - BHIE_RXVECSTATUS_OFFS, - BHIE_RXVECSTATUS_STATUS_BMSK, - BHIE_RXVECSTATUS_STATUS_SHFT, - &rx_status) || rx_status, - msecs_to_jiffies(mhi_cntrl->timeout_ms)); - - if (MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) - return -EIO; - - return (rx_status == BHIE_RXVECSTATUS_STATUS_XFER_COMPL) ? 0 : -EIO; -} -EXPORT_SYMBOL(mhi_download_rddm_img); - -static int mhi_fw_load_amss(struct mhi_controller *mhi_cntrl, - const struct mhi_buf *mhi_buf) -{ - void __iomem *base = mhi_cntrl->bhi; - rwlock_t *pm_lock = &mhi_cntrl->pm_lock; - u32 tx_status; - - read_lock_bh(pm_lock); - if (!MHI_REG_ACCESS_VALID(mhi_cntrl->pm_state)) { - read_unlock_bh(pm_lock); - return -EIO; - } - - MHI_LOG("Starting BHIe Programming\n"); - - mhi_write_reg(mhi_cntrl, base, BHIE_TXVECADDR_HIGH_OFFS, - upper_32_bits(mhi_buf->dma_addr)); - - mhi_write_reg(mhi_cntrl, base, BHIE_TXVECADDR_LOW_OFFS, - lower_32_bits(mhi_buf->dma_addr)); - - mhi_write_reg(mhi_cntrl, base, BHIE_TXVECSIZE_OFFS, mhi_buf->len); - - mhi_cntrl->sequence_id = prandom_u32() & BHIE_TXVECSTATUS_SEQNUM_BMSK; - mhi_write_reg_field(mhi_cntrl, base, BHIE_TXVECDB_OFFS, - BHIE_TXVECDB_SEQNUM_BMSK, BHIE_TXVECDB_SEQNUM_SHFT, - mhi_cntrl->sequence_id); - read_unlock_bh(pm_lock); - - MHI_LOG("Upper:0x%x Lower:0x%x len:0x%zx sequence:%u\n", - upper_32_bits(mhi_buf->dma_addr), - lower_32_bits(mhi_buf->dma_addr), - mhi_buf->len, mhi_cntrl->sequence_id); - MHI_LOG("Waiting for image transfer completion\n"); - - /* waiting for image download completion */ - wait_event_timeout(mhi_cntrl->state_event, - MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state) || - mhi_read_reg_field(mhi_cntrl, base, - BHIE_TXVECSTATUS_OFFS, - BHIE_TXVECSTATUS_STATUS_BMSK, - BHIE_TXVECSTATUS_STATUS_SHFT, - &tx_status) || tx_status, - msecs_to_jiffies(mhi_cntrl->timeout_ms)); - - if (MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) - return -EIO; - - return (tx_status == BHIE_TXVECSTATUS_STATUS_XFER_COMPL) ? 0 : -EIO; -} - -static int mhi_fw_load_sbl(struct mhi_controller *mhi_cntrl, - void *buf, - size_t size) -{ - u32 tx_status, val; - int i, ret; - void __iomem *base = mhi_cntrl->bhi; - rwlock_t *pm_lock = &mhi_cntrl->pm_lock; - dma_addr_t phys = dma_map_single(mhi_cntrl->dev, buf, size, - DMA_TO_DEVICE); - struct { - char *name; - u32 offset; - } error_reg[] = { - { "ERROR_CODE", BHI_ERRCODE }, - { "ERROR_DBG1", BHI_ERRDBG1 }, - { "ERROR_DBG2", BHI_ERRDBG2 }, - { "ERROR_DBG3", BHI_ERRDBG3 }, - { NULL }, - }; - - if (dma_mapping_error(mhi_cntrl->dev, phys)) - return -ENOMEM; - - MHI_LOG("Starting BHI programming\n"); - - /* program start sbl download via bhi protocol */ - read_lock_bh(pm_lock); - if (!MHI_REG_ACCESS_VALID(mhi_cntrl->pm_state)) { - read_unlock_bh(pm_lock); - goto invalid_pm_state; - } - - mhi_write_reg(mhi_cntrl, base, BHI_STATUS, 0); - mhi_write_reg(mhi_cntrl, base, BHI_IMGADDR_HIGH, upper_32_bits(phys)); - mhi_write_reg(mhi_cntrl, base, BHI_IMGADDR_LOW, lower_32_bits(phys)); - mhi_write_reg(mhi_cntrl, base, BHI_IMGSIZE, size); - mhi_cntrl->session_id = prandom_u32() & BHI_TXDB_SEQNUM_BMSK; - mhi_write_reg(mhi_cntrl, base, BHI_IMGTXDB, mhi_cntrl->session_id); - read_unlock_bh(pm_lock); - - MHI_LOG("Waiting for image transfer completion\n"); - - /* waiting for image download completion */ - wait_event_timeout(mhi_cntrl->state_event, - /*MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state) ||*/ - mhi_read_reg_field(mhi_cntrl, base, BHI_STATUS, - BHI_STATUS_MASK, BHI_STATUS_SHIFT, - &tx_status) || tx_status, - msecs_to_jiffies(mhi_cntrl->timeout_ms)); - - #if 0 - if (MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) - goto invalid_pm_state; - #endif - - MHI_LOG("image transfer status:%d\n", tx_status); - - if (tx_status == BHI_STATUS_ERROR) { - MHI_ERR("Image transfer failed\n"); - read_lock_bh(pm_lock); - if (MHI_REG_ACCESS_VALID(mhi_cntrl->pm_state)) { - for (i = 0; error_reg[i].name; i++) { - ret = mhi_read_reg(mhi_cntrl, base, - error_reg[i].offset, &val); - if (ret) - break; - MHI_ERR("reg:%s value:0x%x\n", - error_reg[i].name, val); - } - } - read_unlock_bh(pm_lock); - goto invalid_pm_state; - } - - dma_unmap_single(mhi_cntrl->dev, phys, size, DMA_TO_DEVICE); - - return (tx_status == BHI_STATUS_SUCCESS) ? 0 : -ETIMEDOUT; - -invalid_pm_state: - dma_unmap_single(mhi_cntrl->dev, phys, size, DMA_TO_DEVICE); - - return -EIO; -} - -void mhi_free_bhie_table(struct mhi_controller *mhi_cntrl, - struct image_info *image_info) -{ - int i; - struct mhi_buf *mhi_buf = image_info->mhi_buf; - - for (i = 0; i < image_info->entries; i++, mhi_buf++) - mhi_free_coherent(mhi_cntrl, mhi_buf->len, mhi_buf->buf, - mhi_buf->dma_addr); - - kfree(image_info->mhi_buf); - kfree(image_info); -} - -int mhi_alloc_bhie_table(struct mhi_controller *mhi_cntrl, - struct image_info **image_info, - size_t alloc_size) -{ - size_t seg_size = mhi_cntrl->seg_len; - /* requier additional entry for vec table */ - int segments = DIV_ROUND_UP(alloc_size, seg_size) + 1; - int i; - struct image_info *img_info; - struct mhi_buf *mhi_buf; - - MHI_LOG("Allocating bytes:%zu seg_size:%zu total_seg:%u\n", - alloc_size, seg_size, segments); - - img_info = kzalloc(sizeof(*img_info), GFP_KERNEL); - if (!img_info) - return -ENOMEM; - - /* allocate memory for entries */ - img_info->mhi_buf = kcalloc(segments, sizeof(*img_info->mhi_buf), - GFP_KERNEL); - if (!img_info->mhi_buf) - goto error_alloc_mhi_buf; - - /* allocate and populate vector table */ - mhi_buf = img_info->mhi_buf; - for (i = 0; i < segments; i++, mhi_buf++) { - size_t vec_size = seg_size; - - /* last entry is for vector table */ - if (i == segments - 1) - vec_size = sizeof(struct __packed bhi_vec_entry) * i; - - mhi_buf->len = vec_size; - mhi_buf->buf = mhi_alloc_coherent(mhi_cntrl, vec_size, - &mhi_buf->dma_addr, GFP_KERNEL); - if (!mhi_buf->buf) - goto error_alloc_segment; - - MHI_LOG("Entry:%d Address:0x%llx size:%zd\n", i, - (u64)mhi_buf->dma_addr, mhi_buf->len); - } - - img_info->bhi_vec = img_info->mhi_buf[segments - 1].buf; - img_info->entries = segments; - *image_info = img_info; - - MHI_LOG("Successfully allocated bhi vec table\n"); - - return 0; - -error_alloc_segment: - for (--i, --mhi_buf; i >= 0; i--, mhi_buf--) - mhi_free_coherent(mhi_cntrl, mhi_buf->len, mhi_buf->buf, - mhi_buf->dma_addr); - -error_alloc_mhi_buf: - kfree(img_info); - - return -ENOMEM; -} - -static void mhi_firmware_copy(struct mhi_controller *mhi_cntrl, - const struct firmware *firmware, - struct image_info *img_info) -{ - size_t remainder = firmware->size; - size_t to_cpy; - const u8 *buf = firmware->data; - int i = 0; - struct mhi_buf *mhi_buf = img_info->mhi_buf; - struct bhi_vec_entry *bhi_vec = img_info->bhi_vec; - - while (remainder) { - MHI_ASSERT(i >= img_info->entries, "malformed vector table"); - - to_cpy = min(remainder, mhi_buf->len); - memcpy(mhi_buf->buf, buf, to_cpy); - bhi_vec->dma_addr = mhi_buf->dma_addr; - bhi_vec->size = to_cpy; - - MHI_VERB("Setting Vector:0x%llx size: %llu\n", - bhi_vec->dma_addr, bhi_vec->size); - buf += to_cpy; - remainder -= to_cpy; - i++; - bhi_vec++; - mhi_buf++; - } -} - -void mhi_fw_load_worker(struct work_struct *work) -{ - int ret; - struct mhi_controller *mhi_cntrl; - const char *fw_name; - const struct firmware *firmware; - struct image_info *image_info; - void *buf; - size_t size; - - mhi_cntrl = container_of(work, struct mhi_controller, fw_worker); - - MHI_LOG("Waiting for device to enter PBL from EE:%s\n", - TO_MHI_EXEC_STR(mhi_cntrl->ee)); - - ret = wait_event_timeout(mhi_cntrl->state_event, - MHI_IN_PBL(mhi_cntrl->ee) || - MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state), - msecs_to_jiffies(mhi_cntrl->timeout_ms)); - - if (!ret || MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) { - MHI_ERR("MHI is not in valid state\n"); - return; - } - - MHI_LOG("Device current EE:%s\n", TO_MHI_EXEC_STR(mhi_cntrl->ee)); - - /* if device in pthru, we do not have to load firmware */ - if (mhi_cntrl->ee == MHI_EE_PT) - return; - - fw_name = (mhi_cntrl->ee == MHI_EE_EDL) ? - mhi_cntrl->edl_image : mhi_cntrl->fw_image; - - if (!fw_name || (mhi_cntrl->fbc_download && (!mhi_cntrl->sbl_size || - !mhi_cntrl->seg_len))) { - MHI_ERR("No firmware image defined or !sbl_size || !seg_len\n"); - return; - } - - ret = request_firmware(&firmware, fw_name, mhi_cntrl->dev); - if (ret) { - MHI_ERR("Error loading firmware, ret:%d\n", ret); - return; - } - - size = (mhi_cntrl->fbc_download) ? mhi_cntrl->sbl_size : firmware->size; - - /* the sbl size provided is maximum size, not necessarily image size */ - if (size > firmware->size) - size = firmware->size; - - buf = kmalloc(size, GFP_KERNEL); - if (!buf) { - MHI_ERR("Could not allocate memory for image\n"); - release_firmware(firmware); - return; - } - - /* load sbl image */ - memcpy(buf, firmware->data, size); - ret = mhi_fw_load_sbl(mhi_cntrl, buf, size); - kfree(buf); - - if (!mhi_cntrl->fbc_download || ret || mhi_cntrl->ee == MHI_EE_EDL) - release_firmware(firmware); - - /* error or in edl, we're done */ - if (ret || mhi_cntrl->ee == MHI_EE_EDL) - return; - - write_lock_irq(&mhi_cntrl->pm_lock); - mhi_cntrl->dev_state = MHI_STATE_RESET; - write_unlock_irq(&mhi_cntrl->pm_lock); - - /* - * if we're doing fbc, populate vector tables while - * device transitioning into MHI READY state - */ - if (mhi_cntrl->fbc_download) { - ret = mhi_alloc_bhie_table(mhi_cntrl, &mhi_cntrl->fbc_image, - firmware->size); - if (ret) { - MHI_ERR("Error alloc size of %zu\n", firmware->size); - goto error_alloc_fw_table; - } - - MHI_LOG("Copying firmware image into vector table\n"); - - /* load the firmware into BHIE vec table */ - mhi_firmware_copy(mhi_cntrl, firmware, mhi_cntrl->fbc_image); - } - - /* transitioning into MHI RESET->READY state */ - ret = mhi_ready_state_transition(mhi_cntrl); - - MHI_LOG("To Reset->Ready PM_STATE:%s MHI_STATE:%s EE:%s, ret:%d\n", - to_mhi_pm_state_str(mhi_cntrl->pm_state), - TO_MHI_STATE_STR(mhi_cntrl->dev_state), - TO_MHI_EXEC_STR(mhi_cntrl->ee), ret); - - if (!mhi_cntrl->fbc_download) - return; - - if (ret) { - MHI_ERR("Did not transition to READY state\n"); - goto error_read; - } - - /* wait for BHIE event */ - ret = wait_event_timeout(mhi_cntrl->state_event, - mhi_cntrl->ee == MHI_EE_BHIE || - MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state), - msecs_to_jiffies(mhi_cntrl->timeout_ms)); - - if (!ret || MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) { - MHI_ERR("MHI did not enter BHIE\n"); - goto error_read; - } - - /* start full firmware image download */ - image_info = mhi_cntrl->fbc_image; - ret = mhi_fw_load_amss(mhi_cntrl, - /* last entry is vec table */ - &image_info->mhi_buf[image_info->entries - 1]); - - MHI_LOG("amss fw_load, ret:%d\n", ret); - - release_firmware(firmware); - - return; - -error_read: - mhi_free_bhie_table(mhi_cntrl, mhi_cntrl->fbc_image); - mhi_cntrl->fbc_image = NULL; - -error_alloc_fw_table: - release_firmware(firmware); -} - -int BhiWrite(struct mhi_controller *mhi_cntrl, void *buf, size_t size) -{ - int ret; - - MHI_LOG("Device current EE:%s,%d M:%s\n", - TO_MHI_EXEC_STR(mhi_get_exec_env(mhi_cntrl)), - mhi_cntrl->ee, - TO_MHI_STATE_STR(mhi_get_m_state(mhi_cntrl))); - - mhi_cntrl->ee = mhi_get_exec_env(mhi_cntrl); - - if (!MHI_IN_PBL(mhi_cntrl->ee)/* || MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)*/) { - MHI_ERR("MHI is not in valid BHI state:%d\n", mhi_cntrl->ee); - return -EINVAL; - } - - if (mhi_cntrl->ee != MHI_EE_EDL) - return 0; - - ret = mhi_fw_load_sbl(mhi_cntrl, buf, size); - - if (ret) { - MHI_ERR("ret = %d, ee=%d\n", ret, mhi_cntrl->ee); - goto error_state; - } - - write_lock_irq(&mhi_cntrl->pm_lock); - mhi_cntrl->dev_state = MHI_STATE_RESET; - write_unlock_irq(&mhi_cntrl->pm_lock); - - /* transitioning into MHI RESET->READY state */ - ret = mhi_ready_state_transition(mhi_cntrl); - if (ret) { - MHI_ERR("Did not transition to READY state\n"); - goto error_state; - } - - MHI_LOG("To Reset->Ready PM_STATE:%s MHI_STATE:%s EE:%s, ret:%d\n", - to_mhi_pm_state_str(mhi_cntrl->pm_state), - TO_MHI_STATE_STR(mhi_cntrl->dev_state), - TO_MHI_EXEC_STR(mhi_cntrl->ee), ret); - - /* wait for BHIE event */ - ret = wait_event_timeout(mhi_cntrl->state_event, - mhi_cntrl->ee == MHI_EE_FP || - MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state), - msecs_to_jiffies(mhi_cntrl->timeout_ms)); - if (!ret || MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) { - MHI_ERR("MHI did not enter Flash Programmer Environment\n"); - goto error_state; - } - - MHI_LOG("MHI enter Flash Programmer Environment\n"); - return 0; - -error_state: - MHI_LOG("Device current EE:%s, M:%s\n", - TO_MHI_EXEC_STR(mhi_get_exec_env(mhi_cntrl)), - TO_MHI_STATE_STR(mhi_get_m_state(mhi_cntrl))); - - return ret; -} - -static int mhi_cntrl_open(struct inode *inode, struct file *f) -{ - return 0; -} - -static int mhi_cntrl_release(struct inode *inode, struct file *f) -{ - return 0; -} - -static long mhi_cntrl_ioctl(struct file *f, unsigned int cmd, unsigned long __arg) -{ - long ret = -EINVAL; - void *ubuf = (void *)__arg; - struct miscdevice *c = (struct miscdevice *)f->private_data; - struct mhi_controller *mhi_cntrl = container_of(c, struct mhi_controller, miscdev); - - switch (cmd) { - case IOCTL_BHI_GETDEVINFO: - { - BHI_INFO_TYPE bhi_info; - ret = BhiRead(mhi_cntrl, &bhi_info); - if (ret) { - MHI_ERR("IOCTL_BHI_GETDEVINFO BhiRead error, ret = %ld\n", ret); - return ret; - } - - ret = copy_to_user(ubuf, &bhi_info, sizeof(bhi_info)); - if (ret) { - MHI_ERR("IOCTL_BHI_GETDEVINFO copy error, ret = %ld\n", ret); - } - } - break; - - case IOCTL_BHI_WRITEIMAGE: - { - void *buf; - size_t size; - - ret = copy_from_user(&size, ubuf, sizeof(size)); - if (ret) { - MHI_ERR("IOCTL_BHI_WRITEIMAGE copy size error, ret = %ld\n", ret); - return ret; - } - - buf = kmalloc(size, GFP_KERNEL); - if (buf == NULL) { - return -ENOMEM; - } - - ret = copy_from_user(buf, ubuf+sizeof(size), size); - if (ret) { - MHI_ERR("IOCTL_BHI_WRITEIMAGE copy buf error, ret = %ld\n", ret); - kfree(buf); - return ret; - } - - ret = BhiWrite(mhi_cntrl, buf, size); - if (ret) { - MHI_ERR("IOCTL_BHI_WRITEIMAGE BhiWrite error, ret = %ld\n", ret); - } - kfree(buf); - } - break; - - default: - break; - } - - return ret; -} - -static const struct file_operations mhi_cntrl_fops = { - .unlocked_ioctl = mhi_cntrl_ioctl, - .open = mhi_cntrl_open, - .release = mhi_cntrl_release, -}; - -int mhi_cntrl_register_miscdev(struct mhi_controller *mhi_cntrl) -{ - mhi_cntrl->miscdev.minor = MISC_DYNAMIC_MINOR; - mhi_cntrl->miscdev.name = "mhi_BHI"; - mhi_cntrl->miscdev.fops = &mhi_cntrl_fops; - - return misc_register(&mhi_cntrl->miscdev); -} - -void mhi_cntrl_deregister_miscdev(struct mhi_controller *mhi_cntrl) -{ - misc_deregister(&mhi_cntrl->miscdev); -} diff --git a/fibocom_MHI/src/core/mhi_common.h b/fibocom_MHI/src/core/mhi_common.h deleted file mode 100644 index a554604..0000000 --- a/fibocom_MHI/src/core/mhi_common.h +++ /dev/null @@ -1,362 +0,0 @@ -#ifndef __MHI_COMMON_H -#define __MHI_COMMON_H - -#include - -/* MHI control data structures alloted by the host, including - * channel context array, event context array, command context and rings */ - -/* Channel context state */ -enum mhi_dev_ch_ctx_state { - MHI_DEV_CH_STATE_DISABLED, - MHI_DEV_CH_STATE_ENABLED, - MHI_DEV_CH_STATE_RUNNING, - MHI_DEV_CH_STATE_SUSPENDED, - MHI_DEV_CH_STATE_STOP, - MHI_DEV_CH_STATE_ERROR, - MHI_DEV_CH_STATE_RESERVED, - MHI_DEV_CH_STATE_32BIT = 0x7FFFFFFF -}; - -/* Channel type */ -enum mhi_dev_ch_ctx_type { - MHI_DEV_CH_TYPE_NONE, - MHI_DEV_CH_TYPE_OUTBOUND_CHANNEL, - MHI_DEV_CH_TYPE_INBOUND_CHANNEL, - MHI_DEV_CH_RESERVED -}; - -/* Channel context type */ -struct mhi_dev_ch_ctx { - enum mhi_dev_ch_ctx_state ch_state; - enum mhi_dev_ch_ctx_type ch_type; - uint32_t err_indx; - uint64_t rbase; - uint64_t rlen; - uint64_t rp; - uint64_t wp; -} __packed; - -enum mhi_dev_ring_element_type_id { - MHI_DEV_RING_EL_INVALID = 0, - MHI_DEV_RING_EL_NOOP = 1, - MHI_DEV_RING_EL_TRANSFER = 2, - MHI_DEV_RING_EL_RESET = 16, - MHI_DEV_RING_EL_STOP = 17, - MHI_DEV_RING_EL_START = 18, - MHI_DEV_RING_EL_MHI_STATE_CHG = 32, - MHI_DEV_RING_EL_CMD_COMPLETION_EVT = 33, - MHI_DEV_RING_EL_TRANSFER_COMPLETION_EVENT = 34, - MHI_DEV_RING_EL_EE_STATE_CHANGE_NOTIFY = 64, - MHI_DEV_RING_EL_UNDEF -}; - -enum mhi_dev_ring_state { - RING_STATE_UINT = 0, - RING_STATE_IDLE, - RING_STATE_PENDING, -}; - -enum mhi_dev_ring_type { - RING_TYPE_CMD = 0, - RING_TYPE_ER, - RING_TYPE_CH, - RING_TYPE_INVAL -}; - -/* Event context interrupt moderation */ -enum mhi_dev_evt_ctx_int_mod_timer { - MHI_DEV_EVT_INT_MODERATION_DISABLED -}; - -/* Event ring type */ -enum mhi_dev_evt_ctx_event_ring_type { - MHI_DEV_EVT_TYPE_DEFAULT, - MHI_DEV_EVT_TYPE_VALID, - MHI_DEV_EVT_RESERVED -}; - -/* Event ring context type */ -struct mhi_dev_ev_ctx { - uint32_t res1:16; - enum mhi_dev_evt_ctx_int_mod_timer intmodt:16; - enum mhi_dev_evt_ctx_event_ring_type ertype; - uint32_t msivec; - uint64_t rbase; - uint64_t rlen; - uint64_t rp; - uint64_t wp; -} __packed; - -/* Command context */ -struct mhi_dev_cmd_ctx { - uint32_t res1; - uint32_t res2; - uint32_t res3; - uint64_t rbase; - uint64_t rlen; - uint64_t rp; - uint64_t wp; -} __packed; - -/* generic context */ -struct mhi_dev_gen_ctx { - uint32_t res1; - uint32_t res2; - uint32_t res3; - uint64_t rbase; - uint64_t rlen; - uint64_t rp; - uint64_t wp; -} __packed; - -/* Transfer ring element */ -struct mhi_dev_transfer_ring_element { - uint64_t data_buf_ptr; - uint32_t len:16; - uint32_t res1:16; - uint32_t chain:1; - uint32_t res2:7; - uint32_t ieob:1; - uint32_t ieot:1; - uint32_t bei:1; - uint32_t res3:5; - enum mhi_dev_ring_element_type_id type:8; - uint32_t res4:8; -} __packed; - -/* Command ring element */ -/* Command ring No op command */ -struct mhi_dev_cmd_ring_op { - uint64_t res1; - uint32_t res2; - uint32_t res3:16; - enum mhi_dev_ring_element_type_id type:8; - uint32_t chid:8; -} __packed; - -/* Command ring reset channel command */ -struct mhi_dev_cmd_ring_reset_channel_cmd { - uint64_t res1; - uint32_t res2; - uint32_t res3:16; - enum mhi_dev_ring_element_type_id type:8; - uint32_t chid:8; -} __packed; - -/* Command ring stop channel command */ -struct mhi_dev_cmd_ring_stop_channel_cmd { - uint64_t res1; - uint32_t res2; - uint32_t res3:16; - enum mhi_dev_ring_element_type_id type:8; - uint32_t chid:8; -} __packed; - -/* Command ring start channel command */ -struct mhi_dev_cmd_ring_start_channel_cmd { - uint64_t res1; - uint32_t seqnum; - uint32_t reliable:1; - uint32_t res2:15; - enum mhi_dev_ring_element_type_id type:8; - uint32_t chid:8; -} __packed; - -enum mhi_dev_cmd_completion_code { - MHI_CMD_COMPL_CODE_INVALID = 0, - MHI_CMD_COMPL_CODE_SUCCESS = 1, - MHI_CMD_COMPL_CODE_EOT = 2, - MHI_CMD_COMPL_CODE_OVERFLOW = 3, - MHI_CMD_COMPL_CODE_EOB = 4, - MHI_CMD_COMPL_CODE_UNDEFINED = 16, - MHI_CMD_COMPL_CODE_RING_EL = 17, - MHI_CMD_COMPL_CODE_RES -}; - -/* Event ring elements */ -/* Transfer completion event */ -struct mhi_dev_event_ring_transfer_completion { - uint64_t ptr; - uint32_t len:16; - uint32_t res1:8; - enum mhi_dev_cmd_completion_code code:8; - uint32_t res2:16; - enum mhi_dev_ring_element_type_id type:8; - uint32_t chid:8; -} __packed; - -/* Command completion event */ -struct mhi_dev_event_ring_cmd_completion { - uint64_t ptr; - uint32_t res1:24; - enum mhi_dev_cmd_completion_code code:8; - uint32_t res2:16; - enum mhi_dev_ring_element_type_id type:8; - uint32_t res3:8; -} __packed; - -enum mhi_dev_state { - MHI_DEV_RESET_STATE = 0, - MHI_DEV_READY_STATE, - MHI_DEV_M0_STATE, - MHI_DEV_M1_STATE, - MHI_DEV_M2_STATE, - MHI_DEV_M3_STATE, - MHI_DEV_MAX_STATE, - MHI_DEV_SYSERR_STATE = 0xff -}; - -/* MHI state change event */ -struct mhi_dev_event_ring_state_change { - uint64_t ptr; - uint32_t res1:24; - enum mhi_dev_state mhistate:8; - uint32_t res2:16; - enum mhi_dev_ring_element_type_id type:8; - uint32_t res3:8; -} __packed; - -enum mhi_dev_execenv { - MHI_DEV_SBL_EE = 1, - MHI_DEV_AMSS_EE = 2, - MHI_DEV_UNRESERVED -}; - -/* EE state change event */ -struct mhi_dev_event_ring_ee_state_change { - uint64_t ptr; - uint32_t res1:24; - enum mhi_dev_execenv execenv:8; - uint32_t res2:16; - enum mhi_dev_ring_element_type_id type:8; - uint32_t res3:8; -} __packed; - -/* Generic cmd to parse common details like type and channel id */ -struct mhi_dev_ring_generic { - uint64_t ptr; - uint32_t res1:24; - enum mhi_dev_state mhistate:8; - uint32_t res2:16; - enum mhi_dev_ring_element_type_id type:8; - uint32_t chid:8; -} __packed; - -struct mhi_config { - uint32_t mhi_reg_len; - uint32_t version; - uint32_t event_rings; - uint32_t channels; - uint32_t chdb_offset; - uint32_t erdb_offset; -}; - -#define NUM_CHANNELS 128 -#define HW_CHANNEL_BASE 100 -#define HW_CHANNEL_END 107 -#define MHI_ENV_VALUE 2 -#define MHI_MASK_ROWS_CH_EV_DB 4 -#define TRB_MAX_DATA_SIZE 8192 -#define MHI_CTRL_STATE 25 -#define IPA_DMA_SYNC 1 -#define IPA_DMA_ASYNC 0 - -/*maximum trasnfer completion events buffer*/ -#define MAX_TR_EVENTS 50 -/*maximum event requests */ -#define MHI_MAX_EVT_REQ 50 - -/* Possible ring element types */ -union mhi_dev_ring_element_type { - struct mhi_dev_cmd_ring_op cmd_no_op; - struct mhi_dev_cmd_ring_reset_channel_cmd cmd_reset; - struct mhi_dev_cmd_ring_stop_channel_cmd cmd_stop; - struct mhi_dev_cmd_ring_start_channel_cmd cmd_start; - struct mhi_dev_transfer_ring_element tre; - struct mhi_dev_event_ring_transfer_completion evt_tr_comp; - struct mhi_dev_event_ring_cmd_completion evt_cmd_comp; - struct mhi_dev_event_ring_state_change evt_state_change; - struct mhi_dev_event_ring_ee_state_change evt_ee_state; - struct mhi_dev_ring_generic generic; -}; - -/* Transfer ring element type */ -union mhi_dev_ring_ctx { - struct mhi_dev_cmd_ctx cmd; - struct mhi_dev_ev_ctx ev; - struct mhi_dev_ch_ctx ch; - struct mhi_dev_gen_ctx generic; -}; - -/* MHI host Control and data address region */ -struct mhi_host_addr { - uint32_t ctrl_base_lsb; - uint32_t ctrl_base_msb; - uint32_t ctrl_limit_lsb; - uint32_t ctrl_limit_msb; - uint32_t data_base_lsb; - uint32_t data_base_msb; - uint32_t data_limit_lsb; - uint32_t data_limit_msb; -}; - -/* MHI physical and virtual address region */ -struct mhi_meminfo { - struct device *dev; - uintptr_t pa_aligned; - uintptr_t pa_unaligned; - uintptr_t va_aligned; - uintptr_t va_unaligned; - uintptr_t size; -}; - -struct mhi_addr { - uint64_t host_pa; - uintptr_t device_pa; - uintptr_t device_va; - size_t size; - dma_addr_t phy_addr; - void *virt_addr; - bool use_ipa_dma; -}; - -struct mhi_interrupt_state { - uint32_t mask; - uint32_t status; -}; - -enum mhi_dev_channel_state { - MHI_DEV_CH_UNINT, - MHI_DEV_CH_STARTED, - MHI_DEV_CH_PENDING_START, - MHI_DEV_CH_PENDING_STOP, - MHI_DEV_CH_STOPPED, - MHI_DEV_CH_CLOSED, -}; - -enum mhi_dev_ch_operation { - MHI_DEV_OPEN_CH, - MHI_DEV_CLOSE_CH, - MHI_DEV_READ_CH, - MHI_DEV_READ_WR, - MHI_DEV_POLL, -}; - -enum mhi_ctrl_info { - MHI_STATE_CONFIGURED = 0, - MHI_STATE_CONNECTED = 1, - MHI_STATE_DISCONNECTED = 2, - MHI_STATE_INVAL, -}; - -enum mhi_dev_tr_compl_evt_type { - SEND_EVENT_BUFFER, - SEND_EVENT_RD_OFFSET, -}; - -enum mhi_dev_transfer_type { - MHI_DEV_DMA_SYNC, - MHI_DEV_DMA_ASYNC, -}; -#endif /* _MHI_COMMON_H_ */ diff --git a/fibocom_MHI/src/core/mhi_dtr.c b/fibocom_MHI/src/core/mhi_dtr.c deleted file mode 100644 index 3651ee1..0000000 --- a/fibocom_MHI/src/core/mhi_dtr.c +++ /dev/null @@ -1,181 +0,0 @@ -/* Copyright (c) 2018, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "mhi.h" -#include "mhi_internal.h" - -struct __packed dtr_ctrl_msg { - u32 preamble; - u32 msg_id; - u32 dest_id; - u32 size; - u32 msg; -}; - -#define CTRL_MAGIC (0x4C525443) -#define CTRL_MSG_DTR BIT(0) -#define CTRL_MSG_ID (0x10) - -static int mhi_dtr_tiocmset(struct mhi_controller *mhi_cntrl, - struct mhi_chan *mhi_chan, - u32 tiocm) -{ - struct dtr_ctrl_msg *dtr_msg = NULL; - struct mhi_chan *dtr_chan = mhi_cntrl->dtr_dev->ul_chan; - int ret = 0; - - tiocm &= TIOCM_DTR; - if (mhi_chan->tiocm == tiocm) - return 0; - - mutex_lock(&dtr_chan->mutex); - - dtr_msg = kzalloc(sizeof(*dtr_msg), GFP_KERNEL); - if (!dtr_msg) { - ret = -ENOMEM; - goto tiocm_exit; - } - - dtr_msg->preamble = CTRL_MAGIC; - dtr_msg->msg_id = CTRL_MSG_ID; - dtr_msg->dest_id = mhi_chan->chan; - dtr_msg->size = sizeof(u32); - if (tiocm & TIOCM_DTR) - dtr_msg->msg |= CTRL_MSG_DTR; - - reinit_completion(&dtr_chan->completion); - ret = mhi_queue_transfer(mhi_cntrl->dtr_dev, DMA_TO_DEVICE, dtr_msg, - sizeof(*dtr_msg), MHI_EOT); - if (ret) - goto tiocm_exit; - - ret = wait_for_completion_timeout(&dtr_chan->completion, - msecs_to_jiffies(mhi_cntrl->timeout_ms)); - - if (!ret) { - MHI_ERR("Failed to receive transfer callback\n"); - ret = -EIO; - goto tiocm_exit; - } - - ret = 0; - mhi_chan->tiocm = tiocm; - -tiocm_exit: - kfree(dtr_msg); - mutex_unlock(&dtr_chan->mutex); - - return ret; -} - -long mhi_ioctl(struct mhi_device *mhi_dev, unsigned int cmd, unsigned long arg) -{ - struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; - struct mhi_chan *mhi_chan = mhi_dev->ul_chan; - int ret; - - /* ioctl not supported by this controller */ - if (!mhi_cntrl->dtr_dev) - return -EIO; - - switch (cmd) { - case TIOCMGET: - return mhi_chan->tiocm; - case TIOCMSET: - { - u32 tiocm; - - ret = get_user(tiocm, (u32 *)arg); - if (ret) - return ret; - - return mhi_dtr_tiocmset(mhi_cntrl, mhi_chan, tiocm); - } - default: - break; - } - - return -EINVAL; -} -EXPORT_SYMBOL(mhi_ioctl); - -static void mhi_dtr_xfer_cb(struct mhi_device *mhi_dev, - struct mhi_result *mhi_result) -{ - struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; - struct mhi_chan *dtr_chan = mhi_cntrl->dtr_dev->ul_chan; - - MHI_VERB("Received with status:%d\n", mhi_result->transaction_status); - if (!mhi_result->transaction_status) - complete(&dtr_chan->completion); -} - -static void mhi_dtr_remove(struct mhi_device *mhi_dev) -{ - struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; - - mhi_cntrl->dtr_dev = NULL; -} - -static int mhi_dtr_probe(struct mhi_device *mhi_dev, - const struct mhi_device_id *id) -{ - struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; - int ret; - - MHI_LOG("Enter for DTR control channel\n"); - - ret = mhi_prepare_for_transfer(mhi_dev); - if (!ret) - mhi_cntrl->dtr_dev = mhi_dev; - - MHI_LOG("Exit with ret:%d\n", ret); - - return ret; -} - -static const struct mhi_device_id mhi_dtr_table[] = { - { .chan = "IP_CTRL" }, - { }, -}; - -static struct mhi_driver mhi_dtr_driver = { - .id_table = mhi_dtr_table, - .remove = mhi_dtr_remove, - .probe = mhi_dtr_probe, - .ul_xfer_cb = mhi_dtr_xfer_cb, - .dl_xfer_cb = mhi_dtr_xfer_cb, - .driver = { - .name = "MHI_DTR", - .owner = THIS_MODULE, - } -}; - -int __init mhi_dtr_init(void) -{ - return mhi_driver_register(&mhi_dtr_driver); -} - -void mhi_dtr_exit(void) { - mhi_driver_unregister(&mhi_dtr_driver); -} diff --git a/fibocom_MHI/src/core/mhi_init.c b/fibocom_MHI/src/core/mhi_init.c deleted file mode 100644 index d976411..0000000 --- a/fibocom_MHI/src/core/mhi_init.c +++ /dev/null @@ -1,1442 +0,0 @@ -/* Copyright (c) 2018, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "mhi.h" -#include "mhi_internal.h" - -const char * const mhi_ee_str[MHI_EE_MAX] = { - [MHI_EE_PBL] = "PBL", - [MHI_EE_SBL] = "SBL", - [MHI_EE_AMSS] = "AMSS", - [MHI_EE_RDDM] = "RDDM", - [MHI_EE_WFW] = "WFW", - [MHI_EE_PT] = "PASS THRU", - [MHI_EE_EDL] = "EDL", - [MHI_EE_FP] = "FlashProg", - [MHI_EE_UEFI] = "UEFI", - [MHI_EE_DISABLE_TRANSITION] = "RESET", -}; - -const char * const mhi_state_tran_str[MHI_ST_TRANSITION_MAX] = { - [MHI_ST_TRANSITION_PBL] = "PBL", - [MHI_ST_TRANSITION_READY] = "READY", - [MHI_ST_TRANSITION_SBL] = "SBL", - [MHI_ST_TRANSITION_AMSS] = "AMSS", - [MHI_ST_TRANSITION_FP] = "FlashProg", - [MHI_ST_TRANSITION_BHIE] = "BHIE", -}; - -const char * const mhi_state_str[MHI_STATE_MAX] = { - [MHI_STATE_RESET] = "RESET", - [MHI_STATE_READY] = "READY", - [MHI_STATE_M0] = "M0", - [MHI_STATE_M1] = "M1", - [MHI_STATE_M2] = "M2", - [MHI_STATE_M3] = "M3", - [MHI_STATE_D3] = "D3", - [MHI_STATE_BHI] = "BHI", - [MHI_STATE_SYS_ERR] = "SYS_ERR", -}; - -static const char * const mhi_pm_state_str[] = { - "DISABLE", - "POR", - "M0", - "M1", - "M1->M2", - "M2", - "M?->M3", - "M3", - "M3->M0", - "FW DL Error", - "SYS_ERR Detect", - "SYS_ERR Process", - "SHUTDOWN Process", - "LD or Error Fatal Detect", -}; - -struct mhi_bus mhi_bus; - -const char *to_mhi_pm_state_str(enum MHI_PM_STATE state) -{ - int index = find_last_bit((unsigned long *)&state, 32); - - if (index >= ARRAY_SIZE(mhi_pm_state_str)) - return "Invalid State"; - - return mhi_pm_state_str[index]; -} - -static void mhi_ring_aligned_check(struct mhi_controller *mhi_cntrl, u64 rbase, u64 rlen) { - uint64_t ra; - - ra = rbase; - do_div(ra, roundup_pow_of_two(rlen)); - - if (rbase != ra * roundup_pow_of_two(rlen)) { - MHI_ERR("bad params ring base not aligned 0x%llx align 0x%lx\n", rbase, roundup_pow_of_two(rlen)); - } -} - -void mhi_deinit_free_irq(struct mhi_controller *mhi_cntrl) -{ - int i; - struct mhi_event *mhi_event = mhi_cntrl->mhi_event; - MHI_LOG("enter\n"); - - if (mhi_cntrl->msi_allocated == 1) { - free_irq(mhi_cntrl->irq[0], mhi_event); - return; - } - - - free_irq(mhi_cntrl->irq[0], mhi_cntrl); - - for (i = 0; i < mhi_cntrl->total_ev_rings; i++, mhi_event++) { - if (mhi_event->offload_ev) - continue; - - free_irq(mhi_cntrl->irq[mhi_event->msi], mhi_event); - } -} - -int mhi_init_irq_setup(struct mhi_controller *mhi_cntrl) -{ - int i; - int ret; - struct mhi_event *mhi_event = mhi_cntrl->mhi_event; - - if (mhi_cntrl->msi_allocated == 1) { - for (i = 0; i < mhi_cntrl->total_ev_rings; i++, mhi_event++) { - mhi_event->msi = 0; - } - - ret = request_irq(mhi_cntrl->irq[0], - mhi_msi_handlr, IRQF_SHARED, "mhi", mhi_cntrl->mhi_event); - if (ret) { - MHI_ERR("Error requesting irq:%d, ret=%d\n", mhi_cntrl->irq[0], ret); - } - return ret; - } - - /* for BHI INTVEC msi */ - ret = request_threaded_irq(mhi_cntrl->irq[0], mhi_intvec_handlr, - mhi_intvec_threaded_handlr, IRQF_ONESHOT, - "mhi", mhi_cntrl); - if (ret) - return ret; - - for (i = 0; i < mhi_cntrl->total_ev_rings; i++, mhi_event++) { - if (mhi_event->offload_ev) - continue; - - ret = request_irq(mhi_cntrl->irq[mhi_event->msi], - mhi_msi_handlr, IRQF_SHARED, "mhi", - mhi_event); - if (ret) { - MHI_ERR("Error requesting irq:%d for ev:%d\n", - mhi_cntrl->irq[mhi_event->msi], i); - goto error_request; - } - } - - return 0; - -error_request: - for (--i, --mhi_event; i >= 0; i--, mhi_event--) { - if (mhi_event->offload_ev) - continue; - - free_irq(mhi_cntrl->irq[mhi_event->msi], mhi_event); - } - free_irq(mhi_cntrl->irq[0], mhi_cntrl); - - return ret; -} - -void mhi_deinit_dev_ctxt(struct mhi_controller *mhi_cntrl) -{ - int i; - struct mhi_ctxt *mhi_ctxt = mhi_cntrl->mhi_ctxt; - struct mhi_cmd *mhi_cmd; - struct mhi_event *mhi_event; - struct mhi_ring *ring; - MHI_LOG("enter\n"); - - mhi_cmd = mhi_cntrl->mhi_cmd; - for (i = 0; i < NR_OF_CMD_RINGS; i++, mhi_cmd++) { - ring = &mhi_cmd->ring; - - ring->base = NULL; - ring->iommu_base = 0; - } - - mhi_event = mhi_cntrl->mhi_event; - for (i = 0; i < mhi_cntrl->total_ev_rings; i++, mhi_event++) { - if (mhi_event->offload_ev) - continue; - - ring = &mhi_event->ring; - - ring->base = NULL; - ring->iommu_base = 0; - } - - mhi_free_coherent(mhi_cntrl, sizeof(*mhi_ctxt->ctrl_seg), mhi_ctxt->ctrl_seg, mhi_ctxt->ctrl_seg_addr); - - mhi_cntrl->mhi_ctxt = NULL; -} - -static int mhi_init_debugfs_mhi_states_open(struct inode *inode, - struct file *fp) -{ - return single_open(fp, mhi_debugfs_mhi_states_show, inode->i_private); -} - -static int mhi_init_debugfs_mhi_event_open(struct inode *inode, struct file *fp) -{ - return single_open(fp, mhi_debugfs_mhi_event_show, inode->i_private); -} - -static int mhi_init_debugfs_mhi_chan_open(struct inode *inode, struct file *fp) -{ - return single_open(fp, mhi_debugfs_mhi_chan_show, inode->i_private); -} - -static const struct file_operations debugfs_state_ops = { - .open = mhi_init_debugfs_mhi_states_open, - .release = single_release, - .read = seq_read, -}; - -static const struct file_operations debugfs_ev_ops = { - .open = mhi_init_debugfs_mhi_event_open, - .release = single_release, - .read = seq_read, -}; - -static const struct file_operations debugfs_chan_ops = { - .open = mhi_init_debugfs_mhi_chan_open, - .release = single_release, - .read = seq_read, -}; - -DEFINE_SIMPLE_ATTRIBUTE(debugfs_trigger_reset_fops, NULL, - mhi_debugfs_trigger_reset, "%llu\n"); - -void mhi_init_debugfs(struct mhi_controller *mhi_cntrl) -{ - struct dentry *dentry; - char node[32]; - - if (!mhi_cntrl->parent) - return; - - snprintf(node, sizeof(node), "%04x_%02u:%02u.%02u", - mhi_cntrl->dev_id, mhi_cntrl->domain, mhi_cntrl->bus, - mhi_cntrl->slot); - - dentry = debugfs_create_dir(node, mhi_cntrl->parent); - if (IS_ERR_OR_NULL(dentry)) - return; - - debugfs_create_file("states", 0444, dentry, mhi_cntrl, - &debugfs_state_ops); - debugfs_create_file("events", 0444, dentry, mhi_cntrl, - &debugfs_ev_ops); - debugfs_create_file("chan", 0444, dentry, mhi_cntrl, &debugfs_chan_ops); - debugfs_create_file("reset", 0444, dentry, mhi_cntrl, - &debugfs_trigger_reset_fops); - mhi_cntrl->dentry = dentry; -} - -void mhi_deinit_debugfs(struct mhi_controller *mhi_cntrl) -{ - debugfs_remove_recursive(mhi_cntrl->dentry); - mhi_cntrl->dentry = NULL; -} - -int mhi_init_dev_ctxt(struct mhi_controller *mhi_cntrl) -{ - struct mhi_ctxt *mhi_ctxt; - struct mhi_chan_ctxt *chan_ctxt; - struct mhi_event_ctxt *er_ctxt; - struct mhi_cmd_ctxt *cmd_ctxt; - struct mhi_chan *mhi_chan; - struct mhi_event *mhi_event; - struct mhi_cmd *mhi_cmd; - int ret = -ENOMEM, i; - - atomic_set(&mhi_cntrl->dev_wake, 0); - atomic_set(&mhi_cntrl->alloc_size, 0); - - mhi_ctxt = &mhi_cntrl->data->mhi_ctxt; - - /* setup channel ctxt */ - mhi_ctxt->ctrl_seg = mhi_alloc_coherent(mhi_cntrl, sizeof(*mhi_ctxt->ctrl_seg), - &mhi_ctxt->ctrl_seg_addr, GFP_KERNEL); - if (!mhi_ctxt->ctrl_seg) - goto error_alloc_chan_ctxt; - - MHI_LOG("mhi_ctxt->ctrl_seg = %p\n", mhi_ctxt->ctrl_seg); - if ((unsigned long)mhi_ctxt->ctrl_seg & (4096-1)) { - mhi_free_coherent(mhi_cntrl, sizeof(*mhi_ctxt->ctrl_seg), mhi_ctxt->ctrl_seg, mhi_ctxt->ctrl_seg_addr); - goto error_alloc_chan_ctxt; - } - -/* -+Transfer rings -+-------------- -+MHI channels are logical, unidirectional data pipes between host and device. -+Each channel associated with a single transfer ring. The data direction can be -+either inbound (device to host) or outbound (host to device). Transfer -+descriptors are managed by using transfer rings, which are defined for each -+channel between device and host and resides in the host memory. -+ -+Transfer ring Pointer: Transfer Ring Array -+[Read Pointer (RP)] ----------->[Ring Element] } TD -+[Write Pointer (WP)]- [Ring Element] -+ - [Ring Element] -+ --------->[Ring Element] -+ [Ring Element] -+ -+1. Host allocate memory for transfer ring -+2. Host sets base, read pointer, write pointer in corresponding channel context -+3. Ring is considered empty when RP == WP -+4. Ring is considered full when WP + 1 == RP -+4. RP indicates the next element to be serviced by device -+4. When host new buffer to send, host update the Ring element with buffer information -+5. Host increment the WP to next element -+6. Ring the associated channel DB. -*/ - - mhi_ctxt->chan_ctxt = mhi_ctxt->ctrl_seg->chan_ctxt; - mhi_ctxt->chan_ctxt_addr = mhi_ctxt->ctrl_seg_addr + offsetof(struct mhi_ctrl_seg, chan_ctxt); - - mhi_chan = mhi_cntrl->data->mhi_chan; - chan_ctxt = mhi_ctxt->chan_ctxt; - for (i = 0; i < mhi_cntrl->max_chan; i++, chan_ctxt++, mhi_chan++) { - /* If it's offload channel skip this step */ - if (mhi_chan->offload_ch) - continue; - - chan_ctxt->chstate = MHI_CH_STATE_DISABLED; - chan_ctxt->brstmode = mhi_chan->db_cfg.brstmode; - chan_ctxt->pollcfg = mhi_chan->db_cfg.pollcfg; - chan_ctxt->chtype = cpu_to_le32(mhi_chan->dir); - chan_ctxt->erindex = cpu_to_le32(mhi_chan->er_index); - - mhi_chan->ch_state = MHI_CH_STATE_DISABLED; - mhi_chan->tre_ring.db_addr = &chan_ctxt->wp; - } - -/* -+Event rings -+----------- -+Events from the device to host are organized in event rings and defined in event -+descriptors. Event rings are array of EDs that resides in the host memory. -+ -+Transfer ring Pointer: Event Ring Array -+[Read Pointer (RP)] ----------->[Ring Element] } ED -+[Write Pointer (WP)]- [Ring Element] -+ - [Ring Element] -+ --------->[Ring Element] -+ [Ring Element] -+ -+1. Host allocate memory for event ring -+2. Host sets base, read pointer, write pointer in corresponding channel context -+3. Both host and device has local copy of RP, WP -+3. Ring is considered empty (no events to service) when WP + 1 == RP -+4. Ring is full of events when RP == WP -+4. RP - 1 = last event device programmed -+4. When there is a new event device need to send, device update ED pointed by RP -+5. Device increment RP to next element -+6. Device trigger and interrupt -+ -+Example Operation for data transfer: -+ -+1. Host prepare TD with buffer information -+2. Host increment Chan[id].ctxt.WP -+3. Host ring channel DB register -+4. Device wakes up process the TD -+5. Device generate a completion event for that TD by updating ED -+6. Device increment Event[id].ctxt.RP -+7. Device trigger MSI to wake host -+8. Host wakes up and check event ring for completion event -+9. Host update the Event[i].ctxt.WP to indicate processed of completion event. -*/ - mhi_ctxt->er_ctxt = mhi_ctxt->ctrl_seg->er_ctxt; - mhi_ctxt->er_ctxt_addr = mhi_ctxt->ctrl_seg_addr + offsetof(struct mhi_ctrl_seg, er_ctxt); - - er_ctxt = mhi_ctxt->er_ctxt; - mhi_event = mhi_cntrl->data->mhi_event; - for (i = 0; i < NUM_MHI_EVT_RINGS; i++, er_ctxt++, mhi_event++) { - struct mhi_ring *ring = &mhi_event->ring; - - /* it's a satellite ev, we do not touch it */ - if (mhi_event->offload_ev) - continue; - - er_ctxt->intmodc = 0; - er_ctxt->intmodt = cpu_to_le16(mhi_event->intmod); - er_ctxt->ertype = cpu_to_le32(MHI_ER_TYPE_VALID); - if (mhi_cntrl->msi_allocated == 1) { - mhi_event->msi = 0; - } - er_ctxt->msivec = cpu_to_le32(mhi_event->msi); - mhi_event->db_cfg.db_mode = true; - - ring->el_size = sizeof(struct __packed mhi_tre); - ring->len = ring->el_size * ring->elements; - - ring->alloc_size = ring->len; - - - if (i == 0) - { - ring->pre_aligned = mhi_ctxt->ctrl_seg->event_ring_0; - ring->dma_handle = mhi_ctxt->ctrl_seg_addr + offsetof(struct mhi_ctrl_seg, event_ring_0); - } - else if (i == 1) - { - ring->pre_aligned = mhi_ctxt->ctrl_seg->event_ring_1; - ring->dma_handle = mhi_ctxt->ctrl_seg_addr + offsetof(struct mhi_ctrl_seg, event_ring_1); - } - else if (i == 2) - { - ring->pre_aligned = mhi_ctxt->ctrl_seg->event_ring_2; - ring->dma_handle = mhi_ctxt->ctrl_seg_addr + offsetof(struct mhi_ctrl_seg, event_ring_2); - } - - ring->iommu_base = ring->dma_handle; - ring->base = ring->pre_aligned + (ring->iommu_base - ring->dma_handle); - - ring->rp = ring->wp = ring->base; - er_ctxt->rbase = cpu_to_le64(ring->iommu_base); - er_ctxt->rp = er_ctxt->wp = er_ctxt->rbase; - er_ctxt->rlen = cpu_to_le64(ring->len); - ring->ctxt_wp = &er_ctxt->wp; - - mhi_ring_aligned_check(mhi_cntrl, er_ctxt->rbase, er_ctxt->rlen); - memset(ring->base, 0xCC, ring->len); - } - - mhi_ctxt->cmd_ctxt = mhi_ctxt->ctrl_seg->cmd_ctxt; - mhi_ctxt->cmd_ctxt_addr = mhi_ctxt->ctrl_seg_addr + offsetof(struct mhi_ctrl_seg, cmd_ctxt); - - mhi_cmd = mhi_cntrl->data->mhi_cmd; - cmd_ctxt = mhi_ctxt->cmd_ctxt; - for (i = 0; i < NR_OF_CMD_RINGS; i++, mhi_cmd++, cmd_ctxt++) { - struct mhi_ring *ring = &mhi_cmd->ring; - - ring->el_size = sizeof(struct __packed mhi_tre); - ring->elements = CMD_EL_PER_RING; - ring->len = ring->el_size * ring->elements; - - ring->alloc_size = ring->len; - ring->pre_aligned = mhi_ctxt->ctrl_seg->cmd_ring[i]; - ring->dma_handle = mhi_ctxt->ctrl_seg_addr + offsetof(struct mhi_ctrl_seg, cmd_ring[i]); - ring->iommu_base = ring->dma_handle; - ring->base = ring->pre_aligned + (ring->iommu_base - ring->dma_handle); - - ring->rp = ring->wp = ring->base; - cmd_ctxt->rbase = cpu_to_le64(ring->iommu_base); - cmd_ctxt->rp = cmd_ctxt->wp = cmd_ctxt->rbase; - cmd_ctxt->rlen = cpu_to_le64(ring->len); - ring->ctxt_wp = &cmd_ctxt->wp; - - mhi_ring_aligned_check(mhi_cntrl, cmd_ctxt->rbase, cmd_ctxt->rlen); - } - - mhi_cntrl->mhi_ctxt = mhi_ctxt; - - return 0; - -error_alloc_chan_ctxt: - - return ret; -} - -int mhi_init_mmio(struct mhi_controller *mhi_cntrl) -{ - u32 val; - int i, ret; - struct mhi_chan *mhi_chan; - struct mhi_event *mhi_event; - void __iomem *base = mhi_cntrl->regs; - struct { - u32 offset; - u32 mask; - u32 shift; - u32 val; - } reg_info[] = { - { - CCABAP_HIGHER, U32_MAX, 0, - upper_32_bits(mhi_cntrl->mhi_ctxt->chan_ctxt_addr), - }, - { - CCABAP_LOWER, U32_MAX, 0, - lower_32_bits(mhi_cntrl->mhi_ctxt->chan_ctxt_addr), - }, - { - ECABAP_HIGHER, U32_MAX, 0, - upper_32_bits(mhi_cntrl->mhi_ctxt->er_ctxt_addr), - }, - { - ECABAP_LOWER, U32_MAX, 0, - lower_32_bits(mhi_cntrl->mhi_ctxt->er_ctxt_addr), - }, - { - CRCBAP_HIGHER, U32_MAX, 0, - upper_32_bits(mhi_cntrl->mhi_ctxt->cmd_ctxt_addr), - }, - { - CRCBAP_LOWER, U32_MAX, 0, - lower_32_bits(mhi_cntrl->mhi_ctxt->cmd_ctxt_addr), - }, - - { - MHICTRLBASE_HIGHER, U32_MAX, 0, - upper_32_bits(mhi_cntrl->iova_start), - }, - { - MHICTRLBASE_LOWER, U32_MAX, 0, - lower_32_bits(mhi_cntrl->iova_start), - }, - { - MHIDATABASE_HIGHER, U32_MAX, 0, - upper_32_bits(mhi_cntrl->iova_start), - }, - { - MHIDATABASE_LOWER, U32_MAX, 0, - lower_32_bits(mhi_cntrl->iova_start), - }, - { - MHICTRLLIMIT_HIGHER, U32_MAX, 0, - upper_32_bits(mhi_cntrl->iova_stop), - }, - { - MHICTRLLIMIT_LOWER, U32_MAX, 0, - lower_32_bits(mhi_cntrl->iova_stop), - }, - { - MHIDATALIMIT_HIGHER, U32_MAX, 0, - upper_32_bits(mhi_cntrl->iova_stop), - }, - { - MHIDATALIMIT_LOWER, U32_MAX, 0, - lower_32_bits(mhi_cntrl->iova_stop), - }, - { 0, 0, 0 } - }; - - MHI_LOG("Initializing MMIO\n"); - - MHI_LOG("iova_start = %llx, iova_stop = %llx\n", (u64)mhi_cntrl->iova_start, (u64)mhi_cntrl->iova_stop); - MHI_LOG("cmd_ctxt_addr = %llx\n", (u64)mhi_cntrl->mhi_ctxt->cmd_ctxt_addr); - MHI_LOG("chan_ctxt_addr = %llx\n", (u64)mhi_cntrl->mhi_ctxt->chan_ctxt_addr); - MHI_LOG("er_ctxt_addr = %llx\n", (u64)mhi_cntrl->mhi_ctxt->er_ctxt_addr); - - /* set up DB register for all the chan rings */ - ret = mhi_read_reg_field(mhi_cntrl, base, CHDBOFF, CHDBOFF_CHDBOFF_MASK, - CHDBOFF_CHDBOFF_SHIFT, &val); - if (ret) - return -EIO; - - MHI_LOG("CHDBOFF:0x%x\n", val); - - /* setup wake db */ - mhi_cntrl->wake_db = base + val + (8 * MHI_DEV_WAKE_DB); - mhi_write_reg(mhi_cntrl, mhi_cntrl->wake_db, 4, 0); - mhi_write_reg(mhi_cntrl, mhi_cntrl->wake_db, 0, 0); - mhi_cntrl->wake_set = false; - - /* setup channel db addresses */ - mhi_chan = mhi_cntrl->mhi_chan; - for (i = 0; i < mhi_cntrl->max_chan; i++, val += 8, mhi_chan++) - mhi_chan->tre_ring.db_addr = base + val; - - /* setup event ring db addresses */ - ret = mhi_read_reg_field(mhi_cntrl, base, ERDBOFF, ERDBOFF_ERDBOFF_MASK, - ERDBOFF_ERDBOFF_SHIFT, &val); - if (ret) - return -EIO; - - MHI_LOG("ERDBOFF:0x%x\n", val); - - mhi_event = mhi_cntrl->mhi_event; - for (i = 0; i < mhi_cntrl->total_ev_rings; i++, val += 8, mhi_event++) { - if (mhi_event->offload_ev) - continue; - - mhi_event->ring.db_addr = base + val; - } - - /* set up DB register for primary CMD rings */ - mhi_cntrl->mhi_cmd[PRIMARY_CMD_RING].ring.db_addr = base + CRDB_LOWER; - - MHI_LOG("Programming all MMIO values.\n"); - for (i = 0; reg_info[i].offset; i++) - mhi_write_reg_field(mhi_cntrl, base, reg_info[i].offset, - reg_info[i].mask, reg_info[i].shift, - reg_info[i].val); - - return 0; -} - -void mhi_deinit_chan_ctxt(struct mhi_controller *mhi_cntrl, - struct mhi_chan *mhi_chan) -{ - struct mhi_ring *buf_ring; - struct mhi_ring *tre_ring; - struct mhi_chan_ctxt *chan_ctxt; - - buf_ring = &mhi_chan->buf_ring; - tre_ring = &mhi_chan->tre_ring; - chan_ctxt = &mhi_cntrl->mhi_ctxt->chan_ctxt[mhi_chan->chan]; - - kfree(buf_ring->base); - - buf_ring->base = tre_ring->base = NULL; - chan_ctxt->rbase = cpu_to_le64(0); -} - -int mhi_init_chan_ctxt(struct mhi_controller *mhi_cntrl, - struct mhi_chan *mhi_chan) -{ - struct mhi_ring *buf_ring; - struct mhi_ring *tre_ring; - struct mhi_chan_ctxt *chan_ctxt; - struct mhi_ctxt *mhi_ctxt = mhi_cntrl->mhi_ctxt; - - buf_ring = &mhi_chan->buf_ring; - tre_ring = &mhi_chan->tre_ring; - tre_ring->el_size = sizeof(struct __packed mhi_tre); - tre_ring->len = tre_ring->el_size * tre_ring->elements; - chan_ctxt = &mhi_ctxt->chan_ctxt[mhi_chan->chan]; - - tre_ring->alloc_size = tre_ring->len; - if (MHI_CLIENT_IP_HW_0_IN == mhi_chan->chan) { - tre_ring->pre_aligned = &mhi_ctxt->ctrl_seg->hw_in_chan_ring[mhi_chan->ring]; - tre_ring->dma_handle = mhi_ctxt->ctrl_seg_addr + offsetof(struct mhi_ctrl_seg, hw_in_chan_ring[mhi_chan->ring]); - } - else if (MHI_CLIENT_IP_HW_0_OUT == mhi_chan->chan) { - tre_ring->pre_aligned = &mhi_ctxt->ctrl_seg->hw_out_chan_ring[mhi_chan->ring]; - tre_ring->dma_handle = mhi_ctxt->ctrl_seg_addr + offsetof(struct mhi_ctrl_seg, hw_out_chan_ring[mhi_chan->ring]); - } - else if (MHI_CLIENT_DIAG_IN == mhi_chan->chan) { - tre_ring->pre_aligned = &mhi_ctxt->ctrl_seg->diag_in_chan_ring[mhi_chan->ring]; - tre_ring->dma_handle = mhi_ctxt->ctrl_seg_addr + offsetof(struct mhi_ctrl_seg, diag_in_chan_ring[mhi_chan->ring]); - } - else { - tre_ring->pre_aligned = &mhi_ctxt->ctrl_seg->chan_ring[mhi_chan->ring]; - tre_ring->dma_handle = mhi_ctxt->ctrl_seg_addr + offsetof(struct mhi_ctrl_seg, chan_ring[mhi_chan->ring]); - } - tre_ring->iommu_base = tre_ring->dma_handle; - tre_ring->base = tre_ring->pre_aligned + (tre_ring->iommu_base - tre_ring->dma_handle); - - buf_ring->el_size = sizeof(struct mhi_buf_info); - buf_ring->len = buf_ring->el_size * buf_ring->elements; - buf_ring->base = kzalloc(buf_ring->len, GFP_KERNEL); - MHI_LOG("%d size = %zd\n", __LINE__, buf_ring->len); - - if (!buf_ring->base) { - return -ENOMEM; - } - - chan_ctxt->chstate = MHI_CH_STATE_ENABLED; - chan_ctxt->rbase = cpu_to_le64(tre_ring->iommu_base); - chan_ctxt->rp = chan_ctxt->wp = chan_ctxt->rbase; - chan_ctxt->rlen = cpu_to_le64(tre_ring->len); - tre_ring->ctxt_wp = &chan_ctxt->wp; - - tre_ring->rp = tre_ring->wp = tre_ring->base; - buf_ring->rp = buf_ring->wp = buf_ring->base; - mhi_chan->db_cfg.db_mode = 1; - - mhi_ring_aligned_check(mhi_cntrl, chan_ctxt->rbase, chan_ctxt->rlen); - /* update to all cores */ - smp_wmb(); - - return 0; -} - -int mhi_device_configure(struct mhi_device *mhi_dev, - enum dma_data_direction dir, - struct mhi_buf *cfg_tbl, - int elements) -{ - struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; - struct mhi_chan *mhi_chan; - struct mhi_event_ctxt *er_ctxt; - struct mhi_chan_ctxt *ch_ctxt; - int er_index, chan; - - mhi_chan = (dir == DMA_TO_DEVICE) ? mhi_dev->ul_chan : mhi_dev->dl_chan; - er_index = mhi_chan->er_index; - chan = mhi_chan->chan; - - for (; elements > 0; elements--, cfg_tbl++) { - /* update event context array */ - if (!strcmp(cfg_tbl->name, "ECA")) { - er_ctxt = &mhi_cntrl->mhi_ctxt->er_ctxt[er_index]; - if (sizeof(*er_ctxt) != cfg_tbl->len) { - MHI_ERR( - "Invalid ECA size, expected:%zu actual%zu\n", - sizeof(*er_ctxt), cfg_tbl->len); - return -EINVAL; - } - memcpy((void *)er_ctxt, cfg_tbl->buf, sizeof(*er_ctxt)); - continue; - } - - /* update channel context array */ - if (!strcmp(cfg_tbl->name, "CCA")) { - ch_ctxt = &mhi_cntrl->mhi_ctxt->chan_ctxt[chan]; - if (cfg_tbl->len != sizeof(*ch_ctxt)) { - MHI_ERR( - "Invalid CCA size, expected:%zu actual:%zu\n", - sizeof(*ch_ctxt), cfg_tbl->len); - return -EINVAL; - } - memcpy((void *)ch_ctxt, cfg_tbl->buf, sizeof(*ch_ctxt)); - continue; - } - - return -EINVAL; - } - - return 0; -} - -static int of_parse_ev_cfg(struct mhi_controller *mhi_cntrl, - struct device_node *of_node) -{ - int num, i; - struct mhi_event *mhi_event; - u32 bit_cfg; - - num = NUM_MHI_EVT_RINGS; - - mhi_cntrl->total_ev_rings = num; - mhi_cntrl->mhi_event = mhi_cntrl->data->mhi_event; - - /* populate ev ring */ - mhi_event = mhi_cntrl->mhi_event; - for (i = 0; i < mhi_cntrl->total_ev_rings; i++, mhi_event++) { - mhi_event->er_index = i; - mhi_event->ring.elements = NUM_MHI_EVT_RING_ELEMENTS; //Event ring length in elements - mhi_event->intmod = 1; //Interrupt moderation time in ms - mhi_event->priority = MHI_ER_PRIORITY_MEDIUM; //Event ring priority, set to 1 for now - - mhi_event->msi = 1 + i; //MSI associated with this event ring - if (i == IPA_OUT_EVENT_RING) - { - mhi_event->chan = MHI_CLIENT_IP_HW_0_OUT; //Dedicated channel number, if it's a dedicated event ring - mhi_event->ring.elements = NUM_MHI_IPA_OUT_EVT_RING_ELEMENTS; - mhi_event->priority = MHI_ER_PRIORITY_HIGH; - } - else if (i == IPA_IN_EVENT_RING) - { - mhi_event->chan = MHI_CLIENT_IP_HW_0_IN; //Dedicated channel number, if it's a dedicated event ring - mhi_event->ring.elements = NUM_MHI_IPA_IN_EVT_RING_ELEMENTS; - mhi_event->priority = MHI_ER_PRIORITY_HIGH; - } - else - mhi_event->chan = 0; - - if (mhi_event->chan >= mhi_cntrl->max_chan) - goto error_ev_cfg; - - /* this event ring has a dedicated channel */ - if (mhi_event->chan) - mhi_event->mhi_chan = &mhi_cntrl->mhi_chan[mhi_event->chan]; - - //mhi_event->priority = 1; //Event ring priority, set to 1 for now - mhi_event->db_cfg.brstmode = MHI_BRSTMODE_DISABLE; - - if (mhi_event->chan == MHI_CLIENT_IP_HW_0_OUT || mhi_event->chan == MHI_CLIENT_IP_HW_0_IN) - mhi_event->db_cfg.brstmode = MHI_BRSTMODE_ENABLE; - - if (MHI_INVALID_BRSTMODE(mhi_event->db_cfg.brstmode)) - goto error_ev_cfg; - - mhi_event->db_cfg.process_db = - (mhi_event->db_cfg.brstmode == MHI_BRSTMODE_ENABLE) ? - mhi_db_brstmode : mhi_db_brstmode_disable; - - bit_cfg = (MHI_EV_CFG_BIT_CTRL_EV & 0); - if (bit_cfg & MHI_EV_CFG_BIT_HW_EV) { - mhi_event->hw_ring = true; - mhi_cntrl->hw_ev_rings++; - } else - mhi_cntrl->sw_ev_rings++; - - mhi_event->cl_manage = !!(bit_cfg & MHI_EV_CFG_BIT_CL_MANAGE); - mhi_event->offload_ev = !!(bit_cfg & MHI_EV_CFG_BIT_OFFLOAD_EV); - mhi_event->ctrl_ev = !!(bit_cfg & MHI_EV_CFG_BIT_CTRL_EV); - } - - /* we need msi for each event ring + additional one for BHI */ - mhi_cntrl->msi_required = mhi_cntrl->total_ev_rings + 1; - - return 0; - - error_ev_cfg: - return -EINVAL; -} -static int of_parse_ch_cfg(struct mhi_controller *mhi_cntrl, - struct device_node *of_node) -{ - u32 num, i; - u32 ring = 0; - - struct chan_cfg_t { - const char *chan_name; - u32 chan_id; - u32 elements; - }; - - static struct chan_cfg_t chan_cfg[] = { - //"Qualcomm PCIe Loopback" - {"LOOPBACK", MHI_CLIENT_LOOPBACK_OUT, NUM_MHI_CHAN_RING_ELEMENTS}, - {"LOOPBACK", MHI_CLIENT_LOOPBACK_IN, NUM_MHI_CHAN_RING_ELEMENTS}, - //"Qualcomm PCIe Sahara" - {"SAHARA", MHI_CLIENT_SAHARA_OUT, NUM_MHI_CHAN_RING_ELEMENTS}, - {"SAHARA", MHI_CLIENT_SAHARA_IN, NUM_MHI_CHAN_RING_ELEMENTS}, - //"Qualcomm PCIe Diagnostics" - {"DIAG", MHI_CLIENT_DIAG_OUT, NUM_MHI_CHAN_RING_ELEMENTS}, - {"DIAG", MHI_CLIENT_DIAG_IN, NUM_MHI_DIAG_IN_RING_ELEMENTS}, - //"Qualcomm PCIe QDSS Data" - {"QDSS", MHI_CLIENT_QDSS_OUT, NUM_MHI_CHAN_RING_ELEMENTS}, - {"QDSS", MHI_CLIENT_QDSS_IN, NUM_MHI_CHAN_RING_ELEMENTS}, - //"Qualcomm PCIe EFS" - {"EFS", MHI_CLIENT_EFS_OUT, NUM_MHI_CHAN_RING_ELEMENTS}, - {"EFS", MHI_CLIENT_EFS_IN, NUM_MHI_CHAN_RING_ELEMENTS}, -#ifdef CONFIG_MHI_NETDEV_MBIM - //"Qualcomm PCIe MBIM" - {"MBIM", MHI_CLIENT_MBIM_OUT, NUM_MHI_CHAN_RING_ELEMENTS}, - {"MBIM", MHI_CLIENT_MBIM_IN, NUM_MHI_CHAN_RING_ELEMENTS}, -#else - //"Qualcomm PCIe QMI" - {"QMI0", MHI_CLIENT_QMI_OUT, NUM_MHI_CHAN_RING_ELEMENTS}, - {"QMI0", MHI_CLIENT_QMI_IN, NUM_MHI_CHAN_RING_ELEMENTS}, - //"Qualcomm PCIe QMI" - //{"QMI1", MHI_CLIENT_QMI_2_OUT, NUM_MHI_CHAN_RING_ELEMENTS}, - //{"QMI1", MHI_CLIENT_QMI_2_IN, NUM_MHI_CHAN_RING_ELEMENTS}, -#endif - //"Qualcomm PCIe IP CTRL" - {"IP_CTRL", MHI_CLIENT_IP_CTRL_1_OUT, NUM_MHI_CHAN_RING_ELEMENTS}, - {"IP_CTRL", MHI_CLIENT_IP_CTRL_1_IN, NUM_MHI_CHAN_RING_ELEMENTS}, - - //"Qualcomm PCIe Boot Logging" - //{"BL", MHI_CLIENT_BOOT_LOG_OUT, NUM_MHI_CHAN_RING_ELEMENTS}, - //{"BL", MHI_CLIENT_BOOT_LOG_IN, NUM_MHI_CHAN_RING_ELEMENTS}, - //"Qualcomm PCIe Modem" - {"DUN", MHI_CLIENT_DUN_OUT, NUM_MHI_CHAN_RING_ELEMENTS}, - {"DUN", MHI_CLIENT_DUN_IN, NUM_MHI_CHAN_RING_ELEMENTS}, - //"Qualcomm EDL " - {"EDL", MHI_CLIENT_EDL_OUT, NUM_MHI_CHAN_RING_ELEMENTS}, - {"EDL", MHI_CLIENT_EDL_IN, NUM_MHI_CHAN_RING_ELEMENTS}, - - {"GNSS", MHI_CLIENT_GNSS_OUT, NUM_MHI_CHAN_RING_ELEMENTS}, - {"GNSS", MHI_CLIENT_GNSS_IN, NUM_MHI_CHAN_RING_ELEMENTS}, - - {"AUDIO", MHI_CLIENT_AUDIO_OUT, NUM_MHI_CHAN_RING_ELEMENTS}, - {"AUDIO", MHI_CLIENT_AUDIO_IN, NUM_MHI_CHAN_RING_ELEMENTS}, - //"Qualcomm PCIe WWAN Adapter" - {"IP_HW0", MHI_CLIENT_IP_HW_0_OUT, NUM_MHI_IPA_OUT_RING_ELEMENTS}, - {"IP_HW0", MHI_CLIENT_IP_HW_0_IN, NUM_MHI_IPA_IN_RING_ELEMENTS}, - }; - - mhi_cntrl->max_chan = MHI_MAX_CHANNELS; - num = sizeof(chan_cfg)/sizeof(chan_cfg[0]); - - mhi_cntrl->mhi_chan = mhi_cntrl->data->mhi_chan, - INIT_LIST_HEAD(&mhi_cntrl->lpm_chans); - - /* populate channel configurations */ - for (i = 0; i < num; i++) { - struct mhi_chan *mhi_chan; - u32 chan_id = chan_cfg[i].chan_id; - u32 bit_cfg = 0; - u32 pollcfg = 0; - enum MHI_BRSTMODE brstmode = MHI_BRSTMODE_DISABLE; - - if (chan_id >= mhi_cntrl->max_chan) - goto error_chan_cfg; - - mhi_chan = &mhi_cntrl->mhi_chan[chan_id]; - mhi_chan->chan = chan_id; - mhi_chan->buf_ring.elements = chan_cfg[i].elements; - if (MHI_HW_CHAN(mhi_chan->chan) || mhi_chan->chan == MHI_CLIENT_DIAG_IN) { - mhi_chan->ring = 0; - } - else { - mhi_chan->ring = ring; - ring += mhi_chan->buf_ring.elements; - } - mhi_chan->tre_ring.elements = mhi_chan->buf_ring.elements; - if (chan_id == MHI_CLIENT_IP_HW_0_OUT) - mhi_chan->er_index = IPA_OUT_EVENT_RING; - else if (chan_id == MHI_CLIENT_IP_HW_0_IN) - mhi_chan->er_index = IPA_IN_EVENT_RING; - else - mhi_chan->er_index = PRIMARY_EVENT_RING; - mhi_chan->dir = (chan_cfg[i].chan_id&1) ? INBOUND_CHAN : OUTBOUND_CHAN; - - mhi_chan->db_cfg.pollcfg = pollcfg; - mhi_chan->ee = MHI_EE_AMSS; - if (CHAN_SBL(chan_cfg[i].chan_id)) - mhi_chan->ee = MHI_EE_SBL; - else if (CHAN_EDL(chan_cfg[i].chan_id)) - mhi_chan->ee = MHI_EE_FP; - - mhi_chan->xfer_type = MHI_XFER_BUFFER; - if ((chan_cfg[i].chan_id == MHI_CLIENT_IP_HW_0_OUT || chan_cfg[i].chan_id == MHI_CLIENT_IP_HW_0_IN) - || (chan_cfg[i].chan_id == MHI_CLIENT_IP_SW_0_OUT || chan_cfg[i].chan_id == MHI_CLIENT_IP_SW_0_IN)) - mhi_chan->xfer_type = MHI_XFER_SKB; - - switch (mhi_chan->xfer_type) { - case MHI_XFER_BUFFER: - mhi_chan->gen_tre = mhi_gen_tre; - mhi_chan->queue_xfer = mhi_queue_buf; - break; - case MHI_XFER_SKB: - mhi_chan->queue_xfer = mhi_queue_skb; - break; - case MHI_XFER_SCLIST: - mhi_chan->gen_tre = mhi_gen_tre; - mhi_chan->queue_xfer = mhi_queue_sclist; - break; - case MHI_XFER_NOP: - mhi_chan->queue_xfer = mhi_queue_nop; - break; - default: - goto error_chan_cfg; - } - - mhi_chan->lpm_notify = !!(bit_cfg & MHI_CH_CFG_BIT_LPM_NOTIFY); - mhi_chan->offload_ch = !!(bit_cfg & MHI_CH_CFG_BIT_OFFLOAD_CH); - mhi_chan->db_cfg.reset_req = - !!(bit_cfg & MHI_CH_CFG_BIT_DBMODE_RESET_CH); - mhi_chan->pre_alloc = !!(bit_cfg & MHI_CH_CFG_BIT_PRE_ALLOC); - - if (mhi_chan->pre_alloc && - (mhi_chan->dir != DMA_FROM_DEVICE || - mhi_chan->xfer_type != MHI_XFER_BUFFER)) - goto error_chan_cfg; - - /* if mhi host allocate the buffers then client cannot queue */ - if (mhi_chan->pre_alloc) - mhi_chan->queue_xfer = mhi_queue_nop; - - mhi_chan->name = chan_cfg[i].chan_name; - - if (!mhi_chan->offload_ch) { - if (mhi_chan->chan == MHI_CLIENT_IP_HW_0_OUT || mhi_chan->chan == MHI_CLIENT_IP_HW_0_IN) - brstmode = MHI_BRSTMODE_ENABLE; - - mhi_chan->db_cfg.brstmode = brstmode; - if (MHI_INVALID_BRSTMODE(mhi_chan->db_cfg.brstmode)) - goto error_chan_cfg; - - mhi_chan->db_cfg.process_db = - (mhi_chan->db_cfg.brstmode == - MHI_BRSTMODE_ENABLE) ? - mhi_db_brstmode : mhi_db_brstmode_disable; - } - mhi_chan->configured = true; - - if (mhi_chan->lpm_notify) - list_add_tail(&mhi_chan->node, &mhi_cntrl->lpm_chans); - } - - MHI_LOG("chan ring need %d, chan ring size %zd\n", - ring, sizeof(mhi_cntrl->data->mhi_ctxt.ctrl_seg->chan_ring)/sizeof(struct __packed mhi_tre)); - - if (ring > sizeof(mhi_cntrl->data->mhi_ctxt.ctrl_seg->chan_ring)/sizeof(struct __packed mhi_tre)) - return -ENOMEM; - - return 0; - -error_chan_cfg: - return -EINVAL; -} - -static int of_parse_dt(struct mhi_controller *mhi_cntrl, struct device_node *of_node) -{ - int ret; - - mhi_cntrl->fw_image = NULL; - mhi_cntrl->edl_image = NULL; - mhi_cntrl->fbc_download = 0; - mhi_cntrl->sbl_size = 0; - mhi_cntrl->seg_len = 0; - - /* parse MHI channel configuration */ - ret = of_parse_ch_cfg(mhi_cntrl, of_node); - if (ret) { - MHI_ERR("Error of_parse_ch_cfg ret:%d\n", ret); - return ret; - } - - /* parse MHI event configuration */ - ret = of_parse_ev_cfg(mhi_cntrl, of_node); - if (ret) { - MHI_ERR("Error of_parse_ch_cfg ret:%d\n", ret); - goto error_ev_cfg; - } - - mhi_cntrl->timeout_ms = MHI_TIMEOUT_MS; - - return 0; - - error_ev_cfg: - return ret; -} - -int mhi_register_mhi_controller(struct mhi_controller *mhi_cntrl) -{ - int ret; - int i; - struct mhi_event *mhi_event; - struct mhi_chan *mhi_chan; - struct mhi_cmd *mhi_cmd; - - mhi_cntrl->klog_lvl = MHI_MSG_LVL_ERROR; - - if (!mhi_cntrl->runtime_get || !mhi_cntrl->runtime_put) - return -EINVAL; - - if (!mhi_cntrl->status_cb || !mhi_cntrl->link_status) - return -EINVAL; - - ret = of_parse_dt(mhi_cntrl, NULL); - if (ret) { - MHI_ERR("Error of_parse_dt ret:%d\n", ret); - return -EINVAL; - } - - mhi_cntrl->mhi_cmd = &mhi_cntrl->data->mhi_cmd[0]; - - INIT_LIST_HEAD(&mhi_cntrl->transition_list); - mutex_init(&mhi_cntrl->pm_mutex); - rwlock_init(&mhi_cntrl->pm_lock); - spin_lock_init(&mhi_cntrl->transition_lock); - spin_lock_init(&mhi_cntrl->wlock); - INIT_WORK(&mhi_cntrl->st_worker, mhi_pm_st_worker); - INIT_WORK(&mhi_cntrl->fw_worker, mhi_fw_load_worker); - INIT_WORK(&mhi_cntrl->m1_worker, mhi_pm_m1_worker); - INIT_WORK(&mhi_cntrl->syserr_worker, mhi_pm_sys_err_worker); - init_waitqueue_head(&mhi_cntrl->state_event); - - mhi_cmd = mhi_cntrl->mhi_cmd; - for (i = 0; i < NR_OF_CMD_RINGS; i++, mhi_cmd++) - spin_lock_init(&mhi_cmd->lock); - - mhi_event = mhi_cntrl->mhi_event; - for (i = 0; i < mhi_cntrl->total_ev_rings; i++, mhi_event++) { - if (mhi_event->offload_ev) - continue; - - mhi_event->mhi_cntrl = mhi_cntrl; - spin_lock_init(&mhi_event->lock); - if (mhi_event->ctrl_ev) - tasklet_init(&mhi_event->task, mhi_ctrl_ev_task, - (ulong)mhi_event); - else - tasklet_init(&mhi_event->task, mhi_ev_task, - (ulong)mhi_event); - } - - mhi_chan = mhi_cntrl->mhi_chan; - for (i = 0; i < mhi_cntrl->max_chan; i++, mhi_chan++) { - mutex_init(&mhi_chan->mutex); - init_completion(&mhi_chan->completion); - rwlock_init(&mhi_chan->lock); - } - - mhi_cntrl->parent = mhi_bus.dentry; - - /* add to list */ - mutex_lock(&mhi_bus.lock); - list_add_tail(&mhi_cntrl->node, &mhi_bus.controller_list); - mutex_unlock(&mhi_bus.lock); - - return 0; - -//error_alloc_cmd: - - return -ENOMEM; -}; - -void mhi_unregister_mhi_controller(struct mhi_controller *mhi_cntrl) -{ - mutex_lock(&mhi_bus.lock); - list_del(&mhi_cntrl->node); - mutex_unlock(&mhi_bus.lock); -} - -/* set ptr to control private data */ -static inline void mhi_controller_set_devdata(struct mhi_controller *mhi_cntrl, - void *priv) -{ - mhi_cntrl->priv_data = priv; -} - - -/* allocate mhi controller to register */ -struct mhi_controller *mhi_alloc_controller(size_t size) -{ - struct mhi_controller *mhi_cntrl; - - mhi_cntrl = kzalloc(size + sizeof(*mhi_cntrl) + sizeof(struct mhi_cntrl_data), GFP_KERNEL); - MHI_LOG("%d size = %zd\n", __LINE__, size + sizeof(*mhi_cntrl)); - - if (mhi_cntrl && size) - mhi_controller_set_devdata(mhi_cntrl, mhi_cntrl + 1); - - mhi_cntrl->data = (struct mhi_cntrl_data *)(((char *)mhi_cntrl) + (size + sizeof(*mhi_cntrl))); - - return mhi_cntrl; -} -EXPORT_SYMBOL(mhi_alloc_controller); - -int mhi_prepare_for_power_up(struct mhi_controller *mhi_cntrl) -{ - int ret; - - mutex_lock(&mhi_cntrl->pm_mutex); - - ret = mhi_init_dev_ctxt(mhi_cntrl); - if (ret) { - MHI_ERR("Error with init dev_ctxt\n"); - goto error_dev_ctxt; - } - - ret = mhi_init_irq_setup(mhi_cntrl); - if (ret) { - MHI_ERR("Error setting up irq\n"); - goto error_setup_irq; - } - - /* - * allocate rddm table if specified, this table is for debug purpose - * so we'll ignore erros - */ - if (mhi_cntrl->rddm_size) - mhi_alloc_bhie_table(mhi_cntrl, &mhi_cntrl->rddm_image, - mhi_cntrl->rddm_size); - - mhi_cntrl->pre_init = true; - - mutex_unlock(&mhi_cntrl->pm_mutex); - - return 0; - -error_setup_irq: - mhi_deinit_dev_ctxt(mhi_cntrl); - -error_dev_ctxt: - mutex_unlock(&mhi_cntrl->pm_mutex); - - return ret; -} -EXPORT_SYMBOL(mhi_prepare_for_power_up); - -void mhi_unprepare_after_power_down(struct mhi_controller *mhi_cntrl) -{ - if (mhi_cntrl->fbc_image) { - mhi_free_bhie_table(mhi_cntrl, mhi_cntrl->fbc_image); - mhi_cntrl->fbc_image = NULL; - } - - if (mhi_cntrl->rddm_image) { - mhi_free_bhie_table(mhi_cntrl, mhi_cntrl->rddm_image); - mhi_cntrl->rddm_image = NULL; - } - - mhi_deinit_free_irq(mhi_cntrl); - mhi_deinit_dev_ctxt(mhi_cntrl); - mhi_cntrl->pre_init = false; -} - -/* match dev to drv */ -static int mhi_match(struct device *dev, struct device_driver *drv) -{ - struct mhi_device *mhi_dev = to_mhi_device(dev); - struct mhi_driver *mhi_drv = to_mhi_driver(drv); - const struct mhi_device_id *id; - - for (id = mhi_drv->id_table; id->chan != NULL && id->chan[0] != '\0'; id++) { - if (!strcmp(mhi_dev->chan_name, id->chan)) { - mhi_dev->id = id; - return 1; - } - } - - return 0; -}; - -static void mhi_release_device(struct device *dev) -{ - struct mhi_device *mhi_dev = to_mhi_device(dev); - - kfree(mhi_dev); -} - -struct bus_type mhi_bus_type = { - .name = "mhi", - .dev_name = "mhi", - .match = mhi_match, -}; - -static int mhi_driver_probe(struct device *dev) -{ - struct mhi_device *mhi_dev = to_mhi_device(dev); - struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; - struct device_driver *drv = dev->driver; - struct mhi_driver *mhi_drv = to_mhi_driver(drv); - struct mhi_event *mhi_event; - struct mhi_chan *ul_chan = mhi_dev->ul_chan; - struct mhi_chan *dl_chan = mhi_dev->dl_chan; - bool offload_ch = ((ul_chan && ul_chan->offload_ch) || - (dl_chan && dl_chan->offload_ch)); - - MHI_LOG("%s dev->name = %s\n", __func__, dev_name(dev)); - - /* all offload channels require status_cb to be defined */ - if (offload_ch) { - if (!mhi_dev->status_cb) - return -EINVAL; - mhi_dev->status_cb = mhi_drv->status_cb; - } - - if (ul_chan && !offload_ch) { - if (!mhi_drv->ul_xfer_cb) - return -EINVAL; - ul_chan->xfer_cb = mhi_drv->ul_xfer_cb; - } - - if (dl_chan && !offload_ch) { - if (!mhi_drv->dl_xfer_cb) - return -EINVAL; - dl_chan->xfer_cb = mhi_drv->dl_xfer_cb; - mhi_event = &mhi_cntrl->mhi_event[dl_chan->er_index]; - - /* - * if this channal event ring manage by client, then - * status_cb must be defined so we can send the async - * cb whenever there are pending data - */ - if (mhi_event->cl_manage && !mhi_drv->status_cb) - return -EINVAL; - mhi_dev->status_cb = mhi_drv->status_cb; - } - - return mhi_drv->probe(mhi_dev, mhi_dev->id); -} - -static int mhi_driver_remove(struct device *dev) -{ - struct mhi_device *mhi_dev = to_mhi_device(dev); - struct mhi_driver *mhi_drv = to_mhi_driver(dev->driver); - struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; - struct mhi_chan *mhi_chan; - enum MHI_CH_STATE ch_state[] = { - MHI_CH_STATE_DISABLED, - MHI_CH_STATE_DISABLED - }; - int dir; - - MHI_LOG("Removing device for chan:%s\n", mhi_dev->chan_name); - - /* reset both channels */ - for (dir = 0; dir < 2; dir++) { - mhi_chan = dir ? mhi_dev->ul_chan : mhi_dev->dl_chan; - - if (!mhi_chan) - continue; - - /* wake all threads waiting for completion */ - write_lock_irq(&mhi_chan->lock); - mhi_chan->ccs = MHI_EV_CC_INVALID; - complete_all(&mhi_chan->completion); - write_unlock_irq(&mhi_chan->lock); - - /* move channel state to disable, no more processing */ - mutex_lock(&mhi_chan->mutex); - write_lock_irq(&mhi_chan->lock); - ch_state[dir] = mhi_chan->ch_state; - mhi_chan->ch_state = MHI_CH_STATE_DISABLED; - write_unlock_irq(&mhi_chan->lock); - - /* reset the channel */ - if (!mhi_chan->offload_ch) - mhi_reset_chan(mhi_cntrl, mhi_chan); - } - - /* destroy the device */ - mhi_drv->remove(mhi_dev); - - /* de_init channel if it was enabled */ - for (dir = 0; dir < 2; dir++) { - mhi_chan = dir ? mhi_dev->ul_chan : mhi_dev->dl_chan; - - if (!mhi_chan) - continue; - - if (ch_state[dir] == MHI_CH_STATE_ENABLED && - !mhi_chan->offload_ch) - mhi_deinit_chan_ctxt(mhi_cntrl, mhi_chan); - - mutex_unlock(&mhi_chan->mutex); - } - - /* relinquish any pending votes */ - read_lock_bh(&mhi_cntrl->pm_lock); - while (atomic_read(&mhi_dev->dev_wake)) - mhi_device_put(mhi_dev); - read_unlock_bh(&mhi_cntrl->pm_lock); - - return 0; -} - -int mhi_driver_register(struct mhi_driver *mhi_drv) -{ - struct device_driver *driver = &mhi_drv->driver; - - if (!mhi_drv->probe || !mhi_drv->remove) - return -EINVAL; - - driver->bus = &mhi_bus_type; - driver->probe = mhi_driver_probe; - driver->remove = mhi_driver_remove; - return driver_register(driver); -} -EXPORT_SYMBOL(mhi_driver_register); - -void mhi_driver_unregister(struct mhi_driver *mhi_drv) -{ - driver_unregister(&mhi_drv->driver); -} -EXPORT_SYMBOL(mhi_driver_unregister); - -struct mhi_device *mhi_alloc_device(struct mhi_controller *mhi_cntrl) -{ - struct mhi_device *mhi_dev = kzalloc(sizeof(*mhi_dev), GFP_KERNEL); - struct device *dev; - //MHI_LOG("%d size = %zd\n", __LINE__, sizeof(*mhi_dev)); - - if (!mhi_dev) - return NULL; - - dev = &mhi_dev->dev; - device_initialize(dev); - dev->bus = &mhi_bus_type; - dev->release = mhi_release_device; - dev->parent = mhi_cntrl->dev; - mhi_dev->mhi_cntrl = mhi_cntrl; - mhi_dev->dev_id = mhi_cntrl->dev_id; - mhi_dev->domain = mhi_cntrl->domain; - mhi_dev->bus = mhi_cntrl->bus; - mhi_dev->slot = mhi_cntrl->slot; - mhi_dev->mtu = MHI_MAX_MTU; - atomic_set(&mhi_dev->dev_wake, 0); - - return mhi_dev; -} - -extern int mhi_dtr_init(void); -extern void mhi_dtr_exit(void); -extern int mhi_device_netdev_init(struct dentry *parent); -extern void mhi_device_netdev_exit(void); -extern int mhi_device_uci_init(void); -extern void mhi_device_uci_exit(void); -extern int mhi_controller_qcom_init(void); -extern void mhi_controller_qcom_exit(void); - -static char mhi_version[] = "Fibocom_Linux_PCIE_MHI_Driver_V1.0.5"; -module_param_string(mhi_version, mhi_version, sizeof(mhi_version), S_IRUGO); - -static int __init mhi_init(void) -{ - int ret; - struct dentry *dentry; - - pr_err("INFO:%s %s\n", __func__, mhi_version); - - mutex_init(&mhi_bus.lock); - INIT_LIST_HEAD(&mhi_bus.controller_list); - dentry = debugfs_create_dir("mhi", NULL); - if (!IS_ERR_OR_NULL(dentry)) - mhi_bus.dentry = dentry; - - ret = bus_register(&mhi_bus_type); - if (ret) { - pr_err("Error bus_register ret:%d\n", ret); - return ret; - } - - ret = mhi_dtr_init(); - if (ret) { - pr_err("Error mhi_dtr_init ret:%d\n", ret); - bus_unregister(&mhi_bus_type); - return ret; - } - - ret = mhi_device_netdev_init(dentry); - if (ret) { - pr_err("Error mhi_device_netdev_init ret:%d\n", ret); - } - - ret = mhi_device_uci_init(); - if (ret) { - pr_err("Error mhi_device_uci_init ret:%d\n", ret); - } - - ret = mhi_controller_qcom_init(); - if (ret) { - pr_err("Error mhi_controller_qcom_init ret:%d\n", ret); - } - - return ret; -} - -static void mhi_exit(void) -{ - mhi_controller_qcom_exit(); - mhi_device_uci_exit(); - mhi_device_netdev_exit(); - mhi_dtr_exit(); - bus_unregister(&mhi_bus_type); - debugfs_remove_recursive(mhi_bus.dentry); -} - -module_init(mhi_init); -module_exit(mhi_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_ALIAS("MHI_CORE"); -MODULE_DESCRIPTION("MHI Host Interface"); diff --git a/fibocom_MHI/src/core/mhi_internal.h b/fibocom_MHI/src/core/mhi_internal.h deleted file mode 100644 index 2ab1771..0000000 --- a/fibocom_MHI/src/core/mhi_internal.h +++ /dev/null @@ -1,800 +0,0 @@ -/* Copyright (c) 2018, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef _MHI_INT_H -#define _MHI_INT_H - -#include -#ifndef writel_relaxed -#define writel_relaxed writel -#endif - -#ifndef U32_MAX -#define U32_MAX ((u32)~0U) -#endif - -#if (LINUX_VERSION_CODE <= KERNEL_VERSION( 3,10,108 )) -static inline void reinit_completion(struct completion *x) -{ - x->done = 0; -} -#endif - -extern struct bus_type mhi_bus_type; - -/* MHI mmio register mapping */ -#define PCI_INVALID_READ(val) (val == U32_MAX) - -#define MHIREGLEN (0x0) -#define MHIREGLEN_MHIREGLEN_MASK (0xFFFFFFFF) -#define MHIREGLEN_MHIREGLEN_SHIFT (0) - -#define MHIVER (0x8) -#define MHIVER_MHIVER_MASK (0xFFFFFFFF) -#define MHIVER_MHIVER_SHIFT (0) - -#define MHICFG (0x10) -#define MHICFG_NHWER_MASK (0xFF000000) -#define MHICFG_NHWER_SHIFT (24) -#define MHICFG_NER_MASK (0xFF0000) -#define MHICFG_NER_SHIFT (16) -#define MHICFG_NHWCH_MASK (0xFF00) -#define MHICFG_NHWCH_SHIFT (8) -#define MHICFG_NCH_MASK (0xFF) -#define MHICFG_NCH_SHIFT (0) - -#define CHDBOFF (0x18) -#define CHDBOFF_CHDBOFF_MASK (0xFFFFFFFF) -#define CHDBOFF_CHDBOFF_SHIFT (0) - -#define ERDBOFF (0x20) -#define ERDBOFF_ERDBOFF_MASK (0xFFFFFFFF) -#define ERDBOFF_ERDBOFF_SHIFT (0) - -#define BHIOFF (0x28) -#define BHIOFF_BHIOFF_MASK (0xFFFFFFFF) -#define BHIOFF_BHIOFF_SHIFT (0) - -#define DEBUGOFF (0x30) -#define DEBUGOFF_DEBUGOFF_MASK (0xFFFFFFFF) -#define DEBUGOFF_DEBUGOFF_SHIFT (0) - -#define MHICTRL (0x38) -#define MHICTRL_MHISTATE_MASK (0x0000FF00) -#define MHICTRL_MHISTATE_SHIFT (8) -#define MHICTRL_RESET_MASK (0x2) -#define MHICTRL_RESET_SHIFT (1) - -#define MHISTATUS (0x48) -#define MHISTATUS_MHISTATE_MASK (0x0000FF00) -#define MHISTATUS_MHISTATE_SHIFT (8) -#define MHISTATUS_SYSERR_MASK (0x4) -#define MHISTATUS_SYSERR_SHIFT (2) -#define MHISTATUS_READY_MASK (0x1) -#define MHISTATUS_READY_SHIFT (0) - -#define CCABAP_LOWER (0x58) -#define CCABAP_LOWER_CCABAP_LOWER_MASK (0xFFFFFFFF) -#define CCABAP_LOWER_CCABAP_LOWER_SHIFT (0) - -#define CCABAP_HIGHER (0x5C) -#define CCABAP_HIGHER_CCABAP_HIGHER_MASK (0xFFFFFFFF) -#define CCABAP_HIGHER_CCABAP_HIGHER_SHIFT (0) - -#define ECABAP_LOWER (0x60) -#define ECABAP_LOWER_ECABAP_LOWER_MASK (0xFFFFFFFF) -#define ECABAP_LOWER_ECABAP_LOWER_SHIFT (0) - -#define ECABAP_HIGHER (0x64) -#define ECABAP_HIGHER_ECABAP_HIGHER_MASK (0xFFFFFFFF) -#define ECABAP_HIGHER_ECABAP_HIGHER_SHIFT (0) - -#define CRCBAP_LOWER (0x68) -#define CRCBAP_LOWER_CRCBAP_LOWER_MASK (0xFFFFFFFF) -#define CRCBAP_LOWER_CRCBAP_LOWER_SHIFT (0) - -#define CRCBAP_HIGHER (0x6C) -#define CRCBAP_HIGHER_CRCBAP_HIGHER_MASK (0xFFFFFFFF) -#define CRCBAP_HIGHER_CRCBAP_HIGHER_SHIFT (0) - -#define CRDB_LOWER (0x70) -#define CRDB_LOWER_CRDB_LOWER_MASK (0xFFFFFFFF) -#define CRDB_LOWER_CRDB_LOWER_SHIFT (0) - -#define CRDB_HIGHER (0x74) -#define CRDB_HIGHER_CRDB_HIGHER_MASK (0xFFFFFFFF) -#define CRDB_HIGHER_CRDB_HIGHER_SHIFT (0) - -#define MHICTRLBASE_LOWER (0x80) -#define MHICTRLBASE_LOWER_MHICTRLBASE_LOWER_MASK (0xFFFFFFFF) -#define MHICTRLBASE_LOWER_MHICTRLBASE_LOWER_SHIFT (0) - -#define MHICTRLBASE_HIGHER (0x84) -#define MHICTRLBASE_HIGHER_MHICTRLBASE_HIGHER_MASK (0xFFFFFFFF) -#define MHICTRLBASE_HIGHER_MHICTRLBASE_HIGHER_SHIFT (0) - -#define MHICTRLLIMIT_LOWER (0x88) -#define MHICTRLLIMIT_LOWER_MHICTRLLIMIT_LOWER_MASK (0xFFFFFFFF) -#define MHICTRLLIMIT_LOWER_MHICTRLLIMIT_LOWER_SHIFT (0) - -#define MHICTRLLIMIT_HIGHER (0x8C) -#define MHICTRLLIMIT_HIGHER_MHICTRLLIMIT_HIGHER_MASK (0xFFFFFFFF) -#define MHICTRLLIMIT_HIGHER_MHICTRLLIMIT_HIGHER_SHIFT (0) - -#define MHIDATABASE_LOWER (0x98) -#define MHIDATABASE_LOWER_MHIDATABASE_LOWER_MASK (0xFFFFFFFF) -#define MHIDATABASE_LOWER_MHIDATABASE_LOWER_SHIFT (0) - -#define MHIDATABASE_HIGHER (0x9C) -#define MHIDATABASE_HIGHER_MHIDATABASE_HIGHER_MASK (0xFFFFFFFF) -#define MHIDATABASE_HIGHER_MHIDATABASE_HIGHER_SHIFT (0) - -#define MHIDATALIMIT_LOWER (0xA0) -#define MHIDATALIMIT_LOWER_MHIDATALIMIT_LOWER_MASK (0xFFFFFFFF) -#define MHIDATALIMIT_LOWER_MHIDATALIMIT_LOWER_SHIFT (0) - -#define MHIDATALIMIT_HIGHER (0xA4) -#define MHIDATALIMIT_HIGHER_MHIDATALIMIT_HIGHER_MASK (0xFFFFFFFF) -#define MHIDATALIMIT_HIGHER_MHIDATALIMIT_HIGHER_SHIFT (0) - -/* MHI BHI offfsets */ -#define BHI_BHIVERSION_MINOR (0x00) -#define BHI_BHIVERSION_MAJOR (0x04) -#define BHI_IMGADDR_LOW (0x08) -#define BHI_IMGADDR_HIGH (0x0C) -#define BHI_IMGSIZE (0x10) -#define BHI_RSVD1 (0x14) -#define BHI_IMGTXDB (0x18) -#define BHI_TXDB_SEQNUM_BMSK (0x3FFFFFFF) -#define BHI_TXDB_SEQNUM_SHFT (0) -#define BHI_RSVD2 (0x1C) -#define BHI_INTVEC (0x20) -#define BHI_RSVD3 (0x24) -#define BHI_EXECENV (0x28) -#define BHI_STATUS (0x2C) -#define BHI_ERRCODE (0x30) -#define BHI_ERRDBG1 (0x34) -#define BHI_ERRDBG2 (0x38) -#define BHI_ERRDBG3 (0x3C) -#define BHI_SERIALNUM ( 0x40 ) -#define BHI_SERIALNU (0x40) -#define BHI_SBLANTIROLLVER (0x44) -#define BHI_NUMSEG (0x48) -#define BHI_MSMHWID(n) (0x4C + (0x4 * n)) -#define BHI_OEMPKHASH(n) (0x64 + (0x4 * n)) -#define BHI_RSVD5 (0xC4) -#define BHI_STATUS_MASK (0xC0000000) -#define BHI_STATUS_SHIFT (30) -#define BHI_STATUS_ERROR (3) -#define BHI_STATUS_SUCCESS (2) -#define BHI_STATUS_RESET (0) - -/* MHI BHIE offsets */ -#define BHIE_OFFSET (0x0124) /* BHIE register space offset from BHI base */ -#define BHIE_MSMSOCID_OFFS (BHIE_OFFSET + 0x0000) -#define BHIE_TXVECADDR_LOW_OFFS (BHIE_OFFSET + 0x002C) -#define BHIE_TXVECADDR_HIGH_OFFS (BHIE_OFFSET + 0x0030) -#define BHIE_TXVECSIZE_OFFS (BHIE_OFFSET + 0x0034) -#define BHIE_TXVECDB_OFFS (BHIE_OFFSET + 0x003C) -#define BHIE_TXVECDB_SEQNUM_BMSK (0x3FFFFFFF) -#define BHIE_TXVECDB_SEQNUM_SHFT (0) -#define BHIE_TXVECSTATUS_OFFS (BHIE_OFFSET + 0x0044) -#define BHIE_TXVECSTATUS_SEQNUM_BMSK (0x3FFFFFFF) -#define BHIE_TXVECSTATUS_SEQNUM_SHFT (0) -#define BHIE_TXVECSTATUS_STATUS_BMSK (0xC0000000) -#define BHIE_TXVECSTATUS_STATUS_SHFT (30) -#define BHIE_TXVECSTATUS_STATUS_RESET (0x00) -#define BHIE_TXVECSTATUS_STATUS_XFER_COMPL (0x02) -#define BHIE_TXVECSTATUS_STATUS_ERROR (0x03) -#define BHIE_RXVECADDR_LOW_OFFS (BHIE_OFFSET + 0x0060) -#define BHIE_RXVECADDR_HIGH_OFFS (BHIE_OFFSET + 0x0064) -#define BHIE_RXVECSIZE_OFFS (BHIE_OFFSET + 0x0068) -#define BHIE_RXVECDB_OFFS (BHIE_OFFSET + 0x0070) -#define BHIE_RXVECDB_SEQNUM_BMSK (0x3FFFFFFF) -#define BHIE_RXVECDB_SEQNUM_SHFT (0) -#define BHIE_RXVECSTATUS_OFFS (BHIE_OFFSET + 0x0078) -#define BHIE_RXVECSTATUS_SEQNUM_BMSK (0x3FFFFFFF) -#define BHIE_RXVECSTATUS_SEQNUM_SHFT (0) -#define BHIE_RXVECSTATUS_STATUS_BMSK (0xC0000000) -#define BHIE_RXVECSTATUS_STATUS_SHFT (30) -#define BHIE_RXVECSTATUS_STATUS_RESET (0x00) -#define BHIE_RXVECSTATUS_STATUS_XFER_COMPL (0x02) -#define BHIE_RXVECSTATUS_STATUS_ERROR (0x03) - -struct __packed mhi_event_ctxt { - u32 reserved : 8; - u32 intmodc : 8; - u32 intmodt : 16; - u32 ertype; - u32 msivec; - u64 rbase; - u64 rlen; - u64 rp; - u64 wp; -}; - -struct __packed mhi_chan_ctxt { - u32 chstate : 8; - u32 brstmode : 2; - u32 pollcfg : 6; - u32 reserved : 16; - u32 chtype; - u32 erindex; - u64 rbase; - u64 rlen; - u64 rp; - u64 wp; -}; - -struct __packed mhi_cmd_ctxt { - u32 reserved0; - u32 reserved1; - u32 reserved2; - u64 rbase; - u64 rlen; - u64 rp; - u64 wp; -}; - -struct __packed mhi_tre { - u64 ptr; - u32 dword[2]; -}; - -struct __packed bhi_vec_entry { - u64 dma_addr; - u64 size; -}; - -/* no operation command */ -#define MHI_TRE_CMD_NOOP_PTR cpu_to_le64(0) -#define MHI_TRE_CMD_NOOP_DWORD0 cpu_to_le32(0) -#define MHI_TRE_CMD_NOOP_DWORD1 cpu_to_le32(1 << 16) - -/* channel reset command */ -#define MHI_TRE_CMD_RESET_PTR cpu_to_le64(0) -#define MHI_TRE_CMD_RESET_DWORD0 cpu_to_le32(0) -#define MHI_TRE_CMD_RESET_DWORD1(chid) cpu_to_le32((chid << 24) | (16 << 16)) - -/* channel stop command */ -#define MHI_TRE_CMD_STOP_PTR cpu_to_le64(0) -#define MHI_TRE_CMD_STOP_DWORD0 cpu_to_le32(0) -#define MHI_TRE_CMD_STOP_DWORD1(chid) cpu_to_le32((chid << 24) | (17 << 16)) - -/* channel start command */ -#define MHI_TRE_CMD_START_PTR cpu_to_le64(0) -#define MHI_TRE_CMD_START_DWORD0 cpu_to_le32(0) -#define MHI_TRE_CMD_START_DWORD1(chid) cpu_to_le32((chid << 24) | (18 << 16)) - -#define MHI_TRE_GET_CMD_CHID(tre) ((le32_to_cpu((tre)->dword[1]) >> 24) & 0xFF) - -/* event descriptor macros */ -//#define MHI_TRE_EV_PTR(ptr) (ptr) -//#define MHI_TRE_EV_DWORD0(code, len) ((code << 24) | len) -#define MHI_TRE_EV_DWORD1(chid, type) cpu_to_le32((chid << 24) | (type << 16)) -#define MHI_TRE_GET_EV_PTR(tre) le64_to_cpu((tre)->ptr) -#define MHI_TRE_GET_EV_CODE(tre) ((le32_to_cpu((tre)->dword[0]) >> 24) & 0xFF) -#define MHI_TRE_GET_EV_LEN(tre) (le32_to_cpu((tre)->dword[0]) & 0xFFFF) -#define MHI_TRE_GET_EV_CHID(tre) ((le32_to_cpu((tre)->dword[1]) >> 24) & 0xFF) -#define MHI_TRE_GET_EV_TYPE(tre) ((le32_to_cpu((tre)->dword[1]) >> 16) & 0xFF) -#define MHI_TRE_GET_EV_STATE(tre) ((le32_to_cpu((tre)->dword[0]) >> 24) & 0xFF) -#define MHI_TRE_GET_EV_EXECENV(tre) ((le32_to_cpu((tre)->dword[0]) >> 24) & 0xFF) - - -/* transfer descriptor macros */ -#define MHI_TRE_DATA_PTR(ptr) cpu_to_le64(ptr) -#define MHI_TRE_DATA_DWORD0(len) cpu_to_le32(len & MHI_MAX_MTU) -#define MHI_TRE_DATA_DWORD1(bei, ieot, ieob, chain) cpu_to_le32((2 << 16) | (bei << 10) \ - | (ieot << 9) | (ieob << 8) | chain) - -enum MHI_CMD { - MHI_CMD_NOOP = 0x0, - MHI_CMD_RESET_CHAN = 0x1, - MHI_CMD_STOP_CHAN = 0x2, - MHI_CMD_START_CHAN = 0x3, - MHI_CMD_RESUME_CHAN = 0x4, -}; - -enum MHI_PKT_TYPE { - MHI_PKT_TYPE_INVALID = 0x0, - MHI_PKT_TYPE_NOOP_CMD = 0x1, - MHI_PKT_TYPE_TRANSFER = 0x2, - MHI_PKT_TYPE_RESET_CHAN_CMD = 0x10, - MHI_PKT_TYPE_STOP_CHAN_CMD = 0x11, - MHI_PKT_TYPE_START_CHAN_CMD = 0x12, - MHI_PKT_TYPE_STATE_CHANGE_EVENT = 0x20, - MHI_PKT_TYPE_CMD_COMPLETION_EVENT = 0x21, - MHI_PKT_TYPE_TX_EVENT = 0x22, - MHI_PKT_TYPE_EE_EVENT = 0x40, - MHI_PKT_TYPE_STALE_EVENT, /* internal event */ -}; - -/* MHI transfer completion events */ -enum MHI_EV_CCS { - MHI_EV_CC_INVALID = 0x0, - MHI_EV_CC_SUCCESS = 0x1, - MHI_EV_CC_EOT = 0x2, - MHI_EV_CC_OVERFLOW = 0x3, - MHI_EV_CC_EOB = 0x4, - MHI_EV_CC_OOB = 0x5, - MHI_EV_CC_DB_MODE = 0x6, - MHI_EV_CC_UNDEFINED_ERR = 0x10, - MHI_EV_CC_BAD_TRE = 0x11, -}; - -enum MHI_CH_STATE { - MHI_CH_STATE_DISABLED = 0x0, - MHI_CH_STATE_ENABLED = 0x1, - MHI_CH_STATE_RUNNING = 0x2, - MHI_CH_STATE_SUSPENDED = 0x3, - MHI_CH_STATE_STOP = 0x4, - MHI_CH_STATE_ERROR = 0x5, -}; - -enum MHI_CH_CFG { - MHI_CH_CFG_CHAN_ID = 0, - MHI_CH_CFG_ELEMENTS = 1, - MHI_CH_CFG_ER_INDEX = 2, - MHI_CH_CFG_DIRECTION = 3, - MHI_CH_CFG_BRSTMODE = 4, - MHI_CH_CFG_POLLCFG = 5, - MHI_CH_CFG_EE = 6, - MHI_CH_CFG_XFER_TYPE = 7, - MHI_CH_CFG_BITCFG = 8, - MHI_CH_CFG_MAX -}; - -#define MHI_CH_CFG_BIT_LPM_NOTIFY BIT(0) /* require LPM notification */ -#define MHI_CH_CFG_BIT_OFFLOAD_CH BIT(1) /* satellite mhi devices */ -#define MHI_CH_CFG_BIT_DBMODE_RESET_CH BIT(2) /* require db mode to reset */ -#define MHI_CH_CFG_BIT_PRE_ALLOC BIT(3) /* host allocate buffers for DL */ - -enum MHI_EV_CFG { - MHI_EV_CFG_ELEMENTS = 0, - MHI_EV_CFG_INTMOD = 1, - MHI_EV_CFG_MSI = 2, - MHI_EV_CFG_CHAN = 3, - MHI_EV_CFG_PRIORITY = 4, - MHI_EV_CFG_BRSTMODE = 5, - MHI_EV_CFG_BITCFG = 6, - MHI_EV_CFG_MAX -}; - -#define MHI_EV_CFG_BIT_HW_EV BIT(0) /* hw event ring */ -#define MHI_EV_CFG_BIT_CL_MANAGE BIT(1) /* client manages the event ring */ -#define MHI_EV_CFG_BIT_OFFLOAD_EV BIT(2) /* satellite driver manges it */ -#define MHI_EV_CFG_BIT_CTRL_EV BIT(3) /* ctrl event ring */ - -enum MHI_BRSTMODE { - MHI_BRSTMODE_DISABLE = 0x2, - MHI_BRSTMODE_ENABLE = 0x3, -}; - -#define MHI_INVALID_BRSTMODE(mode) (mode != MHI_BRSTMODE_DISABLE && \ - mode != MHI_BRSTMODE_ENABLE) - -enum MHI_EE { - MHI_EE_PBL = 0x0, /* Primary Boot Loader */ - MHI_EE_SBL = 0x1, /* Secondary Boot Loader */ - MHI_EE_AMSS = 0x2, /* AMSS Firmware */ - MHI_EE_RDDM = 0x3, /* WIFI Ram Dump Debug Module */ - MHI_EE_WFW = 0x4, /* WIFI (WLAN) Firmware */ - MHI_EE_PT = 0x5, /* PassThrough, Non PCIe BOOT (PCIe is BIOS locked, not used for boot */ - MHI_EE_EDL = 0x6, /* PCIe enabled in PBL for emergency download (Non PCIe BOOT) */ - MHI_EE_FP = 0x7, /* FlashProg, Flash Programmer Environment */ - MHI_EE_BHIE = MHI_EE_FP, - MHI_EE_UEFI = 0x8, /* UEFI */ - - MHI_EE_DISABLE_TRANSITION = 0x9, - MHI_EE_MAX -}; - -extern const char * const mhi_ee_str[MHI_EE_MAX]; -#define TO_MHI_EXEC_STR(ee) (((ee) >= MHI_EE_MAX) ? \ - "INVALID_EE" : mhi_ee_str[ee]) - -#define MHI_IN_PBL(ee) (ee == MHI_EE_PBL || ee == MHI_EE_PT || ee == MHI_EE_EDL) - -enum MHI_ST_TRANSITION { - MHI_ST_TRANSITION_PBL, - MHI_ST_TRANSITION_READY, - MHI_ST_TRANSITION_SBL, - MHI_ST_TRANSITION_AMSS, - MHI_ST_TRANSITION_FP, - MHI_ST_TRANSITION_BHIE = MHI_ST_TRANSITION_FP, - MHI_ST_TRANSITION_MAX, -}; - -extern const char * const mhi_state_tran_str[MHI_ST_TRANSITION_MAX]; -#define TO_MHI_STATE_TRANS_STR(state) (((state) >= MHI_ST_TRANSITION_MAX) ? \ - "INVALID_STATE" : mhi_state_tran_str[state]) - -enum MHI_STATE { - MHI_STATE_RESET = 0x0, - MHI_STATE_READY = 0x1, - MHI_STATE_M0 = 0x2, - MHI_STATE_M1 = 0x3, - MHI_STATE_M2 = 0x4, - MHI_STATE_M3 = 0x5, - MHI_STATE_D3 = 0x6, - MHI_STATE_BHI = 0x7, - MHI_STATE_SYS_ERR = 0xFF, - MHI_STATE_MAX, -}; - -extern const char * const mhi_state_str[MHI_STATE_MAX]; -#define TO_MHI_STATE_STR(state) ((state >= MHI_STATE_MAX || \ - !mhi_state_str[state]) ? \ - "INVALID_STATE" : mhi_state_str[state]) - -/* internal power states */ -enum MHI_PM_STATE { - MHI_PM_DISABLE = BIT(0), /* MHI is not enabled */ - MHI_PM_POR = BIT(1), /* reset state */ - MHI_PM_M0 = BIT(2), - MHI_PM_M1 = BIT(3), - MHI_PM_M1_M2_TRANSITION = BIT(4), /* register access not allowed */ - MHI_PM_M2 = BIT(5), - MHI_PM_M3_ENTER = BIT(6), - MHI_PM_M3 = BIT(7), - MHI_PM_M3_EXIT = BIT(8), - MHI_PM_FW_DL_ERR = BIT(9), /* firmware download failure state */ - MHI_PM_SYS_ERR_DETECT = BIT(10), - MHI_PM_SYS_ERR_PROCESS = BIT(11), - MHI_PM_SHUTDOWN_PROCESS = BIT(12), - MHI_PM_LD_ERR_FATAL_DETECT = BIT(13), /* link not accessible */ -}; - -#define MHI_REG_ACCESS_VALID(pm_state) ((pm_state & (MHI_PM_POR | MHI_PM_M0 | \ - MHI_PM_M1 | MHI_PM_M2 | MHI_PM_M3_ENTER | MHI_PM_M3_EXIT | \ - MHI_PM_SYS_ERR_DETECT | MHI_PM_SYS_ERR_PROCESS | \ - MHI_PM_SHUTDOWN_PROCESS | MHI_PM_FW_DL_ERR))) -#define MHI_PM_IN_ERROR_STATE(pm_state) (pm_state >= MHI_PM_FW_DL_ERR) -#define MHI_PM_IN_FATAL_STATE(pm_state) (pm_state == MHI_PM_LD_ERR_FATAL_DETECT) -#define MHI_DB_ACCESS_VALID(pm_state) (pm_state & (MHI_PM_M0 | MHI_PM_M1)) -#define MHI_WAKE_DB_ACCESS_VALID(pm_state) (pm_state & (MHI_PM_M0 | \ - MHI_PM_M1 | MHI_PM_M2)) -#define MHI_EVENT_ACCESS_INVALID(pm_state) (pm_state == MHI_PM_DISABLE || \ - MHI_PM_IN_ERROR_STATE(pm_state)) -#define MHI_PM_IN_SUSPEND_STATE(pm_state) (pm_state & \ - (MHI_PM_M3_ENTER | MHI_PM_M3)) - -/* accepted buffer type for the channel */ -enum MHI_XFER_TYPE { - MHI_XFER_BUFFER, - MHI_XFER_SKB, - MHI_XFER_SCLIST, - MHI_XFER_NOP, /* CPU offload channel, host does not accept transfer */ -}; - -#define NR_OF_CMD_RINGS (1) -#define CMD_EL_PER_RING (128) -#define PRIMARY_CMD_RING (0) -#define MHI_DEV_WAKE_DB (127) -#define MHI_M2_DEBOUNCE_TMR_US (10000) -#define MHI_MAX_MTU (0xffff) - -enum MHI_ER_TYPE { - MHI_ER_TYPE_INVALID = 0x0, - MHI_ER_TYPE_VALID = 0x1, -}; - -struct db_cfg { - bool reset_req; - bool db_mode; - u32 pollcfg; - enum MHI_BRSTMODE brstmode; - dma_addr_t db_val; - void (*process_db)(struct mhi_controller *mhi_cntrl, - struct db_cfg *db_cfg, void __iomem *io_addr, - dma_addr_t db_val); -}; - -struct mhi_pm_transitions { - enum MHI_PM_STATE from_state; - u32 to_states; -}; - -struct state_transition { - struct list_head node; - enum MHI_ST_TRANSITION state; -}; - -/* Control Segment */ -struct mhi_ctrl_seg -{ - struct __packed mhi_tre hw_in_chan_ring[NUM_MHI_IPA_IN_RING_ELEMENTS] __aligned(NUM_MHI_IPA_IN_RING_ELEMENTS*16); - struct __packed mhi_tre hw_out_chan_ring[NUM_MHI_IPA_OUT_RING_ELEMENTS] __aligned(NUM_MHI_IPA_OUT_RING_ELEMENTS*16); - struct __packed mhi_tre diag_in_chan_ring[NUM_MHI_IPA_OUT_RING_ELEMENTS] __aligned(NUM_MHI_IPA_OUT_RING_ELEMENTS*16); - struct __packed mhi_tre chan_ring[NUM_MHI_CHAN_RING_ELEMENTS*2*12] __aligned(NUM_MHI_CHAN_RING_ELEMENTS*16); - //struct __packed mhi_tre event_ring[NUM_MHI_EVT_RINGS][NUM_MHI_EVT_RING_ELEMENTS] __aligned(NUM_MHI_EVT_RING_ELEMENTS*16); - struct __packed mhi_tre event_ring_0[NUM_MHI_EVT_RING_ELEMENTS] __aligned(NUM_MHI_EVT_RING_ELEMENTS*16); - struct __packed mhi_tre event_ring_1[NUM_MHI_IPA_OUT_EVT_RING_ELEMENTS] __aligned(NUM_MHI_IPA_OUT_EVT_RING_ELEMENTS*16); - struct __packed mhi_tre event_ring_2[NUM_MHI_IPA_IN_EVT_RING_ELEMENTS] __aligned(NUM_MHI_IPA_IN_EVT_RING_ELEMENTS*16); - struct __packed mhi_tre cmd_ring[NR_OF_CMD_RINGS][CMD_EL_PER_RING] __aligned(CMD_EL_PER_RING*16); - - struct mhi_chan_ctxt chan_ctxt[NUM_MHI_XFER_RINGS] __aligned(128); - struct mhi_event_ctxt er_ctxt[NUM_MHI_EVT_RINGS] __aligned(128); - struct mhi_cmd_ctxt cmd_ctxt[NR_OF_CMD_RINGS] __aligned(128); -} __aligned(4096); - -struct mhi_ctxt { - struct mhi_event_ctxt *er_ctxt; - struct mhi_chan_ctxt *chan_ctxt; - struct mhi_cmd_ctxt *cmd_ctxt; - dma_addr_t er_ctxt_addr; - dma_addr_t chan_ctxt_addr; - dma_addr_t cmd_ctxt_addr; - struct mhi_ctrl_seg *ctrl_seg; - dma_addr_t ctrl_seg_addr; -}; - -struct mhi_ring { - dma_addr_t dma_handle; - dma_addr_t iommu_base; - u64 *ctxt_wp; /* point to ctxt wp */ - void *pre_aligned; - void *base; - void *rp; - void *wp; - size_t el_size; - size_t len; - size_t elements; - size_t alloc_size; - void __iomem *db_addr; -}; - -struct mhi_cmd { - struct mhi_ring ring; - spinlock_t lock; -}; - -struct mhi_buf_info { - dma_addr_t p_addr; - void *v_addr; - void *wp; - size_t len; - void *cb_buf; - enum dma_data_direction dir; -}; - -struct mhi_event { - u32 er_index; - u32 intmod; - u32 msi; - int chan; /* this event ring is dedicated to a channel */ - u32 priority; - struct mhi_ring ring; - struct db_cfg db_cfg; - bool hw_ring; - bool cl_manage; - bool offload_ev; /* managed by a device driver */ - bool ctrl_ev; - spinlock_t lock; - struct mhi_chan *mhi_chan; /* dedicated to channel */ - struct tasklet_struct task; - struct mhi_controller *mhi_cntrl; -}; - -struct mhi_chan { - u32 chan; - u32 ring; - const char *name; - /* - * important, when consuming increment tre_ring first, when releasing - * decrement buf_ring first. If tre_ring has space, buf_ring - * guranteed to have space so we do not need to check both rings. - */ - struct mhi_ring buf_ring; - struct mhi_ring tre_ring; - u32 er_index; - u32 intmod; - u32 tiocm; - u32 full; - enum dma_data_direction dir; - struct db_cfg db_cfg; - enum MHI_EE ee; - enum MHI_XFER_TYPE xfer_type; - enum MHI_CH_STATE ch_state; - enum MHI_EV_CCS ccs; - bool lpm_notify; - bool configured; - bool offload_ch; - bool pre_alloc; - /* functions that generate the transfer ring elements */ - int (*gen_tre)(struct mhi_controller *mhi_cntrl, - struct mhi_chan *mhi_chan, void *buf, void *cb, - size_t len, enum MHI_FLAGS flags); - int (*queue_xfer)(struct mhi_device *mhi_dev, struct mhi_chan *mhi_chan, - void *buf, size_t len, enum MHI_FLAGS flags); - /* xfer call back */ - struct mhi_device *mhi_dev; - void (*xfer_cb)(struct mhi_device *mhi_dev, struct mhi_result *res); - struct mutex mutex; - struct completion completion; - rwlock_t lock; - struct list_head node; -}; - -struct mhi_bus { - struct list_head controller_list; - struct mutex lock; - struct dentry *dentry; -}; - -struct mhi_cntrl_data { - struct mhi_ctxt mhi_ctxt; - struct mhi_cmd mhi_cmd[NR_OF_CMD_RINGS]; - struct mhi_event mhi_event[NUM_MHI_EVT_RINGS]; - struct mhi_chan mhi_chan[MHI_MAX_CHANNELS]; -}; - -/* default MHI timeout */ -#define MHI_TIMEOUT_MS (3000) -extern struct mhi_bus mhi_bus; - -/* debug fs related functions */ -int mhi_debugfs_mhi_chan_show(struct seq_file *m, void *d); -int mhi_debugfs_mhi_event_show(struct seq_file *m, void *d); -int mhi_debugfs_mhi_states_show(struct seq_file *m, void *d); -int mhi_debugfs_trigger_reset(void *data, u64 val); - -void mhi_deinit_debugfs(struct mhi_controller *mhi_cntrl); -void mhi_init_debugfs(struct mhi_controller *mhi_cntrl); - -/* power management apis */ -enum MHI_PM_STATE __must_check mhi_tryset_pm_state( - struct mhi_controller *mhi_cntrl, - enum MHI_PM_STATE state); -const char *to_mhi_pm_state_str(enum MHI_PM_STATE state); -void mhi_reset_chan(struct mhi_controller *mhi_cntrl, - struct mhi_chan *mhi_chan); -enum MHI_EE mhi_get_exec_env(struct mhi_controller *mhi_cntrl); -enum MHI_STATE mhi_get_m_state(struct mhi_controller *mhi_cntrl); -int mhi_queue_state_transition(struct mhi_controller *mhi_cntrl, - enum MHI_ST_TRANSITION state); -void mhi_pm_st_worker(struct work_struct *work); -void mhi_fw_load_worker(struct work_struct *work); -void mhi_pm_m1_worker(struct work_struct *work); -void mhi_pm_sys_err_worker(struct work_struct *work); -int mhi_ready_state_transition(struct mhi_controller *mhi_cntrl); -void mhi_ctrl_ev_task(unsigned long data); -int mhi_pm_m0_transition(struct mhi_controller *mhi_cntrl); -void mhi_pm_m1_transition(struct mhi_controller *mhi_cntrl); -int mhi_pm_m3_transition(struct mhi_controller *mhi_cntrl); -void mhi_notify(struct mhi_device *mhi_dev, enum MHI_CB cb_reason); - -/* queue transfer buffer */ -int mhi_gen_tre(struct mhi_controller *mhi_cntrl, struct mhi_chan *mhi_chan, - void *buf, void *cb, size_t buf_len, enum MHI_FLAGS flags); -int mhi_queue_buf(struct mhi_device *mhi_dev, struct mhi_chan *mhi_chan, - void *buf, size_t len, enum MHI_FLAGS mflags); -int mhi_queue_skb(struct mhi_device *mhi_dev, struct mhi_chan *mhi_chan, - void *buf, size_t len, enum MHI_FLAGS mflags); -int mhi_queue_sclist(struct mhi_device *mhi_dev, struct mhi_chan *mhi_chan, - void *buf, size_t len, enum MHI_FLAGS mflags); -int mhi_queue_nop(struct mhi_device *mhi_dev, struct mhi_chan *mhi_chan, - void *buf, size_t len, enum MHI_FLAGS mflags); - - -/* register access methods */ -void mhi_db_brstmode(struct mhi_controller *mhi_cntrl, struct db_cfg *db_cfg, - void __iomem *db_addr, dma_addr_t wp); -void mhi_db_brstmode_disable(struct mhi_controller *mhi_cntrl, - struct db_cfg *db_mode, void __iomem *db_addr, - dma_addr_t wp); -int __must_check mhi_read_reg(struct mhi_controller *mhi_cntrl, - void __iomem *base, u32 offset, u32 *out); -int __must_check mhi_read_reg_field(struct mhi_controller *mhi_cntrl, - void __iomem *base, u32 offset, u32 mask, - u32 shift, u32 *out); -void mhi_write_reg(struct mhi_controller *mhi_cntrl, void __iomem *base, - u32 offset, u32 val); -void mhi_write_reg_field(struct mhi_controller *mhi_cntrl, void __iomem *base, - u32 offset, u32 mask, u32 shift, u32 val); -void mhi_ring_er_db(struct mhi_event *mhi_event); -void mhi_write_db(struct mhi_controller *mhi_cntrl, void __iomem *db_addr, - dma_addr_t wp); -void mhi_ring_cmd_db(struct mhi_controller *mhi_cntrl, struct mhi_cmd *mhi_cmd); -void mhi_ring_chan_db(struct mhi_controller *mhi_cntrl, - struct mhi_chan *mhi_chan); -void mhi_set_mhi_state(struct mhi_controller *mhi_cntrl, enum MHI_STATE state); - -/* memory allocation methods */ - -#if (LINUX_VERSION_CODE >= KERNEL_VERSION( 5,3,0 )) -static inline void *dma_zalloc_coherent(struct device *dev, size_t size, - dma_addr_t *dma_handle, gfp_t flag) -{ - void *ret = dma_alloc_coherent(dev, size, dma_handle, - flag | __GFP_ZERO); - return ret; -} -#endif - -static inline void *mhi_alloc_coherent(struct mhi_controller *mhi_cntrl, - size_t size, - dma_addr_t *dma_handle, - gfp_t gfp) -{ - void *buf = dma_zalloc_coherent(mhi_cntrl->dev, size, dma_handle, gfp); - - MHI_LOG("size = %zd, dma_handle = %llx\n", size, (u64)*dma_handle); - if (buf) { - //if (*dma_handle < mhi_cntrl->iova_start || 0 == mhi_cntrl->iova_start) - // mhi_cntrl->iova_start = (*dma_handle)&0xFFF0000000; - //if ((*dma_handle + size) > mhi_cntrl->iova_stop || 0 == mhi_cntrl->iova_stop) - // mhi_cntrl->iova_stop = ((*dma_handle + size)+0x0FFFFFFF)&0xFFF0000000; - } - if (buf) - atomic_add(size, &mhi_cntrl->alloc_size); - - return buf; -} -static inline void mhi_free_coherent(struct mhi_controller *mhi_cntrl, - size_t size, - void *vaddr, - dma_addr_t dma_handle) -{ - atomic_sub(size, &mhi_cntrl->alloc_size); - dma_free_coherent(mhi_cntrl->dev, size, vaddr, dma_handle); -} -struct mhi_device *mhi_alloc_device(struct mhi_controller *mhi_cntrl); -static inline void mhi_dealloc_device(struct mhi_controller *mhi_cntrl, - struct mhi_device *mhi_dev) -{ - kfree(mhi_dev); -} -int mhi_destroy_device(struct device *dev, void *data); -void mhi_create_devices(struct mhi_controller *mhi_cntrl); -int mhi_alloc_bhie_table(struct mhi_controller *mhi_cntrl, - struct image_info **image_info, size_t alloc_size); -void mhi_free_bhie_table(struct mhi_controller *mhi_cntrl, - struct image_info *image_info); - -/* initialization methods */ -int mhi_init_chan_ctxt(struct mhi_controller *mhi_cntrl, - struct mhi_chan *mhi_chan); -void mhi_deinit_chan_ctxt(struct mhi_controller *mhi_cntrl, - struct mhi_chan *mhi_chan); -int mhi_init_mmio(struct mhi_controller *mhi_cntrl); -int mhi_init_dev_ctxt(struct mhi_controller *mhi_cntrl); -void mhi_deinit_dev_ctxt(struct mhi_controller *mhi_cntrl); -int mhi_init_irq_setup(struct mhi_controller *mhi_cntrl); -void mhi_deinit_free_irq(struct mhi_controller *mhi_cntrl); -int mhi_dtr_init(void); - -/* isr handlers */ -irqreturn_t mhi_msi_handlr(int irq_number, void *dev); -irqreturn_t mhi_intvec_threaded_handlr(int irq_number, void *dev); -irqreturn_t mhi_intvec_handlr(int irq_number, void *dev); -void mhi_ev_task(unsigned long data); - -#ifdef CONFIG_MHI_DEBUG - -#define MHI_ASSERT(cond, msg) do { \ - if (cond) \ - panic(msg); \ -} while (0) - -#else - -#define MHI_ASSERT(cond, msg) do { \ - if (cond) { \ - MHI_ERR(msg); \ - WARN_ON(cond); \ - } \ -} while (0) - -#endif - -#endif /* _MHI_INT_H */ diff --git a/fibocom_MHI/src/core/mhi_main.c b/fibocom_MHI/src/core/mhi_main.c deleted file mode 100644 index feae931..0000000 --- a/fibocom_MHI/src/core/mhi_main.c +++ /dev/null @@ -1,1612 +0,0 @@ -/* Copyright (c) 2018, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "mhi.h" -#include "mhi_internal.h" - -static void __mhi_unprepare_channel(struct mhi_controller *mhi_cntrl, - struct mhi_chan *mhi_chan); - -int __must_check mhi_read_reg(struct mhi_controller *mhi_cntrl, - void __iomem *base, - u32 offset, - u32 *out) -{ - u32 tmp = readl_relaxed(base + offset); - - /* unexpected value, query the link status */ - if (PCI_INVALID_READ(tmp) && - mhi_cntrl->link_status(mhi_cntrl, mhi_cntrl->priv_data)) - return -EIO; - - *out = tmp; - - return 0; -} - -int __must_check mhi_read_reg_field(struct mhi_controller *mhi_cntrl, - void __iomem *base, - u32 offset, - u32 mask, - u32 shift, - u32 *out) -{ - u32 tmp; - int ret; - - ret = mhi_read_reg(mhi_cntrl, base, offset, &tmp); - if (ret) - return ret; - - *out = (tmp & mask) >> shift; - - return 0; -} - -void mhi_write_reg(struct mhi_controller *mhi_cntrl, - void __iomem *base, - u32 offset, - u32 val) -{ - writel_relaxed(val, base + offset); -} - -void mhi_write_reg_field(struct mhi_controller *mhi_cntrl, - void __iomem *base, - u32 offset, - u32 mask, - u32 shift, - u32 val) -{ - int ret; - u32 tmp; - - ret = mhi_read_reg(mhi_cntrl, base, offset, &tmp); - if (ret) - return; - - tmp &= ~mask; - tmp |= (val << shift); - mhi_write_reg(mhi_cntrl, base, offset, tmp); -} - -void mhi_write_db(struct mhi_controller *mhi_cntrl, - void __iomem *db_addr, - dma_addr_t wp) -{ - mhi_write_reg(mhi_cntrl, db_addr, 4, upper_32_bits(wp)); - mhi_write_reg(mhi_cntrl, db_addr, 0, lower_32_bits(wp)); -} - -void mhi_db_brstmode(struct mhi_controller *mhi_cntrl, - struct db_cfg *db_cfg, - void __iomem *db_addr, - dma_addr_t wp) -{ - if (db_cfg->db_mode) { - db_cfg->db_val = wp; - mhi_write_db(mhi_cntrl, db_addr, wp); - db_cfg->db_mode = 0; - } -} - -void mhi_db_brstmode_disable(struct mhi_controller *mhi_cntrl, - struct db_cfg *db_cfg, - void __iomem *db_addr, - dma_addr_t wp) -{ - db_cfg->db_val = wp; - mhi_write_db(mhi_cntrl, db_addr, wp); -} - -void mhi_ring_er_db(struct mhi_event *mhi_event) -{ - struct mhi_ring *ring = &mhi_event->ring; - - mhi_event->db_cfg.process_db(mhi_event->mhi_cntrl, &mhi_event->db_cfg, - ring->db_addr, le64_to_cpu(*ring->ctxt_wp)); -} - -void mhi_ring_cmd_db(struct mhi_controller *mhi_cntrl, struct mhi_cmd *mhi_cmd) -{ - dma_addr_t db; - struct mhi_ring *ring = &mhi_cmd->ring; - - db = ring->iommu_base + (ring->wp - ring->base); - *ring->ctxt_wp = cpu_to_le64(db); - mhi_write_db(mhi_cntrl, ring->db_addr, db); -} - -void mhi_ring_chan_db(struct mhi_controller *mhi_cntrl, - struct mhi_chan *mhi_chan) -{ - struct mhi_ring *ring = &mhi_chan->tre_ring; - dma_addr_t db; - - db = ring->iommu_base + (ring->wp - ring->base); - *ring->ctxt_wp = cpu_to_le64(db); - mhi_chan->db_cfg.process_db(mhi_cntrl, &mhi_chan->db_cfg, ring->db_addr, - db); -} - -enum MHI_EE mhi_get_exec_env(struct mhi_controller *mhi_cntrl) -{ - u32 exec; - int ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->bhi, BHI_EXECENV, &exec); - - return (ret) ? MHI_EE_MAX : exec; -} - -enum MHI_STATE mhi_get_m_state(struct mhi_controller *mhi_cntrl) -{ - u32 state; - int ret = mhi_read_reg_field(mhi_cntrl, mhi_cntrl->regs, MHISTATUS, - MHISTATUS_MHISTATE_MASK, - MHISTATUS_MHISTATE_SHIFT, &state); - return ret ? MHI_STATE_MAX : state; -} - -int mhi_queue_sclist(struct mhi_device *mhi_dev, - struct mhi_chan *mhi_chan, - void *buf, - size_t len, - enum MHI_FLAGS mflags) -{ - return -EINVAL; -} - -int mhi_queue_nop(struct mhi_device *mhi_dev, - struct mhi_chan *mhi_chan, - void *buf, - size_t len, - enum MHI_FLAGS mflags) -{ - return -EINVAL; -} - -static void mhi_add_ring_element(struct mhi_controller *mhi_cntrl, - struct mhi_ring *ring) -{ - ring->wp += ring->el_size; - if (ring->wp >= (ring->base + ring->len)) - ring->wp = ring->base; - /* smp update */ - smp_wmb(); -} - -static void mhi_del_ring_element(struct mhi_controller *mhi_cntrl, - struct mhi_ring *ring) -{ - ring->rp += ring->el_size; - if (ring->rp >= (ring->base + ring->len)) - ring->rp = ring->base; - /* smp update */ - smp_wmb(); -} - -static int get_nr_avail_ring_elements(struct mhi_controller *mhi_cntrl, - struct mhi_ring *ring) -{ - int nr_el; - - if (ring->wp < ring->rp) - nr_el = ((ring->rp - ring->wp) / ring->el_size) - 1; - else { - nr_el = (ring->rp - ring->base) / ring->el_size; - nr_el += ((ring->base + ring->len - ring->wp) / - ring->el_size) - 1; - } - return nr_el; -} - -static void *mhi_to_virtual(struct mhi_ring *ring, dma_addr_t addr) -{ - return (addr - ring->iommu_base) + ring->base; -} - -dma_addr_t mhi_to_physical(struct mhi_ring *ring, void *addr) -{ - return (addr - ring->base) + ring->iommu_base; -} - -static void mhi_recycle_ev_ring_element(struct mhi_controller *mhi_cntrl, - struct mhi_ring *ring) -{ - dma_addr_t ctxt_wp; - - /* update the WP */ - ring->wp += ring->el_size; - ctxt_wp = le64_to_cpu(*ring->ctxt_wp) + ring->el_size; - - if (ring->wp >= (ring->base + ring->len)) { - ring->wp = ring->base; - ctxt_wp = ring->iommu_base; - } - - *ring->ctxt_wp = cpu_to_le64(ctxt_wp); - - /* update the RP */ - //memset((unsigned char *)ring->rp, 0x55, ring->el_size); //carl.yin debug - ring->rp += ring->el_size; - if (ring->rp >= (ring->base + ring->len)) - ring->rp = ring->base; - - /* visible to other cores */ - smp_wmb(); -} - -static bool mhi_is_ring_full(struct mhi_controller *mhi_cntrl, - struct mhi_ring *ring) -{ - void *tmp = ring->wp + ring->el_size; - - if (tmp >= (ring->base + ring->len)) - tmp = ring->base; - - return (tmp == ring->rp); -} - -int mhi_queue_skb(struct mhi_device *mhi_dev, - struct mhi_chan *mhi_chan, - void *buf, - size_t len, - enum MHI_FLAGS mflags) -{ - struct sk_buff *skb = buf; - struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; - struct mhi_ring *tre_ring = &mhi_chan->tre_ring; - struct mhi_ring *buf_ring = &mhi_chan->buf_ring; - struct mhi_buf_info *buf_info; - struct mhi_tre *mhi_tre; - - if (mhi_is_ring_full(mhi_cntrl, tre_ring)) - return -ENOMEM; - - read_lock_bh(&mhi_cntrl->pm_lock); - if (unlikely(MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state))) { - MHI_ERR("MHI is not in activate state, pm_state:%s\n", - to_mhi_pm_state_str(mhi_cntrl->pm_state)); - read_unlock_bh(&mhi_cntrl->pm_lock); - - return -EIO; - } - - /* we're in M3 or transitioning to M3 */ - if (MHI_PM_IN_SUSPEND_STATE(mhi_cntrl->pm_state)) { - mhi_cntrl->runtime_get(mhi_cntrl, mhi_cntrl->priv_data); - mhi_cntrl->runtime_put(mhi_cntrl, mhi_cntrl->priv_data); - } - mhi_cntrl->wake_get(mhi_cntrl, false); - - /* generate the tre */ - buf_info = buf_ring->wp; - buf_info->v_addr = skb->data; - buf_info->cb_buf = skb; - buf_info->wp = tre_ring->wp; - buf_info->dir = mhi_chan->dir; - buf_info->len = len; - buf_info->p_addr = dma_map_single(mhi_cntrl->dev, buf_info->v_addr, len, - buf_info->dir); - - if (dma_mapping_error(mhi_cntrl->dev, buf_info->p_addr)) - goto map_error; - - mhi_tre = tre_ring->wp; - mhi_tre->ptr = MHI_TRE_DATA_PTR(buf_info->p_addr); - mhi_tre->dword[0] = MHI_TRE_DATA_DWORD0(buf_info->len); - mhi_tre->dword[1] = MHI_TRE_DATA_DWORD1(1, 1, 0, 0); - - MHI_VERB("chan:%d WP:0x%llx TRE:0x%llx 0x%08x 0x%08x\n", mhi_chan->chan, - (u64)mhi_to_physical(tre_ring, mhi_tre), le64_to_cpu(mhi_tre->ptr), - le32_to_cpu(mhi_tre->dword[0]), le32_to_cpu(mhi_tre->dword[1])); - - /* increment WP */ - mhi_add_ring_element(mhi_cntrl, tre_ring); - mhi_add_ring_element(mhi_cntrl, buf_ring); - - if (likely(MHI_DB_ACCESS_VALID(mhi_cntrl->pm_state))) { - read_lock_bh(&mhi_chan->lock); - mhi_ring_chan_db(mhi_cntrl, mhi_chan); - read_unlock_bh(&mhi_chan->lock); - } - - if (mhi_chan->dir == DMA_FROM_DEVICE) { - bool override = (mhi_cntrl->pm_state != MHI_PM_M0); - - mhi_cntrl->wake_put(mhi_cntrl, override); - } - - read_unlock_bh(&mhi_cntrl->pm_lock); - - return 0; - -map_error: - mhi_cntrl->wake_put(mhi_cntrl, false); - read_unlock_bh(&mhi_cntrl->pm_lock); - - return -ENOMEM; -} - -int mhi_gen_tre(struct mhi_controller *mhi_cntrl, - struct mhi_chan *mhi_chan, - void *buf, - void *cb, - size_t buf_len, - enum MHI_FLAGS flags) -{ - struct mhi_ring *buf_ring, *tre_ring; - struct mhi_tre *mhi_tre; - struct mhi_buf_info *buf_info; - int eot, eob, chain, bei; - - buf_ring = &mhi_chan->buf_ring; - tre_ring = &mhi_chan->tre_ring; - - buf_info = buf_ring->wp; - buf_info->v_addr = buf; - buf_info->cb_buf = cb; - buf_info->wp = tre_ring->wp; - buf_info->dir = mhi_chan->dir; - buf_info->len = buf_len; - buf_info->p_addr = dma_map_single(mhi_cntrl->dev, buf, buf_len, - buf_info->dir); - - if (dma_mapping_error(mhi_cntrl->dev, buf_info->p_addr)) - return -ENOMEM; - - eob = !!(flags & MHI_EOB); - eot = !!(flags & MHI_EOT); - chain = !!(flags & MHI_CHAIN); - bei = !!(mhi_chan->intmod); - - mhi_tre = tre_ring->wp; - mhi_tre->ptr = MHI_TRE_DATA_PTR(buf_info->p_addr); - mhi_tre->dword[0] = MHI_TRE_DATA_DWORD0(buf_len); - mhi_tre->dword[1] = MHI_TRE_DATA_DWORD1(bei, eot, eob, chain); - - MHI_VERB("chan:%d WP:0x%llx TRE:0x%llx 0x%08x 0x%08x\n", mhi_chan->chan, - (u64)mhi_to_physical(tre_ring, mhi_tre), le64_to_cpu(mhi_tre->ptr), - le32_to_cpu(mhi_tre->dword[0]), le32_to_cpu(mhi_tre->dword[1])); - - /* increment WP */ - mhi_add_ring_element(mhi_cntrl, tre_ring); - mhi_add_ring_element(mhi_cntrl, buf_ring); - - return 0; -} - -int mhi_queue_buf(struct mhi_device *mhi_dev, - struct mhi_chan *mhi_chan, - void *buf, - size_t len, - enum MHI_FLAGS mflags) -{ - struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; - struct mhi_ring *tre_ring; - unsigned long flags; - int ret; - - read_lock_irqsave(&mhi_cntrl->pm_lock, flags); - if (unlikely(MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state))) { - MHI_ERR("MHI is not in active state, pm_state:%s\n", - to_mhi_pm_state_str(mhi_cntrl->pm_state)); - read_unlock_irqrestore(&mhi_cntrl->pm_lock, flags); - - return -EIO; - } - - /* we're in M3 or transitioning to M3 */ - if (MHI_PM_IN_SUSPEND_STATE(mhi_cntrl->pm_state)) { - mhi_cntrl->runtime_get(mhi_cntrl, mhi_cntrl->priv_data); - mhi_cntrl->runtime_put(mhi_cntrl, mhi_cntrl->priv_data); - } - - mhi_cntrl->wake_get(mhi_cntrl, false); - read_unlock_irqrestore(&mhi_cntrl->pm_lock, flags); - - tre_ring = &mhi_chan->tre_ring; - if (mhi_is_ring_full(mhi_cntrl, tre_ring)) - goto error_queue; - - ret = mhi_chan->gen_tre(mhi_cntrl, mhi_chan, buf, buf, len, mflags); - if (unlikely(ret)) - goto error_queue; - - read_lock_irqsave(&mhi_cntrl->pm_lock, flags); - if (likely(MHI_DB_ACCESS_VALID(mhi_cntrl->pm_state))) { - unsigned long flags; - - read_lock_irqsave(&mhi_chan->lock, flags); - mhi_ring_chan_db(mhi_cntrl, mhi_chan); - read_unlock_irqrestore(&mhi_chan->lock, flags); - } - - if (mhi_chan->dir == DMA_FROM_DEVICE) { - bool override = (mhi_cntrl->pm_state != MHI_PM_M0); - - mhi_cntrl->wake_put(mhi_cntrl, override); - } - - read_unlock_irqrestore(&mhi_cntrl->pm_lock, flags); - - return 0; - -error_queue: - read_lock_irqsave(&mhi_cntrl->pm_lock, flags); - mhi_cntrl->wake_put(mhi_cntrl, false); - read_unlock_irqrestore(&mhi_cntrl->pm_lock, flags); - - return -ENOMEM; -} - -/* destroy specific device */ -int mhi_destroy_device(struct device *dev, void *data) -{ - struct mhi_device *mhi_dev; - struct mhi_driver *mhi_drv; - struct mhi_controller *mhi_cntrl; - struct mhi_chan *mhi_chan; - int dir; - - if (dev->bus != &mhi_bus_type) - return 0; - - mhi_dev = to_mhi_device(dev); - mhi_drv = to_mhi_driver(dev->driver); - mhi_cntrl = mhi_dev->mhi_cntrl; - - MHI_LOG("destroy device for chan:%s\n", mhi_dev->chan_name); - - for (dir = 0; dir < 2; dir++) { - mhi_chan = dir ? mhi_dev->ul_chan : mhi_dev->dl_chan; - - if (!mhi_chan) - continue; - - /* remove device associated with the channel */ - mutex_lock(&mhi_chan->mutex); - mutex_unlock(&mhi_chan->mutex); - } - - /* notify the client and remove the device from mhi bus */ - device_del(dev); - - return 0; -} - -void mhi_notify(struct mhi_device *mhi_dev, enum MHI_CB cb_reason) -{ - struct mhi_driver *mhi_drv; - - if (!mhi_dev->dev.driver) - return; - - mhi_drv = to_mhi_driver(mhi_dev->dev.driver); - - if (mhi_drv->status_cb) - mhi_drv->status_cb(mhi_dev, cb_reason); -} - -/* bind mhi channels into mhi devices */ -void mhi_create_devices(struct mhi_controller *mhi_cntrl) -{ - int i; - struct mhi_chan *mhi_chan; - struct mhi_device *mhi_dev; - int ret; - - mhi_chan = mhi_cntrl->mhi_chan; - for (i = 0; i < mhi_cntrl->max_chan; i++, mhi_chan++) { - if (!mhi_chan->configured || mhi_chan->ee != mhi_cntrl->ee) - continue; - mhi_dev = mhi_alloc_device(mhi_cntrl); - if (!mhi_dev) - return; - - if (mhi_chan->dir == DMA_TO_DEVICE) { - mhi_dev->ul_chan = mhi_chan; - mhi_dev->ul_chan_id = mhi_chan->chan; - mhi_dev->ul_xfer = mhi_chan->queue_xfer; - mhi_dev->ul_event_id = mhi_chan->er_index; - } else { - mhi_dev->dl_chan = mhi_chan; - mhi_dev->dl_chan_id = mhi_chan->chan; - mhi_dev->dl_xfer = mhi_chan->queue_xfer; - mhi_dev->dl_event_id = mhi_chan->er_index; - } - - mhi_chan->mhi_dev = mhi_dev; - - /* check next channel if it matches */ - if ((i + 1) < mhi_cntrl->max_chan && mhi_chan[1].configured) { - if (!strcmp(mhi_chan[1].name, mhi_chan->name)) { - i++; - mhi_chan++; - if (mhi_chan->dir == DMA_TO_DEVICE) { - mhi_dev->ul_chan = mhi_chan; - mhi_dev->ul_chan_id = mhi_chan->chan; - mhi_dev->ul_xfer = mhi_chan->queue_xfer; - mhi_dev->ul_event_id = - mhi_chan->er_index; - } else { - mhi_dev->dl_chan = mhi_chan; - mhi_dev->dl_chan_id = mhi_chan->chan; - mhi_dev->dl_xfer = mhi_chan->queue_xfer; - mhi_dev->dl_event_id = - mhi_chan->er_index; - } - mhi_chan->mhi_dev = mhi_dev; - } - } - - mhi_dev->chan_name = mhi_chan->name; - dev_set_name(&mhi_dev->dev, "%04x_%02u.%02u.%02u_%s", - mhi_dev->dev_id, mhi_dev->domain, mhi_dev->bus, - mhi_dev->slot, mhi_dev->chan_name); - - ret = device_add(&mhi_dev->dev); - if (ret) { - MHI_ERR("Failed to register dev for chan:%s\n", - mhi_dev->chan_name); - mhi_dealloc_device(mhi_cntrl, mhi_dev); - } - } - - //mhi_cntrl->klog_lvl = MHI_MSG_LVL_ERROR; -} - -static int parse_xfer_event(struct mhi_controller *mhi_cntrl, - struct mhi_tre *event, - struct mhi_chan *mhi_chan) -{ - struct mhi_ring *buf_ring, *tre_ring; - u32 ev_code; - struct mhi_result result; - unsigned long flags = 0; - - ev_code = MHI_TRE_GET_EV_CODE(event); - buf_ring = &mhi_chan->buf_ring; - tre_ring = &mhi_chan->tre_ring; - - if (CHAN_INBOUND(mhi_chan->chan) && (tre_ring->rp + tre_ring->el_size == tre_ring->wp)) { - mhi_chan->full++; - } - - result.transaction_status = (ev_code == MHI_EV_CC_OVERFLOW) ? - -EOVERFLOW : 0; - - /* - * if it's a DB Event then we need to grab the lock - * with preemption disable and as a write because we - * have to update db register and another thread could - * be doing same. - */ - if (ev_code >= MHI_EV_CC_OOB) - write_lock_irqsave(&mhi_chan->lock, flags); - else - read_lock_bh(&mhi_chan->lock); - - if (mhi_chan->ch_state != MHI_CH_STATE_ENABLED) - goto end_process_tx_event; - - switch (ev_code) { - case MHI_EV_CC_OVERFLOW: - case MHI_EV_CC_EOB: - case MHI_EV_CC_EOT: - { - dma_addr_t ptr = MHI_TRE_GET_EV_PTR(event); - struct mhi_tre *local_rp, *ev_tre; - void *dev_rp; - struct mhi_buf_info *buf_info; - u16 xfer_len; - - /* Get the TRB this event points to */ - ev_tre = mhi_to_virtual(tre_ring, ptr); - - /* device rp after servicing the TREs */ - dev_rp = ev_tre + 1; - if (dev_rp >= (tre_ring->base + tre_ring->len)) - dev_rp = tre_ring->base; - - result.dir = mhi_chan->dir; - - /* local rp */ - local_rp = tre_ring->rp; - MHI_VERB("base=%p, local_wp=%p, local_rp=%p, dev_rp=%p\n", tre_ring->base, tre_ring->wp, tre_ring->rp, dev_rp); - while (local_rp != dev_rp) { - buf_info = buf_ring->rp; - /* if it's last tre get len from the event */ - if (local_rp == ev_tre) - xfer_len = MHI_TRE_GET_EV_LEN(event); - else - xfer_len = buf_info->len; - - dma_unmap_single(mhi_cntrl->dev, buf_info->p_addr, - buf_info->len, buf_info->dir); - - result.buf_addr = buf_info->cb_buf; - result.bytes_xferd = xfer_len; - mhi_del_ring_element(mhi_cntrl, buf_ring); - mhi_del_ring_element(mhi_cntrl, tre_ring); - local_rp = tre_ring->rp; - - MHI_VERB("buf_addr=%p, bytes_xferd=%zd\n", result.buf_addr, result.bytes_xferd); - /* notify client */ - mhi_chan->xfer_cb(mhi_chan->mhi_dev, &result); - - if (mhi_chan->dir == DMA_TO_DEVICE) { - read_lock_bh(&mhi_cntrl->pm_lock); - mhi_cntrl->wake_put(mhi_cntrl, false); - read_unlock_bh(&mhi_cntrl->pm_lock); - } - - /* - * recycle the buffer if buffer is pre-allocated, - * if there is error, not much we can do apart from - * dropping the packet - */ - if (mhi_chan->pre_alloc) { - if (mhi_queue_buf(mhi_chan->mhi_dev, mhi_chan, - buf_info->cb_buf, - buf_info->len, MHI_EOT)) { - MHI_ERR( - "Error recycling buffer for chan:%d\n", - mhi_chan->chan); - kfree(buf_info->cb_buf); - } - } - }; - break; - } /* CC_EOT */ - case MHI_EV_CC_OOB: - case MHI_EV_CC_DB_MODE: - { - unsigned long flags; - - MHI_VERB("DB_MODE/OOB Detected chan %d.\n", mhi_chan->chan); - mhi_chan->db_cfg.db_mode = 1; - read_lock_irqsave(&mhi_cntrl->pm_lock, flags); - if (tre_ring->wp != tre_ring->rp && - MHI_DB_ACCESS_VALID(mhi_cntrl->pm_state)) { - mhi_ring_chan_db(mhi_cntrl, mhi_chan); - } - read_unlock_irqrestore(&mhi_cntrl->pm_lock, flags); - break; - } - case MHI_EV_CC_BAD_TRE: - MHI_ASSERT(1, "Received BAD TRE event for ring"); - break; - default: - MHI_CRITICAL("Unknown TX completion.\n"); - - break; - } /* switch(MHI_EV_READ_CODE(EV_TRB_CODE,event)) */ - -end_process_tx_event: - if (ev_code >= MHI_EV_CC_OOB) - write_unlock_irqrestore(&mhi_chan->lock, flags); - else - read_unlock_bh(&mhi_chan->lock); - - return 0; -} - -#include "mhi_common.h" -static void mhi_dump_tre(struct mhi_controller *mhi_cntrl, struct mhi_tre *_ev) { - union mhi_dev_ring_element_type *ev = (union mhi_dev_ring_element_type *)_ev; - - switch (ev->generic.type) { - case MHI_DEV_RING_EL_INVALID: { - MHI_ERR("carl_ev cmd_invalid, ptr=%llx, %x, %x\n", _ev->ptr, _ev->dword[0], _ev->dword[1]); - } - break; - case MHI_DEV_RING_EL_NOOP: { - MHI_LOG("carl_ev cmd_no_op chan=%u\n", ev->cmd_no_op.chid); - } - break; - case MHI_DEV_RING_EL_TRANSFER: { - MHI_LOG("carl_ev tre data=%llx, len=%u, chan=%u\n", - ev->tre.data_buf_ptr, ev->tre.len, ev->tre.chain); - } - break; - case MHI_DEV_RING_EL_RESET: { - MHI_LOG("carl_ev cmd_reset chan=%u\n", ev->cmd_reset.chid); - } - break; - case MHI_DEV_RING_EL_STOP: { - MHI_LOG("carl_ev cmd_stop chan=%u\n", ev->cmd_stop.chid); - } - break; - case MHI_DEV_RING_EL_START: { - MHI_LOG("carl_ev cmd_start chan=%u\n", ev->cmd_start.chid); - } - break; - case MHI_DEV_RING_EL_MHI_STATE_CHG: { - MHI_LOG("carl_ev evt_state_change mhistate=%u\n", ev->evt_state_change.mhistate); - } - break; - case MHI_DEV_RING_EL_CMD_COMPLETION_EVT:{ - MHI_LOG("carl_ev evt_cmd_comp code=%u\n", ev->evt_cmd_comp.code); - } - break; - case MHI_DEV_RING_EL_TRANSFER_COMPLETION_EVENT:{ - MHI_VERB("carl_ev evt_tr_comp ptr=%llx, len=%u, code=%u, chan=%u\n", - ev->evt_tr_comp.ptr, ev->evt_tr_comp.len, ev->evt_tr_comp.code, ev->evt_tr_comp.chid); - } - break; - case MHI_DEV_RING_EL_EE_STATE_CHANGE_NOTIFY:{ - MHI_LOG("carl_ev evt_ee_state execenv=%u\n", ev->evt_ee_state.execenv); - } - break; - case MHI_DEV_RING_EL_UNDEF: - default: { - MHI_ERR("carl_ev el_undef type=%d\n", ev->generic.type); - }; - break; - } -} - - -static int mhi_process_event_ring(struct mhi_controller *mhi_cntrl, - struct mhi_event *mhi_event, - u32 event_quota) -{ - struct mhi_tre *dev_rp, *local_rp; - struct mhi_ring *ev_ring = &mhi_event->ring; - struct mhi_event_ctxt *er_ctxt = - &mhi_cntrl->mhi_ctxt->er_ctxt[mhi_event->er_index]; - int count = 0; - - read_lock_bh(&mhi_cntrl->pm_lock); - if (unlikely(MHI_EVENT_ACCESS_INVALID(mhi_cntrl->pm_state))) { - MHI_ERR("No EV access, PM_STATE:%s\n", - to_mhi_pm_state_str(mhi_cntrl->pm_state)); - read_unlock_bh(&mhi_cntrl->pm_lock); - return -EIO; - } - - mhi_cntrl->wake_get(mhi_cntrl, false); - read_unlock_bh(&mhi_cntrl->pm_lock); - - dev_rp = mhi_to_virtual(ev_ring, le64_to_cpu(er_ctxt->rp)); - local_rp = ev_ring->rp; - - while (dev_rp != local_rp && event_quota > 0) { - enum MHI_PKT_TYPE type = MHI_TRE_GET_EV_TYPE(local_rp); - - mhi_dump_tre(mhi_cntrl, local_rp); - MHI_VERB("Processing Event:0x%llx 0x%08x 0x%08x\n", - local_rp->ptr, local_rp->dword[0], local_rp->dword[1]); - - switch (type) { - case MHI_PKT_TYPE_TX_EVENT: - { - u32 chan; - struct mhi_chan *mhi_chan; - - chan = MHI_TRE_GET_EV_CHID(local_rp); - mhi_chan = &mhi_cntrl->mhi_chan[chan]; - parse_xfer_event(mhi_cntrl, local_rp, mhi_chan); - event_quota--; - break; - } - case MHI_PKT_TYPE_STATE_CHANGE_EVENT: - { - enum MHI_STATE new_state; - - new_state = MHI_TRE_GET_EV_STATE(local_rp); - - MHI_LOG("MHI state change event to state:%s\n", - TO_MHI_STATE_STR(new_state)); - - switch (new_state) { - case MHI_STATE_M0: - mhi_pm_m0_transition(mhi_cntrl); - break; - case MHI_STATE_M1: - mhi_pm_m1_transition(mhi_cntrl); - break; - case MHI_STATE_M3: - mhi_pm_m3_transition(mhi_cntrl); - break; - case MHI_STATE_SYS_ERR: - { - enum MHI_PM_STATE new_state; - - MHI_ERR("MHI system error detected\n"); - write_lock_irq(&mhi_cntrl->pm_lock); - new_state = mhi_tryset_pm_state(mhi_cntrl, - MHI_PM_SYS_ERR_DETECT); - write_unlock_irq(&mhi_cntrl->pm_lock); - if (new_state == MHI_PM_SYS_ERR_DETECT) - schedule_work( - &mhi_cntrl->syserr_worker); - break; - } - default: - MHI_ERR("Unsupported STE:%s\n", - TO_MHI_STATE_STR(new_state)); - } - - break; - } - case MHI_PKT_TYPE_CMD_COMPLETION_EVENT: - { - dma_addr_t ptr = MHI_TRE_GET_EV_PTR(local_rp); - struct mhi_cmd *cmd_ring = - &mhi_cntrl->mhi_cmd[PRIMARY_CMD_RING]; - struct mhi_ring *mhi_ring = &cmd_ring->ring; - struct mhi_tre *cmd_pkt; - struct mhi_chan *mhi_chan; - u32 chan; - - cmd_pkt = mhi_to_virtual(mhi_ring, ptr); - - /* out of order completion received */ - MHI_ASSERT(cmd_pkt != mhi_ring->rp, - "Out of order cmd completion"); - - chan = MHI_TRE_GET_CMD_CHID(cmd_pkt); - - mhi_chan = &mhi_cntrl->mhi_chan[chan]; - write_lock_bh(&mhi_chan->lock); - mhi_chan->ccs = MHI_TRE_GET_EV_CODE(local_rp); - complete(&mhi_chan->completion); - write_unlock_bh(&mhi_chan->lock); - mhi_del_ring_element(mhi_cntrl, mhi_ring); - break; - } - case MHI_PKT_TYPE_EE_EVENT: - { - enum MHI_ST_TRANSITION st = MHI_ST_TRANSITION_MAX; - enum MHI_EE event = MHI_TRE_GET_EV_EXECENV(local_rp); - - MHI_LOG("MHI EE received event:%s, old EE:%s\n", - TO_MHI_EXEC_STR(event), TO_MHI_EXEC_STR(mhi_cntrl->ee)); - - switch (event) { - case MHI_EE_SBL: - st = MHI_ST_TRANSITION_SBL; - break; - case MHI_EE_AMSS: - st = MHI_ST_TRANSITION_AMSS; - break; - case MHI_EE_RDDM: - mhi_cntrl->status_cb(mhi_cntrl, - mhi_cntrl->priv_data, - MHI_CB_EE_RDDM); - break; - /* fall thru to wake up the event */ - case MHI_EE_WFW: - case MHI_EE_PT: - case MHI_EE_EDL: - case MHI_EE_FP: - case MHI_EE_UEFI: - write_lock_irq(&mhi_cntrl->pm_lock); - if (event == MHI_EE_FP) - st = MHI_ST_TRANSITION_FP; - write_unlock_irq(&mhi_cntrl->pm_lock); - wake_up(&mhi_cntrl->state_event); - break; - default: - MHI_ERR("Unhandled EE event:%s\n", - TO_MHI_EXEC_STR(event)); - } - if (st != MHI_ST_TRANSITION_MAX) - mhi_queue_state_transition(mhi_cntrl, st); - break; - } - case MHI_PKT_TYPE_STALE_EVENT: - MHI_VERB("Stale Event received for chan:%u\n", - MHI_TRE_GET_EV_CHID(local_rp)); - break; - default: - //MHI_ERR("Unsupported packet type code 0x%x\n", type); - break; - } - - memset((unsigned char *)ev_ring->rp, 0x00, ev_ring->el_size); //carl.yin debug - mhi_recycle_ev_ring_element(mhi_cntrl, ev_ring); - local_rp = ev_ring->rp; - dev_rp = mhi_to_virtual(ev_ring, le64_to_cpu(er_ctxt->rp)); - count++; - } - read_lock_bh(&mhi_cntrl->pm_lock); - if (likely(MHI_DB_ACCESS_VALID(mhi_cntrl->pm_state))) - mhi_ring_er_db(mhi_event); - mhi_cntrl->wake_put(mhi_cntrl, false); - read_unlock_bh(&mhi_cntrl->pm_lock); - - MHI_VERB("exit er_index:%u\n", mhi_event->er_index); - return count; -} - -void mhi_ev_task(unsigned long data) -{ - struct mhi_event *mhi_event = (struct mhi_event *)data; - struct mhi_controller *mhi_cntrl = mhi_event->mhi_cntrl; - - MHI_VERB("Enter for ev_index:%d\n", mhi_event->er_index); - - /* process all pending events */ - spin_lock_bh(&mhi_event->lock); - mhi_process_event_ring(mhi_cntrl, mhi_event, U32_MAX); - spin_unlock_bh(&mhi_event->lock); -} - -void mhi_ctrl_ev_task(unsigned long data) -{ - struct mhi_event *mhi_event = (struct mhi_event *)data; - struct mhi_controller *mhi_cntrl = mhi_event->mhi_cntrl; - enum MHI_STATE state = MHI_STATE_MAX; - enum MHI_PM_STATE pm_state = 0; - int ret; - - MHI_VERB("Enter for ev_index:%d\n", mhi_event->er_index); - - /* process ctrl events events */ - ret = mhi_process_event_ring(mhi_cntrl, mhi_event, U32_MAX); - - /* - * we received a MSI but no events to process maybe device went to - * SYS_ERR state, check the state - */ - if (!ret) { - write_lock_irq(&mhi_cntrl->pm_lock); - if (MHI_REG_ACCESS_VALID(mhi_cntrl->pm_state)) - state = mhi_get_m_state(mhi_cntrl); - if (state == MHI_STATE_SYS_ERR) { - MHI_ERR("MHI system error detected\n"); - pm_state = mhi_tryset_pm_state(mhi_cntrl, - MHI_PM_SYS_ERR_DETECT); - } - write_unlock_irq(&mhi_cntrl->pm_lock); - if (pm_state == MHI_PM_SYS_ERR_DETECT) - schedule_work(&mhi_cntrl->syserr_worker); - } -} - -irqreturn_t mhi_msi_handlr(int irq_number, void *dev) -{ - struct mhi_event *mhi_event = dev; - struct mhi_controller *mhi_cntrl = mhi_event->mhi_cntrl; - struct mhi_event_ctxt *er_ctxt = - &mhi_cntrl->mhi_ctxt->er_ctxt[mhi_event->er_index]; - struct mhi_ring *ev_ring = &mhi_event->ring; - void *dev_rp = mhi_to_virtual(ev_ring, le64_to_cpu(er_ctxt->rp)); - - if (mhi_cntrl->msi_allocated == 1) - { - unsigned long flags; - int i; - enum MHI_STATE mhi_state = mhi_get_m_state(mhi_cntrl); - - if (mhi_state == MHI_STATE_SYS_ERR) { - enum MHI_PM_STATE pm_state = 0; - - MHI_ERR("MHI system error detected\n"); - write_lock_irqsave(&mhi_cntrl->pm_lock, flags); - pm_state = mhi_tryset_pm_state(mhi_cntrl, MHI_PM_SYS_ERR_DETECT); - write_unlock_irqrestore(&mhi_cntrl->pm_lock, flags); - if (pm_state == MHI_PM_SYS_ERR_DETECT) - schedule_work(&mhi_cntrl->syserr_worker); - } else if (mhi_state != mhi_cntrl->dev_state) { - MHI_LOG("MHISTATUS %s -> %s\n", TO_MHI_STATE_STR(mhi_cntrl->dev_state), TO_MHI_STATE_STR(mhi_state)); - wake_up(&mhi_cntrl->state_event); - } - - er_ctxt = mhi_cntrl->mhi_ctxt->er_ctxt; - mhi_event = mhi_cntrl->data->mhi_event; - for (i = 0; i < NUM_MHI_EVT_RINGS; i++, er_ctxt++, mhi_event++) { - struct mhi_ring *ev_ring = &mhi_event->ring; - void *dev_rp = mhi_to_virtual(ev_ring, le64_to_cpu(er_ctxt->rp)); - - if (ev_ring->rp != dev_rp) { - MHI_VERB("local_rp=%p vs dev_rp=%p\n", ev_ring->rp, dev_rp); - if (mhi_event->priority == MHI_ER_PRIORITY_HIGH) - { - tasklet_hi_schedule(&mhi_event->task); - } - else - { - tasklet_schedule(&mhi_event->task); - } - } - } - - return IRQ_HANDLED; - } - - /* confirm ER has pending events to process before scheduling work */ - if (ev_ring->rp == dev_rp) - return IRQ_HANDLED; - - /* client managed event ring, notify pending data */ - if (mhi_event->cl_manage) { - struct mhi_chan *mhi_chan = mhi_event->mhi_chan; - struct mhi_device *mhi_dev = mhi_chan->mhi_dev; - - if (mhi_dev) - mhi_dev->status_cb(mhi_dev, MHI_CB_PENDING_DATA); - } - else - { - if (mhi_event->priority == MHI_ER_PRIORITY_HIGH) - { - tasklet_hi_schedule(&mhi_event->task); - } - else - { - tasklet_schedule(&mhi_event->task); - } - } - - return IRQ_HANDLED; -} - -/* this is the threaded fn */ -irqreturn_t mhi_intvec_threaded_handlr(int irq_number, void *dev) -{ - struct mhi_controller *mhi_cntrl = dev; - enum MHI_STATE state = MHI_STATE_MAX; - enum MHI_PM_STATE pm_state = 0; - - MHI_VERB("Enter\n"); - - write_lock_irq(&mhi_cntrl->pm_lock); - if (MHI_REG_ACCESS_VALID(mhi_cntrl->pm_state)) - state = mhi_get_m_state(mhi_cntrl); - if (state == MHI_STATE_SYS_ERR) { - MHI_ERR("MHI system error detected\n"); - pm_state = mhi_tryset_pm_state(mhi_cntrl, - MHI_PM_SYS_ERR_DETECT); - } - write_unlock_irq(&mhi_cntrl->pm_lock); - if (pm_state == MHI_PM_SYS_ERR_DETECT) - schedule_work(&mhi_cntrl->syserr_worker); - - MHI_VERB("Exit\n"); - - return IRQ_HANDLED; -} - -irqreturn_t mhi_intvec_handlr(int irq_number, void *dev) -{ - - struct mhi_controller *mhi_cntrl = dev; - - /* wake up any events waiting for state change */ - MHI_VERB("Enter\n"); - wake_up(&mhi_cntrl->state_event); - MHI_VERB("Exit\n"); - - return IRQ_WAKE_THREAD; -} - -static int mhi_send_cmd(struct mhi_controller *mhi_cntrl, - struct mhi_chan *mhi_chan, - enum MHI_CMD cmd) -{ - struct mhi_tre *cmd_tre = NULL; - struct mhi_cmd *mhi_cmd = &mhi_cntrl->mhi_cmd[PRIMARY_CMD_RING]; - struct mhi_ring *ring = &mhi_cmd->ring; - int chan = mhi_chan->chan; - - MHI_VERB("Entered, MHI pm_state:%s dev_state:%s ee:%s\n", - to_mhi_pm_state_str(mhi_cntrl->pm_state), - TO_MHI_STATE_STR(mhi_cntrl->dev_state), - TO_MHI_EXEC_STR(mhi_cntrl->ee)); - - /* MHI host currently handles RESET and START cmd */ - if (cmd != MHI_CMD_START_CHAN && cmd != MHI_CMD_RESET_CHAN) - return -EINVAL; - - spin_lock_bh(&mhi_cmd->lock); - if (!get_nr_avail_ring_elements(mhi_cntrl, ring)) { - spin_unlock_bh(&mhi_cmd->lock); - return -ENOMEM; - } - - /* prepare the cmd tre */ - cmd_tre = ring->wp; - if (cmd == MHI_CMD_START_CHAN) { - cmd_tre->ptr = MHI_TRE_CMD_START_PTR; - cmd_tre->dword[0] = MHI_TRE_CMD_START_DWORD0; - cmd_tre->dword[1] = MHI_TRE_CMD_START_DWORD1(chan); - } else { - cmd_tre->ptr = MHI_TRE_CMD_RESET_PTR; - cmd_tre->dword[0] = MHI_TRE_CMD_RESET_DWORD0; - cmd_tre->dword[1] = MHI_TRE_CMD_RESET_DWORD1(chan); - } - - MHI_VERB("WP:0x%llx TRE: 0x%llx 0x%08x 0x%08x\n", - (u64)mhi_to_physical(ring, cmd_tre), le64_to_cpu(cmd_tre->ptr), - le32_to_cpu(cmd_tre->dword[0]), le32_to_cpu(cmd_tre->dword[1])); - - /* queue to hardware */ - mhi_add_ring_element(mhi_cntrl, ring); - read_lock_bh(&mhi_cntrl->pm_lock); - if (likely(MHI_DB_ACCESS_VALID(mhi_cntrl->pm_state))) - mhi_ring_cmd_db(mhi_cntrl, mhi_cmd); - read_unlock_bh(&mhi_cntrl->pm_lock); - spin_unlock_bh(&mhi_cmd->lock); - - return 0; -} - -static int __mhi_prepare_channel(struct mhi_controller *mhi_cntrl, - struct mhi_chan *mhi_chan) -{ - int ret = 0; - - MHI_LOG("Entered: preparing channel:%d\n", mhi_chan->chan); - - if (mhi_cntrl->ee != mhi_chan->ee) { - MHI_ERR("Current EE:%s Required EE:%s for chan:%s\n", - TO_MHI_EXEC_STR(mhi_cntrl->ee), - TO_MHI_EXEC_STR(mhi_chan->ee), - mhi_chan->name); - return -ENOTCONN; - } - - mutex_lock(&mhi_chan->mutex); - /* client manages channel context for offload channels */ - if (!mhi_chan->offload_ch) { - ret = mhi_init_chan_ctxt(mhi_cntrl, mhi_chan); - if (ret) { - MHI_ERR("Error with init chan\n"); - goto error_init_chan; - } - } - - reinit_completion(&mhi_chan->completion); - read_lock_bh(&mhi_cntrl->pm_lock); - if (MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) { - MHI_ERR("MHI host is not in active state\n"); - read_unlock_bh(&mhi_cntrl->pm_lock); - ret = -EIO; - goto error_pm_state; - } - - mhi_cntrl->wake_get(mhi_cntrl, false); - read_unlock_bh(&mhi_cntrl->pm_lock); - mhi_cntrl->runtime_get(mhi_cntrl, mhi_cntrl->priv_data); - mhi_cntrl->runtime_put(mhi_cntrl, mhi_cntrl->priv_data); - - ret = mhi_send_cmd(mhi_cntrl, mhi_chan, MHI_CMD_START_CHAN); - if (ret) { - MHI_ERR("Failed to send start chan cmd\n"); - goto error_send_cmd; - } - - ret = wait_for_completion_timeout(&mhi_chan->completion, - msecs_to_jiffies(mhi_cntrl->timeout_ms)); - if (!ret || mhi_chan->ccs != MHI_EV_CC_SUCCESS) { - MHI_ERR("Failed to receive cmd completion for chan:%d\n", - mhi_chan->chan); - ret = -EIO; - goto error_send_cmd; - } - - write_lock_irq(&mhi_chan->lock); - mhi_chan->ch_state = MHI_CH_STATE_ENABLED; - write_unlock_irq(&mhi_chan->lock); - - read_lock_bh(&mhi_cntrl->pm_lock); - mhi_cntrl->wake_put(mhi_cntrl, false); - read_unlock_bh(&mhi_cntrl->pm_lock); - - /* pre allocate buffer for xfer ring */ - if (mhi_chan->pre_alloc) { - struct mhi_device *mhi_dev = mhi_chan->mhi_dev; - int nr_el = get_nr_avail_ring_elements(mhi_cntrl, - &mhi_chan->tre_ring); - - while (nr_el--) { - void *buf; - - buf = kmalloc(MHI_MAX_MTU, GFP_KERNEL); - if (!buf) { - ret = -ENOMEM; - goto error_pre_alloc; - } - - ret = mhi_queue_buf(mhi_dev, mhi_chan, buf, MHI_MAX_MTU, - MHI_EOT); - if (ret) { - MHI_ERR("Chan:%d error queue buffer\n", - mhi_chan->chan); - kfree(buf); - goto error_pre_alloc; - } - } - } - - mutex_unlock(&mhi_chan->mutex); - - MHI_LOG("Chan:%d successfully moved to start state\n", mhi_chan->chan); - - return 0; - -error_send_cmd: - read_lock_bh(&mhi_cntrl->pm_lock); - mhi_cntrl->wake_put(mhi_cntrl, false); - read_unlock_bh(&mhi_cntrl->pm_lock); - -error_pm_state: - if (!mhi_chan->offload_ch) - mhi_deinit_chan_ctxt(mhi_cntrl, mhi_chan); - -error_init_chan: - mutex_unlock(&mhi_chan->mutex); - - return ret; - -error_pre_alloc: - mutex_unlock(&mhi_chan->mutex); - __mhi_unprepare_channel(mhi_cntrl, mhi_chan); - - return ret; -} - -void mhi_reset_chan(struct mhi_controller *mhi_cntrl, struct mhi_chan *mhi_chan) -{ - struct mhi_tre *dev_rp, *local_rp; - struct mhi_event_ctxt *er_ctxt; - struct mhi_event *mhi_event; - struct mhi_ring *ev_ring, *buf_ring, *tre_ring; - unsigned long flags; - int chan = mhi_chan->chan; - struct mhi_result result; - - /* nothing to reset, client don't queue buffers */ - if (mhi_chan->offload_ch) - return; - - read_lock_bh(&mhi_cntrl->pm_lock); - mhi_event = &mhi_cntrl->mhi_event[mhi_chan->er_index]; - ev_ring = &mhi_event->ring; - er_ctxt = &mhi_cntrl->mhi_ctxt->er_ctxt[mhi_chan->er_index]; - - MHI_LOG("Marking all events for chan:%d as stale\n", chan); - - /* mark all stale events related to channel as STALE event */ - spin_lock_irqsave(&mhi_event->lock, flags); - dev_rp = mhi_to_virtual(ev_ring, le64_to_cpu(er_ctxt->rp)); - if (!mhi_event->mhi_chan) { - local_rp = ev_ring->rp; - while (dev_rp != local_rp) { - if (MHI_TRE_GET_EV_TYPE(local_rp) == - MHI_PKT_TYPE_TX_EVENT && - chan == MHI_TRE_GET_EV_CHID(local_rp)) - local_rp->dword[1] = MHI_TRE_EV_DWORD1(chan, - MHI_PKT_TYPE_STALE_EVENT); - local_rp++; - if (local_rp == (ev_ring->base + ev_ring->len)) - local_rp = ev_ring->base; - } - } else { - /* dedicated event ring so move the ptr to end */ - ev_ring->rp = dev_rp; - ev_ring->wp = ev_ring->rp - ev_ring->el_size; - if (ev_ring->wp < ev_ring->base) - ev_ring->wp = ev_ring->base + ev_ring->len - - ev_ring->el_size; - if (likely(MHI_DB_ACCESS_VALID(mhi_cntrl->pm_state))) - mhi_ring_er_db(mhi_event); - } - - MHI_LOG("Finished marking events as stale events\n"); - spin_unlock_irqrestore(&mhi_event->lock, flags); - - /* reset any pending buffers */ - buf_ring = &mhi_chan->buf_ring; - tre_ring = &mhi_chan->tre_ring; - result.transaction_status = -ENOTCONN; - result.bytes_xferd = 0; - while (tre_ring->rp != tre_ring->wp) { - struct mhi_buf_info *buf_info = buf_ring->rp; - - if (mhi_chan->dir == DMA_TO_DEVICE) - mhi_cntrl->wake_put(mhi_cntrl, false); - - dma_unmap_single(mhi_cntrl->dev, buf_info->p_addr, - buf_info->len, buf_info->dir); - mhi_del_ring_element(mhi_cntrl, buf_ring); - mhi_del_ring_element(mhi_cntrl, tre_ring); - - if (mhi_chan->pre_alloc) { - kfree(buf_info->cb_buf); - } else { - result.buf_addr = buf_info->cb_buf; - mhi_chan->xfer_cb(mhi_chan->mhi_dev, &result); - } - } - - read_unlock_bh(&mhi_cntrl->pm_lock); - MHI_LOG("Reset complete.\n"); -} - -static void __mhi_unprepare_channel(struct mhi_controller *mhi_cntrl, - struct mhi_chan *mhi_chan) -{ - int ret; - - MHI_LOG("Entered: unprepare channel:%d\n", mhi_chan->chan); - - /* no more processing events for this channel */ - mutex_lock(&mhi_chan->mutex); - write_lock_irq(&mhi_chan->lock); - if (mhi_chan->ch_state != MHI_CH_STATE_ENABLED) { - MHI_LOG("chan:%d is already disabled\n", mhi_chan->chan); - write_unlock_irq(&mhi_chan->lock); - mutex_unlock(&mhi_chan->mutex); - return; - } - - mhi_chan->ch_state = MHI_CH_STATE_DISABLED; - write_unlock_irq(&mhi_chan->lock); - - reinit_completion(&mhi_chan->completion); - read_lock_bh(&mhi_cntrl->pm_lock); - if (MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) { - read_unlock_bh(&mhi_cntrl->pm_lock); - goto error_invalid_state; - } - - mhi_cntrl->wake_get(mhi_cntrl, false); - read_unlock_bh(&mhi_cntrl->pm_lock); - - mhi_cntrl->runtime_get(mhi_cntrl, mhi_cntrl->priv_data); - mhi_cntrl->runtime_put(mhi_cntrl, mhi_cntrl->priv_data); - ret = mhi_send_cmd(mhi_cntrl, mhi_chan, MHI_CMD_RESET_CHAN); - if (ret) { - MHI_ERR("Failed to send reset chan cmd\n"); - goto error_completion; - } - - /* even if it fails we will still reset */ - ret = wait_for_completion_timeout(&mhi_chan->completion, - msecs_to_jiffies(mhi_cntrl->timeout_ms)); - if (!ret || mhi_chan->ccs != MHI_EV_CC_SUCCESS) - MHI_ERR("Failed to receive cmd completion, still resetting\n"); - -error_completion: - read_lock_bh(&mhi_cntrl->pm_lock); - mhi_cntrl->wake_put(mhi_cntrl, false); - read_unlock_bh(&mhi_cntrl->pm_lock); - -error_invalid_state: - if (!mhi_chan->offload_ch) { - mhi_reset_chan(mhi_cntrl, mhi_chan); - mhi_deinit_chan_ctxt(mhi_cntrl, mhi_chan); - } - MHI_LOG("chan:%d successfully resetted\n", mhi_chan->chan); - mutex_unlock(&mhi_chan->mutex); -} - -int mhi_debugfs_mhi_states_show(struct seq_file *m, void *d) -{ - struct mhi_controller *mhi_cntrl = m->private; - u32 reset=-1, ready=-1; - int ret; - - ret = mhi_read_reg_field(mhi_cntrl, mhi_cntrl->regs, MHICTRL, - MHICTRL_RESET_MASK, MHICTRL_RESET_SHIFT, &reset); - ret = mhi_read_reg_field(mhi_cntrl, mhi_cntrl->regs, MHISTATUS, - MHISTATUS_READY_MASK, MHISTATUS_READY_SHIFT, &ready); - if (!ret) - seq_printf(m, - "Device current EE:%s, M:%s, RESET:%d, READY:%d\n", - TO_MHI_EXEC_STR(mhi_get_exec_env(mhi_cntrl)), - TO_MHI_STATE_STR(mhi_get_m_state(mhi_cntrl)), - reset, ready); - - seq_printf(m, - "pm_state:%s dev_state:%s EE:%s M0:%u M1:%u M2:%u M3:%u wake:%d dev_wake:%u alloc_size:%u\n", - to_mhi_pm_state_str(mhi_cntrl->pm_state), - TO_MHI_STATE_STR(mhi_cntrl->dev_state), - TO_MHI_EXEC_STR(mhi_cntrl->ee), - mhi_cntrl->M0, mhi_cntrl->M1, mhi_cntrl->M2, mhi_cntrl->M3, - mhi_cntrl->wake_set, - atomic_read(&mhi_cntrl->dev_wake), - atomic_read(&mhi_cntrl->alloc_size)); - - return 0; -} - -int mhi_debugfs_mhi_event_show(struct seq_file *m, void *d) -{ - struct mhi_controller *mhi_cntrl = m->private; - struct mhi_event *mhi_event; - struct mhi_event_ctxt *er_ctxt; - - int i; - - er_ctxt = mhi_cntrl->mhi_ctxt->er_ctxt; - mhi_event = mhi_cntrl->mhi_event; - for (i = 0; i < mhi_cntrl->total_ev_rings; i++, er_ctxt++, - mhi_event++) { - struct mhi_ring *ring = &mhi_event->ring; - - if (mhi_event->offload_ev) { - seq_printf(m, "Index:%d offload event ring\n", i); - } else { - seq_printf(m, - "Index:%d modc:%d modt:%d base:0x%0llx len:0x%llx", - i, er_ctxt->intmodc, er_ctxt->intmodt, - er_ctxt->rbase, er_ctxt->rlen); - seq_printf(m, - " rp:0x%llx wp:0x%llx local_rp:0x%llx db:0x%llx\n", - er_ctxt->rp, er_ctxt->wp, - (u64)mhi_to_physical(ring, ring->rp), - (u64)mhi_event->db_cfg.db_val); - { - struct mhi_tre *tre = (struct mhi_tre *)ring->base; - size_t i; - for (i = 0; i < ring->elements; i++, tre++) { - seq_printf(m, - "%llx, %x, %x\n", - tre->ptr, tre->dword[0], tre->dword[1]); - } - } - } - } - - return 0; -} - -int mhi_debugfs_mhi_chan_show(struct seq_file *m, void *d) -{ - struct mhi_controller *mhi_cntrl = m->private; - struct mhi_chan *mhi_chan; - struct mhi_chan_ctxt *chan_ctxt; - int i; - - mhi_chan = mhi_cntrl->mhi_chan; - chan_ctxt = mhi_cntrl->mhi_ctxt->chan_ctxt; - for (i = 0; i < mhi_cntrl->max_chan; i++, chan_ctxt++, mhi_chan++) { - struct mhi_ring *ring = &mhi_chan->tre_ring; - - if (mhi_chan->offload_ch) { - seq_printf(m, "%s(%u) offload channel\n", - mhi_chan->name, mhi_chan->chan); - } else if (mhi_chan->mhi_dev) { - seq_printf(m, - "%s(%u) state:0x%x brstmode:0x%x pllcfg:0x%x type:0x%x erindex:%u", - mhi_chan->name, mhi_chan->chan, - chan_ctxt->chstate, chan_ctxt->brstmode, - chan_ctxt->pollcfg, chan_ctxt->chtype, - chan_ctxt->erindex); - seq_printf(m, - " base:0x%llx len:0x%llx wp:0x%llx local_rp:0x%llx local_wp:0x%llx db:0x%llx full:%d\n", - chan_ctxt->rbase, chan_ctxt->rlen, - chan_ctxt->wp, - (u64)mhi_to_physical(ring, ring->rp), - (u64)mhi_to_physical(ring, ring->wp), - (u64)mhi_chan->db_cfg.db_val, mhi_chan->full); - } - } - - return 0; -} - -/* move channel to start state */ -int mhi_prepare_for_transfer(struct mhi_device *mhi_dev) -{ - int ret, dir; - struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; - struct mhi_chan *mhi_chan; - - for (dir = 0; dir < 2; dir++) { - mhi_chan = dir ? mhi_dev->ul_chan : mhi_dev->dl_chan; - - if (!mhi_chan) - continue; - - ret = __mhi_prepare_channel(mhi_cntrl, mhi_chan); - if (ret) { - MHI_ERR("Error moving chan %s,%d to START state\n", - mhi_chan->name, mhi_chan->chan); - goto error_open_chan; - } - } - - return 0; - -error_open_chan: - for (--dir; dir >= 0; dir--) { - mhi_chan = dir ? mhi_dev->ul_chan : mhi_dev->dl_chan; - - if (!mhi_chan) - continue; - - __mhi_unprepare_channel(mhi_cntrl, mhi_chan); - } - - return ret; -} -EXPORT_SYMBOL(mhi_prepare_for_transfer); - -void mhi_unprepare_from_transfer(struct mhi_device *mhi_dev) -{ - struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; - struct mhi_chan *mhi_chan; - int dir; - - for (dir = 0; dir < 2; dir++) { - mhi_chan = dir ? mhi_dev->ul_chan : mhi_dev->dl_chan; - - if (!mhi_chan) - continue; - - __mhi_unprepare_channel(mhi_cntrl, mhi_chan); - } -} -EXPORT_SYMBOL(mhi_unprepare_from_transfer); - -int mhi_get_no_free_descriptors(struct mhi_device *mhi_dev, - enum dma_data_direction dir) -{ - struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; - struct mhi_chan *mhi_chan = (dir == DMA_TO_DEVICE) ? - mhi_dev->ul_chan : mhi_dev->dl_chan; - struct mhi_ring *tre_ring = &mhi_chan->tre_ring; - - return get_nr_avail_ring_elements(mhi_cntrl, tre_ring); -} -EXPORT_SYMBOL(mhi_get_no_free_descriptors); - -struct mhi_controller *mhi_bdf_to_controller(u32 domain, - u32 bus, - u32 slot, - u32 dev_id) -{ - struct mhi_controller *itr, *tmp; - - list_for_each_entry_safe(itr, tmp, &mhi_bus.controller_list, node) - if (itr->domain == domain && itr->bus == bus && - itr->slot == slot && itr->dev_id == dev_id) - return itr; - - return NULL; -} -EXPORT_SYMBOL(mhi_bdf_to_controller); - -int mhi_poll(struct mhi_device *mhi_dev, - u32 budget) -{ - struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; - struct mhi_chan *mhi_chan = mhi_dev->dl_chan; - struct mhi_event *mhi_event = &mhi_cntrl->mhi_event[mhi_chan->er_index]; - int ret; - - spin_lock_bh(&mhi_event->lock); - ret = mhi_process_event_ring(mhi_cntrl, mhi_event, budget); - spin_unlock_bh(&mhi_event->lock); - - return ret; -} -EXPORT_SYMBOL(mhi_poll); diff --git a/fibocom_MHI/src/core/mhi_pm.c b/fibocom_MHI/src/core/mhi_pm.c deleted file mode 100644 index 039de5b..0000000 --- a/fibocom_MHI/src/core/mhi_pm.c +++ /dev/null @@ -1,1271 +0,0 @@ -/* Copyright (c) 2018, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "mhi.h" -#include "mhi_internal.h" - -/* - * Not all MHI states transitions are sync transitions. Linkdown, SSR, and - * shutdown can happen anytime asynchronously. This function will transition to - * new state only if we're allowed to transitions. - * - * Priority increase as we go down, example while in any states from L0, start - * state from L1, L2, or L3 can be set. Notable exception to this rule is state - * DISABLE. From DISABLE state we can transition to only POR or state. Also - * for example while in L2 state, user cannot jump back to L1 or L0 states. - * Valid transitions: - * L0: DISABLE <--> POR - * POR <--> POR - * POR -> M0 -> M1 -> M1_M2 -> M2 --> M0 - * POR -> FW_DL_ERR - * FW_DL_ERR <--> FW_DL_ERR - * M0 -> FW_DL_ERR - * M1_M2 -> M0 (Device can trigger it) - * M0 -> M3_ENTER -> M3 -> M3_EXIT --> M0 - * M1 -> M3_ENTER --> M3 - * L1: SYS_ERR_DETECT -> SYS_ERR_PROCESS --> POR - * L2: SHUTDOWN_PROCESS -> DISABLE - * L3: LD_ERR_FATAL_DETECT <--> LD_ERR_FATAL_DETECT - * LD_ERR_FATAL_DETECT -> SHUTDOWN_PROCESS - */ -static struct mhi_pm_transitions const mhi_state_transitions[] = { - /* L0 States */ - { - MHI_PM_DISABLE, - MHI_PM_POR - }, - { - MHI_PM_POR, - MHI_PM_POR | MHI_PM_DISABLE | MHI_PM_M0 | - MHI_PM_SYS_ERR_DETECT | MHI_PM_SHUTDOWN_PROCESS | - MHI_PM_LD_ERR_FATAL_DETECT | MHI_PM_FW_DL_ERR - }, - { - MHI_PM_M0, - MHI_PM_M1 | MHI_PM_M3_ENTER | MHI_PM_SYS_ERR_DETECT | - MHI_PM_SHUTDOWN_PROCESS | MHI_PM_LD_ERR_FATAL_DETECT | - MHI_PM_FW_DL_ERR - }, - { - MHI_PM_M1, - MHI_PM_M1_M2_TRANSITION | MHI_PM_M3_ENTER | - MHI_PM_SYS_ERR_DETECT | MHI_PM_SHUTDOWN_PROCESS | - MHI_PM_LD_ERR_FATAL_DETECT - }, - { - MHI_PM_M1_M2_TRANSITION, - MHI_PM_M2 | MHI_PM_M0 | MHI_PM_SYS_ERR_DETECT | - MHI_PM_SHUTDOWN_PROCESS | MHI_PM_LD_ERR_FATAL_DETECT - }, - { - MHI_PM_M2, - MHI_PM_M0 | MHI_PM_SYS_ERR_DETECT | MHI_PM_SHUTDOWN_PROCESS | - MHI_PM_LD_ERR_FATAL_DETECT - }, - { - MHI_PM_M3_ENTER, - MHI_PM_M3 | MHI_PM_SYS_ERR_DETECT | MHI_PM_SHUTDOWN_PROCESS | - MHI_PM_LD_ERR_FATAL_DETECT - }, - { - MHI_PM_M3, - MHI_PM_M3_EXIT | MHI_PM_SYS_ERR_DETECT | - MHI_PM_SHUTDOWN_PROCESS | MHI_PM_LD_ERR_FATAL_DETECT - }, - { - MHI_PM_M3_EXIT, - MHI_PM_M0 | MHI_PM_SYS_ERR_DETECT | MHI_PM_SHUTDOWN_PROCESS | - MHI_PM_LD_ERR_FATAL_DETECT - }, - { - MHI_PM_FW_DL_ERR, - MHI_PM_FW_DL_ERR | MHI_PM_SYS_ERR_DETECT | - MHI_PM_SHUTDOWN_PROCESS | MHI_PM_LD_ERR_FATAL_DETECT - }, - /* L1 States */ - { - MHI_PM_SYS_ERR_DETECT, - MHI_PM_SYS_ERR_PROCESS | MHI_PM_SHUTDOWN_PROCESS | - MHI_PM_LD_ERR_FATAL_DETECT - }, - { - MHI_PM_SYS_ERR_PROCESS, - MHI_PM_POR | MHI_PM_SHUTDOWN_PROCESS | - MHI_PM_LD_ERR_FATAL_DETECT - }, - /* L2 States */ - { - MHI_PM_SHUTDOWN_PROCESS, - MHI_PM_DISABLE | MHI_PM_LD_ERR_FATAL_DETECT - }, - /* L3 States */ - { - MHI_PM_LD_ERR_FATAL_DETECT, - MHI_PM_LD_ERR_FATAL_DETECT | MHI_PM_SHUTDOWN_PROCESS - }, -}; - -enum MHI_PM_STATE __must_check mhi_tryset_pm_state( - struct mhi_controller *mhi_cntrl, - enum MHI_PM_STATE state) -{ - unsigned long cur_state = mhi_cntrl->pm_state; - int index = find_last_bit(&cur_state, 32); - - if (unlikely(index >= ARRAY_SIZE(mhi_state_transitions))) { - MHI_CRITICAL("cur_state:%s is not a valid pm_state\n", - to_mhi_pm_state_str(cur_state)); - return cur_state; - } - - if (unlikely(mhi_state_transitions[index].from_state != cur_state)) { - MHI_ERR("index:%u cur_state:%s != actual_state: %s\n", - index, to_mhi_pm_state_str(cur_state), - to_mhi_pm_state_str - (mhi_state_transitions[index].from_state)); - return cur_state; - } - - if (unlikely(!(mhi_state_transitions[index].to_states & state))) { - MHI_LOG( - "Not allowing pm state transition from:%s to:%s state\n", - to_mhi_pm_state_str(cur_state), - to_mhi_pm_state_str(state)); - return cur_state; - } - - MHI_VERB("Transition to pm state from:%s to:%s\n", - to_mhi_pm_state_str(cur_state), to_mhi_pm_state_str(state)); - - mhi_cntrl->pm_state = state; - return mhi_cntrl->pm_state; -} - -void mhi_set_mhi_state(struct mhi_controller *mhi_cntrl, enum MHI_STATE state) -{ - if (state == MHI_STATE_RESET) { - mhi_write_reg_field(mhi_cntrl, mhi_cntrl->regs, MHICTRL, - MHICTRL_RESET_MASK, MHICTRL_RESET_SHIFT, 1); - } else { - mhi_write_reg_field(mhi_cntrl, mhi_cntrl->regs, MHICTRL, - MHICTRL_MHISTATE_MASK, MHICTRL_MHISTATE_SHIFT, state); - } -} - -/* set device wake */ -void mhi_assert_dev_wake(struct mhi_controller *mhi_cntrl, bool force) -{ - unsigned long flags; - - /* if set, regardless of count set the bit if not set */ - if (unlikely(force)) { - spin_lock_irqsave(&mhi_cntrl->wlock, flags); - atomic_inc(&mhi_cntrl->dev_wake); - if (MHI_WAKE_DB_ACCESS_VALID(mhi_cntrl->pm_state) && - !mhi_cntrl->wake_set) { - mhi_write_db(mhi_cntrl, mhi_cntrl->wake_db, 1); - mhi_cntrl->wake_set = true; - } - spin_unlock_irqrestore(&mhi_cntrl->wlock, flags); - } else { - /* if resources requested already, then increment and exit */ - if (likely(atomic_add_unless(&mhi_cntrl->dev_wake, 1, 0))) - return; - - spin_lock_irqsave(&mhi_cntrl->wlock, flags); - if ((atomic_inc_return(&mhi_cntrl->dev_wake) == 1) && - MHI_WAKE_DB_ACCESS_VALID(mhi_cntrl->pm_state) && - !mhi_cntrl->wake_set) { - mhi_write_db(mhi_cntrl, mhi_cntrl->wake_db, 1); - mhi_cntrl->wake_set = true; - } - spin_unlock_irqrestore(&mhi_cntrl->wlock, flags); - } -} - -/* clear device wake */ -void mhi_deassert_dev_wake(struct mhi_controller *mhi_cntrl, bool override) -{ - unsigned long flags; - - if (atomic_read(&mhi_cntrl->dev_wake) == 0) { - MHI_LOG("%s 00000\n", __func__); - return; - } - - MHI_ASSERT(atomic_read(&mhi_cntrl->dev_wake) == 0, "dev_wake == 0"); - - /* resources not dropping to 0, decrement and exit */ - if (likely(atomic_add_unless(&mhi_cntrl->dev_wake, -1, 1))) - return; - - spin_lock_irqsave(&mhi_cntrl->wlock, flags); - if ((atomic_dec_return(&mhi_cntrl->dev_wake) == 0) && - MHI_WAKE_DB_ACCESS_VALID(mhi_cntrl->pm_state) && !override && - mhi_cntrl->wake_set) { - mhi_write_db(mhi_cntrl, mhi_cntrl->wake_db, 0); - mhi_cntrl->wake_set = false; - } - spin_unlock_irqrestore(&mhi_cntrl->wlock, flags); -} - -int mhi_ready_state_transition(struct mhi_controller *mhi_cntrl) -{ - void __iomem *base = mhi_cntrl->regs; - u32 reset = 1, ready = 0; - struct mhi_event *mhi_event; - enum MHI_PM_STATE cur_state; - int ret, i; - - MHI_LOG("Waiting to enter READY state\n"); - - MHI_LOG("Device current EE:%s, M:%s\n", - TO_MHI_EXEC_STR(mhi_get_exec_env(mhi_cntrl)), - TO_MHI_STATE_STR(mhi_get_m_state(mhi_cntrl))); - - /* wait for RESET to be cleared and READY bit to be set */ - for (i = 0; i < mhi_cntrl->timeout_ms; i += 25) { //maybe miss msi interrupt? - ready = 0; - wait_event_timeout(mhi_cntrl->state_event, - MHI_PM_IN_FATAL_STATE(mhi_cntrl->pm_state) || - mhi_read_reg_field(mhi_cntrl, base, MHICTRL, - MHICTRL_RESET_MASK, - MHICTRL_RESET_SHIFT, &reset) || - mhi_read_reg_field(mhi_cntrl, base, MHISTATUS, - MHISTATUS_READY_MASK, - MHISTATUS_READY_SHIFT, &ready) || - (!reset && ready), - msecs_to_jiffies(25)); - - /* device enter into error state */ - if (MHI_PM_IN_FATAL_STATE(mhi_cntrl->pm_state)) { - MHI_LOG("reset=0x%x, ready=0x%x, pm_state=0x%x\n", reset, reset, mhi_cntrl->pm_state); - return -EIO; - } - - if (!reset && ready) - break; - } - - /* device did not transition to ready state */ - if (reset || !ready) { - MHI_LOG("reset=0x%x, ready=0x%x, pm_state=0x%x\n", reset, reset, mhi_cntrl->pm_state); - return -ETIMEDOUT; - } - - MHI_LOG("Device in READY State\n"); - write_lock_irq(&mhi_cntrl->pm_lock); - cur_state = mhi_tryset_pm_state(mhi_cntrl, MHI_PM_POR); - mhi_cntrl->dev_state = MHI_STATE_READY; - write_unlock_irq(&mhi_cntrl->pm_lock); - - if (cur_state != MHI_PM_POR) { - MHI_ERR("Error moving to state %s from %s\n", - to_mhi_pm_state_str(MHI_PM_POR), - to_mhi_pm_state_str(cur_state)); - return -EIO; - } - read_lock_bh(&mhi_cntrl->pm_lock); - if (!MHI_REG_ACCESS_VALID(mhi_cntrl->pm_state)) - goto error_mmio; - - ret = mhi_init_mmio(mhi_cntrl); - if (ret) { - MHI_ERR("Error programming mmio registers\n"); - goto error_mmio; - } - - /* add elements to all sw event rings */ - MHI_LOG("mhi_db_sw_ring\n"); - mhi_event = mhi_cntrl->mhi_event; - for (i = 0; i < mhi_cntrl->total_ev_rings; i++, mhi_event++) { - struct mhi_ring *ring = &mhi_event->ring; - - if (mhi_event->offload_ev || mhi_event->hw_ring) - continue; - - ring->wp = ring->base + ring->len - ring->el_size; - *ring->ctxt_wp = cpu_to_le64(ring->iommu_base + ring->len - ring->el_size); - /* needs to update to all cores */ - smp_wmb(); - - /* ring the db for event rings */ - spin_lock_irq(&mhi_event->lock); - mhi_ring_er_db(mhi_event); - spin_unlock_irq(&mhi_event->lock); - } - - /* set device into M0 state */ - mhi_set_mhi_state(mhi_cntrl, MHI_STATE_M0); - read_unlock_bh(&mhi_cntrl->pm_lock); - - return 0; - -error_mmio: - read_unlock_bh(&mhi_cntrl->pm_lock); - - return -EIO; -} - -int mhi_pm_m0_transition(struct mhi_controller *mhi_cntrl) -{ - enum MHI_PM_STATE cur_state; - struct mhi_chan *mhi_chan; - int i; - - MHI_LOG("Entered With State:%s PM_STATE:%s\n", - TO_MHI_STATE_STR(mhi_cntrl->dev_state), - to_mhi_pm_state_str(mhi_cntrl->pm_state)); - - write_lock_irq(&mhi_cntrl->pm_lock); - mhi_cntrl->dev_state = MHI_STATE_M0; - cur_state = mhi_tryset_pm_state(mhi_cntrl, MHI_PM_M0); - write_unlock_irq(&mhi_cntrl->pm_lock); - if (unlikely(cur_state != MHI_PM_M0)) { - MHI_ERR("Failed to transition to state %s from %s\n", - to_mhi_pm_state_str(MHI_PM_M0), - to_mhi_pm_state_str(cur_state)); - return -EIO; - } - mhi_cntrl->M0++; - read_lock_bh(&mhi_cntrl->pm_lock); - mhi_cntrl->wake_get(mhi_cntrl, true); - - /* ring all event rings and CMD ring only if we're in AMSS */ - if (mhi_cntrl->ee == MHI_EE_AMSS) { - //struct mhi_event *mhi_event = mhi_cntrl->mhi_event; - struct mhi_cmd *mhi_cmd = - &mhi_cntrl->mhi_cmd[PRIMARY_CMD_RING]; - - MHI_LOG("mhi_db_all_ring\n"); - - /* only ring primary cmd ring */ - spin_lock_irq(&mhi_cmd->lock); - if (mhi_cmd->ring.rp != mhi_cmd->ring.wp) - mhi_ring_cmd_db(mhi_cntrl, mhi_cmd); - spin_unlock_irq(&mhi_cmd->lock); - } - - /* ring channel db registers */ - mhi_chan = mhi_cntrl->mhi_chan; - for (i = 0; i < mhi_cntrl->max_chan; i++, mhi_chan++) { - struct mhi_ring *tre_ring = &mhi_chan->tre_ring; - - write_lock_irq(&mhi_chan->lock); - if (mhi_chan->db_cfg.reset_req) - mhi_chan->db_cfg.db_mode = true; - - /* only ring DB if ring is not empty */ - if (tre_ring->base && tre_ring->wp != tre_ring->rp) - mhi_ring_chan_db(mhi_cntrl, mhi_chan); - write_unlock_irq(&mhi_chan->lock); - } - - mhi_cntrl->wake_put(mhi_cntrl, false); - read_unlock_bh(&mhi_cntrl->pm_lock); - wake_up(&mhi_cntrl->state_event); - MHI_VERB("Exited\n"); - - return 0; -} - -void mhi_pm_m1_worker(struct work_struct *work) -{ - enum MHI_PM_STATE cur_state; - struct mhi_controller *mhi_cntrl; - - mhi_cntrl = container_of(work, struct mhi_controller, m1_worker); - - MHI_LOG("M1 state transition from dev_state:%s pm_state:%s\n", - TO_MHI_STATE_STR(mhi_cntrl->dev_state), - to_mhi_pm_state_str(mhi_cntrl->pm_state)); - - mutex_lock(&mhi_cntrl->pm_mutex); - write_lock_irq(&mhi_cntrl->pm_lock); - - /* we either Entered M3 or we did M3->M0 Exit */ - if (mhi_cntrl->pm_state != MHI_PM_M1) - goto invalid_pm_state; - - MHI_LOG("Transitioning to M2 Transition\n"); - cur_state = mhi_tryset_pm_state(mhi_cntrl, MHI_PM_M1_M2_TRANSITION); - if (unlikely(cur_state != MHI_PM_M1_M2_TRANSITION)) { - MHI_ERR("Failed to transition to state %s from %s\n", - to_mhi_pm_state_str(MHI_PM_M1_M2_TRANSITION), - to_mhi_pm_state_str(cur_state)); - goto invalid_pm_state; - } - - mhi_cntrl->dev_state = MHI_STATE_M2; - mhi_set_mhi_state(mhi_cntrl, MHI_STATE_M2); - write_unlock_irq(&mhi_cntrl->pm_lock); - mhi_cntrl->M2++; - - /* during M2 transition we cannot access DB registers must sleep */ - usleep_range(MHI_M2_DEBOUNCE_TMR_US, MHI_M2_DEBOUNCE_TMR_US + 50); - write_lock_irq(&mhi_cntrl->pm_lock); - - /* during de-bounce time could be receiving M0 Event */ - if (mhi_cntrl->pm_state == MHI_PM_M1_M2_TRANSITION) { - MHI_LOG("Entered M2 State\n"); - cur_state = mhi_tryset_pm_state(mhi_cntrl, MHI_PM_M2); - if (unlikely(cur_state != MHI_PM_M2)) { - MHI_ERR("Failed to transition to state %s from %s\n", - to_mhi_pm_state_str(MHI_PM_M2), - to_mhi_pm_state_str(cur_state)); - goto invalid_pm_state; - } - } - write_unlock_irq(&mhi_cntrl->pm_lock); - - /* transfer pending, exit M2 */ - if (unlikely(atomic_read(&mhi_cntrl->dev_wake))) { - MHI_VERB("Exiting M2 Immediately, count:%d\n", - atomic_read(&mhi_cntrl->dev_wake)); - read_lock_bh(&mhi_cntrl->pm_lock); - mhi_cntrl->wake_get(mhi_cntrl, true); - mhi_cntrl->wake_put(mhi_cntrl, false); - read_unlock_bh(&mhi_cntrl->pm_lock); - } else - mhi_cntrl->status_cb(mhi_cntrl, mhi_cntrl->priv_data, - MHI_CB_IDLE); - - mutex_unlock(&mhi_cntrl->pm_mutex); - return; - -invalid_pm_state: - write_unlock_irq(&mhi_cntrl->pm_lock); - mutex_unlock(&mhi_cntrl->pm_mutex); -} - -void mhi_pm_m1_transition(struct mhi_controller *mhi_cntrl) -{ - enum MHI_PM_STATE state; - - write_lock_irq(&mhi_cntrl->pm_lock); - mhi_cntrl->dev_state = mhi_get_m_state(mhi_cntrl); - if (mhi_cntrl->dev_state == MHI_STATE_M1) { - state = mhi_tryset_pm_state(mhi_cntrl, MHI_PM_M1); - - /* schedule M1->M2 transition */ - if (state == MHI_PM_M1) { - schedule_work(&mhi_cntrl->m1_worker); - mhi_cntrl->M1++; - } - } - write_unlock_irq(&mhi_cntrl->pm_lock); -} - -int mhi_pm_m3_transition(struct mhi_controller *mhi_cntrl) -{ - enum MHI_PM_STATE state; - - write_lock_irq(&mhi_cntrl->pm_lock); - mhi_cntrl->dev_state = MHI_STATE_M3; - state = mhi_tryset_pm_state(mhi_cntrl, MHI_PM_M3); - write_unlock_irq(&mhi_cntrl->pm_lock); - if (state != MHI_PM_M3) { - MHI_ERR("Failed to transition to state %s from %s\n", - to_mhi_pm_state_str(MHI_PM_M3), - to_mhi_pm_state_str(mhi_cntrl->pm_state)); - return -EIO; - } - wake_up(&mhi_cntrl->state_event); - mhi_cntrl->M3++; - - MHI_LOG("Entered mhi_state:%s pm_state:%s\n", - TO_MHI_STATE_STR(mhi_cntrl->dev_state), - to_mhi_pm_state_str(mhi_cntrl->pm_state)); - return 0; -} - -static int mhi_pm_amss_transition(struct mhi_controller *mhi_cntrl) -{ - int i; - struct mhi_event *mhi_event; - - MHI_LOG("Processing AMSS Transition\n"); - - write_lock_irq(&mhi_cntrl->pm_lock); - mhi_cntrl->ee = MHI_EE_AMSS; - write_unlock_irq(&mhi_cntrl->pm_lock); - wake_up(&mhi_cntrl->state_event); - - /* add elements to all HW event rings */ - read_lock_bh(&mhi_cntrl->pm_lock); - if (MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) { - read_unlock_bh(&mhi_cntrl->pm_lock); - return -EIO; - } - - MHI_LOG("mhi_db_hw_ring\n"); - mhi_event = mhi_cntrl->mhi_event; - for (i = 0; i < mhi_cntrl->total_ev_rings; i++, mhi_event++) { - struct mhi_ring *ring = &mhi_event->ring; - - if (mhi_event->offload_ev || !mhi_event->hw_ring) - continue; - - ring->wp = ring->base + ring->len - ring->el_size; - *ring->ctxt_wp = cpu_to_le64(ring->iommu_base + ring->len - ring->el_size); - /* all ring updates must get updated immediately */ - smp_wmb(); - - spin_lock_irq(&mhi_event->lock); - if (MHI_DB_ACCESS_VALID(mhi_cntrl->pm_state)) - mhi_ring_er_db(mhi_event); - spin_unlock_irq(&mhi_event->lock); - - } - read_unlock_bh(&mhi_cntrl->pm_lock); - - MHI_LOG("Adding new devices\n"); - - /* add supported devices */ - mhi_create_devices(mhi_cntrl); - - MHI_LOG("Exited\n"); - - return 0; -} - -/* handles both sys_err and shutdown transitions */ -static void mhi_pm_disable_transition(struct mhi_controller *mhi_cntrl, - enum MHI_PM_STATE transition_state) -{ - enum MHI_PM_STATE cur_state, prev_state; - struct mhi_event *mhi_event; - struct mhi_cmd_ctxt *cmd_ctxt; - struct mhi_cmd *mhi_cmd; - struct mhi_event_ctxt *er_ctxt; - int ret = 0, i; - u32 regVal; - - MHI_LOG("Enter with from pm_state:%s MHI_STATE:%s to pm_state:%s\n", - to_mhi_pm_state_str(mhi_cntrl->pm_state), - TO_MHI_STATE_STR(mhi_cntrl->dev_state), - to_mhi_pm_state_str(transition_state)); - - mutex_lock(&mhi_cntrl->pm_mutex); - write_lock_irq(&mhi_cntrl->pm_lock); - prev_state = mhi_cntrl->pm_state; - cur_state = mhi_tryset_pm_state(mhi_cntrl, transition_state); - if (cur_state == transition_state) { - mhi_cntrl->ee = MHI_EE_DISABLE_TRANSITION; - mhi_cntrl->dev_state = MHI_STATE_RESET; - } - write_unlock_irq(&mhi_cntrl->pm_lock); - - /* not handling sys_err, could be middle of shut down */ - if (cur_state != transition_state) { - MHI_LOG("Failed to transition to state:0x%x from:0x%x\n", - transition_state, cur_state); - mutex_unlock(&mhi_cntrl->pm_mutex); - return; - } - - /* trigger MHI RESET so device will not access host ddr */ - if (MHI_REG_ACCESS_VALID(prev_state)) { - u32 in_reset = -1; - u32 i; - - MHI_LOG("Trigger device into MHI_RESET\n"); - mhi_set_mhi_state(mhi_cntrl, MHI_STATE_RESET); - - /* wait for reset to be cleared */ - for (i = 0; i < mhi_cntrl->timeout_ms; i += 25) { //maybe miss msi interrupt - in_reset = -1; - ret = wait_event_timeout(mhi_cntrl->state_event, - mhi_read_reg_field(mhi_cntrl, - mhi_cntrl->regs, MHICTRL, - MHICTRL_RESET_MASK, - MHICTRL_RESET_SHIFT, &in_reset) - || !in_reset, msecs_to_jiffies(25)); - if (in_reset == 0) - break; - } - - if ((!ret || in_reset) && cur_state == MHI_PM_SYS_ERR_PROCESS) { - MHI_CRITICAL("Device failed to exit RESET state\n"); - mutex_unlock(&mhi_cntrl->pm_mutex); - return; - } - - /* Set the numbers of Event Rings supported */ - ret = mhi_read_reg_field(mhi_cntrl, mhi_cntrl->regs, MHICFG, MHICFG_NCH_MASK, MHICFG_NCH_SHIFT, ®Val); - MHI_LOG("%d channels, ret=%d\n", regVal, ret); - - mhi_write_reg_field(mhi_cntrl, mhi_cntrl->regs, MHICFG, MHICFG_NER_MASK, MHICFG_NER_SHIFT, NUM_MHI_EVT_RINGS); - /* - * device cleares INTVEC as part of RESET processing, - * re-program it - */ - mhi_write_reg(mhi_cntrl, mhi_cntrl->bhi, BHI_INTVEC, 0); - } - - MHI_LOG("Waiting for all pending event ring processing to complete\n"); - mhi_event = mhi_cntrl->mhi_event; - for (i = 0; i < mhi_cntrl->total_ev_rings; i++, mhi_event++) { - if (mhi_event->offload_ev) - continue; - tasklet_kill(&mhi_event->task); - } - - MHI_LOG("Reset all active channels and remove mhi devices\n"); - device_for_each_child(mhi_cntrl->dev, NULL, mhi_destroy_device); - - MHI_LOG("Finish resetting channels\n"); - - /* release lock and wait for all pending thread to complete */ - mutex_unlock(&mhi_cntrl->pm_mutex); - MHI_LOG("Waiting for all pending threads to complete\n"); - wake_up(&mhi_cntrl->state_event); - flush_work(&mhi_cntrl->m1_worker); - flush_work(&mhi_cntrl->st_worker); - flush_work(&mhi_cntrl->fw_worker); - - mutex_lock(&mhi_cntrl->pm_mutex); - - MHI_ASSERT(atomic_read(&mhi_cntrl->dev_wake), "dev_wake != 0"); - - /* reset the ev rings and cmd rings */ - MHI_LOG("Resetting EV CTXT and CMD CTXT\n"); - mhi_cmd = mhi_cntrl->mhi_cmd; - cmd_ctxt = mhi_cntrl->mhi_ctxt->cmd_ctxt; - for (i = 0; i < NR_OF_CMD_RINGS; i++, mhi_cmd++, cmd_ctxt++) { - struct mhi_ring *ring = &mhi_cmd->ring; - - ring->rp = ring->base; - ring->wp = ring->base; - cmd_ctxt->rp = cmd_ctxt->rbase; - cmd_ctxt->wp = cmd_ctxt->rbase; - } - - mhi_event = mhi_cntrl->mhi_event; - er_ctxt = mhi_cntrl->mhi_ctxt->er_ctxt; - for (i = 0; i < mhi_cntrl->total_ev_rings; i++, er_ctxt++, - mhi_event++) { - struct mhi_ring *ring = &mhi_event->ring; - - /* do not touch offload er */ - if (mhi_event->offload_ev) - continue; - - ring->rp = ring->base; - ring->wp = ring->base; - er_ctxt->rp = er_ctxt->rbase; - er_ctxt->wp = er_ctxt->rbase; - } - - if (cur_state == MHI_PM_SYS_ERR_PROCESS) { - mhi_ready_state_transition(mhi_cntrl); - } else { - /* move to disable state */ - write_lock_irq(&mhi_cntrl->pm_lock); - cur_state = mhi_tryset_pm_state(mhi_cntrl, MHI_PM_DISABLE); - write_unlock_irq(&mhi_cntrl->pm_lock); - if (unlikely(cur_state != MHI_PM_DISABLE)) - MHI_ERR("Error moving from pm state:%s to state:%s\n", - to_mhi_pm_state_str(cur_state), - to_mhi_pm_state_str(MHI_PM_DISABLE)); - } - - MHI_LOG("Exit with pm_state:%s mhi_state:%s\n", - to_mhi_pm_state_str(mhi_cntrl->pm_state), - TO_MHI_STATE_STR(mhi_cntrl->dev_state)); - - mutex_unlock(&mhi_cntrl->pm_mutex); -} - -int mhi_debugfs_trigger_reset(void *data, u64 val) -{ - struct mhi_controller *mhi_cntrl = data; - enum MHI_PM_STATE cur_state; - int ret; - - MHI_LOG("Trigger MHI Reset\n"); - - /* exit lpm first */ - mhi_cntrl->runtime_get(mhi_cntrl, mhi_cntrl->priv_data); - mhi_cntrl->runtime_put(mhi_cntrl, mhi_cntrl->priv_data); - - ret = wait_event_timeout(mhi_cntrl->state_event, - mhi_cntrl->dev_state == MHI_STATE_M0 || - MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state), - msecs_to_jiffies(mhi_cntrl->timeout_ms)); - - if (!ret || MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) { - MHI_ERR("Did not enter M0 state, cur_state:%s pm_state:%s\n", - TO_MHI_STATE_STR(mhi_cntrl->dev_state), - to_mhi_pm_state_str(mhi_cntrl->pm_state)); - return -EIO; - } - - write_lock_irq(&mhi_cntrl->pm_lock); - cur_state = mhi_tryset_pm_state(mhi_cntrl, MHI_PM_SYS_ERR_DETECT); - write_unlock_irq(&mhi_cntrl->pm_lock); - - if (cur_state == MHI_PM_SYS_ERR_DETECT) - schedule_work(&mhi_cntrl->syserr_worker); - - return 0; -} - -/* queue a new work item and scheduler work */ -int mhi_queue_state_transition(struct mhi_controller *mhi_cntrl, - enum MHI_ST_TRANSITION state) -{ - struct state_transition *item = kmalloc(sizeof(*item), GFP_ATOMIC); - unsigned long flags; - - if (!item) - return -ENOMEM; - - item->state = state; - spin_lock_irqsave(&mhi_cntrl->transition_lock, flags); - list_add_tail(&item->node, &mhi_cntrl->transition_list); - spin_unlock_irqrestore(&mhi_cntrl->transition_lock, flags); - - schedule_work(&mhi_cntrl->st_worker); - - return 0; -} - -void mhi_pm_sys_err_worker(struct work_struct *work) -{ - struct mhi_controller *mhi_cntrl = container_of(work, - struct mhi_controller, - syserr_worker); - - MHI_LOG("Enter with pm_state:%s MHI_STATE:%s\n", - to_mhi_pm_state_str(mhi_cntrl->pm_state), - TO_MHI_STATE_STR(mhi_cntrl->dev_state)); - - mhi_pm_disable_transition(mhi_cntrl, MHI_PM_SYS_ERR_PROCESS); -} - -void mhi_pm_st_worker(struct work_struct *work) -{ - struct state_transition *itr, *tmp; - LIST_HEAD(head); - struct mhi_controller *mhi_cntrl = container_of(work, - struct mhi_controller, - st_worker); - spin_lock_irq(&mhi_cntrl->transition_lock); - list_splice_tail_init(&mhi_cntrl->transition_list, &head); - spin_unlock_irq(&mhi_cntrl->transition_lock); - - list_for_each_entry_safe(itr, tmp, &head, node) { - list_del(&itr->node); - MHI_LOG("Transition to state:%s\n", - TO_MHI_STATE_TRANS_STR(itr->state)); - - if (mhi_cntrl->ee != mhi_get_exec_env(mhi_cntrl)) { - MHI_ERR("%s -> %s\n", TO_MHI_EXEC_STR(mhi_cntrl->ee), - TO_MHI_EXEC_STR(mhi_get_exec_env(mhi_cntrl))); - } - - switch (itr->state) { - case MHI_ST_TRANSITION_PBL: - write_lock_irq(&mhi_cntrl->pm_lock); - if (MHI_REG_ACCESS_VALID(mhi_cntrl->pm_state)) - mhi_cntrl->ee = mhi_get_exec_env(mhi_cntrl); - write_unlock_irq(&mhi_cntrl->pm_lock); - if (MHI_IN_PBL(mhi_cntrl->ee)) - wake_up(&mhi_cntrl->state_event); - break; - case MHI_ST_TRANSITION_READY: - mhi_ready_state_transition(mhi_cntrl); - break; - case MHI_ST_TRANSITION_SBL: - write_lock_irq(&mhi_cntrl->pm_lock); - mhi_cntrl->ee = MHI_EE_SBL; - write_unlock_irq(&mhi_cntrl->pm_lock); - mhi_create_devices(mhi_cntrl); - break; - case MHI_ST_TRANSITION_AMSS: - mhi_pm_amss_transition(mhi_cntrl); - break; - case MHI_ST_TRANSITION_FP: - write_lock_irq(&mhi_cntrl->pm_lock); - mhi_cntrl->ee = MHI_EE_FP; - write_unlock_irq(&mhi_cntrl->pm_lock); - wake_up(&mhi_cntrl->state_event); - mhi_create_devices(mhi_cntrl); - break; - default: - break; - } - kfree(itr); - } -} - -int mhi_async_power_up(struct mhi_controller *mhi_cntrl) -{ - int ret; - u32 bhi_offset; - enum MHI_EE current_ee; - enum MHI_ST_TRANSITION next_state; - u32 mhi_cfg = 0xFFFFFFFF; - u32 mhi_timeout = 10; - enum MHI_STATE mhiDevState; - - MHI_LOG("Requested to power on\n"); - -//# echo 1 > /sys/module/ep_pcie_core/parameters/debug_mask -//# echo 3 > /sys/kernel/debug/pcie-ep/case -//in sdx20 mimo offset is 0x100 -//ep_pcie_reg_dump: 0x0100 00000100 00000000 01000000 b8efc7ae 00010880 ecd23c0b 00000300 00000000 - while (mhi_cfg == 0xFFFFFFFF && mhi_timeout != 0) { //refer to MhiInitNewDev - ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->regs, MHICFG, &mhi_cfg); - if (ret) { - - } - MHI_LOG("mhi_cfg = 0x%x\n", mhi_cfg); - msleep(50); - mhi_timeout--; - } - if (mhi_cfg == 0xFFFFFFFF) - return EBUSY; - - mhiDevState = mhi_get_m_state(mhi_cntrl); - MHI_LOG("mhi_state = %s\n", mhi_state_str[mhiDevState]); - - if (mhiDevState >= MHI_STATE_M0) { - MHI_LOG("Trigger device into MHI_RESET\n"); - mhi_set_mhi_state(mhi_cntrl, MHI_STATE_RESET); - msleep(50); - mhiDevState = mhi_get_m_state(mhi_cntrl); - MHI_LOG("mhi_state = %s\n", mhi_state_str[mhiDevState]); - } - - /* set to default wake if not set */ - if (!mhi_cntrl->wake_get || !mhi_cntrl->wake_put) { - mhi_cntrl->wake_get = mhi_assert_dev_wake; - mhi_cntrl->wake_put = mhi_deassert_dev_wake; - } - - mutex_lock(&mhi_cntrl->pm_mutex); - mhi_cntrl->pm_state = MHI_PM_DISABLE; - - if (!mhi_cntrl->pre_init) { - /* setup device context */ - ret = mhi_init_dev_ctxt(mhi_cntrl); - if (ret) { - MHI_ERR("Error setting dev_context\n"); - goto error_dev_ctxt; - } - - ret = mhi_init_irq_setup(mhi_cntrl); - if (ret) { - MHI_ERR("Error setting up irq\n"); - goto error_setup_irq; - } - } - - /* setup bhi offset & intvec */ - write_lock_irq(&mhi_cntrl->pm_lock); - ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->regs, BHIOFF, &bhi_offset); - if (ret) { - write_unlock_irq(&mhi_cntrl->pm_lock); - MHI_ERR("Error getting bhi offset\n"); - goto error_bhi_offset; - } - - MHI_LOG("bhi_offset = 0x%x\n", bhi_offset); //this should be 0x100, in sdx20, bhi offset is 0x200 - mhi_cntrl->bhi = mhi_cntrl->regs + bhi_offset; - mhi_write_reg(mhi_cntrl, mhi_cntrl->bhi, BHI_INTVEC, 0); - mhi_cntrl->pm_state = MHI_PM_POR; - - mhi_timeout = 30; - while ((current_ee = mhi_get_exec_env(mhi_cntrl)) != MHI_EE_AMSS) - { - if (current_ee < MHI_EE_MAX) - { - MHI_LOG("wait for ee = %s\n", mhi_ee_str[current_ee]); - } - - msleep(500); - mhi_timeout--; - if (0 == mhi_timeout) - { - break; - } - } - - mhi_cntrl->ee = mhi_get_exec_env(mhi_cntrl); - current_ee = mhi_get_exec_env(mhi_cntrl); - write_unlock_irq(&mhi_cntrl->pm_lock); - - MHI_LOG("current_ee = %s\n", mhi_ee_str[current_ee]); - - /* confirm device is in valid exec env */ - if (!MHI_IN_PBL(current_ee) && current_ee != MHI_EE_AMSS) { - MHI_ERR("Not a valid ee for power on\n"); - ret = -EIO; - goto error_bhi_offset; - } - - /* transition to next state */ - next_state = MHI_IN_PBL(current_ee) ? - MHI_ST_TRANSITION_PBL : MHI_ST_TRANSITION_READY; - - mhi_queue_state_transition(mhi_cntrl, next_state); - - mhi_init_debugfs(mhi_cntrl); - mhi_cntrl_register_miscdev(mhi_cntrl); - - mutex_unlock(&mhi_cntrl->pm_mutex); - - MHI_LOG("Power on setup success\n"); - - - return 0; - -error_bhi_offset: - if (!mhi_cntrl->pre_init) - mhi_deinit_free_irq(mhi_cntrl); - -error_setup_irq: - if (!mhi_cntrl->pre_init) - mhi_deinit_dev_ctxt(mhi_cntrl); - -error_dev_ctxt: - mutex_unlock(&mhi_cntrl->pm_mutex); - - return ret; -} -EXPORT_SYMBOL(mhi_async_power_up); - -void mhi_power_down(struct mhi_controller *mhi_cntrl, bool graceful) -{ - enum MHI_PM_STATE cur_state; - MHI_LOG("enter\n"); - - /* if it's not graceful shutdown, force MHI to a linkdown state */ - if (!graceful) { - mutex_lock(&mhi_cntrl->pm_mutex); - write_lock_irq(&mhi_cntrl->pm_lock); - cur_state = mhi_tryset_pm_state(mhi_cntrl, - MHI_PM_LD_ERR_FATAL_DETECT); - write_unlock_irq(&mhi_cntrl->pm_lock); - mutex_unlock(&mhi_cntrl->pm_mutex); - if (cur_state != MHI_PM_LD_ERR_FATAL_DETECT) - MHI_ERR("Failed to move to state:%s from:%s\n", - to_mhi_pm_state_str(MHI_PM_LD_ERR_FATAL_DETECT), - to_mhi_pm_state_str(mhi_cntrl->pm_state)); - - mhi_pm_disable_transition(mhi_cntrl, MHI_PM_SHUTDOWN_PROCESS); - } - else { - device_for_each_child(mhi_cntrl->dev, NULL, mhi_destroy_device); - } - - mhi_cntrl_deregister_miscdev(mhi_cntrl); - mhi_deinit_debugfs(mhi_cntrl); - - if (!mhi_cntrl->pre_init) { - /* free all allocated resources */ - if (mhi_cntrl->fbc_image) { - mhi_free_bhie_table(mhi_cntrl, mhi_cntrl->fbc_image); - mhi_cntrl->fbc_image = NULL; - } - mhi_deinit_free_irq(mhi_cntrl); - mhi_deinit_dev_ctxt(mhi_cntrl); - } - -} -EXPORT_SYMBOL(mhi_power_down); - -int mhi_sync_power_up(struct mhi_controller *mhi_cntrl) -{ - int ret = mhi_async_power_up(mhi_cntrl); - - if (ret) - return ret; - - wait_event_timeout(mhi_cntrl->state_event, - mhi_cntrl->ee == MHI_EE_AMSS || - MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state), - msecs_to_jiffies(mhi_cntrl->timeout_ms)); - - return (mhi_cntrl->ee == MHI_EE_AMSS) ? 0 : -EIO; -} -EXPORT_SYMBOL(mhi_sync_power_up); - -int mhi_pm_suspend(struct mhi_controller *mhi_cntrl) -{ - int ret; - enum MHI_PM_STATE new_state; - struct mhi_chan *itr, *tmp; - - if (mhi_cntrl->pm_state == MHI_PM_DISABLE) - return -EINVAL; - - if (MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) - return -EIO; - - /* do a quick check to see if any pending data, then exit */ - if (atomic_read(&mhi_cntrl->dev_wake)) { - MHI_VERB("Busy, aborting M3\n"); - return -EBUSY; - } - - /* exit MHI out of M2 state */ - read_lock_bh(&mhi_cntrl->pm_lock); - mhi_cntrl->wake_get(mhi_cntrl, false); - read_unlock_bh(&mhi_cntrl->pm_lock); - - ret = wait_event_timeout(mhi_cntrl->state_event, - mhi_cntrl->dev_state == MHI_STATE_M0 || - mhi_cntrl->dev_state == MHI_STATE_M1 || - MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state), - msecs_to_jiffies(mhi_cntrl->timeout_ms)); - - read_lock_bh(&mhi_cntrl->pm_lock); - mhi_cntrl->wake_put(mhi_cntrl, false); - read_unlock_bh(&mhi_cntrl->pm_lock); - - if (!ret || MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) { - MHI_ERR( - "Did not enter M0||M1 state, cur_state:%s pm_state:%s\n", - TO_MHI_STATE_STR(mhi_cntrl->dev_state), - to_mhi_pm_state_str(mhi_cntrl->pm_state)); - return -EIO; - } - - write_lock_irq(&mhi_cntrl->pm_lock); - - if (atomic_read(&mhi_cntrl->dev_wake)) { - MHI_VERB("Busy, aborting M3\n"); - write_unlock_irq(&mhi_cntrl->pm_lock); - return -EBUSY; - } - - /* anytime after this, we will resume thru runtime pm framework */ - MHI_LOG("Allowing M3 transition\n"); - new_state = mhi_tryset_pm_state(mhi_cntrl, MHI_PM_M3_ENTER); - if (new_state != MHI_PM_M3_ENTER) { - write_unlock_irq(&mhi_cntrl->pm_lock); - MHI_ERR("Error setting to pm_state:%s from pm_state:%s\n", - to_mhi_pm_state_str(MHI_PM_M3_ENTER), - to_mhi_pm_state_str(mhi_cntrl->pm_state)); - return -EIO; - } - - /* set dev to M3 and wait for completion */ - mhi_set_mhi_state(mhi_cntrl, MHI_STATE_M3); - write_unlock_irq(&mhi_cntrl->pm_lock); - MHI_LOG("Wait for M3 completion\n"); - - ret = wait_event_timeout(mhi_cntrl->state_event, - mhi_cntrl->dev_state == MHI_STATE_M3 || - MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state), - msecs_to_jiffies(mhi_cntrl->timeout_ms)); - - if (!ret || MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) { - MHI_ERR("Did not enter M3 state, cur_state:%s pm_state:%s\n", - TO_MHI_STATE_STR(mhi_cntrl->dev_state), - to_mhi_pm_state_str(mhi_cntrl->pm_state)); - return -EIO; - } - - /* notify any clients we enter lpm */ - list_for_each_entry_safe(itr, tmp, &mhi_cntrl->lpm_chans, node) { - mutex_lock(&itr->mutex); - if (itr->mhi_dev) - mhi_notify(itr->mhi_dev, MHI_CB_LPM_ENTER); - mutex_unlock(&itr->mutex); - } - - return 0; -} -EXPORT_SYMBOL(mhi_pm_suspend); - -int mhi_pm_resume(struct mhi_controller *mhi_cntrl) -{ - enum MHI_PM_STATE cur_state; - int ret; - struct mhi_chan *itr, *tmp; - - MHI_LOG("Entered with pm_state:%s dev_state:%s\n", - to_mhi_pm_state_str(mhi_cntrl->pm_state), - TO_MHI_STATE_STR(mhi_cntrl->dev_state)); - - if (mhi_cntrl->pm_state == MHI_PM_DISABLE) - return 0; - - if (MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) - return -EIO; - - MHI_ASSERT(mhi_cntrl->pm_state != MHI_PM_M3, "mhi_pm_state != M3"); - - /* notify any clients we enter lpm */ - list_for_each_entry_safe(itr, tmp, &mhi_cntrl->lpm_chans, node) { - mutex_lock(&itr->mutex); - if (itr->mhi_dev) - mhi_notify(itr->mhi_dev, MHI_CB_LPM_EXIT); - mutex_unlock(&itr->mutex); - } - - write_lock_irq(&mhi_cntrl->pm_lock); - cur_state = mhi_tryset_pm_state(mhi_cntrl, MHI_PM_M3_EXIT); - if (cur_state != MHI_PM_M3_EXIT) { - write_unlock_irq(&mhi_cntrl->pm_lock); - MHI_ERR("Error setting to pm_state:%s from pm_state:%s\n", - to_mhi_pm_state_str(MHI_PM_M3_EXIT), - to_mhi_pm_state_str(mhi_cntrl->pm_state)); - return -EIO; - } - - /* set dev to M0 and wait for completion */ - mhi_set_mhi_state(mhi_cntrl, MHI_STATE_M0); - write_unlock_irq(&mhi_cntrl->pm_lock); - - ret = wait_event_timeout(mhi_cntrl->state_event, - mhi_cntrl->dev_state == MHI_STATE_M0 || - MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state), - msecs_to_jiffies(mhi_cntrl->timeout_ms)); - - if (!ret || MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) { - MHI_ERR("Did not enter M0 state, cur_state:%s pm_state:%s\n", - TO_MHI_STATE_STR(mhi_cntrl->dev_state), - to_mhi_pm_state_str(mhi_cntrl->pm_state)); - return -EIO; - } - - return 0; -} - -static int __mhi_device_get_sync(struct mhi_controller *mhi_cntrl) -{ - int ret; - - read_lock_bh(&mhi_cntrl->pm_lock); - mhi_cntrl->wake_get(mhi_cntrl, false); - if (MHI_PM_IN_SUSPEND_STATE(mhi_cntrl->pm_state)) { - mhi_cntrl->runtime_get(mhi_cntrl, mhi_cntrl->priv_data); - mhi_cntrl->runtime_put(mhi_cntrl, mhi_cntrl->priv_data); - } - read_unlock_bh(&mhi_cntrl->pm_lock); - - ret = wait_event_timeout(mhi_cntrl->state_event, - mhi_cntrl->dev_state == MHI_STATE_M0 || - MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state), - msecs_to_jiffies(mhi_cntrl->timeout_ms)); - - if (!ret || MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) { - MHI_ERR("Did not enter M0 state, cur_state:%s pm_state:%s\n", - TO_MHI_STATE_STR(mhi_cntrl->dev_state), - to_mhi_pm_state_str(mhi_cntrl->pm_state)); - read_lock_bh(&mhi_cntrl->pm_lock); - mhi_cntrl->wake_put(mhi_cntrl, false); - read_unlock_bh(&mhi_cntrl->pm_lock); - return -EIO; - } - - return 0; -} - -void mhi_device_get(struct mhi_device *mhi_dev) -{ - struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; - - atomic_inc(&mhi_dev->dev_wake); - read_lock_bh(&mhi_cntrl->pm_lock); - mhi_cntrl->wake_get(mhi_cntrl, false); - read_unlock_bh(&mhi_cntrl->pm_lock); -} -EXPORT_SYMBOL(mhi_device_get); - -int mhi_device_get_sync(struct mhi_device *mhi_dev) -{ - struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; - int ret; - - ret = __mhi_device_get_sync(mhi_cntrl); - if (!ret) - atomic_inc(&mhi_dev->dev_wake); - - return ret; -} -EXPORT_SYMBOL(mhi_device_get_sync); - -void mhi_device_put(struct mhi_device *mhi_dev) -{ - struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; - - atomic_dec(&mhi_dev->dev_wake); - read_lock_bh(&mhi_cntrl->pm_lock); - mhi_cntrl->wake_put(mhi_cntrl, false); - read_unlock_bh(&mhi_cntrl->pm_lock); -} -EXPORT_SYMBOL(mhi_device_put); - -int mhi_force_rddm_mode(struct mhi_controller *mhi_cntrl) -{ - int ret; - - MHI_LOG("Enter with pm_state:%s ee:%s\n", - to_mhi_pm_state_str(mhi_cntrl->pm_state), - TO_MHI_EXEC_STR(mhi_cntrl->ee)); - - /* before rddm mode, we need to enter M0 state */ - ret = __mhi_device_get_sync(mhi_cntrl); - if (ret) - return ret; - - mutex_lock(&mhi_cntrl->pm_mutex); - write_lock_irq(&mhi_cntrl->pm_lock); - if (!MHI_REG_ACCESS_VALID(mhi_cntrl->pm_state)) - goto no_reg_access; - - MHI_LOG("Triggering SYS_ERR to force rddm state\n"); - - mhi_set_mhi_state(mhi_cntrl, MHI_STATE_SYS_ERR); - mhi_cntrl->wake_put(mhi_cntrl, false); - write_unlock_irq(&mhi_cntrl->pm_lock); - mutex_unlock(&mhi_cntrl->pm_mutex); - - /* wait for rddm event */ - MHI_LOG("Waiting for device to enter RDDM state\n"); - ret = wait_event_timeout(mhi_cntrl->state_event, - mhi_cntrl->ee == MHI_EE_RDDM, - msecs_to_jiffies(mhi_cntrl->timeout_ms)); - ret = !ret ? 0 : -EIO; - - MHI_LOG("Exiting with pm_state:%s ee:%s ret:%d\n", - to_mhi_pm_state_str(mhi_cntrl->pm_state), - TO_MHI_EXEC_STR(mhi_cntrl->ee), ret); - - return ret; - -no_reg_access: - mhi_cntrl->wake_put(mhi_cntrl, false); - write_unlock_irq(&mhi_cntrl->pm_lock); - mutex_unlock(&mhi_cntrl->pm_mutex); - - return -EIO; -} -EXPORT_SYMBOL(mhi_force_rddm_mode); diff --git a/fibocom_MHI/src/devices/mhi_netdev.c b/fibocom_MHI/src/devices/mhi_netdev.c deleted file mode 100644 index d34716e..0000000 --- a/fibocom_MHI/src/devices/mhi_netdev.c +++ /dev/null @@ -1,1313 +0,0 @@ -/* Copyright (c) 2018, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "../core/mhi.h" -#include "mhi_netdev.h" - -struct qmap_hdr { - u8 cd_rsvd_pad; - u8 mux_id; - u16 pkt_len; -} __packed; -#define FIBO_QMAP_MUX_ID 0x81 - -#ifdef CONFIG_MHI_NETDEV_MBIM -#else -static uint __read_mostly qmap_mode = 1; -module_param(qmap_mode, uint, S_IRUGO); -#endif - -#define MHI_NETDEV_DRIVER_NAME "mhi_netdev" -#define WATCHDOG_TIMEOUT (30 * HZ) - -#define MSG_VERB(fmt, ...) do { \ - if (mhi_netdev->msg_lvl <= MHI_MSG_LVL_VERBOSE) \ - pr_err("[D][%s] " fmt, __func__, ##__VA_ARGS__);\ -} while (0) - -#define MHI_ASSERT(cond, msg) do { \ - if (cond) { \ - MSG_ERR(msg); \ - WARN_ON(cond); \ - } \ -} while (0) - -#define MSG_LOG(fmt, ...) do { \ - if (mhi_netdev->msg_lvl <= MHI_MSG_LVL_INFO) \ - pr_err("[I][%s] " fmt, __func__, ##__VA_ARGS__);\ -} while (0) - -#define MSG_ERR(fmt, ...) do { \ - if (mhi_netdev->msg_lvl <= MHI_MSG_LVL_ERROR) \ - pr_err("[E][%s] " fmt, __func__, ##__VA_ARGS__); \ -} while (0) - -struct mhi_stats { - u32 rx_int; - u32 tx_full; - u32 tx_pkts; - u32 rx_budget_overflow; - u32 rx_frag; - u32 alloc_failed; -}; - -/* important: do not exceed sk_buf->cb (48 bytes) */ -struct mhi_skb_priv { - void *buf; - size_t size; - struct mhi_netdev *mhi_netdev; -}; - -struct mhi_netdev { - int alias; - struct mhi_device *mhi_dev; - spinlock_t rx_lock; - bool enabled; - rwlock_t pm_lock; /* state change lock */ - int (*rx_queue)(struct mhi_netdev *mhi_netdev, gfp_t gfp_t); - struct work_struct alloc_work; - int wake; - - struct sk_buff_head rx_allocated; - - u32 mru; - const char *interface_name; - struct napi_struct napi; - struct net_device *ndev; - struct sk_buff *frag_skb; - bool recycle_buf; - - struct mhi_stats stats; - struct dentry *dentry; - enum MHI_DEBUG_LEVEL msg_lvl; -#ifdef CONFIG_MHI_NETDEV_MBIM - u16 tx_seq; - u16 rx_seq; - u32 rx_max; -#endif -}; - -struct mhi_netdev_priv { - struct mhi_netdev *mhi_netdev; -}; - -static struct mhi_driver mhi_netdev_driver; -static void mhi_netdev_create_debugfs(struct mhi_netdev *mhi_netdev); - - -static struct mhi_netdev * g_mhi_netdev = NULL; - -static inline void qmap_hex_dump(const char *tag, unsigned char *data, unsigned len) { - //#define MHI_NETDEV_DEBUG - #ifdef MHI_NETDEV_DEBUG - if (g_mhi_netdev && g_mhi_netdev->msg_lvl > MHI_MSG_LVL_CRITICAL) - { - int i; - printk("dump %s,%s:len=%d \n", tag, g_mhi_netdev->ndev->name, len); - for (i = 0; i < len; i++) - { - printk(" 0x%02x", data[i]); - if (((i+1) % 16) == 0) - { - printk("\n"); - } - } - - printk("\n"); - } - #endif -} - - -static int macaddr_check = 0; -static int mhi_netdev_macaddr_check_get(char * buffer, const struct kernel_param * kp) -{ - char mac_str[32]; - - if (g_mhi_netdev == NULL) - { - return sprintf(buffer, "%s\n", "null");; - } - - snprintf(mac_str, sizeof(mac_str), "%02x:%02x:%02x:%02x:%02x:%02x\n", - g_mhi_netdev->ndev->dev_addr[0], - g_mhi_netdev->ndev->dev_addr[1], - g_mhi_netdev->ndev->dev_addr[2], - g_mhi_netdev->ndev->dev_addr[3], - g_mhi_netdev->ndev->dev_addr[4], - g_mhi_netdev->ndev->dev_addr[5]); - - return sprintf(buffer, "%s", mac_str); - -} - - -static int mhi_netdev_macaddr_check_set(const char * val, const struct kernel_param * kp) -{ - if (g_mhi_netdev == NULL) - { - return 0; - } - - if (val[0] == '1') - { - if (!is_valid_ether_addr(g_mhi_netdev->ndev->dev_addr)) - { - eth_random_addr(g_mhi_netdev->ndev->dev_addr); - g_mhi_netdev->ndev->addr_assign_type = NET_ADDR_RANDOM; - - if (!is_valid_ether_addr(g_mhi_netdev->ndev->dev_addr)) - { - eth_random_addr(g_mhi_netdev->ndev->dev_addr); - } - else - { - printk("invalid ether addr\n"); - } - } - - return 0; - } - - return -EINVAL; -} - -module_param_call(macaddr_check, mhi_netdev_macaddr_check_set, mhi_netdev_macaddr_check_get, &macaddr_check, 0644); - - - -static void mhi_netdev_skb_destructor(struct sk_buff *skb) -{ - struct mhi_skb_priv *skb_priv = (struct mhi_skb_priv *)(skb->cb); - struct mhi_netdev *mhi_netdev = skb_priv->mhi_netdev; - - skb->data = skb->head; - skb_reset_tail_pointer(skb); - skb->len = 0; - MHI_ASSERT(skb->data != skb_priv->buf, "incorrect buf"); - skb_queue_tail(&mhi_netdev->rx_allocated, skb); -} - -static int mhi_netdev_alloc_skb(struct mhi_netdev *mhi_netdev, gfp_t gfp_t) -{ - u32 cur_mru = mhi_netdev->mru; - struct mhi_device *mhi_dev = mhi_netdev->mhi_dev; - struct mhi_skb_priv *skb_priv; - int ret; - struct sk_buff *skb; - int no_tre = mhi_get_no_free_descriptors(mhi_dev, DMA_FROM_DEVICE); - int i; - - for (i = 0; i < no_tre; i++) { - skb = alloc_skb(cur_mru + ETH_HLEN, gfp_t); - if (!skb) - return -ENOMEM; - - skb_reserve(skb, ETH_HLEN); - - read_lock_bh(&mhi_netdev->pm_lock); - if (unlikely(!mhi_netdev->enabled)) { - MSG_ERR("Interface not enabled\n"); - ret = -EIO; - goto error_queue; - } - - skb_priv = (struct mhi_skb_priv *)skb->cb; - skb_priv->buf = skb->data; - skb_priv->size = cur_mru; - skb_priv->mhi_netdev = mhi_netdev; - skb->dev = mhi_netdev->ndev; - - if (mhi_netdev->recycle_buf) - skb->destructor = mhi_netdev_skb_destructor; - - spin_lock_bh(&mhi_netdev->rx_lock); - ret = mhi_queue_transfer(mhi_dev, DMA_FROM_DEVICE, skb, - skb_priv->size, MHI_EOT); - spin_unlock_bh(&mhi_netdev->rx_lock); - - if (ret) { - MSG_ERR("Failed to queue skb, ret:%d\n", ret); - ret = -EIO; - goto error_queue; - } - - read_unlock_bh(&mhi_netdev->pm_lock); - } - - return 0; - -error_queue: - skb->destructor = NULL; - read_unlock_bh(&mhi_netdev->pm_lock); - dev_kfree_skb_any(skb); - - return ret; -} - -static void mhi_netdev_alloc_work(struct work_struct *work) -{ - struct mhi_netdev *mhi_netdev = container_of(work, struct mhi_netdev, - alloc_work); - /* sleep about 1 sec and retry, that should be enough time - * for system to reclaim freed memory back. - */ - const int sleep_ms = 1000; - int retry = 60; - int ret; - - MSG_LOG("Entered\n"); - do { - ret = mhi_netdev_alloc_skb(mhi_netdev, GFP_KERNEL); - /* sleep and try again */ - if (ret == -ENOMEM) { - msleep(sleep_ms); - retry--; - } - } while (ret == -ENOMEM && retry); - - MSG_LOG("Exit with status:%d retry:%d\n", ret, retry); -} - -/* we will recycle buffers */ -static int mhi_netdev_skb_recycle(struct mhi_netdev *mhi_netdev, gfp_t gfp_t) -{ - struct mhi_device *mhi_dev = mhi_netdev->mhi_dev; - int no_tre; - int ret = 0; - struct sk_buff *skb; - struct mhi_skb_priv *skb_priv; - - read_lock_bh(&mhi_netdev->pm_lock); - if (!mhi_netdev->enabled) { - read_unlock_bh(&mhi_netdev->pm_lock); - return -EIO; - } - - no_tre = mhi_get_no_free_descriptors(mhi_dev, DMA_FROM_DEVICE); - - spin_lock_bh(&mhi_netdev->rx_lock); - while (no_tre) { - skb = skb_dequeue(&mhi_netdev->rx_allocated); - - /* no free buffers to recycle, reschedule work */ - if (!skb) { - ret = -ENOMEM; - goto error_queue; - } - - skb_priv = (struct mhi_skb_priv *)(skb->cb); - ret = mhi_queue_transfer(mhi_dev, DMA_FROM_DEVICE, skb, - skb_priv->size, MHI_EOT); - - /* failed to queue buffer */ - if (ret) { - MSG_ERR("Failed to queue skb, ret:%d\n", ret); - skb_queue_tail(&mhi_netdev->rx_allocated, skb); - goto error_queue; - } - - no_tre--; - } - -error_queue: - spin_unlock_bh(&mhi_netdev->rx_lock); - read_unlock_bh(&mhi_netdev->pm_lock); - - return ret; -} - -static void mhi_netdev_dealloc(struct mhi_netdev *mhi_netdev) -{ - struct sk_buff *skb; - - skb = skb_dequeue(&mhi_netdev->rx_allocated); - while (skb) { - skb->destructor = NULL; - kfree_skb(skb); - skb = skb_dequeue(&mhi_netdev->rx_allocated); - } -} - -static int mhi_netdev_poll(struct napi_struct *napi, int budget) -{ - struct net_device *dev = napi->dev; - struct mhi_netdev_priv *mhi_netdev_priv = netdev_priv(dev); - struct mhi_netdev *mhi_netdev = mhi_netdev_priv->mhi_netdev; - struct mhi_device *mhi_dev = mhi_netdev->mhi_dev; - int rx_work = 0; - int ret; - - MSG_VERB("Entered\n"); - - read_lock_bh(&mhi_netdev->pm_lock); - - if (!mhi_netdev->enabled) { - MSG_LOG("interface is disabled!\n"); - napi_complete(napi); - read_unlock_bh(&mhi_netdev->pm_lock); - return 0; - } - - mhi_device_get(mhi_dev); - - rx_work = mhi_poll(mhi_dev, budget); - if (rx_work < 0) { - MSG_ERR("Error polling ret:%d\n", rx_work); - rx_work = 0; - napi_complete(napi); - goto exit_poll; - } - - /* queue new buffers */ - ret = mhi_netdev->rx_queue(mhi_netdev, GFP_ATOMIC); - if (ret == -ENOMEM) { - MSG_LOG("out of tre, queuing bg worker\n"); - mhi_netdev->stats.alloc_failed++; - schedule_work(&mhi_netdev->alloc_work); - } - - /* complete work if # of packet processed less than allocated budget */ - if (rx_work < budget) - napi_complete(napi); - else - mhi_netdev->stats.rx_budget_overflow++; - -exit_poll: - mhi_device_put(mhi_dev); - read_unlock_bh(&mhi_netdev->pm_lock); - - MSG_VERB("polled %d pkts\n", rx_work); - - return rx_work; -} - -static int mhi_netdev_open(struct net_device *dev) -{ - struct mhi_netdev_priv *mhi_netdev_priv = netdev_priv(dev); - struct mhi_netdev *mhi_netdev = mhi_netdev_priv->mhi_netdev; - struct mhi_device *mhi_dev = mhi_netdev->mhi_dev; - - MSG_LOG("Opened net dev interface\n"); - - /* tx queue may not necessarily be stopped already - * so stop the queue if tx path is not enabled - */ - if (!mhi_dev->ul_chan) - netif_stop_queue(dev); - else - netif_start_queue(dev); - - return 0; - -} - -static int mhi_netdev_change_mtu(struct net_device *dev, int new_mtu) -{ - struct mhi_netdev_priv *mhi_netdev_priv = netdev_priv(dev); - struct mhi_netdev *mhi_netdev = mhi_netdev_priv->mhi_netdev; - struct mhi_device *mhi_dev = mhi_netdev->mhi_dev; - - if (new_mtu < 0 || mhi_dev->mtu < new_mtu) - return -EINVAL; - - dev->mtu = new_mtu; - return 0; -} - -#ifdef CONFIG_MHI_NETDEV_MBIM -static struct sk_buff *mhi_mbim_tx_fixup(struct mhi_netdev *mhi_netdev, struct sk_buff *skb, struct net_device *dev) { - struct usb_cdc_ncm_nth16 *nth16; - struct usb_cdc_ncm_ndp16 *ndp16; - __le32 sign; - u8 *c; - u16 tci = 0; - unsigned int skb_len; - - qmap_hex_dump(__func__, skb->data, skb->len); - - if (skb->len > VLAN_ETH_HLEN && __vlan_get_tag(skb, &tci) == 0) - { - skb_pull(skb, VLAN_ETH_HLEN); - } - else - { - skb_pull(skb, ETH_HLEN); - } - - skb_len = skb->len; - - if (skb_headroom(skb) < sizeof(struct usb_cdc_ncm_nth16)) { - printk("skb_headroom small!\n"); - return NULL; - } - - if (skb_tailroom(skb) < (sizeof(struct usb_cdc_ncm_ndp16) + sizeof(struct usb_cdc_ncm_dpe16) * 2)) { - if (skb_pad(skb, (sizeof(struct usb_cdc_ncm_ndp16) + sizeof(struct usb_cdc_ncm_dpe16) * 2))) { - printk("skb_tailroom small!\n"); - return NULL; - } - } - - skb_push(skb, sizeof(struct usb_cdc_ncm_nth16)); - skb_put(skb, sizeof(struct usb_cdc_ncm_ndp16) + sizeof(struct usb_cdc_ncm_dpe16) * 2); - - nth16 = (struct usb_cdc_ncm_nth16 *)skb->data; - nth16->dwSignature = cpu_to_le32(USB_CDC_NCM_NTH16_SIGN); - nth16->wHeaderLength = cpu_to_le16(sizeof(struct usb_cdc_ncm_nth16)); - nth16->wSequence = cpu_to_le16(mhi_netdev->tx_seq++); - nth16->wBlockLength = cpu_to_le16(skb->len); - nth16->wNdpIndex = cpu_to_le16(sizeof(struct usb_cdc_ncm_nth16) + skb_len); - - sign = cpu_to_le32(USB_CDC_MBIM_NDP16_IPS_SIGN); - c = (u8 *)&sign; - //tci = 0; - c[3] = tci; - - ndp16 = (struct usb_cdc_ncm_ndp16 *)(skb->data + nth16->wNdpIndex); - ndp16->dwSignature = sign; - ndp16->wLength = cpu_to_le16(sizeof(struct usb_cdc_ncm_ndp16) + sizeof(struct usb_cdc_ncm_dpe16) * 2); - ndp16->wNextNdpIndex = 0; - - ndp16->dpe16[0].wDatagramIndex = sizeof(struct usb_cdc_ncm_nth16); - ndp16->dpe16[0].wDatagramLength = skb_len; - - ndp16->dpe16[1].wDatagramIndex = 0; - ndp16->dpe16[1].wDatagramLength = 0; - - return skb; -} - -static int mhi_mbim_rx_fixup(struct mhi_netdev *mhi_netdev, struct sk_buff *skb_in, struct net_device *dev) { - struct usb_cdc_ncm_nth16 *nth16; - int ndpoffset, len; - u16 wSequence; - struct mhi_netdev *ctx = mhi_netdev; - - if (skb_in->len < (sizeof(struct usb_cdc_ncm_nth16) + sizeof(struct usb_cdc_ncm_ndp16))) { - MSG_ERR("frame too short\n"); - goto error; - } - - nth16 = (struct usb_cdc_ncm_nth16 *)skb_in->data; - - if (nth16->dwSignature != cpu_to_le32(USB_CDC_NCM_NTH16_SIGN)) { - MSG_ERR("invalid NTH16 signature <%#010x>\n", le32_to_cpu(nth16->dwSignature)); - goto error; - } - - len = le16_to_cpu(nth16->wBlockLength); - if (len > ctx->rx_max) { - MSG_ERR("unsupported NTB block length %u/%u\n", len, ctx->rx_max); - goto error; - } - - wSequence = le16_to_cpu(nth16->wSequence); - if (ctx->rx_seq != wSequence) { - MSG_ERR("sequence number glitch prev=%d curr=%d\n", ctx->rx_seq, wSequence); - } - ctx->rx_seq = wSequence + 1; - - ndpoffset = nth16->wNdpIndex; - - while (ndpoffset > 0) { - struct usb_cdc_ncm_ndp16 *ndp16 ; - struct usb_cdc_ncm_dpe16 *dpe16; - int nframes, x; - u8 *c; - u16 tci = 0; - - if (skb_in->len < (ndpoffset + sizeof(struct usb_cdc_ncm_ndp16))) { - MSG_ERR("invalid NDP offset <%u>\n", ndpoffset); - goto error; - } - - ndp16 = (struct usb_cdc_ncm_ndp16 *)(skb_in->data + ndpoffset); - - if (le16_to_cpu(ndp16->wLength) < 0x10) { - MSG_ERR("invalid DPT16 length <%u>\n", le16_to_cpu(ndp16->wLength)); - goto error; - } - - nframes = ((le16_to_cpu(ndp16->wLength) - sizeof(struct usb_cdc_ncm_ndp16)) / sizeof(struct usb_cdc_ncm_dpe16)); - - if (skb_in->len < (sizeof(struct usb_cdc_ncm_ndp16) + nframes * (sizeof(struct usb_cdc_ncm_dpe16)))) { - MSG_ERR("Invalid nframes = %d\n", nframes); - goto error; - } - - switch (ndp16->dwSignature & cpu_to_le32(0x00ffffff)) { - case cpu_to_le32(USB_CDC_MBIM_NDP16_IPS_SIGN): - c = (u8 *)&ndp16->dwSignature; - tci = c[3]; - /* tag IPS<0> packets too if MBIM_IPS0_VID exists */ - //if (!tci && info->flags & FLAG_IPS0_VLAN) - // tci = MBIM_IPS0_VID; - break; - case cpu_to_le32(USB_CDC_MBIM_NDP16_DSS_SIGN): - c = (u8 *)&ndp16->dwSignature; - tci = c[3] + 256; - break; - default: - MSG_ERR("unsupported NDP signature <0x%08x>\n", le32_to_cpu(ndp16->dwSignature)); - goto error; - } - - #if 0 - if (tci != 0) { - MSG_ERR("unsupported tci %d by now\n", tci); - goto error; - } - #endif - - dpe16 = ndp16->dpe16; - - for (x = 0; x < nframes; x++, dpe16++) { - int offset = le16_to_cpu(dpe16->wDatagramIndex); - int skb_len = le16_to_cpu(dpe16->wDatagramLength); - struct sk_buff *skb; - - if (offset == 0 || skb_len == 0) { - break; - } - - /* sanity checking */ - if (((offset + skb_len) > skb_in->len) || (skb_len > ctx->rx_max)) { - MSG_ERR("invalid frame detected (ignored) x=%d, offset=%d, skb_len=%u\n", x, offset, skb_len); - goto error; - } - - skb = skb_clone(skb_in, GFP_ATOMIC); - if (!skb) { - MSG_ERR("skb_clone fail\n"); - goto error; - } - - skb_pull(skb, offset); - skb_trim(skb, skb_len); - switch (skb->data[0] & 0xf0) { - case 0x40: - skb->protocol = htons(ETH_P_IP); - break; - case 0x60: - skb->protocol = htons(ETH_P_IPV6); - break; - default: - MSG_ERR("unknow skb->protocol %02x\n", skb->data[0]); - goto error; - } - skb_reset_mac_header(skb); - - /* map MBIM session to VLAN */ - if (tci) - __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), tci); - - netif_receive_skb(skb); - } - - /* are there more NDPs to process? */ - ndpoffset = le16_to_cpu(ndp16->wNextNdpIndex); - } - - return 1; -error: - MSG_ERR("%s error\n", __func__); - return 0; -} -#else -static struct sk_buff *mhi_qmap_tx_fixup(struct mhi_netdev *mhi_netdev, struct sk_buff *skb, struct net_device *dev) { - struct qmap_hdr *qhdr; - u16 tci = 0; - - if (skb->len > VLAN_ETH_HLEN && __vlan_get_tag(skb, &tci) == 0) - { - skb_pull(skb, VLAN_ETH_HLEN); - } - else - { - skb_pull(skb, ETH_HLEN); - } - - if (skb_headroom(skb) < sizeof(struct qmap_hdr)) { - printk("skb_headroom small!\n"); - return NULL; - } - - qhdr = (struct qmap_hdr *)skb_push(skb, sizeof(struct qmap_hdr)); - qhdr->cd_rsvd_pad = 0; - qhdr->mux_id = FIBO_QMAP_MUX_ID + tci; - qhdr->pkt_len = cpu_to_be16(skb->len - sizeof(struct qmap_hdr)); - - return skb; -} - -static int mhi_qmap_rx_fixup(struct mhi_netdev *mhi_netdev, struct sk_buff *skb_in, struct net_device *dev) -{ - while (skb_in->len > sizeof(struct qmap_hdr)) - { - struct qmap_hdr *qhdr = (struct qmap_hdr *)skb_in->data; - struct sk_buff *skb = NULL; - int pkt_len = be16_to_cpu(qhdr->pkt_len); - u16 tci = qhdr->mux_id - FIBO_QMAP_MUX_ID; - int skb_len; - int ret; - - if (skb_in->len < (pkt_len + sizeof(struct qmap_hdr))) - { - MSG_ERR("drop qmap unknow pkt, len=%d, pkt_len=%d\n", skb_in->len, pkt_len); - goto error; - } - - if (qhdr->cd_rsvd_pad & 0x80) - { - MSG_ERR("drop qmap command packet %x\n", qhdr->cd_rsvd_pad); - skb_pull(skb_in, pkt_len + sizeof(struct qmap_hdr)); - continue; - } - - skb_len = pkt_len - (qhdr->cd_rsvd_pad&0x3F); - - skb = netdev_alloc_skb_ip_align(dev, skb_len + ETH_HLEN); - if (!skb) - { - MSG_ERR("netdev_alloc_skb_ip_align fail\n"); - goto error; - } - - switch (skb_in->data[sizeof(struct qmap_hdr)] & 0xf0) - { - case 0x40: - { - skb->protocol = htons(ETH_P_IP); - break; - } - - case 0x60: - { - skb->protocol = htons(ETH_P_IPV6); - break; - } - - default: - { - MSG_ERR("unknow skb->protocol %02x\n", skb->data[0]); - kfree_skb(skb); - goto error; - } - } - - /* add an ethernet header */ - skb_put(skb, ETH_HLEN); - skb_reset_mac_header(skb); - eth_hdr(skb)->h_proto = skb->protocol;; - eth_zero_addr(eth_hdr(skb)->h_source); - memcpy(eth_hdr(skb)->h_dest, dev->dev_addr, ETH_ALEN); - - /* add datagram */ - #if (LINUX_VERSION_CODE < KERNEL_VERSION( 4,15,0 )) - fibo_skb_put_data(skb, skb_in->data + sizeof(struct qmap_hdr), skb_len); - #else - skb_put_data(skb, skb_in->data + sizeof(struct qmap_hdr), skb_len); - #endif - - skb_pull(skb, ETH_HLEN); - - /* map MBIM session to VLAN */ - if (tci) - __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), tci); - - ret = netif_receive_skb(skb); - - skb_pull(skb_in, pkt_len + sizeof(struct qmap_hdr)); - } - - return 1; - -error: - MSG_ERR("%s error\n", __func__); - return 0; -} -#endif - -static int mhi_netdev_xmit(struct sk_buff *skb, struct net_device *dev) -{ - struct mhi_netdev_priv *mhi_netdev_priv = netdev_priv(dev); - struct mhi_netdev *mhi_netdev = mhi_netdev_priv->mhi_netdev; - struct mhi_device *mhi_dev = mhi_netdev->mhi_dev; - int res = 0; - struct mhi_skb_priv *tx_priv; - - MSG_VERB("Entered\n"); - - tx_priv = (struct mhi_skb_priv *)(skb->cb); - tx_priv->mhi_netdev = mhi_netdev; - read_lock_bh(&mhi_netdev->pm_lock); - - if (unlikely(!mhi_netdev->enabled)) { - /* Only reason interface could be disabled and we get data - * is due to an SSR. We do not want to stop the queue and - * return error. Instead we will flush all the uplink packets - * and return successful - */ - res = NETDEV_TX_OK; - dev_kfree_skb_any(skb); - goto mhi_xmit_exit; - } - -#ifdef CONFIG_MHI_NETDEV_MBIM - if (mhi_mbim_tx_fixup(mhi_netdev, skb, dev) == NULL) { - res = NETDEV_TX_OK; - dev_kfree_skb_any(skb); - goto mhi_xmit_exit; - } -#else - if (qmap_mode) { - if (mhi_qmap_tx_fixup(mhi_netdev, skb, dev) == NULL) { - res = NETDEV_TX_OK; - dev_kfree_skb_any(skb); - goto mhi_xmit_exit; - } - } -#endif - - qmap_hex_dump(__func__, skb->data, skb->len); - - res = mhi_queue_transfer(mhi_dev, DMA_TO_DEVICE, skb, skb->len, - MHI_EOT); - if (res) { - MSG_VERB("Failed to queue with reason:%d\n", res); - netif_stop_queue(dev); - mhi_netdev->stats.tx_full++; - res = NETDEV_TX_BUSY; - goto mhi_xmit_exit; - } - - mhi_netdev->stats.tx_pkts++; - -mhi_xmit_exit: - read_unlock_bh(&mhi_netdev->pm_lock); - MSG_VERB("Exited\n"); - - return res; -} - -static const struct net_device_ops mhi_netdev_ops_ip = { - .ndo_open = mhi_netdev_open, - .ndo_start_xmit = mhi_netdev_xmit, - .ndo_change_mtu = mhi_netdev_change_mtu, - .ndo_set_mac_address = eth_mac_addr, - .ndo_validate_addr = eth_validate_addr, -}; - -static void mhi_netdev_setup(struct net_device *dev) -{ - dev->netdev_ops = &mhi_netdev_ops_ip; - ether_setup(dev); - - /* set this after calling ether_setup */ - dev->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST; - dev->watchdog_timeo = WATCHDOG_TIMEOUT; -} - -/* enable mhi_netdev netdev, call only after grabbing mhi_netdev.mutex */ -static int mhi_netdev_enable_iface(struct mhi_netdev *mhi_netdev) -{ - int ret = 0; - char ifname[IFNAMSIZ]; - struct mhi_device *mhi_dev = mhi_netdev->mhi_dev; - int no_tre; - - MSG_LOG("Prepare the channels for transfer\n"); - - ret = mhi_prepare_for_transfer(mhi_dev); - if (ret) { - MSG_ERR("Failed to start TX chan ret %d\n", ret); - goto mhi_failed_to_start; - } - - /* first time enabling the node */ - if (!mhi_netdev->ndev) { - struct mhi_netdev_priv *mhi_netdev_priv; - - snprintf(ifname, sizeof(ifname), "%s%%d", - mhi_netdev->interface_name); - - rtnl_lock(); -#ifdef NET_NAME_PREDICTABLE - mhi_netdev->ndev = alloc_netdev(sizeof(*mhi_netdev_priv), - ifname, NET_NAME_PREDICTABLE, - mhi_netdev_setup); -#else - mhi_netdev->ndev = alloc_netdev(sizeof(*mhi_netdev_priv), - ifname, - mhi_netdev_setup); -#endif - - if (!mhi_netdev->ndev) { - ret = -ENOMEM; - rtnl_unlock(); - goto net_dev_alloc_fail; - } - - //mhi_netdev->ndev->mtu = mhi_dev->mtu; - SET_NETDEV_DEV(mhi_netdev->ndev, &mhi_dev->dev); - mhi_netdev_priv = netdev_priv(mhi_netdev->ndev); - mhi_netdev_priv->mhi_netdev = mhi_netdev; - rtnl_unlock(); - - netif_napi_add(mhi_netdev->ndev, &mhi_netdev->napi, - mhi_netdev_poll, NAPI_POLL_WEIGHT); - ret = register_netdev(mhi_netdev->ndev); - if (ret) { - MSG_ERR("Network device registration failed\n"); - goto net_dev_reg_fail; - } - - skb_queue_head_init(&mhi_netdev->rx_allocated); - } - - write_lock_irq(&mhi_netdev->pm_lock); - mhi_netdev->enabled = true; - write_unlock_irq(&mhi_netdev->pm_lock); - - /* queue buffer for rx path */ - no_tre = mhi_get_no_free_descriptors(mhi_dev, DMA_FROM_DEVICE); - ret = mhi_netdev_alloc_skb(mhi_netdev, GFP_KERNEL); - if (ret) - schedule_work(&mhi_netdev->alloc_work); - - /* if we recycle prepare one more set */ - if (mhi_netdev->recycle_buf) - for (; no_tre >= 0; no_tre--) { - struct sk_buff *skb = alloc_skb(mhi_netdev->mru + ETH_HLEN, - GFP_KERNEL); - struct mhi_skb_priv *skb_priv; - - if (!skb) - break; - - skb_reserve(skb, ETH_HLEN); - - skb_priv = (struct mhi_skb_priv *)skb->cb; - skb_priv->buf = skb->data; - skb_priv->size = mhi_netdev->mru; - skb_priv->mhi_netdev = mhi_netdev; - skb->dev = mhi_netdev->ndev; - skb->destructor = mhi_netdev_skb_destructor; - skb_queue_tail(&mhi_netdev->rx_allocated, skb); - } - - napi_enable(&mhi_netdev->napi); - - MSG_LOG("Exited.\n"); - - return 0; - -net_dev_reg_fail: - netif_napi_del(&mhi_netdev->napi); - free_netdev(mhi_netdev->ndev); - mhi_netdev->ndev = NULL; - -net_dev_alloc_fail: - mhi_unprepare_from_transfer(mhi_dev); - -mhi_failed_to_start: - MSG_ERR("Exited ret %d.\n", ret); - - return ret; -} - -static void mhi_netdev_xfer_ul_cb(struct mhi_device *mhi_dev, - struct mhi_result *mhi_result) -{ - struct mhi_netdev *mhi_netdev = mhi_device_get_devdata(mhi_dev); - struct sk_buff *skb = mhi_result->buf_addr; - struct net_device *ndev = mhi_netdev->ndev; - - ndev->stats.tx_packets++; - ndev->stats.tx_bytes += skb->len; - dev_kfree_skb(skb); - - if (netif_queue_stopped(ndev)) - netif_wake_queue(ndev); -} - -static int mhi_netdev_process_fragment(struct mhi_netdev *mhi_netdev, - struct sk_buff *skb) -{ - struct sk_buff *temp_skb; - - if (mhi_netdev->frag_skb) { - /* merge the new skb into the old fragment */ - temp_skb = skb_copy_expand(mhi_netdev->frag_skb, ETH_HLEN, skb->len, - GFP_ATOMIC); - if (!temp_skb) { - dev_kfree_skb(mhi_netdev->frag_skb); - mhi_netdev->frag_skb = NULL; - return -ENOMEM; - } - - dev_kfree_skb_any(mhi_netdev->frag_skb); - mhi_netdev->frag_skb = temp_skb; - memcpy(skb_put(mhi_netdev->frag_skb, skb->len), skb->data, - skb->len); - } else { - mhi_netdev->frag_skb = skb_copy(skb, GFP_ATOMIC); - if (!mhi_netdev->frag_skb) - return -ENOMEM; - } - - mhi_netdev->stats.rx_frag++; - - return 0; -} - -static void mhi_netdev_xfer_dl_cb(struct mhi_device *mhi_dev, - struct mhi_result *mhi_result) -{ - struct mhi_netdev *mhi_netdev = mhi_device_get_devdata(mhi_dev); - struct sk_buff *skb = mhi_result->buf_addr; - struct net_device *dev = mhi_netdev->ndev; - int ret = 0; - static size_t bytes_xferd = 0; - - if (mhi_result->transaction_status == -ENOTCONN) { - dev_kfree_skb(skb); - return; - } - - if (mhi_result->bytes_xferd > bytes_xferd) { - bytes_xferd = mhi_result->bytes_xferd; - //printk("%s bytes_xferd=%zd\n", __func__, bytes_xferd); - } - - skb_put(skb, mhi_result->bytes_xferd); - dev->stats.rx_packets++; - dev->stats.rx_bytes += mhi_result->bytes_xferd; - - /* merge skb's together, it's a chain transfer */ - if (mhi_result->transaction_status == -EOVERFLOW || - mhi_netdev->frag_skb) { - ret = mhi_netdev_process_fragment(mhi_netdev, skb); - - /* recycle the skb */ - if (mhi_netdev->recycle_buf) - mhi_netdev_skb_destructor(skb); - else - dev_kfree_skb(skb); - - if (ret) - return; - } - - /* more data will come, don't submit the buffer */ - if (mhi_result->transaction_status == -EOVERFLOW) - return; - - if (mhi_netdev->frag_skb) { - skb = mhi_netdev->frag_skb; - skb->dev = dev; - mhi_netdev->frag_skb = NULL; - } - - qmap_hex_dump(__func__, skb->data, skb->len); - -#ifdef CONFIG_MHI_NETDEV_MBIM - mhi_mbim_rx_fixup(mhi_netdev, skb, dev); - dev_kfree_skb_any(skb); -#else - if (qmap_mode) { - mhi_qmap_rx_fixup(mhi_netdev, skb, dev); - dev_kfree_skb_any(skb); - } - else { - switch (skb->data[0] & 0xf0) { - case 0x40: - skb->protocol = htons(ETH_P_IP); - netif_receive_skb(skb); - break; - case 0x60: - skb->protocol = htons(ETH_P_IPV6); - netif_receive_skb(skb); - break; - default: - break; - } - } -#endif - - mhi_netdev->rx_queue(mhi_netdev, GFP_ATOMIC); -} - -static void mhi_netdev_status_cb(struct mhi_device *mhi_dev, enum MHI_CB mhi_cb) -{ - struct mhi_netdev *mhi_netdev = mhi_device_get_devdata(mhi_dev); - - if (mhi_cb != MHI_CB_PENDING_DATA) - return; - - if (napi_schedule_prep(&mhi_netdev->napi)) { - __napi_schedule(&mhi_netdev->napi); - mhi_netdev->stats.rx_int++; - return; - } - -} - -#ifdef CONFIG_DEBUG_FS - -struct dentry *mhi_netdev_debugfs_dentry; - -static int mhi_netdev_debugfs_trigger_reset(void *data, u64 val) -{ - struct mhi_netdev *mhi_netdev = data; - struct mhi_device *mhi_dev = mhi_netdev->mhi_dev; - int ret; - - MSG_LOG("Triggering channel reset\n"); - - /* disable the interface so no data processing */ - write_lock_irq(&mhi_netdev->pm_lock); - mhi_netdev->enabled = false; - write_unlock_irq(&mhi_netdev->pm_lock); - napi_disable(&mhi_netdev->napi); - - /* disable all hardware channels */ - mhi_unprepare_from_transfer(mhi_dev); - - /* clean up all alocated buffers */ - mhi_netdev_dealloc(mhi_netdev); - - MSG_LOG("Restarting iface\n"); - - ret = mhi_netdev_enable_iface(mhi_netdev); - if (ret) - return ret; - - return 0; -} -DEFINE_SIMPLE_ATTRIBUTE(mhi_netdev_debugfs_trigger_reset_fops, NULL, - mhi_netdev_debugfs_trigger_reset, "%llu\n"); - -static void mhi_netdev_create_debugfs(struct mhi_netdev *mhi_netdev) -{ - char node_name[32]; - int i; - const umode_t mode = 0600; - struct dentry *file; - struct mhi_device *mhi_dev = mhi_netdev->mhi_dev; - struct dentry *dentry = mhi_netdev_debugfs_dentry; - - const struct { - char *name; - u32 *ptr; - } debugfs_table[] = { - { - "rx_int", - &mhi_netdev->stats.rx_int - }, - { - "tx_full", - &mhi_netdev->stats.tx_full - }, - { - "tx_pkts", - &mhi_netdev->stats.tx_pkts - }, - { - "rx_budget_overflow", - &mhi_netdev->stats.rx_budget_overflow - }, - { - "rx_fragmentation", - &mhi_netdev->stats.rx_frag - }, - { - "alloc_failed", - &mhi_netdev->stats.alloc_failed - }, - { - NULL, NULL - }, - }; - - /* Both tx & rx client handle contain same device info */ - snprintf(node_name, sizeof(node_name), "%s_%04x_%02u.%02u.%02u_%u", - mhi_netdev->interface_name, mhi_dev->dev_id, mhi_dev->domain, - mhi_dev->bus, mhi_dev->slot, mhi_netdev->alias); - - if (IS_ERR_OR_NULL(dentry)) - return; - - mhi_netdev->dentry = debugfs_create_dir(node_name, dentry); - if (IS_ERR_OR_NULL(mhi_netdev->dentry)) - return; - /*begin added by tony.du for mantis 0062018 on 2020-11-10*/ - debugfs_create_u32("msg_lvl", mode, mhi_netdev->dentry, - (u32 *)&mhi_netdev->msg_lvl); - /*end added by tony.du for mantis 0062018 on 2020-11-10*/ - - /* Add debug stats table */ - for (i = 0; debugfs_table[i].name; i++) { - /*begin added by tony.du for mantis 0062018 on 2020-11-10*/ - debugfs_create_u32(debugfs_table[i].name, mode, - mhi_netdev->dentry, - debugfs_table[i].ptr); - /*end added by tony.du for mantis 0062018 on 2020-11-10*/ - } - - debugfs_create_file("reset", mode, mhi_netdev->dentry, mhi_netdev, - &mhi_netdev_debugfs_trigger_reset_fops); -} - -static void mhi_netdev_create_debugfs_dir(struct dentry *parent) -{ - mhi_netdev_debugfs_dentry = debugfs_create_dir(MHI_NETDEV_DRIVER_NAME, parent); -} - -#else - -static void mhi_netdev_create_debugfs(struct mhi_netdev *mhi_netdev) -{ -} - -static void mhi_netdev_create_debugfs_dir(struct dentry *parent) -{ -} - -#endif - -static void mhi_netdev_remove(struct mhi_device *mhi_dev) -{ - struct mhi_netdev *mhi_netdev = mhi_device_get_devdata(mhi_dev); - - MSG_LOG("Remove notification received\n"); - - write_lock_irq(&mhi_netdev->pm_lock); - mhi_netdev->enabled = false; - write_unlock_irq(&mhi_netdev->pm_lock); - - napi_disable(&mhi_netdev->napi); - netif_napi_del(&mhi_netdev->napi); - mhi_netdev_dealloc(mhi_netdev); - unregister_netdev(mhi_netdev->ndev); - free_netdev(mhi_netdev->ndev); - flush_work(&mhi_netdev->alloc_work); - - if (!IS_ERR_OR_NULL(mhi_netdev->dentry)) - debugfs_remove_recursive(mhi_netdev->dentry); -} - -static int mhi_netdev_probe(struct mhi_device *mhi_dev, - const struct mhi_device_id *id) -{ - int ret; - struct mhi_netdev *mhi_netdev; - - mhi_netdev = devm_kzalloc(&mhi_dev->dev, sizeof(*mhi_netdev), - GFP_KERNEL); - if (!mhi_netdev) - return -ENOMEM; - - mhi_netdev->alias = 0; - - mhi_netdev->mhi_dev = mhi_dev; - mhi_device_set_devdata(mhi_dev, mhi_netdev); - - mhi_netdev->mru = 0x4000; - if (mhi_dev->dev_id == 0x0304) { //SDX24 - mhi_netdev->mru = 0x8000; - } -#ifdef CONFIG_MHI_NETDEV_MBIM - mhi_netdev->rx_max = 0x8000; -#endif - - if (!strcmp(id->chan, "IP_HW0")) - mhi_netdev->interface_name = "pcie_mhi"; - else if (!strcmp(id->chan, "IP_SW0")) - mhi_netdev->interface_name = "pcie_swip"; - else - mhi_netdev->interface_name = id->chan; - - mhi_netdev->recycle_buf = false; - - mhi_netdev->rx_queue = mhi_netdev->recycle_buf ? - mhi_netdev_skb_recycle : mhi_netdev_alloc_skb; - - spin_lock_init(&mhi_netdev->rx_lock); - rwlock_init(&mhi_netdev->pm_lock); - INIT_WORK(&mhi_netdev->alloc_work, mhi_netdev_alloc_work); - - mhi_netdev->msg_lvl = MHI_MSG_LVL_INFO; - - /* setup network interface */ - ret = mhi_netdev_enable_iface(mhi_netdev); - if (ret) { - pr_err("Error mhi_netdev_enable_iface ret:%d\n", ret); - return ret; - } - - mhi_netdev_create_debugfs(mhi_netdev); - - g_mhi_netdev = mhi_netdev; - - return 0; -} - -static const struct mhi_device_id mhi_netdev_match_table[] = { - { .chan = "IP_HW0" }, - { .chan = "IP_SW0" }, - { .chan = "IP_HW_ADPL" }, - { }, -}; - -static struct mhi_driver mhi_netdev_driver = { - .id_table = mhi_netdev_match_table, - .probe = mhi_netdev_probe, - .remove = mhi_netdev_remove, - .ul_xfer_cb = mhi_netdev_xfer_ul_cb, - .dl_xfer_cb = mhi_netdev_xfer_dl_cb, - .status_cb = mhi_netdev_status_cb, - .driver = { - .name = "mhi_netdev", - .owner = THIS_MODULE, - } -}; - -int __init mhi_device_netdev_init(struct dentry *parent) -{ - mhi_netdev_create_debugfs_dir(parent); - - return mhi_driver_register(&mhi_netdev_driver); -} - -void mhi_device_netdev_exit(void) -{ -#ifdef CONFIG_DEBUG_FS - debugfs_remove_recursive(mhi_netdev_debugfs_dentry); -#endif - mhi_driver_unregister(&mhi_netdev_driver); -} diff --git a/fibocom_MHI/src/devices/mhi_netdev.h b/fibocom_MHI/src/devices/mhi_netdev.h deleted file mode 100644 index 13735bb..0000000 --- a/fibocom_MHI/src/devices/mhi_netdev.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef _FIBO_MHI_NETDEV_H -#define _FIBO_MHI_NETDEV_H - -#include - -#if (LINUX_VERSION_CODE < KERNEL_VERSION( 4,15,0 )) -static inline void *fibo_skb_put_data(struct sk_buff *skb, const void *data, - unsigned int len) -{ - void *tmp = skb_put(skb, len); - - memcpy(tmp,data, len); - - return tmp; -} -#endif - -#endif diff --git a/fibocom_MHI/src/devices/mhi_uci.c b/fibocom_MHI/src/devices/mhi_uci.c deleted file mode 100644 index 7195ab0..0000000 --- a/fibocom_MHI/src/devices/mhi_uci.c +++ /dev/null @@ -1,785 +0,0 @@ -/* Copyright (c) 2018, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "../core/mhi.h" - -#define DEVICE_NAME "mhi" -#define MHI_UCI_DRIVER_NAME "mhi_uci" - -struct uci_chan { - wait_queue_head_t wq; - spinlock_t lock; - struct list_head pending; /* user space waiting to read */ - struct uci_buf *cur_buf; /* current buffer user space reading */ - size_t rx_size; -}; - -struct uci_buf { - void *data; - size_t len; - struct list_head node; -}; - -struct uci_dev { - struct list_head node; - dev_t devt; - struct device *dev; - struct mhi_device *mhi_dev; - const char *chan; - struct mutex mutex; /* sync open and close */ - struct uci_chan ul_chan; - struct uci_chan dl_chan; - size_t mtu; - int ref_count; - bool enabled; - bool disconnect; - struct ktermios termios; - int sigs; -}; - -struct mhi_uci_drv { - struct list_head head; - struct mutex lock; - struct class *class; - int major; - dev_t dev_t; -}; - -enum MHI_DEBUG_LEVEL msg_lvl = MHI_MSG_LVL_ERROR; - -typedef struct _QCQMI_HDR { - u8 IFType; - u16 Length; - u8 CtlFlags; // reserved - u8 QMIType; - u8 ClientId; -} __attribute__ ((packed)) *PQCQMI_HDR; - -#define MSG_VERB(fmt, ...) do { \ - if (msg_lvl <= MHI_MSG_LVL_VERBOSE) \ - pr_err("[D][%s] " fmt, __func__, ##__VA_ARGS__); \ - } while (0) - -#define MSG_LOG(fmt, ...) do { \ - if (msg_lvl <= MHI_MSG_LVL_INFO) \ - pr_err("[I][%s] " fmt, __func__, ##__VA_ARGS__); \ - } while (0) - -#define MSG_ERR(fmt, ...) do { \ - if (msg_lvl <= MHI_MSG_LVL_ERROR) \ - pr_err("[E][%s] " fmt, __func__, ##__VA_ARGS__); \ - } while (0) - -#define MAX_UCI_DEVICES (64) -#define QUEC_MHI_UCI_ALWAYS_OPEN //by now, sdx20 can not handle "start-reset-start" operation, so the simply solution is keep start state - -static DECLARE_BITMAP(uci_minors, MAX_UCI_DEVICES); -static struct mhi_uci_drv mhi_uci_drv; - -static int mhi_queue_inbound(struct uci_dev *uci_dev) -{ - struct mhi_device *mhi_dev = uci_dev->mhi_dev; - int nr_trbs = mhi_get_no_free_descriptors(mhi_dev, DMA_FROM_DEVICE); - size_t mtu = uci_dev->mtu; - void *buf; - struct uci_buf *uci_buf; - int ret = -EIO, i; - - for (i = 0; i < nr_trbs; i++) { - buf = kmalloc(mtu + sizeof(*uci_buf), GFP_KERNEL); - if (!buf) - return -ENOMEM; - - uci_buf = buf + mtu; - uci_buf->data = buf; - - MSG_VERB("Allocated buf %d of %d size %zd\n", i, nr_trbs, mtu); - - ret = mhi_queue_transfer(mhi_dev, DMA_FROM_DEVICE, buf, mtu, - MHI_EOT); - if (ret) { - kfree(buf); - MSG_ERR("Failed to queue buffer %d\n", i); - return ret; - } - } - - return ret; -} - -static long mhi_uci_ioctl(struct file *file, - unsigned int cmd, - unsigned long arg) -{ - struct uci_dev *uci_dev = file->private_data; - struct mhi_device *mhi_dev = uci_dev->mhi_dev; - long ret = -ERESTARTSYS; - - mutex_lock(&uci_dev->mutex); - if (uci_dev->enabled) { - switch (cmd) { - case TCGETS: -#ifndef TCGETS2 - ret = kernel_termios_to_user_termios((struct termios __user *)arg, &uci_dev->termios); -#else - ret = kernel_termios_to_user_termios_1((struct termios __user *)arg, &uci_dev->termios); -#endif - break; - - case TCSETSF: - case TCSETS: -#ifndef TCGETS2 - ret = user_termios_to_kernel_termios(&uci_dev->termios, (struct termios __user *)arg); -#else - ret = user_termios_to_kernel_termios_1(&uci_dev->termios, (struct termios __user *)arg); -#endif - break; - - case TIOCMSET: - case TIOCMBIS: - case TIOCMBIC: - { - uint32_t val; - - ret = get_user(val, (uint32_t *)arg); - if (ret) - return ret; - - switch (cmd) { - case TIOCMBIS: - uci_dev->sigs |= val; - break; - case TIOCMBIC: - uci_dev->sigs &= ~val; - break; - case TIOCMSET: - uci_dev->sigs = val; - break; - } - } - break; - - case TIOCMGET: - ret = put_user(uci_dev->sigs | TIOCM_RTS, (uint32_t *)arg); - break; - - case TCFLSH: - ret = 0; - break; - - default: - ret = mhi_ioctl(mhi_dev, cmd, arg); - break; - } - } - mutex_unlock(&uci_dev->mutex); - - return ret; -} - -static int mhi_uci_release(struct inode *inode, struct file *file) -{ - struct uci_dev *uci_dev = file->private_data; - - mutex_lock(&uci_dev->mutex); - uci_dev->ref_count--; - if (!uci_dev->ref_count) { - struct uci_buf *itr, *tmp; - struct uci_chan *uci_chan; - - MSG_LOG("Last client left, closing node\n"); - - if (uci_dev->enabled) - mhi_unprepare_from_transfer(uci_dev->mhi_dev); - - /* clean inbound channel */ - uci_chan = &uci_dev->dl_chan; - list_for_each_entry_safe(itr, tmp, &uci_chan->pending, node) { - list_del(&itr->node); - kfree(itr->data); - } - if (uci_chan->cur_buf) - kfree(uci_chan->cur_buf->data); - - uci_chan->cur_buf = NULL; - - if (!uci_dev->enabled) { - MSG_LOG("Node is deleted, freeing dev node\n"); - mutex_unlock(&uci_dev->mutex); - mutex_destroy(&uci_dev->mutex); - clear_bit(MINOR(uci_dev->devt), uci_minors); - kfree(uci_dev); - return 0; - } - } - - mutex_unlock(&uci_dev->mutex); - - MSG_LOG("exit: ref_count:%d\n", uci_dev->ref_count); - - return 0; -} - -static unsigned int mhi_uci_poll(struct file *file, poll_table *wait) -{ - struct uci_dev *uci_dev = file->private_data; - struct mhi_device *mhi_dev = uci_dev->mhi_dev; - struct uci_chan *uci_chan; - unsigned int mask = 0; - - poll_wait(file, &uci_dev->dl_chan.wq, wait); - poll_wait(file, &uci_dev->ul_chan.wq, wait); - - uci_chan = &uci_dev->dl_chan; - spin_lock_bh(&uci_chan->lock); - if (!uci_dev->enabled) { - mask = POLLERR; - } else if (!list_empty(&uci_chan->pending) || uci_chan->cur_buf) { - MSG_VERB("Client can read from node\n"); - mask |= POLLIN | POLLRDNORM; - } - spin_unlock_bh(&uci_chan->lock); - - uci_chan = &uci_dev->ul_chan; - spin_lock_bh(&uci_chan->lock); - if (!uci_dev->enabled) { - mask |= POLLERR; - } else if (mhi_get_no_free_descriptors(mhi_dev, DMA_TO_DEVICE) > 0) { - MSG_VERB("Client can write to node\n"); - mask |= POLLOUT | POLLWRNORM; - } - - if (uci_dev->disconnect) - mask |= POLLHUP; - - spin_unlock_bh(&uci_chan->lock); - - MSG_VERB("Client attempted to poll, returning mask 0x%x\n", mask); - - return mask; -} - -static ssize_t mhi_uci_write(struct file *file, - const char __user *buf, - size_t count, - loff_t *offp) -{ - struct uci_dev *uci_dev = file->private_data; - struct mhi_device *mhi_dev = uci_dev->mhi_dev; - struct uci_chan *uci_chan = &uci_dev->ul_chan; - size_t bytes_xfered = 0; - int ret; - - if (!buf || !count) - return -EINVAL; - - /* confirm channel is active */ - spin_lock_bh(&uci_chan->lock); - if (!uci_dev->enabled) { - spin_unlock_bh(&uci_chan->lock); - return -ERESTARTSYS; - } - - MSG_VERB("Enter: to xfer:%zd bytes\n", count); - - while (count) { - size_t xfer_size; - void *kbuf; - enum MHI_FLAGS flags; - - spin_unlock_bh(&uci_chan->lock); - - if (mhi_get_no_free_descriptors(mhi_dev, DMA_TO_DEVICE) == 0 && (file->f_mode & FMODE_NDELAY)) - break; - - /* wait for free descriptors */ - ret = wait_event_interruptible(uci_chan->wq, - (!uci_dev->enabled) || - mhi_get_no_free_descriptors - (mhi_dev, DMA_TO_DEVICE) > 0); - - if (ret == -ERESTARTSYS) { - MSG_LOG("Exit signal caught for node\n"); - return -ERESTARTSYS; - } - - xfer_size = min_t(size_t, count, uci_dev->mtu); - kbuf = kmalloc(xfer_size, GFP_KERNEL); - if (!kbuf) { - MSG_ERR("Failed to allocate memory %zd\n", xfer_size); - return -ENOMEM; - } - - ret = copy_from_user(kbuf, buf, xfer_size); - if (unlikely(ret)) { - kfree(kbuf); - return ret; - } - - spin_lock_bh(&uci_chan->lock); - flags = MHI_EOT; - if (uci_dev->enabled) - ret = mhi_queue_transfer(mhi_dev, DMA_TO_DEVICE, kbuf, - xfer_size, flags); - else - ret = -ERESTARTSYS; - - if (ret) { - kfree(kbuf); - goto sys_interrupt; - } - - bytes_xfered += xfer_size; - count -= xfer_size; - buf += xfer_size; - } - - spin_unlock_bh(&uci_chan->lock); - MSG_VERB("Exit: Number of bytes xferred:%zd\n", bytes_xfered); - - return bytes_xfered; - -sys_interrupt: - spin_unlock_bh(&uci_chan->lock); - - return ret; -} - -static ssize_t mhi_uci_read(struct file *file, - char __user *buf, - size_t count, - loff_t *ppos) -{ - struct uci_dev *uci_dev = file->private_data; - struct mhi_device *mhi_dev = uci_dev->mhi_dev; - struct uci_chan *uci_chan = &uci_dev->dl_chan; - struct uci_buf *uci_buf; - char *ptr; - size_t to_copy; - int ret = 0; - - if (!buf) - return -EINVAL; - - MSG_VERB("Client provided buf len:%zd\n", count); - - /* confirm channel is active */ - spin_lock_bh(&uci_chan->lock); - if (!uci_dev->enabled) { - spin_unlock_bh(&uci_chan->lock); - return -ERESTARTSYS; - } - - /* No data available to read, wait */ - if (!uci_chan->cur_buf && list_empty(&uci_chan->pending)) { - MSG_VERB("No data available to read waiting\n"); - - spin_unlock_bh(&uci_chan->lock); - - if (file->f_mode & FMODE_NDELAY) - return -EAGAIN; - - ret = wait_event_interruptible(uci_chan->wq, - (!uci_dev->enabled || - !list_empty(&uci_chan->pending))); - if (ret == -ERESTARTSYS) { - MSG_LOG("Exit signal caught for node\n"); - return -ERESTARTSYS; - } - - spin_lock_bh(&uci_chan->lock); - if (!uci_dev->enabled) { - MSG_LOG("node is disabled\n"); - ret = -ERESTARTSYS; - goto read_error; - } - } - - /* new read, get the next descriptor from the list */ - if (!uci_chan->cur_buf) { - uci_buf = list_first_entry_or_null(&uci_chan->pending, - struct uci_buf, node); - if (unlikely(!uci_buf)) { - ret = -EIO; - goto read_error; - } - - list_del(&uci_buf->node); - uci_chan->cur_buf = uci_buf; - uci_chan->rx_size = uci_buf->len; - MSG_VERB("Got pkt of size:%zd\n", uci_chan->rx_size); - } - - uci_buf = uci_chan->cur_buf; - spin_unlock_bh(&uci_chan->lock); - - /* Copy the buffer to user space */ - to_copy = min_t(size_t, count, uci_chan->rx_size); - ptr = uci_buf->data + (uci_buf->len - uci_chan->rx_size); - ret = copy_to_user(buf, ptr, to_copy); - if (ret) - return ret; - - MSG_VERB("Copied %zd of %zd bytes\n", to_copy, uci_chan->rx_size); - uci_chan->rx_size -= to_copy; - - /* we finished with this buffer, queue it back to hardware */ - if (!uci_chan->rx_size) { - spin_lock_bh(&uci_chan->lock); - uci_chan->cur_buf = NULL; - - if (uci_dev->enabled) - ret = mhi_queue_transfer(mhi_dev, DMA_FROM_DEVICE, - uci_buf->data, uci_dev->mtu, - MHI_EOT); - else - ret = -ERESTARTSYS; - - if (ret) { - MSG_ERR("Failed to recycle element\n"); - kfree(uci_buf->data); - goto read_error; - } - - spin_unlock_bh(&uci_chan->lock); - } - - MSG_VERB("Returning %zd bytes\n", to_copy); - - return to_copy; - -read_error: - spin_unlock_bh(&uci_chan->lock); - - return ret; -} - -static int mhi_uci_open(struct inode *inode, struct file *filp) -{ - struct uci_dev *uci_dev; - int ret = -EIO; - struct uci_buf *buf_itr, *tmp; - struct uci_chan *dl_chan; - - mutex_lock(&mhi_uci_drv.lock); - list_for_each_entry(uci_dev, &mhi_uci_drv.head, node) { - if (uci_dev->devt == inode->i_rdev) { - ret = 0; - break; - } - } - mutex_unlock(&mhi_uci_drv.lock); - - /* could not find a minor node */ - if (ret) - return ret; - - mutex_lock(&uci_dev->mutex); - if (!uci_dev->enabled) { - MSG_ERR("Node exist, but not in active state!\n"); - goto error_open_chan; - } - - uci_dev->ref_count++; - - MSG_LOG("Node open, ref counts %u\n", uci_dev->ref_count); - - if (uci_dev->ref_count == 1) { - MSG_LOG("Starting channel\n"); - ret = mhi_prepare_for_transfer(uci_dev->mhi_dev); - if (ret) { - MSG_ERR("Error starting transfer channels\n"); - uci_dev->ref_count--; - goto error_open_chan; - } - - ret = mhi_queue_inbound(uci_dev); - if (ret) - goto error_rx_queue; - -#ifdef QUEC_MHI_UCI_ALWAYS_OPEN - uci_dev->ref_count++; - if (uci_dev->mhi_dev->dl_chan_id == MHI_CLIENT_QMI_IN) { - } - if (uci_dev->mhi_dev->dl_chan_id == MHI_CLIENT_MBIM_IN) { - } -#endif - } - - filp->private_data = uci_dev; - mutex_unlock(&uci_dev->mutex); - - return 0; - - error_rx_queue: - dl_chan = &uci_dev->dl_chan; - mhi_unprepare_from_transfer(uci_dev->mhi_dev); - list_for_each_entry_safe(buf_itr, tmp, &dl_chan->pending, node) { - list_del(&buf_itr->node); - kfree(buf_itr->data); - } - - error_open_chan: - mutex_unlock(&uci_dev->mutex); - - return ret; -} - -static const struct file_operations mhidev_fops = { - .open = mhi_uci_open, - .release = mhi_uci_release, - .read = mhi_uci_read, - .write = mhi_uci_write, - .poll = mhi_uci_poll, - .unlocked_ioctl = mhi_uci_ioctl, -}; - -static void mhi_uci_remove(struct mhi_device *mhi_dev) -{ - struct uci_dev *uci_dev = mhi_device_get_devdata(mhi_dev); - - MSG_LOG("Enter\n"); - - /* disable the node */ - mutex_lock(&uci_dev->mutex); - spin_lock_irq(&uci_dev->dl_chan.lock); - spin_lock_irq(&uci_dev->ul_chan.lock); - uci_dev->enabled = false; - uci_dev->disconnect = true; - spin_unlock_irq(&uci_dev->ul_chan.lock); - spin_unlock_irq(&uci_dev->dl_chan.lock); - wake_up(&uci_dev->dl_chan.wq); - wake_up(&uci_dev->ul_chan.wq); - - /* delete the node to prevent new opens */ - device_destroy(mhi_uci_drv.class, uci_dev->devt); - uci_dev->dev = NULL; - mutex_lock(&mhi_uci_drv.lock); - list_del(&uci_dev->node); - mutex_unlock(&mhi_uci_drv.lock); - -#ifdef QUEC_MHI_UCI_ALWAYS_OPEN - if (uci_dev->ref_count > 0) - uci_dev->ref_count--; -#endif - - /* safe to free memory only if all file nodes are closed */ - if (!uci_dev->ref_count) { - mutex_unlock(&uci_dev->mutex); - mutex_destroy(&uci_dev->mutex); - clear_bit(MINOR(uci_dev->devt), uci_minors); - kfree(uci_dev); - return; - } - - mutex_unlock(&uci_dev->mutex); - MSG_LOG("Exit\n"); -} - -static int mhi_uci_probe(struct mhi_device *mhi_dev, - const struct mhi_device_id *id) -{ - struct uci_dev *uci_dev; - int minor; - int dir; - - uci_dev = kzalloc(sizeof(*uci_dev), GFP_KERNEL); - if (!uci_dev) - return -ENOMEM; - - mutex_init(&uci_dev->mutex); - uci_dev->mhi_dev = mhi_dev; - - minor = find_first_zero_bit(uci_minors, MAX_UCI_DEVICES); - if (minor >= MAX_UCI_DEVICES) { - kfree(uci_dev); - return -ENOSPC; - } - - mutex_lock(&uci_dev->mutex); - mutex_lock(&mhi_uci_drv.lock); - - uci_dev->devt = MKDEV(mhi_uci_drv.major, minor); - - uci_dev->dev = device_create(mhi_uci_drv.class, &mhi_dev->dev, - uci_dev->devt, uci_dev, - DEVICE_NAME "_%s", - mhi_dev->chan_name); - - set_bit(minor, uci_minors); - - for (dir = 0; dir < 2; dir++) { - struct uci_chan *uci_chan = (dir) ? - &uci_dev->ul_chan : &uci_dev->dl_chan; - spin_lock_init(&uci_chan->lock); - init_waitqueue_head(&uci_chan->wq); - INIT_LIST_HEAD(&uci_chan->pending); - }; - - uci_dev->termios = tty_std_termios; - uci_dev->sigs = 0; - - uci_dev->mtu = id->driver_data; - mhi_device_set_devdata(mhi_dev, uci_dev); - uci_dev->enabled = true; - - list_add(&uci_dev->node, &mhi_uci_drv.head); - mutex_unlock(&mhi_uci_drv.lock); - mutex_unlock(&uci_dev->mutex); - - MSG_LOG("channel:%s successfully probed\n", mhi_dev->chan_name); - - return 0; -}; - -static void mhi_ul_xfer_cb(struct mhi_device *mhi_dev, - struct mhi_result *mhi_result) -{ - struct uci_dev *uci_dev = mhi_device_get_devdata(mhi_dev); - struct uci_chan *uci_chan = &uci_dev->ul_chan; - - MSG_VERB("status:%d xfer_len:%zu\n", mhi_result->transaction_status, - mhi_result->bytes_xferd); - - kfree(mhi_result->buf_addr); - if (!mhi_result->transaction_status) - wake_up(&uci_chan->wq); -} - -static void mhi_dl_xfer_cb(struct mhi_device *mhi_dev, - struct mhi_result *mhi_result) -{ - struct uci_dev *uci_dev = mhi_device_get_devdata(mhi_dev); - struct uci_chan *uci_chan = &uci_dev->dl_chan; - unsigned long flags; - struct uci_buf *buf; - - MSG_VERB("chan:mhi_dev->dl_chan_id:%d, status:%d receive_len:%zu\n", - mhi_dev->dl_chan_id, mhi_result->transaction_status, mhi_result->bytes_xferd); - - if (mhi_result->transaction_status == -ENOTCONN) { - kfree(mhi_result->buf_addr); - return; - } - - spin_lock_irqsave(&uci_chan->lock, flags); - buf = mhi_result->buf_addr + uci_dev->mtu; - if (buf->data != mhi_result->buf_addr) { - MSG_LOG("%p, %p\n", buf->data, mhi_result->buf_addr); - } - buf->data = mhi_result->buf_addr; - buf->len = mhi_result->bytes_xferd; - - if (uci_dev->mhi_dev->dl_chan_id == MHI_CLIENT_QMI_IN) { - PQCQMI_HDR pHdr = (PQCQMI_HDR) (buf->data); - u16 qmiLength = (le16_to_cpu(pHdr->Length) + 1); - -// open qmi chan, but not read data from the chan, will cause next error, donot know why by now, so it is not recomment to use uqmi&libqmi? -// dmesg -c > /dev/null; echo 1 > /dev/mhi_QMI0; sleep 3; ./FIBO-CM -d /dev/mhi_QMI0 -v - if (qmiLength != buf->len) { - unsigned char *d = (unsigned char *) pHdr; - MSG_ERR("bytes_xferd=%zd, qmiLength=%d %02x%02x%02x%02x - %02x%02x%02x%02x\n", buf->len, qmiLength, - d[0],d[1],d[2],d[3],d[qmiLength+0],d[qmiLength+1],d[qmiLength+2],d[qmiLength+3]); - if (buf->len > qmiLength) - buf->len = qmiLength; - } - } - - list_add_tail(&buf->node, &uci_chan->pending); - spin_unlock_irqrestore(&uci_chan->lock, flags); - - wake_up(&uci_chan->wq); -} - -#define DIAG_MAX_PCIE_PKT_SZ 2048 //define by module - -/* .driver_data stores max mtu */ -static const struct mhi_device_id mhi_uci_match_table[] = { - { .chan = "LOOPBACK", .driver_data = 0x1000 }, - { .chan = "SAHARA", .driver_data = 0x4000 }, - { .chan = "EDL", .driver_data = 0x4000 }, - { .chan = "DIAG", .driver_data = DIAG_MAX_PCIE_PKT_SZ }, - { .chan = "EFS", .driver_data = 0x1000 }, -#ifdef CONFIG_MHI_NETDEV_MBIM - { .chan = "MBIM", .driver_data = 0x1000 }, -#else - { .chan = "QMI0", .driver_data = 0x1000 }, - { .chan = "QMI1", .driver_data = 0x1000 }, -#endif - { .chan = "TF", .driver_data = 0x1000 }, - { .chan = "BL", .driver_data = 0x1000 }, - { .chan = "DUN", .driver_data = 0x1000 }, - { .chan = "GNSS", .driver_data = 0x1000 }, - { .chan = "AUDIO", .driver_data = 0x1000 }, - { }, -}; - -static struct mhi_driver mhi_uci_driver = { - .id_table = mhi_uci_match_table, - .remove = mhi_uci_remove, - .probe = mhi_uci_probe, - .ul_xfer_cb = mhi_ul_xfer_cb, - .dl_xfer_cb = mhi_dl_xfer_cb, - .driver = { - .name = MHI_UCI_DRIVER_NAME, - .owner = THIS_MODULE, - }, -}; - -int mhi_device_uci_init(void) -{ - int ret; - - ret = register_chrdev(0, MHI_UCI_DRIVER_NAME, &mhidev_fops); - if (ret < 0) - return ret; - - mhi_uci_drv.major = ret; - mhi_uci_drv.class = class_create(THIS_MODULE, MHI_UCI_DRIVER_NAME); - if (IS_ERR(mhi_uci_drv.class)) { - unregister_chrdev(mhi_uci_drv.major, MHI_UCI_DRIVER_NAME); - return -ENODEV; - } - - mutex_init(&mhi_uci_drv.lock); - INIT_LIST_HEAD(&mhi_uci_drv.head); - - ret = mhi_driver_register(&mhi_uci_driver); - if (ret) { - class_destroy(mhi_uci_drv.class); - unregister_chrdev(mhi_uci_drv.major, MHI_UCI_DRIVER_NAME); - } - - return ret; -} - -void mhi_device_uci_exit(void) -{ - mhi_driver_unregister(&mhi_uci_driver); - class_destroy(mhi_uci_drv.class); - unregister_chrdev(mhi_uci_drv.major, MHI_UCI_DRIVER_NAME); -} diff --git a/fibocom_QMI_WWAN/Makefile b/fibocom_QMI_WWAN/Makefile deleted file mode 100644 index 836085e..0000000 --- a/fibocom_QMI_WWAN/Makefile +++ /dev/null @@ -1,47 +0,0 @@ -# -# Copyright (C) 2015 OpenWrt.org -# -# This is free software, licensed under the GNU General Public License v2. -# See /LICENSE for more information. -# - -include $(TOPDIR)/rules.mk - -PKG_NAME:=qmi_wwan_f -PKG_VERSION:=1.0 -PKG_RELEASE:=2 - -include $(INCLUDE_DIR)/kernel.mk -include $(INCLUDE_DIR)/package.mk - -define KernelPackage/qmi_wwan_f - SUBMENU:=WWAN Support - TITLE:=Fibocom Linux USB QMI WWAN Driver - DEPENDS:=+kmod-usb-net +kmod-usb-wdm - FILES:=$(PKG_BUILD_DIR)/qmi_wwan_f.ko - AUTOLOAD:=$(call AutoLoad,82,qmi_wwan_f) -endef - -define KernelPackage/qmi_wwan_f/description - Fibocom Linux USB QMI WWAN Driver -endef - -MAKE_OPTS:= \ - ARCH="$(LINUX_KARCH)" \ - CROSS_COMPILE="$(TARGET_CROSS)" \ - CXXFLAGS="$(TARGET_CXXFLAGS)" \ - M="$(PKG_BUILD_DIR)" \ - $(EXTRA_KCONFIG) - -define Build/Prepare - mkdir -p $(PKG_BUILD_DIR) - $(CP) ./src/* $(PKG_BUILD_DIR)/ -endef - -define Build/Compile - $(MAKE) -C "$(LINUX_DIR)" \ - $(MAKE_OPTS) \ - modules -endef - -$(eval $(call KernelPackage,qmi_wwan_f)) diff --git a/fibocom_QMI_WWAN/src/Makefile b/fibocom_QMI_WWAN/src/Makefile deleted file mode 100644 index 00250a1..0000000 --- a/fibocom_QMI_WWAN/src/Makefile +++ /dev/null @@ -1,38 +0,0 @@ -obj-m += qmi_wwan_f.o - -PWD := $(shell pwd) -OUTPUTDIR=/lib/modules/`uname -r`/kernel/drivers/net/usb/ - -ifeq ($(ARCH),) -ARCH := $(shell uname -m) -endif -ifeq ($(CROSS_COMPILE),) -CROSS_COMPILE := -endif -ifeq ($(KDIR),) -KDIR := /lib/modules/$(shell uname -r)/build -ifeq ($(ARCH),i686) -ifeq ($(wildcard $KDIR/arch/$ARCH),) -ARCH=i386 -endif -endif -endif - -ifneq ($(findstring &,${PWD}),) -$(warning "${PWD}") -$(warning "current directory contain special char '&' !") -$(error "please remove it!") -endif - -default: - $(MAKE) ARCH=${ARCH} CROSS_COMPILE=${CROSS_COMPILE} -C $(KDIR) M=$(PWD) modules - -install: default - cp $(PWD)/qmi_wwan_f.ko /lib/modules/$(shell uname -r)/kernel/drivers/net/usb/ - depmod - modprobe -r qmi_wwan_f - modprobe -r qmi_wwan - modprobe qmi_wwan_f -clean: - rm -rf *~ .tmp_versions modules.order Module.symvers - find . -type f -name "*~" -o -name "*.o" -o -name "*.ko" -o -name "*.cmd" -o -name "*.mod.c" | xargs rm -rf diff --git a/fibocom_QMI_WWAN/src/qmi_wwan_f.c b/fibocom_QMI_WWAN/src/qmi_wwan_f.c deleted file mode 100644 index 48efef7..0000000 --- a/fibocom_QMI_WWAN/src/qmi_wwan_f.c +++ /dev/null @@ -1,2534 +0,0 @@ -/* - * Copyright (c) 2012 Bjørn Mork - * - * The probing code is heavily inspired by cdc_ether, which is: - * Copyright (C) 2003-2005 by David Brownell - * Copyright (C) 2006 by Ole Andre Vadla Ravnas (ActiveSync) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. - */ - -#include -#include -#include -#include -#include -#include -#include -#if LINUX_VERSION_CODE > KERNEL_VERSION(3,16,0) //8b094cd03b4a3793220d8d8d86a173bfea8c285b -#include -#else -#define timespec64 timespec -#define ktime_get_ts64 ktime_get_ts -#define timespec64_sub timespec_sub -#endif -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef ETH_P_MAP -#define ETH_P_MAP 0xDA1A -#endif - -#if (ETH_P_MAP == 0x00F9) -#undef ETH_P_MAP -#define ETH_P_MAP 0xDA1A -#endif - -#ifndef ARPHRD_RAWIP -#define ARPHRD_RAWIP ARPHRD_NONE -#endif - -#ifdef CONFIG_PINCTRL_IPQ807x -#define CONFIG_QCA_NSS_DRV -#endif - -#if 1//def CONFIG_QCA_NSS_DRV -#define _RMNET_NSS_H_ -#define _RMENT_NSS_H_ -struct rmnet_nss_cb { - int (*nss_create)(struct net_device *dev); - int (*nss_free)(struct net_device *dev); - int (*nss_tx)(struct sk_buff *skb); -}; -static struct rmnet_nss_cb *rmnet_nss_callbacks __rcu __read_mostly; -#ifdef CONFIG_QCA_NSS_DRV -static uint __read_mostly qca_nss_enabled = 1; -module_param( qca_nss_enabled, uint, S_IRUGO); -#endif -#endif - -#if (LINUX_VERSION_CODE < KERNEL_VERSION( 4,0,0 )) //1e9e39f4a29857a396ac7b669d109f697f66695e -#define usbnet_set_skb_tx_stats(skb, packets, bytes_delta) do { dev->net->stats.tx_packets += packets; } while(0) -#endif - -/* This driver supports wwan (3G/LTE/?) devices using a vendor - * specific management protocol called Qualcomm MSM Interface (QMI) - - * in addition to the more common AT commands over serial interface - * management - * - * QMI is wrapped in CDC, using CDC encapsulated commands on the - * control ("master") interface of a two-interface CDC Union - * resembling standard CDC ECM. The devices do not use the control - * interface for any other CDC messages. Most likely because the - * management protocol is used in place of the standard CDC - * notifications NOTIFY_NETWORK_CONNECTION and NOTIFY_SPEED_CHANGE - * - * Alternatively, control and data functions can be combined in a - * single USB interface. - * - * Handling a protocol like QMI is out of the scope for any driver. - * It is exported as a character device using the cdc-wdm driver as - * a subdriver, enabling userspace applications ("modem managers") to - * handle it. - * - * These devices may alternatively/additionally be configured using AT - * commands on a serial interface - */ -#define VERSION_NUMBER "V1.0.5" -#define FIBOCOM_WWAN_VERSION "Fibocom_QMI_WWAN_Driver_"VERSION_NUMBER -static const char driver_name[] = "qmi_wwan_f"; - -/* driver specific data */ -struct qmi_wwan_state { - struct usb_driver *subdriver; - atomic_t pmcount; - unsigned long unused; - struct usb_interface *control; - struct usb_interface *data; -}; - -/* default ethernet address used by the modem */ -static const u8 default_modem_addr[ETH_ALEN] = {0x02, 0x50, 0xf3}; - -#if 1 -#define FIBOCOM_WWAN_QMAP 4 //MAX is 7 - -#if defined(FIBOCOM_WWAN_QMAP) -#define FIBOCOM_QMAP_MUX_ID 0x81 - -static uint __read_mostly qmap_mode = 0; -module_param( qmap_mode, uint, S_IRUGO); -module_param_named( rx_qmap, qmap_mode, uint, S_IRUGO ); -#endif - -#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) -#define FIBOCOM_BRIDGE_MODE -#endif - -#ifdef FIBOCOM_BRIDGE_MODE -static uint __read_mostly bridge_mode = 0/*|BIT(1)*/; -module_param( bridge_mode, uint, S_IRUGO ); -#endif - -#if defined(FIBOCOM_WWAN_QMAP) -#define FIBOCOM_UL_DATA_AGG 1 - -#if defined(FIBOCOM_UL_DATA_AGG) -struct tx_agg_ctx { - /* QMIWDS_ADMIN_SET_DATA_FORMAT_RESP TLV_0x17 and TLV_0x18 */ - uint ul_data_aggregation_max_datagrams; //UplinkDataAggregationMaxDatagramsTlv - uint ul_data_aggregation_max_size; //UplinkDataAggregationMaxSizeTlv - uint dl_minimum_padding; //0x1A -}; -#endif - -typedef struct { - unsigned int size; - unsigned int rx_urb_size; - unsigned int ep_type; - unsigned int iface_id; - unsigned int qmap_mode; - unsigned int qmap_version; - unsigned int dl_minimum_padding; - char ifname[8][16]; - unsigned char mux_id[8]; -} RMNET_INFO; - -typedef struct sQmiWwanQmap -{ - struct usbnet *mpNetDev; - struct driver_info driver_info; - atomic_t refcount; - struct net_device *mpQmapNetDev[FIBOCOM_WWAN_QMAP]; - uint link_state; - uint qmap_mode; - uint qmap_size; - uint qmap_version; - struct sk_buff_head skb_chain; - -#if defined(FIBOCOM_UL_DATA_AGG) - struct tx_agg_ctx tx_ctx; - struct tasklet_struct txq; -#endif - -#ifdef FIBOCOM_BRIDGE_MODE - uint bridge_mode; - uint bridge_ipv4; - unsigned char bridge_mac[ETH_ALEN]; -#endif - uint use_rmnet_usb; - RMNET_INFO rmnet_info; -} sQmiWwanQmap; -//2021-03-19 willa.liu@fibocom.com changed begin for support mantis 0073129 -//#if LINUX_VERSION_CODE > KERNEL_VERSION(3,10,0) -#if LINUX_VERSION_CODE > KERNEL_VERSION(3,15,0) -//2021-03-19 willa.liu@fibocom.com changed end for support mantis 0073129 -#define MHI_NETDEV_STATUS64 -#endif -struct qmap_priv { - struct usbnet *dev; - struct net_device *real_dev; - struct net_device *self_dev; - u8 offset_id; - u8 mux_id; - u8 qmap_version; - u8 link_state; - -#if defined(MHI_NETDEV_STATUS64) - struct pcpu_sw_netstats __percpu *stats64; -#endif - - spinlock_t agg_lock; - struct sk_buff *agg_skb; - unsigned agg_count; - struct timespec64 agg_time; - struct hrtimer agg_hrtimer; - struct work_struct agg_wq; - -#ifdef FIBOCOM_BRIDGE_MODE - uint bridge_mode; - uint bridge_ipv4; - unsigned char bridge_mac[ETH_ALEN]; -#endif -}; - -struct qmap_hdr { - u8 cd_rsvd_pad; - u8 mux_id; - u16 pkt_len; -} __packed; - -enum rmnet_map_v5_header_type { - RMNET_MAP_HEADER_TYPE_UNKNOWN, - RMNET_MAP_HEADER_TYPE_COALESCING = 0x1, - RMNET_MAP_HEADER_TYPE_CSUM_OFFLOAD = 0x2, - RMNET_MAP_HEADER_TYPE_ENUM_LENGTH -}; - -/* Main QMAP header */ -struct rmnet_map_header { - u8 pad_len:6; - u8 next_hdr:1; - u8 cd_bit:1; - u8 mux_id; - __be16 pkt_len; -} __aligned(1); - -/* QMAP v5 headers */ -struct rmnet_map_v5_csum_header { - u8 next_hdr:1; - u8 header_type:7; - u8 hw_reserved:7; - u8 csum_valid_required:1; - __be16 reserved; -} __aligned(1); - -#ifdef FIBOCOM_BRIDGE_MODE -static int is_qmap_netdev(const struct net_device *netdev); -#endif -#endif - -#ifdef FIBOCOM_BRIDGE_MODE -static int bridge_arp_reply(struct net_device *net, struct sk_buff *skb, uint bridge_ipv4) { - struct arphdr *parp; - u8 *arpptr, *sha; - u8 sip[4], tip[4], ipv4[4]; - struct sk_buff *reply = NULL; - - ipv4[0] = (bridge_ipv4 >> 24) & 0xFF; - ipv4[1] = (bridge_ipv4 >> 16) & 0xFF; - ipv4[2] = (bridge_ipv4 >> 8) & 0xFF; - ipv4[3] = (bridge_ipv4 >> 0) & 0xFF; - - parp = arp_hdr(skb); - - if (parp->ar_hrd == htons(ARPHRD_ETHER) && parp->ar_pro == htons(ETH_P_IP) - && parp->ar_op == htons(ARPOP_REQUEST) && parp->ar_hln == 6 && parp->ar_pln == 4) { - arpptr = (u8 *)parp + sizeof(struct arphdr); - sha = arpptr; - arpptr += net->addr_len; /* sha */ - memcpy(sip, arpptr, sizeof(sip)); - arpptr += sizeof(sip); - arpptr += net->addr_len; /* tha */ - memcpy(tip, arpptr, sizeof(tip)); - - pr_info("%s sip = %d.%d.%d.%d, tip=%d.%d.%d.%d, ipv4=%d.%d.%d.%d\n", netdev_name(net), - sip[0], sip[1], sip[2], sip[3], tip[0], tip[1], tip[2], tip[3], ipv4[0], ipv4[1], ipv4[2], ipv4[3]); - //wwan0 sip = 10.151.137.255, tip=10.151.138.0, ipv4=10.151.137.255 - if (tip[0] == ipv4[0] && tip[1] == ipv4[1] && (tip[2]&0xFC) == (ipv4[2]&0xFC) && tip[3] != ipv4[3]) - reply = arp_create(ARPOP_REPLY, ETH_P_ARP, *((__be32 *)sip), net, *((__be32 *)tip), sha, default_modem_addr, sha); - - if (reply) { - skb_reset_mac_header(reply); - __skb_pull(reply, skb_network_offset(reply)); - reply->ip_summed = CHECKSUM_UNNECESSARY; - reply->pkt_type = PACKET_HOST; -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,18,0) - netif_rx_ni(reply); -#else - netif_rx(reply); -#endif - } - return 1; - } - - return 0; -} - -static struct sk_buff *bridge_mode_tx_fixup(struct net_device *net, struct sk_buff *skb, uint bridge_ipv4, unsigned char *bridge_mac) { - struct ethhdr *ehdr; - const struct iphdr *iph; - - skb_reset_mac_header(skb); - ehdr = eth_hdr(skb); - - if (ehdr->h_proto == htons(ETH_P_ARP)) { - if (bridge_ipv4) - bridge_arp_reply(net, skb, bridge_ipv4); - return NULL; - } - - iph = ip_hdr(skb); - //DBG("iphdr: "); - //PrintHex((void *)iph, sizeof(struct iphdr)); - -// 1 0.000000000 0.0.0.0 255.255.255.255 DHCP 362 DHCP Request - Transaction ID 0xe7643ad7 - if (ehdr->h_proto == htons(ETH_P_IP) && iph->protocol == IPPROTO_UDP && iph->saddr == 0x00000000 && iph->daddr == 0xFFFFFFFF) { - //if (udp_hdr(skb)->dest == htons(67)) //DHCP Request - { - memcpy(bridge_mac, ehdr->h_source, ETH_ALEN); - pr_info("%s PC Mac Address: %02x:%02x:%02x:%02x:%02x:%02x\n", netdev_name(net), - bridge_mac[0], bridge_mac[1], bridge_mac[2], bridge_mac[3], bridge_mac[4], bridge_mac[5]); - } - } - - if (memcmp(ehdr->h_source, bridge_mac, ETH_ALEN)) { - return NULL; - } - - return skb; -} - -static void bridge_mode_rx_fixup(sQmiWwanQmap *pQmapDev, struct net_device *net, struct sk_buff *skb) { - uint bridge_mode = 0; - unsigned char *bridge_mac; - - if (pQmapDev->qmap_mode > 1 || pQmapDev->use_rmnet_usb == 1) { - struct qmap_priv *priv = netdev_priv(net); - bridge_mode = priv->bridge_mode; - bridge_mac = priv->bridge_mac; - } - else { - bridge_mode = pQmapDev->bridge_mode; - bridge_mac = pQmapDev->bridge_mac; - } - - if (bridge_mode) - memcpy(eth_hdr(skb)->h_dest, bridge_mac, ETH_ALEN); - else - memcpy(eth_hdr(skb)->h_dest, net->dev_addr, ETH_ALEN); -} -#endif - -#if defined(FIBOCOM_WWAN_QMAP) -static ssize_t qmap_mode_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct net_device *netdev = to_net_dev(dev); - struct usbnet * usbnetdev = netdev_priv( netdev ); - struct qmi_wwan_state *info = (void *)&usbnetdev->data; - sQmiWwanQmap *pQmapDev = (sQmiWwanQmap *)info->unused; - - return snprintf(buf, PAGE_SIZE, "%d\n", pQmapDev->qmap_mode); -} - -static DEVICE_ATTR(qmap_mode, S_IRUGO, qmap_mode_show, NULL); - -static ssize_t qmap_size_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct net_device *netdev = to_net_dev(dev); - struct usbnet * usbnetdev = netdev_priv( netdev ); - struct qmi_wwan_state *info = (void *)&usbnetdev->data; - sQmiWwanQmap *pQmapDev = (sQmiWwanQmap *)info->unused; - - return snprintf(buf, PAGE_SIZE, "%u\n", pQmapDev->qmap_size); -} - -static DEVICE_ATTR(qmap_size, S_IRUGO, qmap_size_show, NULL); - -static ssize_t link_state_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct net_device *netdev = to_net_dev(dev); - struct usbnet * usbnetdev = netdev_priv( netdev ); - struct qmi_wwan_state *info = (void *)&usbnetdev->data; - sQmiWwanQmap *pQmapDev = (sQmiWwanQmap *)info->unused; - - return snprintf(buf, PAGE_SIZE, "0x%x\n", pQmapDev->link_state); -} - -static ssize_t link_state_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - struct net_device *netdev = to_net_dev(dev); - struct usbnet * usbnetdev = netdev_priv( netdev ); - struct qmi_wwan_state *info = (void *)&usbnetdev->data; - sQmiWwanQmap *pQmapDev = (sQmiWwanQmap *)info->unused; - unsigned link_state = 0; - unsigned old_link = pQmapDev->link_state; - uint offset_id = 0; - - link_state = simple_strtoul(buf, NULL, 0); - - if (pQmapDev->qmap_mode == 1) { - pQmapDev->link_state = !!link_state; - } - else if (pQmapDev->qmap_mode > 1) { - offset_id = ((link_state&0x7F) - 1); - - if (offset_id >= pQmapDev->qmap_mode) { - dev_info(dev, "%s offset_id is %d. but qmap_mode is %d\n", __func__, offset_id, pQmapDev->qmap_mode); - return count; - } - - if (link_state&0x80) - pQmapDev->link_state &= ~(1 << offset_id); - else - pQmapDev->link_state |= (1 << offset_id); - } - - if (old_link != pQmapDev->link_state) { - struct net_device *qmap_net = pQmapDev->mpQmapNetDev[offset_id]; - - if (pQmapDev->link_state) { - netif_carrier_on(usbnetdev->net); - } else { - netif_carrier_off(usbnetdev->net); - } - - if (qmap_net && qmap_net != netdev) { - struct qmap_priv *priv = netdev_priv(qmap_net); - - priv->link_state = !!(pQmapDev->link_state & (1 << offset_id)); - if (priv->link_state) { - netif_carrier_on(qmap_net); - if (netif_queue_stopped(qmap_net) && !netif_queue_stopped(usbnetdev->net)) - netif_wake_queue(qmap_net); - } - else { - netif_carrier_off(qmap_net); - } - } - - dev_info(dev, "link_state 0x%x -> 0x%x\n", old_link, pQmapDev->link_state); - } - - return count; -} - -#ifdef FIBOCOM_BRIDGE_MODE -static ssize_t bridge_mode_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - struct net_device *netdev = to_net_dev(dev); - uint old_mode = 0; - uint bridge_mode = simple_strtoul(buf, NULL, 0); - - if (netdev->type != ARPHRD_ETHER) { - return count; - } - - if (is_qmap_netdev(netdev)) { - struct qmap_priv *priv = netdev_priv(netdev); - old_mode = priv->bridge_mode; - priv->bridge_mode = bridge_mode; - } - else { - struct usbnet * usbnetdev = netdev_priv( netdev ); - struct qmi_wwan_state *info = (void *)&usbnetdev->data; - sQmiWwanQmap *pQmapDev = (sQmiWwanQmap *)info->unused; - old_mode = pQmapDev->bridge_mode; - pQmapDev->bridge_mode = bridge_mode; - } - - if (old_mode != bridge_mode) { - dev_info(dev, "bridge_mode change to 0x%x\n", bridge_mode); - } - - return count; -} - -static ssize_t bridge_mode_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct net_device *netdev = to_net_dev(dev); - uint bridge_mode = 0; - - if (is_qmap_netdev(netdev)) { - struct qmap_priv *priv = netdev_priv(netdev); - bridge_mode = priv->bridge_mode; - } - else { - struct usbnet * usbnetdev = netdev_priv( netdev ); - struct qmi_wwan_state *info = (void *)&usbnetdev->data; - sQmiWwanQmap *pQmapDev = (sQmiWwanQmap *)info->unused; - bridge_mode = pQmapDev->bridge_mode; - } - - return snprintf(buf, PAGE_SIZE, "%u\n", bridge_mode); -} - -static ssize_t bridge_ipv4_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct net_device *netdev = to_net_dev(dev); - unsigned int bridge_ipv4 = 0; - unsigned char ipv4[4]; - - if (is_qmap_netdev(netdev)) { - struct qmap_priv *priv = netdev_priv(netdev); - bridge_ipv4 = priv->bridge_ipv4; - } - else { - struct usbnet * usbnetdev = netdev_priv( netdev ); - struct qmi_wwan_state *info = (void *)&usbnetdev->data; - sQmiWwanQmap *pQmapDev = (sQmiWwanQmap *)info->unused; - bridge_ipv4 = pQmapDev->bridge_ipv4; - } - - ipv4[0] = (bridge_ipv4 >> 24) & 0xFF; - ipv4[1] = (bridge_ipv4 >> 16) & 0xFF; - ipv4[2] = (bridge_ipv4 >> 8) & 0xFF; - ipv4[3] = (bridge_ipv4 >> 0) & 0xFF; - - return snprintf(buf, PAGE_SIZE, "%d.%d.%d.%d\n", ipv4[0], ipv4[1], ipv4[2], ipv4[3]); -} - -static ssize_t bridge_ipv4_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - struct net_device *netdev = to_net_dev(dev); - - if (is_qmap_netdev(netdev)) { - struct qmap_priv *priv = netdev_priv(netdev); - priv->bridge_ipv4 = simple_strtoul(buf, NULL, 16); - } - else { - struct usbnet * usbnetdev = netdev_priv( netdev ); - struct qmi_wwan_state *info = (void *)&usbnetdev->data; - sQmiWwanQmap *pQmapDev = (sQmiWwanQmap *)info->unused; - pQmapDev->bridge_ipv4 = simple_strtoul(buf, NULL, 16); - } - - return count; -} -#endif - -static DEVICE_ATTR(link_state, S_IWUSR | S_IRUGO, link_state_show, link_state_store); -#ifdef FIBOCOM_BRIDGE_MODE -static DEVICE_ATTR(bridge_mode, S_IWUSR | S_IRUGO, bridge_mode_show, bridge_mode_store); -static DEVICE_ATTR(bridge_ipv4, S_IWUSR | S_IRUGO, bridge_ipv4_show, bridge_ipv4_store); -#endif - -static struct attribute *qmi_wwan_sysfs_attrs[] = { - &dev_attr_link_state.attr, - &dev_attr_qmap_mode.attr, - &dev_attr_qmap_size.attr, -#ifdef FIBOCOM_BRIDGE_MODE - &dev_attr_bridge_mode.attr, - &dev_attr_bridge_ipv4.attr, -#endif - NULL, -}; - -static struct attribute_group qmi_wwan_sysfs_attr_group = { - .attrs = qmi_wwan_sysfs_attrs, -}; - -#ifdef FIBOCOM_BRIDGE_MODE -static struct attribute *qmi_qmap_sysfs_attrs[] = { - &dev_attr_bridge_mode.attr, - &dev_attr_bridge_ipv4.attr, - NULL, -}; - -static struct attribute_group qmi_qmap_sysfs_attr_group = { - .attrs = qmi_qmap_sysfs_attrs, -}; -#endif - -static int qmap_open(struct net_device *dev) -{ - struct qmap_priv *priv = netdev_priv(dev); - struct net_device *real_dev = priv->real_dev; - - if (!(priv->real_dev->flags & IFF_UP)) - return -ENETDOWN; - - if (netif_carrier_ok(real_dev) && priv->link_state) - netif_carrier_on(dev); - - if (netif_carrier_ok(dev)) { - if (netif_queue_stopped(dev) && !netif_queue_stopped(real_dev)) - netif_wake_queue(dev); - } - - return 0; -} - -static int qmap_stop(struct net_device *pNet) -{ - netif_carrier_off(pNet); - return 0; -} - -static struct sk_buff * add_qhdr(struct sk_buff *skb, u8 mux_id) { - struct qmap_hdr *qhdr; - int pad = 0; - - pad = skb->len%4; - if (pad) { - pad = 4 - pad; - if (skb_tailroom(skb) < pad) { - printk("skb_tailroom small!\n"); - pad = 0; - } - if (pad) - __skb_put(skb, pad); - } - - qhdr = (struct qmap_hdr *)skb_push(skb, sizeof(struct qmap_hdr)); - qhdr->cd_rsvd_pad = pad; - qhdr->mux_id = mux_id; - qhdr->pkt_len = cpu_to_be16(skb->len - sizeof(struct qmap_hdr)); - - return skb; -} - -static struct sk_buff * add_qhdr_v5(struct sk_buff *skb, u8 mux_id) { - struct rmnet_map_header *map_header; - struct rmnet_map_v5_csum_header *ul_header; - u32 padding, map_datalen; - - map_datalen = skb->len; - padding = map_datalen%4; - if (padding) { - padding = 4 - padding; - if (skb_tailroom(skb) < padding) { - printk("skb_tailroom small!\n"); - padding = 0; - } - if (padding) - __skb_put(skb, padding); - } - - map_header = (struct rmnet_map_header *)skb_push(skb, (sizeof(struct rmnet_map_header) + sizeof(struct rmnet_map_v5_csum_header))); - map_header->cd_bit = 0; - map_header->next_hdr = 1; - map_header->pad_len = padding; - map_header->mux_id = mux_id; - map_header->pkt_len = htons(map_datalen + padding); - - ul_header = (struct rmnet_map_v5_csum_header *)(map_header + 1); - memset(ul_header, 0, sizeof(*ul_header)); - ul_header->header_type = RMNET_MAP_HEADER_TYPE_CSUM_OFFLOAD; - if (skb->ip_summed == CHECKSUM_PARTIAL) { -#if 0 //TODO - skb->ip_summed = CHECKSUM_NONE; - /* Ask for checksum offloading */ - ul_header->csum_valid_required = 1; -#endif - } - - return skb; -} - -static void rmnet_vnd_update_rx_stats(struct net_device *net, - unsigned rx_packets, unsigned rx_bytes) { -#if defined(MHI_NETDEV_STATUS64) - struct qmap_priv *dev = netdev_priv(net); - struct pcpu_sw_netstats *stats64 = this_cpu_ptr(dev->stats64); - - u64_stats_update_begin(&stats64->syncp); -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,18,0) - stats64->rx_packets += rx_packets; - stats64->rx_bytes += rx_bytes; -#else - u64_stats_add(&stats64->rx_packets, rx_packets); - u64_stats_add(&stats64->rx_bytes, rx_bytes); -#endif - u64_stats_update_end(&stats64->syncp); -#else - net->stats.rx_packets += rx_packets; - net->stats.rx_bytes += rx_bytes; -#endif -} - -static void rmnet_vnd_update_tx_stats(struct net_device *net, - unsigned tx_packets, unsigned tx_bytes) { -#if defined(MHI_NETDEV_STATUS64) - struct qmap_priv *dev = netdev_priv(net); - struct pcpu_sw_netstats *stats64 = this_cpu_ptr(dev->stats64); - - u64_stats_update_begin(&stats64->syncp); -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,18,0) - stats64->tx_packets += tx_packets; - stats64->tx_bytes += tx_bytes; -#else - u64_stats_add(&stats64->tx_packets, tx_packets); - u64_stats_add(&stats64->tx_bytes, tx_bytes); -#endif - u64_stats_update_end(&stats64->syncp); -#else - net->stats.tx_packets += tx_packets; - net->stats.tx_bytes += tx_bytes; -#endif -} - -#if defined(MHI_NETDEV_STATUS64) -static struct rtnl_link_stats64 *_rmnet_vnd_get_stats64(struct net_device *net, struct rtnl_link_stats64 *stats) -{ - struct qmap_priv *dev = netdev_priv(net); - unsigned int start; - int cpu; - struct rmnet_nss_cb *nss_cb; - - netdev_stats_to_stats64(stats, &net->stats); - - nss_cb = rcu_dereference(rmnet_nss_callbacks); - if (nss_cb) { // rmnet_nss.c:rmnet_nss_tx() will update rx stats - stats->rx_packets = 0; - stats->rx_bytes = 0; - } - - for_each_possible_cpu(cpu) { - struct pcpu_sw_netstats *stats64; - u64 rx_packets, rx_bytes; - u64 tx_packets, tx_bytes; - - stats64 = per_cpu_ptr(dev->stats64, cpu); - - do { - start = u64_stats_fetch_begin_irq(&stats64->syncp); -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,18,0) - rx_packets = stats64->rx_packets; - rx_bytes = stats64->rx_bytes; - tx_packets = stats64->tx_packets; - tx_bytes = stats64->tx_bytes; -#else - rx_packets = u64_stats_read(&stats64->rx_packets); - rx_bytes = u64_stats_read(&stats64->rx_bytes); - tx_packets = u64_stats_read(&stats64->tx_packets); - tx_bytes = u64_stats_read(&stats64->tx_bytes); -#endif - } while (u64_stats_fetch_retry_irq(&stats64->syncp, start)); - - stats->rx_packets += rx_packets; - stats->rx_bytes += rx_bytes; - stats->tx_packets += tx_packets; - stats->tx_bytes += tx_bytes; - } - - return stats; -} - -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 4,10,0 )) //bc1f44709cf27fb2a5766cadafe7e2ad5e9cb221 -static void rmnet_vnd_get_stats64(struct net_device *net, struct rtnl_link_stats64 *stats) { - _rmnet_vnd_get_stats64(net, stats); -} -#else -static struct rtnl_link_stats64 *rmnet_vnd_get_stats64(struct net_device *net, struct rtnl_link_stats64 *stats) { - return _rmnet_vnd_get_stats64(net, stats); -} -#endif -#endif - -#if defined(FIBOCOM_UL_DATA_AGG) -static void rmnet_usb_tx_wake_queue(unsigned long data) { - sQmiWwanQmap *pQmapDev = (void *)data; - int i; - - for (i = 0; i < pQmapDev->qmap_mode; i++) { - struct net_device *qmap_net = pQmapDev->mpQmapNetDev[i]; - if (qmap_net) { - if (netif_queue_stopped(qmap_net) && !netif_queue_stopped(pQmapDev->mpNetDev->net)) { - netif_wake_queue(qmap_net); - } - } - } -} - -static void rmnet_usb_tx_skb_destructor(struct sk_buff *skb) { - struct net_device *net = skb->dev; - struct usbnet * dev = netdev_priv( net ); - struct qmi_wwan_state *info = (void *)&dev->data; - sQmiWwanQmap *pQmapDev = (sQmiWwanQmap *)info->unused; - - if (pQmapDev && pQmapDev->use_rmnet_usb) { - int i; - - for (i = 0; i < pQmapDev->qmap_mode; i++) { - struct net_device *qmap_net = pQmapDev->mpQmapNetDev[i]; - - if (qmap_net) { - if (netif_queue_stopped(qmap_net)) { - tasklet_schedule(&pQmapDev->txq); - break; - } - } - } - } -} - -static int rmnet_usb_tx_agg_skip(struct sk_buff *skb, int offset) -{ - u8 *packet_start = skb->data + offset; - int ready2send = 0; - - if (skb->protocol == htons(ETH_P_IP)) { - struct iphdr *ip4h = (struct iphdr *)(packet_start); - - if (ip4h->protocol == IPPROTO_TCP) { - const struct tcphdr *th = (const struct tcphdr *)(packet_start + sizeof(struct iphdr)); - if (th->psh) { - ready2send = 1; - } - } - else if (ip4h->protocol == IPPROTO_ICMP) - ready2send = 1; - - } else if (skb->protocol == htons(ETH_P_IPV6)) { - struct ipv6hdr *ip6h = (struct ipv6hdr *)(packet_start); - - if (ip6h->nexthdr == NEXTHDR_TCP) { - const struct tcphdr *th = (const struct tcphdr *)(packet_start + sizeof(struct ipv6hdr)); - if (th->psh) { - ready2send = 1; - } - } else if (ip6h->nexthdr == NEXTHDR_ICMP) { - ready2send = 1; - } else if (ip6h->nexthdr == NEXTHDR_FRAGMENT) { - struct frag_hdr *frag; - - frag = (struct frag_hdr *)(packet_start - + sizeof(struct ipv6hdr)); - if (frag->nexthdr == IPPROTO_ICMPV6) - ready2send = 1; - } - } - - return ready2send; -} - -static void rmnet_usb_tx_agg_work(struct work_struct *work) -{ - struct qmap_priv *priv = - container_of(work, struct qmap_priv, agg_wq); - struct sk_buff *skb = NULL; - unsigned long flags; - - spin_lock_irqsave(&priv->agg_lock, flags); - if (likely(priv->agg_skb)) { - skb = priv->agg_skb; - priv->agg_skb = NULL; - priv->agg_count = 0; - skb->protocol = htons(ETH_P_MAP); - skb->dev = priv->real_dev; - ktime_get_ts64(&priv->agg_time); - } - spin_unlock_irqrestore(&priv->agg_lock, flags); - - if (skb) { - int err = dev_queue_xmit(skb); - if (err != NET_XMIT_SUCCESS) { - priv->self_dev->stats.tx_errors++; - } - } -} - -static enum hrtimer_restart rmnet_usb_tx_agg_timer_cb(struct hrtimer *timer) -{ - struct qmap_priv *priv = - container_of(timer, struct qmap_priv, agg_hrtimer); - - schedule_work(&priv->agg_wq); - return HRTIMER_NORESTART; -} - -static long agg_time_limit __read_mostly = 1000000L; //reduce this time, can get better TPUT performance, but will increase USB interrupts -module_param(agg_time_limit, long, S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(agg_time_limit, "Maximum time packets sit in the agg buf"); - -static long agg_bypass_time __read_mostly = 10000000L; -module_param(agg_bypass_time, long, S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(agg_bypass_time, "Skip agg when apart spaced more than this"); - -static int rmnet_usb_tx_agg(struct sk_buff *skb, struct qmap_priv *priv) { - struct qmi_wwan_state *info = (void *)&priv->dev->data; - sQmiWwanQmap *pQmapDev = (sQmiWwanQmap *)info->unused; - struct tx_agg_ctx *ctx = &pQmapDev->tx_ctx; - int ready2send = 0; - int xmit_more = 0; - struct timespec64 diff, now; - struct sk_buff *agg_skb = NULL; - unsigned long flags; - int err; - struct net_device *pNet = priv->self_dev; - -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,1,0) //6b16f9ee89b8d5709f24bc3ac89ae8b5452c0d7c -#if LINUX_VERSION_CODE > KERNEL_VERSION(3,16,0) - xmit_more = skb->xmit_more; -#endif -#else - xmit_more = netdev_xmit_more(); -#endif - - rmnet_vnd_update_tx_stats(pNet, 1, skb->len); - - if (ctx->ul_data_aggregation_max_datagrams == 1) { - skb->protocol = htons(ETH_P_MAP); - skb->dev = priv->real_dev; - if (!skb->destructor) - skb->destructor = rmnet_usb_tx_skb_destructor; - err = dev_queue_xmit(skb); - if (err != NET_XMIT_SUCCESS) - pNet->stats.tx_errors++; - return NET_XMIT_SUCCESS; - } - -new_packet: - spin_lock_irqsave(&priv->agg_lock, flags); - agg_skb = NULL; - ready2send = 0; - ktime_get_ts64(&now); - diff = timespec64_sub(now, priv->agg_time); - - if (priv->agg_skb) { - if ((priv->agg_skb->len + skb->len) < ctx->ul_data_aggregation_max_size) { - memcpy(skb_put(priv->agg_skb, skb->len), skb->data, skb->len); - priv->agg_count++; - - if (diff.tv_sec > 0 || diff.tv_nsec > agg_time_limit) { - ready2send = 1; - } - else if (priv->agg_count == ctx->ul_data_aggregation_max_datagrams) { - ready2send = 1; - } - else if (xmit_more == 0) { - struct rmnet_map_header *map_header = (struct rmnet_map_header *)skb->data; - size_t offset = sizeof(struct rmnet_map_header); - if (map_header->next_hdr) - offset += sizeof(struct rmnet_map_v5_csum_header); - - ready2send = rmnet_usb_tx_agg_skip(skb, offset); - } - - dev_kfree_skb_any(skb); - skb = NULL; - } - else { - ready2send = 1; - } - - if (ready2send) { - agg_skb = priv->agg_skb; - priv->agg_skb = NULL; - priv->agg_count = 0; - } - } - else if (skb) { - if (diff.tv_sec > 0 || diff.tv_nsec > agg_bypass_time) { - ready2send = 1; - } - else if (xmit_more == 0) { - struct rmnet_map_header *map_header = (struct rmnet_map_header *)skb->data; - size_t offset = sizeof(struct rmnet_map_header); - if (map_header->next_hdr) - offset += sizeof(struct rmnet_map_v5_csum_header); - - ready2send = rmnet_usb_tx_agg_skip(skb, offset); - } - - if (ready2send == 0) { - priv->agg_skb = alloc_skb(ctx->ul_data_aggregation_max_size, GFP_ATOMIC); - if (priv->agg_skb) { - memcpy(skb_put(priv->agg_skb, skb->len), skb->data, skb->len); - priv->agg_count++; - dev_kfree_skb_any(skb); - skb = NULL; - } - else { - ready2send = 1; - } - } - - if (ready2send) { - agg_skb = skb; - skb = NULL; - } - } - - if (ready2send) { - priv->agg_time = now; - } - spin_unlock_irqrestore(&priv->agg_lock, flags); - - if (agg_skb) { - agg_skb->protocol = htons(ETH_P_MAP); - agg_skb->dev = priv->real_dev; - if (!agg_skb->destructor) - agg_skb->destructor = rmnet_usb_tx_skb_destructor; - err = dev_queue_xmit(agg_skb); - if (err != NET_XMIT_SUCCESS) { - pNet->stats.tx_errors++; - } - } - - if (skb) { - goto new_packet; - } - - if (priv->agg_skb) { - if (!hrtimer_is_queued(&priv->agg_hrtimer)) - hrtimer_start(&priv->agg_hrtimer, ns_to_ktime(NSEC_PER_MSEC * 2), HRTIMER_MODE_REL); - } - - return NET_XMIT_SUCCESS; -} -#endif - -static netdev_tx_t rmnet_vnd_start_xmit(struct sk_buff *skb, - struct net_device *pNet) -{ - int err; - struct qmap_priv *priv = netdev_priv(pNet); - - if (netif_queue_stopped(priv->real_dev)) { - netif_stop_queue(pNet); - return NETDEV_TX_BUSY; - } - - //printk("%s 1 skb=%p, len=%d, protocol=%x, hdr_len=%d\n", __func__, skb, skb->len, skb->protocol, skb->hdr_len); - if (pNet->type == ARPHRD_ETHER) { - skb_reset_mac_header(skb); - -#ifdef FIBOCOM_BRIDGE_MODE - if (priv->bridge_mode && bridge_mode_tx_fixup(pNet, skb, priv->bridge_ipv4, priv->bridge_mac) == NULL) { - dev_kfree_skb_any (skb); - return NETDEV_TX_OK; - } -#endif - - if (skb_pull(skb, ETH_HLEN) == NULL) { - dev_kfree_skb_any (skb); - return NETDEV_TX_OK; - } - } - //printk("%s 2 skb=%p, len=%d, protocol=%x, hdr_len=%d\n", __func__, skb, skb->len, skb->protocol, skb->hdr_len); - - if (priv->qmap_version == 5) { - add_qhdr(skb, priv->mux_id); - } - else if (priv->qmap_version == 9) { - add_qhdr_v5(skb, priv->mux_id); - } - else { - dev_kfree_skb_any (skb); - return NETDEV_TX_OK; - } - //printk("%s skb=%p, len=%d, protocol=%x, hdr_len=%d\n", __func__, skb, skb->len, skb->protocol, skb->hdr_len); - -#if 0 - skb->protocol = htons(ETH_P_MAP); - skb->dev = priv->real_dev; - err = dev_queue_xmit(skb); - - if (err == NET_XMIT_SUCCESS) { - rmnet_vnd_update_tx_stats(pNet, 1, skb->len); - } else { - pNet->stats.tx_errors++; - } -#else - err = rmnet_usb_tx_agg(skb, priv); -#endif - - return err; -} - -static int rmnet_vnd_change_mtu(struct net_device *rmnet_dev, int new_mtu) -{ - if (new_mtu < 0 || new_mtu > 1500) - return -EINVAL; - - rmnet_dev->mtu = new_mtu; - return 0; -} - -/* drivers may override default ethtool_ops in their bind() routine */ -static const struct ethtool_ops rmnet_vnd_ethtool_ops = { - .get_link = ethtool_op_get_link, -}; - -static int qmap_start_xmit(struct sk_buff *skb, struct net_device *pNet) -{ - int err; - struct qmap_priv *priv = netdev_priv(pNet); - - //printk("%s 1 skb=%p, len=%d, protocol=%x, hdr_len=%d\n", __func__, skb, skb->len, skb->protocol, skb->hdr_len); - if (pNet->type == ARPHRD_ETHER) { - skb_reset_mac_header(skb); - -#ifdef FIBOCOM_BRIDGE_MODE - if (priv->bridge_mode && bridge_mode_tx_fixup(pNet, skb, priv->bridge_ipv4, priv->bridge_mac) == NULL) { - dev_kfree_skb_any (skb); - return NETDEV_TX_OK; - } -#endif - - if (skb_pull(skb, ETH_HLEN) == NULL) { - dev_kfree_skb_any (skb); - return NETDEV_TX_OK; - } - } - - - add_qhdr(skb, FIBOCOM_QMAP_MUX_ID + priv->offset_id); - - skb->dev = priv->real_dev; - err = dev_queue_xmit(skb); - if (err == NET_XMIT_SUCCESS) { - pNet->stats.tx_packets++; - pNet->stats.tx_bytes += skb->len; - } else { - pNet->stats.tx_errors++; - } - - return err; -} - -static const struct net_device_ops qmap_netdev_ops = { - .ndo_open = qmap_open, - .ndo_stop = qmap_stop, - .ndo_start_xmit = qmap_start_xmit, -}; - -static const struct net_device_ops rmnet_vnd_ops = { - .ndo_open = qmap_open, - .ndo_stop = qmap_stop, - .ndo_start_xmit = rmnet_vnd_start_xmit, - .ndo_change_mtu = rmnet_vnd_change_mtu, -#if defined(MHI_NETDEV_STATUS64) - .ndo_get_stats64 = rmnet_vnd_get_stats64, -#endif -}; - -static void rmnet_usb_vnd_setup(struct net_device *rmnet_dev) -{ - rmnet_dev->needed_headroom = 16; - - /* Raw IP mode */ - rmnet_dev->header_ops = NULL; /* No header */ - rmnet_dev->type = ARPHRD_RAWIP; - rmnet_dev->hard_header_len = 0; - rmnet_dev->flags &= ~(IFF_BROADCAST | IFF_MULTICAST); -} - -static rx_handler_result_t rmnet_usb_rx_priv_handler(struct sk_buff **pskb) -{ - struct sk_buff *skb = *pskb; - struct rmnet_nss_cb *nss_cb; - - if (!skb) - return RX_HANDLER_CONSUMED; - - //printk("%s skb=%p, len=%d, protocol=%x, hdr_len=%d\n", __func__, skb, skb->len, skb->protocol, skb->hdr_len); - - if (skb->pkt_type == PACKET_LOOPBACK) - return RX_HANDLER_PASS; - - /* Check this so that we dont loop around netif_receive_skb */ - if (skb->cb[0] == 1) { - skb->cb[0] = 0; - - return RX_HANDLER_PASS; - } - - nss_cb = rcu_dereference(rmnet_nss_callbacks); - if (nss_cb) { - nss_cb->nss_tx(skb); - return RX_HANDLER_CONSUMED; - } - - return RX_HANDLER_PASS; -} - -static int qmap_register_device(sQmiWwanQmap * pDev, u8 offset_id) -{ - struct net_device *real_dev = pDev->mpNetDev->net; - struct net_device *qmap_net; - struct qmap_priv *priv; - int err; - struct rmnet_nss_cb *nss_cb; - - qmap_net = alloc_etherdev(sizeof(*priv)); - if (!qmap_net) - return -ENOBUFS; - - SET_NETDEV_DEV(qmap_net, &real_dev->dev); - priv = netdev_priv(qmap_net); - priv->offset_id = offset_id; - priv->real_dev = real_dev; - priv->self_dev = qmap_net; - priv->dev = pDev->mpNetDev; - priv->qmap_version = pDev->qmap_version; - priv->mux_id = FIBOCOM_QMAP_MUX_ID + offset_id; - sprintf(qmap_net->name, "%s.%d", real_dev->name, offset_id + 1); - qmap_net->netdev_ops = &qmap_netdev_ops; - memcpy (qmap_net->dev_addr, real_dev->dev_addr, ETH_ALEN); - -#ifdef FIBOCOM_BRIDGE_MODE - priv->bridge_mode = !!(pDev->bridge_mode & BIT(offset_id)); - qmap_net->sysfs_groups[0] = &qmi_qmap_sysfs_attr_group; -#endif - - priv->agg_skb = NULL; - priv->agg_count = 0; - hrtimer_init(&priv->agg_hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); - priv->agg_hrtimer.function = rmnet_usb_tx_agg_timer_cb; - INIT_WORK(&priv->agg_wq, rmnet_usb_tx_agg_work); - ktime_get_ts64(&priv->agg_time); - spin_lock_init(&priv->agg_lock); - - if (pDev->use_rmnet_usb) { - qmap_net->ethtool_ops = &rmnet_vnd_ethtool_ops; - qmap_net->netdev_ops = &rmnet_vnd_ops; -#if defined(MHI_NETDEV_STATUS64) - priv->stats64 = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); - if (!priv->stats64) { - err = -ENOBUFS; - goto out_free_newdev; - } -#endif - } - - nss_cb = rcu_dereference(rmnet_nss_callbacks); -#ifdef FIBOCOM_BRIDGE_MODE - if(nss_cb && !priv->bridge_mode) { -#else - if (nss_cb) { -#endif - rmnet_usb_vnd_setup(qmap_net); - } - - err = register_netdev(qmap_net); - dev_info(&real_dev->dev, "%s(%s)=%d\n", __func__, qmap_net->name, err); - if (err < 0) - goto out_free_newdev; - netif_device_attach (qmap_net); - netif_carrier_off(qmap_net); - - nss_cb = rcu_dereference(rmnet_nss_callbacks); -#ifdef FIBOCOM_BRIDGE_MODE - if(nss_cb && !priv->bridge_mode) { -#else - if (nss_cb) { -#endif - int rc = nss_cb->nss_create(qmap_net); - if (rc) { - /* Log, but don't fail the device creation */ - netdev_err(qmap_net, "Device will not use NSS path: %d\n", rc); - } else { - netdev_info(qmap_net, "NSS context created\n"); - rtnl_lock(); - netdev_rx_handler_register(qmap_net, rmnet_usb_rx_priv_handler, NULL); - rtnl_unlock(); - } - } - - if (pDev->use_rmnet_usb) { - strcpy(pDev->rmnet_info.ifname[offset_id], qmap_net->name); - pDev->rmnet_info.mux_id[offset_id] = priv->mux_id; - } - - pDev->mpQmapNetDev[offset_id] = qmap_net; - qmap_net->flags |= IFF_NOARP; - qmap_net->flags &= ~(IFF_BROADCAST | IFF_MULTICAST); - - dev_info(&real_dev->dev, "%s %s\n", __func__, qmap_net->name); - - return 0; - -out_free_newdev: - free_netdev(qmap_net); - return err; -} - -static void qmap_unregister_device(sQmiWwanQmap * pDev, u8 offset_id) { - struct net_device *qmap_net = pDev->mpQmapNetDev[offset_id]; - - if (qmap_net != NULL && qmap_net != pDev->mpNetDev->net) { - struct rmnet_nss_cb *nss_cb; - struct qmap_priv *priv = netdev_priv(qmap_net); - unsigned long flags; - - pr_info("qmap_unregister_device(%s)\n", qmap_net->name); - pDev->mpQmapNetDev[offset_id] = NULL; - netif_carrier_off( qmap_net ); - netif_stop_queue( qmap_net ); - - hrtimer_cancel(&priv->agg_hrtimer); - cancel_work_sync(&priv->agg_wq); - spin_lock_irqsave(&priv->agg_lock, flags); - if (priv->agg_skb) { - kfree_skb(priv->agg_skb); - } - spin_unlock_irqrestore(&priv->agg_lock, flags); - nss_cb = rcu_dereference(rmnet_nss_callbacks); - -#ifdef FIBOCOM_BRIDGE_MODE - if(nss_cb && !priv->bridge_mode) { -#else - if (nss_cb) { -#endif - rtnl_lock(); - netdev_rx_handler_unregister(qmap_net); - rtnl_unlock(); - nss_cb->nss_free(qmap_net); - } - -#if defined(MHI_NETDEV_STATUS64) - free_percpu(priv->stats64); -#endif - unregister_netdev (qmap_net); - free_netdev(qmap_net); - } -} - -#if 1//def CONFIG_ANDROID -typedef struct { - unsigned int size; - unsigned int rx_urb_size; - unsigned int ep_type; - unsigned int iface_id; - unsigned int MuxId; - unsigned int ul_data_aggregation_max_datagrams; //0x17 - unsigned int ul_data_aggregation_max_size ;//0x18 - unsigned int dl_minimum_padding; //0x1A -} QMAP_SETTING; - -int qma_setting_store(struct device *dev, QMAP_SETTING *qmap_settings, size_t size) { - struct net_device *netdev = to_net_dev(dev); - struct usbnet * usbnetdev = netdev_priv( netdev ); - struct qmi_wwan_state *info = (void *)&usbnetdev->data; - sQmiWwanQmap *pQmapDev = (sQmiWwanQmap *)info->unused; - - if (qmap_settings->size != size) { - dev_err(dev, "ERROR: qmap_settings.size donot match!\n"); - return -EOPNOTSUPP; - } - -#ifdef FIBOCOM_UL_DATA_AGG - netif_tx_lock_bh(netdev); - if (pQmapDev->tx_ctx.ul_data_aggregation_max_datagrams == 1 && qmap_settings->ul_data_aggregation_max_datagrams > 1) { - pQmapDev->tx_ctx.ul_data_aggregation_max_datagrams = qmap_settings->ul_data_aggregation_max_datagrams; - pQmapDev->tx_ctx.ul_data_aggregation_max_size = qmap_settings->ul_data_aggregation_max_size; - pQmapDev->tx_ctx.dl_minimum_padding = qmap_settings->dl_minimum_padding; - dev_info(dev, "ul_data_aggregation_max_datagrams=%d, ul_data_aggregation_max_size=%d, dl_minimum_padding=%d\n", - pQmapDev->tx_ctx.ul_data_aggregation_max_datagrams, - pQmapDev->tx_ctx.ul_data_aggregation_max_size, - pQmapDev->tx_ctx.dl_minimum_padding); - } - netif_tx_unlock_bh(netdev); - return 0; -#endif - - return -EOPNOTSUPP; -} - -static int qmap_ndo_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) { - struct usbnet * usbnetdev = netdev_priv( dev ); - struct qmi_wwan_state *info = (void *)&usbnetdev->data; - sQmiWwanQmap *pQmapDev = (sQmiWwanQmap *)info->unused; - int rc = -EOPNOTSUPP; - uint link_state = 0; - QMAP_SETTING qmap_settings = {0}; - - switch (cmd) { - case 0x89F1: //SIOCDEVPRIVATE - rc = copy_from_user(&link_state, ifr->ifr_ifru.ifru_data, sizeof(link_state)); - if (!rc) { - char buf[32]; - snprintf(buf, sizeof(buf), "%u", link_state); - link_state_store(&dev->dev, NULL, buf, strlen(buf)); - } - break; - - case 0x89F2: //SIOCDEVPRIVATE - rc = copy_from_user(&qmap_settings, ifr->ifr_ifru.ifru_data, sizeof(qmap_settings)); - if (!rc) { - rc = qma_setting_store(&dev->dev, &qmap_settings, sizeof(qmap_settings)); - } - break; - - case 0x89F3: //SIOCDEVPRIVATE - if (pQmapDev->use_rmnet_usb) { - uint i; - - for (i = 0; i < pQmapDev->qmap_mode; i++) { - struct net_device *qmap_net = pQmapDev->mpQmapNetDev[i]; - - if (!qmap_net) - break; - - strcpy(pQmapDev->rmnet_info.ifname[i], qmap_net->name); - } - rc = copy_to_user(ifr->ifr_ifru.ifru_data, &pQmapDev->rmnet_info, sizeof(pQmapDev->rmnet_info)); - } - break; - - default: - break; - } - - return rc; -} -#endif - -#ifdef FIBOCOM_BRIDGE_MODE -static int is_qmap_netdev(const struct net_device *netdev) { - return netdev->netdev_ops == &qmap_netdev_ops || netdev->netdev_ops == &rmnet_vnd_ops; -} -#endif -#endif - -static struct sk_buff *qmi_wwan_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) { - if ((dev->driver_info->flags & FLAG_NOARP) == 0) - return skb; - - // Skip Ethernet header from message - if (dev->net->hard_header_len == 0) - return skb; - else - skb_reset_mac_header(skb); - -#ifdef FIBOCOM_BRIDGE_MODE -{ - struct qmi_wwan_state *info = (void *)&dev->data; - sQmiWwanQmap *pQmapDev = (sQmiWwanQmap *)info->unused; - - if (pQmapDev->bridge_mode && bridge_mode_tx_fixup(dev->net, skb, pQmapDev->bridge_ipv4, pQmapDev->bridge_mac) == NULL) { - dev_kfree_skb_any (skb); - return NULL; - } -} -#endif - - if (skb_pull(skb, ETH_HLEN)) { - return skb; - } else { - dev_err(&dev->intf->dev, "Packet Dropped "); - } - - // Filter the packet out, release it - dev_kfree_skb_any(skb); - return NULL; -} -#endif - -/* Make up an ethernet header if the packet doesn't have one. - * - * A firmware bug common among several devices cause them to send raw - * IP packets under some circumstances. There is no way for the - * driver/host to know when this will happen. And even when the bug - * hits, some packets will still arrive with an intact header. - * - * The supported devices are only capably of sending IPv4, IPv6 and - * ARP packets on a point-to-point link. Any packet with an ethernet - * header will have either our address or a broadcast/multicast - * address as destination. ARP packets will always have a header. - * - * This means that this function will reliably add the appropriate - * header if necessary, provided our hardware address does not start - * with 4 or 6. - * - * Another common firmware bug results in all packets being addressed - * to 00:a0:c6:00:00:00 despite the host address being different. - * This function will also fixup such packets. - */ -static int qmi_wwan_rx_fixup(struct usbnet *dev, struct sk_buff *skb) -{ - __be16 proto; - - /* This check is no longer done by usbnet */ - if (skb->len < dev->net->hard_header_len) - return 0; - - switch (skb->data[0] & 0xf0) { - case 0x40: - proto = htons(ETH_P_IP); - break; - case 0x60: - proto = htons(ETH_P_IPV6); - break; - case 0x00: - if (is_multicast_ether_addr(skb->data)) - return 1; - /* possibly bogus destination - rewrite just in case */ - skb_reset_mac_header(skb); - goto fix_dest; - default: - /* pass along other packets without modifications */ - return 1; - } - if (skb_headroom(skb) < ETH_HLEN) - return 0; - skb_push(skb, ETH_HLEN); - skb_reset_mac_header(skb); - eth_hdr(skb)->h_proto = proto; - memset(eth_hdr(skb)->h_source, 0, ETH_ALEN); -#if 1 //Added by Fibocom - //some kernel will drop ethernet packet which's souce mac is all zero - memcpy(eth_hdr(skb)->h_source, default_modem_addr, ETH_ALEN); -#endif - -fix_dest: -#ifdef FIBOCOM_BRIDGE_MODE -{ - struct qmi_wwan_state *info = (void *)&dev->data; - sQmiWwanQmap *pQmapDev = (sQmiWwanQmap *)info->unused; - bridge_mode_rx_fixup(pQmapDev, dev->net, skb); -} -#else - memcpy(eth_hdr(skb)->h_dest, dev->net->dev_addr, ETH_ALEN); -#endif - - return 1; -} - -#if defined(FIBOCOM_WWAN_QMAP) -static struct sk_buff *qmap_qmi_wwan_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) { - struct qmi_wwan_state *info = (void *)&dev->data; - sQmiWwanQmap *pQmapDev = (sQmiWwanQmap *)info->unused; - struct qmap_hdr *qhdr; - - if (unlikely(pQmapDev == NULL)) { - goto drop_skb; - } else if (unlikely(pQmapDev->qmap_mode && !pQmapDev->link_state)) { - dev_dbg(&dev->net->dev, "link_state 0x%x, drop skb, len = %u\n", pQmapDev->link_state, skb->len); - goto drop_skb; - } else if (pQmapDev->qmap_mode == 0) { - skb = qmi_wwan_tx_fixup(dev, skb, flags); - } - else if (pQmapDev->qmap_mode > 1) { - if (likely(skb)) { - qhdr = (struct qmap_hdr *)skb->data; - if ((qhdr->mux_id&0xF0) != 0x80 || ((be16_to_cpu(qhdr->pkt_len) + sizeof(struct qmap_hdr)) != skb->len)) { - goto drop_skb; - } - } - } - else { - if (likely(skb)) { - skb = qmi_wwan_tx_fixup(dev, skb, flags); - - if (skb) { - add_qhdr(skb, FIBOCOM_QMAP_MUX_ID); - } - else { - return NULL; - } - } - } - - if (skb && (dev->driver_info->flags&FLAG_MULTI_PACKET)) { - usbnet_set_skb_tx_stats(skb, 1, 0); - } - - - return skb; -drop_skb: - dev_kfree_skb_any (skb); - return NULL; -} - -static int qmap_qmi_wwan_rx_fixup(struct usbnet *dev, struct sk_buff *skb_in) -{ - struct qmi_wwan_state *info = (void *)&dev->data; - sQmiWwanQmap *pQmapDev = (sQmiWwanQmap *)info->unused; - unsigned headroom = 0; - const unsigned need_headroot = ETH_HLEN; - struct sk_buff *qmap_skb; - - if (pQmapDev->qmap_mode == 0) - return qmi_wwan_rx_fixup(dev, skb_in); - - headroom = skb_headroom(skb_in); - - while (skb_in->len > sizeof(struct qmap_hdr)) { - struct qmap_hdr *qhdr = (struct qmap_hdr *)skb_in->data; - struct net_device *qmap_net; - int pkt_len = be16_to_cpu(qhdr->pkt_len); - int skb_len; - __be16 protocol; - int mux_id; - - skb_len = pkt_len - (qhdr->cd_rsvd_pad&0x3F); - if (skb_len > 1500) { - dev_info(&dev->net->dev, "drop skb_len=%x larger than 1500\n", skb_len); - goto error_pkt; - } - - if (skb_in->len < (pkt_len + sizeof(struct qmap_hdr))) { - dev_info(&dev->net->dev, "drop qmap unknow pkt, len=%d, pkt_len=%d\n", skb_in->len, pkt_len); - goto error_pkt; - } - - if (qhdr->cd_rsvd_pad & 0x80) { - dev_info(&dev->net->dev, "skip qmap command packet %x\n", qhdr->cd_rsvd_pad); - goto skip_pkt; - } - - switch (skb_in->data[sizeof(struct qmap_hdr)] & 0xf0) { - case 0x40: - protocol = htons(ETH_P_IP); - break; - case 0x60: - protocol = htons(ETH_P_IPV6); - break; - default: - dev_info(&dev->net->dev, "unknow skb->protocol %02x\n", skb_in->data[sizeof(struct qmap_hdr)]); - goto error_pkt; - } - - mux_id = qhdr->mux_id - FIBOCOM_QMAP_MUX_ID; - if (mux_id >= pQmapDev->qmap_mode) { - dev_info(&dev->net->dev, "drop qmap unknow mux_id %x\n", qhdr->mux_id); - goto error_pkt; - } - - qmap_net = pQmapDev->mpQmapNetDev[mux_id]; - - if (qmap_net == NULL) { - dev_info(&dev->net->dev, "drop qmap unknow mux_id %x\n", qhdr->mux_id); - goto skip_pkt; - } - - if (headroom >= need_headroot) { - qmap_skb = skb_clone(skb_in, GFP_ATOMIC); - if (qmap_skb) { - qmap_skb->dev = qmap_net; - skb_pull(qmap_skb, sizeof(struct qmap_hdr)); - skb_trim(qmap_skb, skb_len); - } - headroom = (qhdr->cd_rsvd_pad&0x3F); - } - else { - qmap_skb = netdev_alloc_skb(qmap_net, need_headroot + skb_len); - if (qmap_skb) { - skb_reserve(qmap_skb, need_headroot); - skb_put(qmap_skb, skb_len); - memcpy(qmap_skb->data, skb_in->data + sizeof(struct qmap_hdr), skb_len); - } - headroom = pkt_len; - } - - if (qmap_skb == NULL) { - dev_info(&dev->net->dev, "fail to alloc skb, pkt_len = %d\n", skb_len); - return 0; - } - - skb_push(qmap_skb, ETH_HLEN); - skb_reset_mac_header(qmap_skb); - memcpy(eth_hdr(qmap_skb)->h_source, default_modem_addr, ETH_ALEN); - memcpy(eth_hdr(qmap_skb)->h_dest, qmap_net->dev_addr, ETH_ALEN); - eth_hdr(qmap_skb)->h_proto = protocol; -#ifdef FIBOCOM_BRIDGE_MODE - bridge_mode_rx_fixup(pQmapDev, qmap_net, qmap_skb); -#endif - - if (qmap_net != dev->net) { - qmap_net->stats.rx_packets++; - qmap_net->stats.rx_bytes += qmap_skb->len; - } - - skb_queue_tail(&pQmapDev->skb_chain, qmap_skb); - -skip_pkt: - skb_pull(skb_in, pkt_len + sizeof(struct qmap_hdr)); - } - - while ((qmap_skb = skb_dequeue (&pQmapDev->skb_chain))) { - if (qmap_skb->dev != dev->net) { - qmap_skb->protocol = eth_type_trans (qmap_skb, qmap_skb->dev); - netif_rx(qmap_skb); - } - else { - qmap_skb->protocol = 0; - usbnet_skb_return(dev, qmap_skb); - } - } - -error_pkt: - return 0; -} -#endif - -/* very simplistic detection of IPv4 or IPv6 headers */ -static bool possibly_iphdr(const char *data) -{ - return (data[0] & 0xd0) == 0x40; -} - -/* disallow addresses which may be confused with IP headers */ -static int qmi_wwan_mac_addr(struct net_device *dev, void *p) -{ - int ret; - struct sockaddr *addr = p; - - ret = eth_prepare_mac_addr_change(dev, p); - if (ret < 0) - return ret; - if (possibly_iphdr(addr->sa_data)) - return -EADDRNOTAVAIL; - eth_commit_mac_addr_change(dev, p); - return 0; -} - -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 4,10,0 )) //bc1f44709cf27fb2a5766cadafe7e2ad5e9cb221 -static void (*_usbnet_get_stats64)(struct net_device *net, struct rtnl_link_stats64 *stats); - -static void qmi_wwan_get_stats64(struct net_device *net, struct rtnl_link_stats64 *stats) { - if (_usbnet_get_stats64) ////c8b5d129ee293bcf972e7279ac996bb8a138505c - return _usbnet_get_stats64(net, stats); - - netdev_stats_to_stats64(stats, &net->stats); -} -#else -static struct rtnl_link_stats64 * (*_usbnet_get_stats64)(struct net_device *net, struct rtnl_link_stats64 *stats); - -static struct rtnl_link_stats64 * qmi_wwan_get_stats64(struct net_device *net, struct rtnl_link_stats64 *stats) { - if (_usbnet_get_stats64) - return _usbnet_get_stats64(net, stats); - - netdev_stats_to_stats64(stats, &net->stats); - return stats; -} -#endif - -static netdev_tx_t qmi_wwan_start_xmit (struct sk_buff *skb, - struct net_device *net) -{ - struct usbnet * usbnetdev = netdev_priv( net ); - struct qmi_wwan_state *info = (void *)&usbnetdev->data; - sQmiWwanQmap *pQmapDev = (sQmiWwanQmap *)info->unused; - int retval; - - retval = usbnet_start_xmit(skb, net); - - if (netif_queue_stopped(net) && pQmapDev && pQmapDev->use_rmnet_usb) { - int i; - - for (i = 0; i < pQmapDev->qmap_mode; i++) { - struct net_device *qmap_net = pQmapDev->mpQmapNetDev[i]; - if (qmap_net) { - netif_stop_queue(qmap_net); - } - } - } - - return retval; -} - -static const struct net_device_ops qmi_wwan_netdev_ops = { - .ndo_open = usbnet_open, - .ndo_stop = usbnet_stop, - .ndo_start_xmit = qmi_wwan_start_xmit, - .ndo_tx_timeout = usbnet_tx_timeout, - .ndo_change_mtu = usbnet_change_mtu, - .ndo_get_stats64 = qmi_wwan_get_stats64, - .ndo_set_mac_address = qmi_wwan_mac_addr, - .ndo_validate_addr = eth_validate_addr, -#if defined(FIBOCOM_WWAN_QMAP)// && defined(CONFIG_ANDROID) - .ndo_do_ioctl = qmap_ndo_do_ioctl, -#endif -}; - -static void ql_net_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *info) -{ - /* Inherit standard device info */ - usbnet_get_drvinfo(net, info); - strlcpy(info->driver, driver_name, sizeof(info->driver)); - strlcpy(info->version, VERSION_NUMBER, sizeof(info->version)); -} - -static struct ethtool_ops ql_net_ethtool_ops; - -/* using a counter to merge subdriver requests with our own into a - * combined state - */ -static int qmi_wwan_manage_power(struct usbnet *dev, int on) -{ - struct qmi_wwan_state *info = (void *)&dev->data; - int rv; - - dev_dbg(&dev->intf->dev, "%s() pmcount=%d, on=%d\n", __func__, - atomic_read(&info->pmcount), on); - - if ((on && atomic_add_return(1, &info->pmcount) == 1) || - (!on && atomic_dec_and_test(&info->pmcount))) { - /* need autopm_get/put here to ensure the usbcore sees - * the new value - */ - rv = usb_autopm_get_interface(dev->intf); - dev->intf->needs_remote_wakeup = on; - if (!rv) - usb_autopm_put_interface(dev->intf); - } - return 0; -} - -static int qmi_wwan_cdc_wdm_manage_power(struct usb_interface *intf, int on) -{ - struct usbnet *dev = usb_get_intfdata(intf); - - /* can be called while disconnecting */ - if (!dev) - return 0; - return qmi_wwan_manage_power(dev, on); -} - -/* collect all three endpoints and register subdriver */ -static int qmi_wwan_register_subdriver(struct usbnet *dev) -{ - int rv; - struct usb_driver *subdriver = NULL; - struct qmi_wwan_state *info = (void *)&dev->data; - - /* collect bulk endpoints */ - rv = usbnet_get_endpoints(dev, info->data); - if (rv < 0) - goto err; - - /* update status endpoint if separate control interface */ - if (info->control != info->data) - dev->status = &info->control->cur_altsetting->endpoint[0]; - - /* require interrupt endpoint for subdriver */ - if (!dev->status) { - rv = -EINVAL; - goto err; - } - - /* for subdriver power management */ - atomic_set(&info->pmcount, 0); - - /* register subdriver */ -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 5,12,0 )) //cac6fb015f719104e60b1c68c15ca5b734f57b9c - subdriver = usb_cdc_wdm_register(info->control, &dev->status->desc, - 4096, WWAN_PORT_QMI, &qmi_wwan_cdc_wdm_manage_power); -#else - subdriver = usb_cdc_wdm_register(info->control, &dev->status->desc, - 4096, &qmi_wwan_cdc_wdm_manage_power); - -#endif - if (IS_ERR(subdriver)) { - dev_err(&info->control->dev, "subdriver registration failed\n"); - rv = PTR_ERR(subdriver); - goto err; - } - - /* prevent usbnet from using status endpoint */ - dev->status = NULL; - - /* save subdriver struct for suspend/resume wrappers */ - info->subdriver = subdriver; - -err: - return rv; -} - -static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf) -{ - int status = -1; - struct usb_driver *driver = driver_of(intf); - struct qmi_wwan_state *info = (void *)&dev->data; - - BUILD_BUG_ON((sizeof(((struct usbnet *)0)->data) < - sizeof(struct qmi_wwan_state))); - - /* set up initial state */ - info->control = intf; - info->data = intf; - - status = qmi_wwan_register_subdriver(dev); - if (status < 0 && info->control != info->data) { - usb_set_intfdata(info->data, NULL); - usb_driver_release_interface(driver, info->data); - } - - /* Never use the same address on both ends of the link, even - * if the buggy firmware told us to. - */ - if (ether_addr_equal(dev->net->dev_addr, default_modem_addr)) - eth_hw_addr_random(dev->net); - - /* make MAC addr easily distinguishable from an IP header */ - if (possibly_iphdr(dev->net->dev_addr)) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,18,0) - dev->net->dev_addr[0] |= 0x02; /* set local assignment bit */ - dev->net->dev_addr[0] &= 0xbf; /* clear "IP" bit */ -#else - u8 addr = dev->net->dev_addr[0]; - - addr |= 0x02; /* set local assignment bit */ - addr &= 0xbf; /* clear "IP" bit */ - dev_addr_mod(dev->net, 0, &addr, 1); -#endif - } - if (!_usbnet_get_stats64) - _usbnet_get_stats64 = dev->net->netdev_ops->ndo_get_stats64; - dev->net->netdev_ops = &qmi_wwan_netdev_ops; - - ql_net_ethtool_ops = *dev->net->ethtool_ops; - ql_net_ethtool_ops.get_drvinfo = ql_net_get_drvinfo; - dev->net->ethtool_ops = &ql_net_ethtool_ops; - -#if 1 //Added by Fibocom - if (dev->driver_info->flags & FLAG_NOARP) { - int ret; - char buf[32] = "Module"; - - ret = usb_string(dev->udev, dev->udev->descriptor.iProduct, buf, sizeof(buf)); - if (ret > 0) { - buf[ret] = '\0'; - } - - dev_err(&intf->dev, "Fibocom %s work on RawIP mode\n", buf); - dev->net->flags |= IFF_NOARP; - dev->net->flags &= ~(IFF_BROADCAST | IFF_MULTICAST); - - usb_control_msg( - interface_to_usbdev(intf), - usb_sndctrlpipe(interface_to_usbdev(intf), 0), - 0x22, //USB_CDC_REQ_SET_CONTROL_LINE_STATE - 0x21, //USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE - 1, //active CDC DTR - intf->cur_altsetting->desc.bInterfaceNumber, - NULL, 0, 100); - } - - dev->rx_urb_size = ETH_DATA_LEN + ETH_HLEN + 6; - -#if defined(FIBOCOM_WWAN_QMAP) - if (qmap_mode > FIBOCOM_WWAN_QMAP) - qmap_mode = FIBOCOM_WWAN_QMAP; - - if (!status) - { - sQmiWwanQmap *pQmapDev = (sQmiWwanQmap *)kzalloc(sizeof(sQmiWwanQmap), GFP_KERNEL); - - if (pQmapDev == NULL) - return -ENODEV; - -#ifdef FIBOCOM_BRIDGE_MODE - pQmapDev->bridge_mode = bridge_mode; -#endif - pQmapDev->mpNetDev = dev; - pQmapDev->link_state = 1; - - dev->net->features |= (NETIF_F_VLAN_CHALLENGED); - - skb_queue_head_init(&pQmapDev->skb_chain); - - if (dev->driver_info->flags & FLAG_NOARP) - { - int idProduct = le16_to_cpu(dev->udev->descriptor.idProduct); - int lte_a = (idProduct == 0x0104 || idProduct == 0x0109 || idProduct == 0x0113 || idProduct == 0x1000 || idProduct == 0x1001); - - pQmapDev->qmap_mode = qmap_mode; - if (lte_a || dev->udev->speed >= USB_SPEED_SUPER) { - if (pQmapDev->qmap_mode == 0) { - pQmapDev->qmap_mode = 1; - if(qmap_mode == 0) - qmap_mode = 1; - } - } - - if (pQmapDev->qmap_mode) { - pQmapDev->qmap_version = 5; - pQmapDev->qmap_size = (dev->udev->speed >= USB_SPEED_SUPER) ? 16*1024 : 4*1024; -/* - switch (idProduct) { - case 0x0104: - pQmapDev->qmap_version = 9; - pQmapDev->qmap_size = 31*1024; - break; - default: - break; - } -*/ - dev->rx_urb_size = pQmapDev->qmap_size; - //for these modules, if send pakcet before qmi_start_network, or cause host PC crash, or cause modules crash - if (lte_a || dev->udev->speed >= USB_SPEED_SUPER) - pQmapDev->link_state = 0; - } - -#if defined(FIBOCOM_UL_DATA_AGG) - if (pQmapDev->qmap_mode) { - struct tx_agg_ctx *ctx = &pQmapDev->tx_ctx; - ctx->ul_data_aggregation_max_datagrams = 1; - ctx->ul_data_aggregation_max_size = 1500; - } -#endif - - if (pQmapDev->qmap_mode == 0) { - pQmapDev->driver_info = *dev->driver_info; - pQmapDev->driver_info.flags &= ~(FLAG_MULTI_PACKET); //see usbnet.c rx_process() - dev->driver_info = &pQmapDev->driver_info; - } - } - - info->unused = (unsigned long)pQmapDev; - dev->net->sysfs_groups[0] = &qmi_wwan_sysfs_attr_group; - - dev_info(&intf->dev, "rx_urb_size = %zd\n", dev->rx_urb_size); - } -#endif -#endif - - return status; -} - -static void qmi_wwan_unbind(struct usbnet *dev, struct usb_interface *intf) -{ - struct qmi_wwan_state *info = (void *)&dev->data; - struct usb_driver *driver = driver_of(intf); - struct usb_interface *other; - - if (dev->udev && dev->udev->state == USB_STATE_CONFIGURED) { - usb_control_msg( - interface_to_usbdev(intf), - usb_sndctrlpipe(interface_to_usbdev(intf), 0), - 0x22, //USB_CDC_REQ_SET_CONTROL_LINE_STATE - 0x21, //USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE - 0, //deactive CDC DTR - intf->cur_altsetting->desc.bInterfaceNumber, - NULL, 0, 100); - } - - if (info->subdriver && info->subdriver->disconnect) - info->subdriver->disconnect(info->control); - - /* allow user to unbind using either control or data */ - if (intf == info->control) - other = info->data; - else - other = info->control; - - /* only if not shared */ - if (other && intf != other) { - usb_set_intfdata(other, NULL); - usb_driver_release_interface(driver, other); - } - - info->subdriver = NULL; - info->data = NULL; - info->control = NULL; -} - -/* suspend/resume wrappers calling both usbnet and the cdc-wdm - * subdriver if present. - * - * NOTE: cdc-wdm also supports pre/post_reset, but we cannot provide - * wrappers for those without adding usbnet reset support first. - */ -static int qmi_wwan_suspend(struct usb_interface *intf, pm_message_t message) -{ - struct usbnet *dev = usb_get_intfdata(intf); - struct qmi_wwan_state *info = (void *)&dev->data; - int ret; - - /* Both usbnet_suspend() and subdriver->suspend() MUST return 0 - * in system sleep context, otherwise, the resume callback has - * to recover device from previous suspend failure. - */ - ret = usbnet_suspend(intf, message); - if (ret < 0) - goto err; - - if (intf == info->control && info->subdriver && - info->subdriver->suspend) - ret = info->subdriver->suspend(intf, message); - if (ret < 0) - usbnet_resume(intf); -err: - return ret; -} - -static int qmi_wwan_resume(struct usb_interface *intf) -{ - struct usbnet *dev = usb_get_intfdata(intf); - struct qmi_wwan_state *info = (void *)&dev->data; - int ret = 0; - bool callsub = (intf == info->control && info->subdriver && - info->subdriver->resume); - - if (callsub) - ret = info->subdriver->resume(intf); - if (ret < 0) - goto err; - ret = usbnet_resume(intf); - if (ret < 0 && callsub) - info->subdriver->suspend(intf, PMSG_SUSPEND); -err: - return ret; -} - -static int qmi_wwan_reset_resume(struct usb_interface *intf) -{ - dev_info(&intf->dev, "device do not support reset_resume\n"); - intf->needs_binding = 1; - return -EOPNOTSUPP; -} - -static int rmnet_usb_bind(struct usbnet *dev, struct usb_interface *intf) -{ - int status = qmi_wwan_bind(dev, intf); - dev_err(&intf->dev, "rmnet_usb_bind\n"); - - if (!status) { - struct qmi_wwan_state *info = (void *)&dev->data; - sQmiWwanQmap *pQmapDev = (sQmiWwanQmap *)info->unused; - - if (pQmapDev && pQmapDev->qmap_mode) { - struct net_device *rmmet_usb = dev->net; - - pQmapDev->use_rmnet_usb = 1; - pQmapDev->rmnet_info.size = sizeof(RMNET_INFO); - pQmapDev->rmnet_info.rx_urb_size = pQmapDev->qmap_size; - pQmapDev->rmnet_info.ep_type = 2; //DATA_EP_TYPE_HSUSB - pQmapDev->rmnet_info.iface_id = 4; - pQmapDev->rmnet_info.qmap_mode = pQmapDev->qmap_mode; - pQmapDev->rmnet_info.qmap_version = pQmapDev->qmap_version; - pQmapDev->rmnet_info.dl_minimum_padding = 0; - - strcpy(rmmet_usb->name, "rmnet_usb%d"); - -#if 0 - rmmet_usb->header_ops = NULL; /* No header */ - rmmet_usb->type = ARPHRD_RAWIP; - rmmet_usb->hard_header_len = 0; - rmmet_usb->addr_len = 0; -#endif - rmmet_usb->flags &= ~(IFF_BROADCAST | IFF_MULTICAST); - rmmet_usb->flags |= (IFF_NOARP); - } - } - - return status; -} - -static struct sk_buff *rmnet_usb_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) -{ - //printk("%s skb=%p, len=%d, protocol=%x, hdr_len=%d\n", __func__, skb, skb->len, skb->protocol, skb->hdr_len); - if (skb->protocol != htons(ETH_P_MAP)) { - dev_kfree_skb_any(skb); - return NULL; - } - - return skb; -} - -static int rmnet_usb_rx_fixup(struct usbnet *dev, struct sk_buff *skb) -{ - struct net_device *net = dev->net; - - //printk("%s skb=%p, len=%d, protocol=%x, hdr_len=%d\n", __func__, skb, skb->len, skb->protocol, skb->hdr_len); - if (net->type == ARPHRD_ETHER && skb_headroom(skb) >= ETH_HLEN) { - //usbnet.c rx_process() usbnet_skb_return() eth_type_trans() - skb_push(skb, ETH_HLEN); - skb_reset_mac_header(skb); - memcpy(eth_hdr(skb)->h_source, default_modem_addr, ETH_ALEN); - memcpy(eth_hdr(skb)->h_dest, net->dev_addr, ETH_ALEN); - eth_hdr(skb)->h_proto = htons(ETH_P_MAP); - - return 1; - } - - return 0; -} - -static void _rmnet_usb_rx_handler(struct usbnet *dev, struct sk_buff *skb_in) -{ - struct qmi_wwan_state *info = (void *)&dev->data; - sQmiWwanQmap *pQmapDev = (sQmiWwanQmap *)info->unused; - struct sk_buff *qmap_skb; - struct sk_buff_head skb_chain; - uint dl_minimum_padding = 0; - - if (pQmapDev->qmap_version == 9) - dl_minimum_padding = pQmapDev->tx_ctx.dl_minimum_padding; - - __skb_queue_head_init(&skb_chain); - - while (skb_in->len > sizeof(struct qmap_hdr)) { - struct rmnet_map_header *map_header = (struct rmnet_map_header *)skb_in->data; - struct rmnet_map_v5_csum_header *ul_header = NULL; - size_t hdr_size = sizeof(struct rmnet_map_header); - struct net_device *qmap_net; - int pkt_len = ntohs(map_header->pkt_len); - int skb_len; - __be16 protocol; - int mux_id; - - if (map_header->next_hdr) { - ul_header = (struct rmnet_map_v5_csum_header *)(map_header + 1); - hdr_size += sizeof(struct rmnet_map_v5_csum_header); - } - - skb_len = pkt_len - (map_header->pad_len&0x3F); - skb_len -= dl_minimum_padding; - if (skb_len > 1500) { - dev_info(&dev->net->dev, "drop skb_len=%x larger than 1500\n", skb_len); - goto error_pkt; - } - - if (skb_in->len < (pkt_len + hdr_size)) { - dev_info(&dev->net->dev, "drop qmap unknow pkt, len=%d, pkt_len=%d\n", skb_in->len, pkt_len); - goto error_pkt; - } - - if (map_header->cd_bit) { - dev_info(&dev->net->dev, "skip qmap command packet\n"); - goto skip_pkt; - } - - switch (skb_in->data[hdr_size] & 0xf0) { - case 0x40: - protocol = htons(ETH_P_IP); - break; - case 0x60: - protocol = htons(ETH_P_IPV6); - break; - default: - dev_info(&dev->net->dev, "unknow skb->protocol %02x\n", skb_in->data[hdr_size]); - goto error_pkt; - } - - mux_id = map_header->mux_id - FIBOCOM_QMAP_MUX_ID; - if (mux_id >= pQmapDev->qmap_mode) { - dev_info(&dev->net->dev, "drop qmap unknow mux_id %x\n", map_header->mux_id); - goto error_pkt; - } - - qmap_net = pQmapDev->mpQmapNetDev[mux_id]; - - if (qmap_net == NULL) { - dev_info(&dev->net->dev, "drop qmap unknow mux_id %x\n", map_header->mux_id); - goto skip_pkt; - } - - qmap_skb = netdev_alloc_skb(qmap_net, skb_len); - if (qmap_skb) { - skb_put(qmap_skb, skb_len); - memcpy(qmap_skb->data, skb_in->data + hdr_size, skb_len); - } - - if (qmap_skb == NULL) { - dev_info(&dev->net->dev, "fail to alloc skb, pkt_len = %d\n", skb_len); - goto error_pkt; - } - - skb_reset_transport_header(qmap_skb); - skb_reset_network_header(qmap_skb); - qmap_skb->pkt_type = PACKET_HOST; - skb_set_mac_header(qmap_skb, 0); - qmap_skb->protocol = protocol; - - if (ul_header && ul_header->header_type == RMNET_MAP_HEADER_TYPE_CSUM_OFFLOAD - && ul_header->csum_valid_required) { -#if 0 //TODO - qmap_skb->ip_summed = CHECKSUM_UNNECESSARY; -#endif - } - - if (qmap_skb->dev->type == ARPHRD_ETHER) { - skb_push(qmap_skb, ETH_HLEN); - skb_reset_mac_header(qmap_skb); - memcpy(eth_hdr(qmap_skb)->h_source, default_modem_addr, ETH_ALEN); - memcpy(eth_hdr(qmap_skb)->h_dest, qmap_net->dev_addr, ETH_ALEN); - eth_hdr(qmap_skb)->h_proto = protocol; -#ifdef FIBOCOM_BRIDGE_MODE - bridge_mode_rx_fixup(pQmapDev, qmap_net, qmap_skb); -#endif - __skb_pull(qmap_skb, ETH_HLEN); - } - - rmnet_vnd_update_rx_stats(qmap_net, 1, skb_len); - __skb_queue_tail(&skb_chain, qmap_skb); - -skip_pkt: - skb_pull(skb_in, pkt_len + hdr_size); - } - -error_pkt: - while ((qmap_skb = __skb_dequeue (&skb_chain))) { - netif_receive_skb(qmap_skb); - } -} - -static rx_handler_result_t rmnet_usb_rx_handler(struct sk_buff **pskb) -{ - struct sk_buff *skb = *pskb; - struct usbnet *dev; - - if (!skb) - goto done; - - //printk("%s skb=%p, protocol=%x, len=%d\n", __func__, skb, skb->protocol, skb->len); - - if (skb->pkt_type == PACKET_LOOPBACK) - return RX_HANDLER_PASS; - - if (skb->protocol != htons(ETH_P_MAP)) { - WARN_ON(1); - return RX_HANDLER_PASS; - } - /* when open hyfi function, run cm will make system crash */ - //dev = rcu_dereference(skb->dev->rx_handler_data); - dev = netdev_priv(skb->dev); - - if (dev == NULL) { - WARN_ON(1); - return RX_HANDLER_PASS; - } - - _rmnet_usb_rx_handler(dev, skb); - consume_skb(skb); - -done: - return RX_HANDLER_CONSUMED; -} - -static const struct driver_info qmi_wwan_info = { - .description = "WWAN/QMI device", - .flags = FLAG_WWAN, - .bind = qmi_wwan_bind, - .unbind = qmi_wwan_unbind, - .manage_power = qmi_wwan_manage_power, - .rx_fixup = qmi_wwan_rx_fixup, -}; - -static const struct driver_info qmi_wwan_raw_ip_info = { - .description = "WWAN/QMI device", - .flags = FLAG_WWAN | FLAG_RX_ASSEMBLE | FLAG_NOARP | FLAG_SEND_ZLP | FLAG_MULTI_PACKET, - .bind = qmi_wwan_bind, - .unbind = qmi_wwan_unbind, - .manage_power = qmi_wwan_manage_power, -#if defined(FIBOCOM_WWAN_QMAP) - .tx_fixup = qmap_qmi_wwan_tx_fixup, - .rx_fixup = qmap_qmi_wwan_rx_fixup, -#else - .tx_fixup = qmi_wwan_tx_fixup, - .rx_fixup = qmi_wwan_rx_fixup, -#endif -}; - -static const struct driver_info rmnet_usb_info = { - .description = "RMNET/USB device", - .flags = FLAG_NOARP | FLAG_SEND_ZLP, - .bind = rmnet_usb_bind, - .unbind = qmi_wwan_unbind, - .manage_power = qmi_wwan_manage_power, - .tx_fixup = rmnet_usb_tx_fixup, - .rx_fixup = rmnet_usb_rx_fixup, -}; - -/* map QMI/wwan function by a fixed interface number */ -#define QMI_FIXED_INTF(vend, prod, num) \ - USB_DEVICE_INTERFACE_NUMBER(vend, prod, num), \ - .driver_info = (unsigned long)&qmi_wwan_info - -#define QMI_FIXED_RAWIP_INTF(vend, prod, num) \ - USB_DEVICE_INTERFACE_NUMBER(vend, prod, num), \ - .driver_info = (unsigned long)&qmi_wwan_raw_ip_info - -#define RMNET_USB_INTF(vend, prod, num) \ - USB_DEVICE_INTERFACE_NUMBER(vend, prod, num), \ - .driver_info = (unsigned long) &rmnet_usb_info - -static const struct usb_device_id products[] = { -#if 1 //Added by Fibocom - { QMI_FIXED_RAWIP_INTF(0x2cb7, 0x0104, 4) }, /* Fibocom FG150/FM150/NL952/FG101 */ - { QMI_FIXED_RAWIP_INTF(0x2cb7, 0x0109, 2) }, /* Fibocom FG150/FM150 */ - { QMI_FIXED_RAWIP_INTF(0x2cb7, 0x0113, 0) }, /* Fibocom FG101 */ - { QMI_FIXED_RAWIP_INTF(0x1508, 0x1000, 2) }, /* Fibocom NL668 */ - { QMI_FIXED_RAWIP_INTF(0x1508, 0x1001, 4) }, /* Fibocom NL668 */ - { QMI_FIXED_RAWIP_INTF(0x05c6, 0x9025, 4) }, /* Fibocom NL668 */ -#endif - { } /* END */ -}; -MODULE_DEVICE_TABLE(usb, products); - -static int qmi_wwan_probe(struct usb_interface *intf, - const struct usb_device_id *prod) -{ - struct usb_device_id *id = (struct usb_device_id *)prod; - - /* Workaround to enable dynamic IDs. This disables usbnet - * blacklisting functionality. Which, if required, can be - * reimplemented here by using a magic "blacklist" value - * instead of 0 in the static device id table - */ - if (!id->driver_info) { - dev_dbg(&intf->dev, "setting defaults for dynamic device id\n"); - id->driver_info = (unsigned long)&qmi_wwan_info; - } - - if (intf->cur_altsetting->desc.bInterfaceClass != 0xff) { - dev_info(&intf->dev, "Fibocom module not qmi_wwan mode!\n"); - return -ENODEV; - } - - return usbnet_probe(intf, id); -} - -#if defined(FIBOCOM_WWAN_QMAP) -static int qmap_qmi_wwan_probe(struct usb_interface *intf, - const struct usb_device_id *prod) -{ - int status = qmi_wwan_probe(intf, prod); - - if (!status) { - struct usbnet *dev = usb_get_intfdata(intf); - struct qmi_wwan_state *info = (void *)&dev->data; - sQmiWwanQmap *pQmapDev = (sQmiWwanQmap *)info->unused; - unsigned i; - - if (!pQmapDev) - return status; - - tasklet_init(&pQmapDev->txq, rmnet_usb_tx_wake_queue, (unsigned long)pQmapDev); - - if (pQmapDev->qmap_mode == 1) { - pQmapDev->mpQmapNetDev[0] = dev->net; - if (pQmapDev->use_rmnet_usb) { - pQmapDev->mpQmapNetDev[0] = NULL; - qmap_register_device(pQmapDev, 0); - } - } - else if (pQmapDev->qmap_mode > 1) { - for (i = 0; i < pQmapDev->qmap_mode; i++) { - qmap_register_device(pQmapDev, i); - } - } - - if (pQmapDev->use_rmnet_usb) { - rtnl_lock(); - /* when open hyfi function, run cm will make system crash */ - //netdev_rx_handler_register(dev->net, rmnet_usb_rx_handler, dev); - netdev_rx_handler_register(dev->net, rmnet_usb_rx_handler, NULL); - rtnl_unlock(); - } - - if (pQmapDev->link_state == 0) { - netif_carrier_off(dev->net); - } - } - - return status; -} - -static void qmap_qmi_wwan_disconnect(struct usb_interface *intf) -{ - struct usbnet *dev = usb_get_intfdata(intf); - struct qmi_wwan_state *info; - sQmiWwanQmap *pQmapDev; - uint i; - - if (!dev) - return; - - info = (void *)&dev->data; - pQmapDev = (sQmiWwanQmap *)info->unused; - - if (!pQmapDev) { - return usbnet_disconnect(intf); - } - - pQmapDev->link_state = 0; - - if (pQmapDev->qmap_mode > 1) { - for (i = 0; i < pQmapDev->qmap_mode; i++) { - qmap_unregister_device(pQmapDev, i); - } - } - - if (pQmapDev->use_rmnet_usb) { - qmap_unregister_device(pQmapDev, 0); - rtnl_lock(); - netdev_rx_handler_unregister(dev->net); - rtnl_unlock(); - } - - tasklet_kill(&pQmapDev->txq); - - usbnet_disconnect(intf); - info->unused = 0; - kfree(pQmapDev); -} -#endif - -static struct usb_driver qmi_wwan_driver = { - .name = "qmi_wwan_f", - .id_table = products, - .probe = qmi_wwan_probe, -#if defined(FIBOCOM_WWAN_QMAP) - .probe = qmap_qmi_wwan_probe, - .disconnect = qmap_qmi_wwan_disconnect, -#else - .probe = qmi_wwan_probe, - .disconnect = usbnet_disconnect, -#endif - .suspend = qmi_wwan_suspend, - .resume = qmi_wwan_resume, - .reset_resume = qmi_wwan_reset_resume, - .supports_autosuspend = 1, - .disable_hub_initiated_lpm = 1, -}; - -#ifdef CONFIG_QCA_NSS_DRV -/* - EXTRA_CFLAGS="-I$(STAGING_DIR)/usr/include/qca-nss-drv $(EXTRA_CFLAGS)" - qsdk/qca/src/data-kernel/drivers/rmnet-nss/rmnet_nss.c -*/ -#include "rmnet_nss.c" -#endif - -static int __init qmi_wwan_driver_init(void) -{ - RCU_INIT_POINTER(rmnet_nss_callbacks, NULL); -#ifdef CONFIG_QCA_NSS_DRV - if (qca_nss_enabled) - rmnet_nss_init(); -#endif - return usb_register(&qmi_wwan_driver); -} -module_init(qmi_wwan_driver_init); -static void __exit qmi_wwan_driver_exit(void) -{ -#ifdef CONFIG_QCA_NSS_DRV - if (qca_nss_enabled) - rmnet_nss_exit(); -#endif - usb_deregister(&qmi_wwan_driver); -} -module_exit(qmi_wwan_driver_exit); - -MODULE_AUTHOR("Bjørn Mork "); -MODULE_DESCRIPTION("Qualcomm MSM Interface (QMI) WWAN driver"); -MODULE_LICENSE("GPL"); -MODULE_VERSION(FIBOCOM_WWAN_VERSION); diff --git a/luci-app-cpe/Makefile b/luci-app-cpe/Makefile deleted file mode 100644 index d259239..0000000 --- a/luci-app-cpe/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -#将openwrt顶层目录下的rules.mk文件中的内容导入进来 -include $(TOPDIR)/rules.mk -#软件包名 -PKG_NAME:=luci-app-cpe -#软件包版本 -PKG_VERSION:=5.0.1 -#真正编译当前软件包的目录 -PKG_BUILD_DIR:= $(BUILD_DIR)/$(PKG_NAME) - - - #将$(TOPDIR)/include目录下的package.mk文件中的内容导入进来 -include $(INCLUDE_DIR)/package.mk - -define Package/luci-app-cpe - PKGARCH:=all - SECTION:=wrtnode - CATEGORY:=Daocaoren - SUBMENU :=CPE - TITLE:=luci-app-cpe - DEPENDS:=+sendat + luci-compat +kmod-usb-net +kmod-usb-net-cdc-ether +kmod-usb-acm \ - +kmod-usb-net-qmi-wwan +kmod-usb-net-rndis +kmod-usb-serial-qualcomm \ - +kmod-usb-net-sierrawireless +kmod-usb-ohci +kmod-usb-serial \ - +kmod-usb-serial-option +kmod-usb-wdm \ - +kmod-usb2 +kmod-usb3 \ - +quectel-CM-5G +kmod-usb-net-cdc-mbim +usbutils -endef - -PKG_LICENSE:=GPLv3 -PKG_LINCESE_FILES:=LICENSE -PKF_MAINTAINER:=daocaoren <168620188@qq.com> - -include $(TOPDIR)/feeds/luci/luci.mk -# call BuildPackage - OpenWrt buildroot signature - diff --git a/luci-app-cpe/luasrc/controller/admin/cpe.lua b/luci-app-cpe/luasrc/controller/admin/cpe.lua deleted file mode 100644 index 49dad2c..0000000 --- a/luci-app-cpe/luasrc/controller/admin/cpe.lua +++ /dev/null @@ -1,189 +0,0 @@ -module("luci.controller.admin.cpe", package.seeall) - -I18N = require "luci.i18n" -translate = I18N.translate - -function index() - entry({"admin", "modem"}, firstchild(), translate("移动数据"), 25).dependent=false - entry({"admin", "modem", "nets"}, template("cpe/net_status"), translate("信号状态"), 0) - entry({"admin", "modem", "get_csq"}, call("action_get_csq")) - entry({"admin", "modem", "send_atcmd"}, call("action_send_atcmd")) - - -- entry({"admin", "modem", "sms"}, template("cpe/sms"), translate("短信信息"), 1) - -- entry({"admin", "modem", "band"}, template("cpe/band"), translate("锁频段/锁PCI"), 1) - entry({"admin", "modem", "at"}, template("cpe/at"), translate("AT工具"), 98) - - if not nixio.fs.access("/etc/config/modem") then - return - end - entry({"admin", "modem", "modem"}, cbi("cpe/modem"), _("模块设置"), 99) - -end - -function action_send_atcmd() - local rv ={} - local file - local p = luci.http.formvalue("p") - local set = luci.http.formvalue("set") - fixed = string.gsub(set, "\"", "~") - port= string.gsub(p, "\"", "~") - rv["at"] = fixed - rv["port"] = port - - os.execute("/usr/share/cpe/atcmd.sh \'" .. port .. "\' \'" .. fixed .. "\'") - result = "/tmp/result.at" - file = io.open(result, "r") - if file ~= nil then - rv["result"] = file:read("*all") - file:close() - else - rv["result"] = " " - end - os.execute("/usr/share/cpe/delatcmd.sh") - luci.http.prepare_content("application/json") - luci.http.write_json(rv) - -end - -function action_get_csq() - local file - stat = "/tmp/cpe_cell.file" - file = io.open(stat, "r") - local rv ={} - - -- echo 'RM520N-GL' - -- echo 'conntype' - -- echo '1e0e:9001' - -- echo $COPS #运营商 - -- echo '' #端口 - -- echo '' #温度 - -- echo '' #协议 - rv["modem"] = file:read("*line") - rv["conntype"] = file:read("*line") - rv["modid"] = file:read("*line") - rv["cops"] = file:read("*line") - rv["port"] = file:read("*line") - rv["tempur"] = file:read("*line") - rv["proto"] = file:read("*line") - file:read("*line") - - - -- echo $IMEI #imei - -- echo $IMSI #imsi - -- echo $ICCID #iccid - -- echo $phone #phone - rv["imei"] = file:read("*line") - rv["imsi"] = file:read("*line") - rv["iccid"] =file:read("*line") - rv["phone"] = file:read("*line") - file:read("*line") - - - -- echo $MODE - -- echo $CSQ - -- echo $CSQ_PER - -- echo $CSQ_RSSI - -- echo '' #参考信号接收质量 RSRQ ecio - -- echo '' #参考信号接收质量 RSRQ ecio1 - -- echo '' #参考信号接收功率 RSRP rscp - -- echo '' #参考信号接收功率 RSRP rscp1 - -- echo '' #信噪比 SINR rv["sinr"] - -- echo '' #连接状态监控 rv["netmode"] - rv["mode"] = file:read("*line") - rv["csq"] = file:read("*line") - rv["per"] = file:read("*line") - rv["rssi"] = file:read("*line") - rv["ecio"] = file:read("*line") - rv["ecio1"] = file:read("*line") - rv["rscp"] = file:read("*line") - rv["rscp1"] = file:read("*line") - rv["sinr"] = file:read("*line") - rv["netmode"] = file:read("*line") - file:read("*line") - - rssi = rv["rssi"] - ecio = rv["ecio"] - rscp = rv["rscp"] - ecio1 = rv["ecio1"] - rscp1 = rv["rscp1"] - if ecio == nil then - ecio = "-" - end - if ecio1 == nil then - ecio1 = "-" - end - if rscp == nil then - rscp = "-" - end - if rscp1 == nil then - rscp1 = "-" - end - - if ecio ~= "-" then - rv["ecio"] = ecio .. " dB" - end - if rscp ~= "-" then - rv["rscp"] = rscp .. " dBm" - end - if ecio1 ~= " " then - rv["ecio1"] = " (" .. ecio1 .. " dB)" - end - if rscp1 ~= " " then - rv["rscp1"] = " (" .. rscp1 .. " dBm)" - end - - rv["mcc"] = file:read("*line") - rv["mnc"] = file:read("*line") - rv["rnc"] = file:read("*line") - rv["rncn"] = file:read("*line") - rv["lac"] = file:read("*line") - rv["lacn"] = file:read("*line") - rv["cid"] = file:read("*line") - rv["cidn"] = file:read("*line") - rv["lband"] = file:read("*line") - rv["channel"] = file:read("*line") - rv["pci"] = file:read("*line") - - rv["date"] = file:read("*line") - - -- rv["phonen"] = file:read("*line") - --rv["host"] = "0" - - -- rv["simerr"] = "0" - -- - -- - -- - -- - -- - -- - -- - -- - -- - -- - - - -- rv["down"] = file:read("*line") - -- rv["up"] = file:read("*line") - -- - -- - - -- - -- rv["cell"] = file:read("*line") - -- rv["modtype"] = file:read("*line") - -- - -- - -- - -- - -- - -- - - - -- rv["lat"] = "-" - -- rv["long"] = "-" - - - - rv["crate"] = translate("快速(每10秒更新一次)") - luci.http.prepare_content("application/json") - luci.http.write_json(rv) -end \ No newline at end of file diff --git a/luci-app-cpe/luasrc/model/cbi/cpe/modem.lua b/luci-app-cpe/luasrc/model/cbi/cpe/modem.lua deleted file mode 100644 index 376c068..0000000 --- a/luci-app-cpe/luasrc/model/cbi/cpe/modem.lua +++ /dev/null @@ -1,144 +0,0 @@ -local m, section, m2, s2 - -m = Map("modem", translate("Mobile Network")) -m.description = translate("Modem Server For OpenWrt") - - --------------------------------Fibocom Wireless Inc. FM650 Module---------------------------------- -if (string.gsub(luci.sys.exec('lsusb |grep "ID 2cb7:0a05 " | wc -l'),"%s+","")=="1") then - section = m:section(TypedSection, "ndis", translate("FMFM650-CN Settings"), translate("[1]Automatic start upon startup: Check
[2] FMFMFM650-CN module default ECM (36) mode. If not, please modify it, otherwise dialing cannot proceed normally
")) - section.anonymous = true - section.addremove = false - enable = section:option(Flag, "enabled", translate("Enable")) - enable.rmempty = false -else - section = m:section(TypedSection, "ndis", translate("SIM Settings"), translate("Automatic operation upon startup \r\n ooo")) - section.anonymous = true - section.addremove = false - section:tab("general", translate("General Setup")) - section:tab("advanced", translate("Advanced Settings")) - - - enable = section:taboption("general", Flag, "enabled", translate("Enable")) - enable.rmempty = false - - device = section:taboption("general",Value, "device", translate("Modem device")) - device.rmempty = false - local device_suggestions = nixio.fs.glob("/dev/cdc-wdm*") - if device_suggestions then - local node - for node in device_suggestions do - device:value(node) - end - end - apn = section:taboption("general", Value, "apn", translate("APN")) - username = section:taboption("general", Value, "username", translate("PAP/CHAP Username")) - password = section:taboption("general", Value, "password", translate("PAP/CHAP Password")) - password.password = true - pincode = section:taboption("general", Value, "pincode", translate("PIN Code")) - auth = section:taboption("general", Value, "auth", translate("Authentication Type")) - auth.rmempty = true - auth:value("", translate("-- Please choose --")) - auth:value("both", "PAP/CHAP (both)") - auth:value("pap", "PAP") - auth:value("chap", "CHAP") - auth:value("none", "NONE") - tool = section:taboption("general", Value, "tool", translate("Tools")) - tool:value("quectel-CM", "quectel-CM") - tool.rmempty = true - PdpType= section:taboption("general", Value, "pdptype", translate("PdpType")) - PdpType:value("IPV4", "IPV4") - PdpType:value("IPV6", "IPV6") - PdpType:value("IPV4V6", "IPV4V6") - PdpType.rmempty = true - - - ---------------------------advanced------------------------------ - bandlist = section:taboption("advanced", ListValue, "bandlist", translate("Lock Band List")) - -- if (string.gsub(luci.sys.exec('uci get system.@system[0].modem |grep lte |wc -l'),"%s+","")=="1") then - -- bandlist.default = "0" - -- bandlist:value("1", "LTE BAND1") - -- bandlist:value("2", "LTE BAND2") - -- bandlist:value("3", "LTE BAND3") - -- bandlist:value("4", "LTE BAND4") - -- bandlist:value("5", "LTE BAND5") - -- bandlist:value("7", "LTE BAND7") - -- bandlist:value("8", "LTE BAND8") - -- bandlist:value("20", "LTE BAND20") - -- bandlist:value("38", "LTE BAND38") - -- bandlist:value("40", "LTE BAND40") - -- bandlist:value("41", "LTE BAND41") - -- bandlist:value("28", "LTE BAND28") - -- bandlist:value("A", "AUTO") - -- end - bandlist:value("0", translate("Disable")) - - servertype = section:taboption("advanced", ListValue, "servertype", translate("Server Type")) - servertype.default = "0" - - --if (string.gsub(luci.sys.exec('uci get system.@system[0].modem |grep nr5g |wc -l'),"%s+","")=="1") then - servertype:value("1", "5G Only") - servertype:value("5", "4G/5G Only") - --end - servertype:value("2", "4G Only") - servertype:value("3", "3G Only") - servertype:value("4", "2G Only") - servertype:value("0", "AUTO") - - - -- s1 = m:section(TypedSection, "ndis", translate("AT Port Settings"),translate("Set tyyUSB port")) - -- s1.anonymous = true - -- s1.addremove = false - -- tyyusb= s1:option(Value, "tyyusb", translate("tyyUSB port")) - -- tyyusb.default = "2" - -- tyyusb:value("0", "0") - -- tyyusb:value("1", "1") - -- tyyusb:value("2", "2") - -- tyyusb:value("3", "3") - -- tyyusb:value("4", "4") - -- tyyusb.rmempty=false -end - - - - - - - - - -s2 = m:section(TypedSection, "ndis", translate("Network Diagnostics"),translate("Network exception handling: \ -check the network connection in a loop for 5 seconds. If the Ping IP address is not successful, After the network \ -exceeds the abnormal number, restart and search the registered network again.")) -s2.anonymous = true -s2.addremove = false - -en = s2:option(Flag, "en", translate("Enable")) -en.rmempty = false - - - -ipaddress= s2:option(Value, "ipaddress", translate("Ping IP address")) -ipaddress.default = "114.114.114.114" -ipaddress.rmempty=false - -an = s2:option(Value, "an", translate("Abnormal number")) -an.default = "15" -an:value("3", "3") -an:value("5", "5") -an:value("10", "10") -an:value("15", "15") -an:value("20", "20") -an:value("25", "25") -an:value("30", "30") -an.rmempty=false - - - -local apply = luci.http.formvalue("cbi.apply") -if apply then - -- io.popen("/etc/init.d/modeminit restart") - io.popen("/etc/init.d/modem restart") -end - -return m,m2 diff --git a/luci-app-cpe/luasrc/view/cpe/at.htm b/luci-app-cpe/luasrc/view/cpe/at.htm deleted file mode 100644 index 1c9a8a7..0000000 --- a/luci-app-cpe/luasrc/view/cpe/at.htm +++ /dev/null @@ -1,152 +0,0 @@ -<%+header%> -<% -local sys = require "luci.sys" -local utl = require "luci.util" -local fs = require "nixio.fs" -local uci = require "luci.model.uci".cursor() -local s = uci:get("custom", "bandlock", "enabled") -local a = uci:get("custom", "atcmd", "enabled") - -local multilock = uci:get("custom", "multiuser", "multi") or "0" -local rootlock = uci:get("custom", "multiuser", "root") or "0" -nomulti=1 -if (multilock == "0") or (multilock == "1" and rootlock == "1") then - nosms = 1 - if a == "1" then - nosms = 0 - end -else - nosms = 1 - nomulti = 0 -end -block = 1 -if s == "1" then - block = 0 -end - -function showicon(lck) -end - --%> - - - - -
-

<%:AT命令工具%>

-
<%:AT命令工具%>
- - - - -
- <%:AT命令终端%> - - - - - - - - - - - -
<%:模块端口 : %>
- -
<%:AT命令 : %>
- - -  
- - - -
- - - - -<%+footer%> diff --git a/luci-app-cpe/luasrc/view/cpe/net_status.htm b/luci-app-cpe/luasrc/view/cpe/net_status.htm deleted file mode 100644 index 96c569e..0000000 --- a/luci-app-cpe/luasrc/view/cpe/net_status.htm +++ /dev/null @@ -1,296 +0,0 @@ -<%+header%> -<% -local fs = require "nixio.fs" -nosms = 1 -if not fs.stat("/etc/nosim") then - nosms = 0 -end -havegps = 0 -if fs.stat("/etc/havegps") then - havegps = 1 -end --%> - - - - - -
-

<%:信号状态/模块信息%>

-
请注意该插件所有功能并无适配所有5G模块,不用妄想冷门模块插上就能用(有能力者自行适配) -
- - - - -
- <%:综合信息%> - - - - - - -
<%:模块 :%>-
<%:制造商 :%>
<%:温度 : %>
<%:更新时间 : %>
-
- -<% if nosms == 0 then %> -<% end %> - -
- <%:通信模块/SIM卡信息%> - - - - - - -
<%:运营商 : %>
<%:IMEI :%>
<%:IMSI : %>
<%:ICCID : %>
<%:SIM卡号码 : %>
-
- - -
- <%:信号状态%> - - - - - - - - - - -
<%:蜂窝网络类型 :%>
<%:CSQ : %>
<%:信号强度 : %>
<%:信号接收强度 RSSI : %>
<%:参考信号接收质量 RSRQ : %>
<%:参考信号接收功率 RSRP : %>
<%:信噪比 SINR : %>
<%:连接状态监控 : %>
-
- -
- <%:基站信息%> - - - - - - - - - - -
<%:MCC / MNC :%>
<%:eNB ID : %>
<%:TAC : %>
<%:Cell ID : %>
<%:频段 Band : %>
<%:频点 Channel : %>
<%:物理小区标识 PCI : %>
<%:最大Qos级别 Maximum Qos : %>
-
- - -<% if havegps == 1 then %> -
- <%:GPS 定位%> - - - - - - - - - - - -
<%:纬度 :%>
     
    <%:经度 :%>
       
      -
      -<% end %> - - -
      -<%+footer%> - diff --git a/luci-app-cpe/po/zh-cn/modem.po b/luci-app-cpe/po/zh-cn/modem.po deleted file mode 100644 index 25681b8..0000000 --- a/luci-app-cpe/po/zh-cn/modem.po +++ /dev/null @@ -1,73 +0,0 @@ -msgid "" -msgstr "" - -msgid "Mobile Network" -msgstr "模块设置" - - -msgid "Automatic operation upon startup ooo" -msgstr "开机自动启动:勾选" - -msgid "Tools" -msgstr "拨号工具" - -msgid "PAP/CHAP Username" -msgstr "PAP/CHAP 用户" - -msgid "PAP/CHAP Password" -msgstr "PAP/CHAP 密码" - - -msgid "Modem Server For OpenWrt" -msgstr "4G/5G模块管理" - - -msgid "SIM Settings" -msgstr "SIM 配置 (联通ANP:3gnet) (电信APN:ctnet) (移动APN:cmnet) (广电APN:cbnet) " - -msgid "PdpType" -msgstr "IP获取方式" - -msgid "AT Port Settings" -msgstr "AT 模块配置" - -msgid "Set tyyUSB port" -msgstr "AT 模块端口配置 (全模块指定端口)" - -msgid "tyyUSB port" -msgstr "ttyUSB 配置ID" - -msgid "Network Diagnostics" -msgstr "网络诊断" - - -msgid "Network Diagnostics" -msgstr "网络诊断" - - -msgid "Network exception handling: check the network connection in a loop for 5 seconds. If the Ping IP address is not successful, After the network exceeds the abnormal number, restart and search the registered network again." -msgstr "网络异常处理:循环检查网络连接5秒。如果Ping IP地址不成功,则在网络超过异常数量后,重新启动并搜索已注册的网络。" - -msgid "Ping IP address" -msgstr "Ping IP地址" - -msgid "Abnormal number" -msgstr "异常次数" - -msgid "Lock Band List" -msgstr "锁定频段列表" - -msgid "Server Type" -msgstr "服务类型" - -msgid "FMFM650-CN Settings" -msgstr "FMFM650-CN 设置" - -msgid "[1]Automatic start upon startup: Check
      [2] FMFMFM650-CN module default ECM (36) mode. If not, please modify it, otherwise dialing cannot proceed normally
      " -msgstr "【1】 开机自动启动:勾选
      【2】 FMFM650-CN 模块默认 ECM (36)模式如果不是请修改 否则不能正常进行拨号
      " - - - - - - diff --git a/luci-app-cpe/po/zh_Hans b/luci-app-cpe/po/zh_Hans deleted file mode 100644 index 41451e4..0000000 --- a/luci-app-cpe/po/zh_Hans +++ /dev/null @@ -1 +0,0 @@ -zh-cn \ No newline at end of file diff --git a/luci-app-cpe/root/etc/config/modem b/luci-app-cpe/root/etc/config/modem deleted file mode 100644 index 3b57bd5..0000000 --- a/luci-app-cpe/root/etc/config/modem +++ /dev/null @@ -1,12 +0,0 @@ -config ndis - option enabled '0' - option bandlist '0' - option servertype '0' - option ipaddress '114.114.114.114' - option en '0' - option an '5' - option model 'nr5g' - option tyyusb '2' - option tool 'quectel-CM' - option device '/dev/cdc-wdm0' - option pdptype 'IPV4V6' diff --git a/luci-app-cpe/root/etc/init.d/cpeinit b/luci-app-cpe/root/etc/init.d/cpeinit deleted file mode 100644 index c5f2299..0000000 --- a/luci-app-cpe/root/etc/init.d/cpeinit +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh /etc/rc.common - -START=99 - -start() { - /bin/sh /usr/share/cpe/rssi & -} \ No newline at end of file diff --git a/luci-app-cpe/root/etc/init.d/modem b/luci-app-cpe/root/etc/init.d/modem deleted file mode 100644 index dffe31c..0000000 --- a/luci-app-cpe/root/etc/init.d/modem +++ /dev/null @@ -1,103 +0,0 @@ -#!/bin/sh /etc/rc.common -# Copyright (C) 2006-2014 OpenWrt.org - -START=16 -STOP=16 -USE_PROCD=1 -#使用procd启动 - - -# start启动服务 -# stop停止服务 -# restart重新启动服务 -# reload重新加载配置文件(如果服务未实现重新加载,则重新启动) -# enable启用服务自动启动 -# disable禁用服务自动启动 -# enabled检查服务是否在启动时启动 -# 正在运行检查服务是否正在运行 -# status服务状态 -# trace从系统调用跟踪开始 - -runModem() -{ - local enabled - config_get_bool enabled $1 enabled - echo "run runModem" >> /tmp/log4g - if [ "$enabled" = "1" ]; then - - - local user - local password - local apn - local auth - local pincode - local device - local tool - local pdptype - - - config_get user $1 user - config_get password $1 password - config_get apn $1 apn - config_get auth $1 auth - config_get pincode $1 pincode - config_get device $1 device - config_get tool $1 tool - config_get pdptype $1 pdptype - config_get tty $1 tty - config_get atcmd $1 atcmd - - if [ "$pdptype" = "IPV4V6" ]; then - pdptype='-4 -6' - elif [ "$pdptype" = "IPV6" ]; then - pdptype='-6' - else - pdptype='' - fi - - devname="$(basename "$device")" - devpath="$(readlink -f /sys/class/usbmisc/$devname/device/)" - ifname="$( ls "$devpath"/net )" - - - procd_open_instance - #创建一个实例, 在procd看来一个应用程序可以多个实\E4\BE? - #ubus call service list 可以查看实例 - procd_set_param command $tool -i $ifname -s $apn $pdptype - if [ "$password" != "" ];then - procd_append_param command $user $password $auth - fi - if [ "$pincode" != "" ]; then - procd_append_param command -p $pincode - fi - # procd_append_param command -f /tmp/4g.log - procd_set_param respawn - echo "quectel-CM has started." - procd_close_instance - #关闭实例 - fi - - - -} - - - - -service_triggers() -{ - procd_add_reload_trigger "modem" -} - -start_service() { - config_load modem - config_foreach runModem ndis -} - -stop_service() -{ - echo "runModem stop" >> /tmp/log4g - killall quectel-CM - echo "quectel-CM has stoped." -} - diff --git a/luci-app-cpe/root/etc/uci-defaults/luci-modem b/luci-app-cpe/root/etc/uci-defaults/luci-modem deleted file mode 100644 index 3181024..0000000 --- a/luci-app-cpe/root/etc/uci-defaults/luci-modem +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -uci -q batch <<-EOF >/dev/null - delete ucitrack.@modem[-1] - add ucitrack modem - set ucitrack.@modem[-1].init=modem - commit ucitrack -EOF - -rm -f /tmp/luci-indexcache -exit 0 diff --git a/luci-app-cpe/root/usr/bin/bmask128 b/luci-app-cpe/root/usr/bin/bmask128 deleted file mode 100644 index bfd5bde..0000000 --- a/luci-app-cpe/root/usr/bin/bmask128 +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh -# -printf "Band 128-bit bandmask\n" -LBAND=1 -BBAND=1 -while [ $LBAND -le 48 ] -do - printf "%-6s%016X%016X\n" "$LBAND" "0" "$BBAND" - LBAND=$(( $LBAND + 1 )) - BBAND=$(( $BBAND * 2 )) -done -LBAND=65 -BBAND=1 -while [ $LBAND -le 85 ] -do - printf "%-6s%016X%016X\n" "$LBAND" "$BBAND" "0" - LBAND=$(( $LBAND + 1 )) - BBAND=$(( $BBAND * 2 )) -done diff --git a/luci-app-cpe/root/usr/bin/chan2band.sh b/luci-app-cpe/root/usr/bin/chan2band.sh deleted file mode 100644 index 5b5bff0..0000000 --- a/luci-app-cpe/root/usr/bin/chan2band.sh +++ /dev/null @@ -1,317 +0,0 @@ -#!/bin/sh -CHAN=$1 -CHAN=$(echo "$CHAN" | grep -o "[0-9]*") - -decode_lte() { - if [ $CHAN -lt 600 ]; then - BAND="B1" - elif [ $CHAN -lt 1200 ]; then - BAND="B2" - elif [ $CHAN -lt 1950 ]; then - BAND="B3" - elif [ $CHAN -lt 2400 ]; then - BAND="B4" - elif [ $CHAN -lt 2650 ]; then - BAND="B5" - elif [ $CHAN -lt 2750 ]; then - BAND="B6" - elif [ $CHAN -lt 3450 ]; then - BAND="B7" - elif [ $CHAN -lt 3800 ]; then - BAND="B8" - elif [ $CHAN -lt 4150 ]; then - BAND="B9" - elif [ $CHAN -lt 4750 ]; then - BAND="B10" - elif [ $CHAN -lt 4950 ]; then - BAND="B11" - elif [ $CHAN -lt 5010 ]; then - BAND="-" - elif [ $CHAN -lt 5180 ]; then - BAND="B12" - elif [ $CHAN -lt 5280 ]; then - BAND="B13" - elif [ $CHAN -lt 5380 ]; then - BAND="B14" - elif [ $CHAN -lt 5730 ]; then - BAND="-" - elif [ $CHAN -lt 5850 ]; then - BAND="B17" - elif [ $CHAN -lt 6000 ]; then - BAND="B18" - elif [ $CHAN -lt 6150 ]; then - BAND="B19" - elif [ $CHAN -lt 6450 ]; then - BAND="B20" - elif [ $CHAN -lt 6600 ]; then - BAND="B21" - elif [ $CHAN -lt 7400 ]; then - BAND="B22" - elif [ $CHAN -lt 7500 ]; then - BAND="-" - elif [ $CHAN -lt 7700 ]; then - BAND="B23" - elif [ $CHAN -lt 8040 ]; then - BAND="B24" - elif [ $CHAN -lt 8690 ]; then - BAND="B25" - elif [ $CHAN -lt 9040 ]; then - BAND="B26" - elif [ $CHAN -lt 9210 ]; then - BAND="B27" - elif [ $CHAN -lt 9660 ]; then - BAND="B28" - elif [ $CHAN -lt 9770 ]; then - BAND="B29" - elif [ $CHAN -lt 9870 ]; then - BAND="B30" - elif [ $CHAN -lt 9920 ]; then - BAND="B31" - elif [ $CHAN -lt 10400 ]; then - BAND="B32" - elif [ $CHAN -lt 36000 ]; then - BAND="-" - elif [ $CHAN -lt 36200 ]; then - BAND="B33" - elif [ $CHAN -lt 36350 ]; then - BAND="B34" - elif [ $CHAN -lt 36950 ]; then - BAND="B35" - elif [ $CHAN -lt 37550 ]; then - BAND="B36" - elif [ $CHAN -lt 37750 ]; then - BAND="B37" - elif [ $CHAN -lt 38250 ]; then - BAND="B38" - elif [ $CHAN -lt 38650 ]; then - BAND="B39" - elif [ $CHAN -lt 39650 ]; then - BAND="B40" - elif [ $CHAN -lt 41590 ]; then - BAND="B41" - elif [ $CHAN -lt 43590 ]; then - BAND="B42" - elif [ $CHAN -lt 45590 ]; then - BAND="B43" - elif [ $CHAN -lt 46590 ]; then - BAND="B44" - elif [ $CHAN -lt 46790 ]; then - BAND="B45" - elif [ $CHAN -lt 54540 ]; then - BAND="B46" - elif [ $CHAN -lt 55240 ]; then - BAND="B47" - elif [ $CHAN -lt 56740 ]; then - BAND="B48" - elif [ $CHAN -lt 58240 ]; then - BAND="B49" - elif [ $CHAN -lt 59090 ]; then - BAND="B50" - elif [ $CHAN -lt 59140 ]; then - BAND="B51" - elif [ $CHAN -lt 60140 ]; then - BAND="B52" - elif [ $CHAN -lt 60255 ]; then - BAND="B53" - elif [ $CHAN -lt 65536 ]; then - BAND="-" - elif [ $CHAN -lt 66436 ]; then - BAND="B65" - elif [ $CHAN -lt 67336 ]; then - BAND="B66" - elif [ $CHAN -lt 67536 ]; then - BAND="B67" - elif [ $CHAN -lt 67836 ]; then - BAND="B68" - elif [ $CHAN -lt 68336 ]; then - BAND="B69" - elif [ $CHAN -lt 68586 ]; then - BAND="B70" - elif [ $CHAN -lt 68936 ]; then - BAND="B71" - elif [ $CHAN -lt 68986 ]; then - BAND="B72" - elif [ $CHAN -lt 69036 ]; then - BAND="B73" - elif [ $CHAN -lt 69466 ]; then - BAND="B74" - elif [ $CHAN -lt 70316 ]; then - BAND="B75" - elif [ $CHAN -lt 70366 ]; then - BAND="B76" - elif [ $CHAN -lt 70546 ]; then - BAND="B85" - elif [ $CHAN -lt 70596 ]; then - BAND="B87" - elif [ $CHAN -lt 70646 ]; then - BAND="B88" - else - BAND="-" - fi -} - -decode_nr5g() { - if [ $CHAN -lt 123400 ]; then - BAND="-" - elif [ $CHAN -le 130400 ]; then - BAND="n71" - elif [ $CHAN -lt 143400 ]; then - BAND="-" - elif [ $CHAN -lt 145600 ]; then - BAND="n29" - elif [ $CHAN -eq 145600 ]; then - BAND="n29|n85" - elif [ $CHAN -lt 145800 ]; then - BAND="n85" - elif [ $CHAN -eq 145800 ]; then - BAND="n12|n85" - elif [ $CHAN -lt 147600 ]; then - BAND="n12|n85" - elif [ $CHAN -lt 149200 ]; then - BAND="n12|n67|n85" - elif [ $CHAN -eq 149200 ]; then - BAND="n12|n13|n67|n85" - elif [ $CHAN -le 151200 ]; then - BAND="n13|n67" - elif [ $CHAN -lt 151600 ]; then - BAND="n67" - elif [ $CHAN -eq 151600 ]; then - BAND="n14|n28|n67" - elif [ $CHAN -le 153600 ]; then - BAND="n14|n28" - elif [ $CHAN -lt 158200 ]; then - BAND="n28" - elif [ $CHAN -eq 158200 ]; then - BAND="n14|n20|n28" - elif [ $CHAN -le 160600 ]; then - BAND="n20|n28" - elif [ $CHAN -le 164200 ]; then - BAND="n20" - elif [ $CHAN -lt 171800 ]; then - BAND="-" - elif [ $CHAN -lt 172000 ]; then - BAND="n26" - elif [ $CHAN -lt 173800 ]; then - BAND="n18|n26" - elif [ $CHAN -le 175000 ]; then - BAND="n5|n18|n26" - elif [ $CHAN -le 178800 ]; then - BAND="n5|n26" - elif [ $CHAN -lt 185000 ]; then - BAND="-" - elif [ $CHAN -le 192000 ]; then - BAND="n8" - elif [ $CHAN -lt 285400 ]; then - BAND="-" - elif [ $CHAN -lt 286400 ]; then - BAND="n51|n76|n91|n93" - elif [ $CHAN -eq 286400 ]; then - BAND="n50|n51|n75|n76|n91|92|n93|94" - elif [ $CHAN -lt 295000 ]; then - BAND="n50|n75|n92|n94" - elif [ $CHAN -eq 295000 ]; then - BAND="n50|n74|n75|n92|n94" - elif [ $CHAN -le 303400 ]; then - BAND="n50|n74|n75|n92|n94" - elif [ $CHAN -le 303600 ]; then - BAND="n74" - elif [ $CHAN -lt 305000 ]; then - BAND="-" - elif [ $CHAN -le 311800 ]; then - BAND="n24" - elif [ $CHAN -lt 361000 ]; then - BAND="-" - elif [ $CHAN -lt 376000 ]; then - BAND="n3" - elif [ $CHAN -eq 376000 ]; then - BAND="n3|n39" - elif [ $CHAN -le 384000 ]; then - BAND="n39" - elif [ $CHAN -lt 386000 ]; then - BAND="-" - elif [ $CHAN -le 398000 ]; then - BAND="n2|n25" - elif [ $CHAN -lt 399000 ]; then - BAND="n25" - elif [ $CHAN -eq 399000 ]; then - BAND="n25|n70" - elif [ $CHAN -lt 402000 ]; then - BAND="n70" - elif [ $CHAN -eq 402000 ]; then - BAND="n34|n70" - elif [ $CHAN -le 404000 ]; then - BAND="n34|n70" - elif [ $CHAN -le 405000 ]; then - BAND="n34" - elif [ $CHAN -lt 422000 ]; then - BAND="-" - elif [ $CHAN -le 434000 ]; then - BAND="n1|n65|n66" - elif [ $CHAN -le 440000 ]; then - BAND="n65|n66" - elif [ $CHAN -lt 460000 ]; then - BAND="-" - elif [ $CHAN -lt 470000 ]; then - BAND="n40" - elif [ $CHAN -eq 470000 ]; then - BAND="n30|n40" - elif [ $CHAN -le 472000 ]; then - BAND="n30|n40" - elif [ $CHAN -le 480000 ]; then - BAND="n40" - elif [ $CHAN -lt 496700 ]; then - BAND="-" - elif [ $CHAN -le 499000 ]; then - BAND="n53" - elif [ $CHAN -lt 499200 ]; then - BAND="-" - elif [ $CHAN -lt 514000 ]; then - BAND="n41|n90" - elif [ $CHAN -eq 514000 ]; then - BAND="n38|n41|n90" - elif [ $CHAN -lt 524000 ]; then - BAND="n38|n41|n90" - elif [ $CHAN -eq 524000 ]; then - BAND="n7|n38|n41|n90" - elif [ $CHAN -lt 538000 ]; then - BAND="n7|n41|n90" - elif [ $CHAN -eq 538000 ]; then - BAND="n7|n90" - elif [ $CHAN -lt 620000 ]; then - BAND="-" - elif [ $CHAN -lt 636667 ]; then - BAND="n77|n78" - elif [ $CHAN -le 646666 ]; then - BAND="n48|n77|n78" - elif [ $CHAN -le 653333 ]; then - BAND="n77|n78" - elif [ $CHAN -le 680000 ]; then - BAND="n77" - elif [ $CHAN -lt 693334 ]; then - BAND="-" - elif [ $CHAN -le 733333 ]; then - BAND="n79" - elif [ $CHAN -lt 743333 ]; then - BAND="-" - elif [ $CHAN -lt 795000 ]; then - BAND="n46" - elif [ $CHAN -eq 795000 ]; then - BAND="n46|n96" - elif [ $CHAN -le 875000 ]; then - BAND="n96" - else - BAND="-" - fi -} - -if [ -z "$CHAN" ]; then - BAND="-" -elif [ "$CHAN" -lt 123400 ]; then - decode_lte -elif [ "$CHAN" -le 875000 ]; then - decode_nr5g -else - BAND="-" -fi -echo $BAND -exit diff --git a/luci-app-cpe/root/usr/bin/encodemask b/luci-app-cpe/root/usr/bin/encodemask deleted file mode 100644 index 6b3ed14..0000000 --- a/luci-app-cpe/root/usr/bin/encodemask +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/lua - -mtab = {} -vtab = {1, 2, 4, 8} - -for i = 1, 32 do - mtab[i] = 0 -end - -numarg = #arg -for argval = 1, numarg do - band = arg[argval] - if tonumber(band) <= 128 then - idx = math.floor((band - 1) / 4) + 1 - idxr = 33 - idx - val = vtab[(band - ((idx - 1) * 4 ))] - mtab[idxr] = mtab[idxr] + val - end -end -for i = 1, 32 do - mtab[i] = string.format("%X", mtab[i]) -end - -print(table.concat(mtab)) diff --git a/luci-app-cpe/root/usr/bin/jkillall b/luci-app-cpe/root/usr/bin/jkillall deleted file mode 100644 index 3802082..0000000 --- a/luci-app-cpe/root/usr/bin/jkillall +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -LOOKFOR=$1 -KILLLIST=$(ps | grep $LOOKFOR) -echo "$KILLLIST" | while read line; do - if `echo "$line" | grep "/$LOOKFOR" > /dev/null` ; then - PIDV=$(echo $line | grep -o "^[0-9]\{1,5\}" | grep -o "[0-9]\{1,5\}") - kill $PIDV - fi -done \ No newline at end of file diff --git a/luci-app-cpe/root/usr/bin/rsrp2rssi b/luci-app-cpe/root/usr/bin/rsrp2rssi deleted file mode 100644 index 06ad5b6..0000000 --- a/luci-app-cpe/root/usr/bin/rsrp2rssi +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/lua - -rsrp = tonumber(arg[1]) -bw = tonumber(arg[2]) -if bw == 1.4 then - n = 6 -else - n = bw * 5 -end - -if tonumber(string.match(_VERSION, "%d+%.%d")) > 5.1 then - rssi = rsrp + (10 * math.log(n * 12, 10)) -else - rssi = rsrp + (10 * math.log10(n * 12)) -end -if rssi < -113 then - rssi = -113 -elseif rssi > -51 then - rssi = -51 -end -print(math.floor(rssi)) diff --git a/luci-app-cpe/root/usr/bin/set_gpio b/luci-app-cpe/root/usr/bin/set_gpio deleted file mode 100644 index 5fddfa7..0000000 --- a/luci-app-cpe/root/usr/bin/set_gpio +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -PIN=$1 -VALUE=$2 - -PIN_FILE=/sys/class/gpio/gpio$PIN - -if [ -z "$PIN" -o -z "$VALUE" ]; then - exit 1 -fi - -echo $PIN >/sys/class/gpio/export - -if [ $(cat $PIN_FILE/direction) = "out" ]; then - echo $VALUE >$PIN_FILE/value -fi - -echo $PIN >/sys/class/gpio/unexport \ No newline at end of file diff --git a/luci-app-cpe/root/usr/share/cpe/Fibocom b/luci-app-cpe/root/usr/share/cpe/Fibocom deleted file mode 100644 index 72bfe02..0000000 --- a/luci-app-cpe/root/usr/share/cpe/Fibocom +++ /dev/null @@ -1,285 +0,0 @@ -#!/bin/sh -ATPORT=1 - - - -# SIMCOM获取基站信息 -Fibocom_Cellinfo() -{ - #baseinfo.gcom - OX=$( sendat $ATPORT "ATI") - OX=$( sendat $ATPORT "AT+CGEQNEG=1") - - #cellinfo0.gcom - OX1=$( sendat $ATPORT "AT+COPS=3,0;+COPS?") - OX2=$( sendat $ATPORT "AT+COPS=3,2;+COPS?") - OX=$OX1" "$OX2 - - #cellinfo.gcom - OY1=$( sendat $ATPORT "AT+CREG=2;+CREG?;+CREG=0") - OY2=$( sendat $ATPORT "AT+CEREG=2;+CEREG?;+CEREG=0") - OY3=$( sendat $ATPORT "AT+C5GREG=2;+C5GREG?;+C5GREG=0") - OY=$OY1" "$OY2" "$OY3 - - - OXx=$OX - OX=$(echo $OX | tr 'a-z' 'A-Z') - OY=$(echo $OY | tr 'a-z' 'A-Z') - OX=$OX" "$OY - - #Debug "$OX" - #Debug "$OY" - - COPS="-" - COPS_MCC="-" - COPS_MNC="-" - COPSX=$(echo $OXx | grep -o "+COPS: [01],0,.\+," | cut -d, -f3 | grep -o "[^\"]\+") - - if [ "x$COPSX" != "x" ]; then - COPS=$COPSX - fi - - COPSX=$(echo $OX | grep -o "+COPS: [01],2,.\+," | cut -d, -f3 | grep -o "[^\"]\+") - - if [ "x$COPSX" != "x" ]; then - COPS_MCC=${COPSX:0:3} - COPS_MNC=${COPSX:3:3} - if [ "$COPS" = "-" ]; then - COPS=$(awk -F[\;] '/'$COPS'/ {print $2}' $ROOTER/signal/mccmnc.data) - [ "x$COPS" = "x" ] && COPS="-" - fi - fi - - if [ "$COPS" = "-" ]; then - COPS=$(echo "$O" | awk -F[\"] '/^\+COPS: 0,0/ {print $2}') - if [ "x$COPS" = "x" ]; then - COPS="-" - COPS_MCC="-" - COPS_MNC="-" - fi - fi - COPS_MNC=" "$COPS_MNC - - OX=$(echo "${OX//[ \"]/}") - CID="" - CID5="" - RAT="" - REGV=$(echo "$OX" | grep -o "+C5GREG:2,[0-9],[A-F0-9]\{2,6\},[A-F0-9]\{5,10\},[0-9]\{1,2\}") - if [ -n "$REGV" ]; then - LAC5=$(echo "$REGV" | cut -d, -f3) - LAC5=$LAC5" ($(printf "%d" 0x$LAC5))" - CID5=$(echo "$REGV" | cut -d, -f4) - CID5L=$(printf "%010X" 0x$CID5) - RNC5=${CID5L:1:6} - RNC5=$RNC5" ($(printf "%d" 0x$RNC5))" - CID5=${CID5L:7:3} - CID5="Short $(printf "%X" 0x$CID5) ($(printf "%d" 0x$CID5)), Long $(printf "%X" 0x$CID5L) ($(printf "%d" 0x$CID5L))" - RAT=$(echo "$REGV" | cut -d, -f5) - fi - REGV=$(echo "$OX" | grep -o "+CEREG:2,[0-9],[A-F0-9]\{2,4\},[A-F0-9]\{5,8\}") - REGFMT="3GPP" - if [ -z "$REGV" ]; then - REGV=$(echo "$OX" | grep -o "+CEREG:2,[0-9],[A-F0-9]\{2,4\},[A-F0-9]\{1,3\},[A-F0-9]\{5,8\}") - REGFMT="SW" - fi - if [ -n "$REGV" ]; then - LAC=$(echo "$REGV" | cut -d, -f3) - LAC=$(printf "%04X" 0x$LAC)" ($(printf "%d" 0x$LAC))" - if [ $REGFMT = "3GPP" ]; then - CID=$(echo "$REGV" | cut -d, -f4) - else - CID=$(echo "$REGV" | cut -d, -f5) - fi - CIDL=$(printf "%08X" 0x$CID) - RNC=${CIDL:1:5} - RNC=$RNC" ($(printf "%d" 0x$RNC))" - CID=${CIDL:6:2} - CID="Short $(printf "%X" 0x$CID) ($(printf "%d" 0x$CID)), Long $(printf "%X" 0x$CIDL) ($(printf "%d" 0x$CIDL))" - - else - REGV=$(echo "$OX" | grep -o "+CREG:2,[0-9],[A-F0-9]\{2,4\},[A-F0-9]\{2,8\}") - if [ -n "$REGV" ]; then - LAC=$(echo "$REGV" | cut -d, -f3) - CID=$(echo "$REGV" | cut -d, -f4) - if [ ${#CID} -gt 4 ]; then - LAC=$(printf "%04X" 0x$LAC)" ($(printf "%d" 0x$LAC))" - CIDL=$(printf "%08X" 0x$CID) - RNC=${CIDL:1:3} - CID=${CIDL:4:4} - CID="Short $(printf "%X" 0x$CID) ($(printf "%d" 0x$CID)), Long $(printf "%X" 0x$CIDL) ($(printf "%d" 0x$CIDL))" - else - LAC="" - fi - else - LAC="" - fi - fi - REGSTAT=$(echo "$REGV" | cut -d, -f2) - if [ "$REGSTAT" == "5" -a "$COPS" != "-" ]; then - COPS_MNC=$COPS_MNC" (Roaming)" - fi - if [ -n "$CID" -a -n "$CID5" ] && [ "$RAT" == "13" -o "$RAT" == "10" ]; then - LAC="4G $LAC, 5G $LAC5" - CID="4G $CID
      5G $CID5" - RNC="4G $RNC, 5G $RNC5" - elif [ -n "$CID5" ]; then - LAC=$LAC5 - CID=$CID5 - RNC=$RNC5 - fi - if [ -z "$LAC" ]; then - LAC="-" - CID="-" - RNC="-" - fi -} -Fibocom_SIMINFO() -{ - Debug "Fibocom_SIMINFO" - # 获取IMEI - IMEI=$( sendat $ATPORT "AT+CGSN" | sed -n '2p' ) - # 获取IMSI - IMSI=$( sendat $ATPORT "AT+CIMI" | sed -n '2p' ) - # 获取ICCID - ICCID=$( sendat $ATPORT "AT+ICCID" | grep -o "+ICCID:[ ]*[-0-9]\+" | grep -o "[-0-9]\{1,4\}" ) - # 获取电话号码 - phone=$( sendat $ATPORT "AT+CNUM" | grep "+CNUM:" ) -} - -#SIMCOM查找基站AT -Fibocom_AT() -{ - Debug "Fibocom_AT" - ATPORT - All_CSQ - Fibocom_SIMINFO - Fibocom_Cellinfo - - #温度 - OX=$( sendat $ATPORT "AT+CPMUTEMP") - TEMP=$(echo "$OX" | grep -o "+CPMUTEMP:[ ]*[-0-9]\+" | grep -o "[-0-9]\{1,4\}") - if [ -n "$TEMP" ]; then - TEMP=$(echo $TEMP)$(printf "\xc2\xb0")"C" - fi - - - #基站信息 - OX=$( sendat $ATPORT "AT+CPSI?") - rec=$(echo "$OX" | grep "+CPSI:") - w=$(echo $rec |grep "NO SERVICE"| wc -l) - if [ $w -ge 1 ];then - Debug "NO SERVICE" - return - fi - w=$(echo $rec |grep "NR5G_"| wc -l) - if [ $w -ge 1 ];then - - w=$(echo $rec |grep "32768"| wc -l) - if [ $w -ge 1 ];then - Debug "-32768" - return - fi - - Debug "$rec" - rec1=${rec##*+CPSI:} - #echo "$rec1" - MODE="${rec1%%,*}" # MODE="NR5G" - rect1=${rec1#*,} - rect1s="${rect1%%,*}" #Online - rect2=${rect1#*,} - rect2s="${rect2%%,*}" #460-11 - rect3=${rect2#*,} - rect3s="${rect3%%,*}" #0xCFA102 - rect4=${rect3#*,} - rect4s="${rect4%%,*}" #55744245764 - rect5=${rect4#*,} - rect5s="${rect5%%,*}" #196 - rect6=${rect5#*,} - rect6s="${rect6%%,*}" #NR5G_BAND78 - rect7=${rect6#*,} - rect7s="${rect7%%,*}" #627264 - rect8=${rect7#*,} - rect8s="${rect8%%,*}" #-940 - rect9=${rect8#*,} - rect9s="${rect9%%,*}" #-110 - # "${rec1##*,}" #最后一位 - rect10=${rect9#*,} - rect10s="${rect10%%,*}" #最后一位 - PCI=$rect5s - LBAND="n"$(echo $rect6s | cut -d, -f0 | grep -o "BAND[0-9]\{1,3\}" | grep -o "[0-9]\+") - CHANNEL=$rect7s - RSCP=$(($(echo $rect8s | cut -d, -f0) / 10)) - ECIO=$(($(echo $rect9s | cut -d, -f0) / 10)) - if [ "$CSQ_PER" = "-" ]; then - CSQ_PER=$((100 - (($RSCP + 31) * 100/-125)))"%" - fi - SINR=$(($(echo $rect10s | cut -d, -f0) / 10))" dB" - fi - w=$(echo $rec |grep "LTE"|grep "EUTRAN"| wc -l) - if [ $w -ge 1 ];then - rec1=${rec#*EUTRAN-} - lte_band=${rec1%%,*} #EUTRAN-BAND - rec1=${rec1#*,} - rec1=${rec1#*,} - rec1=${rec1#*,} - rec1=${rec1#*,} - #rec1=${rec1#*,} - rec1=${rec1#*,} - lte_rssi=${rec1%%,*} #LTE_RSSI - lte_rssi=`expr $lte_rssi / 10` #LTE_RSSI - Debug "LTE_BAND=$lte_band LTE_RSSI=$lte_rssi" - if [ $rssi == 0 ];then - rssi=$lte_rssi - fi - fi - w=$(echo $rec |grep "WCDMA"| wc -l) - if [ $w -ge 1 ];then - w=$(echo $rec |grep "UNKNOWN"|wc -l) - if [ $w -ge 1 ];then - Debug "UNKNOWN BAND" - return - fi - fi - - - - - - - #CNMP - OX=$( sendat $ATPORT "AT+CNMP?") - CNMP=$(echo "$OX" | grep -o "+CNMP:[ ]*[0-9]\{1,3\}" | grep -o "[0-9]\{1,3\}") - if [ -n "$CNMP" ]; then - case $CNMP in - "2"|"55" ) - NETMODE="1" ;; - "13" ) - NETMODE="3" ;; - "14" ) - NETMODE="5" ;; - "38" ) - NETMODE="7" ;; - "71" ) - NETMODE="9" ;; - "109" ) - NETMODE="8" ;; - * ) - NETMODE="0" ;; - esac - fi - - # CMGRMI 信息 - OX=$( sendat $ATPORT "AT+CMGRMI=4") - CAINFO=$(echo "$OX" | grep -o "$REGXz" | tr ' ' ':') - if [ -n "$CAINFO" ]; then - for CASV in $(echo "$CAINFO"); do - LBAND=$LBAND"
      B"$(echo "$CASV" | cut -d, -f4) - BW=$(echo "$CASV" | cut -d, -f5) - decode_bw - LBAND=$LBAND" (CA, Bandwidth $BW MHz)" - CHANNEL="$CHANNEL, "$(echo "$CASV" | cut -d, -f2) - PCI="$PCI, "$(echo "$CASV" | cut -d, -f7) - done - fi - -} \ No newline at end of file diff --git a/luci-app-cpe/root/usr/share/cpe/Quectel b/luci-app-cpe/root/usr/share/cpe/Quectel deleted file mode 100644 index 22974c1..0000000 --- a/luci-app-cpe/root/usr/share/cpe/Quectel +++ /dev/null @@ -1,507 +0,0 @@ -#!/bin/sh -ATPORT=1 -#Quectel -lte_bw() { - BW=$(echo $BW | grep -o "[0-5]\{1\}") - case $BW in - "0") - BW="1.4" ;; - "1") - BW="3" ;; - "2"|"3"|"4"|"5") - BW=$((($(echo $BW) - 1) * 5)) ;; - esac -} -#Quectel -nr_bw() { - BW=$(echo $BW | grep -o "[0-9]\{1,2\}") - case $BW in - "0"|"1"|"2"|"3"|"4"|"5") - BW=$((($(echo $BW) + 1) * 5)) ;; - "6"|"7"|"8"|"9"|"10"|"11"|"12") - BW=$((($(echo $BW) - 2) * 10)) ;; - "13") - BW="200" ;; - "14") - BW="400" ;; - esac -} - -#ѯϢǿ -All_CSQ() -{ - Debug "All_CSQ" - #ź - OX=$( sendat $ATPORT "AT+CSQ" |grep "+CSQ:") - OX=$(echo $OX | tr 'a-z' 'A-Z') - CSQ=$(echo "$OX" | grep -o "+CSQ: [0-9]\{1,2\}" | grep -o "[0-9]\{1,2\}") - if [ $CSQ = "99" ]; then - CSQ="" - fi - if [ -n "$CSQ" ]; then - CSQ_PER=$(($CSQ * 100/31))"%" - CSQ_RSSI=$((2 * CSQ - 113))" dBm" - else - CSQ="-" - CSQ_PER="-" - CSQ_RSSI="-" - fi -} - -Quectel_SIMINFO() -{ - Debug "Quectel_SIMINFO" - # ȡIMEI - IMEI=$( sendat $ATPORT "AT+CGSN" | sed -n '2p' ) - # ȡIMSI - IMSI=$( sendat $ATPORT "AT+CIMI" | sed -n '2p' ) - # ȡICCID - ICCID=$( sendat $ATPORT "AT+ICCID" | grep -o "+ICCID:[ ]*[-0-9]\+" | grep -o "[-0-9]\{1,4\}" ) - # ȡ绰 - phone=$( sendat $ATPORT "AT+CNUM" | grep "+CNUM:" ) - -} -# SIMCOMȡվϢ -Quectel_Cellinfo() -{ - # return - #cellinfo0.gcom - OX1=$( sendat $ATPORT "AT+COPS=3,0;+COPS?") - OX2=$( sendat $ATPORT "AT+COPS=3,2;+COPS?") - OX=$OX1" "$OX2 - - #cellinfo.gcom - OY1=$( sendat $ATPORT "AT+CREG=2;+CREG?;+CREG=0") - OY2=$( sendat $ATPORT "AT+CEREG=2;+CEREG?;+CEREG=0") - OY3=$( sendat $ATPORT "AT+C5GREG=2;+C5GREG?;+C5GREG=0") - OY=$OY1" "$OY2" "$OY3 - - - OXx=$OX - OX=$(echo $OX | tr 'a-z' 'A-Z') - OY=$(echo $OY | tr 'a-z' 'A-Z') - OX=$OX" "$OY - - #Debug "$OX" - #Debug "$OY" - - COPS="-" - COPS_MCC="-" - COPS_MNC="-" - COPSX=$(echo $OXx | grep -o "+COPS: [01],0,.\+," | cut -d, -f3 | grep -o "[^\"]\+") - - if [ "x$COPSX" != "x" ]; then - COPS=$COPSX - fi - - COPSX=$(echo $OX | grep -o "+COPS: [01],2,.\+," | cut -d, -f3 | grep -o "[^\"]\+") - - if [ "x$COPSX" != "x" ]; then - COPS_MCC=${COPSX:0:3} - COPS_MNC=${COPSX:3:3} - if [ "$COPS" = "-" ]; then - COPS=$(awk -F[\;] '/'$COPS'/ {print $2}' $ROOTER/signal/mccmnc.data) - [ "x$COPS" = "x" ] && COPS="-" - fi - fi - - if [ "$COPS" = "-" ]; then - COPS=$(echo "$O" | awk -F[\"] '/^\+COPS: 0,0/ {print $2}') - if [ "x$COPS" = "x" ]; then - COPS="-" - COPS_MCC="-" - COPS_MNC="-" - fi - fi - COPS_MNC=" "$COPS_MNC - - OX=$(echo "${OX//[ \"]/}") - CID="" - CID5="" - RAT="" - REGV=$(echo "$OX" | grep -o "+C5GREG:2,[0-9],[A-F0-9]\{2,6\},[A-F0-9]\{5,10\},[0-9]\{1,2\}") - if [ -n "$REGV" ]; then - LAC5=$(echo "$REGV" | cut -d, -f3) - LAC5=$LAC5" ($(printf "%d" 0x$LAC5))" - CID5=$(echo "$REGV" | cut -d, -f4) - CID5L=$(printf "%010X" 0x$CID5) - RNC5=${CID5L:1:6} - RNC5=$RNC5" ($(printf "%d" 0x$RNC5))" - CID5=${CID5L:7:3} - CID5="Short $(printf "%X" 0x$CID5) ($(printf "%d" 0x$CID5)), Long $(printf "%X" 0x$CID5L) ($(printf "%d" 0x$CID5L))" - RAT=$(echo "$REGV" | cut -d, -f5) - fi - REGV=$(echo "$OX" | grep -o "+CEREG:2,[0-9],[A-F0-9]\{2,4\},[A-F0-9]\{5,8\}") - REGFMT="3GPP" - if [ -z "$REGV" ]; then - REGV=$(echo "$OX" | grep -o "+CEREG:2,[0-9],[A-F0-9]\{2,4\},[A-F0-9]\{1,3\},[A-F0-9]\{5,8\}") - REGFMT="SW" - fi - if [ -n "$REGV" ]; then - LAC=$(echo "$REGV" | cut -d, -f3) - LAC=$(printf "%04X" 0x$LAC)" ($(printf "%d" 0x$LAC))" - if [ $REGFMT = "3GPP" ]; then - CID=$(echo "$REGV" | cut -d, -f4) - else - CID=$(echo "$REGV" | cut -d, -f5) - fi - CIDL=$(printf "%08X" 0x$CID) - RNC=${CIDL:1:5} - RNC=$RNC" ($(printf "%d" 0x$RNC))" - CID=${CIDL:6:2} - CID="Short $(printf "%X" 0x$CID) ($(printf "%d" 0x$CID)), Long $(printf "%X" 0x$CIDL) ($(printf "%d" 0x$CIDL))" - - else - REGV=$(echo "$OX" | grep -o "+CREG:2,[0-9],[A-F0-9]\{2,4\},[A-F0-9]\{2,8\}") - if [ -n "$REGV" ]; then - LAC=$(echo "$REGV" | cut -d, -f3) - CID=$(echo "$REGV" | cut -d, -f4) - if [ ${#CID} -gt 4 ]; then - LAC=$(printf "%04X" 0x$LAC)" ($(printf "%d" 0x$LAC))" - CIDL=$(printf "%08X" 0x$CID) - RNC=${CIDL:1:3} - CID=${CIDL:4:4} - CID="Short $(printf "%X" 0x$CID) ($(printf "%d" 0x$CID)), Long $(printf "%X" 0x$CIDL) ($(printf "%d" 0x$CIDL))" - else - LAC="" - fi - else - LAC="" - fi - fi - REGSTAT=$(echo "$REGV" | cut -d, -f2) - if [ "$REGSTAT" == "5" -a "$COPS" != "-" ]; then - COPS_MNC=$COPS_MNC" (Roaming)" - fi - if [ -n "$CID" -a -n "$CID5" ] && [ "$RAT" == "13" -o "$RAT" == "10" ]; then - LAC="4G $LAC, 5G $LAC5" - CID="4G $CID
      5G $CID5" - RNC="4G $RNC, 5G $RNC5" - elif [ -n "$CID5" ]; then - LAC=$LAC5 - CID=$CID5 - RNC=$RNC5 - fi - if [ -z "$LAC" ]; then - LAC="-" - CID="-" - RNC="-" - fi -} - -#Quectel˾һվAT -Quectel_AT() -{ - Debug "Quectel_AT" - ATPORT - - Quectel_SIMINFO - All_CSQ - - Quectel_Cellinfo - - # - OX=$( sendat $ATPORT 'AT+QENG="servingcell"' | grep "+QENG:" ) - NR_NSA=$(echo $OX | grep -o -i "+QENG:[ ]\?\"NR5G-NSA\",") - NR_SA=$(echo $OX | grep -o -i "+QENG: \"SERVINGCELL\",[^,]\+,\"NR5G-SA\",\"[DFT]\{3\}\",") - if [ -n "$NR_NSA" ]; then - QENG=",,"$(echo $OX" " | grep -o -i "+QENG: \"LTE\".\+\"NR5G-NSA\"," | tr " " ",") - QENG5=$(echo $OX | grep -o -i "+QENG:[ ]\?\"NR5G-NSA\",[0-9]\{3\},[0-9]\{2,3\},[0-9]\{1,5\},-[0-9]\{2,5\},[-0-9]\{1,3\},-[0-9]\{2,3\},[0-9]\{1,7\},[0-9]\{1,3\}.\{1,6\}") - if [ -z "$QENG5" ]; then - QENG5=$(echo $OX | grep -o -i "+QENG:[ ]\?\"NR5G-NSA\",[0-9]\{3\},[0-9]\{2,3\},[0-9]\{1,5\},-[0-9]\{2,3\},[-0-9]\{1,3\},-[0-9]\{2,3\}") - if [ -n "$QENG5" ]; then - QENG5=$QENG5",," - fi - fi - elif [ -n "$NR_SA" ]; then - QENG=$(echo $NR_SA | tr " " ",") - QENG5=$(echo $OX | grep -o -i "+QENG: \"SERVINGCELL\",[^,]\+,\"NR5G-SA\",\"[DFT]\{3\}\",[ 0-9]\{3,4\},[0-9]\{2,3\},[0-9A-F]\{1,10\},[0-9]\{1,5\},[0-9A-F]\{2,6\},[0-9]\{6,7\},[0-9]\{1,3\},[0-9]\{1,2\},-[0-9]\{2,5\},-[0-9]\{2,3\},[-0-9]\{1,3\}") - else - QENG=$(echo $OX" " | grep -o -i "+QENG: [^ ]\+ " | tr " " ",") - fi - - - # Debug "$QENG" - # Debug "$QENG5" - - RAT=$(echo $QENG | cut -d, -f4 | grep -o "[-A-Z5]\{3,7\}") - case $RAT in - "GSM") - MODE="GSM" - ;; - "WCDMA") - MODE="WCDMA" - CHANNEL=$(echo $QENG | cut -d, -f9) - RSCP=$(echo $QENG | cut -d, -f12) - RSCP="-"$(echo $RSCP | grep -o "[0-9]\{1,3\}") - ECIO=$(echo $QENG | cut -d, -f13) - ECIO="-"$(echo $ECIO | grep -o "[0-9]\{1,3\}") - ;; - "LTE"|"CAT-M"|"CAT-NB") - MODE=$(echo $QENG | cut -d, -f5 | grep -o "[DFT]\{3\}") - if [ -n "$MODE" ]; then - MODE="$RAT $MODE" - else - MODE="$RAT" - fi - PCI=$(echo $QENG | cut -d, -f9) - CHANNEL=$(echo $QENG | cut -d, -f10) - LBAND=$(echo $QENG | cut -d, -f11 | grep -o "[0-9]\{1,3\}") - BW=$(echo $QENG | cut -d, -f12) - lte_bw - BWU=$BW - BW=$(echo $QENG | cut -d, -f13) - lte_bw - BWD=$BW - if [ -z "$BWD" ]; then - BWD="unknown" - fi - if [ -z "$BWU" ]; then - BWU="unknown" - fi - if [ -n "$LBAND" ]; then - LBAND="B"$LBAND" (Bandwidth $BWD MHz Down | $BWU MHz Up)" - fi - RSRP=$(echo $QENG | cut -d, -f15 | grep -o "[0-9]\{1,3\}") - if [ -n "$RSRP" ]; then - RSCP="-"$RSRP - RSRPLTE=$RSCP - fi - RSRQ=$(echo $QENG | cut -d, -f16 | grep -o "[0-9]\{1,3\}") - if [ -n "$RSRQ" ]; then - ECIO="-"$RSRQ - fi - RSSI=$(echo $QENG | cut -d, -f17 | grep -o "\-[0-9]\{1,3\}") - if [ -n "$RSSI" ]; then - CSQ_RSSI=$RSSI" dBm" - fi - SINRR=$(echo $QENG | cut -d, -f18 | grep -o "[0-9]\{1,3\}") - if [ -n "$SINRR" ]; then - if [ $SINRR -le 25 ]; then - SINR=$((($(echo $SINRR) * 2) -20))" dB" - fi - fi - - if [ -n "$NR_NSA" ]; then - MODE="LTE/NR EN-DC" - echo "0" > /tmp/modnetwork - if [ -n "$QENG5" ] && [ -n "$LBAND" ] && [ "$RSCP" != "-" ] && [ "$ECIO" != "-" ]; then - PCI="$PCI, "$(echo $QENG5 | cut -d, -f4) - SCHV=$(echo $QENG5 | cut -d, -f8) - SLBV=$(echo $QENG5 | cut -d, -f9) - BW=$(echo $QENG5 | cut -d, -f10 | grep -o "[0-9]\{1,3\}") - if [ -n "$SLBV" ]; then - LBAND=$LBAND"
      n"$SLBV - if [ -n "$BW" ]; then - nr_bw - LBAND=$LBAND" (Bandwidth $BW MHz)" - fi - if [ "$SCHV" -ge 123400 ]; then - CHANNEL=$CHANNEL", "$SCHV - else - CHANNEL=$CHANNEL", -" - fi - else - LBAND=$LBAND"
      nxx (unknown NR5G band)" - CHANNEL=$CHANNEL", -" - fi - RSCP=$RSCP" dBm
      "$(echo $QENG5 | cut -d, -f5) - SINRR=$(echo $QENG5 | cut -d, -f6 | grep -o "[0-9]\{1,3\}") - if [ -n "$SINRR" ]; then - if [ $SINRR -le 30 ]; then - SINR=$SINR"
      "$((($(echo $SINRR) * 2) -20))" dB" - fi - fi - ECIO=$ECIO" (4G) dB
      "$(echo $QENG5 | cut -d, -f7)" (5G) " - fi - fi - if [ -z "$LBAND" ]; then - LBAND="-" - else - if [ -n "$QCA" ]; then - QCA=$(echo $QCA | grep -o "\"S[CS]\{2\}\"[-0-9A-Z,\"]\+") - for QCAL in $(echo "$QCA"); do - if [ $(echo "$QCAL" | cut -d, -f7) = "2" ]; then - SCHV=$(echo $QCAL | cut -d, -f2 | grep -o "[0-9]\+") - SRATP="B" - if [ -n "$SCHV" ]; then - CHANNEL="$CHANNEL, $SCHV" - if [ "$SCHV" -gt 123400 ]; then - SRATP="n" - fi - fi - SLBV=$(echo $QCAL | cut -d, -f6 | grep -o "[0-9]\{1,2\}") - if [ -n "$SLBV" ]; then - LBAND=$LBAND"
      "$SRATP$SLBV - BWD=$(echo $QCAL | cut -d, -f3 | grep -o "[0-9]\{1,3\}") - if [ -n "$BWD" ]; then - UPDOWN=$(echo $QCAL | cut -d, -f13) - case "$UPDOWN" in - "UL" ) - CATYPE="CA"$(printf "\xe2\x86\x91") ;; - "DL" ) - CATYPE="CA"$(printf "\xe2\x86\x93") ;; - * ) - CATYPE="CA" ;; - esac - if [ $BWD -gt 14 ]; then - LBAND=$LBAND" ("$CATYPE", Bandwidth "$(($(echo $BWD) / 5))" MHz)" - else - LBAND=$LBAND" ("$CATYPE", Bandwidth 1.4 MHz)" - fi - fi - LBAND=$LBAND - fi - PCI="$PCI, "$(echo $QCAL | cut -d, -f8) - fi - done - fi - fi - if [ $RAT = "CAT-M" ] || [ $RAT = "CAT-NB" ]; then - LBAND="B$(echo $QENG | cut -d, -f11) ($RAT)" - fi - ;; - "NR5G-SA") - MODE="NR5G-SA" - if [ -n "$QENG5" ]; then - #AT+qnwcfg="NR5G_AMBR" #ѯٶ - MODE="$RAT $(echo $QENG5 | cut -d, -f4)" - PCI=$(echo $QENG5 | cut -d, -f8) - CHANNEL=$(echo $QENG5 | cut -d, -f10) - LBAND=$(echo $QENG5 | cut -d, -f11) - BW=$(echo $QENG5 | cut -d, -f12) - nr_bw - LBAND="n"$LBAND" (Bandwidth $BW MHz)" - RSCP=$(echo $QENG5 | cut -d, -f13) - ECIO=$(echo $QENG5 | cut -d, -f14) - if [ "$CSQ_PER" = "-" ]; then - RSSI=$(rsrp2rssi $RSCP $BW) - CSQ_PER=$((100 - (($RSSI + 51) * 100/-62)))"%" - CSQ=$((($RSSI + 113) / 2)) - CSQ_RSSI=$RSSI" dBm" - fi - SINRR=$(echo $QENG5 | cut -d, -f15 | grep -o "[0-9]\{1,3\}") - if [ -n "$SINRR" ]; then - if [ $SINRR -le 30 ]; then - SINR=$((($(echo $SINRR) * 2) -20))" dB" - fi - fi - fi - ;; - esac - - - - - - # - OX=$( sendat $ATPORT "AT+QCAINFO" | grep "+QCAINFO:" ) - QCA=$(echo $OX" " | grep -o -i "+QCAINFO: \"S[CS]\{2\}\".\+NWSCANMODE" | tr " " ",") - - - # - OX=$( sendat $ATPORT 'AT+QCFG="nwscanmode"' | grep "+QCAINFO:" ) - QNSM=$(echo $OX | grep -o -i "+QCFG: \"NWSCANMODE\",[0-9]") - QNSM=$(echo "$QNSM" | grep -o "[0-9]") - if [ -n "$QNSM" ]; then - MODTYPE="6" - case $QNSM in - "0" ) - NETMODE="1" ;; - "1" ) - NETMODE="3" ;; - "2"|"5" ) - NETMODE="5" ;; - "3" ) - NETMODE="7" ;; - esac - fi - if [ -n "$QNWP" ]; then - MODTYPE="6" - case $QNWP in - "AUTO" ) - NETMODE="1" ;; - "WCDMA" ) - NETMODE="5" ;; - "LTE" ) - NETMODE="7" ;; - "LTE:NR5G" ) - NETMODE="8" ;; - "NR5G" ) - NETMODE="9" ;; - esac - fi - - - # - OX=$( sendat $ATPORT 'AT+QNWPREFCFG="mode_pref"' | grep "+QNWPREFCFG:" ) - QNWP=$(echo $OX | grep -o -i "+QNWPREFCFG: \"MODE_PREF\",[A-Z5:]\+" | cut -d, -f2) - - #¶ - OX=$( sendat $ATPORT 'AT+QTEMP' | grep "+QTEMP:" ) - QTEMP=$(echo $OX | grep -o -i "+QTEMP: [0-9]\{1,3\}") - if [ -z "$QTEMP" ]; then - QTEMP=$(echo $OX | grep -o -i "+QTEMP:[ ]\?\"XO[_-]THERM[_-][^,]\+,[\"]\?[0-9]\{1,3\}" | grep -o "[0-9]\{1,3\}") - fi - if [ -z "$QTEMP" ]; then - QTEMP=$(echo $OX | grep -o -i "+QTEMP:[ ]\?\"MDM-CORE-USR.\+[0-9]\{1,3\}\"" | cut -d\" -f4) - fi - if [ -z "$QTEMP" ]; then - QTEMP=$(echo $OX | grep -o -i "+QTEMP:[ ]\?\"MDMSS.\+[0-9]\{1,3\}\"" | cut -d\" -f4) - fi - if [ -n "$QTEMP" ]; then - CTEMP=$(echo $QTEMP | grep -o -i "[0-9]\{1,3\}")$(printf "\xc2\xb0")"C" - fi - - - - # - OX=$( sendat $ATPORT "AT+QRSRP" | grep "+QRSRP:" ) - QRSRP=$(echo "$OX" | grep -o -i "+QRSRP:[^,]\+,-[0-9]\{1,5\},-[0-9]\{1,5\},-[0-9]\{1,5\}[^ ]*") - if [ -n "$QRSRP" ] && [ "$RAT" != "WCDMA" ]; then - QRSRP1=$(echo $QRSRP | cut -d, -f1 | grep -o "[-0-9]\+") - QRSRP2=$(echo $QRSRP | cut -d, -f2) - QRSRP3=$(echo $QRSRP | cut -d, -f3) - QRSRP4=$(echo $QRSRP | cut -d, -f4) - QRSRPtype=$(echo $QRSRP | cut -d, -f5) - if [ "$QRSRPtype" == "NR5G" ]; then - if [ -n "$NR_SA" ]; then - RSCP=$QRSRP1 - if [ -n "$QRPRP2" -a "$QRSRP2" != "-32768" ]; then - RSCP1="RxD "$QRSRP2 - fi - if [ -n "$QRSRP3" -a "$QRSRP3" != "-32768" ]; then - RSCP=$RSCP" dBm
      "$QRSRP3 - fi - if [ -n "$QRSRP4" -a "$QRSRP4" != "-32768" ]; then - RSCP1="RxD "$QRSRP4 - fi - else - RSCP=$RSRPLTE - if [ -n "$QRSRP1" -a "$QRSRP1" != "-32768" ]; then - RSCP=$RSCP" (4G) dBm
      "$QRSRP1 - if [ -n "$QRSRP2" -a "$QRSRP2" != "-32768" ]; then - RSCP="$RSCP,$QRSRP2" - if [ -n "$QRSRP3" -a "$QRSRP3" != "-32768" ]; then - RSCP="$RSCP,$QRSRP3" - if [ -n "$QRSRP4" -a "$QRSRP4" != "-32768" ]; then - RSCP="$RSCP,$QRSRP4" - fi - fi - RSCP=$RSCP" (5G) " - fi - fi - fi - elif [ "$QRSRP2$QRSRP3$QRSRP4" != "-44-44-44" -a -z "$QENG5" ]; then - RSCP=$QRSRP1 - if [ "$QRSRP3$QRSRP4" == "-140-140" -o "$QRSRP3$QRSRP4" == "-44-44" -o "$QRSRP3$QRSRP4" == "-32768-32768" ]; then - RSCP1="RxD "$(echo $QRSRP | cut -d, -f2) - else - RSCP=$RSCP" dBm (RxD "$QRSRP2" dBm)
      "$QRSRP3 - RSCP1="RxD "$QRSRP4 - fi - fi - fi - - -} \ No newline at end of file diff --git a/luci-app-cpe/root/usr/share/cpe/SIMCOM b/luci-app-cpe/root/usr/share/cpe/SIMCOM deleted file mode 100644 index 4d1cd41..0000000 --- a/luci-app-cpe/root/usr/share/cpe/SIMCOM +++ /dev/null @@ -1,303 +0,0 @@ -#!/bin/sh -ATPORT=1 - -#查询信息强度 -All_CSQ() -{ - Debug "All_CSQ" - #信号 - OX=$( sendat $ATPORT "AT+CSQ" |grep "+CSQ:") - OX=$(echo $OX | tr 'a-z' 'A-Z') - CSQ=$(echo "$OX" | grep -o "+CSQ: [0-9]\{1,2\}" | grep -o "[0-9]\{1,2\}") - if [ $CSQ = "99" ]; then - CSQ="" - fi - if [ -n "$CSQ" ]; then - CSQ_PER=$(($CSQ * 100/31))"%" - CSQ_RSSI=$((2 * CSQ - 113))" dBm" - else - CSQ="-" - CSQ_PER="-" - CSQ_RSSI="-" - fi -} - -# SIMCOM获取基站信息 -SIMCOM_Cellinfo() -{ - #baseinfo.gcom - OX=$( sendat 2 "ATI") - OX=$( sendat 2 "AT+CGEQNEG=1") - - #cellinfo0.gcom - OX1=$( sendat 2 "AT+COPS=3,0;+COPS?") - OX2=$( sendat 2 "AT+COPS=3,2;+COPS?") - OX=$OX1" "$OX2 - - #cellinfo.gcom - OY1=$( sendat 2 "AT+CREG=2;+CREG?;+CREG=0") - OY2=$( sendat 2 "AT+CEREG=2;+CEREG?;+CEREG=0") - OY3=$( sendat 2 "AT+C5GREG=2;+C5GREG?;+C5GREG=0") - OY=$OY1" "$OY2" "$OY3 - - - OXx=$OX - OX=$(echo $OX | tr 'a-z' 'A-Z') - OY=$(echo $OY | tr 'a-z' 'A-Z') - OX=$OX" "$OY - - #Debug "$OX" - #Debug "$OY" - - COPS="-" - COPS_MCC="-" - COPS_MNC="-" - COPSX=$(echo $OXx | grep -o "+COPS: [01],0,.\+," | cut -d, -f3 | grep -o "[^\"]\+") - - if [ "x$COPSX" != "x" ]; then - COPS=$COPSX - fi - - COPSX=$(echo $OX | grep -o "+COPS: [01],2,.\+," | cut -d, -f3 | grep -o "[^\"]\+") - - if [ "x$COPSX" != "x" ]; then - COPS_MCC=${COPSX:0:3} - COPS_MNC=${COPSX:3:3} - if [ "$COPS" = "-" ]; then - COPS=$(awk -F[\;] '/'$COPS'/ {print $2}' $ROOTER/signal/mccmnc.data) - [ "x$COPS" = "x" ] && COPS="-" - fi - fi - - if [ "$COPS" = "-" ]; then - COPS=$(echo "$O" | awk -F[\"] '/^\+COPS: 0,0/ {print $2}') - if [ "x$COPS" = "x" ]; then - COPS="-" - COPS_MCC="-" - COPS_MNC="-" - fi - fi - COPS_MNC=" "$COPS_MNC - - OX=$(echo "${OX//[ \"]/}") - CID="" - CID5="" - RAT="" - REGV=$(echo "$OX" | grep -o "+C5GREG:2,[0-9],[A-F0-9]\{2,6\},[A-F0-9]\{5,10\},[0-9]\{1,2\}") - if [ -n "$REGV" ]; then - LAC5=$(echo "$REGV" | cut -d, -f3) - LAC5=$LAC5" ($(printf "%d" 0x$LAC5))" - CID5=$(echo "$REGV" | cut -d, -f4) - CID5L=$(printf "%010X" 0x$CID5) - RNC5=${CID5L:1:6} - RNC5=$RNC5" ($(printf "%d" 0x$RNC5))" - CID5=${CID5L:7:3} - CID5="Short $(printf "%X" 0x$CID5) ($(printf "%d" 0x$CID5)), Long $(printf "%X" 0x$CID5L) ($(printf "%d" 0x$CID5L))" - RAT=$(echo "$REGV" | cut -d, -f5) - fi - REGV=$(echo "$OX" | grep -o "+CEREG:2,[0-9],[A-F0-9]\{2,4\},[A-F0-9]\{5,8\}") - REGFMT="3GPP" - if [ -z "$REGV" ]; then - REGV=$(echo "$OX" | grep -o "+CEREG:2,[0-9],[A-F0-9]\{2,4\},[A-F0-9]\{1,3\},[A-F0-9]\{5,8\}") - REGFMT="SW" - fi - if [ -n "$REGV" ]; then - LAC=$(echo "$REGV" | cut -d, -f3) - LAC=$(printf "%04X" 0x$LAC)" ($(printf "%d" 0x$LAC))" - if [ $REGFMT = "3GPP" ]; then - CID=$(echo "$REGV" | cut -d, -f4) - else - CID=$(echo "$REGV" | cut -d, -f5) - fi - CIDL=$(printf "%08X" 0x$CID) - RNC=${CIDL:1:5} - RNC=$RNC" ($(printf "%d" 0x$RNC))" - CID=${CIDL:6:2} - CID="Short $(printf "%X" 0x$CID) ($(printf "%d" 0x$CID)), Long $(printf "%X" 0x$CIDL) ($(printf "%d" 0x$CIDL))" - - else - REGV=$(echo "$OX" | grep -o "+CREG:2,[0-9],[A-F0-9]\{2,4\},[A-F0-9]\{2,8\}") - if [ -n "$REGV" ]; then - LAC=$(echo "$REGV" | cut -d, -f3) - CID=$(echo "$REGV" | cut -d, -f4) - if [ ${#CID} -gt 4 ]; then - LAC=$(printf "%04X" 0x$LAC)" ($(printf "%d" 0x$LAC))" - CIDL=$(printf "%08X" 0x$CID) - RNC=${CIDL:1:3} - CID=${CIDL:4:4} - CID="Short $(printf "%X" 0x$CID) ($(printf "%d" 0x$CID)), Long $(printf "%X" 0x$CIDL) ($(printf "%d" 0x$CIDL))" - else - LAC="" - fi - else - LAC="" - fi - fi - REGSTAT=$(echo "$REGV" | cut -d, -f2) - if [ "$REGSTAT" == "5" -a "$COPS" != "-" ]; then - COPS_MNC=$COPS_MNC" (Roaming)" - fi - if [ -n "$CID" -a -n "$CID5" ] && [ "$RAT" == "13" -o "$RAT" == "10" ]; then - LAC="4G $LAC, 5G $LAC5" - CID="4G $CID
      5G $CID5" - RNC="4G $RNC, 5G $RNC5" - elif [ -n "$CID5" ]; then - LAC=$LAC5 - CID=$CID5 - RNC=$RNC5 - fi - if [ -z "$LAC" ]; then - LAC="-" - CID="-" - RNC="-" - fi -} -SIMCOM_SIMINFO() -{ - Debug "Quectel_SIMINFO" - # 获取IMEI - IMEI=$( sendat $ATPORT "AT+CGSN" | sed -n '2p' ) - # 获取IMSI - IMSI=$( sendat $ATPORT "AT+CIMI" | sed -n '2p' ) - # 获取ICCID - ICCID=$( sendat $ATPORT "AT+ICCID" | grep -o "+ICCID:[ ]*[-0-9]\+" | grep -o "[-0-9]\{1,4\}" ) - # 获取电话号码 - phone=$( sendat $ATPORT "AT+CNUM" | grep "+CNUM:" ) -} -#SIMCOM查找基站AT -SIMCOM_AT() -{ - Debug "SIMCOM_AT" - ATPORT - All_CSQ - SIMCOM_SIMINFO - SIMCOM_Cellinfo - - #温度 - OX=$( sendat $ATPORT "AT+CPMUTEMP") - TEMP=$(echo "$OX" | grep -o "+CPMUTEMP:[ ]*[-0-9]\+" | grep -o "[-0-9]\{1,4\}") - if [ -n "$TEMP" ]; then - TEMP=$(echo $TEMP)$(printf "\xc2\xb0")"C" - fi - - - #基站信息 - OX=$( sendat $ATPORT "AT+CPSI?") - rec=$(echo "$OX" | grep "+CPSI:") - w=$(echo $rec |grep "NO SERVICE"| wc -l) - if [ $w -ge 1 ];then - Debug "NO SERVICE" - return - fi - w=$(echo $rec |grep "NR5G_"| wc -l) - if [ $w -ge 1 ];then - - w=$(echo $rec |grep "32768"| wc -l) - if [ $w -ge 1 ];then - Debug "-32768" - return - fi - - Debug "$rec" - rec1=${rec##*+CPSI:} - #echo "$rec1" - MODE="${rec1%%,*}" # MODE="NR5G" - rect1=${rec1#*,} - rect1s="${rect1%%,*}" #Online - rect2=${rect1#*,} - rect2s="${rect2%%,*}" #460-11 - rect3=${rect2#*,} - rect3s="${rect3%%,*}" #0xCFA102 - rect4=${rect3#*,} - rect4s="${rect4%%,*}" #55744245764 - rect5=${rect4#*,} - rect5s="${rect5%%,*}" #196 - rect6=${rect5#*,} - rect6s="${rect6%%,*}" #NR5G_BAND78 - rect7=${rect6#*,} - rect7s="${rect7%%,*}" #627264 - rect8=${rect7#*,} - rect8s="${rect8%%,*}" #-940 - rect9=${rect8#*,} - rect9s="${rect9%%,*}" #-110 - # "${rec1##*,}" #最后一位 - rect10=${rect9#*,} - rect10s="${rect10%%,*}" #最后一位 - PCI=$rect5s - LBAND="n"$(echo $rect6s | cut -d, -f0 | grep -o "BAND[0-9]\{1,3\}" | grep -o "[0-9]\+") - CHANNEL=$rect7s - RSCP=$(($(echo $rect8s | cut -d, -f0) / 10)) - ECIO=$(($(echo $rect9s | cut -d, -f0) / 10)) - if [ "$CSQ_PER" = "-" ]; then - CSQ_PER=$((100 - (($RSCP + 31) * 100/-125)))"%" - fi - SINR=$(($(echo $rect10s | cut -d, -f0) / 10))" dB" - fi - w=$(echo $rec |grep "LTE"|grep "EUTRAN"| wc -l) - if [ $w -ge 1 ];then - rec1=${rec#*EUTRAN-} - lte_band=${rec1%%,*} #EUTRAN-BAND - rec1=${rec1#*,} - rec1=${rec1#*,} - rec1=${rec1#*,} - rec1=${rec1#*,} - #rec1=${rec1#*,} - rec1=${rec1#*,} - lte_rssi=${rec1%%,*} #LTE_RSSI - lte_rssi=`expr $lte_rssi / 10` #LTE_RSSI - Debug "LTE_BAND=$lte_band LTE_RSSI=$lte_rssi" - if [ $rssi == 0 ];then - rssi=$lte_rssi - fi - fi - w=$(echo $rec |grep "WCDMA"| wc -l) - if [ $w -ge 1 ];then - w=$(echo $rec |grep "UNKNOWN"|wc -l) - if [ $w -ge 1 ];then - Debug "UNKNOWN BAND" - return - fi - fi - - - - - - - #CNMP - OX=$( sendat $ATPORT "AT+CNMP?") - CNMP=$(echo "$OX" | grep -o "+CNMP:[ ]*[0-9]\{1,3\}" | grep -o "[0-9]\{1,3\}") - if [ -n "$CNMP" ]; then - case $CNMP in - "2"|"55" ) - NETMODE="1" ;; - "13" ) - NETMODE="3" ;; - "14" ) - NETMODE="5" ;; - "38" ) - NETMODE="7" ;; - "71" ) - NETMODE="9" ;; - "109" ) - NETMODE="8" ;; - * ) - NETMODE="0" ;; - esac - fi - - # CMGRMI 信息 - OX=$( sendat $ATPORT "AT+CMGRMI=4") - CAINFO=$(echo "$OX" | grep -o "$REGXz" | tr ' ' ':') - if [ -n "$CAINFO" ]; then - for CASV in $(echo "$CAINFO"); do - LBAND=$LBAND"
      B"$(echo "$CASV" | cut -d, -f4) - BW=$(echo "$CASV" | cut -d, -f5) - decode_bw - LBAND=$LBAND" (CA, Bandwidth $BW MHz)" - CHANNEL="$CHANNEL, "$(echo "$CASV" | cut -d, -f2) - PCI="$PCI, "$(echo "$CASV" | cut -d, -f7) - done - fi - -} diff --git a/luci-app-cpe/root/usr/share/cpe/atcmd.sh b/luci-app-cpe/root/usr/share/cpe/atcmd.sh deleted file mode 100644 index 989adab..0000000 --- a/luci-app-cpe/root/usr/share/cpe/atcmd.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -rec=$(sendat $1 $2) -echo $rec >> /tmp/result.at \ No newline at end of file diff --git a/luci-app-cpe/root/usr/share/cpe/cpedebug b/luci-app-cpe/root/usr/share/cpe/cpedebug deleted file mode 100644 index 16d59fa..0000000 --- a/luci-app-cpe/root/usr/share/cpe/cpedebug +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh - -en=1 #调试开关:0关闭,1打开 ,2输出到文件 -outfile="/tmp/cpe.log" #输出文件 -#日志信息 -Debug() -{ - tim=$(date "+%Y-%m-%d %H:%M:%S") #获取系统时间 - if [ $en == 1 ]; then - echo $tim $1 #打印输出 - elif [ $en == 2 ]; then - echo $tim $1 >> $outfile #输出到文件 - fi -} -ATPORT() -{ - MODEMNAME="ALL" - # ATPORT=$(uci -q get modem.@ndis[0].tyyusb) - lsusb=$( lsusb ) - RDFM650=$(echo "$lsusb" | grep "ID 2cb7:0a05 " | wc -l) - if [ "$RDFM650" == 1 ]; then - ATPORT=0 - MODEMNAME="FM650CN" - else - ATPORT=2 - fi -} \ No newline at end of file diff --git a/luci-app-cpe/root/usr/share/cpe/delatcmd.sh b/luci-app-cpe/root/usr/share/cpe/delatcmd.sh deleted file mode 100644 index dd131f0..0000000 --- a/luci-app-cpe/root/usr/share/cpe/delatcmd.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -rm -f /tmp/result.at \ No newline at end of file diff --git a/luci-app-cpe/root/usr/share/cpe/rssi b/luci-app-cpe/root/usr/share/cpe/rssi deleted file mode 100644 index 0131323..0000000 --- a/luci-app-cpe/root/usr/share/cpe/rssi +++ /dev/null @@ -1,418 +0,0 @@ -#!/bin/sh -source /usr/share/cpe/cpedebug -source /usr/share/cpe/SIMCOM -source /usr/share/cpe/Quectel -source /usr/share/cpe/Fibocom - -#初值化数据结构 -InitData() -{ - Date='' - CHANNEL="-" - ECIO="-" - RSCP="-" - ECIO1=" " - RSCP1=" " - NETMODE="-" - LBAND="-" - PCI="-" - CTEMP="-" - MODE="-" - SINR="-" - IMEI='-' - IMSI='-' - ICCID='-' - phone='-' - conntype='' - Model='' - - -} -#写数据 -SETData() -{ - { - echo $Model #'RM520N-GL' - echo $conntype #'conntype' - echo '1e0e:9001' - echo $COPS #运营商 - echo 'ttyUSB2' #端口 - echo $TEMP #温度 - echo 'QMI' #协议 - echo '---------------------------------' - echo $IMEI #imei - echo $IMSI #imsi - echo $ICCID #iccid - echo $phone #phone - echo '---------------------------------' - - echo $MODE - echo $CSQ - echo $CSQ_PER - echo $CSQ_RSSI - echo $ECIO #参考信号接收质量 RSRQ ecio - echo $ECIO1 #参考信号接收质量 RSRQ ecio1 - echo $RSCP #参考信号接收功率 RSRP rscp0 - echo $RSCP1 #参考信号接收功率 RSRP rscp1 - echo $SINR #信噪比 SINR rv["sinr"] - echo $NETMODE #连接状态监控 rv["netmode"] - echo '---------------------------------' - - - echo $COPS_MCC #MCC - echo $$COPS_MNC #MNC - echo $LAC #eNB ID - echo '' #LAC_NUM - echo $RNC #TAC - echo '' #RNC_NUM - echo $CID - echo '' #CID_NUM - echo $LBAND - echo $CHANNEL - echo $PCI - - echo $Date - - - - echo $MODTYPE - echo $QTEMP - - } > /tmp/cpe_cell.file -} -ATPORT=1 - -# 自动处理模块信号 -AUTO_CPE() -{ - Debug "------------------------------端口$ATPORT---------------------------" - Debug "AUTO_CPE" - Date=$(date "+%Y-%m-%d %H:%M:%S") - - - #检测设备是否准备好 - rec=$(sendat $ATPORT "AT" 500 |grep OK |wc -l) - if [ $rec == "1" ];then - sleep 1s - else - sleep 5s - return - fi - #读取模块信息 - # if [ "$conntype" == "" ]; then - # { - # Debug "计算模块" - # ATATI=$( sendat $ATPORT "ATI") - # Getconntype=$(echo "$ATATI" | sed -n '2p') - # if [ "$Getconntype" == "" ]; then - # { - # sleep 5s - # return - # } - # fi - # Model=$(echo "$ATATI" | sed -n '3p') - # conntype=$Getconntype - # } - # fi - - Debug "读取模块信息 计算模块" - ATATI=$( sendat $ATPORT "ATI") - Getconntype=$(echo "$ATATI" | sed -n '2p') - if [ "$Getconntype" == "" ]; then - { - sleep 5s - return - } - fi - Model=$(echo "$ATATI" | sed -n '3p') - conntype=$Getconntype - - cpin=$( sendat $ATPORT "at+cpin?") - ERR=$(echo "$cpin" | grep "ERROR") - if [ ! -z "$ERR" ]; then # No SIM - Debug "No SIM" - sleep 5s - return - fi - RDY=$(echo "$cpin" | grep "READY") - if [ -z "$RDY" ]; then # SIM Locked - Debug "Correct Pin" - sleep 5s - return - else - Debug "Not Locked" - fi - #执行对应模块 - if [ $(echo $conntype |grep "Quectel"| wc -l) -ge 1 ];then - { - Quectel_AT - } - elif [ $(echo $conntype |grep "SIMCOM"| wc -l) -ge 1 ];then - { - SIMCOM_AT - } - elif [ $(echo $conntype |grep "Fibocom"| wc -l) -ge 1 ];then - { - Fibocom_AT - } - else - { - Debug "null " - } - fi -} -#重新联网 -modem_reset() -{ - - echo "Abnormal network restart" - lsusb=$( lsusb ) - RDFM650=$(echo "$lsusb" | grep "ID 2cb7:0a05 " | wc -l) - echo "RDFM650 $RDFM650" - if [ "$RDFM650" == 1 ]; then - { - GTRNDIS=$(sendat $ATPORT "AT+GTRNDIS=1,1" 500 |grep OK |wc -l) - sleep 2s - } - else - { - start="$( /etc/init.d/modem stop )" - sleep 2s - start="$( /etc/init.d/modem start )" - sleep 5s - } - fi -} -#检测SIM卡是否插入,10次检测不到则重启模块 -check_sim() -{ - while [ 1 ] - do - enabled=$(uci -q get modem.@ndis[0].enabled) - if [ $enabled == '1' ] ;then - echo "Check the sim" - rec=$( sendat 2 "AT+CPIN?") - rec1=$(echo $rec | grep "READY" | wc -l ) - if [ $rec1 == 1 ]; then - x=0 - echo "SIM is READY" - else - let x++ - if [ $x == 10 ]; then - echo "SIM abnormal restart" - modem_reset #重启模块 - x=0 - fi - fi - fi - sleep 6s - done -} -#检测网络状态第一次开机 -chenk_firstdns() -{ - while [ 1 ] - do - enabled=$(uci -q get modem.@ndis[0].enabled) - en1=$(uci -q get modem.@ndis[0].en) - if [ $enabled == '1' ] ;then - if [ $en1 == '1' ] ;then - echo "------------------------------开启任务---------------------------" - ipadd=$(uci -q get modem.@ndis[0].ipaddress) - ping -c 1 -w 1 $ipadd > /dev/null 2>&1 - if [ $? -eq 0 ];then - echo "网络连接正常" - xx=0 - return - else - echo "网络连接异常 $ipadd" - let xx++ - let pxx++ - fi - fi - if [ $xx == 5 ];then - xx=0 - modem_reset - fi - if [ $pxx == 10 ];then - xx=0 - pxx=0 - return - fi - echo "------------------------------结束任务---------------------------" - fi - sleep 1s - done -} -#检测网络状态 -chenk_dns() -{ - en1=$(uci -q get modem.@ndis[0].en) - if [ $en1 == '1' ] ;then - echo "------------------------------开启任务---------------------------" - ipadd=$(uci -q get modem.@ndis[0].ipaddress) - ping -c 1 -w 1 $ipadd > /dev/null 2>&1 - if [ $? -eq 0 ];then - echo "网络连接正常" - xx=0 - else - echo "网络连接异常 $ipadd 次数$xx" - let xx++ - fi - fi - an=$(uci -q get modem.@ndis[0].an) - if [ $xx == $an ];then - xx=0 - modem_reset - fi - echo "------------------------------结束任务---------------------------" - -} -# 信号任务 -chenk_Task() -{ - while [ 1 ] - do - enabled=$(uci -q get modem.@ndis[0].enabled) - if [ $enabled == '1' ] ;then - ATPORT - Debug "------------------------------开启任务---------------------------" - AUTO_CPE - SETData - chenk_dns - Debug "------------------------------结束任务---------------------------" - fi - sleep 10s - done -} - - -#注册网卡 -RegisterNetwork() -{ - # ATPORT - Debug "RegisterNetwork 注册网卡 $ $MODEMNAME" - # if [ "$MODEMNAME" == "FM650CN" ]; then - # getFM650=$(uci -q get network.wwan5g |grep "interface"| wc -l) - # if [ $getFM650 == "0" ] ;then - # uci set network.wwan5g=interface - # uci set network.wwan5g.ifname='usb0' - # uci set network.wwan5g.proto=dhcp - # uci commit network - - # uci set firewall.@zone[1].network="wan wan6 wwan5g wwan5g6 wlan" - # uci commit firewall - - # $(/etc/init.d/network reload) - # fi - # getFM650=$(uci -q get network.wwan5g6|grep "interface"| wc -l) - # if [ $getFM650 == "0" ] ;then - # uci set network.wwan5g6=interface - # uci set network.wwan5g6.ifname='usb0' - # uci set network.wwan5g6.proto='dhcpv6' - # uci set network.wwan5g6.reqaddress='try' - # uci set network.wwan5g6.reqprefix='auto' - # uci set network.wwan5g6._orig_ifname='usb0' - # uci set network.wwan5g6._orig_bridge='false' - # uci set network.wwan5g6.extendprefix='1' - # uci commit network - # uci set firewall.@zone[1].network="wan wan6 wwan wwan5g wwan5g6 wlan" - # uci commit firewall - # $(/etc/init.d/network reload) - # fi - # fi - - - - if [ $(uci -q get network.wwan5g |grep "interface"| wc -l) == "0" ] ;then - uci set network.wwan5g=interface - if [ "$MODEMNAME" == "FM650CN" ]; then - uci set network.wwan5g.ifname='usb0' - else - uci set network.wwan5g.ifname='wwan0' - fi - uci set network.wwan5g.proto=dhcp - uci commit network - uci set firewall.@zone[1].network="wan wan6 wwan5g wwan5g6 wlan" - uci commit firewall - $(/etc/init.d/network reload) - fi - if [ $(uci -q get network.wwan5g6 |grep "interface"| wc -l) == "0" ] ;then - uci set network.wwan5g6=interface - if [ "$MODEMNAME" == "FM650CN" ]; then - uci set network.wwan5g6.ifname='usb0' - uci set network.wwan5g6._orig_ifname='usb0' - else - uci set network.wwan5g6.ifname='wwan0' - uci set network.wwan5g6._orig_ifname='wwan0' - fi - uci set network.wwan5g6.proto='dhcpv6' - uci set network.wwan5g6.reqaddress='try' - uci set network.wwan5g6.reqprefix='auto' - uci set network.wwan5g6._orig_bridge='false' - uci set network.wwan5g6.extendprefix='1' - uci commit network - uci set firewall.@zone[1].network="wan wan6 wwan wwan5g wwan5g6 wlan" - uci commit firewall - $(/etc/init.d/network reload) - fi - if [ "$MODEMNAME" == "FM650CN" ]; then - if [ $(uci -q get network.wwan5g.ifname |grep "usb0"| wc -l) == "0" ] ;then - uci set network.wwan5g.ifname='usb0' - uci commit network - $(/etc/init.d/network reload) - fi - if [ $(uci -q get network.wwan5g6.ifname |grep "usb0"| wc -l) == "0" ] ;then - uci set network.wwan5g6.ifname='usb0' - uci commit network - $(/etc/init.d/network reload) - fi - else - if [ $(uci -q get network.wwan5g.ifname |grep "wwan0"| wc -l) == "0" ] ;then - uci set network.wwan5g.ifname='wwan0' - uci commit network - $(/etc/init.d/network reload) - fi - if [ $(uci -q get network.wwan5g6.ifname |grep "wwan0"| wc -l) == "0" ] ;then - uci set network.wwan5g6._orig_ifname='wwan0' - uci set network.wwan5g6.ifname='wwan0' - uci commit network - $(/etc/init.d/network reload) - fi - fi - - - -} - - - -# 运行入口 -first() -{ - Debug "开启RSSI服务" - # 初值化数据结构 - InitData - Debug "初值化数据完成" - sleep 1s - # 计算模块AT端口号 - ATPORT - # 注册网卡 - RegisterNetwork - # 第一次获取模块信息数据 - AUTO_CPE - # 保存结构数据 - SETData - #开机直接运行网络注册 - modem_reset - # 第一次开机检测是否联网 - chenk_firstdns - chenk_Task -} - -############################################# -# # -# 进入主函数 # -# # -############################################# -first diff --git a/luci-app-gobinetmodem/Makefile b/luci-app-gobinetmodem/Makefile deleted file mode 100644 index 634cff7..0000000 --- a/luci-app-gobinetmodem/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -# -# Copyright (C) 2015 OpenWrt.org -# -# This is free software, licensed under the GNU General Public License v2. -# See /LICENSE for more information. -# - -include $(TOPDIR)/rules.mk - -LUCI_TITLE:=Modem Server -LUCI_DEPENDS:=+luci-compat +quectel-CM-5G +kmod-gobinet \ - +kmod-usb-net-cdc-ether +kmod-usb-net-qmi-wwan \ - +kmod-usb-net-rndis +kmod-usb-serial-option - -include $(TOPDIR)/feeds/luci/luci.mk - -# call BuildPackage - OpenWrt buildroot signature diff --git a/luci-app-gobinetmodem/luasrc/controller/gobinetmodem.lua b/luci-app-gobinetmodem/luasrc/controller/gobinetmodem.lua deleted file mode 100644 index 5b6de85..0000000 --- a/luci-app-gobinetmodem/luasrc/controller/gobinetmodem.lua +++ /dev/null @@ -1,9 +0,0 @@ -module("luci.controller.gobinetmodem", package.seeall) - -function index() - if not nixio.fs.access("/etc/config/gobinetmodem") then - return - end - - entry({"admin", "network", "gobinetmodem"}, cbi("gobinetmodem"), _("Gobinet Modem Server"), 80).dependent = false -end diff --git a/luci-app-gobinetmodem/luasrc/model/cbi/gobinetmodem.lua b/luci-app-gobinetmodem/luasrc/model/cbi/gobinetmodem.lua deleted file mode 100644 index 784130f..0000000 --- a/luci-app-gobinetmodem/luasrc/model/cbi/gobinetmodem.lua +++ /dev/null @@ -1,39 +0,0 @@ --- Copyright 2016 David Thornley --- Licensed to the public under the Apache License 2.0. - -mp = Map("gobinetmodem") -mp.title = translate("gobinet Modem Server") -mp.description = translate("Modem Server For OpenWrt") - -s = mp:section(TypedSection, "service", "Base Setting") -s.anonymous = true - -enabled = s:option(Flag, "enabled", translate("Enable")) -enabled.default = 0 -enabled.rmempty = false - -apn = s:option(Value, "apn", translate("APN")) -apn.rmempty = true - -pincode = s:option(Value, "pincode", translate("PIN")) -pincode.rmempty = true - -username = s:option(Value, "username", translate("PAP/CHAP username")) -username.rmempty = true - -password = s:option(Value, "password", translate("PAP/CHAP password")) -password.rmempty = true - -auth = s:option(Value, "auth", translate("Authentication Type")) -auth.rmempty = true -auth:value("", translate("-- Please choose --")) -auth:value("both", "PAP/CHAP (both)") -auth:value("pap", "PAP") -auth:value("chap", "CHAP") -auth:value("none", "NONE") - -tool = s:option(Value, "tool", translate("Tools")) -tool:value("quectel-CM", "quectel-CM") -tool.rmempty = true - -return mp diff --git a/luci-app-gobinetmodem/po/zh-cn/usbmodem.po b/luci-app-gobinetmodem/po/zh-cn/usbmodem.po deleted file mode 100644 index df1f6df..0000000 --- a/luci-app-gobinetmodem/po/zh-cn/usbmodem.po +++ /dev/null @@ -1,24 +0,0 @@ -msgid "" -msgstr "" -"Project-Id-Version: \n" -"POT-Creation-Date: \n" -"PO-Revision-Date: \n" -"Last-Translator: dingpengyu \n" -"Language-Team: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Language: zh_CN\n" -"X-Generator: Poedit 2.3.1\n" - -msgid "Base Setting" -msgstr "基本设置" - -msgid "gobinet Modem Server" -msgstr "gobinet移动网络拨号服务" - -msgid "Modem Server For OpenWrt" -msgstr "OpenWrt移动网络拨号服务" - -msgid "Tools" -msgstr "拨号工具" diff --git a/luci-app-gobinetmodem/root/etc/config/gobinetmodem b/luci-app-gobinetmodem/root/etc/config/gobinetmodem deleted file mode 100644 index 05fad9b..0000000 --- a/luci-app-gobinetmodem/root/etc/config/gobinetmodem +++ /dev/null @@ -1,4 +0,0 @@ -config service - option tool 'quectel-CM' - option enabled '0' - diff --git a/luci-app-gobinetmodem/root/etc/init.d/gobinetmodem b/luci-app-gobinetmodem/root/etc/init.d/gobinetmodem deleted file mode 100644 index 953ee96..0000000 --- a/luci-app-gobinetmodem/root/etc/init.d/gobinetmodem +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/sh /etc/rc.common -# Copyright (C) 2006-2014 OpenWrt.org - -START=99 -STOP=16 -USE_PROCD=1 -#使用procd启动 - -run_4g() -{ - local enabled - config_get_bool enabled $1 enabled - - echo "run 4G" >> /tmp/log4g - - if [ "$enabled" = "1" ]; then - local user - local password - local apn - local auth - local pincode - local device - local tool - - # echo "enable 4G" >> /tmp/log4g - config_get user $1 user - config_get password $1 password - config_get apn $1 apn - config_get auth $1 auth - config_get pincode $1 pincode - config_get device $1 device - config_get tool $1 tool - config_get tty $1 tty - config_get atcmd $1 atcmd - - devname="$(basename "$device")" - devpath="$(readlink -f /sys/class/usbmisc/$devname/device/)" - ifname="$( ls "$devpath"/net )" - - if [ "$tool" = "at" ];then - at_tool "$atcmd" -d $tty - else - procd_open_instance - #创建一个实例, 在procd看来一个应用程序可以多个实\E4\BE? - #ubus call service list 可以查看实例 - procd_set_param command $tool -i $ifname -s $apn - if [ "$password" != "" ];then - procd_append_param command $user $password $auth - fi - if [ "$pincode" != "" ]; then - procd_append_param command -p $pincode - fi - # procd_append_param command -f /tmp/4g.log - procd_set_param respawn - echo "quectel-CM has started." - procd_close_instance - #关闭实例 - fi - - fi -} - - -service_triggers() -{ - procd_add_reload_trigger "gobinetmodem" -} - -start_service() { - config_load gobinetmodem - config_foreach run_4g service -} - -stop_service() -{ - echo "4G stop" >> /tmp/log4g - killall quectel-CM - echo "quectel-CM has stoped." -} - diff --git a/luci-app-gobinetmodem/root/etc/uci-defaults/luci-gobinetmodem b/luci-app-gobinetmodem/root/etc/uci-defaults/luci-gobinetmodem deleted file mode 100644 index b4b7674..0000000 --- a/luci-app-gobinetmodem/root/etc/uci-defaults/luci-gobinetmodem +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -uci -q batch <<-EOF >/dev/null - delete ucitrack.@gobinetmodem[-1] - add ucitrack gobinetmodem - set ucitrack.@gobinetmodem[-1].init=gobinetmodem - commit ucitrack -EOF - -rm -f /tmp/luci-indexcache -exit 0 diff --git a/luci-app-hypermodem/Makefile b/luci-app-hypermodem/Makefile deleted file mode 100644 index 98dc044..0000000 --- a/luci-app-hypermodem/Makefile +++ /dev/null @@ -1,26 +0,0 @@ -# -# Copyright (C) 2015 OpenWrt.org -# -# This is free software, licensed under the GNU General Public License v2. -# See /LICENSE for more information. -# - -include $(TOPDIR)/rules.mk - -LUCI_TITLE:=Hyper Modem Server -LUCI_DEPENDS:=+luci-compat +kmod-usb-net +kmod-usb-net-cdc-ether +kmod-usb-acm \ - +kmod-usb-net-qmi-wwan +kmod-usb-net-rndis +kmod-usb-serial-qualcomm \ - +kmod-usb-net-sierrawireless +kmod-usb-ohci +kmod-usb-serial \ - +kmod-usb-serial-option +kmod-usb-wdm \ - +kmod-usb2 +kmod-usb3 \ - +kmod-usb-net-cdc-mbim \ - +usbutils \ - +luci-proto-qmi \ - +pciutils \ - +kmod-pcie_mhi \ - +quectel-CM-5G \ - +grep \ - -include $(TOPDIR)/feeds/luci/luci.mk - -# call BuildPackage - OpenWrt buildroot signature diff --git a/luci-app-hypermodem/README.md b/luci-app-hypermodem/README.md deleted file mode 100644 index e6fe7bb..0000000 --- a/luci-app-hypermodem/README.md +++ /dev/null @@ -1,20 +0,0 @@ -# luci-app-hypermodem - -# 目录 - -[一、说明](#一说明) - -# 一、说明 - -原项目地址:https://github.com/momokind/luci-app-hypermodem - -插件功能 - -- 支持USB和PCIe两种通信方式的通信模组 - -- 支持IPv6 - -- 支持高通和紫光展锐两个平台的通信模组 - -- 支持常见厂商的通信模组(例如:移远,广和通等) - diff --git a/luci-app-hypermodem/luasrc/controller/hypermodem.lua b/luci-app-hypermodem/luasrc/controller/hypermodem.lua deleted file mode 100644 index d46e21b..0000000 --- a/luci-app-hypermodem/luasrc/controller/hypermodem.lua +++ /dev/null @@ -1,9 +0,0 @@ -module("luci.controller.hypermodem", package.seeall) - -function index() - if not nixio.fs.access("/etc/config/hypermodem") then - return - end - - entry({"admin", "network", "hypermodem"}, cbi("hypermodem"), _("Hyper Modem Server"), 80).dependent = false -end diff --git a/luci-app-hypermodem/luasrc/model/cbi/hypermodem.lua b/luci-app-hypermodem/luasrc/model/cbi/hypermodem.lua deleted file mode 100644 index 51e5459..0000000 --- a/luci-app-hypermodem/luasrc/model/cbi/hypermodem.lua +++ /dev/null @@ -1,67 +0,0 @@ --- Copyright 2016 David Thornley --- Licensed to the public under the Apache License 2.0. - -mp = Map("hypermodem") -mp.title = translate("Hyper Modem Server") -mp.description = translate("Modem Server For OpenWrt") - -s = mp:section(TypedSection, "service", translate("Base Setting")) -s.anonymous = true - -enabled = s:option(Flag, "enabled", translate("Enable")) -enabled.default = 0 -enabled.rmempty = false - -ipv6 = s:option(Flag, "ipv6", translate("Enable IPv6")) -ipv6.default = 1 -ipv6.rmempty = false - -network_bridge = s:option(Flag, "network_bridge", translate("Enable Network bridge")) -network_bridge.description = translate("After checking, enable network interface bridge.") -network_bridge.default = 0 -network_bridge.rmempty = false - -device = s:option(Value, "device", translate("Modem device")) -device.rmempty = false - -local device_suggestions = nixio.fs.glob("/dev/cdc-wdm*") - -if device_suggestions then - local node - for node in device_suggestions do - device:value(node) - end -end - -apn = s:option(Value, "apn", translate("APN")) -apn.default = "" -apn.rmempty = true -apn:value("", translate("Auto Choose")) -apn:value("cmnet", translate("China Mobile")) -apn:value("3gnet", translate("China Unicom")) -apn:value("ctnet", translate("China Telecom")) -apn:value("cbnet", translate("China Broadcast")) -apn:value("5gscuiot", translate("Skytone")) - -auth = s:option(ListValue, "auth", translate("Authentication Type")) -auth.default = "none" -auth.rmempty = false -auth:value("none", translate("NONE")) -auth:value("both", translate("PAP/CHAP (both)")) -auth:value("pap", "PAP") -auth:value("chap", "CHAP") - -username = s:option(Value, "username", translate("PAP/CHAP Username")) -username.rmempty = true -username:depends("auth", "both") -username:depends("auth", "pap") -username:depends("auth", "chap") - -password = s:option(Value, "password", translate("PAP/CHAP Password")) -password.rmempty = true -password.password = true -password:depends("auth", "both") -password:depends("auth", "pap") -password:depends("auth", "chap") - -return mp diff --git a/luci-app-hypermodem/po/zh-cn/hypermodem.po b/luci-app-hypermodem/po/zh-cn/hypermodem.po deleted file mode 100644 index 383e595..0000000 --- a/luci-app-hypermodem/po/zh-cn/hypermodem.po +++ /dev/null @@ -1,63 +0,0 @@ -msgid "" -msgstr "" -"Project-Id-Version: \n" -"POT-Creation-Date: \n" -"PO-Revision-Date: \n" -"Last-Translator: momokind \n" -"Language-Team: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Language: zh_CN\n" -"X-Generator: Poedit 2.3.1\n" - -msgid "Base Setting" -msgstr "基本设置" - -msgid "Hyper Modem Server" -msgstr "超级移动网络拨号服务" - -msgid "Modem Server For OpenWrt" -msgstr "OpenWrt移动网络拨号服务" - -msgid "Enable IPv6" -msgstr "启用IPv6协商" - -msgid "Enable Network bridge" -msgstr "启用网络桥架" - -msgid "After checking, enable network interface bridge." -msgstr "勾选后,启用网络接口桥接。" - -msgid "APN" -msgstr "接入点" - -msgid "China Mobile" -msgstr "中国移动" - -msgid "China Unicom" -msgstr "中国联通" - -msgid "China Telecom" -msgstr "中国电信" - -msgid "China Broadcast" -msgstr "中国广电" - -msgid "Skytone" -msgstr "天际通" - -msgid "Authentication Type" -msgstr "认证类型" - -msgid "PAP/CHAP (both)" -msgstr "PAP/CHAP (均使用)" - -msgid "NONE" -msgstr "无" - -msgid "PAP/CHAP Username" -msgstr "PAP/CHAP 用户名" - -msgid "PAP/CHAP Password" -msgstr "PAP/CHAP 密码" \ No newline at end of file diff --git a/luci-app-hypermodem/root/etc/config/hypermodem b/luci-app-hypermodem/root/etc/config/hypermodem deleted file mode 100644 index 0e9654e..0000000 --- a/luci-app-hypermodem/root/etc/config/hypermodem +++ /dev/null @@ -1,5 +0,0 @@ -config service - option device '/dev/cdc-wdm0' - option ipv6 '1' - option enabled '0' - diff --git a/luci-app-hypermodem/root/etc/init.d/hypermodem b/luci-app-hypermodem/root/etc/init.d/hypermodem deleted file mode 100755 index b44da18..0000000 --- a/luci-app-hypermodem/root/etc/init.d/hypermodem +++ /dev/null @@ -1,186 +0,0 @@ -#!/bin/sh /etc/rc.common -# Copyright (C) 2006-2014 OpenWrt.org - -START=94 -STOP=13 -USE_PROCD=1 - -#设置防火墙 -# $1:网络接口名称 -set_firewall() -{ - local interface_name="$1" - - local num=$(uci show firewall | grep "name='wan'" | wc -l) - local wwan_num=$(uci -q get firewall.@zone[$num].network | grep -w "${interface_name}" | wc -l) - if [ "$wwan_num" = "0" ]; then - uci add_list firewall.@zone[$num].network="${interface_name}" - fi - uci commit firewall -} - -#设置IPv4网络接口 -# $1:网络接口名称 -# $2:网络接口 -set_ipv4_interface() -{ - local interface_name="$1" - local network_interface="$2" - - #添加或修改网络配置 - uci set network.${interface_name}='interface' - uci set network.${interface_name}.proto='dhcp' - uci set network.${interface_name}.device="${network_interface}" - uci set network.${interface_name}.ifname="${network_interface}" - uci commit network - - #加入WAN防火墙 - set_firewall "${interface_name}" - - #启动网络接口 - ifup "${interface_name}" -} - -#设置IPv6网络接口 -# $1:网络接口名称 -# $2:网络接口 -set_ipv6_interface() -{ - local interface_name="$1" - local network_interface="$2" - - #添加或修改网络配置 - uci set network.${interface_name}='interface' - uci set network.${interface_name}.proto='dhcpv6' - uci set network.${interface_name}.extendprefix='1' - uci set network.${interface_name}.device="${network_interface}" - uci set network.${interface_name}.ifname="${network_interface}" - uci commit network - - #加入WAN防火墙 - set_firewall "${interface_name}" - - #启动网络接口 - ifup "${interface_name}" -} - -#设置IPV4和IPv6网络接口 -# $1:IPV4网络接口名称 -# $2:IPv6网络接口名称 -# $3:网络接口 -set_ipv4v6_interface() -{ - local ipv4_interface_name="$1" - local ipv6_interface_name="$2" - local network_interface="$3" - - #设置IPV4网络接口 - set_ipv4_interface "${ipv4_interface_name}" "${network_interface}" - #设置IPV6网络接口(别名) - set_ipv6_interface "${ipv6_interface_name}" "@${ipv4_interface_name}" -} - -#设置网络接口 -# $2:网络接口 -set_interface() -{ - local network_interface="$1" - - local pdp_type - [ "$ipv6" = "1" ] && { - pdp_type="ipv4v6" - } - - case $pdp_type in - "ipv4") set_ipv4_interface "wwan_5g" "${network_interface}" ;; - "ipv6") set_ipv6_interface "wwan6_5g" "${network_interface}" ;; - "ipv4v6") set_ipv4v6_interface "wwan_5g" "wwan6_5g" "${network_interface}" ;; - *) set_ipv4v6_interface "wwan_5g" "wwan6_5g" "${network_interface}" ;; - esac -} - -run_dial() -{ - local enabled - config_get_bool enabled $1 enabled - - if [ "$enabled" = "1" ]; then - local apn - local user - local password - local auth - local ipv6 - local network_bridge - local device - - config_get apn $1 apn - config_get user $1 user - config_get password $1 password - config_get auth $1 auth - config_get ipv6 $1 ipv6 - config_get network_bridge $1 network_bridge - config_get device $1 device - - devname="$(basename "${device}")" - devicepath="$(find /sys/class/ -name ${devname})" - devpath="$(readlink -f ${devicepath}/device/)" - network="$( ls "${devpath}"/net )" - - #拨号配置 - procd_open_instance - procd_set_param command quectel-CM - if [ "$ipv6" = 1 ]; then - procd_append_param command "-4" "-6" - fi - if [ "$network_bridge" = 1 ]; then - procd_append_param command "-b" - fi - if [ "$apn" != "" ];then - procd_append_param command "-s" "$apn" - fi - if [ "$username" != "" ]; then - procd_append_param command "$username" - fi - if [ "$password" != "" ]; then - procd_append_param command "$password" - fi - if [ "$auth" != "" ]; then - procd_append_param command "$auth" - fi - if [ "$device" != "" ]; then - procd_append_param command -i "$network" - fi - procd_set_param respawn - procd_close_instance - - #设置网络接口 - local network_interface - if [ -d /sys/class/net/rmnet_mhi0 ]; then - network_interface="rmnet_mhi0.1" - elif [ -d /sys/class/net/wwan0_1 ]; then - network_interface="wwan0_1" - elif [ -d /sys/class/net/wwan0.1 ]; then - network_interface="wwan0.1" - elif [ -d /sys/class/net/wwan0 ]; then - network_interface="wwan0" - fi - set_interface "${network_interface}" - fi - - sleep 15 -} - -service_triggers() -{ - procd_add_reload_trigger "hypermodem" -} - -start_service() { - config_load hypermodem - config_foreach run_dial service -} - -stop_service() -{ - killall quectel-CM >/dev/null 2>&1 -} diff --git a/luci-app-hypermodem/root/etc/uci-defaults/luci-hypermodem b/luci-app-hypermodem/root/etc/uci-defaults/luci-hypermodem deleted file mode 100755 index 531e07b..0000000 --- a/luci-app-hypermodem/root/etc/uci-defaults/luci-hypermodem +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -uci -q batch <<-EOF >/dev/null - delete ucitrack.@hypermodem[-1] - add ucitrack hypermodem - set ucitrack.@hypermodem[-1].init=hypermodem - commit ucitrack -EOF - -rm -f /tmp/luci-indexcache -exit 0 diff --git a/luci-app-pcimodem/Makefile b/luci-app-pcimodem/Makefile deleted file mode 100644 index 1bcb748..0000000 --- a/luci-app-pcimodem/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -# -# Copyright (C) 2015 OpenWrt.org -# -# This is free software, licensed under the GNU General Public License v2. -# See /LICENSE for more information. -# - -include $(TOPDIR)/rules.mk - -LUCI_TITLE:=PCI Modem Server -LUCI_DEPENDS:=+kmod-pcie_mhi +pciutils +quectel-CM-5G - -include $(TOPDIR)/feeds/luci/luci.mk - -# call BuildPackage - OpenWrt buildroot signature diff --git a/luci-app-pcimodem/luasrc/controller/pcimodem.lua b/luci-app-pcimodem/luasrc/controller/pcimodem.lua deleted file mode 100644 index e1d3daf..0000000 --- a/luci-app-pcimodem/luasrc/controller/pcimodem.lua +++ /dev/null @@ -1,9 +0,0 @@ -module("luci.controller.pcimodem", package.seeall) - -function index() - if not nixio.fs.access("/etc/config/pcimodem") then - return - end - - entry({"admin", "network", "pcimodem"}, cbi("pcimodem"), _("PCI Modem Server"), 80).dependent = false -end diff --git a/luci-app-pcimodem/luasrc/model/cbi/pcimodem.lua b/luci-app-pcimodem/luasrc/model/cbi/pcimodem.lua deleted file mode 100644 index 258ce66..0000000 --- a/luci-app-pcimodem/luasrc/model/cbi/pcimodem.lua +++ /dev/null @@ -1,39 +0,0 @@ --- Copyright 2016 David Thornley --- Licensed to the public under the Apache License 2.0. - -mp = Map("pcimodem") -mp.title = translate("PCI Modem Server") -mp.description = translate("Modem Server For OpenWrt") - -s = mp:section(TypedSection, "service", "Base Setting") -s.anonymous = true - -enabled = s:option(Flag, "enabled", translate("Enable")) -enabled.default = 0 -enabled.rmempty = false - -apn = s:option(Value, "apn", translate("APN")) -apn.rmempty = true - -pincode = s:option(Value, "pincode", translate("PIN")) -pincode.rmempty = true - -username = s:option(Value, "username", translate("PAP/CHAP username")) -username.rmempty = true - -password = s:option(Value, "password", translate("PAP/CHAP password")) -password.rmempty = true - -auth = s:option(Value, "auth", translate("Authentication Type")) -auth.rmempty = true -auth:value("", translate("-- Please choose --")) -auth:value("both", "PAP/CHAP (both)") -auth:value("pap", "PAP") -auth:value("chap", "CHAP") -auth:value("none", "NONE") - -tool = s:option(Value, "tool", translate("Tools")) -tool:value("quectel-CM", "quectel-CM") -tool.rmempty = true - -return mp diff --git a/luci-app-pcimodem/po/zh-cn/pcimodem.po b/luci-app-pcimodem/po/zh-cn/pcimodem.po deleted file mode 100644 index fea348d..0000000 --- a/luci-app-pcimodem/po/zh-cn/pcimodem.po +++ /dev/null @@ -1,24 +0,0 @@ -msgid "" -msgstr "" -"Project-Id-Version: \n" -"POT-Creation-Date: \n" -"PO-Revision-Date: \n" -"Last-Translator: dingpengyu \n" -"Language-Team: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Language: zh_CN\n" -"X-Generator: Poedit 2.3.1\n" - -msgid "Base Setting" -msgstr "基本设置" - -msgid "PCI Modem Server" -msgstr "PCI移动网络拨号服务" - -msgid "Modem Server For OpenWrt" -msgstr "OpenWrt移动网络拨号服务" - -msgid "Tools" -msgstr "拨号工具" diff --git a/luci-app-pcimodem/root/etc/config/pcimodem b/luci-app-pcimodem/root/etc/config/pcimodem deleted file mode 100644 index 05fad9b..0000000 --- a/luci-app-pcimodem/root/etc/config/pcimodem +++ /dev/null @@ -1,4 +0,0 @@ -config service - option tool 'quectel-CM' - option enabled '0' - diff --git a/luci-app-pcimodem/root/etc/init.d/pcimodem b/luci-app-pcimodem/root/etc/init.d/pcimodem deleted file mode 100644 index f60124f..0000000 --- a/luci-app-pcimodem/root/etc/init.d/pcimodem +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/sh /etc/rc.common -# Copyright (C) 2006-2014 OpenWrt.org - -START=99 -STOP=16 -USE_PROCD=1 -#使用procd启动 - -run_5g() -{ - local enabled - config_get_bool enabled $1 enabled - - echo "run 4G" >> /tmp/log4g - - if [ "$enabled" = "1" ]; then - local user - local password - local apn - local auth - local pincode - local tool - - # echo "enable 5G" >> /tmp/log5g - config_get user $1 user - config_get password $1 password - config_get apn $1 apn - config_get auth $1 auth - config_get pincode $1 pincode - config_get tool $1 tool - config_get tty $1 tty - config_get atcmd $1 atcmd - - if [ "$tool" = "at" ];then - at_tool "$atcmd" -d $tty - else - procd_open_instance - #创建一个实例, 在procd看来一个应用程序可以多个实\E4\BE? - #ubus call service list 可以查看实例 - procd_set_param command $tool -i rmnet_mhi0 -s $apn - if [ "$password" != "" ];then - procd_append_param command $user $password $auth - fi - if [ "$pincode" != "" ]; then - procd_append_param command -p $pincode - fi - # procd_append_param command -f /tmp/4g.log - procd_set_param respawn - echo "quectel-CM has started." - procd_close_instance - #关闭实例 - fi - - fi -} - - -service_triggers() -{ - procd_add_reload_trigger "pcimodem" -} - -start_service() { - config_load pcimodem - config_foreach run_5g service -} - -stop_service() -{ - echo "5G stop" >> /tmp/log5g - killall quectel-CM - echo "quectel-CM has stoped." -} - - diff --git a/luci-app-pcimodem/root/etc/uci-defaults/luci-pcimodem b/luci-app-pcimodem/root/etc/uci-defaults/luci-pcimodem deleted file mode 100644 index 10f5ab8..0000000 --- a/luci-app-pcimodem/root/etc/uci-defaults/luci-pcimodem +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -uci -q batch <<-EOF >/dev/null - delete ucitrack.@pcimodem[-1] - add ucitrack pcimodem - set ucitrack.@pcimodem[-1].init=pcimodem - commit ucitrack -EOF - -rm -f /tmp/luci-indexcache -exit 0 diff --git a/luci-app-sms-tool/LICENSE b/luci-app-sms-tool/LICENSE deleted file mode 100644 index f288702..0000000 --- a/luci-app-sms-tool/LICENSE +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/luci-app-sms-tool/Makefile b/luci-app-sms-tool/Makefile deleted file mode 100644 index db9d2a2..0000000 --- a/luci-app-sms-tool/Makefile +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright (C) 2023 Siriling -# This is free software, licensed under the GNU General Public License v3. - -include $(TOPDIR)/rules.mk - -PKG_NAME:=luci-app-sms-tool -LUCI_TITLE:=LuCI Support for sms_tool -LUCI_PKGARCH:=all -PKG_VERSION:=1.0.0 -PKG_LICENSE:=GPLv3 -PKG_LINCESE_FILES:=LICENSE -PKF_MAINTAINER:=siriling -LUCI_DEPENDS:=+sms-tool +luci-compat +kmod-usb-serial +kmod-usb-serial-option - -define Package/luci-app-sms-tool/postinst -#!/bin/sh -rm -rf /tmp/luci-indexcache -rm -rf /tmp/luci-modulecache/ -/sbin/set_sms_ports.sh -exit 0 -endef - -define Package/$(PKG_NAME)/config -# shown in make menuconfig -help - $(LUCI_TITLE) - Version: $(PKG_VERSION) -endef - -include $(TOPDIR)/feeds/luci/luci.mk - -# call BuildPackage - OpenWrt buildroot signature diff --git a/luci-app-sms-tool/htdocs/luci-static/resources/icons/delsms.png b/luci-app-sms-tool/htdocs/luci-static/resources/icons/delsms.png deleted file mode 100644 index b036e81..0000000 Binary files a/luci-app-sms-tool/htdocs/luci-static/resources/icons/delsms.png and /dev/null differ diff --git a/luci-app-sms-tool/htdocs/luci-static/resources/icons/delsms2.png b/luci-app-sms-tool/htdocs/luci-static/resources/icons/delsms2.png deleted file mode 100644 index eeb13c5..0000000 Binary files a/luci-app-sms-tool/htdocs/luci-static/resources/icons/delsms2.png and /dev/null differ diff --git a/luci-app-sms-tool/luasrc/controller/modem/sms.lua b/luci-app-sms-tool/luasrc/controller/modem/sms.lua deleted file mode 100644 index f807e9e..0000000 --- a/luci-app-sms-tool/luasrc/controller/modem/sms.lua +++ /dev/null @@ -1,242 +0,0 @@ - local util = require "luci.util" - local fs = require "nixio.fs" - local sys = require "luci.sys" - local http = require "luci.http" - local dispatcher = require "luci.dispatcher" - local http = require "luci.http" - local sys = require "luci.sys" - local uci = require "luci.model.uci".cursor() - -module("luci.controller.modem.sms", package.seeall) - -function index() - entry({"admin", "modem"}, firstchild(), "Modem", 30).dependent=false - entry({"admin", "modem", "sms"}, alias("admin", "modem", "sms", "readsms"), translate("短信"), 20) - entry({"admin", "modem", "sms", "readsms"},template("modem/readsms"),translate("收到的信息"), 10) - entry({"admin", "modem", "sms", "sendsms"},template("modem/sendsms"),translate("发送消息"), 20) - entry({"admin", "modem", "sms", "ussd"},template("modem/ussd"),translate("USSD 代码"), 30) - entry({"admin", "modem", "sms", "atcommands"},template("modem/atcommands"),translate("AT 命令"), 40) - entry({"admin", "modem", "sms", "smsconfig"},cbi("modem/smsconfig"),translate("配置"), 50) - entry({"admin", "modem", "sms", "delete_one"}, call("delete_sms", smsindex), nil).leaf = true - entry({"admin", "modem", "sms", "delete_all"}, call("delete_all_sms"), nil).leaf = true - entry({"admin", "modem", "sms", "run_ussd"}, call("ussd"), nil).leaf = true - entry({"admin", "modem", "sms", "run_at"}, call("at"), nil).leaf = true - entry({"admin", "modem", "sms", "run_sms"}, call("sms"), nil).leaf = true - entry({"admin", "modem", "sms", "readsim"}, call("slots"), nil).leaf = true - entry({"admin", "modem", "sms", "countsms"}, call("count_sms"), nil).leaf = true - entry({"admin", "modem", "sms", "user_ussd"}, call("userussd"), nil).leaf = true - entry({"admin", "modem", "sms", "user_atc"}, call("useratc"), nil).leaf = true - entry({"admin", "modem", "sms", "user_phonebook"}, call("userphb"), nil).leaf = true -end - - -function delete_sms(smsindex) -local devv = tostring(uci:get("sms_tool", "general", "readport")) -local s = smsindex -for d in s:gmatch("%d+") do - os.execute("sms_tool -d " .. devv .. " delete " .. d .. "") -end -end - -function delete_all_sms() - local devv = tostring(uci:get("sms_tool", "general", "readport")) - os.execute("sms_tool -d " .. devv .. " delete all") -end - -function get_ussd() - local cursor = luci.model.uci.cursor() - if cursor:get("sms_tool", "general", "ussd") == "1" then - return " -R" - else - return "" - end -end - - -function get_pdu() - local cursor = luci.model.uci.cursor() - if cursor:get("sms_tool", "general", "pdu") == "1" then - return " -r" - else - return "" - end -end - - -function ussd() - local devv = tostring(uci:get("sms_tool", "general", "ussdport")) - - local ussd = get_ussd() - local pdu = get_pdu() - - local ussd_code = http.formvalue("code") - if ussd_code then - local odpall = io.popen("sms_tool -d " .. devv .. ussd .. pdu .. " ussd " .. ussd_code .." 2>&1") - local odp = odpall:read("*a") - odpall:close() - http.write(tostring(odp)) - else - http.write_json(http.formvalue()) - end -end - - -function at() - local devv = tostring(uci:get("sms_tool", "general", "atport")) - - local at_code = http.formvalue("code") - if at_code then - local odpall = io.popen("sms_tool -d " .. devv .. " at " ..at_code:gsub("[$]", "\\\$"):gsub("\"", "\\\"").." 2>&1") - local odp = odpall:read("*a") - odpall:close() - http.write(tostring(odp)) - else - http.write_json(http.formvalue()) - end -end - - -function sms() - local devv = tostring(uci:get("sms_tool", "general", "sendport")) - local sms_code = http.formvalue("scode") - - nr = (string.sub(sms_code, 1, 20)) - msgall = string.sub(sms_code, 21) - msg = string.gsub(msgall, "\n", " ") - - if sms_code then - local odpall = io.popen("sms_tool -d " .. devv .. " send " .. nr .." '".. msg .."'") - local odp = odpall:read("*a") - odpall:close() - http.write(tostring(odp)) - else - http.write_json(http.formvalue()) - end - -end - -function slots() - local sim = { } - local devv = tostring(uci:get("sms_tool", "general", "readport")) - local led = tostring(uci:get("sms_tool", "general", "smsled")) - local dsled = tostring(uci:get("sms_tool", "general", "ledtype")) - local ln = tostring(uci:get("sms_tool", "general", "lednotify")) - - local smsmem = tostring(uci:get("sms_tool", "general", "storage")) - - local statusb = luci.util.exec("sms_tool -s" .. smsmem .. " -d ".. devv .. " status") - local usex = string.sub (statusb, 23, 27) - local max = statusb:match('[^: ]+$') - sim["use"] = string.match(usex, '%d+') - local smscount = string.match(usex, '%d+') - if ln == "1" then - luci.sys.call("echo " .. smscount .. " > /etc/config/sms_count") - if dsled == "S" then - luci.util.exec("/etc/init.d/led restart") - end - if dsled == "D" then - luci.sys.call("echo 0 > '/sys/class/leds/" .. led .. "/brightness'") - end - end - sim["all"] = string.match(max, '%d+') - luci.http.prepare_content("application/json") - luci.http.write_json(sim) -end - - -function count_sms() - os.execute("sleep 3") - local cursor = luci.model.uci.cursor() - if cursor:get("sms_tool", "general", "lednotify") == "1" then - local devv = tostring(uci:get("sms_tool", "general", "readport")) - - local smsmem = tostring(uci:get("sms_tool", "general", "storage")) - - local statusb = luci.util.exec("sms_tool -s" .. smsmem .. " -d ".. devv .. " status") - local smsnum = string.sub (statusb, 23, 27) - local smscount = string.match(smsnum, '%d+') - os.execute("echo " .. smscount .. " > /etc/config/sms_count") - end -end - - -function uussd(rv) - local c = nixio.fs.access("/etc/config/ussd.user") and - io.popen("cat /etc/config/ussd.user") - - if c then - for l in c:lines() do - local i = l - if i then - rv[#rv + 1] = { - usd = i - } - end - end - c:close() - end -end - - - -function userussd() - local usd = { } - uussd(usd) - luci.http.prepare_content("application/json") - luci.http.write_json(usd) -end - - -function uat(rv) - local c = nixio.fs.access("/etc/config/atcmds.user") and - io.popen("cat /etc/config/atcmds.user") - - if c then - for l in c:lines() do - local i = l - if i then - rv[#rv + 1] = { - atu = i - } - end - end - c:close() - end -end - - - -function useratc() - local atu = { } - uat(atu) - luci.http.prepare_content("application/json") - luci.http.write_json(atu) -end - - - -function uphb(rv) - local c = nixio.fs.access("/etc/config/phonebook.user") and - io.popen("cat /etc/config/phonebook.user") - - if c then - for l in c:lines() do - local i = l - if i then - rv[#rv + 1] = { - phb = i - } - end - end - c:close() - end -end - - - -function userphb() - local phb = { } - uphb(phb) - luci.http.prepare_content("application/json") - luci.http.write_json(phb) -end diff --git a/luci-app-sms-tool/luasrc/model/cbi/modem/smsconfig.lua b/luci-app-sms-tool/luasrc/model/cbi/modem/smsconfig.lua deleted file mode 100644 index dc756e5..0000000 --- a/luci-app-sms-tool/luasrc/model/cbi/modem/smsconfig.lua +++ /dev/null @@ -1,226 +0,0 @@ -local util = require "luci.util" -local fs = require "nixio.fs" -local sys = require "luci.sys" -local http = require "luci.http" -local dispatcher = require "luci.dispatcher" -local http = require "luci.http" -local sys = require "luci.sys" -local uci = require "luci.model.uci".cursor() - -local USSD_FILE_PATH = "/etc/config/ussd.user" -local PHB_FILE_PATH = "/etc/config/phonebook.user" -local SMSC_FILE_PATH = "/etc/config/smscommands.user" -local AT_FILE_PATH = "/etc/config/atcmds.user" - -local led = tostring(uci:get("sms_tool", "general", "smsled")) -local dsled = tostring(uci:get("sms_tool", "general", "ledtype")) -local ledtime = tostring(uci:get("sms_tool", "general", "checktime")) - -local m -local s -local dev1, dev2, dev3, dev4, leds -local try_devices1 = nixio.fs.glob("/dev/tty[A-Z][A-Z]*") -local try_devices2 = nixio.fs.glob("/dev/tty[A-Z][A-Z]*") -local try_devices3 = nixio.fs.glob("/dev/tty[A-Z][A-Z]*") -local try_devices4 = nixio.fs.glob("/dev/tty[A-Z][A-Z]*") -local try_leds = nixio.fs.glob("/sys/class/leds/*") - - -local devv = tostring(uci:get("sms_tool", "general", "readport")) - -local smsmem = tostring(uci:get("sms_tool", "general", "storage")) - -local statusb = luci.util.exec("sms_tool -s".. smsmem .. " -d ".. devv .. " status") - -local smsnum = string.sub (statusb, 23, 27) - -local smscount = string.match(smsnum, '%d+') - -m = Map("sms_tool", translate("配置短信工具"), - translate("sms_tool和gui应用程序的配置面板。")) - -s = m:section(NamedSection, 'general' , "sms_tool" , "" .. translate("")) -s.anonymous = true -s:tab("sms", translate("SMS 设置")) -s:tab("ussd", translate("USSD 代码设置")) -s:tab("at", translate("AT 命令设置")) -s:tab("info", translate("通知设置")) - -this_tab = "sms" - -dev1 = s:taboption(this_tab, Value, "readport", translate("短信读取端口")) -if try_devices1 then -local node -for node in try_devices1 do -dev1:value(node, node) -end -end - -mem = s:taboption(this_tab, ListValue, "storage", translate("信息存储区"), translate("信息存储在一个特定的位置(例如,在SIM卡或调制解调器内存),但根据设备的类型,其他区域也可能是可用的。")) -mem.default = "SM" -mem:value("SM", translate("SIM 卡")) -mem:value("ME", translate("调制解调器内存")) -mem.rmempty = true - -local msm = s:taboption(this_tab, Flag, "mergesms", translate("合并分割的信息"), translate("勾选这个选项会使阅读信息更容易,但会导致显示和接收的信息数量不一致。")) -msm.rmempty = false - -dev2 = s:taboption(this_tab, Value, "sendport", translate("短信发送端口")) -if try_devices2 then -local node -for node in try_devices2 do -dev2:value(node, node) -end -end - -local t = s:taboption(this_tab, Value, "pnumber", translate("前缀号码"), translate("电话号码的前面应该有国家的前缀(波兰是48,没有'+')。如果号码是5个、4个或3个字符,它将被视为 '短',不应该在前面加上国家前缀。")) -t.rmempty = true -t.default = 48 - -local f = s:taboption(this_tab, Flag, "prefix", translate("为电话号码添加前缀"), translate("自动添加电话号码字段的前缀。")) -f.rmempty = false - - -local i = s:taboption(this_tab, Flag, "information", translate("号码和前缀的解释"), translate("在发送短信的标签中,显示前缀的解释和正确的电话号码。")) -i.rmempty = false - -local ta = s:taboption(this_tab, TextValue, "user_phonebook", translate("用户电话簿"), translate("每一行必须有以下格式。'联系人姓名;电话号码'。保存到文件'/etc/config/phonebook.user'。")) -ta.rows = 7 -ta.rmempty = false - -function ta.cfgvalue(self, section) - return fs.readfile(PHB_FILE_PATH) -end - -function ta.write(self, section, value) - value = value:gsub("\r\n", "\n") - fs.writefile(PHB_FILE_PATH, value) -end - -this_taba = "ussd" - -dev3 = s:taboption(this_taba, Value, "ussdport", translate("USSD发送端口")) -if try_devices3 then -local node -for node in try_devices3 do -dev3:value(node, node) -end -end - -local u = s:taboption(this_taba, Flag, "ussd", translate("以纯文本发送USSD代码"), translate("以纯文本发送USSD代码。命令没有被编码到PDU中。")) -u.rmempty = false - -local p = s:taboption(this_taba, Flag, "pdu", translate("接收没有PDU解码的信息"), translate("接收并显示消息,而不将其解码为PDU。")) -p.rmempty = false - -local tb = s:taboption(this_taba, TextValue, "user_ussd", translate("用户USSD代码"), translate("每一行必须有以下格式。'代码名称;代码'。保存到文件'/etc/config/ussd.user'。")) -tb.rows = 7 -tb.rmempty = true - -function tb.cfgvalue(self, section) - return fs.readfile(USSD_FILE_PATH) -end - -function tb.write(self, section, value) - value = value:gsub("\r\n", "\n") - fs.writefile(USSD_FILE_PATH, value) -end - -this_tabc = "at" - -dev4 = s:taboption(this_tabc, Value, "atport", translate("AT命令的发送端口")) -if try_devices4 then -local node -for node in try_devices4 do -dev4:value(node, node) -end -end - -local tat = s:taboption(this_tabc, TextValue, "user_at", translate("用户AT命令"), translate("每一行必须有以下格式。'AT命令名称;AT命令'。保存到文件'/etc/config/atcmds.user'。")) -tat.rows = 20 -tat.rmempty = true - -function tat.cfgvalue(self, section) - return fs.readfile(AT_FILE_PATH) -end - -function tat.write(self, section, value) - value = value:gsub("\r\n", "\n") - fs.writefile(AT_FILE_PATH, value) -end - -this_tabb = "info" - -local uw = s:taboption(this_tabb, Flag, "lednotify", translate("通知新消息"), translate("LED通知有新的信息。在激活这个功能之前,请配置并保存短信阅读端口,检查短信收件箱的时间,并选择通知LED。")) -uw.rmempty = false - -function uw.write(self, section, value) -if devv ~= nil or devv ~= '' then -if ( smscount ~= nil and led ~= nil ) then - if value == '1' then - - luci.sys.call("echo " .. smscount .. " > /etc/config/sms_count") - luci.sys.call("uci set sms_tool.general.lednotify=" .. 1 .. ";/etc/init.d/smsled enable;/etc/init.d/smsled start") - luci.sys.call("/sbin/cronsync.sh") - - elseif value == '0' then - luci.sys.call("uci set sms_tool.general.lednotify=" .. 0 .. ";/etc/init.d/smsled stop;/etc/init.d/smsled disable") - if dsled == 'D' then - luci.sys.call("echo 0 > '/sys/class/leds/" .. led .. "/brightness'") - end - luci.sys.call("/sbin/cronsync.sh") - - end -return Flag.write(self, section ,value) - end -end -end - -local time = s:taboption(this_tabb, Value, "checktime", translate("每(几)分钟检查一次收件箱"), translate("指定你想在多少分钟内检查你的收件箱。")) -time.rmempty = false -time.maxlength = 2 -time.default = 5 - -function time.validate(self, value) - if ( tonumber(value) < 60 and tonumber(value) > 0 ) then - return value - end -end - -sync = s:taboption(this_tabb, ListValue, "prestart", translate("每隔一段时间重新启动收件箱检查程序"), translate("该过程将在选定的时间间隔内重新启动。这将消除检查收件箱的延迟。")) -sync.default = "6" -sync:value("4", translate("4h")) -sync:value("6", translate("6h")) -sync:value("8", translate("8h")) -sync:value("12", translate("12h")) -sync.rmempty = true - - -leds = s:taboption(this_tabb, Value, "smsled", translate("通知LED"), translate("选择通知LED。")) -if try_leds then -local node -local status -for node in try_leds do -local status = node -local all = string.sub (status, 17) -leds:value(all, all) -end -end - -oled = s:taboption(this_tabb, ListValue, "ledtype", translate("该二极管只专门用于这些通知"), translate("如果路由器只有一个LED,或者LED是多任务的,就选'No'。")) -oled.default = "D" -oled:value("S", translate("No")) -oled:value("D", translate("Yes")) -oled.rmempty = true - -local timeon = s:taboption(this_tabb, Value, "ledtimeon", translate("每(几)秒打开LED灯"), translate("指定LED应该亮多长时间。")) -timeon.rmempty = false -timeon.maxlength = 3 -timeon.default = 1 - -local timeoff = s:taboption(this_tabb, Value, "ledtimeoff", translate("每(几)秒关闭LED灯"), translate("指定LED应该关闭多长时间。")) -timeoff.rmempty = false -timeoff.maxlength = 3 -timeoff.default = 5 - -return m diff --git a/luci-app-sms-tool/luasrc/view/modem/atcommands.htm b/luci-app-sms-tool/luasrc/view/modem/atcommands.htm deleted file mode 100644 index 3510d8b..0000000 --- a/luci-app-sms-tool/luasrc/view/modem/atcommands.htm +++ /dev/null @@ -1,136 +0,0 @@ -<%+header%> - - - -

      <%:AT 命令%>

      -
      <%:通过sms_tool处理AT命令的Web用户界面。关于sms-tool的更多信息,请见%> <%:eko.one.pl 论坛%>.
      -

      -

      <%:向调制解调器发送命令%>

      -
      - -
      -
      <%:用户AT命令%>:
      - -
      - -
      -
      -
      - -
      -
      <%:要发送的命令%>:
      -
      -
      - -
      - -
      -
      <%:回复%>: -

      -

      - -
      -
      -
      - -
      - - - -<%+footer%> - diff --git a/luci-app-sms-tool/luasrc/view/modem/readsms.htm b/luci-app-sms-tool/luasrc/view/modem/readsms.htm deleted file mode 100644 index dc8245e..0000000 --- a/luci-app-sms-tool/luasrc/view/modem/readsms.htm +++ /dev/null @@ -1,285 +0,0 @@ -<% - local util = require "luci.util" - local fs = require "nixio.fs" - local sys = require "luci.sys" - local http = require "luci.http" - local dispatcher = require "luci.dispatcher" - local uci = require "luci.model.uci".cursor() - - local devv = tostring(uci:get("sms_tool", "general", "readport")) - local smsmem = tostring(uci:get("sms_tool", "general", "storage")) - local sms = tostring(luci.sys.exec("sms_tool -s" .. smsmem .. " -d " .. devv .. " -f '%Y-%m-%d %H:%M' -j recv 2>/dev/null")) - local smsmer = tostring(uci:get("sms_tool", "general", "mergesms")) - local smscuta = string.sub (sms, 8) - local smscut = smscuta:sub(1, #smscuta - 2) - local statusb = luci.util.exec("sms_tool -s" .. smsmem .. " -d ".. devv .. " status") - local all = statusb:match('[^: ]+$') - local location = "" - local l = string.sub (statusb, 15, 16) - if l == "SM" then - location = translate("SIM card") - end - if l == "ME" then - location = translate("Modem memory") - end --%> - -<%+header%> - - - - - - - -

      <%:短信%>

      -
      <%:通过sms_tool接收信息的Web用户界面。关于短信工具的更多信息,请见%> <%:eko.one.pl 论坛%>
      -

      -

      <%:接收的信息%>

      -
      -
      <%:信息存储在%>:
      <%=location%>
      -
      <%:信息 (收件箱 / 最大值)%>:
      -
      - - - - - - - - - - -
      <%:来自%><%:收到%><%:信息%>
      - -
      -
      - -
      -
      -     - -
      -
      - -<%+footer%> diff --git a/luci-app-sms-tool/luasrc/view/modem/sendsms.htm b/luci-app-sms-tool/luasrc/view/modem/sendsms.htm deleted file mode 100644 index f9747c6..0000000 --- a/luci-app-sms-tool/luasrc/view/modem/sendsms.htm +++ /dev/null @@ -1,237 +0,0 @@ -<% - local util = require "luci.util" - local sys = require "luci.sys" - local uci = require "luci.model.uci".cursor() - - local pon = tostring(uci:get("sms_tool", "general", "prefix")) - local pnumber = tostring(uci:get("sms_tool", "general", "pnumber")) - local info = tostring(uci:get("sms_tool", "general", "information")) - --%> - -<%+header%> - - - - - - - - -

      <%:短信%>

      -
      <%:通过sms_tool发送信息的Web用户界面。关于短信工具的更多信息,请见%> <%:eko.one.pl 论坛%>.
      -

      - -

      <%:发送短信%>

      - -
      - -
      -
      <%:用户电话簿%>:
      -
      - - -
      -
      -
      - -
      -
      <%:发送至%>:
      -
      -
      -
      -
      -
      <%:消息正文%>:
      -
      160
      -
      -
      - -
      -
      <%:状态%>:
      - -
      - -
      -
      - -
      -
      -
      - -
      - - - -<%+footer%> diff --git a/luci-app-sms-tool/luasrc/view/modem/ussd.htm b/luci-app-sms-tool/luasrc/view/modem/ussd.htm deleted file mode 100644 index 38be1c3..0000000 --- a/luci-app-sms-tool/luasrc/view/modem/ussd.htm +++ /dev/null @@ -1,265 +0,0 @@ -<% - local util = require "luci.util" - local fs = require "nixio.fs" - local sys = require "luci.sys" - local http = require "luci.http" - local dispatcher = require "luci.dispatcher" - local uci = require "luci.model.uci".cursor() - --%> - - -<%+header%> - - - -

      <%:USSD 代码%>

      -
      <%:通过sms_tool处理USSD代码的Web用户界面。关于短信工具的更多信息,请见%> <%:eko.one.pl forum%>.
      -

      -

      <%:发送 USSD 代码%>

      -
      - -
      -
      <%:用户 USSD 代码%>:
      - -
      - -
      -
      -
      - -
      -
      <%:要发送的代码%>:
      -
      - -
      -
      -
      <%:回复%>:
      - -
      -
      - -
      -
      -
      -
      - -
      - - - -<%+footer%> diff --git a/luci-app-sms-tool/po/pl/sms-tool.po b/luci-app-sms-tool/po/pl/sms-tool.po deleted file mode 100644 index 2ef0778..0000000 --- a/luci-app-sms-tool/po/pl/sms-tool.po +++ /dev/null @@ -1,288 +0,0 @@ -msgid "" -msgstr "Content-Type: text/plain; charset=UTF-8" - -"Language: pl\n" -"Last-Translator: Rafał Wabik (IceG) - From eko.one.pl forum\n" - -msgid "SMS Messages" -msgstr "Wiadomości SMS" - -msgid "Received Messages" -msgstr "Odebrane wiadomości" - -msgid "Send Messages" -msgstr "Wysyłanie wiadomości" - -msgid "USSD" -msgstr "USSD" - -msgid "From" -msgstr "Nadawca" - -msgid "Received" -msgstr "Odebrano" - -msgid "Message" -msgstr "Wiadomość" - -msgid "Configuration" -msgstr "Ustawienia" - -msgid "Sample codes" -msgstr "Przykładowe kody" - -msgid "Sending USSD codes" -msgstr "Wysyłanie kodów USSD" - -msgid "Please enter phone number" -msgstr "Proszę podać numer telefonu" - -msgid "Please correct phone number" -msgstr "Proszę poprawić numer telefonu" - -msgid "Please enter a message text" -msgstr "Proszę podać treść wiadomości" - -msgid "Please select the message(s) to be deleted" -msgstr "Proszę wybrać wiadomość(-ci) do usunięcia" - -msgid "Reply" -msgstr "Odpowiedź" - -msgid "SMS sent sucessfully" -msgstr "SMS został wysłany" - -msgid "Please enter a USSD code" -msgstr "Proszę podać kod do wysłania" - -msgid "Delete selected message(s)?" -msgstr "Usunąć wybraną(-e) wiadomość(-ci)?" - -msgid "Delete all the messages?" -msgstr "Usunąć wszystkie wiadomości?" - -msgid "Configuration sms-tool" -msgstr "Konfiguracja sms-tool" - -msgid "Configuration panel for sms_tool and gui application." -msgstr "Panel ustawień dla aplikacji sms_tool oraz dla interfejsu użytkownika." - -msgid "Device" -msgstr "Urządzenie" - -msgid "Web UI for handling messages via sms_tool." -msgstr "Interfejs użytkownika dla sms_tool do obsługi wiadomości SMS." - -msgid "Web UI for handling USSD codes via sms_tool." -msgstr "Interfejs użytkownika dla sms_tool do obsługi kodów USSD." - -msgid "SIM card" -msgstr "Karta SIM" - -msgid "Modem memory" -msgstr "Pamięć modemu" - -msgid "Messages store in" -msgstr "Miejsce przechowywania wiadomości" - -msgid "Messages (Inbox / Maximum)" -msgstr "Wiadomości (Odebrane / Maksymalnie)" - -msgid "Delete Selected" -msgstr "Usuń wybraną" - -msgid "Delete message(s)" -msgstr "Usuń wiadomość(-ci)" - -msgid "Delete All" -msgstr "Usuń wszystkie" - -msgid "USSD Codes" -msgstr "Kody USSD" - -msgid "Send to" -msgstr "Wyślij do" - -msgid "Message text" -msgstr "Treść wiadomości" - -msgid "Send Message" -msgstr "Wyślij SMS" - -msgid "Code to send" -msgstr "Kod do wysłania" - -msgid "Send Code" -msgstr "Wyślij kod" - -msgid "SMS Settings" -msgstr "Ustawienia dla wiadomości SMS" - -msgid "USSD Codes Settings" -msgstr "Ustawienia dla kodów USSD" - -msgid "SMS Reading Port" -msgstr "Port do odczytu SMS" - -msgid "SMS Sending Port" -msgstr "Port do wysyłania SMS" - -msgid "USSD Sending Port" -msgstr "Port do wysyłania kodów USSD" - -msgid "Add Prefix to Phone Number" -msgstr "Dodaj prefiks do numeru telefonu" - -msgid "Automatically add prefix to the phone number field." -msgstr "Automatycznie uzupełnij pole numeru telefonu o prefiks." - -msgid "Prefix Number" -msgstr "Numer prefiks" - -msgid "PHONE_NUMBER" -msgstr "48NumerTelefonu" - -msgid "Refresh SMS" -msgstr "Odśwież" - -msgid "Sending USSD Code in plain text" -msgstr "Wysyłaj kod USSD jawnym tekstem" - -msgid "Receive message without PDU decoding" -msgstr "Odbierz wiadomość bez dekodowania jej jako PDU" - -msgid "Send the USSD code in plain text. Command is not being coded to the PDU." -msgstr "Wysyła kod USSD jawnym tekstem. Polecenie nie jest dekodowane na PDU." - -msgid "Receive and display the message without decoding it as a PDU." -msgstr "Odebrana wiadomość wyświetlana jest bez dekodowania jej jako PDU." - -msgid "Explanation of number and prefix" -msgstr "Wyjaśnienie dot. numeru i prefiksu" - -msgid "In the tab for sending SMSes, show an explanation of the prefix and the correct phone number." -msgstr "W zakładce umożliwiającej wysyłanie SMS-ów pokaż wyjaśnienie dotyczące prefiksu i poprawnego numeru telefonu." - -msgid "The phone number should be preceded by the country prefix (for Poland it is 48, without '+'). If the number is 5, 4 or 3 characters, it is treated as 'short' and should not be preceded by a country prefix." -msgstr "Numer telefonu należy poprzedzić prefiksem kraju (dla Polski jest to 48, bez znaku '+'). Jeżeli numer jest 5, 4 lub 3 znakowy to jest on traktowany jako 'krótki' i nie należy go poprzedzać prefiksem kraju." - -msgid "The phone number should be preceded by the country prefix (for Poland it is 48, without +). If the number is 5, 4 or 3 characters, it is treated as.. short and should not be preceded by a country prefix." -msgstr "Numer telefonu należy poprzedzić prefiksem kraju (dla Polski jest to 48, bez znaku +). Jeżeli numer jest 5, 4 lub 3 znakowy to jest on traktowany jako krótki i nie należy go poprzedzać prefiksem kraju." - -msgid "Each line must have the following format: 'Contact name;Phone number'. Save to file '/etc/config/phonebook.user'." -msgstr "Każda linijka powinna mieć następujący format: 'Nazwa kontaktu;Numer telefonu'. Dla wygody kontakty użytkownika zapisywane są w pliku '/etc/config/phonebook.user'." - -msgid "User Phonebook" -msgstr "Kontakty użytkownika" - -msgid "User USSD Codes" -msgstr "Kody USSD użytkownika" - -msgid "Each line must have the following format: 'Code name;Code'. Save to file '/etc/config/ussd.user'." -msgstr "Każda linijka powinna mieć następujący format: 'Etykieta kodu;Kod'. Dla wygody kody użytkownika zapisywane są w pliku '/etc/config/ussd.user'." - -msgid "Notification Settings" -msgstr "Ustawienia powiadomień" - -msgid "The LED informs about a new message. Before activating this function, please config and save the SMS reading port, time to check SMS inbox and select the notification LED." -msgstr "Powiadomienie diodą o nowej wiadomości. Przed uruchomieniem tej funkcji proszę ustawić port odczytu wiadomości, czas sprawdzania skrzynki odbiorczej oraz wybrać diodę powiadomień." - -msgid "Check inbox every minute(s)" -msgstr "Sprawdzaj skrzynkę odbiorczą co minut(-y)" - -msgid "Specify how many minutes you want your inbox to be checked." -msgstr "Podaj co ile minut ma być sprawdzana skrzynka odbiorcza w poszukiwaniu nowych wiadomości." - -msgid "Notification LED" -msgstr "Dioda powiadomień" - -msgid "Select the notification LED." -msgstr "Wybierz diodę powiadomień." - -msgid "Notify new messages" -msgstr "Powiadomienie o nowych wiadomościach" - -msgid "Turn on the LED for seconds(s)" -msgstr "Włącz diodę na sekund(-y)" - -msgid "Turn off the LED for seconds(s)" -msgstr "Wyłącz diodę na sekund(-y)" - -msgid "Specify for how long the LED should be on." -msgstr "Podaj przez jaki czas dioda ma być włączona." - -msgid "Specify for how long the LED should be off." -msgstr "Podaj przez jaki czas dioda ma być wyłączona." - -msgid "Merge split messages" -msgstr "Połącz podzielone wiadomości" - -msgid "Checking this option will make it easier to read the messages, but it will cause a discrepancy in the number of messages shown and received." -msgstr "Podzielone wiadomości zostaną złączone. Zaznaczenie tej opcji ułatwi czytanie SMS-ów, ale spowoduje niezgodność w ilości pokazanych, odebranych wiadomości." - -msgid "Message storage area" -msgstr "Miejsce przechowywania wiadomości" - -msgid "Messages are stored in a specific location (for example, on the SIM card or modem memory), but other areas may also be available depending on the type of device." -msgstr "Wiadomości przechowywane są w określonym miejscu (np. na karcie SIM lub pamięci modemu), ale w zależności od typu urządzenia mogą być dostępne także inne obszary." - -msgid "AT Commands" -msgstr "Polecenia AT" - -msgid "Web UI for handling AT commands via sms_tool." -msgstr "Interfejs użytkownika dla sms_tool do obsługi poleceń AT." - -msgid "Sending commands to modem" -msgstr "Wysyłanie poleceń do modemu" - -msgid "User AT Commands" -msgstr "Polecenia AT użytkownika" - -msgid "Command to send" -msgstr "Polecenie do wysłania" - -msgid "Please enter a AT Command" -msgstr "Proszę podać polecenie AT do wysłania" - -msgid "AT Commands Sending Port" -msgstr "Port do wysyłania poleceń AT" - -msgid "Send Command" -msgstr "Wyślij polecenie" - -msgid "AT Commands Settings" -msgstr "Ustawienia dla poleceń AT" - -msgid "Each line must have the following format: 'AT Command name;AT Command'. Save to file '/etc/config/atcmds.user'." -msgstr "Każda linijka powinna mieć następujący format: 'Etykieta polecenia;polecenie AT'. Dla wygody polecenia użytkownika zapisywane są w pliku '/etc/config/atcmds.user'." - -msgid "Restart the inbox checking process every" -msgstr "Uruchom proces ponownie po" - -msgid "The process will restart at the selected time interval. This will eliminate the delay in checking your inbox." -msgstr "Proces zostanie uruchomiony ponownie po wybranym przez użytkownika czasie. Pozwoli to wyeliminować opóźnienie w sprawdzaniu skrzynki odbiorczej." - -msgid "4h" -msgstr "4 godz." - -msgid "6h" -msgstr "6 godz." - -msgid "8h" -msgstr "8 godz." - -msgid "12h" -msgstr "12 godz." - -msgid "The diode is dedicated only to these notifications" -msgstr "Dioda jest dedykowana tylko tym powiadomieniom" - -msgid "Select 'No' in case the router has only one LED or if the LED is multi-tasking." -msgstr "Wybierz 'Nie' w przypadku, kiedy router ma tylko jedną diodę lub gdy dioda obsługuje wiele zadań." - -msgid "No" -msgstr "Nie" - -msgid "Yes" -msgstr "Tak" - diff --git a/luci-app-sms-tool/po/zh-cn/sms-tool.po b/luci-app-sms-tool/po/zh-cn/sms-tool.po deleted file mode 100644 index 4417c9c..0000000 --- a/luci-app-sms-tool/po/zh-cn/sms-tool.po +++ /dev/null @@ -1,246 +0,0 @@ -msgid "Modem" -msgstr "调制解调器" - -msgid "SMS Messages" -msgstr "SMS 信息" - -msgid "Received Messages" -msgstr "接收信息" - -msgid "Send Messages" -msgstr "发送信息" - -msgid "From" -msgstr "发件人" - -msgid "Received" -msgstr "接收时间" - -msgid "Message" -msgstr "信息" - -msgid "Configuration" -msgstr "参数配置" - -msgid "Sample codes" -msgstr "代码样本" - -msgid "Please enter phone number" -msgstr "请输入手机号" - -msgid "Please correct phone number" -msgstr "请更正手机号" - -msgid "Please enter a message text" -msgstr "请输入信息内容" - -msgid "Please select the message(s) to be deleted" -msgstr "请选择要删除的信息" - -msgid "Reply" -msgstr "回复" - -msgid "SMS sent sucessfully" -msgstr "信息发送成功" - -msgid "Delete selected message(s)?" -msgstr "删除选择的信息?" - -msgid "Delete all the messages?" -msgstr "删除所有信息?" - -msgid "Configuration sms-tool" -msgstr "配置 sms-tool" - -msgid "Configuration panel for sms_tool and gui application." -msgstr "sms_tool 和 gui 应用程序的配置面板." - -msgid "Device" -msgstr "设备" - -msgid "Web UI for handling messages via sms_tool." -msgstr "用于通过 sms_tool 处理信息的 Web UI." - -msgid "Web UI for sending messages via sms_tool." -msgstr "用于通过 sms_tool 发送信息的 Web UI." - -msgid "Web UI for receiveling messages via sms_tool." -msgstr "用于通过 sms_tool 接收信息的 Web UI." - -msgid "SIM card" -msgstr "SIM卡" - -msgid "Modem memory" -msgstr "Modem内存" - -msgid "Messages store in" -msgstr "信息存储在" - -msgid "Messages (Inbox / Maximum)" -msgstr "信息(收件箱/最大)" - -msgid "Delete Selected" -msgstr "删除所选" - -msgid "Delete message(s)" -msgstr "删除信息" - -msgid "Delete All" -msgstr "删除所有" - -msgid "Send to" -msgstr "发送到" - -msgid "Message text" -msgstr "信息文本" - -msgid "Send Message" -msgstr "发送信息" - -msgid "Code to send" -msgstr "代码发送" - -msgid "Send Code" -msgstr "发送代码" - -msgid "SMS Settings" -msgstr "SMS 设置" - -msgid "SMS Reading Port" -msgstr "SMS 读取端口" - -msgid "SMS Sending Port" -msgstr "SMS 发送端口" - -msgid "Add Prefix to Phone Number" -msgstr "为手机号码添加前缀" - -msgid "Automatically add prefix to the phone number field." -msgstr "自动为手机号码字段添加前缀." - -msgid "Prefix Number" -msgstr "前缀编号" - -msgid "PHONE_NUMBER" -msgstr "手机号码" - -msgid "Refresh SMS" -msgstr "刷新信息" - -msgid "Explanation of number and prefix" -msgstr "数字和前缀的解释" - -msgid "In the tab for sending SMSes, show an explanation of the prefix and the correct phone number." -msgstr "在发送短信的选项卡中,显示前缀说明和正确的电话号码." - -msgid "The phone number should be preceded by the country prefix (for Poland it is 48, without '+'). If the number is 5, 4 or 3 characters, it is treated as 'short' and should not be preceded by a country prefix." -msgstr "电话号码前面应有国家/地区前缀(中国为 86,不带“+”), 号码是 5、4 或 3 个字符的短号除外." - -msgid "The phone number should be preceded by the country prefix (for Poland it is 48, without +). If the number is 5, 4 or 3 characters, it is treated as.. short and should not be preceded by a country prefix." -msgstr "电话号码前面应有国家/地区前缀(中国为 86,不带“+”), 号码是 5、4 或 3 个字符的短号除外." - -msgid "Each line must have the following format: 'Contact name;Phone number'. Save to file '/etc/config/phonebook.user'." -msgstr "每行必须具有以下格式:“联系人姓名;电话号码”。 保存到文件“/etc/config/phonebook.user”." - -msgid "User Phonebook" -msgstr "电话簿" - -msgid "Notification Settings" -msgstr "通知设置" - -msgid "The LED informs about a new message. Before activating this function, please config and save the SMS reading port, time to check SMS inbox and select the notification LED." -msgstr "LED 新消息通知。 激活此功能前,请配置并保存短信阅读端口,及时查看短信收件箱并选择通知LED." - -msgid "Check inbox every minute(s)" -msgstr "每分钟检查收件箱" - -msgid "Specify how many minutes you want your inbox to be checked." -msgstr "指定要检查收件箱的分钟数." - -msgid "Notification LED" -msgstr "通知LED" - -msgid "Select the notification LED." -msgstr "选择通知LED." - -msgid "Notify new messages" -msgstr "通知新消息" - -msgid "Turn on the LED for seconds(s)" -msgstr "打开LED秒数" - -msgid "Turn off the LED for seconds(s)" -msgstr "关闭LED秒数" - -msgid "Specify for how long the LED should be on." -msgstr "指定 LED 应亮多长时间." - -msgid "Specify for how long the LED should be off." -msgstr "指定 LED 应关闭多长时间." - -msgid "Merge split messages" -msgstr "合并分割的消息" - -msgid "Checking this option will make it easier to read the messages, but it will cause a discrepancy in the number of messages shown and received." -msgstr "选中此选项将使阅读消息更容易,但会导致显示和接收的消息数量出现差异." - -msgid "Message storage area" -msgstr "消息存储区" - -msgid "Messages are stored in a specific location (for example, on the SIM card or modem memory), but other areas may also be available depending on the type of device." -msgstr "消息存储在特定位置(例如,SIM 卡或调制解调器内存中),但其他区域也可能可用,具体取决于设备类型." - -msgid "AT Commands" -msgstr "AT 命令" - -msgid "Web UI for handling AT commands via sms_tool." -msgstr "用于通过 sms_tool 处理 AT 命令的 Web UI." - -msgid "Sending commands to modem" -msgstr "向调制解调器发送命令" - -msgid "User AT Commands" -msgstr "用户 AT 命令" - -msgid "Command to send" -msgstr "命令发送" - -msgid "Please enter a AT Command" -msgstr "请输入 AT 命令" - -msgid "AT Commands Sending Port" -msgstr "AT命令发送端口" - -msgid "Send Command" -msgstr "发送命令" - -msgid "AT Commands Settings" -msgstr "AT命令设置" - -msgid "Each line must have the following format: 'AT Command name;AT Command'. Save to file '/etc/config/atcmds.user'." -msgstr "每行必须具有以下格式:'AT Command name;AT Command'。 保存到文件“/etc/config/atcmds.user”." - -msgid "Restart the inbox checking process every" -msgstr "每次重新启动收件箱检查过程" - -msgid "The process will restart at the selected time interval. This will eliminate the delay in checking your inbox." -msgstr "该过程将在选定的时间间隔重新开始。 这将消除检查收件箱的延迟." - -msgid "4h" -msgstr "4小时." - -msgid "6h" -msgstr "6小时." - -msgid "8h" -msgstr "8小时." - -msgid "12h" -msgstr "12小时." - -msgid "The diode is dedicated only to these notifications" -msgstr "二极管仅用于这些通知" - -msgid "Select 'No' in case the router has only one LED or if the LED is multi-tasking." -msgstr "如果路由器只有一个 LED 或者 LED 是多任务处理,请选择“否”." - diff --git a/luci-app-sms-tool/root/etc/config/atcmds.user b/luci-app-sms-tool/root/etc/config/atcmds.user deleted file mode 100644 index 44bafb9..0000000 --- a/luci-app-sms-tool/root/etc/config/atcmds.user +++ /dev/null @@ -1,28 +0,0 @@ -------查询------;AT -查看IMEI;AT+CGSN -固件版本信息;AT+GMR -信号强度;AT+CSQ -正在使用的网络信息;AT+QNWINFO -查询限速;AT+C5GQOSRDP=1 -模块温度;AT+QTEMP -查询运营商名称;AT+QSPN -查询小区信息;AT+QENG="servingcell" ------3/4/5G网络配置-----;AT -查询当前网络搜索模式;AT+QNWPREFCFG="mode_pref" -!切换仅3G;AT+QNWPREFCFG="mode_pref",WCDMA -切换仅4G;AT+QNWPREFCFG="mode_pref",LTE -切换仅5G;AT+QNWPREFCFG="mode_pref",NR5G -切换5,4G;AT+QNWPREFCFG="mode_pref",NR5G:LTE -切换AUTO;AT+QNWPREFCFG="mode_pref",AUTO ------锁频段-----;AT -查询支持的所有频段;AT+QNWPREFCFG=? -查询当前配置的5G频段;AT+QNWPREFCFG="nr5g_band" -查询当前配置的4G频段;AT+QNWPREFCFG="lte_band" -!5G锁频段(78);AT+QNWPREFCFG="nr5g_band",78 -5G默认频段;AT+QNWPREFCFG="nr5g_band",1:28:41:77:78:79 -!4G锁频段(1);AT+QNWPREFCFG="lte_band",1 -4G默认频段;AT+QNWPREFCFG="lte_band",1:2:3:5:7:8:20:28:34:38:39:40:41 ------MORE-----;AT -查看产品型号;ATI -挂断现有语音;ATH -!更改IMEI,需重启;AT+EGMR=1,7,"868227050701486" \ No newline at end of file diff --git a/luci-app-sms-tool/root/etc/config/phonebook.user b/luci-app-sms-tool/root/etc/config/phonebook.user deleted file mode 100644 index 74c98ab..0000000 --- a/luci-app-sms-tool/root/etc/config/phonebook.user +++ /dev/null @@ -1 +0,0 @@ -other user;8613188888888 diff --git a/luci-app-sms-tool/root/etc/config/sms_tool b/luci-app-sms-tool/root/etc/config/sms_tool deleted file mode 100644 index 7bff8f6..0000000 --- a/luci-app-sms-tool/root/etc/config/sms_tool +++ /dev/null @@ -1,14 +0,0 @@ - -config sms_tool 'general' - option pnumber '86' - option prefix '1' - option ledtimeon '1' - option ledtimeoff '5' - option lednotify '0' - option checktime '10' - option mergesms '0' - option information '0' - option pdu '0' - option storage 'SM' - option prestart '6' - option ledtype 'D' diff --git a/luci-app-sms-tool/root/etc/init.d/smsled b/luci-app-sms-tool/root/etc/init.d/smsled deleted file mode 100755 index 2442b14..0000000 --- a/luci-app-sms-tool/root/etc/init.d/smsled +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh /etc/rc.common -# Copyright 2020 Rafał Wabik (IceG) - From eko.one.pl forum -# Licensed to the GNU General Public License v3.0. - -USE_PROCD=1 -START=99 -STOP=01 - -start_service() { - procd_open_instance - procd_set_param command /bin/sh "/sbin/smsled-init.sh" - procd_close_instance -} - -stop_service() { - for KILLPID in `ps | grep 'smsled' | awk ' { print $1;}'`; do - (kill -9 $KILLPID >/dev/null 2>&1 )& - done - sleep 1 - return 0 -} - -restart_service() { - stop_service - start_service -} diff --git a/luci-app-sms-tool/root/etc/uci-defaults/set_sms_ports.sh b/luci-app-sms-tool/root/etc/uci-defaults/set_sms_ports.sh deleted file mode 100755 index fbc77d7..0000000 --- a/luci-app-sms-tool/root/etc/uci-defaults/set_sms_ports.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh -# Copyright 2020-2021 Rafał Wabik (IceG) - From eko.one.pl forum -# Licensed to the GNU General Public License v3.0. - -work=false -for port in /dev/ttyUSB* -do - [[ -e $port ]] || continue - gcom -d $port info &> /tmp/testusb - testUSB=`cat /tmp/testusb | grep "Error\|Can't"` - if [ -z "$testUSB" ]; then - work=$port - break - fi -done -rm -rf /tmp/testusb - -if [ $work != false ]; then -uci set sms_tool.@sms_tool[0].readport=$work -uci set sms_tool.@sms_tool[0].sendport=$work -uci set sms_tool.@sms_tool[0].atport=$work -uci commit sms_tool -fi diff --git a/luci-app-sms-tool/root/etc/uci-defaults/start-smsled b/luci-app-sms-tool/root/etc/uci-defaults/start-smsled deleted file mode 100755 index 95ca388..0000000 --- a/luci-app-sms-tool/root/etc/uci-defaults/start-smsled +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -# Copyright 2020 Rafał Wabik (IceG) - From eko.one.pl forum -# Licensed to the GNU General Public License v3.0. - -/etc/init.d/smsled disable - -exit 0 diff --git a/luci-app-sms-tool/root/sbin/cronsync.sh b/luci-app-sms-tool/root/sbin/cronsync.sh deleted file mode 100755 index 39f7899..0000000 --- a/luci-app-sms-tool/root/sbin/cronsync.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -[ -e /etc/crontabs/root ] || touch /etc/crontabs/root - -SLED=$(uci -q get sms_tool.general.lednotify) -if [ "x$SLED" != "x1" ]; then - if grep -q "smsled" /etc/crontabs/root; then - grep -v "/init.d/smsled" /etc/crontabs/root > /tmp/new_cron - mv /tmp/new_cron /etc/crontabs/root - /etc/init.d/cron restart - fi - exit 0 -fi - -if ! grep -q "smsled" /etc/crontabs/root; then -PTR=$(uci -q get sms_tool.general.prestart) - echo "1 */$PTR * * * /etc/init.d/smsled enable" >> /etc/crontabs/root - /etc/init.d/cron restart -fi - -exit 0 diff --git a/luci-app-sms-tool/root/sbin/set_sms_ports.sh b/luci-app-sms-tool/root/sbin/set_sms_ports.sh deleted file mode 100755 index e89eb17..0000000 --- a/luci-app-sms-tool/root/sbin/set_sms_ports.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -# Copyright 2020-2021 Rafał Wabik (IceG) - From eko.one.pl forum -# Licensed to the GNU General Public License v3.0. - -work=false -for port in /dev/ttyUSB* -do - [[ -e $port ]] || continue - gcom -d $port info &> /tmp/testusb - testUSB=`cat /tmp/testusb | grep "Error\|Can't"` - if [ -z "$testUSB" ]; then - work=$port - break - fi -done -rm -rf /tmp/testusb - -if [ $work != false ]; then -uci set sms_tool.@sms_tool[0].readport=$work -uci set sms_tool.@sms_tool[0].sendport=$work -uci set sms_tool.@sms_tool[0].ussdport=$work -uci set sms_tool.@sms_tool[0].atport=$work -uci commit sms_tool -fi diff --git a/luci-app-sms-tool/root/sbin/smsled-init.sh b/luci-app-sms-tool/root/sbin/smsled-init.sh deleted file mode 100755 index fa7d863..0000000 --- a/luci-app-sms-tool/root/sbin/smsled-init.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -# Copyright 2020 Rafał Wabik (IceG) - From eko.one.pl forum -# Licensed to the GNU General Public License v3.0. - -sleep 10 -CT=$(uci -q get sms_tool.general.checktime) -TX=$(echo $CT | tr -dc '0-9') -TM=$(($TX * 60)) - -while [ 1 ]; do - LED=$(uci -q get sms_tool.general.lednotify) - if [ $LED == "1" ]; then - sleep $TM - (/sbin/smsled.sh >/dev/null 2>&1 )& - continue - fi - sleep 1 -done - -exit 0 - diff --git a/luci-app-sms-tool/root/sbin/smsled.sh b/luci-app-sms-tool/root/sbin/smsled.sh deleted file mode 100755 index fffd856..0000000 --- a/luci-app-sms-tool/root/sbin/smsled.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh -# Copyright 2020-2021 Rafał Wabik (IceG) - From eko.one.pl forum -# Licensed to the GNU General Public License v3.0. - - DEV=$(uci -q get sms_tool.general.readport) - LEDX=$(uci -q get sms_tool.general.smsled) - MEM=$(uci -q get sms_tool.general.storage) - STX=$(sms_tool -s $MEM -d $DEV status | cut -c23-27) - SMS=$(echo $STX | tr -dc '0-9') - SMSC=$(cat /etc/config/sms_count) - LEDT="/sys/class/leds/$LEDX/trigger" - LEDON="/sys/class/leds/$LEDX/delay_on" - LEDOFF="/sys/class/leds/$LEDX/delay_off" - LED="/sys/class/leds/$LEDX/brightness" - - LON=$(uci -q get sms_tool.general.ledtimeon) - TXON=$(echo $LON | tr -dc '0-9') - TMON=$(($TXON * 1000)) - - LOFF=$(uci -q get sms_tool.general.ledtimeoff) - TXOFF=$(echo $LOFF | tr -dc '0-9') - TMOFF=$(($TXOFF * 1000)) - -if [ $SMS == $SMSC ]; then - - exit 0 -fi - -if [ $SMS > $SMSC ]; then - -echo timer > $LEDT -echo $TMOFF > $LEDOFF -echo $TMON > $LEDON -exit 0 - -fi - - -exit 0 diff --git a/luci-app-sms-tool/root/usr/share/rpcd/acl.d/luci-app-sms-tool.json b/luci-app-sms-tool/root/usr/share/rpcd/acl.d/luci-app-sms-tool.json deleted file mode 100644 index 3f4e02f..0000000 --- a/luci-app-sms-tool/root/usr/share/rpcd/acl.d/luci-app-sms-tool.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "luci-app-sms-tool": { - "description": "Grant UCI and file access for luci-app-sms-tool", - "read": { - "file": { - "/usr/bin/sms_tool *": [ "exec" ], - }, - "uci": [ "sms_tool" ] - }, - "write": { - "file": { - "/usr/bin/sms_tool *": [ "exec" ], - - }, - "uci": [ "sms_tool" ] - } - } -} - - - - - - diff --git a/luci-app-spdmodem/Makefile b/luci-app-spdmodem/Makefile deleted file mode 100644 index 988ee1c..0000000 --- a/luci-app-spdmodem/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -# -# Copyright (C) 2015 OpenWrt.org -# -# This is free software, licensed under the GNU General Public License v2. -# See /LICENSE for more information. -# - -include $(TOPDIR)/rules.mk - -LUCI_TITLE:=SPD Modem Server -LUCI_DEPENDS:=+luci-compat +kmod-sprd_pcie - -include $(TOPDIR)/feeds/luci/luci.mk - -# call BuildPackage - OpenWrt buildroot signature diff --git a/luci-app-spdmodem/luasrc/controller/spdmodem.lua b/luci-app-spdmodem/luasrc/controller/spdmodem.lua deleted file mode 100644 index c0164bb..0000000 --- a/luci-app-spdmodem/luasrc/controller/spdmodem.lua +++ /dev/null @@ -1,9 +0,0 @@ -module("luci.controller.spdmodem", package.seeall) - -function index() - if not nixio.fs.access("/etc/config/spdmodem") then - return - end - - entry({"admin", "network", "spdmodem"}, cbi("spdmodem"), _("SPD Modem Server"), 80).dependent = false -end diff --git a/luci-app-spdmodem/luasrc/model/cbi/spdmodem.lua b/luci-app-spdmodem/luasrc/model/cbi/spdmodem.lua deleted file mode 100644 index c6bade4..0000000 --- a/luci-app-spdmodem/luasrc/model/cbi/spdmodem.lua +++ /dev/null @@ -1,39 +0,0 @@ --- Copyright 2016 David Thornley --- Licensed to the public under the Apache License 2.0. - -mp = Map("spdmodem") -mp.title = translate("SPD Modem Server") -mp.description = translate("Modem Server For OpenWrt") - -s = mp:section(TypedSection, "service", "Base Setting") -s.anonymous = true - -enabled = s:option(Flag, "enabled", translate("Enable")) -enabled.default = 0 -enabled.rmempty = false - -apn = s:option(Value, "apn", translate("APN")) -apn.rmempty = true - -pincode = s:option(Value, "pincode", translate("PIN")) -pincode.rmempty = true - -username = s:option(Value, "username", translate("PAP/CHAP username")) -username.rmempty = true - -password = s:option(Value, "password", translate("PAP/CHAP password")) -password.rmempty = true - -auth = s:option(Value, "auth", translate("Authentication Type")) -auth.rmempty = true -auth:value("", translate("-- Please choose --")) -auth:value("both", "PAP/CHAP (both)") -auth:value("pap", "PAP") -auth:value("chap", "CHAP") -auth:value("none", "NONE") - -tool = s:option(Value, "tool", translate("Tools")) -tool:value("quectel-CM", "quectel-CM") -tool.rmempty = true - -return mp diff --git a/luci-app-spdmodem/po/zh-cn/spdmodem.po b/luci-app-spdmodem/po/zh-cn/spdmodem.po deleted file mode 100644 index b10da0f..0000000 --- a/luci-app-spdmodem/po/zh-cn/spdmodem.po +++ /dev/null @@ -1,24 +0,0 @@ -msgid "" -msgstr "" -"Project-Id-Version: \n" -"POT-Creation-Date: \n" -"PO-Revision-Date: \n" -"Last-Translator: dingpengyu \n" -"Language-Team: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Language: zh_CN\n" -"X-Generator: Poedit 2.3.1\n" - -msgid "Base Setting" -msgstr "基本设置" - -msgid "SPD Modem Server" -msgstr "SPD移动网络拨号服务" - -msgid "Modem Server For OpenWrt" -msgstr "OpenWrt移动网络拨号服务" - -msgid "Tools" -msgstr "拨号工具" diff --git a/luci-app-spdmodem/root/etc/config/spdmodem b/luci-app-spdmodem/root/etc/config/spdmodem deleted file mode 100644 index 05fad9b..0000000 --- a/luci-app-spdmodem/root/etc/config/spdmodem +++ /dev/null @@ -1,4 +0,0 @@ -config service - option tool 'quectel-CM' - option enabled '0' - diff --git a/luci-app-spdmodem/root/etc/init.d/spdmodem b/luci-app-spdmodem/root/etc/init.d/spdmodem deleted file mode 100644 index eece321..0000000 --- a/luci-app-spdmodem/root/etc/init.d/spdmodem +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/sh /etc/rc.common -# Copyright (C) 2006-2014 OpenWrt.org - -START=99 -STOP=16 -USE_PROCD=1 -#使用procd启动 - -run_5g() -{ - local enabled - config_get_bool enabled $1 enabled - - echo "run 4G" >> /tmp/log4g - - if [ "$enabled" = "1" ]; then - local user - local password - local apn - local auth - local pincode - local tool - - # echo "enable 5G" >> /tmp/log5g - config_get user $1 user - config_get password $1 password - config_get apn $1 apn - config_get auth $1 auth - config_get pincode $1 pincode - config_get tool $1 tool - config_get tty $1 tty - config_get atcmd $1 atcmd - - if [ "$tool" = "at" ];then - at_tool "$atcmd" -d $tty - else - procd_open_instance - #创建一个实例, 在procd看来一个应用程序可以多个实\E4\BE? - #ubus call service list 可以查看实例 - procd_set_param command $tool -i -s $apn - if [ "$password" != "" ];then - procd_append_param command $user $password $auth - fi - if [ "$pincode" != "" ]; then - procd_append_param command -p $pincode - fi - # procd_append_param command -f /tmp/4g.log - procd_set_param respawn - echo "quectel-CM has started." - procd_close_instance - #关闭实例 - fi - - fi -} - - -service_triggers() -{ - procd_add_reload_trigger "spdmodem" -} - -start_service() { - config_load spdmodem - config_foreach run_5g service -} - -stop_service() -{ - echo "5G stop" >> /tmp/log5g - killall quectel-CM - echo "quectel-CM has stoped." -} - - diff --git a/luci-app-spdmodem/root/etc/uci-defaults/luci-spdmodem b/luci-app-spdmodem/root/etc/uci-defaults/luci-spdmodem deleted file mode 100644 index faa1d1e..0000000 --- a/luci-app-spdmodem/root/etc/uci-defaults/luci-spdmodem +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -uci -q batch <<-EOF >/dev/null - delete ucitrack.@spdmodem[-1] - add ucitrack spdmodem - set ucitrack.@spdmodem[-1].init=spdmodem - commit ucitrack -EOF - -rm -f /tmp/luci-indexcache -exit 0 diff --git a/luci-app-usbmodem/Makefile b/luci-app-usbmodem/Makefile deleted file mode 100644 index 826ed02..0000000 --- a/luci-app-usbmodem/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -# -# Copyright (C) 2015 OpenWrt.org -# -# This is free software, licensed under the GNU General Public License v2. -# See /LICENSE for more information. -# - -include $(TOPDIR)/rules.mk - -LUCI_TITLE:=Modem Server -LUCI_DEPENDS:=+luci-compat +quectel-CM-5G +kmod-usb-acm \ - +kmod-usb-net-cdc-ether +kmod-usb-net-cdc-mbim \ - +kmod-usb-net-qmi-wwan +kmod-usb-net-rndis \ - +kmod-usb-serial-option +kmod-usb-wdm \ - +kmod-qmi_wwan_f +kmod-qmi_wwan_q +usbutils - -include $(TOPDIR)/feeds/luci/luci.mk - -# call BuildPackage - OpenWrt buildroot signature diff --git a/luci-app-usbmodem/luasrc/controller/usbmodem.lua b/luci-app-usbmodem/luasrc/controller/usbmodem.lua deleted file mode 100644 index 6cf943c..0000000 --- a/luci-app-usbmodem/luasrc/controller/usbmodem.lua +++ /dev/null @@ -1,9 +0,0 @@ -module("luci.controller.usbmodem", package.seeall) - -function index() - if not nixio.fs.access("/etc/config/usbmodem") then - return - end - - entry({"admin", "network", "usbmodem"}, cbi("usbmodem"), _("USB Modem Server"), 80).dependent = false -end diff --git a/luci-app-usbmodem/luasrc/model/cbi/usbmodem.lua b/luci-app-usbmodem/luasrc/model/cbi/usbmodem.lua deleted file mode 100644 index 97af802..0000000 --- a/luci-app-usbmodem/luasrc/model/cbi/usbmodem.lua +++ /dev/null @@ -1,51 +0,0 @@ --- Copyright 2016 David Thornley --- Licensed to the public under the Apache License 2.0. - -mp = Map("usbmodem") -mp.title = translate("USB Modem Server") -mp.description = translate("Modem Server For OpenWrt") - -s = mp:section(TypedSection, "service", "Base Setting") -s.anonymous = true - -enabled = s:option(Flag, "enabled", translate("Enable")) -enabled.default = 0 -enabled.rmempty = false - -device = s:option(Value, "device", translate("Modem device")) -device.rmempty = false - -local device_suggestions = nixio.fs.glob("/dev/cdc-wdm*") - -if device_suggestions then - local node - for node in device_suggestions do - device:value(node) - end -end - -apn = s:option(Value, "apn", translate("APN")) -apn.rmempty = true - -pincode = s:option(Value, "pincode", translate("PIN")) -pincode.rmempty = true - -username = s:option(Value, "username", translate("PAP/CHAP username")) -username.rmempty = true - -password = s:option(Value, "password", translate("PAP/CHAP password")) -password.rmempty = true - -auth = s:option(Value, "auth", translate("Authentication Type")) -auth.rmempty = true -auth:value("", translate("-- Please choose --")) -auth:value("both", "PAP/CHAP (both)") -auth:value("pap", "PAP") -auth:value("chap", "CHAP") -auth:value("none", "NONE") - -tool = s:option(Value, "tool", translate("Tools")) -tool:value("quectel-CM", "quectel-CM") -tool.rmempty = true - -return mp diff --git a/luci-app-usbmodem/po/zh-cn/usbmodem.po b/luci-app-usbmodem/po/zh-cn/usbmodem.po deleted file mode 100644 index 6459a00..0000000 --- a/luci-app-usbmodem/po/zh-cn/usbmodem.po +++ /dev/null @@ -1,24 +0,0 @@ -msgid "" -msgstr "" -"Project-Id-Version: \n" -"POT-Creation-Date: \n" -"PO-Revision-Date: \n" -"Last-Translator: dingpengyu \n" -"Language-Team: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Language: zh_CN\n" -"X-Generator: Poedit 2.3.1\n" - -msgid "Base Setting" -msgstr "基本设置" - -msgid "USB Modem Server" -msgstr "USB移动网络拨号服务" - -msgid "Modem Server For OpenWrt" -msgstr "OpenWrt移动网络拨号服务" - -msgid "Tools" -msgstr "拨号工具" diff --git a/luci-app-usbmodem/root/etc/config/usbmodem b/luci-app-usbmodem/root/etc/config/usbmodem deleted file mode 100644 index 8d7627b..0000000 --- a/luci-app-usbmodem/root/etc/config/usbmodem +++ /dev/null @@ -1,5 +0,0 @@ -config service - option tool 'quectel-CM' - option device '/dev/cdc-wdm0' - option enabled '0' - diff --git a/luci-app-usbmodem/root/etc/init.d/usbmodem b/luci-app-usbmodem/root/etc/init.d/usbmodem deleted file mode 100644 index e5f1081..0000000 --- a/luci-app-usbmodem/root/etc/init.d/usbmodem +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/sh /etc/rc.common -# Copyright (C) 2006-2014 OpenWrt.org - -START=99 -STOP=16 -USE_PROCD=1 -#使用procd启动 - -run_4g() -{ - local enabled - config_get_bool enabled $1 enabled - - echo "run 4G" >> /tmp/log4g - - if [ "$enabled" = "1" ]; then - local user - local password - local apn - local auth - local pincode - local device - local tool - - # echo "enable 4G" >> /tmp/log4g - config_get user $1 user - config_get password $1 password - config_get apn $1 apn - config_get auth $1 auth - config_get pincode $1 pincode - config_get device $1 device - config_get tool $1 tool - config_get tty $1 tty - config_get atcmd $1 atcmd - - devname="$(basename "$device")" - devpath="$(readlink -f /sys/class/usbmisc/$devname/device/)" - ifname="$( ls "$devpath"/net )" - - if [ "$tool" = "at" ];then - at_tool "$atcmd" -d $tty - else - procd_open_instance - #创建一个实例, 在procd看来一个应用程序可以多个实\E4\BE? - #ubus call service list 可以查看实例 - procd_set_param command $tool -i $ifname -s $apn - if [ "$password" != "" ];then - procd_append_param command $user $password $auth - fi - if [ "$pincode" != "" ]; then - procd_append_param command -p $pincode - fi - # procd_append_param command -f /tmp/4g.log - procd_set_param respawn - echo "quectel-CM has started." - procd_close_instance - #关闭实例 - fi - - fi -} - - -service_triggers() -{ - procd_add_reload_trigger "usbmodem" -} - -start_service() { - config_load usbmodem - config_foreach run_4g service -} - -stop_service() -{ - echo "4G stop" >> /tmp/log4g - killall quectel-CM - echo "quectel-CM has stoped." -} - diff --git a/luci-app-usbmodem/root/etc/uci-defaults/luci-usbmodem b/luci-app-usbmodem/root/etc/uci-defaults/luci-usbmodem deleted file mode 100644 index 1b2ba06..0000000 --- a/luci-app-usbmodem/root/etc/uci-defaults/luci-usbmodem +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -uci -q batch <<-EOF >/dev/null - delete ucitrack.@usbmodem[-1] - add ucitrack usbmodem - set ucitrack.@usbmodem[-1].init=usbmodem - commit ucitrack -EOF - -rm -f /tmp/luci-indexcache -exit 0 diff --git a/quectel_Gobinet/Makefile b/quectel_Gobinet/Makefile deleted file mode 100644 index abdba44..0000000 --- a/quectel_Gobinet/Makefile +++ /dev/null @@ -1,47 +0,0 @@ -# -# Copyright (C) 2015 OpenWrt.org -# -# This is free software, licensed under the GNU General Public License v2. -# See /LICENSE for more information. -# - -include $(TOPDIR)/rules.mk - -PKG_NAME:=gobinet -PKG_VERSION:=1.6.3 -PKG_RELEASE:=1 - -include $(INCLUDE_DIR)/kernel.mk -include $(INCLUDE_DIR)/package.mk - -define KernelPackage/gobinet - SUBMENU:=WWAN Support - TITLE:=Quectel Linux USB Gobinet Driver - DEPENDS:=+kmod-usb-net - FILES:=$(PKG_BUILD_DIR)/GobiNet.ko - AUTOLOAD:=$(call AutoLoad,81,GobiNet) -endef - -define KernelPackage/gobinet/description - Quectel Linux USB gobinet Driver -endef - -MAKE_OPTS:= \ - ARCH="$(LINUX_KARCH)" \ - CROSS_COMPILE="$(TARGET_CROSS)" \ - CXXFLAGS="$(TARGET_CXXFLAGS)" \ - M="$(PKG_BUILD_DIR)" \ - $(EXTRA_KCONFIG) - -define Build/Prepare - mkdir -p $(PKG_BUILD_DIR) - $(CP) ./src/* $(PKG_BUILD_DIR)/ -endef - -define Build/Compile - $(MAKE) -C "$(LINUX_DIR)" \ - $(MAKE_OPTS) \ - modules -endef - -$(eval $(call KernelPackage,gobinet)) diff --git a/quectel_Gobinet/src/GobiUSBNet.c b/quectel_Gobinet/src/GobiUSBNet.c deleted file mode 100644 index 689c173..0000000 --- a/quectel_Gobinet/src/GobiUSBNet.c +++ /dev/null @@ -1,3202 +0,0 @@ -/*=========================================================================== -FILE: - GobiUSBNet.c - -DESCRIPTION: - Qualcomm USB Network device for Gobi 3000 - -FUNCTIONS: - GobiNetSuspend - GobiNetResume - GobiNetDriverBind - GobiNetDriverUnbind - GobiUSBNetURBCallback - GobiUSBNetTXTimeout - GobiUSBNetAutoPMThread - GobiUSBNetStartXmit - GobiUSBNetOpen - GobiUSBNetStop - GobiUSBNetProbe - GobiUSBNetModInit - GobiUSBNetModExit - -Copyright (c) 2011, Code Aurora Forum. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of Code Aurora Forum nor - the names of its contributors may be used to endorse or promote - products derived from this software without specific prior written - permission. - - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. -===========================================================================*/ - -//--------------------------------------------------------------------------- -// Include Files -//--------------------------------------------------------------------------- - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#if LINUX_VERSION_CODE > KERNEL_VERSION(3,16,0) //8b094cd03b4a3793220d8d8d86a173bfea8c285b -#include -#else -#define timespec64 timespec -#define ktime_get_ts64 ktime_get_ts -#define timespec64_sub timespec_sub -#endif - -#include "Structs.h" -#include "QMIDevice.h" -#include "QMI.h" - -#ifndef ETH_P_MAP -#define ETH_P_MAP 0xDA1A -#endif - -#if (ETH_P_MAP == 0x00F9) -#undef ETH_P_MAP -#define ETH_P_MAP 0xDA1A -#endif - -//----------------------------------------------------------------------------- -// Definitions -//----------------------------------------------------------------------------- - -// Version Information -//add new module or new feature, increase major version. fix bug, increase minor version -#define VERSION_NUMBER "V1.6.3" -#define DRIVER_VERSION "Quectel_Linux&Android_GobiNet_Driver_"VERSION_NUMBER -#define DRIVER_AUTHOR "Qualcomm Innovation Center" -#define DRIVER_DESC "GobiNet" -static const char driver_name[] = "GobiNet"; - -// Debug flag -int quec_debug = 0; - -// Allow user interrupts -//int interruptible = 1; - -// Number of IP packets which may be queued up for transmit -static int txQueueLength = 100; - -// Class should be created during module init, so needs to be global -static struct class * gpClass; - -static const unsigned char ec20_mac[ETH_ALEN] = {0x02, 0x50, 0xf3, 0x00, 0x00, 0x00}; -static const unsigned char default_modem_addr[ETH_ALEN] = {0x02, 0x50, 0xf3, 0x00, 0x00, 0x00}; -static const unsigned char node_id[ETH_ALEN] = {0x02, 0x50, 0xf4, 0x00, 0x00, 0x00}; -//static const u8 broadcast_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - -//setup data call by "AT$QCRMCALL=1,1" -static uint __read_mostly qcrmcall_mode = 0; -module_param( qcrmcall_mode, uint, S_IRUGO | S_IWUSR ); - -static struct sk_buff * ether_to_ip_fixup(struct net_device *dev, struct sk_buff *skb) { - const struct ethhdr *ehdr; - - skb_reset_mac_header(skb); - ehdr = eth_hdr(skb); - - if (ehdr->h_proto == htons(ETH_P_IP)) { - if (unlikely(skb->len <= (sizeof(struct ethhdr) + sizeof(struct iphdr)))) { - goto drop_skb; - } - } - else if (ehdr->h_proto == htons(ETH_P_IPV6)) { - if (unlikely(skb->len <= (sizeof(struct ethhdr) + sizeof(struct ipv6hdr)))) { - goto drop_skb; - } - } - else { - DBG("%s skb h_proto is %04x\n", dev->name, ntohs(ehdr->h_proto)); - goto drop_skb; - } - - if (unlikely(skb_pull(skb, ETH_HLEN))) - return skb; - -drop_skb: - return NULL; -} - -//#define QUECTEL_REMOVE_TX_ZLP -#define USB_CDC_SET_REMOVE_TX_ZLP_COMMAND 0x5D - -//#define QUECTEL_WWAN_MULTI_PACKAGES - -#ifdef QUECTEL_WWAN_MULTI_PACKAGES -static uint __read_mostly rx_packets = 10; -module_param( rx_packets, uint, S_IRUGO | S_IWUSR ); - -#define USB_CDC_SET_MULTI_PACKAGE_COMMAND (0x5C) -#define QUEC_NET_MSG_SPEC (0x80) -#define QUEC_NET_MSG_ID_IP_DATA (0x00) - -struct multi_package_config { - __le32 enable; - __le32 package_max_len; - __le32 package_max_count_in_queue; - __le32 timeout; -} __packed; - -struct quec_net_package_header { - unsigned char msg_spec; - unsigned char msg_id; - unsigned short payload_len; - unsigned char reserve[16]; -} __packed; -#endif - -#ifdef QUECTEL_WWAN_QMAP -/* - Quectel_WCDMA<E_Linux_USB_Driver_User_Guide_V1.9.pdf - 5.6. Test QMAP on GobiNet or QMI WWAN - 0 - no QMAP - 1 - QMAP (Aggregation protocol) - X - QMAP (Multiplexing and Aggregation protocol) -*/ -static uint __read_mostly qmap_mode = 0; -module_param( qmap_mode, uint, S_IRUGO | S_IWUSR ); - -struct qmap_hdr { - u8 cd_rsvd_pad; - u8 mux_id; - u16 pkt_len; -} __packed; - -enum rmnet_map_v5_header_type { - RMNET_MAP_HEADER_TYPE_UNKNOWN, - RMNET_MAP_HEADER_TYPE_COALESCING = 0x1, - RMNET_MAP_HEADER_TYPE_CSUM_OFFLOAD = 0x2, - RMNET_MAP_HEADER_TYPE_ENUM_LENGTH -}; - -/* Main QMAP header */ -struct rmnet_map_header { -#if defined(__LITTLE_ENDIAN_BITFIELD) - u8 pad_len:6; - u8 next_hdr:1; - u8 cd_bit:1; -#elif defined (__BIG_ENDIAN_BITFIELD) - u8 cd_bit:1; - u8 next_hdr:1; - u8 pad_len:6; -#else -#error "Please fix " -#endif - u8 mux_id; - __be16 pkt_len; -} __aligned(1); - -/* QMAP v5 headers */ -struct rmnet_map_v5_csum_header { -#if defined(__LITTLE_ENDIAN_BITFIELD) - u8 next_hdr:1; - u8 header_type:7; - u8 hw_reserved:7; - u8 csum_valid_required:1; -#elif defined (__BIG_ENDIAN_BITFIELD) - u8 header_type:7; - u8 next_hdr:1; - u8 csum_valid_required:1; - u8 hw_reserved:7; -#else -#error "Please fix " -#endif - __be16 reserved; -} __aligned(1); - -struct qmap_priv { - struct net_device *real_dev; - struct net_device *self_dev; - uint qmap_version; - uint offset_id; - uint mux_id; - uint link_state; - -#if defined(QUECTEL_UL_DATA_AGG) - /* QMIWDS_ADMIN_SET_DATA_FORMAT_RESP TLV_0x17 and TLV_0x18 */ - uint ul_data_aggregation_max_datagrams; //UplinkDataAggregationMaxDatagramsTlv - uint ul_data_aggregation_max_size; //UplinkDataAggregationMaxSizeTlv - uint dl_minimum_padding; //0x1A - - spinlock_t agg_lock; - struct sk_buff *agg_skb; - unsigned agg_count; - struct timespec64 agg_time; - struct hrtimer agg_hrtimer; - struct work_struct agg_wq; -#endif - -#ifdef QUECTEL_BRIDGE_MODE - int m_bridge_mode; - uint m_bridge_ipv4; - unsigned char mHostMAC[6]; -#endif -}; - -#ifdef QUECTEL_BRIDGE_MODE -static int is_qmap_netdev(const struct net_device *netdev); -#endif - -#endif - -#ifdef QUECTEL_BRIDGE_MODE -static int __read_mostly bridge_mode = 0/*|BIT(1)*/; -module_param( bridge_mode, int, S_IRUGO | S_IWUSR ); - -static int bridge_arp_reply(struct net_device *net, struct sk_buff *skb, uint bridge_ipv4) { - struct arphdr *parp; - u8 *arpptr, *sha; - u8 sip[4], tip[4], ipv4[4]; - struct sk_buff *reply = NULL; - - ipv4[0] = (bridge_ipv4 >> 24) & 0xFF; - ipv4[1] = (bridge_ipv4 >> 16) & 0xFF; - ipv4[2] = (bridge_ipv4 >> 8) & 0xFF; - ipv4[3] = (bridge_ipv4 >> 0) & 0xFF; - - parp = arp_hdr(skb); - - if (parp->ar_hrd == htons(ARPHRD_ETHER) && parp->ar_pro == htons(ETH_P_IP) - && parp->ar_op == htons(ARPOP_REQUEST) && parp->ar_hln == 6 && parp->ar_pln == 4) { - arpptr = (u8 *)parp + sizeof(struct arphdr); - sha = arpptr; - arpptr += net->addr_len; /* sha */ - memcpy(sip, arpptr, sizeof(sip)); - arpptr += sizeof(sip); - arpptr += net->addr_len; /* tha */ - memcpy(tip, arpptr, sizeof(tip)); - - pr_info("%s sip = %d.%d.%d.%d, tip=%d.%d.%d.%d, ipv4=%d.%d.%d.%d\n", netdev_name(net), - sip[0], sip[1], sip[2], sip[3], tip[0], tip[1], tip[2], tip[3], ipv4[0], ipv4[1], ipv4[2], ipv4[3]); - //wwan0 sip = 10.151.137.255, tip=10.151.138.0, ipv4=10.151.137.255 - if (tip[0] == ipv4[0] && tip[1] == ipv4[1] && (tip[2]&0xFC) == (ipv4[2]&0xFC) && tip[3] != ipv4[3]) - reply = arp_create(ARPOP_REPLY, ETH_P_ARP, *((__be32 *)sip), net, *((__be32 *)tip), sha, ec20_mac, sha); - - if (reply) { - skb_reset_mac_header(reply); - __skb_pull(reply, skb_network_offset(reply)); - reply->ip_summed = CHECKSUM_UNNECESSARY; - reply->pkt_type = PACKET_HOST; - - netif_rx_ni(reply); - } - return 1; - } - - return 0; -} - -static struct sk_buff *bridge_mode_tx_fixup(struct net_device *net, struct sk_buff *skb, uint bridge_ipv4, unsigned char *bridge_mac) { - struct ethhdr *ehdr; - const struct iphdr *iph; - - skb_reset_mac_header(skb); - ehdr = eth_hdr(skb); - - if (ehdr->h_proto == htons(ETH_P_ARP)) { - if (bridge_ipv4) - bridge_arp_reply(net, skb, bridge_ipv4); - return NULL; - } - - iph = ip_hdr(skb); - //DBG("iphdr: "); - //PrintHex((void *)iph, sizeof(struct iphdr)); - -// 1 0.000000000 0.0.0.0 255.255.255.255 DHCP 362 DHCP Request - Transaction ID 0xe7643ad7 - if (ehdr->h_proto == htons(ETH_P_IP) && iph->protocol == IPPROTO_UDP && iph->saddr == 0x00000000 && iph->daddr == 0xFFFFFFFF) { - //if (udp_hdr(skb)->dest == htons(67)) //DHCP Request - { - memcpy(bridge_mac, ehdr->h_source, ETH_ALEN); - pr_info("%s PC Mac Address: %02x:%02x:%02x:%02x:%02x:%02x\n", netdev_name(net), - bridge_mac[0], bridge_mac[1], bridge_mac[2], bridge_mac[3], bridge_mac[4], bridge_mac[5]); - } - } - - if (memcmp(ehdr->h_source, bridge_mac, ETH_ALEN)) { - return NULL; - } - - return skb; -} - -static void bridge_mode_rx_fixup(sGobiUSBNet *pQmapDev, struct net_device *net, struct sk_buff *skb) { - uint bridge_mode = 0; - unsigned char *bridge_mac; - - if (pQmapDev->qmap_mode > 1) { - struct qmap_priv *priv = netdev_priv(net); - bridge_mode = priv->m_bridge_mode; - bridge_mac = priv->mHostMAC; - } - else { - bridge_mode = pQmapDev->m_bridge_mode; - bridge_mac = pQmapDev->mHostMAC; - } - - if (bridge_mode) - memcpy(eth_hdr(skb)->h_dest, bridge_mac, ETH_ALEN); - else - memcpy(eth_hdr(skb)->h_dest, net->dev_addr, ETH_ALEN); -} - -static ssize_t bridge_mode_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct net_device *pNet = to_net_dev(dev); - uint bridge_mode = 0; - - if (is_qmap_netdev(pNet)) { - struct qmap_priv *priv = netdev_priv(pNet); - bridge_mode = priv->m_bridge_mode; - } - else { - struct usbnet * pDev = netdev_priv( pNet ); - sGobiUSBNet * pGobiDev = (sGobiUSBNet *)pDev->data[0]; - bridge_mode = pGobiDev->m_bridge_mode; - } - - return snprintf(buf, PAGE_SIZE, "%d\n", bridge_mode); -} - -static ssize_t bridge_mode_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - struct net_device *pNet = to_net_dev(dev); - uint old_mode = 0; - uint bridge_mode = simple_strtoul(buf, NULL, 0); - - if (pNet->type != ARPHRD_ETHER) { - return count; - } - - if (is_qmap_netdev(pNet)) { - struct qmap_priv *priv = netdev_priv(pNet); - - old_mode = priv->m_bridge_mode; - priv->m_bridge_mode = bridge_mode; - } - else { - struct usbnet * pDev = netdev_priv( pNet ); - sGobiUSBNet * pGobiDev = (sGobiUSBNet *)pDev->data[0]; - - old_mode = pGobiDev->m_bridge_mode; - pGobiDev->m_bridge_mode = bridge_mode; - } - - if (old_mode != bridge_mode) - dev_info(dev, "bridge_mode change to 0x%x\n", bridge_mode); - - return count; -} - -static ssize_t bridge_ipv4_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct net_device *pNet = to_net_dev(dev); - unsigned int bridge_ipv4 = 0; - unsigned char ipv4[4]; - - if (is_qmap_netdev(pNet)) { - struct qmap_priv *priv = netdev_priv(pNet); - bridge_ipv4 = priv->m_bridge_ipv4; - } - else { - struct usbnet * pDev = netdev_priv( pNet ); - sGobiUSBNet * pGobiDev = (sGobiUSBNet *)pDev->data[0]; - bridge_ipv4 = pGobiDev->m_bridge_ipv4; - } - - ipv4[0] = (bridge_ipv4 >> 24) & 0xFF; - ipv4[1] = (bridge_ipv4 >> 16) & 0xFF; - ipv4[2] = (bridge_ipv4 >> 8) & 0xFF; - ipv4[3] = (bridge_ipv4 >> 0) & 0xFF; - - return snprintf(buf, PAGE_SIZE, "%d.%d.%d.%d\n", ipv4[0], ipv4[1], ipv4[2], ipv4[3]); -} - -static ssize_t bridge_ipv4_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - struct net_device *pNet = to_net_dev(dev); - - if (is_qmap_netdev(pNet)) { - struct qmap_priv *priv = netdev_priv(pNet); - priv->m_bridge_ipv4 = simple_strtoul(buf, NULL, 16); - } - else { - struct usbnet * pDev = netdev_priv( pNet ); - sGobiUSBNet * pGobiDev = (sGobiUSBNet *)pDev->data[0]; - pGobiDev->m_bridge_ipv4 = simple_strtoul(buf, NULL, 16); - } - - return count; -} - -static DEVICE_ATTR(bridge_mode, S_IWUSR | S_IRUGO, bridge_mode_show, bridge_mode_store); -static DEVICE_ATTR(bridge_ipv4, S_IWUSR | S_IRUGO, bridge_ipv4_show, bridge_ipv4_store); - -static struct attribute *qmi_qmap_sysfs_attrs[] = { - &dev_attr_bridge_mode.attr, - &dev_attr_bridge_ipv4.attr, - NULL, -}; - -static struct attribute_group qmi_qmap_sysfs_attr_group = { - .attrs = qmi_qmap_sysfs_attrs, -}; -#endif - -#ifdef QUECTEL_WWAN_QMAP -static sGobiUSBNet * net_to_qmap(struct net_device *dev) { - struct usbnet *usbnet = netdev_priv(dev); - sGobiUSBNet * pGobiDev = (sGobiUSBNet *)usbnet->data[0]; - - return pGobiDev; -} - -static struct sk_buff * add_qhdr(struct sk_buff *skb, u8 mux_id) { - struct qmap_hdr *qhdr; - int pad = 0; - - pad = skb->len%4; - if (pad) { - pad = 4 - pad; - if (skb_tailroom(skb) < pad) { - printk("skb_tailroom small!\n"); - pad = 0; - } - if (pad) - __skb_put(skb, pad); - } - - qhdr = (struct qmap_hdr *)skb_push(skb, sizeof(struct qmap_hdr)); - qhdr->cd_rsvd_pad = pad; - qhdr->mux_id = mux_id; - qhdr->pkt_len = cpu_to_be16(skb->len - sizeof(struct qmap_hdr)); - - return skb; -} - -static struct sk_buff * add_qhdr_v5(struct sk_buff *skb, u8 mux_id) { - struct rmnet_map_header *map_header; - struct rmnet_map_v5_csum_header *ul_header; - u32 padding, map_datalen; - - map_datalen = skb->len; - padding = map_datalen%4; - if (padding) { - padding = 4 - padding; - if (skb_tailroom(skb) < padding) { - printk("skb_tailroom small!\n"); - padding = 0; - } - if (padding) - __skb_put(skb, padding); - } - - map_header = (struct rmnet_map_header *)skb_push(skb, (sizeof(struct rmnet_map_header) + sizeof(struct rmnet_map_v5_csum_header))); - map_header->cd_bit = 0; - map_header->next_hdr = 1; - map_header->pad_len = padding; - map_header->mux_id = mux_id; - map_header->pkt_len = htons(map_datalen + padding); - - ul_header = (struct rmnet_map_v5_csum_header *)(map_header + 1); - memset(ul_header, 0, sizeof(*ul_header)); - ul_header->header_type = RMNET_MAP_HEADER_TYPE_CSUM_OFFLOAD; - if (skb->ip_summed == CHECKSUM_PARTIAL) { -#if 0 //TODO - skb->ip_summed = CHECKSUM_NONE; - /* Ask for checksum offloading */ - ul_header->csum_valid_required = 1; -#endif - } - - return skb; -} - -static void rmnet_usb_tx_wake_queue(unsigned long data) { - sGobiUSBNet *pQmapDev = (void *)data; - int i; - - for (i = 0; i < pQmapDev->qmap_mode; i++) { - struct net_device *qmap_net = pQmapDev->mpQmapNetDev[i]; - if (qmap_net) { - if (netif_queue_stopped(qmap_net) && !netif_queue_stopped(pQmapDev->mpNetDev->net)) { - netif_wake_queue(qmap_net); - } - } - } -} - -static void rmnet_usb_tx_skb_destructor(struct sk_buff *skb) { - sGobiUSBNet *pQmapDev = net_to_qmap(skb->dev); - int i; - - for (i = 0; i < pQmapDev->qmap_mode; i++) { - struct net_device *qmap_net = pQmapDev->mpQmapNetDev[i]; - - if (qmap_net) { - if (netif_queue_stopped(qmap_net)) { - tasklet_schedule(&pQmapDev->txq); - break; - } - } - } -} - -static void rmnet_vnd_update_rx_stats(struct net_device *net, - unsigned rx_packets, unsigned rx_bytes) { - net->stats.rx_packets += rx_packets; - net->stats.rx_bytes += rx_bytes; -} - -static void rmnet_vnd_update_tx_stats(struct net_device *net, - unsigned tx_packets, unsigned tx_bytes) { - net->stats.tx_packets += tx_packets; - net->stats.tx_bytes += tx_bytes; -} - -#if defined(QUECTEL_UL_DATA_AGG) -static long agg_time_limit __read_mostly = 1000000L; //reduce this time, can get better TPUT performance, but will increase USB interrupts -module_param(agg_time_limit, long, S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(agg_time_limit, "Maximum time packets sit in the agg buf"); - -static long agg_bypass_time __read_mostly = 10000000L; -module_param(agg_bypass_time, long, S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(agg_bypass_time, "Skip agg when apart spaced more than this"); - -static int rmnet_usb_tx_agg_skip(struct sk_buff *skb, int offset) -{ - u8 *packet_start = skb->data + offset; - int ready2send = 0; - - if (skb->protocol == htons(ETH_P_IP)) { - struct iphdr *ip4h = (struct iphdr *)(packet_start); - - if (ip4h->protocol == IPPROTO_TCP) { - const struct tcphdr *th = (const struct tcphdr *)(packet_start + sizeof(struct iphdr)); - if (th->psh) { - ready2send = 1; - } - } - else if (ip4h->protocol == IPPROTO_ICMP) - ready2send = 1; - - } else if (skb->protocol == htons(ETH_P_IPV6)) { - struct ipv6hdr *ip6h = (struct ipv6hdr *)(packet_start); - - if (ip6h->nexthdr == NEXTHDR_TCP) { - const struct tcphdr *th = (const struct tcphdr *)(packet_start + sizeof(struct ipv6hdr)); - if (th->psh) { - ready2send = 1; - } - } else if (ip6h->nexthdr == NEXTHDR_ICMP) { - ready2send = 1; - } else if (ip6h->nexthdr == NEXTHDR_FRAGMENT) { - struct frag_hdr *frag; - - frag = (struct frag_hdr *)(packet_start - + sizeof(struct ipv6hdr)); - if (frag->nexthdr == IPPROTO_ICMPV6) - ready2send = 1; - } - } - - return ready2send; -} - -static void rmnet_usb_tx_agg_work(struct work_struct *work) -{ - struct qmap_priv *priv = - container_of(work, struct qmap_priv, agg_wq); - struct sk_buff *skb = NULL; - unsigned long flags; - - spin_lock_irqsave(&priv->agg_lock, flags); - if (likely(priv->agg_skb)) { - skb = priv->agg_skb; - priv->agg_skb = NULL; - priv->agg_count = 0; - skb->protocol = htons(ETH_P_MAP); - skb->dev = priv->real_dev; - ktime_get_ts64(&priv->agg_time); - } - spin_unlock_irqrestore(&priv->agg_lock, flags); - - if (skb) { - int err = dev_queue_xmit(skb); - if (err != NET_XMIT_SUCCESS) { - priv->self_dev->stats.tx_errors++; - } - } -} - -static enum hrtimer_restart rmnet_usb_tx_agg_timer_cb(struct hrtimer *timer) -{ - struct qmap_priv *priv = - container_of(timer, struct qmap_priv, agg_hrtimer); - - schedule_work(&priv->agg_wq); - return HRTIMER_NORESTART; -} - -static int rmnet_usb_tx_agg(struct sk_buff *skb, struct qmap_priv *priv) { - int ready2send = 0; - int xmit_more = 0; - struct timespec64 diff, now; - struct sk_buff *agg_skb = NULL; - unsigned long flags; - int err; - struct net_device *pNet = priv->self_dev; - -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,1,0) //6b16f9ee89b8d5709f24bc3ac89ae8b5452c0d7c -#if LINUX_VERSION_CODE > KERNEL_VERSION(3,16,0) - xmit_more = skb->xmit_more; -#endif -#else - xmit_more = netdev_xmit_more(); -#endif - - rmnet_vnd_update_tx_stats(pNet, 1, skb->len); - - if (priv->ul_data_aggregation_max_datagrams == 1) { - skb->protocol = htons(ETH_P_MAP); - skb->dev = priv->real_dev; - if (!skb->destructor) - skb->destructor = rmnet_usb_tx_skb_destructor; - err = dev_queue_xmit(skb); - if (err != NET_XMIT_SUCCESS) - pNet->stats.tx_errors++; - return NET_XMIT_SUCCESS; - } - -new_packet: - spin_lock_irqsave(&priv->agg_lock, flags); - agg_skb = NULL; - ready2send = 0; - ktime_get_ts64(&now); - diff = timespec64_sub(now, priv->agg_time); - - if (priv->agg_skb) { - if ((priv->agg_skb->len + skb->len) < priv->ul_data_aggregation_max_size) { - memcpy(skb_put(priv->agg_skb, skb->len), skb->data, skb->len); - priv->agg_count++; - - if (diff.tv_sec > 0 || diff.tv_nsec > agg_time_limit) { - ready2send = 1; - } - else if (priv->agg_count == priv->ul_data_aggregation_max_datagrams) { - ready2send = 1; - } - else if (xmit_more == 0) { - struct rmnet_map_header *map_header = (struct rmnet_map_header *)skb->data; - size_t offset = sizeof(struct rmnet_map_header); - if (map_header->next_hdr) - offset += sizeof(struct rmnet_map_v5_csum_header); - - ready2send = rmnet_usb_tx_agg_skip(skb, offset); - } - - dev_kfree_skb_any(skb); - skb = NULL; - } - else { - ready2send = 1; - } - - if (ready2send) { - agg_skb = priv->agg_skb; - priv->agg_skb = NULL; - priv->agg_count = 0; - } - } - else if (skb) { - if (diff.tv_sec > 0 || diff.tv_nsec > agg_bypass_time) { - ready2send = 1; - } - else if (xmit_more == 0) { - struct rmnet_map_header *map_header = (struct rmnet_map_header *)skb->data; - size_t offset = sizeof(struct rmnet_map_header); - if (map_header->next_hdr) - offset += sizeof(struct rmnet_map_v5_csum_header); - - ready2send = rmnet_usb_tx_agg_skip(skb, offset); - } - - if (ready2send == 0) { - priv->agg_skb = alloc_skb(priv->ul_data_aggregation_max_size, GFP_ATOMIC); - if (priv->agg_skb) { - memcpy(skb_put(priv->agg_skb, skb->len), skb->data, skb->len); - priv->agg_count++; - dev_kfree_skb_any(skb); - skb = NULL; - } - else { - ready2send = 1; - } - } - - if (ready2send) { - agg_skb = skb; - skb = NULL; - } - } - - if (ready2send) { - priv->agg_time = now; - } - spin_unlock_irqrestore(&priv->agg_lock, flags); - - if (agg_skb) { - agg_skb->protocol = htons(ETH_P_MAP); - agg_skb->dev = priv->real_dev; - if (!agg_skb->destructor) - agg_skb->destructor = rmnet_usb_tx_skb_destructor; - err = dev_queue_xmit(agg_skb); - if (err != NET_XMIT_SUCCESS) { - pNet->stats.tx_errors++; - } - } - - if (skb) { - goto new_packet; - } - - if (priv->agg_skb) { - if (!hrtimer_is_queued(&priv->agg_hrtimer)) - hrtimer_start(&priv->agg_hrtimer, ns_to_ktime(NSEC_PER_MSEC * 2), HRTIMER_MODE_REL); - } - - return NET_XMIT_SUCCESS; -} -#endif - -static int qmap_open(struct net_device *dev) -{ - struct qmap_priv *priv = netdev_priv(dev); - sGobiUSBNet * pGobiDev = net_to_qmap(priv->real_dev); - - if (!(priv->real_dev->flags & IFF_UP)) - return -ENETDOWN; - - if (!pGobiDev->mbQMIReady) - return -ENETDOWN; - -#if defined(QUECTEL_UL_DATA_AGG) - if (priv->ul_data_aggregation_max_datagrams == 1 && pGobiDev->agg_ctx.ul_data_aggregation_max_datagrams > 1) { - priv->ul_data_aggregation_max_datagrams = pGobiDev->agg_ctx.ul_data_aggregation_max_datagrams; - priv->ul_data_aggregation_max_size = pGobiDev->agg_ctx.ul_data_aggregation_max_size; - priv->dl_minimum_padding = pGobiDev->agg_ctx.dl_minimum_padding; - } -#endif - - if (netif_carrier_ok(priv->real_dev) && priv->link_state) - netif_carrier_on(dev); - - if (netif_carrier_ok(dev)) { - if (netif_queue_stopped(dev) && !netif_queue_stopped(priv->real_dev)) - netif_wake_queue(dev); - } - - return 0; -} - -static int qmap_stop(struct net_device *pNet) -{ - netif_carrier_off(pNet); - return 0; -} - -static int qmap_start_xmit(struct sk_buff *skb, struct net_device *pNet) -{ - int err; - struct qmap_priv *priv = netdev_priv(pNet); - - if (netif_queue_stopped(priv->real_dev)) { - //printk(KERN_DEBUG "s\n"); - netif_stop_queue(pNet); - return NETDEV_TX_BUSY; - } - - if (pNet->type == ARPHRD_ETHER) { -#ifdef QUECTEL_BRIDGE_MODE - if (priv->m_bridge_mode && bridge_mode_tx_fixup(pNet, skb, priv->m_bridge_ipv4, priv->mHostMAC) == NULL) { - dev_kfree_skb_any (skb); - return NETDEV_TX_OK; - } -#endif - - if (ether_to_ip_fixup(pNet, skb) == NULL) { - dev_kfree_skb_any (skb); - return NETDEV_TX_OK; - } - } - - if (priv->qmap_version == 5) { - add_qhdr(skb, priv->mux_id); - } - else if (priv->qmap_version == 9) { - add_qhdr_v5(skb, priv->mux_id); - } - else { - dev_kfree_skb_any (skb); - return NETDEV_TX_OK; - } - -#if defined(QUECTEL_UL_DATA_AGG) - err = rmnet_usb_tx_agg(skb, priv); -#else - skb->protocol = htons(ETH_P_MAP); - skb->dev = priv->real_dev; - if (!skb->destructor) - skb->destructor = rmnet_usb_tx_skb_destructor; - err = dev_queue_xmit(skb); -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 2,6,14 )) - if (err == NET_XMIT_SUCCESS) { - rmnet_vnd_update_tx_stats(pNet, 1, skb->len); - } else { - pNet->stats.tx_errors++; - } -#endif -#endif - - return err; -} - -#if (LINUX_VERSION_CODE < KERNEL_VERSION( 2,6,29 )) -#else -static const struct net_device_ops qmap_netdev_ops = { - .ndo_open = qmap_open, - .ndo_stop = qmap_stop, - .ndo_start_xmit = qmap_start_xmit, -}; -#endif - -#ifdef QUECTEL_BRIDGE_MODE -static int is_qmap_netdev(const struct net_device *netdev) { -#if (LINUX_VERSION_CODE < KERNEL_VERSION( 2,6,29 )) - return netdev->open == qmap_open; -#else - return netdev->netdev_ops == &qmap_netdev_ops; -#endif -} -#endif - -static int qmap_register_device(sGobiUSBNet * pDev, u8 offset_id) -{ - struct net_device *real_dev = pDev->mpNetDev->net; - struct net_device *qmap_net; - struct qmap_priv *priv; - int err; - - qmap_net = alloc_etherdev(sizeof(*priv)); - if (!qmap_net) - return -ENOBUFS; - - SET_NETDEV_DEV(qmap_net, &real_dev->dev); - priv = netdev_priv(qmap_net); - priv->offset_id = offset_id; - priv->mux_id = QUECTEL_QMAP_MUX_ID + offset_id; - priv->qmap_version = pDev->qmap_version; - priv->real_dev = real_dev; - priv->self_dev = qmap_net; - -#if defined(QUECTEL_UL_DATA_AGG) - priv->ul_data_aggregation_max_datagrams = 1; - priv->ul_data_aggregation_max_size = 2048; - priv->dl_minimum_padding = 0; - priv->agg_skb = NULL; - priv->agg_count = 0; - hrtimer_init(&priv->agg_hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); - priv->agg_hrtimer.function = rmnet_usb_tx_agg_timer_cb; - INIT_WORK(&priv->agg_wq, rmnet_usb_tx_agg_work); - ktime_get_ts64(&priv->agg_time); - spin_lock_init(&priv->agg_lock); -#endif - - sprintf(qmap_net->name, "%s.%d", real_dev->name, offset_id + 1); -#if (LINUX_VERSION_CODE < KERNEL_VERSION( 2,6,29 )) - qmap_net->open = qmap_open; - qmap_net->stop = qmap_stop; - qmap_net->hard_start_xmit = qmap_start_xmit; -#else - qmap_net->netdev_ops = &qmap_netdev_ops; -#endif - memcpy (qmap_net->dev_addr, real_dev->dev_addr, ETH_ALEN); - -#ifdef QUECTEL_BRIDGE_MODE - priv->m_bridge_mode = !!(pDev->m_bridge_mode & BIT(offset_id)); - qmap_net->sysfs_groups[0] = &qmi_qmap_sysfs_attr_group; -#endif - - err = register_netdev(qmap_net); - if (err < 0) { - INFO("register_netdev(%s), err=%d\n", qmap_net->name, err); - goto out_free_newdev; - } - netif_device_attach (qmap_net); - - pDev->mpQmapNetDev[offset_id] = qmap_net; - qmap_net->flags |= IFF_NOARP; - qmap_net->flags &= ~(IFF_BROADCAST | IFF_MULTICAST); - - INFO("%s\n", qmap_net->name); - - return 0; - -out_free_newdev: - free_netdev(qmap_net); - return err; -} - -static void qmap_unregister_device(sGobiUSBNet * pDev, u8 offset_id) { - struct net_device *qmap_net; -#if defined(QUECTEL_UL_DATA_AGG) - struct qmap_priv *priv; - unsigned long flags; -#endif - - qmap_net = pDev->mpQmapNetDev[offset_id]; - if (qmap_net == NULL) - return; - - netif_carrier_off(qmap_net); - netif_stop_queue(qmap_net); - -#if defined(QUECTEL_UL_DATA_AGG) - priv = netdev_priv(qmap_net); - hrtimer_cancel(&priv->agg_hrtimer); - cancel_work_sync(&priv->agg_wq); - spin_lock_irqsave(&priv->agg_lock, flags); - if (priv->agg_skb) { - kfree_skb(priv->agg_skb); - } - spin_unlock_irqrestore(&priv->agg_lock, flags); -#endif - - unregister_netdev(qmap_net); - free_netdev(qmap_net); -} - -static ssize_t qmap_mode_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct net_device *pNet = to_net_dev(dev); - struct usbnet * pDev = netdev_priv( pNet ); - sGobiUSBNet * pGobiDev = (sGobiUSBNet *)pDev->data[0]; - - return snprintf(buf, PAGE_SIZE, "%d\n", pGobiDev->qmap_mode); -} - -static DEVICE_ATTR(qmap_mode, S_IRUGO, qmap_mode_show, NULL); - -static ssize_t qmap_size_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct net_device *pNet = to_net_dev(dev); - struct usbnet * pDev = netdev_priv( pNet ); - sGobiUSBNet * pGobiDev = (sGobiUSBNet *)pDev->data[0]; - - return snprintf(buf, PAGE_SIZE, "%d\n", pGobiDev->qmap_size); -} - -static DEVICE_ATTR(qmap_size, S_IRUGO, qmap_size_show, NULL); - -static ssize_t link_state_show(struct device *dev, struct device_attribute *attr, char *buf) { - sGobiUSBNet *pQmapDev = net_to_qmap(to_net_dev(dev)); - - return snprintf(buf, PAGE_SIZE, "0x%x\n", pQmapDev->link_state); -} - -static ssize_t link_state_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - struct net_device *netdev = to_net_dev(dev); - sGobiUSBNet *pQmapDev = net_to_qmap(to_net_dev(dev)); - unsigned qmap_mode = pQmapDev->qmap_mode; - unsigned link_state = 0; - unsigned old_link = pQmapDev->link_state; - uint offset_id = 0; - - link_state = simple_strtoul(buf, NULL, 0); - if (qmap_mode == 1) { - pQmapDev->link_state = !!link_state; - } - else if (qmap_mode > 1) { - offset_id = ((link_state&0x7F) - 1); - - if (offset_id >= qmap_mode) { - dev_info(dev, "%s offset_id is %d. but qmap_mode is %d\n", __func__, offset_id, pQmapDev->qmap_mode); - return count; - } - - if (link_state&0x80) - pQmapDev->link_state &= ~(1 << offset_id); - else - pQmapDev->link_state |= (1 << offset_id); - } - - if (old_link != pQmapDev->link_state) { - struct net_device *qmap_net = pQmapDev->mpQmapNetDev[offset_id]; - - if (pQmapDev->link_state) { - netif_carrier_on(netdev); - } else { - netif_carrier_off(netdev); - } - - if (qmap_net && qmap_net != netdev) { - struct qmap_priv *priv = netdev_priv(qmap_net); - - priv->link_state = !!(pQmapDev->link_state & (1 << offset_id)); - if (priv->link_state) { - netif_carrier_on(qmap_net); - if (netif_queue_stopped(qmap_net) && !netif_queue_stopped(priv->real_dev)) - netif_wake_queue(qmap_net); - } - else - netif_carrier_off(qmap_net); - } - } - - if (old_link != pQmapDev->link_state) - dev_info(dev, "link_state 0x%x -> 0x%x\n", old_link, pQmapDev->link_state); - - return count; -} - -static DEVICE_ATTR(link_state, S_IWUSR | S_IRUGO, link_state_show, link_state_store); -#endif - -static struct attribute *gobinet_sysfs_attrs[] = { -#ifdef QUECTEL_BRIDGE_MODE - &dev_attr_bridge_mode.attr, - &dev_attr_bridge_ipv4.attr, -#endif -#ifdef QUECTEL_WWAN_QMAP - &dev_attr_qmap_mode.attr, - &dev_attr_qmap_size.attr, - &dev_attr_link_state.attr, -#endif - NULL, -}; - -static struct attribute_group gobinet_sysfs_attr_group = { - .attrs = gobinet_sysfs_attrs, -}; - -#if defined(QUECTEL_WWAN_QMAP) -typedef struct { - unsigned int size; - unsigned int rx_urb_size; - unsigned int ep_type; - unsigned int iface_id; - unsigned int qmap_mode; - unsigned int qmap_version; - unsigned int dl_minimum_padding; - char ifname[8][16]; - unsigned char mux_id[8]; -} RMNET_INFO; - -static void rmnet_info_set(struct sGobiUSBNet *pQmapDev, RMNET_INFO *rmnet_info) -{ - int i; - - memset(rmnet_info, 0, sizeof(*rmnet_info)); - rmnet_info->size = sizeof(RMNET_INFO); - rmnet_info->rx_urb_size = pQmapDev->qmap_size; - rmnet_info->ep_type = 2; //DATA_EP_TYPE_HSUSB - rmnet_info->iface_id = 4; - rmnet_info->qmap_mode = pQmapDev->qmap_mode; - rmnet_info->qmap_version = pQmapDev->qmap_version; - rmnet_info->dl_minimum_padding = 0; - - for (i = 0; i < pQmapDev->qmap_mode; i++) { - struct net_device *qmap_net = pQmapDev->mpQmapNetDev[i]; - - if (!qmap_net) - break; - - strcpy(rmnet_info->ifname[i], qmap_net->name); - rmnet_info->mux_id[i] = QUECTEL_QMAP_MUX_ID; - if (pQmapDev->qmap_mode > 1) { - struct qmap_priv *priv = netdev_priv(qmap_net); - - rmnet_info->mux_id[i] = priv->mux_id; - } - } -} - -static int qmap_ndo_do_ioctl(struct net_device *dev,struct ifreq *ifr, int cmd) { - int rc = -EOPNOTSUPP; - uint link_state = 0; - sGobiUSBNet *pQmapDev = net_to_qmap(dev); - - atomic_inc(&pQmapDev->refcount); - if (!pQmapDev->mbQMIReady) { - if (wait_for_completion_interruptible_timeout(&pQmapDev->mQMIReadyCompletion, 15*HZ) <= 0) { - if (atomic_dec_and_test(&pQmapDev->refcount)) { - kfree( pQmapDev ); - } - return -ETIMEDOUT; - } - } - atomic_dec(&pQmapDev->refcount); - - switch (cmd) { - case 0x89F1: //SIOCDEVPRIVATE - rc = copy_from_user(&link_state, ifr->ifr_ifru.ifru_data, sizeof(link_state)); - if (!rc) { - char buf[32]; - snprintf(buf, sizeof(buf), "%u", link_state); - link_state_store(&dev->dev, NULL, buf, strlen(buf)); - } - break; - - case 0x89F2: //SIOCDEVPRIVATE - rc = 0; - break; - - case 0x89F3: //SIOCDEVPRIVATE - if (pQmapDev->qmap_mode) { - RMNET_INFO rmnet_info; - - rmnet_info_set(pQmapDev, &rmnet_info); - rc = copy_to_user(ifr->ifr_ifru.ifru_data, &rmnet_info, sizeof(rmnet_info)); - } - break; - - default: - break; - } - - return rc; -} -#endif - -#ifdef CONFIG_PM -/*=========================================================================== -METHOD: - GobiNetSuspend (Public Method) - -DESCRIPTION: - Stops QMI traffic while device is suspended - -PARAMETERS - pIntf [ I ] - Pointer to interface - powerEvent [ I ] - Power management event - -RETURN VALUE: - int - 0 for success - negative errno for failure -===========================================================================*/ -static int GobiNetSuspend( - struct usb_interface * pIntf, - pm_message_t powerEvent ) -{ - struct usbnet * pDev; - sGobiUSBNet * pGobiDev; - - if (pIntf == 0) - { - return -ENOMEM; - } - -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 2,6,23 )) - pDev = usb_get_intfdata( pIntf ); -#else - pDev = (struct usbnet *)pIntf->dev.platform_data; -#endif - - if (pDev == NULL || pDev->net == NULL) - { - DBG( "failed to get netdevice\n" ); - return -ENXIO; - } - - pGobiDev = (sGobiUSBNet *)pDev->data[0]; - if (pGobiDev == NULL) - { - DBG( "failed to get QMIDevice\n" ); - return -ENXIO; - } - - if (pGobiDev->mbQMISyncIng) - { - DBG( "QMI sync ing\n" ); - return -EBUSY; - } - - // Is this autosuspend or system suspend? - // do we allow remote wakeup? -#if (LINUX_VERSION_CODE < KERNEL_VERSION( 2,6,33 )) -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 2,6,18 )) - if (pDev->udev->auto_pm == 0) -#else - if (1) -#endif -#else - if ((powerEvent.event & PM_EVENT_AUTO) == 0) -#endif - { - DBG( "device suspended to power level %d\n", - powerEvent.event ); - GobiSetDownReason( pGobiDev, DRIVER_SUSPENDED ); - } - else - { - DBG( "device autosuspend\n" ); - } - - if (powerEvent.event & PM_EVENT_SUSPEND) - { - // Stop QMI read callbacks - if (pGobiDev->m_qcrmcall_mode) { - } else { - KillRead( pGobiDev ); - } -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 2,6,22 )) - pDev->udev->reset_resume = 0; -#endif - - // Store power state to avoid duplicate resumes - pIntf->dev.power.power_state.event = powerEvent.event; - } - else - { - // Other power modes cause QMI connection to be lost -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 2,6,22 )) - pDev->udev->reset_resume = 1; -#endif - } - - // Run usbnet's suspend function - return usbnet_suspend( pIntf, powerEvent ); -} -int QuecGobiNetSuspend(struct usb_interface *pIntf, pm_message_t powerEvent ) { - return GobiNetSuspend(pIntf, powerEvent); -} - -/*=========================================================================== -METHOD: - GobiNetResume (Public Method) - -DESCRIPTION: - Resume QMI traffic or recreate QMI device - -PARAMETERS - pIntf [ I ] - Pointer to interface - -RETURN VALUE: - int - 0 for success - negative errno for failure -===========================================================================*/ -static int GobiNetResume( struct usb_interface * pIntf ) -{ - struct usbnet * pDev; - sGobiUSBNet * pGobiDev; - int nRet; - int oldPowerState; - - if (pIntf == 0) - { - return -ENOMEM; - } - -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 2,6,23 )) - pDev = usb_get_intfdata( pIntf ); -#else - pDev = (struct usbnet *)pIntf->dev.platform_data; -#endif - - if (pDev == NULL || pDev->net == NULL) - { - DBG( "failed to get netdevice\n" ); - return -ENXIO; - } - - pGobiDev = (sGobiUSBNet *)pDev->data[0]; - if (pGobiDev == NULL) - { - DBG( "failed to get QMIDevice\n" ); - return -ENXIO; - } - - oldPowerState = pIntf->dev.power.power_state.event; - pIntf->dev.power.power_state.event = PM_EVENT_ON; - DBG( "resuming from power mode %d\n", oldPowerState ); - - if (oldPowerState & PM_EVENT_SUSPEND) - { - // It doesn't matter if this is autoresume or system resume - GobiClearDownReason( pGobiDev, DRIVER_SUSPENDED ); - - nRet = usbnet_resume( pIntf ); - if (nRet != 0) - { - DBG( "usbnet_resume error %d\n", nRet ); - return nRet; - } - - // Restart QMI read callbacks - if (pGobiDev->m_qcrmcall_mode) { - nRet = 0; - } else { - nRet = StartRead( pGobiDev ); - } - if (nRet != 0) - { - DBG( "StartRead error %d\n", nRet ); - return nRet; - } - -#ifdef CONFIG_PM - #if (LINUX_VERSION_CODE < KERNEL_VERSION( 2,6,29 )) - // Kick Auto PM thread to process any queued URBs - complete( &pGobiDev->mAutoPM.mThreadDoWork ); - #endif -#endif /* CONFIG_PM */ - -#if defined(QUECTEL_WWAN_QMAP) - if ((!netif_queue_stopped(pDev->net)) && (pGobiDev->qmap_mode > 1)) { - rmnet_usb_tx_wake_queue((unsigned long )pGobiDev); - } -#endif - } - else - { - DBG( "nothing to resume\n" ); - return 0; - } - - return nRet; -} -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 2,6,27 )) -static int GobiNetResetResume( struct usb_interface * pIntf ) -{ - INFO( "device do not support reset_resume\n" ); - pIntf->needs_binding = 1; - - return -EOPNOTSUPP; -} -#endif -#endif /* CONFIG_PM */ - -static void ql_net_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *info) -{ - usbnet_get_drvinfo(net, info); - /* Inherit standard device info */ - strlcpy(info->driver, driver_name, sizeof(info->driver)); - strlcpy(info->version, VERSION_NUMBER, sizeof(info->version)); -} - -static struct ethtool_ops ql_net_ethtool_ops; - -/*=========================================================================== -METHOD: - GobiNetDriverBind (Public Method) - -DESCRIPTION: - Setup in and out pipes - -PARAMETERS - pDev [ I ] - Pointer to usbnet device - pIntf [ I ] - Pointer to interface - -RETURN VALUE: - int - 0 for success - Negative errno for error -===========================================================================*/ -static int GobiNetDriverBind( - struct usbnet * pDev, - struct usb_interface * pIntf ) -{ - int numEndpoints; - int endpointIndex; - struct usb_host_endpoint * pEndpoint = NULL; - struct usb_host_endpoint * pIn = NULL; - struct usb_host_endpoint * pOut = NULL; - - // Verify one altsetting - if (pIntf->num_altsetting != 1) - { - DBG( "invalid num_altsetting %u\n", pIntf->num_altsetting ); - return -ENODEV; - } - - // Verify correct interface (4 for UC20) - if ( !test_bit(pIntf->cur_altsetting->desc.bInterfaceNumber, &pDev->driver_info->data)) - { - DBG( "invalid interface %d\n", - pIntf->cur_altsetting->desc.bInterfaceNumber ); - return -ENODEV; - } - - if ( pIntf->cur_altsetting->desc.bInterfaceClass != 0xff) - { - struct usb_interface_descriptor *desc = &pIntf->cur_altsetting->desc; - const char *qcfg_usbnet = "UNKNOW"; - - if (desc->bInterfaceClass == 2 && desc->bInterfaceSubClass == 0x0e) { - qcfg_usbnet = "MBIM"; - } else if (desc->bInterfaceClass == 2 && desc->bInterfaceSubClass == 0x06) { - qcfg_usbnet = "ECM"; - } else if (desc->bInterfaceClass == 0xe0 && desc->bInterfaceSubClass == 1 && desc->bInterfaceProtocol == 3) { - qcfg_usbnet = "RNDIS"; - } - - INFO( "usbnet is %s not NDIS/RMNET!\n", qcfg_usbnet); - - return -ENODEV; - } - - // Collect In and Out endpoints - numEndpoints = pIntf->cur_altsetting->desc.bNumEndpoints; - for (endpointIndex = 0; endpointIndex < numEndpoints; endpointIndex++) - { - pEndpoint = pIntf->cur_altsetting->endpoint + endpointIndex; - if (pEndpoint == NULL) - { - DBG( "invalid endpoint %u\n", endpointIndex ); - return -ENODEV; - } - - if (usb_endpoint_dir_in( &pEndpoint->desc ) == true - && usb_endpoint_xfer_int( &pEndpoint->desc ) == false) - { - pIn = pEndpoint; - } - else if (usb_endpoint_dir_out( &pEndpoint->desc ) == true) - { - pOut = pEndpoint; - } - } - - if (pIn == NULL || pOut == NULL) - { - DBG( "invalid endpoints\n" ); - return -ENODEV; - } - - if (usb_set_interface( pDev->udev, - pIntf->cur_altsetting->desc.bInterfaceNumber, - 0 ) != 0) - { - DBG( "unable to set interface\n" ); - return -ENODEV; - } - - pDev->in = usb_rcvbulkpipe( pDev->udev, - pIn->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK ); - pDev->out = usb_sndbulkpipe( pDev->udev, - pOut->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK ); - -#if defined(QUECTEL_WWAN_MULTI_PACKAGES) - if (rx_packets && pDev->udev->descriptor.idVendor == cpu_to_le16(0x2C7C)) { - struct multi_package_config rx_config = { - .enable = cpu_to_le32(1), - .package_max_len = cpu_to_le32((1500 + sizeof(struct quec_net_package_header)) * rx_packets), - .package_max_count_in_queue = cpu_to_le32(rx_packets), - .timeout = cpu_to_le32(10*1000), //10ms - }; - int ret = 0; - - ret = usb_control_msg( - interface_to_usbdev(pIntf), - usb_sndctrlpipe(interface_to_usbdev(pIntf), 0), - USB_CDC_SET_MULTI_PACKAGE_COMMAND, - 0x21, //USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE - 1, - pIntf->cur_altsetting->desc.bInterfaceNumber, - &rx_config, sizeof(rx_config), 100); - - DBG( "Quectel EC21&EC25 rx_packets=%d, ret=%d\n", rx_packets, ret); - if (ret == sizeof(rx_config)) { - pDev->rx_urb_size = le32_to_cpu(rx_config.package_max_len); - } else { - rx_packets = 0; - } - } -#endif - -#if 1 //def DATA_MODE_RP - /* make MAC addr easily distinguishable from an IP header */ - if ((pDev->net->dev_addr[0] & 0xd0) == 0x40) { - /*clear this bit wil make usbnet apdater named as usbX(instead if ethX)*/ - pDev->net->dev_addr[0] |= 0x02; /* set local assignment bit */ - pDev->net->dev_addr[0] &= 0xbf; /* clear "IP" bit */ - } - memcpy (pDev->net->dev_addr, node_id, sizeof node_id); - pDev->net->flags &= ~(IFF_BROADCAST | IFF_MULTICAST); - pDev->net->features |= (NETIF_F_VLAN_CHALLENGED); -#endif - - ql_net_ethtool_ops = *pDev->net->ethtool_ops; - ql_net_ethtool_ops.get_drvinfo = ql_net_get_drvinfo; - pDev->net->ethtool_ops = &ql_net_ethtool_ops; - - DBG( "in %x, out %x\n", - pIn->desc.bEndpointAddress, - pOut->desc.bEndpointAddress ); - - // In later versions of the kernel, usbnet helps with this -#if (LINUX_VERSION_CODE <= KERNEL_VERSION( 2,6,23 )) - pIntf->dev.platform_data = (void *)pDev; -#endif - - if (qcrmcall_mode == 0 && pDev->net->sysfs_groups[0] == NULL && gobinet_sysfs_attr_group.attrs[0] != NULL) { -#if (LINUX_VERSION_CODE <= KERNEL_VERSION( 2,6,32)) //see commit 0c509a6c9393b27a8c5a01acd4a72616206cfc24 - pDev->net->sysfs_groups[1] = &gobinet_sysfs_attr_group; //see netdev_register_sysfs() -#else - pDev->net->sysfs_groups[0] = &gobinet_sysfs_attr_group; -#endif - } - - if (!pDev->rx_urb_size) { -//to advoid module report mtu 1460, but rx 1500 bytes IP packets, and cause the customer's system crash -//next setting can make usbnet.c:usbnet_change_mtu() do not modify rx_urb_size according to mtu - pDev->rx_urb_size = ETH_DATA_LEN + ETH_HLEN + 6; - } - - return 0; -} - -/*=========================================================================== -METHOD: - GobiNetDriverUnbind (Public Method) - -DESCRIPTION: - Deregisters QMI device (Registration happened in the probe function) - -PARAMETERS - pDev [ I ] - Pointer to usbnet device - pIntfUnused [ I ] - Pointer to interface - -RETURN VALUE: - None -===========================================================================*/ -static void GobiNetDriverUnbind( - struct usbnet * pDev, - struct usb_interface * pIntf) -{ - sGobiUSBNet * pGobiDev = (sGobiUSBNet *)pDev->data[0]; - - // Should already be down, but just in case... - netif_carrier_off( pDev->net ); - - if (pGobiDev->m_qcrmcall_mode) { - } else { - DeregisterQMIDevice( pGobiDev ); - } - -#if (LINUX_VERSION_CODE >= KERNEL_VERSION( 2,6,29 )) - kfree( pDev->net->netdev_ops ); - pDev->net->netdev_ops = NULL; -#endif - -#if (LINUX_VERSION_CODE <= KERNEL_VERSION( 2,6,23 )) - pIntf->dev.platform_data = NULL; -#endif - -#if (LINUX_VERSION_CODE >= KERNEL_VERSION( 2,6,19 )) - pIntf->needs_remote_wakeup = 0; -#endif - - if (atomic_dec_and_test(&pGobiDev->refcount)) - kfree( pGobiDev ); - else - INFO("memory leak!\n"); -} - -#if 1 //def DATA_MODE_RP - -#if defined(QUECTEL_WWAN_QMAP) -static void _rmnet_usb_rx_handler(struct usbnet *dev, struct sk_buff *skb_in) -{ - sGobiUSBNet * pQmapDev = (sGobiUSBNet *)dev->data[0]; - struct sk_buff *qmap_skb; - struct sk_buff_head skb_chain; - uint dl_minimum_padding = 0; - -#if defined(QUECTEL_UL_DATA_AGG) - if (pQmapDev->qmap_version == 9) - dl_minimum_padding = pQmapDev->agg_ctx.dl_minimum_padding; -#endif - - __skb_queue_head_init(&skb_chain); - - while (skb_in->len > sizeof(struct qmap_hdr)) { - struct rmnet_map_header *map_header = (struct rmnet_map_header *)skb_in->data; - struct rmnet_map_v5_csum_header *ul_header = NULL; - size_t hdr_size = sizeof(struct rmnet_map_header); - struct net_device *qmap_net; - int pkt_len = ntohs(map_header->pkt_len); - int skb_len; - __be16 protocol; - int mux_id; - - if (map_header->next_hdr) { - ul_header = (struct rmnet_map_v5_csum_header *)(map_header + 1); - hdr_size += sizeof(struct rmnet_map_v5_csum_header); - } - - skb_len = pkt_len - (map_header->pad_len&0x3F); - skb_len -= dl_minimum_padding; - if (skb_len > 1500) { - dev_info(&dev->net->dev, "drop skb_len=%x larger than 1500\n", skb_len); - goto error_pkt; - } - - if (skb_in->len < (pkt_len + hdr_size)) { - dev_info(&dev->net->dev, "drop qmap unknow pkt, len=%d, pkt_len=%d\n", skb_in->len, pkt_len); - goto error_pkt; - } - - if (map_header->cd_bit) { - dev_info(&dev->net->dev, "skip qmap command packet\n"); - goto skip_pkt; - } - - switch (skb_in->data[hdr_size] & 0xf0) { - case 0x40: - protocol = htons(ETH_P_IP); - break; - case 0x60: - protocol = htons(ETH_P_IPV6); - break; - default: - dev_info(&dev->net->dev, "unknow skb->protocol %02x\n", skb_in->data[hdr_size]); - goto error_pkt; - } - - mux_id = map_header->mux_id - QUECTEL_QMAP_MUX_ID; - if (mux_id >= pQmapDev->qmap_mode) { - dev_info(&dev->net->dev, "drop qmap unknow mux_id %x\n", map_header->mux_id); - goto error_pkt; - } - - qmap_net = pQmapDev->mpQmapNetDev[mux_id]; - - if (qmap_net == NULL) { - dev_info(&dev->net->dev, "drop qmap unknow mux_id %x\n", map_header->mux_id); - goto skip_pkt; - } - - qmap_skb = netdev_alloc_skb(qmap_net, skb_len); - if (qmap_skb) { - skb_put(qmap_skb, skb_len); - memcpy(qmap_skb->data, skb_in->data + hdr_size, skb_len); - } - - if (qmap_skb == NULL) { - dev_info(&dev->net->dev, "fail to alloc skb, pkt_len = %d\n", skb_len); - goto error_pkt; - } - - skb_reset_transport_header(qmap_skb); - skb_reset_network_header(qmap_skb); - qmap_skb->pkt_type = PACKET_HOST; - skb_set_mac_header(qmap_skb, 0); - qmap_skb->protocol = protocol; - - if (ul_header && ul_header->header_type == RMNET_MAP_HEADER_TYPE_CSUM_OFFLOAD - && ul_header->csum_valid_required) { -#if 0 //TODO - qmap_skb->ip_summed = CHECKSUM_UNNECESSARY; -#endif - } - - if (qmap_skb->dev->type == ARPHRD_ETHER) { - skb_push(qmap_skb, ETH_HLEN); - skb_reset_mac_header(qmap_skb); - memcpy(eth_hdr(qmap_skb)->h_source, default_modem_addr, ETH_ALEN); - memcpy(eth_hdr(qmap_skb)->h_dest, qmap_net->dev_addr, ETH_ALEN); - eth_hdr(qmap_skb)->h_proto = protocol; -#ifdef QUECTEL_BRIDGE_MODE - bridge_mode_rx_fixup(pQmapDev, qmap_net, qmap_skb); -#endif - } - - __skb_queue_tail(&skb_chain, qmap_skb); - -skip_pkt: - skb_pull(skb_in, pkt_len + hdr_size); - } - -error_pkt: - while ((qmap_skb = __skb_dequeue (&skb_chain))) { - if (qmap_skb->dev != dev->net) { - if (qmap_skb->dev->type == ARPHRD_ETHER) - __skb_pull(qmap_skb, ETH_HLEN); - rmnet_vnd_update_rx_stats(qmap_skb->dev, 1, qmap_skb->len); - netif_rx(qmap_skb); - } - else { - qmap_skb->protocol = 0; - usbnet_skb_return(dev, qmap_skb); - } - } -} - -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 2,6,35 )) //ab95bfe01f9872459c8678572ccadbf646badad0 -#if (LINUX_VERSION_CODE < KERNEL_VERSION( 2,6,39 )) //8a4eb5734e8d1dc60a8c28576bbbdfdcc643626d -static struct sk_buff* rmnet_usb_rx_handler(struct sk_buff *skb) -{ - struct usbnet *dev; - - if (!skb) - goto done; - - //printk("%s skb=%p, protocol=%x, len=%d\n", __func__, skb, skb->protocol, skb->len); - - if (skb->pkt_type == PACKET_LOOPBACK) - return skb; - - if (skb->protocol != htons(ETH_P_MAP)) { - WARN_ON(1); - return skb; - } - - dev = netdev_priv(skb->dev); - - if (dev == NULL) { - WARN_ON(1); - return skb; - } - - _rmnet_usb_rx_handler(dev, skb); - consume_skb(skb); - -done: - return NULL; -} -#else -static rx_handler_result_t rmnet_usb_rx_handler(struct sk_buff **pskb) -{ - struct sk_buff *skb = *pskb; - struct usbnet *dev; - - if (!skb) - goto done; - - //printk("%s skb=%p, protocol=%x, len=%d\n", __func__, skb, skb->protocol, skb->len); - - if (skb->pkt_type == PACKET_LOOPBACK) - return RX_HANDLER_PASS; - - if (skb->protocol != htons(ETH_P_MAP)) { - WARN_ON(1); - return RX_HANDLER_PASS; - } - - dev = netdev_priv(skb->dev); - - if (dev == NULL) { - WARN_ON(1); - return RX_HANDLER_PASS; - } - - _rmnet_usb_rx_handler(dev, skb); - consume_skb(skb); - -done: - return RX_HANDLER_CONSUMED; -} -#endif -#endif -#endif -/*=========================================================================== -METHOD: - GobiNetDriverTxFixup (Public Method) - -DESCRIPTION: - Handling data format mode on transmit path - -PARAMETERS - pDev [ I ] - Pointer to usbnet device - pSKB [ I ] - Pointer to transmit packet buffer - flags [ I ] - os flags - -RETURN VALUE: - None -===========================================================================*/ -static struct sk_buff *GobiNetDriverTxFixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) -{ - sGobiUSBNet * pGobiDev = (sGobiUSBNet *)dev->data[0]; - - if (!pGobiDev) { - DBG( "failed to get QMIDevice\n" ); - dev_kfree_skb_any(skb); - return NULL; - } - - if (unlikely(!skb)) { - return NULL; - } - - if (!pGobiDev->mbRawIPMode) - return skb; - -#ifdef QUECTEL_WWAN_QMAP - if (pGobiDev->qmap_mode > 1) { - if (skb->protocol == htons(ETH_P_MAP)) - return skb; - - goto drop_skb; - } - else if (pGobiDev->qmap_mode == 1) { - if (unlikely(!pGobiDev->link_state)) { - dev_info(&dev->net->dev, "link_state 0x%x, drop skb, len = %u\n", pGobiDev->link_state, skb->len); - goto drop_skb; - } - - if (dev->net->type == ARPHRD_ETHER) { -#ifdef QUECTEL_BRIDGE_MODE - if (pGobiDev->m_bridge_mode && bridge_mode_tx_fixup(dev->net, skb, pGobiDev->m_bridge_ipv4, pGobiDev->mHostMAC) == NULL) { - goto drop_skb; - } -#endif - - if (ether_to_ip_fixup(dev->net, skb) == NULL) - goto drop_skb; - } - - if (pGobiDev->qmap_version == 5) { - add_qhdr(skb, QUECTEL_QMAP_MUX_ID); - } - else if (pGobiDev->qmap_version == 9) { - add_qhdr_v5(skb, QUECTEL_QMAP_MUX_ID); - } - else { - goto drop_skb; - } - - return skb; - } -#endif - -#ifdef QUECTEL_BRIDGE_MODE - if (pGobiDev->m_bridge_mode && bridge_mode_tx_fixup(dev->net, skb, pGobiDev->m_bridge_ipv4, pGobiDev->mHostMAC) == NULL) { - goto drop_skb; - } -#endif - - // Skip Ethernet header from message - if (likely(ether_to_ip_fixup(dev->net, skb))) { - return skb; - } - else { -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 2,6,22 )) - dev_err(&dev->intf->dev, "Packet Dropped "); -#elif (LINUX_VERSION_CODE > KERNEL_VERSION( 2,6,18 )) - dev_err(dev->net->dev.parent, "Packet Dropped "); -#else - INFO("Packet Dropped "); -#endif - } - -#if defined(QUECTEL_WWAN_QMAP) -drop_skb: -#endif -#if (LINUX_VERSION_CODE <= KERNEL_VERSION( 2,6,24 )) && defined(CONFIG_X86_32) - INFO("dev_kfree_skb_any() will make kernel panic on CentOS!\n"); - quec_debug=1;PrintHex(skb->data, 32);quec_debug=0; -#else - // Filter the packet out, release it - dev_kfree_skb_any(skb); -#endif - - return NULL; -} - -#if defined(QUECTEL_WWAN_MULTI_PACKAGES) -static int GobiNetDriverRxPktsFixup(struct usbnet *dev, struct sk_buff *skb) -{ - sGobiUSBNet * pGobiDev = (sGobiUSBNet *)dev->data[0]; - - if (!pGobiDev->mbRawIPMode) - return 1; - - /* This check is no longer done by usbnet */ - if (skb->len < dev->net->hard_header_len) - return 0; - - if (!rx_packets) { - return GobiNetDriverRxFixup(dev, skb); - } - - while (likely(skb->len)) { - struct sk_buff* new_skb; - struct quec_net_package_header package_header; - - if (skb->len < sizeof(package_header)) - return 0; - - memcpy(&package_header, skb->data, sizeof(package_header)); - package_header.payload_len = be16_to_cpu(package_header.payload_len); - - if (package_header.msg_spec != QUEC_NET_MSG_SPEC || package_header.msg_id != QUEC_NET_MSG_ID_IP_DATA) - return 0; - - if (skb->len < (package_header.payload_len + sizeof(package_header))) - return 0; - - skb_pull(skb, sizeof(package_header)); - - if (skb->len == package_header.payload_len) - return GobiNetDriverRxFixup(dev, skb); - - new_skb = skb_clone(skb, GFP_ATOMIC); - if (new_skb) { - skb_trim(new_skb, package_header.payload_len); - if (GobiNetDriverRxFixup(dev, new_skb)) - usbnet_skb_return(dev, new_skb); - else - return 0; - } - - skb_pull(skb, package_header.payload_len); - } - - return 0; -} -#endif - -#ifdef QUECTEL_WWAN_QMAP -static int GobiNetDriverRxQmapFixup(struct usbnet *dev, struct sk_buff *skb) -{ -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 2,6,35 )) //ab95bfe01f9872459c8678572ccadbf646badad0 - rx_handler_func_t *rx_handler; - -#if (LINUX_VERSION_CODE < KERNEL_VERSION( 3,3,1 )) //7bdd402706cf26bfef9050dfee3f229b7f33ee4f - if (skb->dev == NULL) { - skb->dev = dev->net; - } -#endif - rx_handler = rcu_dereference(skb->dev->rx_handler); - - if (rx_handler == rmnet_usb_rx_handler) { -#if (LINUX_VERSION_CODE < KERNEL_VERSION( 3,3,1 )) //7bdd402706cf26bfef9050dfee3f229b7f33ee4f - unsigned headroom = skb_headroom(skb); - if (headroom < ETH_HLEN) { - unsigned tailroom = skb_tailroom(skb); - if ((tailroom + headroom) >= ETH_HLEN) { - unsigned moveroom = ETH_HLEN - headroom; - memmove(skb->data + moveroom ,skb->data, skb->len); - skb->data += moveroom; - skb->tail += moveroom; - #ifdef WARN_ONCE - WARN_ONCE(1, "It is better reserve headroom in usbnet.c:rx_submit()!\n"); - #endif - } - } -#endif - - if (dev->net->type == ARPHRD_ETHER && skb_headroom(skb) >= ETH_HLEN) { - //usbnet.c rx_process() usbnet_skb_return() eth_type_trans() - skb_push(skb, ETH_HLEN); - skb_reset_mac_header(skb); - memcpy(eth_hdr(skb)->h_source, default_modem_addr, ETH_ALEN); - memcpy(eth_hdr(skb)->h_dest, dev->net->dev_addr, ETH_ALEN); - eth_hdr(skb)->h_proto = htons(ETH_P_MAP); - - return 1; - } - -#ifdef WARN_ONCE - WARN_ONCE(1, "skb_headroom < ETH_HLEN\n"); -#endif - return 0; - } -#endif - - _rmnet_usb_rx_handler(dev, skb); - return 0; -} -#endif -/*=========================================================================== -METHOD: - GobiNetDriverRxFixup (Public Method) - -DESCRIPTION: - Handling data format mode on receive path - -PARAMETERS - pDev [ I ] - Pointer to usbnet device - pSKB [ I ] - Pointer to received packet buffer - -RETURN VALUE: - None -===========================================================================*/ -static int GobiNetDriverRxFixup(struct usbnet *dev, struct sk_buff *skb) -{ - __be16 proto; - sGobiUSBNet * pGobiDev = (sGobiUSBNet *)dev->data[0]; - - if (!pGobiDev->mbRawIPMode) - return 1; - - /* This check is no longer done by usbnet */ - if (skb->len < dev->net->hard_header_len) - return 0; - -#ifdef QUECTEL_WWAN_QMAP - if (pGobiDev->qmap_mode) { - return GobiNetDriverRxQmapFixup(dev, skb); - } -#endif - - switch (skb->data[0] & 0xf0) { - case 0x40: - proto = htons(ETH_P_IP); - break; - case 0x60: - proto = htons(ETH_P_IPV6); - break; - case 0x00: - if (is_multicast_ether_addr(skb->data)) - return 1; - /* possibly bogus destination - rewrite just in case */ - skb_reset_mac_header(skb); - goto fix_dest; - default: - /* pass along other packets without modifications */ - return 1; - } - if (skb_headroom(skb) < ETH_HLEN && pskb_expand_head(skb, ETH_HLEN, 0, GFP_ATOMIC)) { - DBG("%s: couldn't pskb_expand_head\n", __func__); - return 0; - } - skb_push(skb, ETH_HLEN); - skb_reset_mac_header(skb); - eth_hdr(skb)->h_proto = proto; - memcpy(eth_hdr(skb)->h_source, ec20_mac, ETH_ALEN); -fix_dest: -#ifdef QUECTEL_BRIDGE_MODE - bridge_mode_rx_fixup(pGobiDev, dev->net, skb); -#else - memcpy(eth_hdr(skb)->h_dest, dev->net->dev_addr, ETH_ALEN); -#endif - -#ifdef QUECTEL_BRIDGE_MODE -#if 0 - if (pGobiDev->m_bridge_mode) { - struct ethhdr *ehdr = eth_hdr(skb); -quec_debug = 1; - DBG(": "); - PrintHex(ehdr, sizeof(struct ethhdr)); -quec_debug = 0; - } -#endif -#endif - - return 1; -} -#endif - -#if (LINUX_VERSION_CODE < KERNEL_VERSION( 2,6,29 )) -#ifdef CONFIG_PM -/*=========================================================================== -METHOD: - GobiUSBNetURBCallback (Public Method) - -DESCRIPTION: - Write is complete, cleanup and signal that we're ready for next packet - -PARAMETERS - pURB [ I ] - Pointer to sAutoPM struct - -RETURN VALUE: - None -===========================================================================*/ -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 2,6,18 )) -void GobiUSBNetURBCallback( struct urb * pURB ) -#else -void GobiUSBNetURBCallback(struct urb *pURB, struct pt_regs *regs) -#endif -{ - unsigned long activeURBflags; - sAutoPM * pAutoPM = (sAutoPM *)pURB->context; - if (pAutoPM == NULL) - { - // Should never happen - DBG( "bad context\n" ); - return; - } - - if (pURB->status != 0) - { - // Note that in case of an error, the behaviour is no different - DBG( "urb finished with error %d\n", pURB->status ); - } - - // Remove activeURB (memory to be freed later) - spin_lock_irqsave( &pAutoPM->mActiveURBLock, activeURBflags ); - - // EAGAIN used to signify callback is done - pAutoPM->mpActiveURB = ERR_PTR( -EAGAIN ); - - spin_unlock_irqrestore( &pAutoPM->mActiveURBLock, activeURBflags ); - - complete( &pAutoPM->mThreadDoWork ); - -#ifdef URB_FREE_BUFFER_BY_SELF - if (pURB->transfer_flags & URB_FREE_BUFFER) - kfree(pURB->transfer_buffer); -#endif - usb_free_urb( pURB ); -} - -/*=========================================================================== -METHOD: - GobiUSBNetTXTimeout (Public Method) - -DESCRIPTION: - Timeout declared by the net driver. Stop all transfers - -PARAMETERS - pNet [ I ] - Pointer to net device - -RETURN VALUE: - None -===========================================================================*/ -void GobiUSBNetTXTimeout( struct net_device * pNet ) -{ - struct sGobiUSBNet * pGobiDev; - sAutoPM * pAutoPM; - sURBList * pURBListEntry; - unsigned long activeURBflags, URBListFlags; - struct usbnet * pDev = netdev_priv( pNet ); - struct urb * pURB; - - if (pDev == NULL || pDev->net == NULL) - { - DBG( "failed to get usbnet device\n" ); - return; - } - - pGobiDev = (sGobiUSBNet *)pDev->data[0]; - if (pGobiDev == NULL) - { - DBG( "failed to get QMIDevice\n" ); - return; - } - pAutoPM = &pGobiDev->mAutoPM; - - DBG( "\n" ); - - // Grab a pointer to active URB - spin_lock_irqsave( &pAutoPM->mActiveURBLock, activeURBflags ); - pURB = pAutoPM->mpActiveURB; - spin_unlock_irqrestore( &pAutoPM->mActiveURBLock, activeURBflags ); - // Stop active URB - if (pURB != NULL) - { - usb_kill_urb( pURB ); - } - - // Cleanup URB List - spin_lock_irqsave( &pAutoPM->mURBListLock, URBListFlags ); - - pURBListEntry = pAutoPM->mpURBList; - while (pURBListEntry != NULL) - { - pAutoPM->mpURBList = pAutoPM->mpURBList->mpNext; - atomic_dec( &pAutoPM->mURBListLen ); - usb_free_urb( pURBListEntry->mpURB ); - kfree( pURBListEntry ); - pURBListEntry = pAutoPM->mpURBList; - } - - spin_unlock_irqrestore( &pAutoPM->mURBListLock, URBListFlags ); - - complete( &pAutoPM->mThreadDoWork ); - - return; -} - -/*=========================================================================== -METHOD: - GobiUSBNetAutoPMThread (Public Method) - -DESCRIPTION: - Handle device Auto PM state asynchronously - Handle network packet transmission asynchronously - -PARAMETERS - pData [ I ] - Pointer to sAutoPM struct - -RETURN VALUE: - int - 0 for success - Negative errno for error -===========================================================================*/ -static int GobiUSBNetAutoPMThread( void * pData ) -{ - unsigned long activeURBflags, URBListFlags; - sURBList * pURBListEntry; - int status; - struct usb_device * pUdev; - sAutoPM * pAutoPM = (sAutoPM *)pData; - struct urb * pURB; - - if (pAutoPM == NULL) - { - DBG( "passed null pointer\n" ); - return -EINVAL; - } - - pUdev = interface_to_usbdev( pAutoPM->mpIntf ); - - DBG( "traffic thread started\n" ); - - while (pAutoPM->mbExit == false) - { - // Wait for someone to poke us - wait_for_completion_interruptible( &pAutoPM->mThreadDoWork ); - - // Time to exit? - if (pAutoPM->mbExit == true) - { - // Stop activeURB - spin_lock_irqsave( &pAutoPM->mActiveURBLock, activeURBflags ); - pURB = pAutoPM->mpActiveURB; - spin_unlock_irqrestore( &pAutoPM->mActiveURBLock, activeURBflags ); - - // EAGAIN used to signify callback is done - if (IS_ERR( pAutoPM->mpActiveURB ) - && PTR_ERR( pAutoPM->mpActiveURB ) == -EAGAIN ) - { - pURB = NULL; - } - - if (pURB != NULL) - { - usb_kill_urb( pURB ); - } - // Will be freed in callback function - - // Cleanup URB List - spin_lock_irqsave( &pAutoPM->mURBListLock, URBListFlags ); - - pURBListEntry = pAutoPM->mpURBList; - while (pURBListEntry != NULL) - { - pAutoPM->mpURBList = pAutoPM->mpURBList->mpNext; - atomic_dec( &pAutoPM->mURBListLen ); - usb_free_urb( pURBListEntry->mpURB ); - kfree( pURBListEntry ); - pURBListEntry = pAutoPM->mpURBList; - } - - spin_unlock_irqrestore( &pAutoPM->mURBListLock, URBListFlags ); - - break; - } - - // Is our URB active? - spin_lock_irqsave( &pAutoPM->mActiveURBLock, activeURBflags ); - - // EAGAIN used to signify callback is done - if (IS_ERR( pAutoPM->mpActiveURB ) - && PTR_ERR( pAutoPM->mpActiveURB ) == -EAGAIN ) - { - pAutoPM->mpActiveURB = NULL; - - // Restore IRQs so task can sleep - spin_unlock_irqrestore( &pAutoPM->mActiveURBLock, activeURBflags ); - - // URB is done, decrement the Auto PM usage count - usb_autopm_put_interface( pAutoPM->mpIntf ); - - // Lock ActiveURB again - spin_lock_irqsave( &pAutoPM->mActiveURBLock, activeURBflags ); - } - - if (pAutoPM->mpActiveURB != NULL) - { - // There is already a URB active, go back to sleep - spin_unlock_irqrestore( &pAutoPM->mActiveURBLock, activeURBflags ); - continue; - } - - // Is there a URB waiting to be submitted? - spin_lock_irqsave( &pAutoPM->mURBListLock, URBListFlags ); - if (pAutoPM->mpURBList == NULL) - { - // No more URBs to submit, go back to sleep - spin_unlock_irqrestore( &pAutoPM->mURBListLock, URBListFlags ); - spin_unlock_irqrestore( &pAutoPM->mActiveURBLock, activeURBflags ); - continue; - } - - // Pop an element - pURBListEntry = pAutoPM->mpURBList; - pAutoPM->mpURBList = pAutoPM->mpURBList->mpNext; - atomic_dec( &pAutoPM->mURBListLen ); - spin_unlock_irqrestore( &pAutoPM->mURBListLock, URBListFlags ); - - // Set ActiveURB - pAutoPM->mpActiveURB = pURBListEntry->mpURB; - spin_unlock_irqrestore( &pAutoPM->mActiveURBLock, activeURBflags ); - - // Tell autopm core we need device woken up - status = usb_autopm_get_interface( pAutoPM->mpIntf ); - if (status < 0) - { - DBG( "unable to autoresume interface: %d\n", status ); - - // likely caused by device going from autosuspend -> full suspend - if (status == -EPERM) - { -#if (LINUX_VERSION_CODE < KERNEL_VERSION( 2,6,33 )) -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 2,6,18 )) - pUdev->auto_pm = 0; -#else - pUdev = pUdev; -#endif -#endif - GobiNetSuspend( pAutoPM->mpIntf, PMSG_SUSPEND ); - } - - // Add pURBListEntry back onto pAutoPM->mpURBList - spin_lock_irqsave( &pAutoPM->mURBListLock, URBListFlags ); - pURBListEntry->mpNext = pAutoPM->mpURBList; - pAutoPM->mpURBList = pURBListEntry; - atomic_inc( &pAutoPM->mURBListLen ); - spin_unlock_irqrestore( &pAutoPM->mURBListLock, URBListFlags ); - - spin_lock_irqsave( &pAutoPM->mActiveURBLock, activeURBflags ); - pAutoPM->mpActiveURB = NULL; - spin_unlock_irqrestore( &pAutoPM->mActiveURBLock, activeURBflags ); - - // Go back to sleep - continue; - } - - // Submit URB - status = usb_submit_urb( pAutoPM->mpActiveURB, GFP_KERNEL ); - if (status < 0) - { - // Could happen for a number of reasons - DBG( "Failed to submit URB: %d. Packet dropped\n", status ); - spin_lock_irqsave( &pAutoPM->mActiveURBLock, activeURBflags ); - usb_free_urb( pAutoPM->mpActiveURB ); - pAutoPM->mpActiveURB = NULL; - spin_unlock_irqrestore( &pAutoPM->mActiveURBLock, activeURBflags ); - usb_autopm_put_interface( pAutoPM->mpIntf ); - - // Loop again - complete( &pAutoPM->mThreadDoWork ); - } - - kfree( pURBListEntry ); - } - - DBG( "traffic thread exiting\n" ); - pAutoPM->mpThread = NULL; - return 0; -} - -/*=========================================================================== -METHOD: - GobiUSBNetStartXmit (Public Method) - -DESCRIPTION: - Convert sk_buff to usb URB and queue for transmit - -PARAMETERS - pNet [ I ] - Pointer to net device - -RETURN VALUE: - NETDEV_TX_OK on success - NETDEV_TX_BUSY on error -===========================================================================*/ -int GobiUSBNetStartXmit( - struct sk_buff * pSKB, - struct net_device * pNet ) -{ - unsigned long URBListFlags; - struct sGobiUSBNet * pGobiDev; - sAutoPM * pAutoPM; - sURBList * pURBListEntry, ** ppURBListEnd; - void * pURBData; - struct usbnet * pDev = netdev_priv( pNet ); - - //DBG( "\n" ); - - if (pDev == NULL || pDev->net == NULL) - { - DBG( "failed to get usbnet device\n" ); - return NETDEV_TX_BUSY; - } - - pGobiDev = (sGobiUSBNet *)pDev->data[0]; - if (pGobiDev == NULL) - { - DBG( "failed to get QMIDevice\n" ); - return NETDEV_TX_BUSY; - } - pAutoPM = &pGobiDev->mAutoPM; - - if( NULL == pSKB ) - { - DBG( "Buffer is NULL \n" ); - return NETDEV_TX_BUSY; - } - - if (GobiTestDownReason( pGobiDev, DRIVER_SUSPENDED )) - { - // Should not happen - DBG( "device is suspended\n" ); - dump_stack(); - return NETDEV_TX_BUSY; - } - - if (GobiTestDownReason( pGobiDev, NO_NDIS_CONNECTION )) - { - //netif_carrier_off( pGobiDev->mpNetDev->net ); - //DBG( "device is disconnected\n" ); - //dump_stack(); - return NETDEV_TX_BUSY; - } - - // Convert the sk_buff into a URB - - // Check if buffer is full - if ( atomic_read( &pAutoPM->mURBListLen ) >= txQueueLength) - { - DBG( "not scheduling request, buffer is full\n" ); - return NETDEV_TX_BUSY; - } - - // Allocate URBListEntry - pURBListEntry = kmalloc( sizeof( sURBList ), GFP_ATOMIC ); - if (pURBListEntry == NULL) - { - DBG( "unable to allocate URBList memory\n" ); - return NETDEV_TX_BUSY; - } - pURBListEntry->mpNext = NULL; - - // Allocate URB - pURBListEntry->mpURB = usb_alloc_urb( 0, GFP_ATOMIC ); - if (pURBListEntry->mpURB == NULL) - { - DBG( "unable to allocate URB\n" ); - // release all memory allocated by now - if (pURBListEntry) - kfree( pURBListEntry ); - return NETDEV_TX_BUSY; - } - -#if 1 //def DATA_MODE_RP - GobiNetDriverTxFixup(pDev, pSKB, GFP_ATOMIC); -#endif - - // Allocate URB transfer_buffer - pURBData = kmalloc( pSKB->len, GFP_ATOMIC ); - if (pURBData == NULL) - { - DBG( "unable to allocate URB data\n" ); - // release all memory allocated by now - if (pURBListEntry) - { - usb_free_urb( pURBListEntry->mpURB ); - kfree( pURBListEntry ); - } - return NETDEV_TX_BUSY; - } - // Fill with SKB's data - memcpy( pURBData, pSKB->data, pSKB->len ); - - usb_fill_bulk_urb( pURBListEntry->mpURB, - pGobiDev->mpNetDev->udev, - pGobiDev->mpNetDev->out, - pURBData, - pSKB->len, - GobiUSBNetURBCallback, - pAutoPM ); - - /* Handle the need to send a zero length packet and release the - * transfer buffer - */ - pURBListEntry->mpURB->transfer_flags |= (URB_ZERO_PACKET | URB_FREE_BUFFER); - - // Aquire lock on URBList - spin_lock_irqsave( &pAutoPM->mURBListLock, URBListFlags ); - - // Add URB to end of list - ppURBListEnd = &pAutoPM->mpURBList; - while ((*ppURBListEnd) != NULL) - { - ppURBListEnd = &(*ppURBListEnd)->mpNext; - } - *ppURBListEnd = pURBListEntry; - atomic_inc( &pAutoPM->mURBListLen ); - - spin_unlock_irqrestore( &pAutoPM->mURBListLock, URBListFlags ); - - complete( &pAutoPM->mThreadDoWork ); - - // Start transfer timer - pNet->trans_start = jiffies; - // Free SKB - if (pSKB) - dev_kfree_skb_any( pSKB ); - - return NETDEV_TX_OK; -} -#endif -static int (*local_usbnet_start_xmit) (struct sk_buff *skb, struct net_device *net); -#endif - -static int GobiUSBNetStartXmit2( struct sk_buff *pSKB, struct net_device *pNet ){ - struct sGobiUSBNet * pGobiDev; - struct usbnet * pDev = netdev_priv( pNet ); - - //DBG( "\n" ); - - if (pDev == NULL || pDev->net == NULL) - { - DBG( "failed to get usbnet device\n" ); - return NETDEV_TX_BUSY; - } - - pGobiDev = (sGobiUSBNet *)pDev->data[0]; - if (pGobiDev == NULL) - { - DBG( "failed to get QMIDevice\n" ); - return NETDEV_TX_BUSY; - } - - if( NULL == pSKB ) - { - DBG( "Buffer is NULL \n" ); - return NETDEV_TX_BUSY; - } - - if (GobiTestDownReason( pGobiDev, DRIVER_SUSPENDED )) - { - // Should not happen - DBG( "device is suspended\n" ); - dump_stack(); - return NETDEV_TX_BUSY; - } - - if (GobiTestDownReason( pGobiDev, NO_NDIS_CONNECTION )) - { - //netif_carrier_off( pGobiDev->mpNetDev->net ); - //DBG( "device is disconnected\n" ); - //dump_stack(); - return NETDEV_TX_BUSY; - } - -#if (LINUX_VERSION_CODE < KERNEL_VERSION( 2,6,29 )) - return local_usbnet_start_xmit(pSKB, pNet); -#else - return usbnet_start_xmit(pSKB, pNet); -#endif -} - -/*=========================================================================== -METHOD: - GobiUSBNetOpen (Public Method) - -DESCRIPTION: - Wrapper to usbnet_open, correctly handling autosuspend - Start AutoPM thread (if CONFIG_PM is defined) - -PARAMETERS - pNet [ I ] - Pointer to net device - -RETURN VALUE: - int - 0 for success - Negative errno for error -===========================================================================*/ -static int GobiUSBNetOpen( struct net_device * pNet ) -{ - int status = 0; - struct sGobiUSBNet * pGobiDev; - struct usbnet * pDev = netdev_priv( pNet ); - - if (pDev == NULL) - { - DBG( "failed to get usbnet device\n" ); - return -ENXIO; - } - - pGobiDev = (sGobiUSBNet *)pDev->data[0]; - if (pGobiDev == NULL) - { - DBG( "failed to get QMIDevice\n" ); - return -ENXIO; - } - - DBG( "\n" ); - -#ifdef CONFIG_PM - #if (LINUX_VERSION_CODE < KERNEL_VERSION( 2,6,29 )) - // Start the AutoPM thread - pGobiDev->mAutoPM.mpIntf = pGobiDev->mpIntf; - pGobiDev->mAutoPM.mbExit = false; - pGobiDev->mAutoPM.mpURBList = NULL; - pGobiDev->mAutoPM.mpActiveURB = NULL; - spin_lock_init( &pGobiDev->mAutoPM.mURBListLock ); - spin_lock_init( &pGobiDev->mAutoPM.mActiveURBLock ); - atomic_set( &pGobiDev->mAutoPM.mURBListLen, 0 ); - init_completion( &pGobiDev->mAutoPM.mThreadDoWork ); - - pGobiDev->mAutoPM.mpThread = kthread_run( GobiUSBNetAutoPMThread, - &pGobiDev->mAutoPM, - "GobiUSBNetAutoPMThread" ); - if (IS_ERR( pGobiDev->mAutoPM.mpThread )) - { - DBG( "AutoPM thread creation error\n" ); - return PTR_ERR( pGobiDev->mAutoPM.mpThread ); - } - #endif -#endif /* CONFIG_PM */ - - // Allow traffic - GobiClearDownReason( pGobiDev, NET_IFACE_STOPPED ); - - // Pass to usbnet_open if defined - if (pGobiDev->mpUSBNetOpen != NULL) - { - status = pGobiDev->mpUSBNetOpen( pNet ); -#ifdef CONFIG_PM - // If usbnet_open was successful enable Auto PM - if (status == 0) - { -#if (LINUX_VERSION_CODE < KERNEL_VERSION( 2,6,33 )) - usb_autopm_enable( pGobiDev->mpIntf ); -#else - usb_autopm_put_interface( pGobiDev->mpIntf ); -#endif - } -#endif /* CONFIG_PM */ - } - else - { - DBG( "no USBNetOpen defined\n" ); - } - - return status; -} - -/*=========================================================================== -METHOD: - GobiUSBNetStop (Public Method) - -DESCRIPTION: - Wrapper to usbnet_stop, correctly handling autosuspend - Stop AutoPM thread (if CONFIG_PM is defined) - -PARAMETERS - pNet [ I ] - Pointer to net device - -RETURN VALUE: - int - 0 for success - Negative errno for error -===========================================================================*/ -static int GobiUSBNetStop( struct net_device * pNet ) -{ - struct sGobiUSBNet * pGobiDev; - struct usbnet * pDev = netdev_priv( pNet ); - - if (pDev == NULL || pDev->net == NULL) - { - DBG( "failed to get netdevice\n" ); - return -ENXIO; - } - - pGobiDev = (sGobiUSBNet *)pDev->data[0]; - if (pGobiDev == NULL) - { - DBG( "failed to get QMIDevice\n" ); - return -ENXIO; - } - - // Stop traffic - GobiSetDownReason( pGobiDev, NET_IFACE_STOPPED ); - -#ifdef CONFIG_PM - #if (LINUX_VERSION_CODE < KERNEL_VERSION( 2,6,29 )) - // Tell traffic thread to exit - pGobiDev->mAutoPM.mbExit = true; - complete( &pGobiDev->mAutoPM.mThreadDoWork ); - - // Wait for it to exit - while( pGobiDev->mAutoPM.mpThread != NULL ) - { - msleep( 100 ); - } - DBG( "thread stopped\n" ); - #endif -#endif /* CONFIG_PM */ - - // Pass to usbnet_stop, if defined - if (pGobiDev->mpUSBNetStop != NULL) - { - return pGobiDev->mpUSBNetStop( pNet ); - } - else - { - return 0; - } -} - -static int GobiNetDriver_check_connect(struct usbnet *pDev) { - int status = 0; - struct sGobiUSBNet * pGobiDev = NULL; - - while (status++ < 10) { - pGobiDev = (sGobiUSBNet *)pDev->data[0]; - if (pGobiDev && pGobiDev->mbProbeDone) - break; - msleep(1); - } - - return 0; -} - -/*=========================================================================*/ -// Struct driver_info -/*=========================================================================*/ -static struct driver_info GobiNetInfo = -{ - .description = "GobiNet Ethernet Device", -#if 1//def CONFIG_ANDROID -#if defined(QUECTEL_WWAN_QMAP) && defined(FLAG_RX_ASSEMBLE) - .flags = FLAG_RX_ASSEMBLE, //usb0 -#endif -#else -#if defined(QUECTEL_WWAN_QMAP) && defined(FLAG_RX_ASSEMBLE) - .flags = FLAG_ETHER | FLAG_RX_ASSEMBLE, -#else - .flags = FLAG_ETHER, -#endif -#endif - .bind = GobiNetDriverBind, - .unbind = GobiNetDriverUnbind, -#if 1 //def DATA_MODE_RP -#if defined(QUECTEL_WWAN_MULTI_PACKAGES) - .rx_fixup = GobiNetDriverRxPktsFixup, -#else - .rx_fixup = GobiNetDriverRxFixup, -#endif - .tx_fixup = GobiNetDriverTxFixup, -#endif - .check_connect = GobiNetDriver_check_connect, - .data = (1 << 4), -}; - -/*=========================================================================*/ -// Qualcomm Gobi 3000 VID/PIDs -/*=========================================================================*/ -#define GOBI_FIXED_INTF(vend, prod) \ - { \ - USB_DEVICE( vend, prod ), \ - .driver_info = (unsigned long)&GobiNetInfo, \ - } -static const struct usb_device_id QuecGobiVIDPIDTable [] = -{ - GOBI_FIXED_INTF( 0x05c6, 0x9003 ), // Quectel UC20 - GOBI_FIXED_INTF( 0x05c6, 0x9215 ), // Quectel EC20 (MDM9215) - GOBI_FIXED_INTF( 0x2c7c, 0x0125 ), // Quectel EC20 (MDM9X07)/EC25/EG25 - GOBI_FIXED_INTF( 0x2c7c, 0x0121 ), // Quectel EC21 - GOBI_FIXED_INTF( 0x2c7c, 0x0306 ), // Quectel EP06 - GOBI_FIXED_INTF( 0x2c7c, 0x030B ), // Quectel EG065K,SDX12 - GOBI_FIXED_INTF( 0x2c7c, 0x0435 ), // Quectel AG35 - GOBI_FIXED_INTF( 0x2c7c, 0x0296 ), // Quectel BG96 - GOBI_FIXED_INTF( 0x2c7c, 0x0191 ), // Quectel EG91 - GOBI_FIXED_INTF( 0x2c7c, 0x0195 ), // Quectel EG95 - GOBI_FIXED_INTF( 0x2c7c, 0x0512 ), // Quectel EG12/EP12/EM12/EG16/EG18,SDx20 - GOBI_FIXED_INTF( 0x2c7c, 0x0620 ), // Quectel EG20,SDx24 - GOBI_FIXED_INTF( 0x2c7c, 0x0800 ), // Quectel RG500Q,RM500Q,RM510Q,SDX55 - GOBI_FIXED_INTF( 0x2c7c, 0x0801 ), // Quectel RG520Q,RM520Q,SG520Q,SDX6X - //Terminating entry - { } -}; - -MODULE_DEVICE_TABLE( usb, QuecGobiVIDPIDTable ); - -/*=========================================================================== -METHOD: - GobiUSBNetProbe (Public Method) - -DESCRIPTION: - Run usbnet_probe - Setup QMI device - -PARAMETERS - pIntf [ I ] - Pointer to interface - pVIDPIDs [ I ] - Pointer to VID/PID table - -RETURN VALUE: - int - 0 for success - Negative errno for error -===========================================================================*/ -static int GobiUSBNetProbe( - struct usb_interface * pIntf, - const struct usb_device_id * pVIDPIDs ) -{ - int status; - struct usbnet * pDev; - sGobiUSBNet * pGobiDev; -#if (LINUX_VERSION_CODE >= KERNEL_VERSION( 2,6,29 )) - struct net_device_ops * pNetDevOps; -#endif - - status = usbnet_probe( pIntf, pVIDPIDs ); - if (status < 0) - { - DBG( "usbnet_probe failed %d\n", status ); - return status; - } - -#if (LINUX_VERSION_CODE >= KERNEL_VERSION( 2,6,19 )) - pIntf->needs_remote_wakeup = 1; -#endif - -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 2,6,23 )) - pDev = usb_get_intfdata( pIntf ); -#else - pDev = (struct usbnet *)pIntf->dev.platform_data; -#endif - - if (pDev == NULL || pDev->net == NULL) - { - DBG( "failed to get netdevice\n" ); - usbnet_disconnect( pIntf ); - return -ENXIO; - } - - pGobiDev = kzalloc( sizeof( sGobiUSBNet ), GFP_KERNEL ); - if (pGobiDev == NULL) - { - DBG( "fail to allocate device buffers" ); - usbnet_disconnect( pIntf ); - return -ENOMEM; - } - - atomic_set(&pGobiDev->refcount, 1); - - pDev->data[0] = (unsigned long)pGobiDev; - - pGobiDev->mpNetDev = pDev; - - // Clearing endpoint halt is a magic handshake that brings - // the device out of low power (airplane) mode - usb_clear_halt( pGobiDev->mpNetDev->udev, pDev->out ); - - // Overload PM related network functions -#if (LINUX_VERSION_CODE < KERNEL_VERSION( 2,6,29 )) - pGobiDev->mpUSBNetOpen = pDev->net->open; - pDev->net->open = GobiUSBNetOpen; - pGobiDev->mpUSBNetStop = pDev->net->stop; - pDev->net->stop = GobiUSBNetStop; -#if defined(CONFIG_PM) && (LINUX_VERSION_CODE > KERNEL_VERSION( 2,6,14 )) - pDev->net->hard_start_xmit = GobiUSBNetStartXmit; - pDev->net->tx_timeout = GobiUSBNetTXTimeout; -#else //quectel donot send dhcp request before ndis connect for uc20 - local_usbnet_start_xmit = pDev->net->hard_start_xmit; - pDev->net->hard_start_xmit = GobiUSBNetStartXmit2; -#endif -#else - pNetDevOps = kmalloc( sizeof( struct net_device_ops ), GFP_KERNEL ); - if (pNetDevOps == NULL) - { - DBG( "falied to allocate net device ops" ); - usbnet_disconnect( pIntf ); - return -ENOMEM; - } - memcpy( pNetDevOps, pDev->net->netdev_ops, sizeof( struct net_device_ops ) ); - - pGobiDev->mpUSBNetOpen = pNetDevOps->ndo_open; - pNetDevOps->ndo_open = GobiUSBNetOpen; - pGobiDev->mpUSBNetStop = pNetDevOps->ndo_stop; - pNetDevOps->ndo_stop = GobiUSBNetStop; -#if 1 //quectel donot send dhcp request before ndis connect for uc20 - pNetDevOps->ndo_start_xmit = GobiUSBNetStartXmit2; -#else - pNetDevOps->ndo_start_xmit = usbnet_start_xmit; -#endif - pNetDevOps->ndo_tx_timeout = usbnet_tx_timeout; - -#if defined(QUECTEL_WWAN_QMAP) - pNetDevOps->ndo_do_ioctl = qmap_ndo_do_ioctl; -#endif - - pDev->net->netdev_ops = pNetDevOps; -#endif - -#if (LINUX_VERSION_CODE < KERNEL_VERSION( 2,6,31 )) - memset( &(pGobiDev->mpNetDev->stats), 0, sizeof( struct net_device_stats ) ); -#else - memset( &(pGobiDev->mpNetDev->net->stats), 0, sizeof( struct net_device_stats ) ); -#endif - - pGobiDev->mpIntf = pIntf; - memset( &(pGobiDev->mMEID), '0', 14 ); - - DBG( "Mac Address:\n" ); - PrintHex( &pGobiDev->mpNetDev->net->dev_addr[0], 6 ); - - pGobiDev->mbQMIValid = false; - memset( &pGobiDev->mQMIDev, 0, sizeof( sQMIDev ) ); - pGobiDev->mQMIDev.mbCdevIsInitialized = false; - - pGobiDev->mQMIDev.mpDevClass = gpClass; - -#ifdef CONFIG_PM - #if (LINUX_VERSION_CODE < KERNEL_VERSION( 2,6,29 )) - init_completion( &pGobiDev->mAutoPM.mThreadDoWork ); - #endif -#endif /* CONFIG_PM */ - spin_lock_init( &pGobiDev->mQMIDev.mClientMemLock ); - - // Default to device down - pGobiDev->mDownReason = 0; - -//#if (LINUX_VERSION_CODE < KERNEL_VERSION( 3,11,0 )) - GobiSetDownReason( pGobiDev, NO_NDIS_CONNECTION ); - GobiSetDownReason( pGobiDev, NET_IFACE_STOPPED ); -//#endif - - // Register QMI - pGobiDev->mbMdm9x07 |= (pDev->udev->descriptor.idVendor == cpu_to_le16(0x2c7c)); - pGobiDev->mbMdm9x06 |= (pDev->udev->descriptor.idVendor == cpu_to_le16(0x2c7c) && pDev->udev->descriptor.idProduct == cpu_to_le16(0x0296)); - pGobiDev->mbRawIPMode = pGobiDev->mbMdm9x07; - if ( pGobiDev->mbRawIPMode) - pGobiDev->mpNetDev->net->flags |= IFF_NOARP; -#ifdef QUECTEL_BRIDGE_MODE - memcpy(pGobiDev->mHostMAC, pDev->net->dev_addr, 6); - pGobiDev->m_bridge_mode = bridge_mode; -#endif - -#ifdef QUECTEL_REMOVE_TX_ZLP - { - struct remove_tx_zlp_config { - __le32 enable; - } __packed; - - struct remove_tx_zlp_config cfg; - cfg.enable = cpu_to_le32(1); //1-enable 0-disable - - usb_control_msg( - interface_to_usbdev(pIntf), - usb_sndctrlpipe(interface_to_usbdev(pIntf), 0), - USB_CDC_SET_REMOVE_TX_ZLP_COMMAND, - 0x21, //USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE - 0, - pIntf->cur_altsetting->desc.bInterfaceNumber, - &cfg, sizeof(cfg), 100); - } -#endif - - pGobiDev->m_qcrmcall_mode = qcrmcall_mode; - - if (pGobiDev->m_qcrmcall_mode) { - INFO("AT$QCRMCALL MODE!"); - - GobiClearDownReason( pGobiDev, NO_NDIS_CONNECTION ); - usb_control_msg( - interface_to_usbdev(pIntf), - usb_sndctrlpipe(interface_to_usbdev(pIntf), 0), - 0x22, //USB_CDC_REQ_SET_CONTROL_LINE_STATE - 0x21, //USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE - 1, //active CDC DTR - pIntf->cur_altsetting->desc.bInterfaceNumber, - NULL, 0, 100); - status = 0; - } - else { -#if defined(QUECTEL_WWAN_QMAP) - if (pGobiDev->mbRawIPMode) { - unsigned idProduct = le16_to_cpu(pDev->udev->descriptor.idProduct); - - pGobiDev->qmap_mode = qmap_mode; - if (pGobiDev->qmap_mode == 0) { - if (idProduct == 0x0800 || idProduct == 0x0801) { - pGobiDev->qmap_mode = 1; - } - } - - pGobiDev->qmap_version = 5; - if (idProduct == 0x0800 || idProduct == 0x0801) { - pGobiDev->qmap_version = 9; - } - } - - if (pGobiDev->qmap_mode) { - netif_carrier_off(pDev->net); - } - - if (pGobiDev->qmap_mode > 1) { -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 2,6,35 )) //ab95bfe01f9872459c8678572ccadbf646badad0 - rtnl_lock(); - netdev_rx_handler_register(pDev->net, rmnet_usb_rx_handler, NULL); - rtnl_unlock(); -#endif - } - -#if defined(QUECTEL_UL_DATA_AGG) - if (pGobiDev->qmap_mode) { - struct ul_agg_ctx *agg_ctx = &pGobiDev->agg_ctx; - - agg_ctx->ul_data_aggregation_max_datagrams = 1; - agg_ctx->ul_data_aggregation_max_size = 2048; - agg_ctx->dl_minimum_padding = 0; - } -#endif -#endif - status = RegisterQMIDevice( pGobiDev ); - } - - if (status != 0) - { - // usbnet_disconnect() will call GobiNetDriverUnbind() which will call - // DeregisterQMIDevice() to clean up any partially created QMI device - usbnet_disconnect( pIntf ); - return status; - } - -#if defined(QUECTEL_WWAN_QMAP) - tasklet_init(&pGobiDev->txq, rmnet_usb_tx_wake_queue, (unsigned long)pGobiDev); - - if (pGobiDev->qmap_mode > 1) { - unsigned i; - - for (i = 0; i < pGobiDev->qmap_mode; i++) { - qmap_register_device(pGobiDev, i); - } - } else { - pGobiDev->mpQmapNetDev[0] = pDev->net; - } -#endif - - pGobiDev->mbProbeDone = 1; - // Success - return 0; -} - -static void GobiUSBNetDisconnect (struct usb_interface *intf) { -#if defined(QUECTEL_WWAN_QMAP) - struct usbnet *pDev = usb_get_intfdata(intf); - sGobiUSBNet * pGobiDev = (sGobiUSBNet *)pDev->data[0]; - unsigned i; - - if (pGobiDev->qmap_mode > 1) { - for (i = 0; i < pGobiDev->qmap_mode; i++) { - qmap_unregister_device(pGobiDev, i); - } - - } - - tasklet_kill(&pGobiDev->txq); -#endif - - usbnet_disconnect(intf); -} - -static struct usb_driver GobiNet = -{ - .name = "GobiNet", - .id_table = QuecGobiVIDPIDTable, - .probe = GobiUSBNetProbe, - .disconnect = GobiUSBNetDisconnect, -#ifdef CONFIG_PM - .suspend = GobiNetSuspend, - .resume = GobiNetResume, -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 2,6,27 )) - .reset_resume = GobiNetResetResume, -#endif -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 2,6,18 )) - .supports_autosuspend = true, -#endif -#endif /* CONFIG_PM */ -}; - -/*=========================================================================== -METHOD: - GobiUSBNetModInit (Public Method) - -DESCRIPTION: - Initialize module - Create device class - Register out usb_driver struct - -RETURN VALUE: - int - 0 for success - Negative errno for error -===========================================================================*/ -static int __init GobiUSBNetModInit( void ) -{ - gpClass = class_create( THIS_MODULE, "GobiQMI" ); - if (IS_ERR( gpClass ) == true) - { - DBG( "error at class_create %ld\n", PTR_ERR( gpClass ) ); - return -ENOMEM; - } - - // This will be shown whenever driver is loaded - printk( KERN_INFO "%s: %s\n", DRIVER_DESC, DRIVER_VERSION ); - - return usb_register( &GobiNet ); -} -module_init( GobiUSBNetModInit ); - -/*=========================================================================== -METHOD: - GobiUSBNetModExit (Public Method) - -DESCRIPTION: - Deregister module - Destroy device class - -RETURN VALUE: - void -===========================================================================*/ -static void __exit GobiUSBNetModExit( void ) -{ - usb_deregister( &GobiNet ); - - class_destroy( gpClass ); -} -module_exit( GobiUSBNetModExit ); - -MODULE_VERSION( DRIVER_VERSION ); -MODULE_AUTHOR( DRIVER_AUTHOR ); -MODULE_DESCRIPTION( DRIVER_DESC ); -MODULE_LICENSE("Dual BSD/GPL"); - -#ifdef bool -#undef bool -#endif - -module_param_named( debug, quec_debug, int, S_IRUGO | S_IWUSR ); -MODULE_PARM_DESC( debug, "Debuging enabled or not" ); - -//module_param_named( interruptible, Quecinterruptible, int, S_IRUGO | S_IWUSR ); -//MODULE_PARM_DESC( interruptible, "Listen for and return on user interrupt" ); -module_param( txQueueLength, int, S_IRUGO | S_IWUSR ); -MODULE_PARM_DESC( txQueueLength, - "Number of IP packets which may be queued up for transmit" ); - diff --git a/quectel_Gobinet/src/Makefile b/quectel_Gobinet/src/Makefile deleted file mode 100644 index fe4ccf1..0000000 --- a/quectel_Gobinet/src/Makefile +++ /dev/null @@ -1,43 +0,0 @@ -obj-m := GobiNet.o -GobiNet-objs := GobiUSBNet.o QMIDevice.o QMI.o - -PWD := $(shell pwd) -OUTPUTDIR=/lib/modules/`uname -r`/kernel/drivers/net/usb/ - -ifeq ($(ARCH),) -ARCH := $(shell uname -m) -endif -ifeq ($(CROSS_COMPILE),) -CROSS_COMPILE := -endif -ifeq ($(KDIR),) -KDIR := /lib/modules/$(shell uname -r)/build -ifeq ($(ARCH),i686) -ifeq ($(wildcard $KDIR/arch/$ARCH),) -ARCH=i386 -endif -endif -endif - -$(shell rm -rf usbnet.h) -ifneq ($(wildcard $(KDIR)/drivers/usb/net/usbnet.h),) -$(shell ln -s $(KDIR)/drivers/usb/net/usbnet.h usbnet.h) -endif -ifneq ($(wildcard $(KDIR)/drivers/net/usb/usbnet.h),) -$(shell ln -s $(KDIR)/drivers/net/usb/usbnet.h usbnet.h) -endif - -default: - ln -sf makefile Makefile - $(MAKE) ARCH=${ARCH} CROSS_COMPILE=${CROSS_COMPILE} -C $(KDIR) M=$(PWD) modules - -install: default - mkdir -p $(OUTPUTDIR) - cp -f GobiNet.ko $(OUTPUTDIR) - depmod - modprobe -r GobiNet - modprobe GobiNet - -clean: - rm -rf Makefile usbnet.h - rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions Module.* modules.order diff --git a/quectel_Gobinet/src/QMI.c b/quectel_Gobinet/src/QMI.c deleted file mode 100644 index eaf1cac..0000000 --- a/quectel_Gobinet/src/QMI.c +++ /dev/null @@ -1,1521 +0,0 @@ -#ifdef __QUEC_INCLUDE_QMI_C__ -/*=========================================================================== -FILE: - QMI.c - -DESCRIPTION: - Qualcomm QMI driver code - -FUNCTIONS: - Generic QMUX functions - ParseQMUX - FillQMUX - - Generic QMI functions - GetTLV - ValidQMIMessage - GetQMIMessageID - - Fill Buffers with QMI requests - QMICTLGetClientIDReq - QMICTLReleaseClientIDReq - QMICTLReadyReq - QMIWDSSetEventReportReq - QMIWDSGetPKGSRVCStatusReq - QMIDMSGetMEIDReq - QMIWDASetDataFormatReq - QMICTLSetDataFormatReq - QMICTLSyncReq - - Parse data from QMI responses - QMICTLGetClientIDResp - QMICTLReleaseClientIDResp - QMIWDSEventResp - QMIDMSGetMEIDResp - QMIWDASetDataFormatResp - QMICTLSyncResp - -Copyright (c) 2011, Code Aurora Forum. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of Code Aurora Forum nor - the names of its contributors may be used to endorse or promote - products derived from this software without specific prior written - permission. - - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. -===========================================================================*/ - -//--------------------------------------------------------------------------- -// Include Files -//--------------------------------------------------------------------------- -#include -#include -#include "Structs.h" -#include "QMI.h" - -/*=========================================================================*/ -// Get sizes of buffers needed by QMI requests -/*=========================================================================*/ - -/*=========================================================================== -METHOD: - QMUXHeaderSize (Public Method) - -DESCRIPTION: - Get size of buffer needed for QMUX - -RETURN VALUE: - u16 - size of buffer -===========================================================================*/ -static u16 QMUXHeaderSize( void ) -{ - return sizeof( sQMUX ); -} - -/*=========================================================================== -METHOD: - QMICTLGetClientIDReqSize (Public Method) - -DESCRIPTION: - Get size of buffer needed for QMUX + QMICTLGetClientIDReq - -RETURN VALUE: - u16 - size of buffer -===========================================================================*/ -static u16 QMICTLGetClientIDReqSize( void ) -{ - return sizeof( sQMUX ) + 10; -} - -/*=========================================================================== -METHOD: - QMICTLReleaseClientIDReqSize (Public Method) - -DESCRIPTION: - Get size of buffer needed for QMUX + QMICTLReleaseClientIDReq - -RETURN VALUE: - u16 - size of header -===========================================================================*/ -static u16 QMICTLReleaseClientIDReqSize( void ) -{ - return sizeof( sQMUX ) + 11; -} - -/*=========================================================================== -METHOD: - QMICTLReadyReqSize (Public Method) - -DESCRIPTION: - Get size of buffer needed for QMUX + QMICTLReadyReq - -RETURN VALUE: - u16 - size of buffer -===========================================================================*/ -static u16 QMICTLReadyReqSize( void ) -{ - return sizeof( sQMUX ) + 6; -} - -/*=========================================================================== -METHOD: - QMIWDSSetEventReportReqSize (Public Method) - -DESCRIPTION: - Get size of buffer needed for QMUX + QMIWDSSetEventReportReq - -RETURN VALUE: - u16 - size of buffer -===========================================================================*/ -static u16 QMIWDSSetEventReportReqSize( void ) -{ - return sizeof( sQMUX ) + 15; -} - -/*=========================================================================== -METHOD: - QMIWDSGetPKGSRVCStatusReqSize (Public Method) - -DESCRIPTION: - Get size of buffer needed for QMUX + QMIWDSGetPKGSRVCStatusReq - -RETURN VALUE: - u16 - size of buffer -===========================================================================*/ -static u16 QMIWDSGetPKGSRVCStatusReqSize( void ) -{ - return sizeof( sQMUX ) + 7; -} - -/*=========================================================================== -METHOD: - QMIDMSGetMEIDReqSize (Public Method) - -DESCRIPTION: - Get size of buffer needed for QMUX + QMIDMSGetMEIDReq - -RETURN VALUE: - u16 - size of buffer -===========================================================================*/ -static u16 QMIDMSGetMEIDReqSize( void ) -{ - return sizeof( sQMUX ) + 7; -} - -struct QMIWDS_ADMIN_SET_DATA_FORMAT_TLV_QOS -{ - u8 TLVType; - u16 TLVLength; - u8 QOSSetting; -} __packed; - -struct QMIWDS_ADMIN_SET_DATA_FORMAT_TLV -{ - u8 TLVType; - u16 TLVLength; - u32 Value; -} __packed; - -struct QMIWDS_ENDPOINT_TLV -{ - u8 TLVType; - u16 TLVLength; - u32 ep_type; - u32 iface_id; -} __packed; - -struct QMIWDS_ADMIN_SET_DATA_FORMAT_REQ_MSG -{ - u8 CtlFlags; // 0: single QMUX Msg; 1: - u16 TransactionId; - u16 Type; - u16 Length; - struct QMIWDS_ADMIN_SET_DATA_FORMAT_TLV_QOS QosDataFormatTlv; - struct QMIWDS_ADMIN_SET_DATA_FORMAT_TLV UnderlyingLinkLayerProtocolTlv; - struct QMIWDS_ADMIN_SET_DATA_FORMAT_TLV UplinkDataAggregationProtocolTlv; - struct QMIWDS_ADMIN_SET_DATA_FORMAT_TLV DownlinkDataAggregationProtocolTlv; - struct QMIWDS_ADMIN_SET_DATA_FORMAT_TLV DownlinkDataAggregationMaxDatagramsTlv; - struct QMIWDS_ADMIN_SET_DATA_FORMAT_TLV DownlinkDataAggregationMaxSizeTlv; - struct QMIWDS_ENDPOINT_TLV epTlv; - struct QMIWDS_ADMIN_SET_DATA_FORMAT_TLV dl_minimum_padding; - struct QMIWDS_ADMIN_SET_DATA_FORMAT_TLV UplinkDataAggregationMaxDatagramsTlv; - struct QMIWDS_ADMIN_SET_DATA_FORMAT_TLV UplinkDataAggregationMaxSizeTlv; -} __packed; - -/*=========================================================================== -METHOD: - QMIWDASetDataFormatReqSize (Public Method) - -DESCRIPTION: - Get size of buffer needed for QMUX + QMIWDASetDataFormatReq - -RETURN VALUE: - u16 - size of buffer -===========================================================================*/ -static u16 QMIWDASetDataFormatReqSize( int qmap_version ) -{ -if (qmap_version) - return sizeof( sQMUX ) + sizeof(struct QMIWDS_ADMIN_SET_DATA_FORMAT_REQ_MSG); -else - return sizeof( sQMUX ) + 18; -} - -/*=========================================================================== -METHOD: - QMICTLSyncReqSize (Public Method) - -DESCRIPTION: - Get size of buffer needed for QMUX + QMICTLSyncReq - -RETURN VALUE: - u16 - size of buffer -===========================================================================*/ -static u16 QMICTLSyncReqSize( void ) -{ - return sizeof( sQMUX ) + 6; -} - -/*=========================================================================*/ -// Generic QMUX functions -/*=========================================================================*/ - -/*=========================================================================== -METHOD: - ParseQMUX (Public Method) - -DESCRIPTION: - Remove QMUX headers from a buffer - -PARAMETERS - pClientID [ O ] - On success, will point to Client ID - pBuffer [ I ] - Full Message passed in - buffSize [ I ] - Size of pBuffer - -RETURN VALUE: - int - Positive for size of QMUX header - Negative errno for error -===========================================================================*/ -static int ParseQMUX( - u16 * pClientID, - void * pBuffer, - u16 buffSize ) -{ - sQMUX * pQMUXHeader; - - if (pBuffer == 0 || buffSize < 12) - { - return -ENOMEM; - } - - // QMUX Header - pQMUXHeader = (sQMUX *)pBuffer; - - if (pQMUXHeader->mTF != 1 - || le16_to_cpu(get_unaligned(&pQMUXHeader->mLength)) != buffSize - 1 - || pQMUXHeader->mCtrlFlag != 0x80 ) - { - return -EINVAL; - } - - // Client ID - *pClientID = (pQMUXHeader->mQMIClientID << 8) + pQMUXHeader->mQMIService; - - return sizeof( sQMUX ); -} - -/*=========================================================================== -METHOD: - FillQMUX (Public Method) - -DESCRIPTION: - Fill buffer with QMUX headers - -PARAMETERS - clientID [ I ] - Client ID - pBuffer [ O ] - Buffer to be filled - buffSize [ I ] - Size of pBuffer (must be at least 6) - -RETURN VALUE: - int - 0 for success - Negative errno for error -===========================================================================*/ -static int FillQMUX( - u16 clientID, - void * pBuffer, - u16 buffSize ) -{ - sQMUX * pQMUXHeader; - - if (pBuffer == 0 || buffSize < sizeof( sQMUX )) - { - return -ENOMEM; - } - - // QMUX Header - pQMUXHeader = (sQMUX *)pBuffer; - - pQMUXHeader->mTF = 1; - put_unaligned(cpu_to_le16(buffSize - 1), &pQMUXHeader->mLength); - //DBG("pQMUXHeader->mLength = 0x%x, buffSize - 1 = 0x%x\n",pQMUXHeader->mLength, buffSize - 1); - pQMUXHeader->mCtrlFlag = 0; - - // Service and Client ID - pQMUXHeader->mQMIService = clientID & 0xff; - pQMUXHeader->mQMIClientID = clientID >> 8; - - return 0; -} - -/*=========================================================================*/ -// Generic QMI functions -/*=========================================================================*/ - -/*=========================================================================== -METHOD: - GetTLV (Public Method) - -DESCRIPTION: - Get data buffer of a specified TLV from a QMI message - - QMI Message shall NOT include SDU - -PARAMETERS - pQMIMessage [ I ] - QMI Message buffer - messageLen [ I ] - Size of QMI Message buffer - type [ I ] - Desired Type - pOutDataBuf [ O ] - Buffer to be filled with TLV - messageLen [ I ] - Size of QMI Message buffer - -RETURN VALUE: - u16 - Size of TLV for success - Negative errno for error -===========================================================================*/ -static int GetTLV( - void * pQMIMessage, - u16 messageLen, - u8 type, - void * pOutDataBuf, - u16 bufferLen ) -{ - u16 pos; - u16 tlvSize = 0; - u16 cpyCount; - - if (pQMIMessage == 0 || pOutDataBuf == 0) - { - return -ENOMEM; - } - - for (pos = 4; - pos + 3 < messageLen; - pos += tlvSize + 3) - { - tlvSize = le16_to_cpu( get_unaligned(((u16 *)(pQMIMessage + pos + 1) )) ); - if (*(u8 *)(pQMIMessage + pos) == type) - { - if (bufferLen < tlvSize) - { - return -ENOMEM; - } - - for (cpyCount = 0; cpyCount < tlvSize; cpyCount++) - { - *((char*)(pOutDataBuf + cpyCount)) = *((char*)(pQMIMessage + pos + 3 + cpyCount)); - } - - return tlvSize; - } - } - - return -ENOMSG; -} - -/*=========================================================================== -METHOD: - ValidQMIMessage (Public Method) - -DESCRIPTION: - Check mandatory TLV in a QMI message - - QMI Message shall NOT include SDU - -PARAMETERS - pQMIMessage [ I ] - QMI Message buffer - messageLen [ I ] - Size of QMI Message buffer - -RETURN VALUE: - int - 0 for success (no error) - Negative errno for error - Positive for QMI error code -===========================================================================*/ -static int ValidQMIMessage( - void * pQMIMessage, - u16 messageLen ) -{ - char mandTLV[4]; - - if (GetTLV( pQMIMessage, messageLen, 2, &mandTLV[0], 4 ) == 4) - { - // Found TLV - if (*(u16 *)&mandTLV[0] != 0) - { - return le16_to_cpu( get_unaligned(&mandTLV[2]) ); - } - else - { - return 0; - } - } - else - { - return -ENOMSG; - } -} - -/*=========================================================================== -METHOD: - GetQMIMessageID (Public Method) - -DESCRIPTION: - Get the message ID of a QMI message - - QMI Message shall NOT include SDU - -PARAMETERS - pQMIMessage [ I ] - QMI Message buffer - messageLen [ I ] - Size of QMI Message buffer - -RETURN VALUE: - int - Positive for message ID - Negative errno for error -===========================================================================*/ -static int GetQMIMessageID( - void * pQMIMessage, - u16 messageLen ) -{ - if (messageLen < 2) - { - return -ENODATA; - } - else - { - return le16_to_cpu( get_unaligned((u16 *)pQMIMessage) ); - } -} - -/*=========================================================================*/ -// Fill Buffers with QMI requests -/*=========================================================================*/ - -/*=========================================================================== -METHOD: - QMICTLGetClientIDReq (Public Method) - -DESCRIPTION: - Fill buffer with QMI CTL Get Client ID Request - -PARAMETERS - pBuffer [ 0 ] - Buffer to be filled - buffSize [ I ] - Size of pBuffer - transactionID [ I ] - Transaction ID - serviceType [ I ] - Service type requested - -RETURN VALUE: - int - Positive for resulting size of pBuffer - Negative errno for error -===========================================================================*/ -static int QMICTLGetClientIDReq( - void * pBuffer, - u16 buffSize, - u8 transactionID, - u8 serviceType ) -{ - if (pBuffer == 0 || buffSize < QMICTLGetClientIDReqSize() ) - { - return -ENOMEM; - } - - // QMI CTL GET CLIENT ID - // Request - *(u8 *)(pBuffer + sizeof( sQMUX ))= 0x00; - // Transaction ID - *(u8 *)(pBuffer + sizeof( sQMUX ) + 1) = transactionID; - // Message ID - put_unaligned(cpu_to_le16(0x0022), (u16 *)(pBuffer + sizeof( sQMUX ) + 2)); - // Size of TLV's - put_unaligned(cpu_to_le16(0x0004), (u16 *)(pBuffer + sizeof( sQMUX ) + 4)); - // QMI Service Type - *(u8 *)(pBuffer + sizeof( sQMUX ) + 6) = 0x01; - // Size - put_unaligned(cpu_to_le16(0x0001), (u16 *)(pBuffer + sizeof( sQMUX ) + 7)); - // QMI svc type - *(u8 *)(pBuffer + sizeof( sQMUX ) + 9) = serviceType; - - // success - return sizeof( sQMUX ) + 10; -} - -/*=========================================================================== -METHOD: - QMICTLReleaseClientIDReq (Public Method) - -DESCRIPTION: - Fill buffer with QMI CTL Release Client ID Request - -PARAMETERS - pBuffer [ 0 ] - Buffer to be filled - buffSize [ I ] - Size of pBuffer - transactionID [ I ] - Transaction ID - clientID [ I ] - Service type requested - -RETURN VALUE: - int - Positive for resulting size of pBuffer - Negative errno for error -===========================================================================*/ -static int QMICTLReleaseClientIDReq( - void * pBuffer, - u16 buffSize, - u8 transactionID, - u16 clientID ) -{ - if (pBuffer == 0 || buffSize < QMICTLReleaseClientIDReqSize() ) - { - return -ENOMEM; - } - - DBG( "buffSize: 0x%x, transactionID: 0x%x, clientID: 0x%x,\n", - buffSize, transactionID, clientID ); - - // QMI CTL RELEASE CLIENT ID REQ - // Request - *(u8 *)(pBuffer + sizeof( sQMUX )) = 0x00; - // Transaction ID - *(u8 *)(pBuffer + sizeof( sQMUX ) + 1 ) = transactionID; - // Message ID - put_unaligned( cpu_to_le16(0x0023), (u16 *)(pBuffer + sizeof( sQMUX ) + 2) ); - // Size of TLV's - put_unaligned( cpu_to_le16(0x0005), (u16 *)(pBuffer + sizeof( sQMUX ) + 4) ); - // Release client ID - *(u8 *)(pBuffer + sizeof( sQMUX ) + 6) = 0x01; - // Size - put_unaligned( cpu_to_le16(0x0002), (u16 *)(pBuffer + sizeof( sQMUX ) + 7)); - // QMI svs type / Client ID - put_unaligned(cpu_to_le16(clientID), (u16 *)(pBuffer + sizeof( sQMUX ) + 9)); - - // success - return sizeof( sQMUX ) + 11; -} - -/*=========================================================================== -METHOD: - QMICTLReadyReq (Public Method) - -DESCRIPTION: - Fill buffer with QMI CTL Get Version Info Request - -PARAMETERS - pBuffer [ 0 ] - Buffer to be filled - buffSize [ I ] - Size of pBuffer - transactionID [ I ] - Transaction ID - -RETURN VALUE: - int - Positive for resulting size of pBuffer - Negative errno for error -===========================================================================*/ -static int QMICTLReadyReq( - void * pBuffer, - u16 buffSize, - u8 transactionID ) -{ - if (pBuffer == 0 || buffSize < QMICTLReadyReqSize() ) - { - return -ENOMEM; - } - - DBG("buffSize: 0x%x, transactionID: 0x%x\n", buffSize, transactionID); - - // QMI CTL GET VERSION INFO REQ - // Request - *(u8 *)(pBuffer + sizeof( sQMUX )) = 0x00; - // Transaction ID - *(u8 *)(pBuffer + sizeof( sQMUX ) + 1) = transactionID; - // Message ID - put_unaligned( cpu_to_le16(0x0021), (u16 *)(pBuffer + sizeof( sQMUX ) + 2) ); - // Size of TLV's - put_unaligned( cpu_to_le16(0x0000), (u16 *)(pBuffer + sizeof( sQMUX ) + 4) ); - - // success - return sizeof( sQMUX ) + 6; -} - -/*=========================================================================== -METHOD: - QMIWDSSetEventReportReq (Public Method) - -DESCRIPTION: - Fill buffer with QMI WDS Set Event Report Request - -PARAMETERS - pBuffer [ 0 ] - Buffer to be filled - buffSize [ I ] - Size of pBuffer - transactionID [ I ] - Transaction ID - -RETURN VALUE: - int - Positive for resulting size of pBuffer - Negative errno for error -===========================================================================*/ -static int QMIWDSSetEventReportReq( - void * pBuffer, - u16 buffSize, - u16 transactionID ) -{ - if (pBuffer == 0 || buffSize < QMIWDSSetEventReportReqSize() ) - { - return -ENOMEM; - } - - // QMI WDS SET EVENT REPORT REQ - // Request - *(u8 *)(pBuffer + sizeof( sQMUX )) = 0x00; - // Transaction ID - put_unaligned( cpu_to_le16(transactionID), (u16 *)(pBuffer + sizeof( sQMUX ) + 1)); - // Message ID - put_unaligned( cpu_to_le16(0x0001), (u16 *)(pBuffer + sizeof( sQMUX ) + 3)); - // Size of TLV's - put_unaligned(cpu_to_le16(0x0008), (u16 *)(pBuffer + sizeof( sQMUX ) + 5)); - // Report channel rate TLV - *(u8 *)(pBuffer + sizeof( sQMUX ) + 7) = 0x11; - // Size - put_unaligned( cpu_to_le16(0x0005), (u16 *)(pBuffer + sizeof( sQMUX ) + 8)); - // Stats period - *(u8 *)(pBuffer + sizeof( sQMUX ) + 10) = 0x01; - // Stats mask - put_unaligned( cpu_to_le32(0x000000ff), (u32 *)(pBuffer + sizeof( sQMUX ) + 11) ); - - // success - return sizeof( sQMUX ) + 15; -} - -/*=========================================================================== -METHOD: - QMIWDSGetPKGSRVCStatusReq (Public Method) - -DESCRIPTION: - Fill buffer with QMI WDS Get PKG SRVC Status Request - -PARAMETERS - pBuffer [ 0 ] - Buffer to be filled - buffSize [ I ] - Size of pBuffer - transactionID [ I ] - Transaction ID - -RETURN VALUE: - int - Positive for resulting size of pBuffer - Negative errno for error -===========================================================================*/ -static int QMIWDSGetPKGSRVCStatusReq( - void * pBuffer, - u16 buffSize, - u16 transactionID ) -{ - if (pBuffer == 0 || buffSize < QMIWDSGetPKGSRVCStatusReqSize() ) - { - return -ENOMEM; - } - - // QMI WDS Get PKG SRVC Status REQ - // Request - *(u8 *)(pBuffer + sizeof( sQMUX )) = 0x00; - // Transaction ID - put_unaligned(cpu_to_le16(transactionID), (u16 *)(pBuffer + sizeof( sQMUX ) + 1)); - // Message ID - put_unaligned(cpu_to_le16(0x0022), (u16 *)(pBuffer + sizeof( sQMUX ) + 3)); - // Size of TLV's - put_unaligned(cpu_to_le16(0x0000), (u16 *)(pBuffer + sizeof( sQMUX ) + 5)); - - // success - return sizeof( sQMUX ) + 7; -} - -#if 0 -static u16 QMIWDSSetQMUXBindMuxDataPortSize( void ) -{ - return sizeof( sQMUX ) + 29; -} - -static u16 QMIWDSSetQMUXBindMuxDataPortReq( - void * pBuffer, - u16 buffSize, - u8 MuxId, - u16 transactionID ) -{ - if (pBuffer == 0 || buffSize < QMIWDSSetQMUXBindMuxDataPortSize() ) - { - return -ENOMEM; - } - - // QMI WDS Set QMUX Bind Mux Data Port REQ - // Request - *(u8 *)(pBuffer + sizeof( sQMUX )) = 0x00; - // Transaction ID - put_unaligned(cpu_to_le16(transactionID), (u16 *)(pBuffer + sizeof( sQMUX ) + 1)); - // Message ID - put_unaligned(cpu_to_le16(0x00a2), (u16 *)(pBuffer + sizeof( sQMUX ) + 3)); - // Size of TLV's - put_unaligned(cpu_to_le16(0x0016), (u16 *)(pBuffer + sizeof( sQMUX ) + 5)); - - *(u8 *)(pBuffer + sizeof( sQMUX ) + 7) = 0x10; - put_unaligned(cpu_to_le16(0x08), (u16 *)(pBuffer + sizeof( sQMUX ) + 8)); - put_unaligned(cpu_to_le32(0x02), (u32 *)(pBuffer + sizeof( sQMUX ) + 10)); // ep_type - put_unaligned(cpu_to_le32(0x04), (u32 *)(pBuffer + sizeof( sQMUX ) + 14)); // iface_id - - *(u8 *)(pBuffer + sizeof( sQMUX ) + 18) = 0x11; - put_unaligned(cpu_to_le16(0x01), (u16 *)(pBuffer + sizeof( sQMUX ) + 19)); - *(u8 *)(pBuffer + sizeof( sQMUX ) + 21) = MuxId; // MuxId - - *(u8 *)(pBuffer + sizeof( sQMUX ) + 22) = 0x13; - put_unaligned(cpu_to_le16(0x04), (u16 *)(pBuffer + sizeof( sQMUX ) + 23)); - put_unaligned(cpu_to_le32(0x01), (u32 *)(pBuffer + sizeof( sQMUX ) + 25)); - - // success - return sizeof( sQMUX ) + 29; -} -#endif - -/*=========================================================================== -METHOD: - QMIDMSGetMEIDReq (Public Method) - -DESCRIPTION: - Fill buffer with QMI DMS Get Serial Numbers Request - -PARAMETERS - pBuffer [ 0 ] - Buffer to be filled - buffSize [ I ] - Size of pBuffer - transactionID [ I ] - Transaction ID - -RETURN VALUE: - int - Positive for resulting size of pBuffer - Negative errno for error -===========================================================================*/ -static int QMIDMSGetMEIDReq( - void * pBuffer, - u16 buffSize, - u16 transactionID ) -{ - if (pBuffer == 0 || buffSize < QMIDMSGetMEIDReqSize() ) - { - return -ENOMEM; - } - - // QMI DMS GET SERIAL NUMBERS REQ - // Request - *(u8 *)(pBuffer + sizeof( sQMUX )) = 0x00; - // Transaction ID - put_unaligned( cpu_to_le16(transactionID), (u16 *)(pBuffer + sizeof( sQMUX ) + 1) ); - // Message ID - put_unaligned( cpu_to_le16(0x0025), (u16 *)(pBuffer + sizeof( sQMUX ) + 3) ); - // Size of TLV's - put_unaligned( cpu_to_le16(0x0000), (u16 *)(pBuffer + sizeof( sQMUX ) + 5)); - - // success - return sizeof( sQMUX ) + 7; -} - -/*=========================================================================== -METHOD: - QMIWDASetDataFormatReq (Public Method) - -DESCRIPTION: - Fill buffer with QMI WDA Set Data Format Request - -PARAMETERS - pBuffer [ 0 ] - Buffer to be filled - buffSize [ I ] - Size of pBuffer - transactionID [ I ] - Transaction ID - -RETURN VALUE: - int - Positive for resulting size of pBuffer - Negative errno for error -===========================================================================*/ -static int QMIWDASetDataFormatReq( - void * pBuffer, - u16 buffSize, - bool bRawIPMode, int qmap_version, u32 rx_size, - u16 transactionID ) -{ -if (qmap_version) { - struct QMIWDS_ADMIN_SET_DATA_FORMAT_REQ_MSG *pMUXMsg = (struct QMIWDS_ADMIN_SET_DATA_FORMAT_REQ_MSG *)(pBuffer + sizeof( sQMUX )); - - pMUXMsg->CtlFlags = 0x00; - put_unaligned( cpu_to_le16(transactionID), &pMUXMsg->TransactionId); - put_unaligned( cpu_to_le16(0x0020), &pMUXMsg->Type); - put_unaligned( cpu_to_le16(sizeof( struct QMIWDS_ADMIN_SET_DATA_FORMAT_REQ_MSG) - 7), &pMUXMsg->Length); - - //Indicates whether the Quality of Service(QOS) data format is used by the client. - pMUXMsg->QosDataFormatTlv.TLVType = 0x10; - pMUXMsg->QosDataFormatTlv.TLVLength = cpu_to_le16(0x0001); - pMUXMsg->QosDataFormatTlv.QOSSetting = 0; /* no-QOS header */ -//Underlying Link Layer Protocol - pMUXMsg->UnderlyingLinkLayerProtocolTlv.TLVType = 0x11; - pMUXMsg->UnderlyingLinkLayerProtocolTlv.TLVLength = cpu_to_le16(4); - pMUXMsg->UnderlyingLinkLayerProtocolTlv.Value = cpu_to_le32(0x02); /* Set Ethernet mode */ -//Uplink (UL) data aggregation protocol to be used for uplink data transfer. - pMUXMsg->UplinkDataAggregationProtocolTlv.TLVType = 0x12; - pMUXMsg->UplinkDataAggregationProtocolTlv.TLVLength = cpu_to_le16(4); - pMUXMsg->UplinkDataAggregationProtocolTlv.Value = cpu_to_le32(qmap_version); //UL QMAP is enabled -//Downlink (DL) data aggregation protocol to be used for downlink data transfer - pMUXMsg->DownlinkDataAggregationProtocolTlv.TLVType = 0x13; - pMUXMsg->DownlinkDataAggregationProtocolTlv.TLVLength = cpu_to_le16(4); - pMUXMsg->DownlinkDataAggregationProtocolTlv.Value = cpu_to_le32(qmap_version); //UL QMAP is enabled -//Maximum number of datagrams in a single aggregated packet on downlink - pMUXMsg->DownlinkDataAggregationMaxDatagramsTlv.TLVType = 0x15; - pMUXMsg->DownlinkDataAggregationMaxDatagramsTlv.TLVLength = cpu_to_le16(4); - pMUXMsg->DownlinkDataAggregationMaxDatagramsTlv.Value = cpu_to_le32(rx_size/1024); -//Maximum size in bytes of a single aggregated packet allowed on downlink - pMUXMsg->DownlinkDataAggregationMaxSizeTlv.TLVType = 0x16; - pMUXMsg->DownlinkDataAggregationMaxSizeTlv.TLVLength = cpu_to_le16(4); - pMUXMsg->DownlinkDataAggregationMaxSizeTlv.Value = cpu_to_le32(rx_size); -//Peripheral End Point ID - pMUXMsg->epTlv.TLVType = 0x17; - pMUXMsg->epTlv.TLVLength = cpu_to_le16(8); - pMUXMsg->epTlv.ep_type = cpu_to_le32(0x02); // DATA_EP_TYPE_BAM_DMUX - pMUXMsg->epTlv.iface_id = cpu_to_le32(0x04); -//Specifies the minimum padding bytes to be added in between aggregated downlink QMAP packets. - pMUXMsg->dl_minimum_padding.TLVType = 0x19; - pMUXMsg->dl_minimum_padding.TLVLength = cpu_to_le16(4); - pMUXMsg->dl_minimum_padding.Value = cpu_to_le32(0); -//Maximum number of datagrams in a single aggregated packet on uplink - pMUXMsg->UplinkDataAggregationMaxDatagramsTlv.TLVType = 27; - pMUXMsg->UplinkDataAggregationMaxDatagramsTlv.TLVLength = cpu_to_le16(4); - pMUXMsg->UplinkDataAggregationMaxDatagramsTlv.Value = cpu_to_le32(11); -//Maximum size in bytes of a single aggregated packet allowed on uplink - pMUXMsg->UplinkDataAggregationMaxSizeTlv.TLVType = 28; - pMUXMsg->UplinkDataAggregationMaxSizeTlv.TLVLength = cpu_to_le16(4); - pMUXMsg->UplinkDataAggregationMaxSizeTlv.Value = cpu_to_le32(8*1024); -} -else { - if (pBuffer == 0 || buffSize < QMIWDASetDataFormatReqSize(qmap_version) ) - { - return -ENOMEM; - } - - // QMI WDA SET DATA FORMAT REQ - // Request - *(u8 *)(pBuffer + sizeof( sQMUX )) = 0x00; - - // Transaction ID - put_unaligned( cpu_to_le16(transactionID), (u16 *)(pBuffer + sizeof( sQMUX ) + 1) ); - - // Message ID - put_unaligned( cpu_to_le16(0x0020), (u16 *)(pBuffer + sizeof( sQMUX ) + 3) ); - - // Size of TLV's - put_unaligned( cpu_to_le16(0x000b), (u16 *)(pBuffer + sizeof( sQMUX ) + 5)); - - /* TLVType QOS Data Format 1 byte */ - *(u8 *)(pBuffer + sizeof( sQMUX ) + 7) = 0x10; // type data format - - /* TLVLength 2 bytes - see spec */ - put_unaligned( cpu_to_le16(0x0001), (u16 *)(pBuffer + sizeof( sQMUX ) + 8)); - - /* DataFormat: 0-default; 1-QoS hdr present 2 bytes */ -#ifdef QOS_MODE - *(u8 *)(pBuffer + sizeof( sQMUX ) + 10) = 1; /* QOS header */ -#else - *(u8 *)(pBuffer + sizeof( sQMUX ) + 10) = 0; /* no-QOS header */ -#endif - - /* TLVType Link-Layer Protocol (Optional) 1 byte */ - *(u8 *)(pBuffer + sizeof( sQMUX ) + 11) = 0x11; - - /* TLVLength 2 bytes */ - put_unaligned( cpu_to_le16(0x0004), (u16 *)(pBuffer + sizeof( sQMUX ) + 12)); - - /* LinkProt: 0x1 - ETH; 0x2 - rawIP 4 bytes */ -if (bRawIPMode) { //#ifdef DATA_MODE_RP - /* Set RawIP mode */ - put_unaligned( cpu_to_le32(0x00000002), (u32 *)(pBuffer + sizeof( sQMUX ) + 14)); - DBG("Request RawIP Data Format\n"); -} else { //#else - /* Set Ethernet mode */ - put_unaligned( cpu_to_le32(0x00000001), (u32 *)(pBuffer + sizeof( sQMUX ) + 14)); - DBG("Request Ethernet Data Format\n"); -} //#endif - -} - - // success - return QMIWDASetDataFormatReqSize(qmap_version); -} - -#if 0 -static int QMIWDASetDataQmapReq( - void * pBuffer, - u16 buffSize, - u16 transactionID ) -{ - // QMI WDA SET DATA FORMAT REQ - // Request - *(u8 *)(pBuffer + sizeof( sQMUX )) = 0x00; - - // Transaction ID - put_unaligned( cpu_to_le16(transactionID), (u16 *)(pBuffer + sizeof( sQMUX ) + 1) ); - - // Message ID - put_unaligned( cpu_to_le16(0x002B), (u16 *)(pBuffer + sizeof( sQMUX ) + 3) ); - - // Size of TLV's - put_unaligned( cpu_to_le16(0x0004), (u16 *)(pBuffer + sizeof( sQMUX ) + 5)); - - /* TLVType QMAP In-Band Flow Control 1 byte */ - *(u8 *)(pBuffer + sizeof( sQMUX ) + 7) = 0x10; - put_unaligned( cpu_to_le16(0x0001), (u16 *)(pBuffer + sizeof( sQMUX ) + 8)); - *(u8 *)(pBuffer + sizeof( sQMUX ) + 10) = 0x01; - - // success - return ( sizeof( sQMUX ) + 11); -} -#endif - -#if 0 -/*=========================================================================== -METHOD: - QMICTLSetDataFormatReqSize (Public Method) - -DESCRIPTION: - Get size of buffer needed for QMUX + QMICTLSetDataFormatReq - -RETURN VALUE: - u16 - size of buffer -===========================================================================*/ -static u16 QMICTLSetDataFormatReqSize( void ) -{ - return sizeof( sQMUX ) + 15; -} - -/*=========================================================================== -METHOD: - QMICTLSetDataFormatReq (Public Method) - -DESCRIPTION: - Fill buffer with QMI CTL Set Data Format Request - -PARAMETERS - pBuffer [ 0 ] - Buffer to be filled - buffSize [ I ] - Size of pBuffer - transactionID [ I ] - Transaction ID - -RETURN VALUE: - int - Positive for resulting size of pBuffer - Negative errno for error -===========================================================================*/ -static int QMICTLSetDataFormatReq( - void * pBuffer, - u16 buffSize, - u8 transactionID ) -{ - if (pBuffer == 0 || buffSize < QMICTLSetDataFormatReqSize() ) - { - return -ENOMEM; - } - - /* QMI CTL Set Data Format Request */ - /* Request */ - *(u8 *)(pBuffer + sizeof( sQMUX )) = 0x00; // QMICTL_FLAG_REQUEST - - /* Transaction ID 1 byte */ - *(u8 *)(pBuffer + sizeof( sQMUX ) + 1) = transactionID; /* 1 byte as in spec */ - - /* QMICTLType 2 bytes */ - put_unaligned( cpu_to_le16(0x0026), (u16 *)(pBuffer + sizeof( sQMUX ) + 2)); - - /* Length 2 bytes of 2 TLVs each - see spec */ - put_unaligned( cpu_to_le16(0x0009), (u16 *)(pBuffer + sizeof( sQMUX ) + 4)); - - /* TLVType Data Format (Mandatory) 1 byte */ - *(u8 *)(pBuffer + sizeof( sQMUX ) + 6) = 0x01; // type data format - - /* TLVLength 2 bytes - see spec */ - put_unaligned( cpu_to_le16(0x0001), (u16 *)(pBuffer + sizeof( sQMUX ) + 7)); - - /* DataFormat: 0-default; 1-QoS hdr present 2 bytes */ -#ifdef QOS_MODE - *(u8 *)(pBuffer + sizeof( sQMUX ) + 9) = 1; /* QOS header */ -#else - *(u8 *)(pBuffer + sizeof( sQMUX ) + 9) = 0; /* no-QOS header */ -#endif - - /* TLVType Link-Layer Protocol (Optional) 1 byte */ - *(u8 *)(pBuffer + sizeof( sQMUX ) + 10) = TLV_TYPE_LINK_PROTO; - - /* TLVLength 2 bytes */ - put_unaligned( cpu_to_le16(0x0002), (u16 *)(pBuffer + sizeof( sQMUX ) + 11)); - - /* LinkProt: 0x1 - ETH; 0x2 - rawIP 2 bytes */ -#ifdef DATA_MODE_RP - /* Set RawIP mode */ - put_unaligned( cpu_to_le16(0x0002), (u16 *)(pBuffer + sizeof( sQMUX ) + 13)); - DBG("Request RawIP Data Format\n"); -#else - /* Set Ethernet mode */ - put_unaligned( cpu_to_le16(0x0001), (u16 *)(pBuffer + sizeof( sQMUX ) + 13)); - DBG("Request Ethernet Data Format\n"); -#endif - - /* success */ - return sizeof( sQMUX ) + 15; - -} -#endif - -/*=========================================================================== -METHOD: - QMICTLSyncReq (Public Method) - -DESCRIPTION: - Fill buffer with QMI CTL Sync Request - -PARAMETERS - pBuffer [ 0 ] - Buffer to be filled - buffSize [ I ] - Size of pBuffer - transactionID [ I ] - Transaction ID - -RETURN VALUE: - int - Positive for resulting size of pBuffer - Negative errno for error -===========================================================================*/ -static int QMICTLSyncReq( - void * pBuffer, - u16 buffSize, - u16 transactionID ) -{ - if (pBuffer == 0 || buffSize < QMICTLSyncReqSize() ) - { - return -ENOMEM; - } - - // Request - *(u8 *)(pBuffer + sizeof( sQMUX )) = 0x00; - // Transaction ID - *(u8 *)(pBuffer + sizeof( sQMUX ) + 1) = transactionID; - // Message ID - put_unaligned( cpu_to_le16(0x0027), (u16 *)(pBuffer + sizeof( sQMUX ) + 2) ); - // Size of TLV's - put_unaligned( cpu_to_le16(0x0000), (u16 *)(pBuffer + sizeof( sQMUX ) + 4) ); - - // success - return sizeof( sQMUX ) + 6; -} - -/*=========================================================================*/ -// Parse data from QMI responses -/*=========================================================================*/ - -/*=========================================================================== -METHOD: - QMICTLGetClientIDResp (Public Method) - -DESCRIPTION: - Parse the QMI CTL Get Client ID Resp - -PARAMETERS - pBuffer [ I ] - Buffer to be parsed - buffSize [ I ] - Size of pBuffer - pClientID [ 0 ] - Recieved client ID - -RETURN VALUE: - int - 0 for success - Negative errno for error -===========================================================================*/ -static int QMICTLGetClientIDResp( - void * pBuffer, - u16 buffSize, - u16 * pClientID ) -{ - int result; - - // Ignore QMUX and SDU - // QMI CTL SDU is 2 bytes, not 3 - u8 offset = sizeof( sQMUX ) + 2; - - if (pBuffer == 0 || buffSize < offset) - { - return -ENOMEM; - } - - pBuffer = pBuffer + offset; - buffSize -= offset; - - result = GetQMIMessageID( pBuffer, buffSize ); - if (result != 0x22) - { - return -EFAULT; - } - - result = ValidQMIMessage( pBuffer, buffSize ); - if (result != 0) - { - return -EFAULT; - } - - result = GetTLV( pBuffer, buffSize, 0x01, pClientID, 2 ); - if (result != 2) - { - return -EFAULT; - } - - return 0; -} - -/*=========================================================================== -METHOD: - QMICTLReleaseClientIDResp (Public Method) - -DESCRIPTION: - Verify the QMI CTL Release Client ID Resp is valid - -PARAMETERS - pBuffer [ I ] - Buffer to be parsed - buffSize [ I ] - Size of pBuffer - -RETURN VALUE: - int - 0 for success - Negative errno for error -===========================================================================*/ -static int QMICTLReleaseClientIDResp( - void * pBuffer, - u16 buffSize ) -{ - int result; - - // Ignore QMUX and SDU - // QMI CTL SDU is 2 bytes, not 3 - u8 offset = sizeof( sQMUX ) + 2; - - if (pBuffer == 0 || buffSize < offset) - { - return -ENOMEM; - } - - pBuffer = pBuffer + offset; - buffSize -= offset; - - result = GetQMIMessageID( pBuffer, buffSize ); - if (result != 0x23) - { - return -EFAULT; - } - - result = ValidQMIMessage( pBuffer, buffSize ); - if (result != 0) - { - return -EFAULT; - } - - return 0; -} - -/*=========================================================================== -METHOD: - QMIWDSEventResp (Public Method) - -DESCRIPTION: - Parse the QMI WDS Set Event Report Resp/Indication or - QMI WDS Get PKG SRVC Status Resp/Indication - - Return parameters will only be updated if value was received - -PARAMETERS - pBuffer [ I ] - Buffer to be parsed - buffSize [ I ] - Size of pBuffer - pTXOk [ O ] - Number of transmitted packets without errors - pRXOk [ O ] - Number of recieved packets without errors - pTXErr [ O ] - Number of transmitted packets with framing errors - pRXErr [ O ] - Number of recieved packets with framing errors - pTXOfl [ O ] - Number of transmitted packets dropped due to overflow - pRXOfl [ O ] - Number of recieved packets dropped due to overflow - pTXBytesOk [ O ] - Number of transmitted bytes without errors - pRXBytesOk [ O ] - Number of recieved bytes without errors - pbLinkState [ 0 ] - Is the link active? - pbReconfigure [ 0 ] - Must interface be reconfigured? (reset IP address) - -RETURN VALUE: - int - 0 for success - Negative errno for error -===========================================================================*/ -static int QMIWDSEventResp( - void * pBuffer, - u16 buffSize, - u32 * pTXOk, - u32 * pRXOk, - u32 * pTXErr, - u32 * pRXErr, - u32 * pTXOfl, - u32 * pRXOfl, - u64 * pTXBytesOk, - u64 * pRXBytesOk, - bool * pbLinkState, - bool * pbReconfigure ) -{ - int result; - u8 pktStatusRead[2]; - - // Ignore QMUX and SDU - u8 offset = sizeof( sQMUX ) + 3; - - if (pBuffer == 0 - || buffSize < offset - || pTXOk == 0 - || pRXOk == 0 - || pTXErr == 0 - || pRXErr == 0 - || pTXOfl == 0 - || pRXOfl == 0 - || pTXBytesOk == 0 - || pRXBytesOk == 0 - || pbLinkState == 0 - || pbReconfigure == 0 ) - { - return -ENOMEM; - } - - pBuffer = pBuffer + offset; - buffSize -= offset; - - // Note: Indications. No Mandatory TLV required - - result = GetQMIMessageID( pBuffer, buffSize ); - // QMI WDS Set Event Report Resp - if (result == 0x01) - { - // TLV's are not mandatory - GetTLV( pBuffer, buffSize, 0x10, (void*)pTXOk, 4 ); - put_unaligned( le32_to_cpu(*pTXOk), pTXOk); - GetTLV( pBuffer, buffSize, 0x11, (void*)pRXOk, 4 ); - put_unaligned( le32_to_cpu(*pRXOk), pRXOk); - GetTLV( pBuffer, buffSize, 0x12, (void*)pTXErr, 4 ); - put_unaligned( le32_to_cpu(*pTXErr), pTXErr); - GetTLV( pBuffer, buffSize, 0x13, (void*)pRXErr, 4 ); - put_unaligned( le32_to_cpu(*pRXErr), pRXErr); - GetTLV( pBuffer, buffSize, 0x14, (void*)pTXOfl, 4 ); - put_unaligned( le32_to_cpu(*pTXOfl), pTXOfl); - GetTLV( pBuffer, buffSize, 0x15, (void*)pRXOfl, 4 ); - put_unaligned( le32_to_cpu(*pRXOfl), pRXOfl); - GetTLV( pBuffer, buffSize, 0x19, (void*)pTXBytesOk, 8 ); - put_unaligned( le64_to_cpu(*pTXBytesOk), pTXBytesOk); - GetTLV( pBuffer, buffSize, 0x1A, (void*)pRXBytesOk, 8 ); - put_unaligned( le64_to_cpu(*pRXBytesOk), pRXBytesOk); - } - // QMI WDS Get PKG SRVC Status Resp - else if (result == 0x22) - { - result = GetTLV( pBuffer, buffSize, 0x01, &pktStatusRead[0], 2 ); - // 1 or 2 bytes may be received - if (result >= 1) - { - if (pktStatusRead[0] == 0x02) - { - *pbLinkState = true; - } - else - { - *pbLinkState = false; - } - } - if (result == 2) - { - if (pktStatusRead[1] == 0x01) - { - *pbReconfigure = true; - } - else - { - *pbReconfigure = false; - } - } - - if (result < 0) - { - return result; - } - } - else - { - return -EFAULT; - } - - return 0; -} - -/*=========================================================================== -METHOD: - QMIDMSGetMEIDResp (Public Method) - -DESCRIPTION: - Parse the QMI DMS Get Serial Numbers Resp - -PARAMETERS - pBuffer [ I ] - Buffer to be parsed - buffSize [ I ] - Size of pBuffer - pMEID [ O ] - Device MEID - meidSize [ I ] - Size of MEID buffer (at least 14) - -RETURN VALUE: - int - 0 for success - Negative errno for error -===========================================================================*/ -static int QMIDMSGetMEIDResp( - void * pBuffer, - u16 buffSize, - char * pMEID, - int meidSize ) -{ - int result; - - // Ignore QMUX and SDU - u8 offset = sizeof( sQMUX ) + 3; - - if (pBuffer == 0 || buffSize < offset || meidSize < 14) - { - return -ENOMEM; - } - - pBuffer = pBuffer + offset; - buffSize -= offset; - - result = GetQMIMessageID( pBuffer, buffSize ); - if (result != 0x25) - { - return -EFAULT; - } - - result = ValidQMIMessage( pBuffer, buffSize ); - if (result != 0) - { - return -EFAULT; - } - - result = GetTLV( pBuffer, buffSize, 0x12, (void*)pMEID, 14 ); - if (result != 14) - { - return -EFAULT; - } - - return 0; -} - -/*=========================================================================== -METHOD: - QMIWDASetDataFormatResp (Public Method) - -DESCRIPTION: - Parse the QMI WDA Set Data Format Response - -PARAMETERS - pBuffer [ I ] - Buffer to be parsed - buffSize [ I ] - Size of pBuffer - -RETURN VALUE: - int - 0 for success - Negative errno for error -===========================================================================*/ -static int QMIWDASetDataFormatResp( - void * pBuffer, - u16 buffSize, bool bRawIPMode, int *qmap_version, int *rx_size, int *tx_size, QMAP_SETTING *set) -{ - - int result; - - u8 pktLinkProtocol[4]; - - // Ignore QMUX and SDU - // QMI SDU is 3 bytes - u8 offset = sizeof( sQMUX ) + 3; - - if (pBuffer == 0 || buffSize < offset) - { - return -ENOMEM; - } - - pBuffer = pBuffer + offset; - buffSize -= offset; - - result = GetQMIMessageID( pBuffer, buffSize ); - if (result != 0x20) - { - return -EFAULT; - } - - /* Check response message result TLV */ - result = ValidQMIMessage( pBuffer, buffSize ); - if (result != 0) - { - DBG("EFAULT: Data Format Mode Bad Response\n"); -// return -EFAULT; - return 0; - } - - /* Check response message link protocol */ - result = GetTLV( pBuffer, buffSize, 0x11, - &pktLinkProtocol[0], 4); - if (result != 4) - { - DBG("EFAULT: Wrong TLV format\n"); - return 0; - } - -if (bRawIPMode) { ////#ifdef DATA_MODE_RP - if (pktLinkProtocol[0] != 2) - { - DBG("EFAULT: Data Format Cannot be set to RawIP Mode\n"); - return pktLinkProtocol[0]; - } - DBG("Data Format Set to RawIP\n"); -} else { ////#else - if (pktLinkProtocol[0] != 1) - { - DBG("EFAULT: Data Format Cannot be set to Ethernet Mode\n"); - return pktLinkProtocol[0]; - } - DBG("Data Format Set to Ethernet Mode \n"); -} //#endif - - GetTLV( pBuffer, buffSize, 0x12, qmap_version, 4); - if (le32_to_cpu(*qmap_version)) - GetTLV( pBuffer, buffSize, 0x13, qmap_version, 4); - - GetTLV( pBuffer, buffSize, 0x16, rx_size, 4); - GetTLV( pBuffer, buffSize, 0x18, tx_size, 4); - - if (set) { - GetTLV( pBuffer, buffSize, 0x15, &set->dl_data_aggregation_max_datagrams, 4); - GetTLV( pBuffer, buffSize, 0x16, &set->dl_data_aggregation_max_size, 4); - GetTLV( pBuffer, buffSize, 0x17, &set->ul_data_aggregation_max_datagrams, 4); - GetTLV( pBuffer, buffSize, 0x18, &set->ul_data_aggregation_max_size, 4); - GetTLV( pBuffer, buffSize, 0x1a, &set->dl_minimum_padding, 4); - } - - return pktLinkProtocol[0]; -} - -/*=========================================================================== -METHOD: - QMICTLSyncResp (Public Method) - -DESCRIPTION: - Validate the QMI CTL Sync Response - -PARAMETERS - pBuffer [ I ] - Buffer to be parsed - buffSize [ I ] - Size of pBuffer - -RETURN VALUE: - int - 0 for success - Negative errno for error -===========================================================================*/ -static int QMICTLSyncResp( - void *pBuffer, - u16 buffSize ) -{ - int result; - - // Ignore QMUX (2 bytes for QMI CTL) and SDU - u8 offset = sizeof( sQMUX ) + 2; - - if (pBuffer == 0 || buffSize < offset) - { - return -ENOMEM; - } - - pBuffer = pBuffer + offset; - buffSize -= offset; - - result = GetQMIMessageID( pBuffer, buffSize ); - if (result != 0x27) - { - return -EFAULT; - } - - result = ValidQMIMessage( pBuffer, buffSize ); - - return result; -} -#endif diff --git a/quectel_Gobinet/src/QMI.h b/quectel_Gobinet/src/QMI.h deleted file mode 100644 index 4508be4..0000000 --- a/quectel_Gobinet/src/QMI.h +++ /dev/null @@ -1,337 +0,0 @@ -/*=========================================================================== -FILE: - QMI.h - -DESCRIPTION: - Qualcomm QMI driver header - -FUNCTIONS: - Generic QMUX functions - ParseQMUX - FillQMUX - - Generic QMI functions - GetTLV - ValidQMIMessage - GetQMIMessageID - - Get sizes of buffers needed by QMI requests - QMUXHeaderSize - QMICTLGetClientIDReqSize - QMICTLReleaseClientIDReqSize - QMICTLReadyReqSize - QMIWDSSetEventReportReqSize - QMIWDSGetPKGSRVCStatusReqSize - QMIDMSGetMEIDReqSize - QMICTLSyncReqSize - - Fill Buffers with QMI requests - QMICTLGetClientIDReq - QMICTLReleaseClientIDReq - QMICTLReadyReq - QMIWDSSetEventReportReq - QMIWDSGetPKGSRVCStatusReq - QMIDMSGetMEIDReq - QMICTLSetDataFormatReq - QMICTLSyncReq - - Parse data from QMI responses - QMICTLGetClientIDResp - QMICTLReleaseClientIDResp - QMIWDSEventResp - QMIDMSGetMEIDResp - -Copyright (c) 2011, Code Aurora Forum. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of Code Aurora Forum nor - the names of its contributors may be used to endorse or promote - products derived from this software without specific prior written - permission. - - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. -===========================================================================*/ - -#pragma once - -/*=========================================================================*/ -// Definitions -/*=========================================================================*/ - -extern int quec_debug; -// DBG macro -#define DBG( format, arg... ) do { \ - if (quec_debug == 1)\ - { \ - printk( KERN_INFO "GobiNet::%s " format, __FUNCTION__, ## arg ); \ - } }while(0) - -#if 0 -#define VDBG( format, arg... ) do { \ - if (debug == 1)\ - { \ - printk( KERN_INFO "GobiNet::%s " format, __FUNCTION__, ## arg ); \ - } } while(0) -#else -#define VDBG( format, arg... ) do { } while(0) -#endif - -#define INFO( format, arg... ) do { \ - printk( KERN_INFO "GobiNet::%s " format, __FUNCTION__, ## arg ); \ - }while(0) - -// QMI Service Types -#define QMICTL 0 -#define QMIWDS 1 -#define QMIDMS 2 -#define QMINAS 3 -#define QMIUIM 11 -#define QMIWDA 0x1A - -#define u8 unsigned char -#define u16 unsigned short -#define u32 unsigned int -#define u64 unsigned long long - -#define bool u8 -#define true 1 -#define false 0 - -#define ENOMEM 12 -#define EFAULT 14 -#define EINVAL 22 -#ifndef ENOMSG -#define ENOMSG 42 -#endif -#define ENODATA 61 - -#define TLV_TYPE_LINK_PROTO 0x10 - -/*=========================================================================*/ -// Struct sQMUX -// -// Structure that defines a QMUX header -/*=========================================================================*/ -typedef struct sQMUX -{ - /* T\F, always 1 */ - u8 mTF; - - /* Size of message */ - u16 mLength; - - /* Control flag */ - u8 mCtrlFlag; - - /* Service Type */ - u8 mQMIService; - - /* Client ID */ - u8 mQMIClientID; - -}__attribute__((__packed__)) sQMUX; - -#if 0 -/*=========================================================================*/ -// Generic QMUX functions -/*=========================================================================*/ - -// Remove QMUX headers from a buffer -int ParseQMUX( - u16 * pClientID, - void * pBuffer, - u16 buffSize ); - -// Fill buffer with QMUX headers -int FillQMUX( - u16 clientID, - void * pBuffer, - u16 buffSize ); - -/*=========================================================================*/ -// Generic QMI functions -/*=========================================================================*/ - -// Get data buffer of a specified TLV from a QMI message -int GetTLV( - void * pQMIMessage, - u16 messageLen, - u8 type, - void * pOutDataBuf, - u16 bufferLen ); - -// Check mandatory TLV in a QMI message -int ValidQMIMessage( - void * pQMIMessage, - u16 messageLen ); - -// Get the message ID of a QMI message -int GetQMIMessageID( - void * pQMIMessage, - u16 messageLen ); - -/*=========================================================================*/ -// Get sizes of buffers needed by QMI requests -/*=========================================================================*/ - -// Get size of buffer needed for QMUX -u16 QMUXHeaderSize( void ); - -// Get size of buffer needed for QMUX + QMICTLGetClientIDReq -u16 QMICTLGetClientIDReqSize( void ); - -// Get size of buffer needed for QMUX + QMICTLReleaseClientIDReq -u16 QMICTLReleaseClientIDReqSize( void ); - -// Get size of buffer needed for QMUX + QMICTLReadyReq -u16 QMICTLReadyReqSize( void ); - -// Get size of buffer needed for QMUX + QMIWDSSetEventReportReq -u16 QMIWDSSetEventReportReqSize( void ); - -// Get size of buffer needed for QMUX + QMIWDSGetPKGSRVCStatusReq -u16 QMIWDSGetPKGSRVCStatusReqSize( void ); - -u16 QMIWDSSetQMUXBindMuxDataPortSize( void ); - -// Get size of buffer needed for QMUX + QMIDMSGetMEIDReq -u16 QMIDMSGetMEIDReqSize( void ); - -// Get size of buffer needed for QMUX + QMIWDASetDataFormatReq -u16 QMIWDASetDataFormatReqSize( int qmap_mode ); - -// Get size of buffer needed for QMUX + QMICTLSyncReq -u16 QMICTLSyncReqSize( void ); - -/*=========================================================================*/ -// Fill Buffers with QMI requests -/*=========================================================================*/ - -// Fill buffer with QMI CTL Get Client ID Request -int QMICTLGetClientIDReq( - void * pBuffer, - u16 buffSize, - u8 transactionID, - u8 serviceType ); - -// Fill buffer with QMI CTL Release Client ID Request -int QMICTLReleaseClientIDReq( - void * pBuffer, - u16 buffSize, - u8 transactionID, - u16 clientID ); - -// Fill buffer with QMI CTL Get Version Info Request -int QMICTLReadyReq( - void * pBuffer, - u16 buffSize, - u8 transactionID ); - -// Fill buffer with QMI WDS Set Event Report Request -int QMIWDSSetEventReportReq( - void * pBuffer, - u16 buffSize, - u16 transactionID ); - -// Fill buffer with QMI WDS Get PKG SRVC Status Request -int QMIWDSGetPKGSRVCStatusReq( - void * pBuffer, - u16 buffSize, - u16 transactionID ); - -u16 QMIWDSSetQMUXBindMuxDataPortReq( - void * pBuffer, - u16 buffSize, - u8 MuxId, - u16 transactionID ); - -// Fill buffer with QMI DMS Get Serial Numbers Request -int QMIDMSGetMEIDReq( - void * pBuffer, - u16 buffSize, - u16 transactionID ); - -// Fill buffer with QMI WDA Set Data Format Request -int QMIWDASetDataFormatReq( - void * pBuffer, - u16 buffSize, - bool bRawIPMode, int qmap_mode, u32 rx_size, - u16 transactionID ); - -#if 0 -int QMIWDASetDataQmapReq( - void * pBuffer, - u16 buffSize, - u16 transactionID ); -#endif - -int QMICTLSyncReq( - void * pBuffer, - u16 buffSize, - u16 transactionID ); - -/*=========================================================================*/ -// Parse data from QMI responses -/*=========================================================================*/ - -// Parse the QMI CTL Get Client ID Resp -int QMICTLGetClientIDResp( - void * pBuffer, - u16 buffSize, - u16 * pClientID ); - -// Verify the QMI CTL Release Client ID Resp is valid -int QMICTLReleaseClientIDResp( - void * pBuffer, - u16 buffSize ); - -// Parse the QMI WDS Set Event Report Resp/Indication or -// QMI WDS Get PKG SRVC Status Resp/Indication -int QMIWDSEventResp( - void * pBuffer, - u16 buffSize, - u32 * pTXOk, - u32 * pRXOk, - u32 * pTXErr, - u32 * pRXErr, - u32 * pTXOfl, - u32 * pRXOfl, - u64 * pTXBytesOk, - u64 * pRXBytesOk, - bool * pbLinkState, - bool * pbReconfigure ); - -// Parse the QMI DMS Get Serial Numbers Resp -int QMIDMSGetMEIDResp( - void * pBuffer, - u16 buffSize, - char * pMEID, - int meidSize ); - -// Parse the QMI DMS Get Serial Numbers Resp -int QMIWDASetDataFormatResp( - void * pBuffer, - u16 buffSize, bool bRawIPMode, int *qmap_enabled, int *rx_size, int *tx_size); - -// Pasre the QMI CTL Sync Response -int QMICTLSyncResp( - void *pBuffer, - u16 buffSize ); -#endif diff --git a/quectel_Gobinet/src/QMIDevice.c b/quectel_Gobinet/src/QMIDevice.c deleted file mode 100644 index fe6b6cf..0000000 --- a/quectel_Gobinet/src/QMIDevice.c +++ /dev/null @@ -1,4363 +0,0 @@ -/*=========================================================================== -FILE: - QMIDevice.c - -DESCRIPTION: - Functions related to the QMI interface device - -FUNCTIONS: - Generic functions - IsDeviceValid - PrintHex - GobiSetDownReason - GobiClearDownReason - GobiTestDownReason - - Driver level asynchronous read functions - ResubmitIntURB - ReadCallback - IntCallback - StartRead - KillRead - - Internal read/write functions - ReadAsync - UpSem - ReadSync - WriteSyncCallback - WriteSync - - Internal memory management functions - GetClientID - ReleaseClientID - FindClientMem - AddToReadMemList - PopFromReadMemList - AddToNotifyList - NotifyAndPopNotifyList - AddToURBList - PopFromURBList - - Internal userspace wrapper functions - UserspaceunlockedIOCTL - - Userspace wrappers - UserspaceOpen - UserspaceIOCTL - UserspaceClose - UserspaceRead - UserspaceWrite - UserspacePoll - - Initializer and destructor - RegisterQMIDevice - DeregisterQMIDevice - - Driver level client management - QMIReady - QMIWDSCallback - SetupQMIWDSCallback - QMIDMSGetMEID - -Copyright (c) 2011, Code Aurora Forum. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of Code Aurora Forum nor - the names of its contributors may be used to endorse or promote - products derived from this software without specific prior written - permission. - - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. -===========================================================================*/ - -//--------------------------------------------------------------------------- -// Include Files -//--------------------------------------------------------------------------- -#include -#include -#include -#include - -//----------------------------------------------------------------------------- -// Definitions -//----------------------------------------------------------------------------- - -#define __QUEC_INCLUDE_QMI_C__ -#include "QMI.c" -#define __QUECTEL_INTER__ -#include "QMIDevice.h" - -#if (LINUX_VERSION_CODE <= KERNEL_VERSION( 2,6,22 )) -static int s_interval; -#endif - -#if (LINUX_VERSION_CODE <= KERNEL_VERSION( 2,6,14 )) -#include -static char devfs_name[32]; -static int device_create(struct class *class, struct device *parent, dev_t devt, const char *fmt, ...) -{ - va_list vargs; - struct class_device *class_dev; - int err; - - va_start(vargs, fmt); - vsnprintf(devfs_name, sizeof(devfs_name), fmt, vargs); - va_end(vargs); - - class_dev = class_device_create(class, devt, parent, "%s", devfs_name); - if (IS_ERR(class_dev)) { - err = PTR_ERR(class_dev); - goto out; - } - - err = devfs_mk_cdev(devt, S_IFCHR|S_IRUSR|S_IWUSR|S_IRGRP, devfs_name); - if (err) { - class_device_destroy(class, devt); - goto out; - } - - return 0; - -out: - return err; -} - -static void device_destroy(struct class *class, dev_t devt) -{ - class_device_destroy(class, devt); - devfs_remove(devfs_name); -} -#endif - -#ifdef CONFIG_PM -// Prototype to GobiNetSuspend function -int QuecGobiNetSuspend( - struct usb_interface * pIntf, - pm_message_t powerEvent ); -#endif /* CONFIG_PM */ - -// IOCTL to generate a client ID for this service type -#define IOCTL_QMI_GET_SERVICE_FILE 0x8BE0 + 1 - -// IOCTL to get the VIDPID of the device -#define IOCTL_QMI_GET_DEVICE_VIDPID 0x8BE0 + 2 - -// IOCTL to get the MEID of the device -#define IOCTL_QMI_GET_DEVICE_MEID 0x8BE0 + 3 - -#define IOCTL_QMI_RELEASE_SERVICE_FILE_IOCTL (0x8BE0 + 4) - -// CDC GET_ENCAPSULATED_RESPONSE packet -#define CDC_GET_ENCAPSULATED_RESPONSE_LE 0x01A1ll -#define CDC_GET_ENCAPSULATED_RESPONSE_BE 0xA101000000000000ll -/* The following masks filter the common part of the encapsulated response - * packet value for Gobi and QMI devices, ie. ignore usb interface number - */ -#define CDC_RSP_MASK_BE 0xFFFFFFFF00FFFFFFll -#define CDC_RSP_MASK_LE 0xFFFFFFE0FFFFFFFFll - -static const int i = 1; -#define is_bigendian() ( (*(char*)&i) == 0 ) -#define CDC_GET_ENCAPSULATED_RESPONSE(pcdcrsp, pmask)\ -{\ - *pcdcrsp = is_bigendian() ? CDC_GET_ENCAPSULATED_RESPONSE_BE \ - : CDC_GET_ENCAPSULATED_RESPONSE_LE ; \ - *pmask = is_bigendian() ? CDC_RSP_MASK_BE \ - : CDC_RSP_MASK_LE; \ -} - -// CDC CONNECTION_SPEED_CHANGE indication packet -#define CDC_CONNECTION_SPEED_CHANGE_LE 0x2AA1ll -#define CDC_CONNECTION_SPEED_CHANGE_BE 0xA12A000000000000ll -/* The following masks filter the common part of the connection speed change - * packet value for Gobi and QMI devices - */ -#define CDC_CONNSPD_MASK_BE 0xFFFFFFFFFFFF7FFFll -#define CDC_CONNSPD_MASK_LE 0XFFF7FFFFFFFFFFFFll -#define CDC_GET_CONNECTION_SPEED_CHANGE(pcdccscp, pmask)\ -{\ - *pcdccscp = is_bigendian() ? CDC_CONNECTION_SPEED_CHANGE_BE \ - : CDC_CONNECTION_SPEED_CHANGE_LE ; \ - *pmask = is_bigendian() ? CDC_CONNSPD_MASK_BE \ - : CDC_CONNSPD_MASK_LE; \ -} - -#define SET_CONTROL_LINE_STATE_REQUEST_TYPE 0x21 -#define SET_CONTROL_LINE_STATE_REQUEST 0x22 -#define CONTROL_DTR 0x01 -#define CONTROL_RTS 0x02 - -/*=========================================================================*/ -// UserspaceQMIFops -// QMI device's userspace file operations -/*=========================================================================*/ -static struct file_operations UserspaceQMIFops = -{ - .owner = THIS_MODULE, - .read = UserspaceRead, - .write = UserspaceWrite, -#ifdef CONFIG_COMPAT - .compat_ioctl = UserspaceunlockedIOCTL, -#endif -#if (LINUX_VERSION_CODE >= KERNEL_VERSION( 2,6,36 )) - .unlocked_ioctl = UserspaceunlockedIOCTL, -#else - .ioctl = UserspaceIOCTL, -#endif - .open = UserspaceOpen, -#ifdef quectel_no_for_each_process - .release = UserspaceClose, -#else - .flush = UserspaceClose, -#endif - .poll = UserspacePoll, -}; - -/*=========================================================================*/ -// Generic functions -/*=========================================================================*/ -static u8 QMIXactionIDGet( sGobiUSBNet *pDev) -{ - u8 transactionID; - - if( 0 == (transactionID = atomic_add_return( 1, &pDev->mQMIDev.mQMICTLTransactionID)) ) - { - transactionID = atomic_add_return( 1, &pDev->mQMIDev.mQMICTLTransactionID ); - } - -#if 1 //free these ununsed qmi response, or when these transactionID re-used, they will be regarded as qmi response of the qmi request that have same transactionID - if (transactionID) { - unsigned long flags; - void * pReadBuffer; - u16 readBufferSize; - - spin_lock_irqsave( &pDev->mQMIDev.mClientMemLock, flags ); - while (PopFromReadMemList( pDev, - QMICTL, - transactionID, - &pReadBuffer, - &readBufferSize ) == true) - { - kfree( pReadBuffer ); - } - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - } -#endif - - return transactionID; -} - -static struct usb_endpoint_descriptor *GetEndpoint( - struct usb_interface *pintf, - int type, - int dir ) -{ - int i; - struct usb_host_interface *iface = pintf->cur_altsetting; - struct usb_endpoint_descriptor *pendp; - - for( i = 0; i < iface->desc.bNumEndpoints; i++) - { - pendp = &iface->endpoint[i].desc; - if( ((pendp->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == dir) - && - (usb_endpoint_type(pendp) == type) ) - { - return pendp; - } - } - - return NULL; -} - -/*=========================================================================== -METHOD: - IsDeviceValid (Public Method) - -DESCRIPTION: - Basic test to see if device memory is valid - -PARAMETERS: - pDev [ I ] - Device specific memory - -RETURN VALUE: - bool -===========================================================================*/ -static bool IsDeviceValid( sGobiUSBNet * pDev ) -{ - if (pDev == NULL) - { - return false; - } - - if (pDev->mbQMIValid == false) - { - return false; - } - - return true; -} - -/*=========================================================================== -METHOD: - PrintHex (Public Method) - -DESCRIPTION: - Print Hex data, for debug purposes - -PARAMETERS: - pBuffer [ I ] - Data buffer - bufSize [ I ] - Size of data buffer - -RETURN VALUE: - None -===========================================================================*/ -void QuecPrintHex( - void * pBuffer, - u16 bufSize ) -{ - char * pPrintBuf; - u16 pos; - int status; - - if (quec_debug != 1) - { - return; - } - - pPrintBuf = kmalloc( bufSize * 3 + 1, GFP_ATOMIC ); - if (pPrintBuf == NULL) - { - DBG( "Unable to allocate buffer\n" ); - return; - } - memset( pPrintBuf, 0 , bufSize * 3 + 1 ); - - for (pos = 0; pos < bufSize; pos++) - { - status = snprintf( (pPrintBuf + (pos * 3)), - 4, - "%02X ", - *(u8 *)(pBuffer + pos) ); - if (status != 3) - { - DBG( "snprintf error %d\n", status ); - kfree( pPrintBuf ); - return; - } - } - - DBG( " : %s\n", pPrintBuf ); - - kfree( pPrintBuf ); - pPrintBuf = NULL; - return; -} - -/*=========================================================================== -METHOD: - GobiSetDownReason (Public Method) - -DESCRIPTION: - Sets mDownReason and turns carrier off - -PARAMETERS - pDev [ I ] - Device specific memory - reason [ I ] - Reason device is down - -RETURN VALUE: - None -===========================================================================*/ -void QuecGobiSetDownReason( - sGobiUSBNet * pDev, - u8 reason ) -{ - DBG("%s reason=%d, mDownReason=%x\n", __func__, reason, (unsigned)pDev->mDownReason); - -#ifdef QUECTEL_WWAN_QMAP - if (reason == NO_NDIS_CONNECTION) - return; -#endif - - set_bit( reason, &pDev->mDownReason ); - - netif_carrier_off( pDev->mpNetDev->net ); -} - -/*=========================================================================== -METHOD: - GobiClearDownReason (Public Method) - -DESCRIPTION: - Clear mDownReason and may turn carrier on - -PARAMETERS - pDev [ I ] - Device specific memory - reason [ I ] - Reason device is no longer down - -RETURN VALUE: - None -===========================================================================*/ -void QuecGobiClearDownReason( - sGobiUSBNet * pDev, - u8 reason ) -{ - clear_bit( reason, &pDev->mDownReason ); - - DBG("%s reason=%d, mDownReason=%x\n", __func__, reason, (unsigned)pDev->mDownReason); -#if 0 //(LINUX_VERSION_CODE >= KERNEL_VERSION( 3,11,0 )) - netif_carrier_on( pDev->mpNetDev->net ); -#else - if (pDev->mDownReason == 0) - { -#ifdef QUECTEL_WWAN_QMAP - if (pDev->qmap_mode && !pDev->link_state) - ; - else -#endif - netif_carrier_on( pDev->mpNetDev->net ); - } -#endif -} - -/*=========================================================================== -METHOD: - GobiTestDownReason (Public Method) - -DESCRIPTION: - Test mDownReason and returns whether reason is set - -PARAMETERS - pDev [ I ] - Device specific memory - reason [ I ] - Reason device is down - -RETURN VALUE: - bool -===========================================================================*/ -bool QuecGobiTestDownReason( - sGobiUSBNet * pDev, - u8 reason ) -{ - return test_bit( reason, &pDev->mDownReason ); -} - -/*=========================================================================*/ -// Driver level asynchronous read functions -/*=========================================================================*/ - -/*=========================================================================== -METHOD: - ResubmitIntURB (Public Method) - -DESCRIPTION: - Resubmit interrupt URB, re-using same values - -PARAMETERS - pIntURB [ I ] - Interrupt URB - -RETURN VALUE: - int - 0 for success - negative errno for failure -===========================================================================*/ -static int ResubmitIntURB( struct urb * pIntURB ) -{ - int status; - int interval; - - // Sanity test - if ( (pIntURB == NULL) - || (pIntURB->dev == NULL) ) - { - return -EINVAL; - } - - // Interval needs reset after every URB completion -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 2,6,22 )) - interval = max((int)(pIntURB->ep->desc.bInterval), - (pIntURB->dev->speed == USB_SPEED_HIGH) ? 7 : 3); -#else - interval = s_interval; -#endif - - // Reschedule interrupt URB - usb_fill_int_urb( pIntURB, - pIntURB->dev, - pIntURB->pipe, - pIntURB->transfer_buffer, - pIntURB->transfer_buffer_length, - pIntURB->complete, - pIntURB->context, - interval ); - status = usb_submit_urb( pIntURB, GFP_ATOMIC ); - if (status != 0) - { - DBG( "Error re-submitting Int URB %d\n", status ); - } - - return status; -} - - -#ifdef QUECTEL_QMI_MERGE -static int MergeRecQmiMsg( sQMIDev * pQMIDev, struct urb * pReadURB ) -{ - sQMIMsgHeader * mHeader; - sQMIMsgPacket * mPacket; - - DBG( "%s called \n", __func__ ); - mPacket = pQMIDev->mpQmiMsgPacket; - - if(pReadURB->actual_length < sizeof(sQMIMsgHeader)) - { - return -1; - } - - mHeader = (sQMIMsgHeader *)pReadURB->transfer_buffer; - if(le16_to_cpu(mHeader->idenity) != MERGE_PACKET_IDENTITY || le16_to_cpu(mHeader->version) != MERGE_PACKET_VERSION || le16_to_cpu(mHeader->cur_len) > le16_to_cpu(mHeader->total_len)) - return -1; - - if(le16_to_cpu(mHeader->cur_len) == le16_to_cpu(mHeader->total_len)) { - mPacket->len = le16_to_cpu(mHeader->total_len); - memcpy(pReadURB->transfer_buffer, pReadURB->transfer_buffer + sizeof(sQMIMsgHeader), mPacket->len); - pReadURB->actual_length = mPacket->len; - mPacket->len = 0; - - return 0; - } - - memcpy(mPacket->buf + mPacket->len, pReadURB->transfer_buffer + sizeof(sQMIMsgHeader), le16_to_cpu(mHeader->cur_len)); - mPacket->len += le16_to_cpu(mHeader->cur_len); - - if (le16_to_cpu(mHeader->cur_len) < MERGE_PACKET_MAX_PAYLOAD_SIZE || mPacket->len >= le16_to_cpu(mHeader->total_len)) { - memcpy(pReadURB->transfer_buffer, mPacket->buf, mPacket->len); - pReadURB->actual_length = mPacket->len; - mPacket->len = 0; - return 0; - } - - return -1; -} -#endif - -/*=========================================================================== -METHOD: - ReadCallback (Public Method) - -DESCRIPTION: - Put the data in storage and notify anyone waiting for data - -PARAMETERS - pReadURB [ I ] - URB this callback is run for - -RETURN VALUE: - None -===========================================================================*/ -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 2,6,18 )) -static void ReadCallback( struct urb * pReadURB ) -#else -static void ReadCallback(struct urb *pReadURB, struct pt_regs *regs) -#endif -{ - int result; - u16 clientID; - sClientMemList * pClientMem; - void * pData; - void * pDataCopy; - u16 dataSize; - sGobiUSBNet * pDev; - unsigned long flags; - u16 transactionID; - - if (pReadURB == NULL) - { - DBG( "bad read URB\n" ); - return; - } - - pDev = pReadURB->context; - if (IsDeviceValid( pDev ) == false) - { - DBG( "Invalid device!\n" ); - return; - } - -#ifdef READ_QMI_URB_ERROR - del_timer(&pDev->mQMIDev.mReadUrbTimer); - if ((pReadURB->status == -ECONNRESET) && (pReadURB->actual_length > 0)) - pReadURB->status = 0; -#endif - - if (pReadURB->status != 0) - { - DBG( "Read status = %d\n", pReadURB->status ); - - // Resubmit the interrupt URB - ResubmitIntURB( pDev->mQMIDev.mpIntURB ); - - return; - } - DBG( "Read %d bytes\n", pReadURB->actual_length ); - -#ifdef QUECTEL_QMI_MERGE - if(MergeRecQmiMsg(&pDev->mQMIDev, pReadURB)) - { - DBG( "not a full packet, read again\n"); - // Resubmit the interrupt URB - ResubmitIntURB( pDev->mQMIDev.mpIntURB ); - return; - } -#endif - - pData = pReadURB->transfer_buffer; - dataSize = pReadURB->actual_length; - - PrintHex( pData, dataSize ); - -#ifdef READ_QMI_URB_ERROR - if (dataSize < (le16_to_cpu(get_unaligned((u16*)(pData + 1))) + 1)) { - dataSize = (le16_to_cpu(get_unaligned((u16*)(pData + 1))) + 1); - memset(pReadURB->transfer_buffer + pReadURB->actual_length, 0x00, dataSize - pReadURB->actual_length); - INFO( "Read %d / %d bytes\n", pReadURB->actual_length, dataSize); - } -#endif - - result = ParseQMUX( &clientID, - pData, - dataSize ); - if (result < 0) - { - DBG( "Read error parsing QMUX %d\n", result ); - - // Resubmit the interrupt URB - ResubmitIntURB( pDev->mQMIDev.mpIntURB ); - - return; - } - - // Grab transaction ID - - // Data large enough? - if (dataSize < result + 3) - { - DBG( "Data buffer too small to parse\n" ); - - // Resubmit the interrupt URB - ResubmitIntURB( pDev->mQMIDev.mpIntURB ); - - return; - } - - // Transaction ID size is 1 for QMICTL, 2 for others - if (clientID == QMICTL) - { - transactionID = *(u8*)(pData + result + 1); - } - else - { - transactionID = le16_to_cpu( get_unaligned((u16*)(pData + result + 1)) ); - } - - // Critical section - spin_lock_irqsave( &pDev->mQMIDev.mClientMemLock, flags ); - - // Find memory storage for this service and Client ID - // Not using FindClientMem because it can't handle broadcasts - pClientMem = pDev->mQMIDev.mpClientMemList; - - while (pClientMem != NULL) - { - if (pClientMem->mClientID == clientID - || (pClientMem->mClientID | 0xff00) == clientID) - { - // Make copy of pData - pDataCopy = kmalloc( dataSize, GFP_ATOMIC ); - if (pDataCopy == NULL) - { - DBG( "Error allocating client data memory\n" ); - - // End critical section - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - - // Resubmit the interrupt URB - ResubmitIntURB( pDev->mQMIDev.mpIntURB ); - - return; - } - - memcpy( pDataCopy, pData, dataSize ); - - if (AddToReadMemList( pDev, - pClientMem->mClientID, - transactionID, - pDataCopy, - dataSize ) == false) - { - DBG( "Error allocating pReadMemListEntry " - "read will be discarded\n" ); - kfree( pDataCopy ); - - // End critical section - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - - // Resubmit the interrupt URB - ResubmitIntURB( pDev->mQMIDev.mpIntURB ); - - return; - } - - // Success - VDBG( "Creating new readListEntry for client 0x%04X, TID %x\n", - clientID, - transactionID ); - - // Notify this client data exists - NotifyAndPopNotifyList( pDev, - pClientMem->mClientID, - transactionID ); - - // Possibly notify poll() that data exists - wake_up_interruptible_sync( &pClientMem->mWaitQueue ); - - // Not a broadcast - if (clientID >> 8 != 0xff) - { - break; - } - } - - // Next element - pClientMem = pClientMem->mpNext; - } - - // End critical section - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - - // Resubmit the interrupt URB - ResubmitIntURB( pDev->mQMIDev.mpIntURB ); -} - -/*=========================================================================== -METHOD: - IntCallback (Public Method) - -DESCRIPTION: - Data is available, fire off a read URB - -PARAMETERS - pIntURB [ I ] - URB this callback is run for - -RETURN VALUE: - None -===========================================================================*/ -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 2,6,18 )) -static void IntCallback( struct urb * pIntURB ) -{ -#else -static void IntCallback(struct urb *pIntURB, struct pt_regs *regs) -{ -#endif - int status; - struct usb_cdc_notification *dr; - - sGobiUSBNet * pDev = (sGobiUSBNet *)pIntURB->context; - dr = (struct usb_cdc_notification *)pDev->mQMIDev.mpIntBuffer; - - if (IsDeviceValid( pDev ) == false) - { - DBG( "Invalid device!\n" ); - return; - } - - // Verify this was a normal interrupt - if (pIntURB->status != 0) - { - DBG( "IntCallback: Int status = %d\n", pIntURB->status ); - - // Ignore EOVERFLOW errors - if (pIntURB->status != -EOVERFLOW) - { - // Read 'thread' dies here - return; - } - } - else - { - //TODO cast transfer_buffer to struct usb_cdc_notification - - VDBG( "IntCallback: Encapsulated Response = 0x%llx\n", - (*(u64*)pIntURB->transfer_buffer)); - - switch (dr->bNotificationType) { - case USB_CDC_NOTIFY_RESPONSE_AVAILABLE: //0x01 - { - // Time to read - usb_fill_control_urb( pDev->mQMIDev.mpReadURB, - pDev->mpNetDev->udev, - usb_rcvctrlpipe( pDev->mpNetDev->udev, 0 ), - (unsigned char *)pDev->mQMIDev.mpReadSetupPacket, - pDev->mQMIDev.mpReadBuffer, - DEFAULT_READ_URB_LENGTH, - ReadCallback, - pDev ); - #ifdef READ_QMI_URB_ERROR - mod_timer( &pDev->mQMIDev.mReadUrbTimer, jiffies + msecs_to_jiffies(300) ); - #endif - status = usb_submit_urb( pDev->mQMIDev.mpReadURB, GFP_ATOMIC ); - if (status != 0) - { - DBG("Error submitting Read URB %d\n", status); - // Resubmit the interrupt urb - ResubmitIntURB(pIntURB); - return; - } - - // Int URB will be resubmitted during ReadCallback - return; - } - case USB_CDC_NOTIFY_SPEED_CHANGE: //0x2a - { - DBG( "IntCallback: Connection Speed Change = 0x%llx\n", - (*(u64*)pIntURB->transfer_buffer)); - - // if upstream or downstream is 0, stop traffic. Otherwise resume it - if ((*(u32*)(pIntURB->transfer_buffer + 8) == 0) - || (*(u32*)(pIntURB->transfer_buffer + 12) == 0)) - { - GobiSetDownReason( pDev, CDC_CONNECTION_SPEED ); - DBG( "traffic stopping due to CONNECTION_SPEED_CHANGE\n" ); - } - else - { - GobiClearDownReason( pDev, CDC_CONNECTION_SPEED ); - DBG( "resuming traffic due to CONNECTION_SPEED_CHANGE\n" ); - } - } - break; - default: - { - DBG( "ignoring invalid interrupt in packet\n" ); - PrintHex( pIntURB->transfer_buffer, pIntURB->actual_length ); - } - } - - // Resubmit the interrupt urb - ResubmitIntURB( pIntURB ); - - return; - } -} - -#ifdef READ_QMI_URB_ERROR -static void ReadUrbTimerFunc( struct urb * pReadURB ) -{ - int result; - - INFO( "%s called (%ld).\n", __func__, jiffies ); - - if ((pReadURB != NULL) && (pReadURB->status == -EINPROGRESS)) - { - // Asynchronously unlink URB. On success, -EINPROGRESS will be returned, - // URB status will be set to -ECONNRESET, and ReadCallback() executed - result = usb_unlink_urb( pReadURB ); - INFO( "%s called usb_unlink_urb, result = %d\n", __func__, result); - } -} -#endif - -/*=========================================================================== -METHOD: - StartRead (Public Method) - -DESCRIPTION: - Start continuous read "thread" (callback driven) - - Note: In case of error, KillRead() should be run - to remove urbs and clean up memory. - -PARAMETERS: - pDev [ I ] - Device specific memory - -RETURN VALUE: - int - 0 for success - negative errno for failure -===========================================================================*/ -int QuecStartRead( sGobiUSBNet * pDev ) -{ - int interval; - struct usb_endpoint_descriptor *pendp; - - if (IsDeviceValid( pDev ) == false) - { - DBG( "Invalid device!\n" ); - return -ENXIO; - } - - // Allocate URB buffers - pDev->mQMIDev.mpReadURB = usb_alloc_urb( 0, GFP_KERNEL ); - if (pDev->mQMIDev.mpReadURB == NULL) - { - DBG( "Error allocating read urb\n" ); - return -ENOMEM; - } - -#ifdef READ_QMI_URB_ERROR - setup_timer( &pDev->mQMIDev.mReadUrbTimer, (void*)ReadUrbTimerFunc, (unsigned long)pDev->mQMIDev.mpReadURB ); -#endif - - pDev->mQMIDev.mpIntURB = usb_alloc_urb( 0, GFP_KERNEL ); - if (pDev->mQMIDev.mpIntURB == NULL) - { - DBG( "Error allocating int urb\n" ); - usb_free_urb( pDev->mQMIDev.mpReadURB ); - pDev->mQMIDev.mpReadURB = NULL; - return -ENOMEM; - } - - // Create data buffers - pDev->mQMIDev.mpReadBuffer = kmalloc( DEFAULT_READ_URB_LENGTH, GFP_KERNEL ); - if (pDev->mQMIDev.mpReadBuffer == NULL) - { - DBG( "Error allocating read buffer\n" ); - usb_free_urb( pDev->mQMIDev.mpIntURB ); - pDev->mQMIDev.mpIntURB = NULL; - usb_free_urb( pDev->mQMIDev.mpReadURB ); - pDev->mQMIDev.mpReadURB = NULL; - return -ENOMEM; - } - - pDev->mQMIDev.mpIntBuffer = kmalloc( 64, GFP_KERNEL ); - if (pDev->mQMIDev.mpIntBuffer == NULL) - { - DBG( "Error allocating int buffer\n" ); - kfree( pDev->mQMIDev.mpReadBuffer ); - pDev->mQMIDev.mpReadBuffer = NULL; - usb_free_urb( pDev->mQMIDev.mpIntURB ); - pDev->mQMIDev.mpIntURB = NULL; - usb_free_urb( pDev->mQMIDev.mpReadURB ); - pDev->mQMIDev.mpReadURB = NULL; - return -ENOMEM; - } - - pDev->mQMIDev.mpReadSetupPacket = kmalloc( sizeof( sURBSetupPacket ), - GFP_KERNEL ); - if (pDev->mQMIDev.mpReadSetupPacket == NULL) - { - DBG( "Error allocating setup packet buffer\n" ); - kfree( pDev->mQMIDev.mpIntBuffer ); - pDev->mQMIDev.mpIntBuffer = NULL; - kfree( pDev->mQMIDev.mpReadBuffer ); - pDev->mQMIDev.mpReadBuffer = NULL; - usb_free_urb( pDev->mQMIDev.mpIntURB ); - pDev->mQMIDev.mpIntURB = NULL; - usb_free_urb( pDev->mQMIDev.mpReadURB ); - pDev->mQMIDev.mpReadURB = NULL; - return -ENOMEM; - } - - // CDC Get Encapsulated Response packet - pDev->mQMIDev.mpReadSetupPacket->mRequestType = 0xA1; - pDev->mQMIDev.mpReadSetupPacket->mRequestCode = 1; - pDev->mQMIDev.mpReadSetupPacket->mValue = 0; - pDev->mQMIDev.mpReadSetupPacket->mIndex = - cpu_to_le16(pDev->mpIntf->cur_altsetting->desc.bInterfaceNumber); /* interface number */ - pDev->mQMIDev.mpReadSetupPacket->mLength = cpu_to_le16(DEFAULT_READ_URB_LENGTH); - - pendp = GetEndpoint(pDev->mpIntf, USB_ENDPOINT_XFER_INT, USB_DIR_IN); - if (pendp == NULL) - { - DBG( "Invalid interrupt endpoint!\n" ); - kfree(pDev->mQMIDev.mpReadSetupPacket); - pDev->mQMIDev.mpReadSetupPacket = NULL; - kfree( pDev->mQMIDev.mpIntBuffer ); - pDev->mQMIDev.mpIntBuffer = NULL; - kfree( pDev->mQMIDev.mpReadBuffer ); - pDev->mQMIDev.mpReadBuffer = NULL; - usb_free_urb( pDev->mQMIDev.mpIntURB ); - pDev->mQMIDev.mpIntURB = NULL; - usb_free_urb( pDev->mQMIDev.mpReadURB ); - pDev->mQMIDev.mpReadURB = NULL; - return -ENXIO; - } - -#ifdef QUECTEL_QMI_MERGE - pDev->mQMIDev.mpQmiMsgPacket = kmalloc( sizeof(sQMIMsgPacket), GFP_KERNEL ); - if (pDev->mQMIDev.mpQmiMsgPacket == NULL) - { - DBG( "Error allocating qmi msg merge packet buffer!\n" ); - kfree(pDev->mQMIDev.mpReadSetupPacket); - pDev->mQMIDev.mpReadSetupPacket = NULL; - kfree( pDev->mQMIDev.mpIntBuffer ); - pDev->mQMIDev.mpIntBuffer = NULL; - kfree( pDev->mQMIDev.mpReadBuffer ); - pDev->mQMIDev.mpReadBuffer = NULL; - usb_free_urb( pDev->mQMIDev.mpIntURB ); - pDev->mQMIDev.mpIntURB = NULL; - usb_free_urb( pDev->mQMIDev.mpReadURB ); - pDev->mQMIDev.mpReadURB = NULL; - return -ENOMEM; - } -#endif - - // Interval needs reset after every URB completion - interval = max((int)(pendp->bInterval), - (pDev->mpNetDev->udev->speed == USB_SPEED_HIGH) ? 7 : 3); -#if (LINUX_VERSION_CODE <= KERNEL_VERSION( 2,6,22 )) - s_interval = interval; -#endif - - // Schedule interrupt URB - usb_fill_int_urb( pDev->mQMIDev.mpIntURB, - pDev->mpNetDev->udev, - /* QMI interrupt endpoint for the following - * interface configuration: DM, NMEA, MDM, NET - */ - usb_rcvintpipe( pDev->mpNetDev->udev, - pendp->bEndpointAddress), - pDev->mQMIDev.mpIntBuffer, - min((int)le16_to_cpu(pendp->wMaxPacketSize), 64), - IntCallback, - pDev, - interval ); - return usb_submit_urb( pDev->mQMIDev.mpIntURB, GFP_KERNEL ); -} - -/*=========================================================================== -METHOD: - KillRead (Public Method) - -DESCRIPTION: - Kill continuous read "thread" - -PARAMETERS: - pDev [ I ] - Device specific memory - -RETURN VALUE: - None -===========================================================================*/ -void QuecKillRead( sGobiUSBNet * pDev ) -{ - // Stop reading - if (pDev->mQMIDev.mpReadURB != NULL) - { - DBG( "Killng read URB\n" ); - usb_kill_urb( pDev->mQMIDev.mpReadURB ); - } - - if (pDev->mQMIDev.mpIntURB != NULL) - { - DBG( "Killng int URB\n" ); - usb_kill_urb( pDev->mQMIDev.mpIntURB ); - } - - // Release buffers - kfree( pDev->mQMIDev.mpReadSetupPacket ); - pDev->mQMIDev.mpReadSetupPacket = NULL; - kfree( pDev->mQMIDev.mpReadBuffer ); - pDev->mQMIDev.mpReadBuffer = NULL; - kfree( pDev->mQMIDev.mpIntBuffer ); - pDev->mQMIDev.mpIntBuffer = NULL; - - // Release URB's - usb_free_urb( pDev->mQMIDev.mpReadURB ); - pDev->mQMIDev.mpReadURB = NULL; - usb_free_urb( pDev->mQMIDev.mpIntURB ); - pDev->mQMIDev.mpIntURB = NULL; - -#ifdef QUECTEL_QMI_MERGE - kfree( pDev->mQMIDev.mpQmiMsgPacket ); - pDev->mQMIDev.mpQmiMsgPacket = NULL; -#endif -} - -/*=========================================================================*/ -// Internal read/write functions -/*=========================================================================*/ - -/*=========================================================================== -METHOD: - ReadAsync (Public Method) - -DESCRIPTION: - Start asynchronous read - NOTE: Reading client's data store, not device - -PARAMETERS: - pDev [ I ] - Device specific memory - clientID [ I ] - Requester's client ID - transactionID [ I ] - Transaction ID or 0 for any - pCallback [ I ] - Callback to be executed when data is available - pData [ I ] - Data buffer that willl be passed (unmodified) - to callback - -RETURN VALUE: - int - 0 for success - negative errno for failure -===========================================================================*/ -static int ReadAsync( - sGobiUSBNet * pDev, - u16 clientID, - u16 transactionID, - void (*pCallback)(sGobiUSBNet*, u16, void *), - void * pData ) -{ - sClientMemList * pClientMem; - sReadMemList ** ppReadMemList; - - unsigned long flags; - - if (IsDeviceValid( pDev ) == false) - { - DBG( "Invalid device!\n" ); - return -ENXIO; - } - - // Critical section - spin_lock_irqsave( &pDev->mQMIDev.mClientMemLock, flags ); - - // Find memory storage for this client ID - pClientMem = FindClientMem( pDev, clientID ); - if (pClientMem == NULL) - { - DBG( "Could not find matching client ID 0x%04X\n", - clientID ); - - // End critical section - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - return -ENXIO; - } - - ppReadMemList = &(pClientMem->mpList); - - // Does data already exist? - while (*ppReadMemList != NULL) - { - // Is this element our data? - if (transactionID == 0 - || transactionID == (*ppReadMemList)->mTransactionID) - { - // End critical section - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - - // Run our own callback - pCallback( pDev, clientID, pData ); - - return 0; - } - - // Next - ppReadMemList = &(*ppReadMemList)->mpNext; - } - - // Data not found, add ourself to list of waiters - if (AddToNotifyList( pDev, - clientID, - transactionID, - pCallback, - pData ) == false) - { - DBG( "Unable to register for notification\n" ); - } - - // End critical section - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - - // Success - return 0; -} - -/*=========================================================================== -METHOD: - UpSem (Public Method) - -DESCRIPTION: - Notification function for synchronous read - -PARAMETERS: - pDev [ I ] - Device specific memory - clientID [ I ] - Requester's client ID - pData [ I ] - Buffer that holds semaphore to be up()-ed - -RETURN VALUE: - None -===========================================================================*/ -#define QUEC_SEM_MAGIC 0x12345678 -struct QuecSem { - struct semaphore readSem; - int magic; -}; - -static void UpSem( - sGobiUSBNet * pDev, - u16 clientID, - void * pData ) -{ - struct QuecSem *pSem = (struct QuecSem *)pData; - - VDBG( "0x%04X\n", clientID ); - - if (pSem->magic == QUEC_SEM_MAGIC) - up( &(pSem->readSem) ); - else - kfree(pSem); - return; -} - -/*=========================================================================== -METHOD: - ReadSync (Public Method) - -DESCRIPTION: - Start synchronous read - NOTE: Reading client's data store, not device - -PARAMETERS: - pDev [ I ] - Device specific memory - ppOutBuffer [I/O] - On success, will be filled with a - pointer to read buffer - clientID [ I ] - Requester's client ID - transactionID [ I ] - Transaction ID or 0 for any - -RETURN VALUE: - int - size of data read for success - negative errno for failure -===========================================================================*/ -static int ReadSync( - sGobiUSBNet * pDev, - void ** ppOutBuffer, - u16 clientID, - u16 transactionID ) -{ - int result; - sClientMemList * pClientMem; - sNotifyList ** ppNotifyList, * pDelNotifyListEntry; - struct QuecSem readSem; - void * pData; - unsigned long flags; - u16 dataSize; - - if (IsDeviceValid( pDev ) == false) - { - DBG( "Invalid device!\n" ); - return -ENXIO; - } - - // Critical section - spin_lock_irqsave( &pDev->mQMIDev.mClientMemLock, flags ); - - // Find memory storage for this Client ID - pClientMem = FindClientMem( pDev, clientID ); - if (pClientMem == NULL) - { - DBG( "Could not find matching client ID 0x%04X\n", - clientID ); - - // End critical section - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - return -ENXIO; - } - - // Note: in cases where read is interrupted, - // this will verify client is still valid - while (PopFromReadMemList( pDev, - clientID, - transactionID, - &pData, - &dataSize ) == false) - { - // Data does not yet exist, wait - sema_init( &readSem.readSem, 0 ); - readSem.magic = QUEC_SEM_MAGIC; - - // Add ourself to list of waiters - if (AddToNotifyList( pDev, - clientID, - transactionID, - UpSem, - &readSem ) == false) - { - DBG( "unable to register for notification\n" ); - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - return -EFAULT; - } - - // End critical section while we block - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - - // Wait for notification - result = down_interruptible( &readSem.readSem ); - //if (result) INFO("down_interruptible = %d\n", result); - if (result == -EINTR) { - result = down_timeout(&readSem.readSem, msecs_to_jiffies(200)); - //if (result) INFO("down_timeout = %d\n", result); - } - if (result != 0) - { - DBG( "Down Timeout %d\n", result ); - - // readSem will fall out of scope, - // remove from notify list so it's not referenced - spin_lock_irqsave( &pDev->mQMIDev.mClientMemLock, flags ); - ppNotifyList = &(pClientMem->mpReadNotifyList); - pDelNotifyListEntry = NULL; - - // Find and delete matching entry - while (*ppNotifyList != NULL) - { - if ((*ppNotifyList)->mpData == &readSem) - { - pDelNotifyListEntry = *ppNotifyList; - *ppNotifyList = (*ppNotifyList)->mpNext; - kfree( pDelNotifyListEntry ); - break; - } - - // Next - ppNotifyList = &(*ppNotifyList)->mpNext; - } - - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - return -EINTR; - } - - // Verify device is still valid - if (IsDeviceValid( pDev ) == false) - { - DBG( "Invalid device!\n" ); - return -ENXIO; - } - - // Restart critical section and continue loop - spin_lock_irqsave( &pDev->mQMIDev.mClientMemLock, flags ); - } - - // End Critical section - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - - // Success - *ppOutBuffer = pData; - - return dataSize; -} - -/*=========================================================================== -METHOD: - WriteSyncCallback (Public Method) - -DESCRIPTION: - Write callback - -PARAMETERS - pWriteURB [ I ] - URB this callback is run for - -RETURN VALUE: - None -===========================================================================*/ -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 2,6,18 )) -static void WriteSyncCallback( struct urb * pWriteURB ) -#else -static void WriteSyncCallback(struct urb *pWriteURB, struct pt_regs *regs) -#endif -{ - if (pWriteURB == NULL) - { - DBG( "null urb\n" ); - return; - } - - DBG( "Write status/size %d/%d\n", - pWriteURB->status, - pWriteURB->actual_length ); - - // Notify that write has completed by up()-ing semeaphore - up( (struct semaphore * )pWriteURB->context ); - - return; -} - -/*=========================================================================== -METHOD: - WriteSync (Public Method) - -DESCRIPTION: - Start synchronous write - -PARAMETERS: - pDev [ I ] - Device specific memory - pWriteBuffer [ I ] - Data to be written - writeBufferSize [ I ] - Size of data to be written - clientID [ I ] - Client ID of requester - -RETURN VALUE: - int - write size (includes QMUX) - negative errno for failure -===========================================================================*/ -static int WriteSync( - sGobiUSBNet * pDev, - char * pWriteBuffer, - int writeBufferSize, - u16 clientID ) -{ - int result; - struct semaphore writeSem; - struct urb * pWriteURB; - sURBSetupPacket *writeSetup; - unsigned long flags; - - if (IsDeviceValid( pDev ) == false) - { - DBG( "Invalid device!\n" ); - return -ENXIO; - } - - pWriteURB = usb_alloc_urb( 0, GFP_KERNEL ); - if (pWriteURB == NULL) - { - DBG( "URB mem error\n" ); - return -ENOMEM; - } - - // Fill writeBuffer with QMUX - result = FillQMUX( clientID, pWriteBuffer, writeBufferSize ); - if (result < 0) - { - usb_free_urb( pWriteURB ); - return result; - } - - // CDC Send Encapsulated Request packet - writeSetup = kmalloc(sizeof(sURBSetupPacket), GFP_KERNEL); - writeSetup->mRequestType = 0x21; - writeSetup->mRequestCode = 0; - writeSetup->mValue = 0; - writeSetup->mIndex = cpu_to_le16(pDev->mpIntf->cur_altsetting->desc.bInterfaceNumber); - writeSetup->mLength = cpu_to_le16(writeBufferSize); - - // Create URB - usb_fill_control_urb( pWriteURB, - pDev->mpNetDev->udev, - usb_sndctrlpipe( pDev->mpNetDev->udev, 0 ), - (unsigned char *)writeSetup, - (void*)pWriteBuffer, - writeBufferSize, - NULL, - pDev ); - - DBG( "Actual Write:\n" ); - PrintHex( pWriteBuffer, writeBufferSize ); - - sema_init( &writeSem, 0 ); - - pWriteURB->complete = WriteSyncCallback; - pWriteURB->context = &writeSem; - - // Wake device - result = usb_autopm_get_interface( pDev->mpIntf ); - if (result < 0) - { - DBG( "unable to resume interface: %d\n", result ); - - // Likely caused by device going from autosuspend -> full suspend - if (result == -EPERM) - { -#ifdef CONFIG_PM -#if (LINUX_VERSION_CODE < KERNEL_VERSION( 2,6,33 )) -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 2,6,18 )) - pDev->mpNetDev->udev->auto_pm = 0; -#endif -#endif - QuecGobiNetSuspend( pDev->mpIntf, PMSG_SUSPEND ); -#endif /* CONFIG_PM */ - } - usb_free_urb( pWriteURB ); - kfree(writeSetup); - - return result; - } - - // Critical section - spin_lock_irqsave( &pDev->mQMIDev.mClientMemLock, flags ); - - if (AddToURBList( pDev, clientID, pWriteURB ) == false) - { - usb_free_urb( pWriteURB ); - kfree(writeSetup); - - // End critical section - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - usb_autopm_put_interface( pDev->mpIntf ); - return -EINVAL; - } - - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - result = usb_submit_urb( pWriteURB, GFP_KERNEL ); - spin_lock_irqsave( &pDev->mQMIDev.mClientMemLock, flags ); - - if (result < 0) - { - DBG( "submit URB error %d\n", result ); - - // Get URB back so we can destroy it - if (PopFromURBList( pDev, clientID ) != pWriteURB) - { - // This shouldn't happen - DBG( "Didn't get write URB back\n" ); - //advoid ReleaseClientID() free again (no PopFromURBList) - } - else - { - usb_free_urb( pWriteURB ); - kfree(writeSetup); - } - - // End critical section - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - usb_autopm_put_interface( pDev->mpIntf ); - return result; - } - - // End critical section while we block - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - - // Wait for write to finish - if (1 != 0) //(interruptible != 0) - { - // Allow user interrupts - result = down_interruptible( &writeSem ); - //if (result) INFO("down_interruptible = %d\n", result); - if (result == -EINTR) { - result = down_timeout(&writeSem, msecs_to_jiffies(200)); - //if (result) INFO("down_interruptible = %d\n", result); - } - } - else - { - // Ignore user interrupts - result = 0; - down( &writeSem ); - } - - // Write is done, release device - usb_autopm_put_interface( pDev->mpIntf ); - - // Verify device is still valid - if (IsDeviceValid( pDev ) == false) - { - DBG( "Invalid device!\n" ); - - usb_kill_urb( pWriteURB ); -#if 0 //advoid ReleaseClientID() free again (no PopFromURBList) - usb_free_urb( pWriteURB ); - kfree(writeSetup); -#endif - return -ENXIO; - } - - // Restart critical section - spin_lock_irqsave( &pDev->mQMIDev.mClientMemLock, flags ); - - // Get URB back so we can destroy it - if (PopFromURBList( pDev, clientID ) != pWriteURB) - { - // This shouldn't happen - DBG( "Didn't get write URB back\n" ); - - // End critical section - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - usb_kill_urb( pWriteURB ); -#if 0 //advoid ReleaseClientID() free again (fail PopFromURBList) - usb_free_urb( pWriteURB ); - kfree(writeSetup); -#endif - return -EINVAL; - } - - // End critical section - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - - if (result == 0) - { - // Write is finished - if (pWriteURB->status == 0) - { - // Return number of bytes that were supposed to have been written, - // not size of QMI request - result = writeBufferSize; - } - else - { - DBG( "bad status = %d\n", pWriteURB->status ); - - // Return error value - result = pWriteURB->status; - } - } - else - { - // We have been forcibly interrupted - DBG( "Interrupted %d !!!\n", result ); - DBG( "Device may be in bad state and need reset !!!\n" ); - - // URB has not finished - usb_kill_urb( pWriteURB ); - } - - usb_free_urb( pWriteURB ); - kfree(writeSetup); - - return result; -} - -/*=========================================================================*/ -// Internal memory management functions -/*=========================================================================*/ - -/*=========================================================================== -METHOD: - GetClientID (Public Method) - -DESCRIPTION: - Request a QMI client for the input service type and initialize memory - structure - -PARAMETERS: - pDev [ I ] - Device specific memory - serviceType [ I ] - Desired QMI service type - -RETURN VALUE: - int - Client ID for success (positive) - Negative errno for error -===========================================================================*/ -static int GetClientID( - sGobiUSBNet * pDev, - u8 serviceType ) -{ - u16 clientID; - sClientMemList ** ppClientMem; - int result; - void * pWriteBuffer; - u16 writeBufferSize; - void * pReadBuffer; - u16 readBufferSize; - unsigned long flags; - u8 transactionID; - - if (IsDeviceValid( pDev ) == false) - { - DBG( "Invalid device!\n" ); - return -ENXIO; - } - - // Run QMI request to be asigned a Client ID - if (serviceType != 0) - { - writeBufferSize = QMICTLGetClientIDReqSize(); - pWriteBuffer = kmalloc( writeBufferSize, GFP_KERNEL ); - if (pWriteBuffer == NULL) - { - return -ENOMEM; - } - - transactionID = QMIXactionIDGet( pDev ); - - result = QMICTLGetClientIDReq( pWriteBuffer, - writeBufferSize, - transactionID, - serviceType ); - if (result < 0) - { - kfree( pWriteBuffer ); - return result; - } - - - result = WriteSync( pDev, - pWriteBuffer, - writeBufferSize, - QMICTL ); - kfree( pWriteBuffer ); - - if (result < 0) - { - return result; - } - - result = ReadSync( pDev, - &pReadBuffer, - QMICTL, - transactionID ); - if (result < 0) - { - DBG( "bad read data %d\n", result ); - return result; - } - readBufferSize = result; - - result = QMICTLGetClientIDResp( pReadBuffer, - readBufferSize, - &clientID ); - - /* Upon return from QMICTLGetClientIDResp, clientID - * low address contains the Service Number (SN), and - * clientID high address contains Client Number (CN) - * For the ReadCallback to function correctly,we swap - * the SN and CN on a Big Endian architecture. - */ - clientID = le16_to_cpu(clientID); - - kfree( pReadBuffer ); - - if (result < 0) - { - return result; - } - } - else - { - // QMI CTL will always have client ID 0 - clientID = 0; - } - - // Critical section - spin_lock_irqsave( &pDev->mQMIDev.mClientMemLock, flags ); - - // Verify client is not already allocated - if (FindClientMem( pDev, clientID ) != NULL) - { - DBG( "Client memory already exists\n" ); - - // End Critical section - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - return -ETOOMANYREFS; - } - - // Go to last entry in client mem list - ppClientMem = &pDev->mQMIDev.mpClientMemList; - while (*ppClientMem != NULL) - { - ppClientMem = &(*ppClientMem)->mpNext; - } - - // Create locations for read to place data into - *ppClientMem = kmalloc( sizeof( sClientMemList ), GFP_ATOMIC ); - if (*ppClientMem == NULL) - { - DBG( "Error allocating read list\n" ); - - // End critical section - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - return -ENOMEM; - } - - (*ppClientMem)->mClientID = clientID; - (*ppClientMem)->mpList = NULL; - (*ppClientMem)->mpReadNotifyList = NULL; - (*ppClientMem)->mpURBList = NULL; - (*ppClientMem)->mpNext = NULL; - - // Initialize workqueue for poll() - init_waitqueue_head( &(*ppClientMem)->mWaitQueue ); - - // End Critical section - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - - return (int)( (*ppClientMem)->mClientID ); -} - -/*=========================================================================== -METHOD: - ReleaseClientID (Public Method) - -DESCRIPTION: - Release QMI client and free memory - -PARAMETERS: - pDev [ I ] - Device specific memory - clientID [ I ] - Requester's client ID - -RETURN VALUE: - None -===========================================================================*/ -static void ReleaseClientID( - sGobiUSBNet * pDev, - u16 clientID ) -{ - int result; - sClientMemList ** ppDelClientMem; - sClientMemList * pNextClientMem; - struct urb * pDelURB; - void * pDelData; - u16 dataSize; - void * pWriteBuffer; - u16 writeBufferSize; - void * pReadBuffer; - u16 readBufferSize; - unsigned long flags; - u8 transactionID; - - // Is device is still valid? - if (IsDeviceValid( pDev ) == false) - { - DBG( "invalid device\n" ); - return; - } - - DBG( "releasing 0x%04X\n", clientID ); - - // Run QMI ReleaseClientID if this isn't QMICTL - if (clientID != QMICTL && pDev->mpNetDev->udev->state) - { - // Note: all errors are non fatal, as we always want to delete - // client memory in latter part of function - - writeBufferSize = QMICTLReleaseClientIDReqSize(); - pWriteBuffer = kmalloc( writeBufferSize, GFP_KERNEL ); - if (pWriteBuffer == NULL) - { - DBG( "memory error\n" ); - } - else - { - transactionID = QMIXactionIDGet( pDev ); - - result = QMICTLReleaseClientIDReq( pWriteBuffer, - writeBufferSize, - transactionID, - clientID ); - if (result < 0) - { - kfree( pWriteBuffer ); - DBG( "error %d filling req buffer\n", result ); - } - else - { - result = WriteSync( pDev, - pWriteBuffer, - writeBufferSize, - QMICTL ); - kfree( pWriteBuffer ); - - if (result < 0) - { - DBG( "bad write status %d\n", result ); - } - else - { - result = ReadSync( pDev, - &pReadBuffer, - QMICTL, - transactionID ); - if (result < 0) - { - DBG( "bad read status %d\n", result ); - } - else - { - readBufferSize = result; - - result = QMICTLReleaseClientIDResp( pReadBuffer, - readBufferSize ); - kfree( pReadBuffer ); - - if (result < 0) - { - DBG( "error %d parsing response\n", result ); - } - } - } - } - } - } - - // Cleaning up client memory - - // Critical section - spin_lock_irqsave( &pDev->mQMIDev.mClientMemLock, flags ); - - // Can't use FindClientMem, I need to keep pointer of previous - ppDelClientMem = &pDev->mQMIDev.mpClientMemList; - while (*ppDelClientMem != NULL) - { - if ((*ppDelClientMem)->mClientID == clientID) - { - pNextClientMem = (*ppDelClientMem)->mpNext; - - // Notify all clients - while (NotifyAndPopNotifyList( pDev, - clientID, - 0 ) == true ); - - // Kill and free all URB's - pDelURB = PopFromURBList( pDev, clientID ); - while (pDelURB != NULL) - { - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - usb_kill_urb( pDelURB ); - usb_free_urb( pDelURB ); - spin_lock_irqsave( &pDev->mQMIDev.mClientMemLock, flags ); - pDelURB = PopFromURBList( pDev, clientID ); - } - - // Free any unread data - while (PopFromReadMemList( pDev, - clientID, - 0, - &pDelData, - &dataSize ) == true ) - { - kfree( pDelData ); - } - - // Delete client Mem - if (!waitqueue_active( &(*ppDelClientMem)->mWaitQueue)) - kfree( *ppDelClientMem ); - else - INFO("memory leak!\n"); - - // Overwrite the pointer that was to this client mem - *ppDelClientMem = pNextClientMem; - } - else - { - // I now point to (a pointer of ((the node I was at)'s mpNext)) - ppDelClientMem = &(*ppDelClientMem)->mpNext; - } - } - - // End Critical section - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - - return; -} - -/*=========================================================================== -METHOD: - FindClientMem (Public Method) - -DESCRIPTION: - Find this client's memory - - Caller MUST have lock on mClientMemLock - -PARAMETERS: - pDev [ I ] - Device specific memory - clientID [ I ] - Requester's client ID - -RETURN VALUE: - sClientMemList - Pointer to requested sClientMemList for success - NULL for error -===========================================================================*/ -static sClientMemList * FindClientMem( - sGobiUSBNet * pDev, - u16 clientID ) -{ - sClientMemList * pClientMem; - - if (IsDeviceValid( pDev ) == false) - { - DBG( "Invalid device\n" ); - return NULL; - } - -#ifdef CONFIG_SMP - // Verify Lock - if (spin_is_locked( &pDev->mQMIDev.mClientMemLock ) == 0) - { - DBG( "unlocked\n" ); - BUG(); - } -#endif - - pClientMem = pDev->mQMIDev.mpClientMemList; - while (pClientMem != NULL) - { - if (pClientMem->mClientID == clientID) - { - // Success - VDBG("Found client's 0x%x memory\n", clientID); - return pClientMem; - } - - pClientMem = pClientMem->mpNext; - } - - DBG( "Could not find client mem 0x%04X\n", clientID ); - return NULL; -} - -/*=========================================================================== -METHOD: - AddToReadMemList (Public Method) - -DESCRIPTION: - Add Data to this client's ReadMem list - - Caller MUST have lock on mClientMemLock - -PARAMETERS: - pDev [ I ] - Device specific memory - clientID [ I ] - Requester's client ID - transactionID [ I ] - Transaction ID or 0 for any - pData [ I ] - Data to add - dataSize [ I ] - Size of data to add - -RETURN VALUE: - bool -===========================================================================*/ -static bool AddToReadMemList( - sGobiUSBNet * pDev, - u16 clientID, - u16 transactionID, - void * pData, - u16 dataSize ) -{ - sClientMemList * pClientMem; - sReadMemList ** ppThisReadMemList; - -#ifdef CONFIG_SMP - // Verify Lock - if (spin_is_locked( &pDev->mQMIDev.mClientMemLock ) == 0) - { - DBG( "unlocked\n" ); - BUG(); - } -#endif - - // Get this client's memory location - pClientMem = FindClientMem( pDev, clientID ); - if (pClientMem == NULL) - { - DBG( "Could not find this client's memory 0x%04X\n", - clientID ); - - return false; - } - - // Go to last ReadMemList entry - ppThisReadMemList = &pClientMem->mpList; - while (*ppThisReadMemList != NULL) - { - ppThisReadMemList = &(*ppThisReadMemList)->mpNext; - } - - *ppThisReadMemList = kmalloc( sizeof( sReadMemList ), GFP_ATOMIC ); - if (*ppThisReadMemList == NULL) - { - DBG( "Mem error\n" ); - - return false; - } - - (*ppThisReadMemList)->mpNext = NULL; - (*ppThisReadMemList)->mpData = pData; - (*ppThisReadMemList)->mDataSize = dataSize; - (*ppThisReadMemList)->mTransactionID = transactionID; - - return true; -} - -/*=========================================================================== -METHOD: - PopFromReadMemList (Public Method) - -DESCRIPTION: - Remove data from this client's ReadMem list if it matches - the specified transaction ID. - - Caller MUST have lock on mClientMemLock - -PARAMETERS: - pDev [ I ] - Device specific memory - clientID [ I ] - Requester's client ID - transactionID [ I ] - Transaction ID or 0 for any - ppData [I/O] - On success, will be filled with a - pointer to read buffer - pDataSize [I/O] - On succces, will be filled with the - read buffer's size - -RETURN VALUE: - bool -===========================================================================*/ -static bool PopFromReadMemList( - sGobiUSBNet * pDev, - u16 clientID, - u16 transactionID, - void ** ppData, - u16 * pDataSize ) -{ - sClientMemList * pClientMem; - sReadMemList * pDelReadMemList, ** ppReadMemList; - -#ifdef CONFIG_SMP - // Verify Lock - if (spin_is_locked( &pDev->mQMIDev.mClientMemLock ) == 0) - { - DBG( "unlocked\n" ); - BUG(); - } -#endif - - // Get this client's memory location - pClientMem = FindClientMem( pDev, clientID ); - if (pClientMem == NULL) - { - DBG( "Could not find this client's memory 0x%04X\n", - clientID ); - - return false; - } - - ppReadMemList = &(pClientMem->mpList); - pDelReadMemList = NULL; - - // Find first message that matches this transaction ID - while (*ppReadMemList != NULL) - { - // Do we care about transaction ID? - if (transactionID == 0 - || transactionID == (*ppReadMemList)->mTransactionID ) - { - pDelReadMemList = *ppReadMemList; - VDBG( "*ppReadMemList = 0x%p pDelReadMemList = 0x%p\n", - *ppReadMemList, pDelReadMemList ); - break; - } - - VDBG( "skipping 0x%04X data TID = %x\n", clientID, (*ppReadMemList)->mTransactionID ); - - // Next - ppReadMemList = &(*ppReadMemList)->mpNext; - } - VDBG( "*ppReadMemList = 0x%p pDelReadMemList = 0x%p\n", - *ppReadMemList, pDelReadMemList ); - if (pDelReadMemList != NULL) - { - *ppReadMemList = (*ppReadMemList)->mpNext; - - // Copy to output - *ppData = pDelReadMemList->mpData; - *pDataSize = pDelReadMemList->mDataSize; - VDBG( "*ppData = 0x%p pDataSize = %u\n", - *ppData, *pDataSize ); - - // Free memory - kfree( pDelReadMemList ); - - return true; - } - else - { - DBG( "No read memory to pop, Client 0x%04X, TID = %x\n", - clientID, - transactionID ); - return false; - } -} - -/*=========================================================================== -METHOD: - AddToNotifyList (Public Method) - -DESCRIPTION: - Add Notify entry to this client's notify List - - Caller MUST have lock on mClientMemLock - -PARAMETERS: - pDev [ I ] - Device specific memory - clientID [ I ] - Requester's client ID - transactionID [ I ] - Transaction ID or 0 for any - pNotifyFunct [ I ] - Callback function to be run when data is available - pData [ I ] - Data buffer that willl be passed (unmodified) - to callback - -RETURN VALUE: - bool -===========================================================================*/ -static bool AddToNotifyList( - sGobiUSBNet * pDev, - u16 clientID, - u16 transactionID, - void (* pNotifyFunct)(sGobiUSBNet *, u16, void *), - void * pData ) -{ - sClientMemList * pClientMem; - sNotifyList ** ppThisNotifyList; - -#ifdef CONFIG_SMP - // Verify Lock - if (spin_is_locked( &pDev->mQMIDev.mClientMemLock ) == 0) - { - DBG( "unlocked\n" ); - BUG(); - } -#endif - - // Get this client's memory location - pClientMem = FindClientMem( pDev, clientID ); - if (pClientMem == NULL) - { - DBG( "Could not find this client's memory 0x%04X\n", clientID ); - return false; - } - - // Go to last URBList entry - ppThisNotifyList = &pClientMem->mpReadNotifyList; - while (*ppThisNotifyList != NULL) - { - ppThisNotifyList = &(*ppThisNotifyList)->mpNext; - } - - *ppThisNotifyList = kmalloc( sizeof( sNotifyList ), GFP_ATOMIC ); - if (*ppThisNotifyList == NULL) - { - DBG( "Mem error\n" ); - return false; - } - - (*ppThisNotifyList)->mpNext = NULL; - (*ppThisNotifyList)->mpNotifyFunct = pNotifyFunct; - (*ppThisNotifyList)->mpData = pData; - (*ppThisNotifyList)->mTransactionID = transactionID; - - return true; -} - -/*=========================================================================== -METHOD: - NotifyAndPopNotifyList (Public Method) - -DESCRIPTION: - Remove first Notify entry from this client's notify list - and Run function - - Caller MUST have lock on mClientMemLock - -PARAMETERS: - pDev [ I ] - Device specific memory - clientID [ I ] - Requester's client ID - transactionID [ I ] - Transaction ID or 0 for any - -RETURN VALUE: - bool -===========================================================================*/ -static bool NotifyAndPopNotifyList( - sGobiUSBNet * pDev, - u16 clientID, - u16 transactionID ) -{ - sClientMemList * pClientMem; - sNotifyList * pDelNotifyList, ** ppNotifyList; - -#ifdef CONFIG_SMP - // Verify Lock - if (spin_is_locked( &pDev->mQMIDev.mClientMemLock ) == 0) - { - DBG( "unlocked\n" ); - BUG(); - } -#endif - - // Get this client's memory location - pClientMem = FindClientMem( pDev, clientID ); - if (pClientMem == NULL) - { - DBG( "Could not find this client's memory 0x%04X\n", clientID ); - return false; - } - - ppNotifyList = &(pClientMem->mpReadNotifyList); - pDelNotifyList = NULL; - - // Remove from list - while (*ppNotifyList != NULL) - { - // Do we care about transaction ID? - if (transactionID == 0 - || (*ppNotifyList)->mTransactionID == 0 - || transactionID == (*ppNotifyList)->mTransactionID) - { - pDelNotifyList = *ppNotifyList; - break; - } - - DBG( "skipping data TID = %x\n", (*ppNotifyList)->mTransactionID ); - - // next - ppNotifyList = &(*ppNotifyList)->mpNext; - } - - if (pDelNotifyList != NULL) - { - // Remove element - *ppNotifyList = (*ppNotifyList)->mpNext; - - // Run notification function - if (pDelNotifyList->mpNotifyFunct != NULL) - { - // Unlock for callback - spin_unlock( &pDev->mQMIDev.mClientMemLock ); - - pDelNotifyList->mpNotifyFunct( pDev, - clientID, - pDelNotifyList->mpData ); - - // Restore lock - spin_lock( &pDev->mQMIDev.mClientMemLock ); - } - - // Delete memory - kfree( pDelNotifyList ); - - return true; - } - else - { - DBG( "no one to notify for TID %x\n", transactionID ); - - return false; - } -} - -/*=========================================================================== -METHOD: - AddToURBList (Public Method) - -DESCRIPTION: - Add URB to this client's URB list - - Caller MUST have lock on mClientMemLock - -PARAMETERS: - pDev [ I ] - Device specific memory - clientID [ I ] - Requester's client ID - pURB [ I ] - URB to be added - -RETURN VALUE: - bool -===========================================================================*/ -static bool AddToURBList( - sGobiUSBNet * pDev, - u16 clientID, - struct urb * pURB ) -{ - sClientMemList * pClientMem; - sURBList ** ppThisURBList; - -#ifdef CONFIG_SMP - // Verify Lock - if (spin_is_locked( &pDev->mQMIDev.mClientMemLock ) == 0) - { - DBG( "unlocked\n" ); - BUG(); - } -#endif - - // Get this client's memory location - pClientMem = FindClientMem( pDev, clientID ); - if (pClientMem == NULL) - { - DBG( "Could not find this client's memory 0x%04X\n", clientID ); - return false; - } - - // Go to last URBList entry - ppThisURBList = &pClientMem->mpURBList; - while (*ppThisURBList != NULL) - { - ppThisURBList = &(*ppThisURBList)->mpNext; - } - - *ppThisURBList = kmalloc( sizeof( sURBList ), GFP_ATOMIC ); - if (*ppThisURBList == NULL) - { - DBG( "Mem error\n" ); - return false; - } - - (*ppThisURBList)->mpNext = NULL; - (*ppThisURBList)->mpURB = pURB; - - return true; -} - -/*=========================================================================== -METHOD: - PopFromURBList (Public Method) - -DESCRIPTION: - Remove URB from this client's URB list - - Caller MUST have lock on mClientMemLock - -PARAMETERS: - pDev [ I ] - Device specific memory - clientID [ I ] - Requester's client ID - -RETURN VALUE: - struct urb - Pointer to requested client's URB - NULL for error -===========================================================================*/ -static struct urb * PopFromURBList( - sGobiUSBNet * pDev, - u16 clientID ) -{ - sClientMemList * pClientMem; - sURBList * pDelURBList; - struct urb * pURB; - -#ifdef CONFIG_SMP - // Verify Lock - if (spin_is_locked( &pDev->mQMIDev.mClientMemLock ) == 0) - { - DBG( "unlocked\n" ); - BUG(); - } -#endif - - // Get this client's memory location - pClientMem = FindClientMem( pDev, clientID ); - if (pClientMem == NULL) - { - DBG( "Could not find this client's memory 0x%04X\n", clientID ); - return NULL; - } - - // Remove from list - if (pClientMem->mpURBList != NULL) - { - pDelURBList = pClientMem->mpURBList; - pClientMem->mpURBList = pClientMem->mpURBList->mpNext; - - // Copy to output - pURB = pDelURBList->mpURB; - - // Delete memory - kfree( pDelURBList ); - - return pURB; - } - else - { - DBG( "No URB's to pop\n" ); - - return NULL; - } -} - -#if (LINUX_VERSION_CODE >= KERNEL_VERSION( 3,19,0 )) -#ifndef f_dentry -#define f_dentry f_path.dentry -#endif -#endif - -/*=========================================================================*/ -// Internal userspace wrappers -/*=========================================================================*/ - -/*=========================================================================== -METHOD: - UserspaceunlockedIOCTL (Public Method) - -DESCRIPTION: - Internal wrapper for Userspace IOCTL interface - -PARAMETERS - pFilp [ I ] - userspace file descriptor - cmd [ I ] - IOCTL command - arg [ I ] - IOCTL argument - -RETURN VALUE: - long - 0 for success - Negative errno for failure -===========================================================================*/ -static long UserspaceunlockedIOCTL( - struct file * pFilp, - unsigned int cmd, - unsigned long arg ) -{ - int result; - u32 devVIDPID; - - sQMIFilpStorage * pFilpData = (sQMIFilpStorage *)pFilp->private_data; - - if (pFilpData == NULL) - { - DBG( "Bad file data\n" ); - return -EBADF; - } - - if (IsDeviceValid( pFilpData->mpDev ) == false) - { - DBG( "Invalid device! Updating f_ops\n" ); - pFilp->f_op = pFilp->f_dentry->d_inode->i_fop; - return -ENXIO; - } - - switch (cmd) - { - case IOCTL_QMI_GET_SERVICE_FILE: - DBG( "Setting up QMI for service %lu\n", arg ); - if ((u8)arg == 0) - { - DBG( "Cannot use QMICTL from userspace\n" ); - return -EINVAL; - } - - // Connection is already setup - if (pFilpData->mClientID != (u16)-1) - { - DBG( "Close the current connection before opening a new one\n" ); - return -EBADR; - } - - result = GetClientID( pFilpData->mpDev, (u8)arg ); -// it seems QMIWDA only allow one client, if the last quectel-CM donot realese it (killed by SIGKILL). -// can force release it at here -#if 1 - if (result < 0 && (u8)arg == QMIWDA) - { - ReleaseClientID( pFilpData->mpDev, QMIWDA | (1 << 8) ); - result = GetClientID( pFilpData->mpDev, (u8)arg ); - } -#endif - if (result < 0) - { - return result; - } - pFilpData->mClientID = (u16)result; - DBG("pFilpData->mClientID = 0x%x\n", pFilpData->mClientID ); - return 0; - break; - - - case IOCTL_QMI_GET_DEVICE_VIDPID: - if (arg == 0) - { - DBG( "Bad VIDPID buffer\n" ); - return -EINVAL; - } - - // Extra verification - if (pFilpData->mpDev->mpNetDev == 0) - { - DBG( "Bad mpNetDev\n" ); - return -ENOMEM; - } - if (pFilpData->mpDev->mpNetDev->udev == 0) - { - DBG( "Bad udev\n" ); - return -ENOMEM; - } - - devVIDPID = ((le16_to_cpu( pFilpData->mpDev->mpNetDev->udev->descriptor.idVendor ) << 16) - + le16_to_cpu( pFilpData->mpDev->mpNetDev->udev->descriptor.idProduct ) ); - - result = copy_to_user( (unsigned int *)arg, &devVIDPID, 4 ); - if (result != 0) - { - DBG( "Copy to userspace failure %d\n", result ); - } - - return result; - - break; - - case IOCTL_QMI_GET_DEVICE_MEID: - if (arg == 0) - { - DBG( "Bad MEID buffer\n" ); - return -EINVAL; - } - - result = copy_to_user( (unsigned int *)arg, &pFilpData->mpDev->mMEID[0], 14 ); - if (result != 0) - { - DBG( "Copy to userspace failure %d\n", result ); - } - - return result; - - break; - - default: - return -EBADRQC; - } -} - -/*=========================================================================*/ -// Userspace wrappers -/*=========================================================================*/ - -/*=========================================================================== -METHOD: - UserspaceOpen (Public Method) - -DESCRIPTION: - Userspace open - IOCTL must be called before reads or writes - -PARAMETERS - pInode [ I ] - kernel file descriptor - pFilp [ I ] - userspace file descriptor - -RETURN VALUE: - int - 0 for success - Negative errno for failure -===========================================================================*/ -static int UserspaceOpen( - struct inode * pInode, - struct file * pFilp ) -{ - sQMIFilpStorage * pFilpData; - - // Optain device pointer from pInode - sQMIDev * pQMIDev = container_of( pInode->i_cdev, - sQMIDev, - mCdev ); - sGobiUSBNet * pDev = container_of( pQMIDev, - sGobiUSBNet, - mQMIDev ); - - if (pDev->mbMdm9x07) - { - atomic_inc(&pDev->refcount); - if (!pDev->mbQMIReady) { - if (wait_for_completion_interruptible_timeout(&pDev->mQMIReadyCompletion, 15*HZ) <= 0) { - if (atomic_dec_and_test(&pDev->refcount)) { - kfree( pDev ); - } - return -ETIMEDOUT; - } - } - atomic_dec(&pDev->refcount); - } - - if (IsDeviceValid( pDev ) == false) - { - DBG( "Invalid device\n" ); - return -ENXIO; - } - - // Setup data in pFilp->private_data - pFilp->private_data = kmalloc( sizeof( sQMIFilpStorage ), GFP_KERNEL ); - if (pFilp->private_data == NULL) - { - DBG( "Mem error\n" ); - return -ENOMEM; - } - - pFilpData = (sQMIFilpStorage *)pFilp->private_data; - pFilpData->mClientID = (u16)-1; - pFilpData->mpDev = pDev; - atomic_inc(&pFilpData->mpDev->refcount); - - return 0; -} - -/*=========================================================================== -METHOD: - UserspaceIOCTL (Public Method) - -DESCRIPTION: - Userspace IOCTL functions - -PARAMETERS - pUnusedInode [ I ] - (unused) kernel file descriptor - pFilp [ I ] - userspace file descriptor - cmd [ I ] - IOCTL command - arg [ I ] - IOCTL argument - -RETURN VALUE: - int - 0 for success - Negative errno for failure -===========================================================================*/ -#if (LINUX_VERSION_CODE < KERNEL_VERSION( 2,6,36 )) -static int UserspaceIOCTL( - struct inode * pUnusedInode, - struct file * pFilp, - unsigned int cmd, - unsigned long arg ) -{ - // call the internal wrapper function - return (int)UserspaceunlockedIOCTL( pFilp, cmd, arg ); -} -#endif - -#ifdef quectel_no_for_each_process -static int UserspaceClose( - struct inode * pInode, - struct file * pFilp ) -{ - sQMIFilpStorage * pFilpData = (sQMIFilpStorage *)pFilp->private_data; - - if (pFilpData == NULL) - { - DBG( "bad file data\n" ); - return -EBADF; - } - - atomic_dec(&pFilpData->mpDev->refcount); - - if (IsDeviceValid( pFilpData->mpDev ) == false) - { - return -ENXIO; - } - - DBG( "0x%04X\n", pFilpData->mClientID ); - - // Disable pFilpData so they can't keep sending read or write - // should this function hang - // Note: memory pointer is still saved in pFilpData to be deleted later - pFilp->private_data = NULL; - - if (pFilpData->mClientID != (u16)-1) - { - if (pFilpData->mpDev->mbDeregisterQMIDevice) - pFilpData->mClientID = (u16)-1; //DeregisterQMIDevice() will release this ClientID - else - ReleaseClientID( pFilpData->mpDev, - pFilpData->mClientID ); - } - - kfree( pFilpData ); - return 0; -} -#else -/*=========================================================================== -METHOD: - UserspaceClose (Public Method) - -DESCRIPTION: - Userspace close - Release client ID and free memory - -PARAMETERS - pFilp [ I ] - userspace file descriptor - unusedFileTable [ I ] - (unused) file table - -RETURN VALUE: - int - 0 for success - Negative errno for failure -===========================================================================*/ -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 2,6,14 )) -int UserspaceClose( - struct file * pFilp, - fl_owner_t unusedFileTable ) -#else -int UserspaceClose( struct file * pFilp ) -#endif -{ - sQMIFilpStorage * pFilpData = (sQMIFilpStorage *)pFilp->private_data; - struct task_struct * pEachTask; - struct fdtable * pFDT; - int count = 0; - int used = 0; - unsigned long flags; - - if (pFilpData == NULL) - { - DBG( "bad file data\n" ); - return -EBADF; - } - - // Fallthough. If f_count == 1 no need to do more checks -#if (LINUX_VERSION_CODE <= KERNEL_VERSION( 2,6,24 )) - if (atomic_read( &pFilp->f_count ) != 1) -#else - if (atomic_long_read( &pFilp->f_count ) != 1) -#endif - { - rcu_read_lock(); - for_each_process( pEachTask ) - { - task_lock(pEachTask); - if (pEachTask == NULL || pEachTask->files == NULL) - { - // Some tasks may not have files (e.g. Xsession) - task_unlock(pEachTask); - continue; - } - spin_lock_irqsave( &pEachTask->files->file_lock, flags ); - task_unlock(pEachTask); //kernel/exit.c:do_exit() -> fs/file.c:exit_files() - pFDT = files_fdtable( pEachTask->files ); - for (count = 0; count < pFDT->max_fds; count++) - { - // Before this function was called, this file was removed - // from our task's file table so if we find it in a file - // table then it is being used by another task - if (pFDT->fd[count] == pFilp) - { - used++; - break; - } - } - spin_unlock_irqrestore( &pEachTask->files->file_lock, flags ); - } - rcu_read_unlock(); - - if (used > 0) - { - DBG( "not closing, as this FD is open by %d other process\n", used ); - return 0; - } - } - - if (IsDeviceValid( pFilpData->mpDev ) == false) - { - DBG( "Invalid device! Updating f_ops\n" ); - pFilp->f_op = pFilp->f_dentry->d_inode->i_fop; - return -ENXIO; - } - - DBG( "0x%04X\n", pFilpData->mClientID ); - - // Disable pFilpData so they can't keep sending read or write - // should this function hang - // Note: memory pointer is still saved in pFilpData to be deleted later - pFilp->private_data = NULL; - - if (pFilpData->mClientID != (u16)-1) - { - if (pFilpData->mpDev->mbDeregisterQMIDevice) - pFilpData->mClientID = (u16)-1; //DeregisterQMIDevice() will release this ClientID - else - ReleaseClientID( pFilpData->mpDev, - pFilpData->mClientID ); - } - atomic_dec(&pFilpData->mpDev->refcount); - - kfree( pFilpData ); - return 0; -} -#endif - -/*=========================================================================== -METHOD: - UserspaceRead (Public Method) - -DESCRIPTION: - Userspace read (synchronous) - -PARAMETERS - pFilp [ I ] - userspace file descriptor - pBuf [ I ] - read buffer - size [ I ] - size of read buffer - pUnusedFpos [ I ] - (unused) file position - -RETURN VALUE: - ssize_t - Number of bytes read for success - Negative errno for failure -===========================================================================*/ -static ssize_t UserspaceRead( - struct file * pFilp, - char __user * pBuf, - size_t size, - loff_t * pUnusedFpos ) -{ - int result; - void * pReadData = NULL; - void * pSmallReadData; - sQMIFilpStorage * pFilpData = (sQMIFilpStorage *)pFilp->private_data; - - if (pFilpData == NULL) - { - DBG( "Bad file data\n" ); - return -EBADF; - } - - if (IsDeviceValid( pFilpData->mpDev ) == false) - { - DBG( "Invalid device! Updating f_ops\n" ); - pFilp->f_op = pFilp->f_dentry->d_inode->i_fop; - return -ENXIO; - } - - if (pFilpData->mClientID == (u16)-1) - { - DBG( "Client ID must be set before reading 0x%04X\n", - pFilpData->mClientID ); - return -EBADR; - } - - // Perform synchronous read - result = ReadSync( pFilpData->mpDev, - &pReadData, - pFilpData->mClientID, - 0 ); - if (result <= 0) - { - return result; - } - - // Discard QMUX header - result -= QMUXHeaderSize(); - pSmallReadData = pReadData + QMUXHeaderSize(); - - if (result > size) - { - DBG( "Read data is too large for amount user has requested\n" ); - kfree( pReadData ); - return -EOVERFLOW; - } - - DBG( "pBuf = 0x%p pSmallReadData = 0x%p, result = %d", - pBuf, pSmallReadData, result ); - - if (copy_to_user( pBuf, pSmallReadData, result ) != 0) - { - DBG( "Error copying read data to user\n" ); - result = -EFAULT; - } - - // Reader is responsible for freeing read buffer - kfree( pReadData ); - - return result; -} - -/*=========================================================================== -METHOD: - UserspaceWrite (Public Method) - -DESCRIPTION: - Userspace write (synchronous) - -PARAMETERS - pFilp [ I ] - userspace file descriptor - pBuf [ I ] - write buffer - size [ I ] - size of write buffer - pUnusedFpos [ I ] - (unused) file position - -RETURN VALUE: - ssize_t - Number of bytes read for success - Negative errno for failure -===========================================================================*/ -static ssize_t UserspaceWrite( - struct file * pFilp, - const char __user * pBuf, - size_t size, - loff_t * pUnusedFpos ) -{ - int status; - void * pWriteBuffer; - sQMIFilpStorage * pFilpData = (sQMIFilpStorage *)pFilp->private_data; - - if (pFilpData == NULL) - { - DBG( "Bad file data\n" ); - return -EBADF; - } - - if (IsDeviceValid( pFilpData->mpDev ) == false) - { - DBG( "Invalid device! Updating f_ops\n" ); - pFilp->f_op = pFilp->f_dentry->d_inode->i_fop; - return -ENXIO; - } - - if (pFilpData->mClientID == (u16)-1) - { - DBG( "Client ID must be set before writing 0x%04X\n", - pFilpData->mClientID ); - return -EBADR; - } - - // Copy data from user to kernel space - pWriteBuffer = kmalloc( size + QMUXHeaderSize(), GFP_KERNEL ); - if (pWriteBuffer == NULL) - { - return -ENOMEM; - } - status = copy_from_user( pWriteBuffer + QMUXHeaderSize(), pBuf, size ); - if (status != 0) - { - DBG( "Unable to copy data from userspace %d\n", status ); - kfree( pWriteBuffer ); - return status; - } - - status = WriteSync( pFilpData->mpDev, - pWriteBuffer, - size + QMUXHeaderSize(), - pFilpData->mClientID ); - - kfree( pWriteBuffer ); - - // On success, return requested size, not full QMI reqest size - if (status == size + QMUXHeaderSize()) - { - return size; - } - else - { - return status; - } -} - -/*=========================================================================== -METHOD: - UserspacePoll (Public Method) - -DESCRIPTION: - Used to determine if read/write operations are possible without blocking - -PARAMETERS - pFilp [ I ] - userspace file descriptor - pPollTable [I/O] - Wait object to notify the kernel when data - is ready - -RETURN VALUE: - unsigned int - bitmask of what operations can be done immediately -===========================================================================*/ -static unsigned int UserspacePoll( - struct file * pFilp, - struct poll_table_struct * pPollTable ) -{ - sQMIFilpStorage * pFilpData = (sQMIFilpStorage *)pFilp->private_data; - sClientMemList * pClientMem; - unsigned long flags; - - // Always ready to write - unsigned long status = POLLOUT | POLLWRNORM; - - if (pFilpData == NULL) - { - DBG( "Bad file data\n" ); - return POLLERR; - } - - if (IsDeviceValid( pFilpData->mpDev ) == false) - { - DBG( "Invalid device! Updating f_ops\n" ); - pFilp->f_op = pFilp->f_dentry->d_inode->i_fop; - return POLLERR; - } - - if (pFilpData->mpDev->mbDeregisterQMIDevice) - { - DBG( "DeregisterQMIDevice ing\n" ); - return POLLHUP | POLLERR; - } - - if (pFilpData->mClientID == (u16)-1) - { - DBG( "Client ID must be set before polling 0x%04X\n", - pFilpData->mClientID ); - return POLLERR; - } - - // Critical section - spin_lock_irqsave( &pFilpData->mpDev->mQMIDev.mClientMemLock, flags ); - - // Get this client's memory location - pClientMem = FindClientMem( pFilpData->mpDev, - pFilpData->mClientID ); - if (pClientMem == NULL) - { - DBG( "Could not find this client's memory 0x%04X\n", - pFilpData->mClientID ); - - spin_unlock_irqrestore( &pFilpData->mpDev->mQMIDev.mClientMemLock, - flags ); - return POLLERR; - } - - poll_wait( pFilp, &pClientMem->mWaitQueue, pPollTable ); - - if (pClientMem->mpList != NULL) - { - status |= POLLIN | POLLRDNORM; - } - - // End critical section - spin_unlock_irqrestore( &pFilpData->mpDev->mQMIDev.mClientMemLock, flags ); - - // Always ready to write - return (status | POLLOUT | POLLWRNORM); -} - -/*=========================================================================*/ -// Initializer and destructor -/*=========================================================================*/ -static int QMICTLSyncProc(sGobiUSBNet *pDev) -{ - void *pWriteBuffer; - void *pReadBuffer; - int result; - u16 writeBufferSize; - u16 readBufferSize; - u8 transactionID; - unsigned long flags; - - if (IsDeviceValid( pDev ) == false) - { - DBG( "Invalid device\n" ); - return -EFAULT; - } - - writeBufferSize= QMICTLSyncReqSize(); - pWriteBuffer = kmalloc( writeBufferSize, GFP_KERNEL ); - if (pWriteBuffer == NULL) - { - return -ENOMEM; - } - - transactionID = QMIXactionIDGet(pDev); - - /* send a QMI_CTL_SYNC_REQ (0x0027) */ - result = QMICTLSyncReq( pWriteBuffer, - writeBufferSize, - transactionID ); - if (result < 0) - { - kfree( pWriteBuffer ); - return result; - } - - result = WriteSync( pDev, - pWriteBuffer, - writeBufferSize, - QMICTL ); - - if (result < 0) - { - kfree( pWriteBuffer ); - return result; - } - - // QMI CTL Sync Response - result = ReadSync( pDev, - &pReadBuffer, - QMICTL, - transactionID ); - if (result < 0) - { - return result; - } - - result = QMICTLSyncResp( pReadBuffer, - (u16)result ); - - kfree( pReadBuffer ); - - if (result < 0) /* need to re-sync */ - { - DBG( "sync response error code %d\n", result ); - /* start timer and wait for the response */ - /* process response */ - return result; - } - -#if 1 //free these ununsed qmi response, or when these transactionID re-used, they will be regarded as qmi response of the qmi request that have same transactionID - // Enter critical section - spin_lock_irqsave( &pDev->mQMIDev.mClientMemLock, flags ); - - // Free any unread data - while (PopFromReadMemList( pDev, QMICTL, 0, &pReadBuffer, &readBufferSize) == true) { - kfree( pReadBuffer ); - } - - // End critical section - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); -#endif - - // Success - return 0; -} - -static int qmi_sync_thread(void *data) { - sGobiUSBNet * pDev = (sGobiUSBNet *)data; - int result = 0; - -#if 1 - // Device is not ready for QMI connections right away - // Wait up to 30 seconds before failing - if (QMIReady( pDev, 30000 ) == false) - { - DBG( "Device unresponsive to QMI\n" ); - goto __qmi_sync_finished; - } - - // Initiate QMI CTL Sync Procedure - DBG( "Sending QMI CTL Sync Request\n" ); - result = QMICTLSyncProc(pDev); - if (result != 0) - { - DBG( "QMI CTL Sync Procedure Error\n" ); - goto __qmi_sync_finished; - } - else - { - DBG( "QMI CTL Sync Procedure Successful\n" ); - } - -#if defined(QUECTEL_WWAN_QMAP) -if (pDev->qmap_mode) { - // Setup Data Format - result = QMIWDASetDataFormat (pDev, pDev->qmap_mode, &pDev->qmap_size); - if (result != 0) - { - goto __qmi_sync_finished; - } - pDev->mpNetDev->rx_urb_size = pDev->qmap_size; -} -#endif - - // Setup WDS callback - result = SetupQMIWDSCallback( pDev ); - if (result != 0) - { - goto __qmi_sync_finished; - } - - // Fill MEID for device - result = QMIDMSGetMEID( pDev ); - if (result != 0) - { - goto __qmi_sync_finished; - } -#endif - -__qmi_sync_finished: - pDev->mbQMIReady = true; - complete_all(&pDev->mQMIReadyCompletion); - pDev->mbQMISyncIng = false; - if (atomic_dec_and_test(&pDev->refcount)) { - kfree( pDev ); - } - return result; -} - -/*=========================================================================== -METHOD: - RegisterQMIDevice (Public Method) - -DESCRIPTION: - QMI Device initialization function - -PARAMETERS: - pDev [ I ] - Device specific memory - -RETURN VALUE: - int - 0 for success - Negative errno for failure -===========================================================================*/ -int RegisterQMIDevice( sGobiUSBNet * pDev ) -{ - int result; - int GobiQMIIndex = 0; - dev_t devno; - char * pDevName; - - if (pDev->mQMIDev.mbCdevIsInitialized == true) - { - // Should never happen, but always better to check - DBG( "device already exists\n" ); - return -EEXIST; - } - - pDev->mbQMIValid = true; - pDev->mbDeregisterQMIDevice = false; - - // Set up for QMICTL - // (does not send QMI message, just sets up memory) - result = GetClientID( pDev, QMICTL ); - if (result != 0) - { - pDev->mbQMIValid = false; - return result; - } - atomic_set( &pDev->mQMIDev.mQMICTLTransactionID, 1 ); - - // Start Async reading - result = StartRead( pDev ); - if (result != 0) - { - pDev->mbQMIValid = false; - return result; - } - - if (pDev->mbMdm9x07) - { - usb_control_msg( pDev->mpNetDev->udev, - usb_sndctrlpipe( pDev->mpNetDev->udev, 0 ), - SET_CONTROL_LINE_STATE_REQUEST, - SET_CONTROL_LINE_STATE_REQUEST_TYPE, - CONTROL_DTR, - /* USB interface number to receive control message */ - pDev->mpIntf->cur_altsetting->desc.bInterfaceNumber, - NULL, - 0, - 100 ); - } - - //for EC21&25, must wait about 15 seconds to wait QMI ready. it is too long for driver probe(will block other drivers probe). - if (pDev->mbMdm9x07) - { - struct task_struct *qmi_sync_task; - atomic_inc(&pDev->refcount); - init_completion(&pDev->mQMIReadyCompletion); - pDev->mbQMIReady = false; - pDev->mbQMISyncIng = true; - qmi_sync_task = kthread_run(qmi_sync_thread, (void *)pDev, "qmi_sync/%d", pDev->mpNetDev->udev->devnum); - if (IS_ERR(qmi_sync_task)) { - pDev->mbQMISyncIng = false; - atomic_dec(&pDev->refcount); - DBG( "Create qmi_sync_thread fail\n" ); - return PTR_ERR(qmi_sync_task); - } - goto __register_chardev_qccmi; - } - - // Device is not ready for QMI connections right away - // Wait up to 30 seconds before failing - if (QMIReady( pDev, 30000 ) == false) - { - DBG( "Device unresponsive to QMI\n" ); - return -ETIMEDOUT; - } - - // Initiate QMI CTL Sync Procedure - DBG( "Sending QMI CTL Sync Request\n" ); - result = QMICTLSyncProc(pDev); - if (result != 0) - { - DBG( "QMI CTL Sync Procedure Error\n" ); - return result; - } - else - { - DBG( "QMI CTL Sync Procedure Successful\n" ); - } - - // Setup Data Format -#if defined(QUECTEL_WWAN_QMAP) - result = QMIWDASetDataFormat (pDev, pDev->qmap_mode, NULL); -#else - result = QMIWDASetDataFormat (pDev, 0, NULL); -#endif - if (result != 0) - { - return result; - } - - // Setup WDS callback - result = SetupQMIWDSCallback( pDev ); - if (result != 0) - { - return result; - } - - // Fill MEID for device - result = QMIDMSGetMEID( pDev ); - if (result != 0) - { - return result; - } - -__register_chardev_qccmi: - // allocate and fill devno with numbers - result = alloc_chrdev_region( &devno, 0, 1, "qcqmi" ); - if (result < 0) - { - return result; - } - - // Create cdev - cdev_init( &pDev->mQMIDev.mCdev, &UserspaceQMIFops ); - pDev->mQMIDev.mCdev.owner = THIS_MODULE; - pDev->mQMIDev.mCdev.ops = &UserspaceQMIFops; - pDev->mQMIDev.mbCdevIsInitialized = true; - - result = cdev_add( &pDev->mQMIDev.mCdev, devno, 1 ); - if (result != 0) - { - DBG( "error adding cdev\n" ); - return result; - } - - // Match interface number (usb# or eth#) - if (!!(pDevName = strstr( pDev->mpNetDev->net->name, "eth" ))) { - pDevName += strlen( "eth" ); - } else if (!!(pDevName = strstr( pDev->mpNetDev->net->name, "usb" ))) { - pDevName += strlen( "usb" ); -#if 1 //openWRT like use ppp# or lte# - } else if (!!(pDevName = strstr( pDev->mpNetDev->net->name, "ppp" ))) { - pDevName += strlen( "ppp" ); - } else if (!!(pDevName = strstr( pDev->mpNetDev->net->name, "lte" ))) { - pDevName += strlen( "lte" ); -#endif - } else { - DBG( "Bad net name: %s\n", pDev->mpNetDev->net->name ); - return -ENXIO; - } - GobiQMIIndex = simple_strtoul( pDevName, NULL, 10 ); - if (GobiQMIIndex < 0) - { - DBG( "Bad minor number\n" ); - return -ENXIO; - } - - // Always print this output - printk( KERN_INFO "creating qcqmi%d\n", - GobiQMIIndex ); - -#if (LINUX_VERSION_CODE >= KERNEL_VERSION( 2,6,27 )) - // kernel 2.6.27 added a new fourth parameter to device_create - // void * drvdata : the data to be added to the device for callbacks - device_create( pDev->mQMIDev.mpDevClass, - &pDev->mpIntf->dev, - devno, - NULL, - "qcqmi%d", - GobiQMIIndex ); -#else - device_create( pDev->mQMIDev.mpDevClass, - &pDev->mpIntf->dev, - devno, - "qcqmi%d", - GobiQMIIndex ); -#endif - - pDev->mQMIDev.mDevNum = devno; - - // Success - return 0; -} - -/*=========================================================================== -METHOD: - DeregisterQMIDevice (Public Method) - -DESCRIPTION: - QMI Device cleanup function - - NOTE: When this function is run the device is no longer valid - -PARAMETERS: - pDev [ I ] - Device specific memory - -RETURN VALUE: - None -===========================================================================*/ -void DeregisterQMIDevice( sGobiUSBNet * pDev ) -{ -#ifndef quectel_no_for_each_process - struct inode * pOpenInode; - struct list_head * pInodeList; - struct task_struct * pEachTask; - struct fdtable * pFDT; - struct file * pFilp; - int count = 0; -#endif - unsigned long flags; - int tries; - int result; - - // Should never happen, but check anyway - if (IsDeviceValid( pDev ) == false) - { - DBG( "wrong device\n" ); - return; - } - - pDev->mbDeregisterQMIDevice = true; - - for (tries = 0; tries < 3000; tries += 10) { - if (pDev->mbQMISyncIng == false) - break; - msleep(10); - } - - if (pDev->mbQMISyncIng) { - DBG( "QMI sync ing\n" ); - } - - // Release all clients - spin_lock_irqsave( &pDev->mQMIDev.mClientMemLock, flags ); - while (pDev->mQMIDev.mpClientMemList != NULL) - { - u16 mClientID = pDev->mQMIDev.mpClientMemList->mClientID; - if (waitqueue_active(&pDev->mQMIDev.mpClientMemList->mWaitQueue)) { - DBG("WaitQueue 0x%04X\n", mClientID); - wake_up_interruptible_sync( &pDev->mQMIDev.mpClientMemList->mWaitQueue ); - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - msleep(10); - spin_lock_irqsave( &pDev->mQMIDev.mClientMemLock, flags ); - continue; - } - - DBG( "release 0x%04X\n", pDev->mQMIDev.mpClientMemList->mClientID ); - - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - ReleaseClientID( pDev, mClientID ); - // NOTE: pDev->mQMIDev.mpClientMemList will - // be updated in ReleaseClientID() - spin_lock_irqsave( &pDev->mQMIDev.mClientMemLock, flags ); - } - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - - // Stop all reads - KillRead( pDev ); - - pDev->mbQMIValid = false; - - if (pDev->mQMIDev.mbCdevIsInitialized == false) - { - return; - } - -#ifndef quectel_no_for_each_process - // Find each open file handle, and manually close it - - // Generally there will only be only one inode, but more are possible - list_for_each( pInodeList, &pDev->mQMIDev.mCdev.list ) - { - // Get the inode - pOpenInode = container_of( pInodeList, struct inode, i_devices ); - if (pOpenInode != NULL && (IS_ERR( pOpenInode ) == false)) - { - // Look for this inode in each task - - rcu_read_lock(); - for_each_process( pEachTask ) - { - task_lock(pEachTask); - if (pEachTask == NULL || pEachTask->files == NULL) - { - // Some tasks may not have files (e.g. Xsession) - task_unlock(pEachTask); - continue; - } - // For each file this task has open, check if it's referencing - // our inode. - spin_lock_irqsave( &pEachTask->files->file_lock, flags ); - task_unlock(pEachTask); //kernel/exit.c:do_exit() -> fs/file.c:exit_files() - pFDT = files_fdtable( pEachTask->files ); - for (count = 0; count < pFDT->max_fds; count++) - { - pFilp = pFDT->fd[count]; - if (pFilp != NULL && pFilp->f_dentry != NULL) - { - if (pFilp->f_dentry->d_inode == pOpenInode) - { - // Close this file handle - rcu_assign_pointer( pFDT->fd[count], NULL ); - spin_unlock_irqrestore( &pEachTask->files->file_lock, flags ); - - DBG( "forcing close of open file handle\n" ); - filp_close( pFilp, pEachTask->files ); - - spin_lock_irqsave( &pEachTask->files->file_lock, flags ); - } - } - } - spin_unlock_irqrestore( &pEachTask->files->file_lock, flags ); - } - rcu_read_unlock(); - } - } -#endif - -if (pDev->mpNetDev->udev->state) { - // Send SetControlLineState request (USB_CDC) - result = usb_control_msg( pDev->mpNetDev->udev, - usb_sndctrlpipe( pDev->mpNetDev->udev, 0 ), - SET_CONTROL_LINE_STATE_REQUEST, - SET_CONTROL_LINE_STATE_REQUEST_TYPE, - 0, // DTR not present - /* USB interface number to receive control message */ - pDev->mpIntf->cur_altsetting->desc.bInterfaceNumber, - NULL, - 0, - 100 ); - if (result < 0) - { - DBG( "Bad SetControlLineState status %d\n", result ); - } -} - - // Remove device (so no more calls can be made by users) - if (IS_ERR( pDev->mQMIDev.mpDevClass ) == false) - { - device_destroy( pDev->mQMIDev.mpDevClass, - pDev->mQMIDev.mDevNum ); - } - - // Hold onto cdev memory location until everyone is through using it. - // Timeout after 30 seconds (10 ms interval). Timeout should never happen, - // but exists to prevent an infinate loop just in case. - for (tries = 0; tries < 30 * 100; tries++) - { -#if (LINUX_VERSION_CODE < KERNEL_VERSION( 4,11,0 )) - int ref = atomic_read( &pDev->mQMIDev.mCdev.kobj.kref.refcount ); -#else - int ref = kref_read( &pDev->mQMIDev.mCdev.kobj.kref ); -#endif - if (ref > 1) - { - DBG( "cdev in use by %d tasks\n", ref - 1 ); - if (tries > 10) - INFO( "cdev in use by %d tasks\n", ref - 1 ); - msleep( 10 ); - } - else - { - break; - } - } - - cdev_del( &pDev->mQMIDev.mCdev ); - - unregister_chrdev_region( pDev->mQMIDev.mDevNum, 1 ); - - return; -} - -/*=========================================================================*/ -// Driver level client management -/*=========================================================================*/ - -/*=========================================================================== -METHOD: - QMIReady (Public Method) - -DESCRIPTION: - Send QMI CTL GET VERSION INFO REQ and SET DATA FORMAT REQ - Wait for response or timeout - -PARAMETERS: - pDev [ I ] - Device specific memory - timeout [ I ] - Milliseconds to wait for response - -RETURN VALUE: - bool -===========================================================================*/ -static bool QMIReady( - sGobiUSBNet * pDev, - u16 timeout ) -{ - int result; - void * pWriteBuffer; - u16 writeBufferSize; - void * pReadBuffer; - u16 readBufferSize; - u16 curTime; - unsigned long flags; - u8 transactionID; - u16 interval = 2000; - - if (IsDeviceValid( pDev ) == false) - { - DBG( "Invalid device\n" ); - return false; - } - - writeBufferSize = QMICTLReadyReqSize(); - pWriteBuffer = kmalloc( writeBufferSize, GFP_KERNEL ); - if (pWriteBuffer == NULL) - { - return false; - } - - // An implimentation of down_timeout has not been agreed on, - // so it's been added and removed from the kernel several times. - // We're just going to ignore it and poll the semaphore. - - // Send a write every 1000 ms and see if we get a response - for (curTime = 0; curTime < timeout; curTime += interval) - { - // Start read - struct QuecSem *readSem = kmalloc(sizeof(struct QuecSem ), GFP_KERNEL); - readSem->magic = QUEC_SEM_MAGIC; - sema_init( &readSem->readSem, 0 ); - - transactionID = QMIXactionIDGet( pDev ); - - result = ReadAsync( pDev, QMICTL, transactionID, UpSem, readSem ); - if (result != 0) - { - kfree( pWriteBuffer ); - return false; - } - - // Fill buffer - result = QMICTLReadyReq( pWriteBuffer, - writeBufferSize, - transactionID ); - if (result < 0) - { - kfree( pWriteBuffer ); - return false; - } - - // Disregard status. On errors, just try again - result = WriteSync( pDev, - pWriteBuffer, - writeBufferSize, - QMICTL ); - - if (result < 0) //maybe caused by usb disconnect - { - kfree( pWriteBuffer ); - return false; - } - -#if 1 - if (down_timeout( &readSem->readSem, msecs_to_jiffies(interval) ) == 0) -#else - msleep( interval ); - if (down_trylock( &readSem->readSem ) == 0) -#endif - { - kfree(readSem); - // Enter critical section - spin_lock_irqsave( &pDev->mQMIDev.mClientMemLock, flags ); - - // Pop the read data - if (PopFromReadMemList( pDev, - QMICTL, - transactionID, - &pReadBuffer, - &readBufferSize ) == true) - { - // Success - - // End critical section - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - - // We don't care about the result - kfree( pReadBuffer ); - - break; - } - else - { - // Read mismatch/failure, unlock and continue - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - } - } - else - { - readSem->magic = 0; - // Enter critical section - spin_lock_irqsave( &pDev->mQMIDev.mClientMemLock, flags ); - - // Timeout, remove the async read - NotifyAndPopNotifyList( pDev, QMICTL, transactionID ); - - // End critical section - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - } - - if (pDev->mbDeregisterQMIDevice) - { - kfree( pWriteBuffer ); - return false; - } - } - - kfree( pWriteBuffer ); - - // Did we time out? - if (curTime >= timeout) - { - return false; - } - - DBG( "QMI Ready after %u milliseconds\n", curTime ); - - // Success - return true; -} - -/*=========================================================================== -METHOD: - QMIWDSCallback (Public Method) - -DESCRIPTION: - QMI WDS callback function - Update net stats or link state - -PARAMETERS: - pDev [ I ] - Device specific memory - clientID [ I ] - Client ID - pData [ I ] - Callback data (unused) - -RETURN VALUE: - None -===========================================================================*/ -static void QMIWDSCallback( - sGobiUSBNet * pDev, - u16 clientID, - void * pData ) -{ - bool bRet; - int result; - void * pReadBuffer; - u16 readBufferSize; - -#if 0 -#if (LINUX_VERSION_CODE < KERNEL_VERSION( 2,6,31 )) - struct net_device_stats * pStats = &(pDev->mpNetDev->stats); -#else - struct net_device_stats * pStats = &(pDev->mpNetDev->net->stats); -#endif -#endif - - u32 TXOk = (u32)-1; - u32 RXOk = (u32)-1; - u32 TXErr = (u32)-1; - u32 RXErr = (u32)-1; - u32 TXOfl = (u32)-1; - u32 RXOfl = (u32)-1; - u64 TXBytesOk = (u64)-1; - u64 RXBytesOk = (u64)-1; - bool bLinkState; - bool bReconfigure; - unsigned long flags; - - if (IsDeviceValid( pDev ) == false) - { - DBG( "Invalid device\n" ); - return; - } - - // Critical section - spin_lock_irqsave( &pDev->mQMIDev.mClientMemLock, flags ); - - bRet = PopFromReadMemList( pDev, - clientID, - 0, - &pReadBuffer, - &readBufferSize ); - - // End critical section - spin_unlock_irqrestore( &pDev->mQMIDev.mClientMemLock, flags ); - - if (bRet == false) - { - DBG( "WDS callback failed to get data\n" ); - return; - } - - // Default values - bLinkState = ! GobiTestDownReason( pDev, NO_NDIS_CONNECTION ); - bReconfigure = false; - - result = QMIWDSEventResp( pReadBuffer, - readBufferSize, - &TXOk, - &RXOk, - &TXErr, - &RXErr, - &TXOfl, - &RXOfl, - &TXBytesOk, - &RXBytesOk, - &bLinkState, - &bReconfigure ); - if (result < 0) - { - DBG( "bad WDS packet\n" ); - } - else - { -#if 0 //usbbet.c will do this job - // Fill in new values, ignore max values - if (TXOfl != (u32)-1) - { - pStats->tx_fifo_errors = TXOfl; - } - - if (RXOfl != (u32)-1) - { - pStats->rx_fifo_errors = RXOfl; - } - - if (TXErr != (u32)-1) - { - pStats->tx_errors = TXErr; - } - - if (RXErr != (u32)-1) - { - pStats->rx_errors = RXErr; - } - - if (TXOk != (u32)-1) - { - pStats->tx_packets = TXOk + pStats->tx_errors; - } - - if (RXOk != (u32)-1) - { - pStats->rx_packets = RXOk + pStats->rx_errors; - } - - if (TXBytesOk != (u64)-1) - { - pStats->tx_bytes = TXBytesOk; - } - - if (RXBytesOk != (u64)-1) - { - pStats->rx_bytes = RXBytesOk; - } -#endif - - if (bReconfigure == true) - { - DBG( "Net device link reset\n" ); - GobiSetDownReason( pDev, NO_NDIS_CONNECTION ); - GobiClearDownReason( pDev, NO_NDIS_CONNECTION ); - } - else - { - if (bLinkState == true) - { - if (GobiTestDownReason( pDev, NO_NDIS_CONNECTION )) { - DBG( "Net device link is connected\n" ); - GobiClearDownReason( pDev, NO_NDIS_CONNECTION ); - } - } - else - { - if (!GobiTestDownReason( pDev, NO_NDIS_CONNECTION )) { - DBG( "Net device link is disconnected\n" ); - GobiSetDownReason( pDev, NO_NDIS_CONNECTION ); - } - } - } - } - - kfree( pReadBuffer ); - - // Setup next read - result = ReadAsync( pDev, - clientID, - 0, - QMIWDSCallback, - pData ); - if (result != 0) - { - DBG( "unable to setup next async read\n" ); - } - - return; -} - -/*=========================================================================== -METHOD: - SetupQMIWDSCallback (Public Method) - -DESCRIPTION: - Request client and fire off reqests and start async read for - QMI WDS callback - -PARAMETERS: - pDev [ I ] - Device specific memory - -RETURN VALUE: - int - 0 for success - Negative errno for failure -===========================================================================*/ -static int SetupQMIWDSCallback( sGobiUSBNet * pDev ) -{ - int result; - void * pWriteBuffer; - u16 writeBufferSize; - u16 WDSClientID; - - if (IsDeviceValid( pDev ) == false) - { - DBG( "Invalid device\n" ); - return -EFAULT; - } - - result = GetClientID( pDev, QMIWDS ); - if (result < 0) - { - return result; - } - WDSClientID = result; - -#if 0 // add for "AT$QCRMCALL=1,1", be careful: donot enable these codes if use quectel-CM, or cannot obtain IP by udhcpc - if (pDev->mbMdm9x07) - { - void * pReadBuffer; - u16 readBufferSize; - - writeBufferSize = QMIWDSSetQMUXBindMuxDataPortSize(); - pWriteBuffer = kmalloc( writeBufferSize, GFP_KERNEL ); - if (pWriteBuffer == NULL) - { - return -ENOMEM; - } - - result = QMIWDSSetQMUXBindMuxDataPortReq( pWriteBuffer, - writeBufferSize, - 0x81, - 3 ); - if (result < 0) - { - kfree( pWriteBuffer ); - return result; - } - - result = WriteSync( pDev, - pWriteBuffer, - writeBufferSize, - WDSClientID ); - kfree( pWriteBuffer ); - - if (result < 0) - { - return result; - } - - result = ReadSync( pDev, - &pReadBuffer, - WDSClientID, - 3 ); - if (result < 0) - { - return result; - } - readBufferSize = result; - - kfree( pReadBuffer ); - } -#endif - - // QMI WDS Set Event Report - writeBufferSize = QMIWDSSetEventReportReqSize(); - pWriteBuffer = kmalloc( writeBufferSize, GFP_KERNEL ); - if (pWriteBuffer == NULL) - { - return -ENOMEM; - } - - result = QMIWDSSetEventReportReq( pWriteBuffer, - writeBufferSize, - 1 ); - if (result < 0) - { - kfree( pWriteBuffer ); - return result; - } - - result = WriteSync( pDev, - pWriteBuffer, - writeBufferSize, - WDSClientID ); - kfree( pWriteBuffer ); - - if (result < 0) - { - return result; - } - - // QMI WDS Get PKG SRVC Status - writeBufferSize = QMIWDSGetPKGSRVCStatusReqSize(); - pWriteBuffer = kmalloc( writeBufferSize, GFP_KERNEL ); - if (pWriteBuffer == NULL) - { - return -ENOMEM; - } - - result = QMIWDSGetPKGSRVCStatusReq( pWriteBuffer, - writeBufferSize, - 2 ); - if (result < 0) - { - kfree( pWriteBuffer ); - return result; - } - - result = WriteSync( pDev, - pWriteBuffer, - writeBufferSize, - WDSClientID ); - kfree( pWriteBuffer ); - - if (result < 0) - { - return result; - } - - // Setup asnyc read callback - result = ReadAsync( pDev, - WDSClientID, - 0, - QMIWDSCallback, - NULL ); - if (result != 0) - { - DBG( "unable to setup async read\n" ); - return result; - } - - // Send SetControlLineState request (USB_CDC) - // Required for Autoconnect - result = usb_control_msg( pDev->mpNetDev->udev, - usb_sndctrlpipe( pDev->mpNetDev->udev, 0 ), - SET_CONTROL_LINE_STATE_REQUEST, - SET_CONTROL_LINE_STATE_REQUEST_TYPE, - CONTROL_DTR, - /* USB interface number to receive control message */ - pDev->mpIntf->cur_altsetting->desc.bInterfaceNumber, - NULL, - 0, - 100 ); - if (result < 0) - { - DBG( "Bad SetControlLineState status %d\n", result ); - return result; - } - - return 0; -} - -/*=========================================================================== -METHOD: - QMIDMSGetMEID (Public Method) - -DESCRIPTION: - Register DMS client - send MEID req and parse response - Release DMS client - -PARAMETERS: - pDev [ I ] - Device specific memory - -RETURN VALUE: - None -===========================================================================*/ -static int QMIDMSGetMEID( sGobiUSBNet * pDev ) -{ - int result; - void * pWriteBuffer; - u16 writeBufferSize; - void * pReadBuffer; - u16 readBufferSize; - u16 DMSClientID; - - if (IsDeviceValid( pDev ) == false) - { - DBG( "Invalid device\n" ); - return -EFAULT; - } - - result = GetClientID( pDev, QMIDMS ); - if (result < 0) - { - return result; - } - DMSClientID = result; - - // QMI DMS Get Serial numbers Req - writeBufferSize = QMIDMSGetMEIDReqSize(); - pWriteBuffer = kmalloc( writeBufferSize, GFP_KERNEL ); - if (pWriteBuffer == NULL) - { - return -ENOMEM; - } - - result = QMIDMSGetMEIDReq( pWriteBuffer, - writeBufferSize, - 1 ); - if (result < 0) - { - kfree( pWriteBuffer ); - return result; - } - - result = WriteSync( pDev, - pWriteBuffer, - writeBufferSize, - DMSClientID ); - kfree( pWriteBuffer ); - - if (result < 0) - { - return result; - } - - // QMI DMS Get Serial numbers Resp - result = ReadSync( pDev, - &pReadBuffer, - DMSClientID, - 1 ); - if (result < 0) - { - return result; - } - readBufferSize = result; - - result = QMIDMSGetMEIDResp( pReadBuffer, - readBufferSize, - &pDev->mMEID[0], - 14 ); - kfree( pReadBuffer ); - - if (result < 0) - { - DBG( "bad get MEID resp\n" ); - - // Non fatal error, device did not return any MEID - // Fill with 0's - memset( &pDev->mMEID[0], '0', 14 ); - } - - ReleaseClientID( pDev, DMSClientID ); - - // Success - return 0; -} - -/*=========================================================================== -METHOD: - QMIWDASetDataFormat (Public Method) - -DESCRIPTION: - Register WDA client - send Data format request and parse response - Release WDA client - -PARAMETERS: - pDev [ I ] - Device specific memory - -RETURN VALUE: - None -===========================================================================*/ -static int QMIWDASetDataFormat( sGobiUSBNet * pDev, int qmap_mode, int *rx_urb_size ) -{ - int result; - void * pWriteBuffer; - u16 writeBufferSize; - void * pReadBuffer; - u16 readBufferSize; - u16 WDAClientID; - - DBG("\n"); - - if (IsDeviceValid( pDev ) == false) - { - DBG( "Invalid device\n" ); - return -EFAULT; - } - - result = GetClientID( pDev, QMIWDA ); - if (result < 0) - { - return result; - } - WDAClientID = result; - - // QMI WDA Set Data Format Request - writeBufferSize = QMIWDASetDataFormatReqSize(qmap_mode); - pWriteBuffer = kmalloc( writeBufferSize, GFP_KERNEL ); - if (pWriteBuffer == NULL) - { - return -ENOMEM; - } - - result = QMIWDASetDataFormatReq( pWriteBuffer, - writeBufferSize, pDev->mbRawIPMode, - qmap_mode ? pDev->qmap_version : 0, (31*1024), - 1 ); - - if (result < 0) - { - kfree( pWriteBuffer ); - return result; - } - - result = WriteSync( pDev, - pWriteBuffer, - writeBufferSize, - WDAClientID ); - kfree( pWriteBuffer ); - - if (result < 0) - { - return result; - } - - // QMI DMS Get Serial numbers Resp - result = ReadSync( pDev, - &pReadBuffer, - WDAClientID, - 1 ); - if (result < 0) - { - return result; - } - readBufferSize = result; - -if (qmap_mode && rx_urb_size) { - int qmap_version = 0, rx_size = 0, tx_size = 0; - result = QMIWDASetDataFormatResp( pReadBuffer, - readBufferSize, pDev->mbRawIPMode, &qmap_version, &rx_size, &tx_size, &pDev->qmap_settings); - INFO( "qmap settings qmap_version=%d, rx_size=%d, tx_size=%d\n", - le32_to_cpu(qmap_version), le32_to_cpu(rx_size), le32_to_cpu(tx_size)); - - if (le32_to_cpu(qmap_version)) { -#if defined(QUECTEL_UL_DATA_AGG) - struct ul_agg_ctx *ctx = &pDev->agg_ctx; - - if (le32_to_cpu(pDev->qmap_settings.ul_data_aggregation_max_datagrams) > 1) { - ctx->ul_data_aggregation_max_size = le32_to_cpu(pDev->qmap_settings.ul_data_aggregation_max_size); - ctx->ul_data_aggregation_max_datagrams = le32_to_cpu(pDev->qmap_settings.ul_data_aggregation_max_datagrams); - ctx->dl_minimum_padding = le32_to_cpu(pDev->qmap_settings.dl_minimum_padding); - } - INFO( "qmap settings ul_data_aggregation_max_size=%d, ul_data_aggregation_max_datagrams=%d\n", - ctx->ul_data_aggregation_max_size, ctx->ul_data_aggregation_max_datagrams); - if (ctx->ul_data_aggregation_max_datagrams > 11) - ctx->ul_data_aggregation_max_datagrams = 11; -#endif - *rx_urb_size = le32_to_cpu(rx_size); - } else { - *rx_urb_size = 0; - result = -EFAULT; - } -} else { - int qmap_enabled = 0, rx_size = 0, tx_size = 0; - result = QMIWDASetDataFormatResp( pReadBuffer, - readBufferSize, pDev->mbRawIPMode, &qmap_enabled, &rx_size, &tx_size, NULL); -} - - kfree( pReadBuffer ); - - if (result < 0) - { - DBG( "Data Format Cannot be set\n" ); - } - - ReleaseClientID( pDev, WDAClientID ); - - // Success - return 0; -} - -int QuecQMIWDASetDataFormat( sGobiUSBNet * pDev, int qmap_mode, int *rx_urb_size ) { - return QMIWDASetDataFormat(pDev, qmap_mode, rx_urb_size); -} diff --git a/quectel_Gobinet/src/QMIDevice.h b/quectel_Gobinet/src/QMIDevice.h deleted file mode 100644 index 71af0af..0000000 --- a/quectel_Gobinet/src/QMIDevice.h +++ /dev/null @@ -1,368 +0,0 @@ -/*=========================================================================== -FILE: - QMIDevice.h - -DESCRIPTION: - Functions related to the QMI interface device - -FUNCTIONS: - Generic functions - IsDeviceValid - PrintHex - GobiSetDownReason - GobiClearDownReason - GobiTestDownReason - - Driver level asynchronous read functions - ResubmitIntURB - ReadCallback - IntCallback - StartRead - KillRead - - Internal read/write functions - ReadAsync - UpSem - ReadSync - WriteSyncCallback - WriteSync - - Internal memory management functions - GetClientID - ReleaseClientID - FindClientMem - AddToReadMemList - PopFromReadMemList - AddToNotifyList - NotifyAndPopNotifyList - AddToURBList - PopFromURBList - - Internal userspace wrapper functions - UserspaceunlockedIOCTL - - Userspace wrappers - UserspaceOpen - UserspaceIOCTL - UserspaceClose - UserspaceRead - UserspaceWrite - UserspacePoll - - Initializer and destructor - RegisterQMIDevice - DeregisterQMIDevice - - Driver level client management - QMIReady - QMIWDSCallback - SetupQMIWDSCallback - QMIDMSGetMEID - -Copyright (c) 2011, Code Aurora Forum. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of Code Aurora Forum nor - the names of its contributors may be used to endorse or promote - products derived from this software without specific prior written - permission. - - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. -===========================================================================*/ - -//--------------------------------------------------------------------------- -// Pragmas -//--------------------------------------------------------------------------- -#pragma once - -//--------------------------------------------------------------------------- -// Include Files -//--------------------------------------------------------------------------- -#include "Structs.h" -#include "QMI.h" - -/*=========================================================================*/ -// Generic functions -/*=========================================================================*/ - -#ifdef __QUECTEL_INTER__ - -// Basic test to see if device memory is valid -static bool IsDeviceValid( sGobiUSBNet * pDev ); - -/*=========================================================================*/ -// Driver level asynchronous read functions -/*=========================================================================*/ - -// Resubmit interrupt URB, re-using same values -static int ResubmitIntURB( struct urb * pIntURB ); - -// Read callback -// Put the data in storage and notify anyone waiting for data -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 2,6,18 )) -static void ReadCallback( struct urb * pReadURB ); -#else -static void ReadCallback(struct urb *pReadURB, struct pt_regs *regs); -#endif - -// Inturrupt callback -// Data is available, start a read URB -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 2,6,18 )) -static void IntCallback( struct urb * pIntURB ); -#else -static void IntCallback(struct urb *pIntURB, struct pt_regs *regs); -#endif - -/*=========================================================================*/ -// Internal read/write functions -/*=========================================================================*/ - -// Start asynchronous read -// Reading client's data store, not device -static int ReadAsync( - sGobiUSBNet * pDev, - u16 clientID, - u16 transactionID, - void (*pCallback)(sGobiUSBNet *, u16, void *), - void * pData ); - -// Notification function for synchronous read -static void UpSem( - sGobiUSBNet * pDev, - u16 clientID, - void * pData ); - -// Start synchronous read -// Reading client's data store, not device -static int ReadSync( - sGobiUSBNet * pDev, - void ** ppOutBuffer, - u16 clientID, - u16 transactionID ); - -// Write callback -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 2,6,18 )) -static void WriteSyncCallback( struct urb * pWriteURB ); -#else -static void WriteSyncCallback(struct urb *pWriteURB, struct pt_regs *regs); -#endif - -// Start synchronous write -static int WriteSync( - sGobiUSBNet * pDev, - char * pInWriteBuffer, - int size, - u16 clientID ); - -/*=========================================================================*/ -// Internal memory management functions -/*=========================================================================*/ - -// Create client and allocate memory -static int GetClientID( - sGobiUSBNet * pDev, - u8 serviceType ); - -// Release client and free memory -static void ReleaseClientID( - sGobiUSBNet * pDev, - u16 clientID ); - -// Find this client's memory -static sClientMemList * FindClientMem( - sGobiUSBNet * pDev, - u16 clientID ); - -// Add Data to this client's ReadMem list -static bool AddToReadMemList( - sGobiUSBNet * pDev, - u16 clientID, - u16 transactionID, - void * pData, - u16 dataSize ); - -// Remove data from this client's ReadMem list if it matches -// the specified transaction ID. -static bool PopFromReadMemList( - sGobiUSBNet * pDev, - u16 clientID, - u16 transactionID, - void ** ppData, - u16 * pDataSize ); - -// Add Notify entry to this client's notify List -static bool AddToNotifyList( - sGobiUSBNet * pDev, - u16 clientID, - u16 transactionID, - void (* pNotifyFunct)(sGobiUSBNet *, u16, void *), - void * pData ); - -// Remove first Notify entry from this client's notify list -// and Run function -static bool NotifyAndPopNotifyList( - sGobiUSBNet * pDev, - u16 clientID, - u16 transactionID ); - -// Add URB to this client's URB list -static bool AddToURBList( - sGobiUSBNet * pDev, - u16 clientID, - struct urb * pURB ); - -// Remove URB from this client's URB list -static struct urb * PopFromURBList( - sGobiUSBNet * pDev, - u16 clientID ); - -/*=========================================================================*/ -// Internal userspace wrappers -/*=========================================================================*/ - -// Userspace unlocked ioctl -static long UserspaceunlockedIOCTL( - struct file * pFilp, - unsigned int cmd, - unsigned long arg ); - -/*=========================================================================*/ -// Userspace wrappers -/*=========================================================================*/ - -// Userspace open -static int UserspaceOpen( - struct inode * pInode, - struct file * pFilp ); - -#if (LINUX_VERSION_CODE < KERNEL_VERSION( 2,6,36 )) -// Userspace ioctl -static int UserspaceIOCTL( - struct inode * pUnusedInode, - struct file * pFilp, - unsigned int cmd, - unsigned long arg ); -#endif - -// Userspace close -#define quectel_no_for_each_process -#ifdef quectel_no_for_each_process -static int UserspaceClose( - struct inode * pInode, - struct file * pFilp ); -#else -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 2,6,14 )) -static int UserspaceClose( - struct file * pFilp, - fl_owner_t unusedFileTable ); -#else -static int UserspaceClose( struct file * pFilp ); -#endif -#endif - -// Userspace read (synchronous) -static ssize_t UserspaceRead( - struct file * pFilp, - char __user * pBuf, - size_t size, - loff_t * pUnusedFpos ); - -// Userspace write (synchronous) -static ssize_t UserspaceWrite( - struct file * pFilp, - const char __user * pBuf, - size_t size, - loff_t * pUnusedFpos ); - -static unsigned int UserspacePoll( - struct file * pFilp, - struct poll_table_struct * pPollTable ); - -/*=========================================================================*/ -// Driver level client management -/*=========================================================================*/ - -// Check if QMI is ready for use -static bool QMIReady( - sGobiUSBNet * pDev, - u16 timeout ); - -// QMI WDS callback function -static void QMIWDSCallback( - sGobiUSBNet * pDev, - u16 clientID, - void * pData ); - -// Fire off reqests and start async read for QMI WDS callback -static int SetupQMIWDSCallback( sGobiUSBNet * pDev ); - -// Register client, send req and parse MEID response, release client -static int QMIDMSGetMEID( sGobiUSBNet * pDev ); - -// Register client, send req and parse Data format response, release client -static int QMIWDASetDataFormat( sGobiUSBNet * pDev, int qmap_mode, int *rx_urb_size ); -#endif - -// Print Hex data, for debug purposes -void QuecPrintHex( - void * pBuffer, - u16 bufSize ); - -// Sets mDownReason and turns carrier off -void QuecGobiSetDownReason( - sGobiUSBNet * pDev, - u8 reason ); - -// Clear mDownReason and may turn carrier on -void QuecGobiClearDownReason( - sGobiUSBNet * pDev, - u8 reason ); - -// Tests mDownReason and returns whether reason is set -bool QuecGobiTestDownReason( - sGobiUSBNet * pDev, - u8 reason ); - -// Start continuous read "thread" - int QuecStartRead( sGobiUSBNet * pDev ); - -// Kill continuous read "thread" - void QuecKillRead( sGobiUSBNet * pDev ); - -/*=========================================================================*/ -// Initializer and destructor -/*=========================================================================*/ - -// QMI Device initialization function -int QuecRegisterQMIDevice( sGobiUSBNet * pDev ); - -// QMI Device cleanup function -void QuecDeregisterQMIDevice( sGobiUSBNet * pDev ); - -int QuecQMIWDASetDataFormat( sGobiUSBNet * pDev, int qmap_mode, int *rx_urb_size ); - -#define PrintHex QuecPrintHex -#define GobiSetDownReason QuecGobiSetDownReason -#define GobiClearDownReason QuecGobiClearDownReason -#define GobiTestDownReason QuecGobiTestDownReason -#define StartRead QuecStartRead -#define KillRead QuecKillRead -#define RegisterQMIDevice QuecRegisterQMIDevice -#define DeregisterQMIDevice QuecDeregisterQMIDevice diff --git a/quectel_Gobinet/src/Readme.txt b/quectel_Gobinet/src/Readme.txt deleted file mode 100644 index 28412fa..0000000 --- a/quectel_Gobinet/src/Readme.txt +++ /dev/null @@ -1,78 +0,0 @@ -Gobi3000 network driver 2011-07-29-1026 - -This readme covers important information concerning -the Gobi Net driver. - -Table of Contents - -1. What's new in this release -2. Known issues -3. Known platform issues - - -------------------------------------------------------------------------------- - -1. WHAT'S NEW - -This Release (Gobi3000 network driver 2011-07-29-1026) -a. Signal the device to leave low power mode on enumeration -b. Add "txQueueLength" parameter, which will set the Tx Queue Length -c. Send SetControlLineState message during driver/device removal -d. Change to new date-based versioning scheme - -Prior Release (Gobi3000 network driver 1.0.60) 06/29/2011 -a. Add UserspacePoll() function, to support select() -b. Fix possible deadlock on GobiUSBNetTXTimeout() -c. Fix memory leak on data transmission - -Prior Release (Gobi3000 network driver 1.0.50) 05/18/2011 -a. Add support for kernels up to 2.6.38 -b. Add support for dynamic interface binding - -Prior Release (Gobi3000 network driver 1.0.40) 02/28/2011 -a. In cases of QMI read errors, discard the error and continue reading. -b. Add "interruptible" parameter, which may be disabled for debugging purposes. - -Prior Release (Gobi3000 network driver 1.0.30) 01/05/2011 -a. Fix rare kernel PANIC if a process terminates while file handle close - or device removal is in progress. - -Prior Release (Gobi3000 network driver 1.0.20) 11/01/2010 -a. Fix possible kernel WARNING if device removed before QCWWANDisconnect(). -b. Fix multiple memory leaks in error cases. - -Prior Release (Gobi3000 network driver 1.0.10) 09/17/2010 -a. Initial release - -------------------------------------------------------------------------------- - -2. KNOWN ISSUES - -No known issues. - -------------------------------------------------------------------------------- - -3. KNOWN PLATFORM ISSUES - -a. Enabling autosuspend: - Autosuspend is supported by the Gobi3000 module and its drivers, - but by default it is not enabled by the open source kernel. As such, - the Gobi3000 module will not enter autosuspend unless the - user specifically turns on autosuspend with the command: - echo auto > /sys/bus/usb/devices/.../power/level -b. Ksoftirq using 100% CPU: - There is a known issue with the open source usbnet driver that can - result in infinite software interrupts. The fix for this is to test - (in the usbnet_bh() function) if the usb_device can submit URBs before - attempting to submit the response URB buffers. -c. NetworkManager does not recognize connection after resume: - After resuming from sleep/hibernate, NetworkManager may not recognize new - network connections by the Gobi device. This is a system issue not specific - to the Gobi device, which may result in dhcp not being run and the default - route not being updated. One way to fix this is to simply restart the - NetworkManager service. - -------------------------------------------------------------------------------- - - - diff --git a/quectel_Gobinet/src/ReleaseNote.txt b/quectel_Gobinet/src/ReleaseNote.txt deleted file mode 100644 index 72f6888..0000000 --- a/quectel_Gobinet/src/ReleaseNote.txt +++ /dev/null @@ -1,166 +0,0 @@ -Release Notes - -[V1.6.3] -Date: 9/26/2021 -enhancement: - 1. change version to 1.6.3 -fix: - -[V1.6.2.16] -Date: 9/17/2021 -enhancement: -fix: - 1. add sdx6x platform support - -[V1.6.2.15] -Date: 3/23/2021 -enhancement: -fix: - 1. add sdx12 platform support - -[V1.6.2.14] -Date: 3/18/2021 -enhancement: -fix: - 1. fix kasam: use-after-free when do modem reboot stress test - 2. wait qmi_sync_thread() finish in DeregisterQMIDevice(), usb will disconnect when driver is still in qmi_sync_thread() - -[V1.6.2.13] -Date: 12/31/2020 -enhancement: -fix: - 1. fix quectel-CM open error when driver is still in qmi_sync_thread() but SOC enter sleep. - -[V1.6.2.12] -Date: 12/31/2020 -enhancement: -fix: - 1. for multi-pdn-call, can not ping when usb resume for usb suspend state. - -[V1.6.2.11] -Date: 11/7/2020 -enhancement: - 1. support QUECTEL_QMI_MERGE, for some SOC, control endpoint only support read max 64 bytes QMI. - for QMI that size > 64, we need read serval times, and merge. -fix: - -[V1.6.2.10] -Date: 9/15/2020 -enhancement: -fix: - 1. for X55, fix panic on kernel V2.6 ~ V3.2 - -[V1.6.2.9] -Date: 7/24/2020 -enhancement: -fix: - 1. for X55, fix errors on Big Endian SOC. - -[V1.6.2.8] -Date: 7/2/2020 -enhancement: - 1. support QMAPV5, UL AGG (porting from qmi_wwan_q) -fix: - 1. fix errors kernel V2.6 . - -[V1.6.2.7] -Date: 6/9/2020 -enhancement: -fix: - 1. when send qmi ctl request, clear qmi ctl response which's TID is same - -[V1.6.2.6] -Date: 5/19/2020 -enhancement: - 1. support bridge mode for multi-pdn-call -fix: - -[V1.6.2.5] -Date: 4/26/2020 -enhancement: - 1. fix netcard name as usbX (from ethX) -fix: - -...... - -[Quectel_WCDMA<E_Linux&Android_GobiNet_Driver_V1.5.0] -Date: 2018/04/17 -enhancement:: -1. support EG20&RG500 -2. fix set rx_urb_size as 1520. do not change accroding to MTU - -[Quectel_WCDMA<E_Linux&Android_GobiNet_Driver_V1.4.3] -Date: 2018/04/16 -enhancement:: -1. increase QMAP's rx_urb_size to 32KB - -[Quectel_WCDMA<E_Linux&Android_GobiNet_Driver_V1.4.2] -Date: 2018/04/03 -bug fix: -1. fix qmi client can not be released when quectel-CM killed by kill -9 - -[Quectel_WCDMA<E_Linux&Android_GobiNet_Driver_V1.4.1] -Date: 2018/02/20 -bug fix: -1. fix a compiler error on Kernel lager than 4.11 - -[Quectel_WCDMA<E_Linux&Android_GobiNet_Driver_V1.4.0] -Date: 2018/12/17 -bug fix: -1. fix a USB DMA error when built as GobiNet.ko on Kernel lager than 4.15 - -[Quectel_WCDMA<E_Linux&Android_GobiNet_Driver_V1.3.8] -[Quectel_WCDMA<E_Linux&Android_GobiNet_Driver_V1.3.7] -Date: 2018/09/25 -enhancement: -1. check skb length in tx_fixup functions. -2. when QMAP enabled, set FLAG_RX_ASSEMBLE to advoid 'RX errors' of ifconfig - -[Quectel_WCDMA<E_Linux&Android_GobiNet_Driver_V1.3.6] -Date: 2018/09/11 -enhancement: -1. support EG12 EM12 -2. optimization QMAP source code -3. fix compile errors and warnnings on kernel version 4.15 - -[Quectel_WCDMA<E_Linux&Android_GobiNet_Driver_V1.3.5] -Date: 2018/05/12 -enhancement: -1. provide two method to enable QMAP function. - 1.1 set module parameters 'qmap_mode' to X(1~4) to enable QMAP. - 1.2 ifconfig usb0 down, then 'echo X > /sys/class/usbX/qmap_mode' to enable QMAP - for above two method, X(1) used to enable 'IP Aggregation' and X(2~4) to enable 'IP Mux' -2. support bridge mode, also provide two method to enable bridge mode. - 2.1 set module parameters 'bridge_mode' to 1 to enable bridge mode. - 2.2 'echo 1 > /sys/class/usbX/bridge_mode' to enable bridge mode. - bridge mode setups: - brctl addbr br0; brctl addif br0 eth0; brctl addif usb0; ./quectel-CM; ifconfig br0 up; ifconfig eth0 up - then connect eth0 to PC by ethernet cable. and PC run DHCP tool to obtain network public IP address. - - 'WCDMA<E_QConnectManager_Linux&Android_V1.1.40' and later version is required to use QMAP and bridge mode. - -[Quectel_WCDMA<E_Linux&Android_GobiNet_Driver_V1.3.4] -Date: 2018/05/07 -enhancement: -1. support use 'AT$QCRMCALL=1,1' to setup data call. - when use 'AT$QCRMCALL=1,1', must set module parameters 'qcrmcall_mode' to 1, - and GobiNet Driver will do not tx&rx QMI. - -[Quectel_WCDMA<E_Linux&Android_GobiNet_Driver_V1.3.3] -Date: 2018/04/04 -optimization: -1. optimization QMAP source code - -[Quectel_WCDMA<E_Linux&Android_GobiNet_Driver_V1.3.2] -Date: 2018/03/23 -enhancement: -1. support Qualcomm Mux and Aggregation Protocol (QMAP) - 1.1 IP Mux: GobiNet Driver register multiple netcards, one netcards corresponding to one PDP. - and GobiNet Driver will tx/rx multiple IP packets maybe belong to different PDPs in one URB. - 1.2 IP Aggregation: GobiNet Driver will rx multiple IP packets in one URB, used to increase throughput theoretically by reducing the number of usb interrupts. - the max rx URB size of MDM9x07 is 4KB, the max rx URB size of MDM9x40&SDX20 is 16KB - -[Quectel_WCDMA<E_Linux&Android_GobiNet_Driver_V1.3.1] -Date: 2017/11/20 -enhancement: -1. support BG96 diff --git a/quectel_Gobinet/src/Structs.h b/quectel_Gobinet/src/Structs.h deleted file mode 100644 index 5b7ebbc..0000000 --- a/quectel_Gobinet/src/Structs.h +++ /dev/null @@ -1,529 +0,0 @@ -/*=========================================================================== -FILE: - Structs.h - -DESCRIPTION: - Declaration of structures used by the Qualcomm Linux USB Network driver - -FUNCTIONS: - none - -Copyright (c) 2011, Code Aurora Forum. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of Code Aurora Forum nor - the names of its contributors may be used to endorse or promote - products derived from this software without specific prior written - permission. - - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. -===========================================================================*/ - -//--------------------------------------------------------------------------- -// Pragmas -//--------------------------------------------------------------------------- -#pragma once - -//--------------------------------------------------------------------------- -// Include Files -//--------------------------------------------------------------------------- -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define QUECTEL_WWAN_QMAP 4 //MAX is 7 -#ifdef QUECTEL_WWAN_QMAP -#define QUECTEL_QMAP_MUX_ID 0x81 -#endif - -//#define QUECTEL_QMI_MERGE - -#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) -#define QUECTEL_BRIDGE_MODE -#endif - -#if (LINUX_VERSION_CODE <= KERNEL_VERSION( 2,6,21 )) -static inline void skb_reset_mac_header(struct sk_buff *skb) -{ - skb->mac.raw = skb->data; -} -#endif - -#if (LINUX_VERSION_CODE <= KERNEL_VERSION( 2,6,22 )) -#define bool u8 -#ifndef URB_FREE_BUFFER -#define URB_FREE_BUFFER_BY_SELF //usb_free_urb will not free, should free by self -#define URB_FREE_BUFFER 0x0100 /* Free transfer buffer with the URB */ -#endif - -/** - * usb_endpoint_type - get the endpoint's transfer type - * @epd: endpoint to be checked - * - * Returns one of USB_ENDPOINT_XFER_{CONTROL, ISOC, BULK, INT} according - * to @epd's transfer type. - */ -static inline int usb_endpoint_type(const struct usb_endpoint_descriptor *epd) -{ - return epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK; -} -#endif - -#if (LINUX_VERSION_CODE <= KERNEL_VERSION( 2,6,18 )) -/** - * usb_endpoint_dir_in - check if the endpoint has IN direction - * @epd: endpoint to be checked - * - * Returns true if the endpoint is of type IN, otherwise it returns false. - */ -static inline int usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd) -{ - return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN); -} - -/** - * usb_endpoint_dir_out - check if the endpoint has OUT direction - * @epd: endpoint to be checked - * - * Returns true if the endpoint is of type OUT, otherwise it returns false. - */ -static inline int usb_endpoint_dir_out( - const struct usb_endpoint_descriptor *epd) -{ - return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT); -} - -/** - * usb_endpoint_xfer_int - check if the endpoint has interrupt transfer type - * @epd: endpoint to be checked - * - * Returns true if the endpoint is of type interrupt, otherwise it returns - * false. - */ -static inline int usb_endpoint_xfer_int( - const struct usb_endpoint_descriptor *epd) -{ - return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == - USB_ENDPOINT_XFER_INT); -} - -static inline int usb_autopm_set_interface(struct usb_interface *intf) -{ return 0; } - -static inline int usb_autopm_get_interface(struct usb_interface *intf) -{ return 0; } - -static inline int usb_autopm_get_interface_async(struct usb_interface *intf) -{ return 0; } - -static inline void usb_autopm_put_interface(struct usb_interface *intf) -{ } -static inline void usb_autopm_put_interface_async(struct usb_interface *intf) -{ } -static inline void usb_autopm_enable(struct usb_interface *intf) -{ } -static inline void usb_autopm_disable(struct usb_interface *intf) -{ } -static inline void usb_mark_last_busy(struct usb_device *udev) -{ } -#endif - -#if (LINUX_VERSION_CODE <= KERNEL_VERSION( 2,6,24 )) - #include "usbnet.h" -#else - #include -#endif - -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 2,6,25 )) - #include -#else - #include -#endif - -// Used in recursion, defined later below -struct sGobiUSBNet; - - -#if defined(QUECTEL_WWAN_QMAP) -#define QUECTEL_UL_DATA_AGG 1 - -#if defined(QUECTEL_UL_DATA_AGG) -struct ul_agg_ctx { - /* QMIWDS_ADMIN_SET_DATA_FORMAT_RESP TLV_0x17 and TLV_0x18 */ - uint ul_data_aggregation_max_datagrams; //UplinkDataAggregationMaxDatagramsTlv - uint ul_data_aggregation_max_size; //UplinkDataAggregationMaxSizeTlv - uint dl_minimum_padding; -}; -#endif -#endif - -/*=========================================================================*/ -// Struct sReadMemList -// -// Structure that defines an entry in a Read Memory linked list -/*=========================================================================*/ -typedef struct sReadMemList -{ - /* Data buffer */ - void * mpData; - - /* Transaction ID */ - u16 mTransactionID; - - /* Size of data buffer */ - u16 mDataSize; - - /* Next entry in linked list */ - struct sReadMemList * mpNext; - -} sReadMemList; - -/*=========================================================================*/ -// Struct sNotifyList -// -// Structure that defines an entry in a Notification linked list -/*=========================================================================*/ -typedef struct sNotifyList -{ - /* Function to be run when data becomes available */ - void (* mpNotifyFunct)(struct sGobiUSBNet *, u16, void *); - - /* Transaction ID */ - u16 mTransactionID; - - /* Data to provide as parameter to mpNotifyFunct */ - void * mpData; - - /* Next entry in linked list */ - struct sNotifyList * mpNext; - -} sNotifyList; - -/*=========================================================================*/ -// Struct sURBList -// -// Structure that defines an entry in a URB linked list -/*=========================================================================*/ -typedef struct sURBList -{ - /* The current URB */ - struct urb * mpURB; - - /* Next entry in linked list */ - struct sURBList * mpNext; - -} sURBList; - -/*=========================================================================*/ -// Struct sClientMemList -// -// Structure that defines an entry in a Client Memory linked list -// Stores data specific to a Service Type and Client ID -/*=========================================================================*/ -typedef struct sClientMemList -{ - /* Client ID for this Client */ - u16 mClientID; - - /* Linked list of Read entries */ - /* Stores data read from device before sending to client */ - sReadMemList * mpList; - - /* Linked list of Notification entries */ - /* Stores notification functions to be run as data becomes - available or the device is removed */ - sNotifyList * mpReadNotifyList; - - /* Linked list of URB entries */ - /* Stores pointers to outstanding URBs which need canceled - when the client is deregistered or the device is removed */ - sURBList * mpURBList; - - /* Next entry in linked list */ - struct sClientMemList * mpNext; - - /* Wait queue object for poll() */ - wait_queue_head_t mWaitQueue; - -} sClientMemList; - -/*=========================================================================*/ -// Struct sURBSetupPacket -// -// Structure that defines a USB Setup packet for Control URBs -// Taken from USB CDC specifications -/*=========================================================================*/ -typedef struct sURBSetupPacket -{ - /* Request type */ - u8 mRequestType; - - /* Request code */ - u8 mRequestCode; - - /* Value */ - u16 mValue; - - /* Index */ - u16 mIndex; - - /* Length of Control URB */ - u16 mLength; - -} sURBSetupPacket; - -// Common value for sURBSetupPacket.mLength -#define DEFAULT_READ_URB_LENGTH 0x1000 - -#ifdef QUECTEL_QMI_MERGE -#define MERGE_PACKET_IDENTITY 0x2c7c -#define MERGE_PACKET_VERSION 0x0001 -#define MERGE_PACKET_MAX_PAYLOAD_SIZE 56 -typedef struct sQMIMsgHeader { - u16 idenity; - u16 version; - u16 cur_len; - u16 total_len; -} sQMIMsgHeader; - -typedef struct sQMIMsgPacket { - sQMIMsgHeader header; - u16 len; - char buf[DEFAULT_READ_URB_LENGTH]; -} sQMIMsgPacket; -#endif - -#ifdef CONFIG_PM -#if (LINUX_VERSION_CODE < KERNEL_VERSION( 2,6,29 )) -/*=========================================================================*/ -// Struct sAutoPM -// -// Structure used to manage AutoPM thread which determines whether the -// device is in use or may enter autosuspend. Also submits net -// transmissions asynchronously. -/*=========================================================================*/ -typedef struct sAutoPM -{ - /* Thread for atomic autopm function */ - struct task_struct * mpThread; - - /* Signal for completion when it's time for the thread to work */ - struct completion mThreadDoWork; - - /* Time to exit? */ - bool mbExit; - - /* List of URB's queued to be sent to the device */ - sURBList * mpURBList; - - /* URB list lock (for adding and removing elements) */ - spinlock_t mURBListLock; - - /* Length of the URB list */ - atomic_t mURBListLen; - - /* Active URB */ - struct urb * mpActiveURB; - - /* Active URB lock (for adding and removing elements) */ - spinlock_t mActiveURBLock; - - /* Duplicate pointer to USB device interface */ - struct usb_interface * mpIntf; - -} sAutoPM; -#endif -#endif /* CONFIG_PM */ - -/*=========================================================================*/ -// Struct sQMIDev -// -// Structure that defines the data for the QMI device -/*=========================================================================*/ -typedef struct sQMIDev -{ - /* Device number */ - dev_t mDevNum; - - /* Device class */ - struct class * mpDevClass; - - /* cdev struct */ - struct cdev mCdev; - - /* is mCdev initialized? */ - bool mbCdevIsInitialized; - - /* Pointer to read URB */ - struct urb * mpReadURB; - -//#define READ_QMI_URB_ERROR -#ifdef READ_QMI_URB_ERROR - struct timer_list mReadUrbTimer; -#endif - -#ifdef QUECTEL_QMI_MERGE - sQMIMsgPacket * mpQmiMsgPacket; -#endif - - /* Read setup packet */ - sURBSetupPacket * mpReadSetupPacket; - - /* Read buffer attached to current read URB */ - void * mpReadBuffer; - - /* Inturrupt URB */ - /* Used to asynchronously notify when read data is available */ - struct urb * mpIntURB; - - /* Buffer used by Inturrupt URB */ - void * mpIntBuffer; - - /* Pointer to memory linked list for all clients */ - sClientMemList * mpClientMemList; - - /* Spinlock for client Memory entries */ - spinlock_t mClientMemLock; - - /* Transaction ID associated with QMICTL "client" */ - atomic_t mQMICTLTransactionID; - -} sQMIDev; - -typedef struct { - u32 qmap_enabled; - u32 dl_data_aggregation_max_datagrams; - u32 dl_data_aggregation_max_size ; - u32 ul_data_aggregation_max_datagrams; - u32 ul_data_aggregation_max_size; - u32 dl_minimum_padding; -} QMAP_SETTING; - -/*=========================================================================*/ -// Struct sGobiUSBNet -// -// Structure that defines the data associated with the Qualcomm USB device -/*=========================================================================*/ -typedef struct sGobiUSBNet -{ - atomic_t refcount; - - /* Net device structure */ - struct usbnet * mpNetDev; -#ifdef QUECTEL_WWAN_QMAP - unsigned link_state; - int qmap_mode; - int qmap_size; - int qmap_version; - struct net_device *mpQmapNetDev[QUECTEL_WWAN_QMAP]; - struct tasklet_struct txq; - - QMAP_SETTING qmap_settings; -#if defined(QUECTEL_UL_DATA_AGG) - struct ul_agg_ctx agg_ctx; -#endif - -#ifdef QUECTEL_BRIDGE_MODE - int m_qmap_bridge_mode[QUECTEL_WWAN_QMAP]; -#endif -#endif - -#if 1 //def DATA_MODE_RP - bool mbMdm9x07; - bool mbMdm9x06; //for BG96 - /* QMI "device" work in IP Mode or ETH Mode */ - bool mbRawIPMode; -#ifdef QUECTEL_BRIDGE_MODE - int m_bridge_mode; - uint m_bridge_ipv4; - unsigned char mHostMAC[6]; -#endif - int m_qcrmcall_mode; -#endif - - struct completion mQMIReadyCompletion; - bool mbQMIReady; - bool mbProbeDone; - bool mbQMISyncIng; - - /* Usb device interface */ - struct usb_interface * mpIntf; - - /* Pointers to usbnet_open and usbnet_stop functions */ - int (* mpUSBNetOpen)(struct net_device *); - int (* mpUSBNetStop)(struct net_device *); - - /* Reason(s) why interface is down */ - /* Used by Gobi*DownReason */ - unsigned long mDownReason; -#define NO_NDIS_CONNECTION 0 -#define CDC_CONNECTION_SPEED 1 -#define DRIVER_SUSPENDED 2 -#define NET_IFACE_STOPPED 3 - - /* QMI "device" status */ - bool mbQMIValid; - - bool mbDeregisterQMIDevice; - - /* QMI "device" memory */ - sQMIDev mQMIDev; - - /* Device MEID */ - char mMEID[14]; - struct hrtimer timer; - struct tasklet_struct bh; - unsigned long - pending_num : 8, - pending_size : 16; - struct sk_buff *pending_pool[16]; - -#ifdef CONFIG_PM - #if (LINUX_VERSION_CODE < KERNEL_VERSION( 2,6,29 )) - /* AutoPM thread */ - sAutoPM mAutoPM; -#endif -#endif /* CONFIG_PM */ -} sGobiUSBNet; - -/*=========================================================================*/ -// Struct sQMIFilpStorage -// -// Structure that defines the storage each file handle contains -// Relates the file handle to a client -/*=========================================================================*/ -typedef struct sQMIFilpStorage -{ - /* Client ID */ - u16 mClientID; - - /* Device pointer */ - sGobiUSBNet * mpDev; - -} sQMIFilpStorage; - diff --git a/quectel_MHI/Makefile b/quectel_MHI/Makefile deleted file mode 100644 index 6322519..0000000 --- a/quectel_MHI/Makefile +++ /dev/null @@ -1,47 +0,0 @@ -# -# Copyright (C) 2015 OpenWrt.org -# -# This is free software, licensed under the GNU General Public License v2. -# See /LICENSE for more information. -# - -include $(TOPDIR)/rules.mk - -PKG_NAME:=pcie_mhi -PKG_VERSION:=1.3.6 -PKG_RELEASE:=1 - -include $(INCLUDE_DIR)/kernel.mk -include $(INCLUDE_DIR)/package.mk - -define KernelPackage/pcie_mhi - SUBMENU:=WWAN Support - TITLE:=Kernel pcie driver for MHI device - DEPENDS:=+pciids +pciutils +quectel-CM-5G - FILES:=$(PKG_BUILD_DIR)/pcie_mhi.ko - AUTOLOAD:=$(call AutoLoad,90,pcie_mhi) -endef - -define KernelPackage/pcie_mhi/description - Kernel module for register a custom pciemhi platform device. -endef - -MAKE_OPTS:= \ - ARCH="$(LINUX_KARCH)" \ - CROSS_COMPILE="$(TARGET_CROSS)" \ - CXXFLAGS="$(TARGET_CXXFLAGS)" \ - M="$(PKG_BUILD_DIR)" \ - $(EXTRA_KCONFIG) - -define Build/Prepare - mkdir -p $(PKG_BUILD_DIR) - $(CP) ./src/* $(PKG_BUILD_DIR)/ -endef - -define Build/Compile - $(MAKE) -C "$(LINUX_DIR)" \ - $(MAKE_OPTS) \ - modules -endef - -$(eval $(call KernelPackage,pcie_mhi)) diff --git a/quectel_MHI/src/Makefile b/quectel_MHI/src/Makefile deleted file mode 100644 index 1b2c1f5..0000000 --- a/quectel_MHI/src/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -#ccflags-y += -g -obj-m += pcie_mhi.o -pcie_mhi-objs := core/mhi_init.o core/mhi_main.o core/mhi_pm.o core/mhi_boot.o core/mhi_dtr.o controllers/mhi_qti.o -pcie_mhi-objs += devices/mhi_uci.o - -ifeq (1,1) -pcie_mhi-objs += devices/mhi_netdev_quectel.o -else -pcie_mhi-objs += devices/mhi_netdev.o -pcie_mhi-objs += devices/rmnet_handler.o -endif - -PWD := $(shell pwd) -ifeq ($(ARCH),) -ARCH := $(shell uname -m) -endif -ifeq ($(CROSS_COMPILE),) -CROSS_COMPILE := -endif -ifeq ($(KDIR),) -KDIR := /lib/modules/$(shell uname -r)/build -endif - -pcie_mhi: clean - $(MAKE) ARCH=${ARCH} CROSS_COMPILE=${CROSS_COMPILE} -C $(KDIR) M=$(PWD) modules - #cp pcie_mhi.ko /tftpboot/ - -clean: - $(MAKE) ARCH=${ARCH} CROSS_COMPILE=${CROSS_COMPILE} -C $(KDIR) M=$(PWD) clean - find . -name *.o.ur-safe | xargs rm -f - -install: pcie_mhi - sudo cp pcie_mhi.ko /lib/modules/${shell uname -r}/kernel/drivers/pci/ - sudo depmod diff --git a/quectel_MHI/src/README b/quectel_MHI/src/README deleted file mode 100644 index 927df0c..0000000 --- a/quectel_MHI/src/README +++ /dev/null @@ -1,36 +0,0 @@ -1. porting pcie_mhi driver as next - -$ git diff drivers/Makefile -diff --git a/drivers/Makefile b/drivers/Makefile -index 77fbc52..e45837e 100644 ---- a/drivers/Makefile -+++ b/drivers/Makefile -@@ -184,3 +184,4 @@ obj-$(CONFIG_FPGA) += fpga/ - obj-$(CONFIG_FSI) += fsi/ - obj-$(CONFIG_TEE) += tee/ - obj-$(CONFIG_MULTIPLEXER) += mux/ -+obj-y += pcie_mhi/ - -$ tree drivers/pcie_mhi/ -L 1 -drivers/pcie_mhi/ - controllers - core - devices - Makefile - -2. check RG500 attach pcie_mhi driver successful - -root@OpenWrt:/# lspci -00:00.0 Class 0604: 17cb:0302 -01:00.0 Class ff00: 17cb:0306 - -root@OpenWrt:~# dmesg | grep mhi -[ 138.483252] mhi_init Quectel_Linux_PCIE_MHI_Driver_V1.3.0.6 -[ 138.492350] mhi_pci_probe pci_dev->name = 0000:01:00.0, domain=0, bus=1, slot=0, vendor=17CB, device=0306 - -3. how to use, see next logs - -log/QXDM_OVER_PCIE.txt -log/AT_OVER_PCIE.txt -log/MBIM_OVER_PCIE.txt -log/QMI_OVER_PCIE.txt diff --git a/quectel_MHI/src/ReleaseNote.txt b/quectel_MHI/src/ReleaseNote.txt deleted file mode 100644 index f70e45c..0000000 --- a/quectel_MHI/src/ReleaseNote.txt +++ /dev/null @@ -1,103 +0,0 @@ -Release Notes - -[V1.3.4] -Date: 12/8/2022 -enhancement: - 1. only allow to enable autosuspend when module is in MHI_EE_AMSS - 2. show pcie link speed and width when driver probe - 3. check pcie link status by read pcie vid and pid when driver probe, - if pcie link is down, return -EIO - 4. support RM520 (1eac:1004) - 5. support qmap command packet -fix: - 1. fix tx queue is wrong stop when do uplink TPUT - 2. fix after QFirehose, module fail to bootup at very small probability - 3. mhi uci add mutex lock for concurrent reads/writes - -[V1.3.3] -Date: 30/6/2022 -enhancement: - 1. remove one un-necessary kmalloc when do qfirehose - 2. support mhi monitor (like usbmon), usage: cat /sys/kernel/debug/mhi_q/0306_00\:01.00/mhimon - 3. set ring size of event 0 to 256 (from 1024), required by x6x - 4. support PCIE local network card mhi_swip0 (chan 46/47), default disabled - 5. porting IPQ5018 mhi rate controll code from spf11.5 - 6. set pcie rmnet download max qmap packet size to 15KB (same to IPQ MHI Driver) - 7. support set different mac address for rmnet net card - 8. when mhi netdev fail to malloc, use delay_work instead work - 9. optimize code for 'when driver load, modem is still in MHI_EE_PTHRU' -fix: - 1. Fix not synchronize access rp/wp when mhi_queue_xxx and mhi_process_xxx_ring run on different CPU - 2. set dma mask when driver probe, some SOC like rpi_4 need it - -[V1.3.2] -Date: 12/16/2021 -enhancement: - 1. support Linux Kernel V5.14 - 2. mhi_netdev_quectel.c do not print log in softirq context - -[V1.3.1] -Date: 9/26/2021 -enhancement: -fix: - -[V1.3.0.19] -Date: 9/18/2021 -enhancement: - 1. support sdx62 (17cb:0308) - 2. support IPQ5018's NSS - 3. use 'qsdk/qca/src/data-kernel/drivers/rmnet-nss/rmnet_nss.c' instead myself rmnet_nss.c - and pcie_mhi.ko must load after then rmnet_nss.ko - 4. allow bhi irq is not 0 (for ipq5018) -fix: - -[V1.3.0.18] -Date: 4/14/2021 -enhancement: - 1. support mbim multiple call, usage: - # insmod pcie_mhi.ko mhi_mbim_enabeld=1 qmap_mode=4 - # quectel-mbim-proxy -d /dev/mhi_MBIM & - # quectel-CM -n X -fix: - -[V1.3.0.17] -Date: 3/11/2021 -enhancement: -fix: - 1. fix CPU loading very high when TPUT test when only one MSI interrupt - 2. fix error on latest X24 modem - -[V1.3.0.16] -Date: 11/18/2020 -enhancement: -fix: - 1. add ring size to 32, for in-bound chan, if one ring is full, modem will not generate MSI interrupt for all chan - -[V1.3.0.15] -Date: 10/30/2020 -enhancement: - 1. support multi-modems, named as /dev/mhi_X -fix: - 1. fix compile error on kernel v5.8 - -[V1.3.0.14] -Date: 10/9/2020 -enhancement: - 1. suppport EM120&EM160 -fix: - 1. fix compile error on kernel v5.6 - 2. support runtime suspend - -[V1.3.0.13] -Date: 9/7/2020 -enhancement: - 1. suppport EM120&EM160 -fix: - 1. fix error on X55 + PCIE2.0(e.g IPQ4019) - 2. support runtime suspend - -[V1.3.0.12] -Date: 7/7/2020 -enhancement: - 1. suppport create only none netcard (enabled by marco MHI_NETDEV_ONE_CARD_MODE), -fix: \ No newline at end of file diff --git a/quectel_MHI/src/controllers/Kconfig b/quectel_MHI/src/controllers/Kconfig deleted file mode 100644 index e18b38b..0000000 --- a/quectel_MHI/src/controllers/Kconfig +++ /dev/null @@ -1,13 +0,0 @@ -menu "MHI controllers" - -config MHI_QTI - tristate "MHI QTI" - depends on MHI_BUS - help - If you say yes to this option, MHI bus support for QTI modem chipsets - will be enabled. QTI PCIe based modems uses MHI as the communication - protocol. MHI control driver is the bus master for such modems. As the - bus master driver, it oversees power management operations such as - suspend, resume, powering on and off the device. - -endmenu diff --git a/quectel_MHI/src/controllers/Makefile b/quectel_MHI/src/controllers/Makefile deleted file mode 100644 index ab9ec55..0000000 --- a/quectel_MHI/src/controllers/Makefile +++ /dev/null @@ -1 +0,0 @@ -obj-$(CONFIG_MHI_QTI) += mhi_qti.o mhi_arch_qti.o diff --git a/quectel_MHI/src/controllers/mhi_arch_qti.c b/quectel_MHI/src/controllers/mhi_arch_qti.c deleted file mode 100644 index de19d94..0000000 --- a/quectel_MHI/src/controllers/mhi_arch_qti.c +++ /dev/null @@ -1,275 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "../core/mhi.h" -#include "mhi_qti.h" - -struct arch_info { - struct mhi_dev *mhi_dev; - struct msm_bus_scale_pdata *msm_bus_pdata; - u32 bus_client; - struct pci_saved_state *pcie_state; - struct pci_saved_state *ref_pcie_state; - struct dma_iommu_mapping *mapping; -}; - -struct mhi_bl_info { - struct mhi_device *mhi_device; - async_cookie_t cookie; - void *ipc_log; -}; - -/* ipc log markings */ -#define DLOG "Dev->Host: " -#define HLOG "Host: " - -#ifdef CONFIG_MHI_DEBUG - -#define MHI_IPC_LOG_PAGES (100) -enum MHI_DEBUG_LEVEL mhi_ipc_log_lvl = MHI_MSG_LVL_VERBOSE; - -#else - -#define MHI_IPC_LOG_PAGES (10) -enum MHI_DEBUG_LEVEL mhi_ipc_log_lvl = MHI_MSG_LVL_ERROR; - -#endif - -static int mhi_arch_set_bus_request(struct mhi_controller *mhi_cntrl, int index) -{ - struct mhi_dev *mhi_dev = mhi_controller_get_devdata(mhi_cntrl); - struct arch_info *arch_info = mhi_dev->arch_info; - - MHI_LOG("Setting bus request to index %d\n", index); - - if (arch_info->bus_client) - return msm_bus_scale_client_update_request( - arch_info->bus_client, - index); - - /* default return success */ - return 0; -} - -static void mhi_bl_dl_cb(struct mhi_device *mhi_dev, - struct mhi_result *mhi_result) -{ - struct mhi_bl_info *mhi_bl_info = mhi_device_get_devdata(mhi_dev); - char *buf = mhi_result->buf_addr; - - /* force a null at last character */ - buf[mhi_result->bytes_xferd - 1] = 0; - - ipc_log_string(mhi_bl_info->ipc_log, "%s %s", DLOG, buf); -} - -static void mhi_bl_dummy_cb(struct mhi_device *mhi_dev, - struct mhi_result *mhi_result) -{ -} - -static void mhi_bl_remove(struct mhi_device *mhi_dev) -{ - struct mhi_bl_info *mhi_bl_info = mhi_device_get_devdata(mhi_dev); - - ipc_log_string(mhi_bl_info->ipc_log, HLOG "Received Remove notif.\n"); - - /* wait for boot monitor to exit */ - async_synchronize_cookie(mhi_bl_info->cookie + 1); -} - -static void mhi_bl_boot_monitor(void *data, async_cookie_t cookie) -{ - struct mhi_bl_info *mhi_bl_info = data; - struct mhi_device *mhi_device = mhi_bl_info->mhi_device; - struct mhi_controller *mhi_cntrl = mhi_device->mhi_cntrl; - /* 15 sec timeout for booting device */ - const u32 timeout = msecs_to_jiffies(15000); - - /* wait for device to enter boot stage */ - wait_event_timeout(mhi_cntrl->state_event, mhi_cntrl->ee == MHI_EE_AMSS - || mhi_cntrl->ee == MHI_EE_DISABLE_TRANSITION, - timeout); - - if (mhi_cntrl->ee == MHI_EE_AMSS) { - ipc_log_string(mhi_bl_info->ipc_log, HLOG - "Device successfully booted to mission mode\n"); - - mhi_unprepare_from_transfer(mhi_device); - } else { - ipc_log_string(mhi_bl_info->ipc_log, HLOG - "Device failed to boot to mission mode, ee = %s\n", - TO_MHI_EXEC_STR(mhi_cntrl->ee)); - } -} - -static int mhi_bl_probe(struct mhi_device *mhi_dev, - const struct mhi_device_id *id) -{ - char node_name[32]; - struct mhi_bl_info *mhi_bl_info; - - mhi_bl_info = devm_kzalloc(&mhi_dev->dev, sizeof(*mhi_bl_info), - GFP_KERNEL); - if (!mhi_bl_info) - return -ENOMEM; - - snprintf(node_name, sizeof(node_name), "mhi_bl_%04x_%02u.%02u.%02u", - mhi_dev->dev_id, mhi_dev->domain, mhi_dev->bus, mhi_dev->slot); - - mhi_bl_info->ipc_log = ipc_log_context_create(MHI_IPC_LOG_PAGES, - node_name, 0); - if (!mhi_bl_info->ipc_log) - return -EINVAL; - - mhi_bl_info->mhi_device = mhi_dev; - mhi_device_set_devdata(mhi_dev, mhi_bl_info); - - ipc_log_string(mhi_bl_info->ipc_log, HLOG - "Entered SBL, Session ID:0x%x\n", - mhi_dev->mhi_cntrl->session_id); - - /* start a thread to monitor entering mission mode */ - mhi_bl_info->cookie = async_schedule(mhi_bl_boot_monitor, mhi_bl_info); - - return 0; -} - -static const struct mhi_device_id mhi_bl_match_table[] = { - { .chan = "BL" }, - {}, -}; - -static struct mhi_driver mhi_bl_driver = { - .id_table = mhi_bl_match_table, - .remove = mhi_bl_remove, - .probe = mhi_bl_probe, - .ul_xfer_cb = mhi_bl_dummy_cb, - .dl_xfer_cb = mhi_bl_dl_cb, - .driver = { - .name = "MHI_BL", - .owner = THIS_MODULE, - }, -}; - -int mhi_arch_pcie_init(struct mhi_controller *mhi_cntrl) -{ - struct mhi_dev *mhi_dev = mhi_controller_get_devdata(mhi_cntrl); - struct arch_info *arch_info = mhi_dev->arch_info; - char node[32]; - - if (!arch_info) { - arch_info = devm_kzalloc(&mhi_dev->pci_dev->dev, - sizeof(*arch_info), GFP_KERNEL); - if (!arch_info) - return -ENOMEM; - - mhi_dev->arch_info = arch_info; - - snprintf(node, sizeof(node), "mhi_%04x_%02u.%02u.%02u", - mhi_cntrl->dev_id, mhi_cntrl->domain, mhi_cntrl->bus, - mhi_cntrl->slot); - mhi_cntrl->log_buf = ipc_log_context_create(MHI_IPC_LOG_PAGES, - node, 0); - mhi_cntrl->log_lvl = mhi_ipc_log_lvl; - - /* save reference state for pcie config space */ - arch_info->ref_pcie_state = pci_store_saved_state( - mhi_dev->pci_dev); - - mhi_driver_register(&mhi_bl_driver); - } - - return mhi_arch_set_bus_request(mhi_cntrl, 1); -} - -void mhi_arch_pcie_deinit(struct mhi_controller *mhi_cntrl) -{ - mhi_arch_set_bus_request(mhi_cntrl, 0); -} - -int mhi_arch_link_off(struct mhi_controller *mhi_cntrl, bool graceful) -{ - struct mhi_dev *mhi_dev = mhi_controller_get_devdata(mhi_cntrl); - struct arch_info *arch_info = mhi_dev->arch_info; - struct pci_dev *pci_dev = mhi_dev->pci_dev; - int ret; - - MHI_LOG("Entered\n"); - - if (graceful) { - pci_clear_master(pci_dev); - ret = pci_save_state(mhi_dev->pci_dev); - if (ret) { - MHI_ERR("Failed with pci_save_state, ret:%d\n", ret); - return ret; - } - - arch_info->pcie_state = pci_store_saved_state(pci_dev); - pci_disable_device(pci_dev); - } - - /* - * We will always attempt to put link into D3hot, however - * link down may have happened due to error fatal, so - * ignoring the return code - */ - pci_set_power_state(pci_dev, PCI_D3hot); - - /* release the resources */ - mhi_arch_set_bus_request(mhi_cntrl, 0); - - MHI_LOG("Exited\n"); - - return 0; -} - -int mhi_arch_link_on(struct mhi_controller *mhi_cntrl) -{ - struct mhi_dev *mhi_dev = mhi_controller_get_devdata(mhi_cntrl); - struct arch_info *arch_info = mhi_dev->arch_info; - struct pci_dev *pci_dev = mhi_dev->pci_dev; - int ret; - - MHI_LOG("Entered\n"); - - /* request resources and establish link trainning */ - ret = mhi_arch_set_bus_request(mhi_cntrl, 1); - if (ret) - MHI_LOG("Could not set bus frequency, ret:%d\n", ret); - - ret = pci_set_power_state(pci_dev, PCI_D0); - if (ret) { - MHI_ERR("Failed to set PCI_D0 state, ret:%d\n", ret); - return ret; - } - - ret = pci_enable_device(pci_dev); - if (ret) { - MHI_ERR("Failed to enable device, ret:%d\n", ret); - return ret; - } - - ret = pci_load_and_free_saved_state(pci_dev, &arch_info->pcie_state); - if (ret) - MHI_LOG("Failed to load saved cfg state\n"); - - pci_restore_state(pci_dev); - pci_set_master(pci_dev); - - MHI_LOG("Exited\n"); - - return 0; -} diff --git a/quectel_MHI/src/controllers/mhi_qcom.c b/quectel_MHI/src/controllers/mhi_qcom.c deleted file mode 100644 index 70dd917..0000000 --- a/quectel_MHI/src/controllers/mhi_qcom.c +++ /dev/null @@ -1,715 +0,0 @@ -/* Copyright (c) 2018, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "../core/mhi.h" -#include "mhi_qcom.h" - -#if 1 -#ifndef PCI_IRQ_MSI -#define PCI_IRQ_MSI (1 << 1) /* Allow MSI interrupts */ - -#if (LINUX_VERSION_CODE < KERNEL_VERSION( 3,10,53 )) -int pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec) -{ - int nvec = maxvec; - int rc; - - if (maxvec < minvec) - return -ERANGE; - - do { - rc = pci_enable_msi_block(dev, nvec); - if (rc < 0) { - return rc; - } else if (rc > 0) { - if (rc < minvec) - return -ENOSPC; - nvec = rc; - } - } while (rc); - - return nvec; -} -#endif - -static int pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs, - unsigned int max_vecs, unsigned int flags) -{ - return pci_enable_msi_range(dev, min_vecs, max_vecs); -} - -static void pci_free_irq_vectors(struct pci_dev *dev) -{ - pci_disable_msi(dev); -} - -static int pci_irq_vector(struct pci_dev *dev, unsigned int nr) -{ - return dev->irq + nr; -} -#endif -#endif - -static struct pci_device_id mhi_pcie_device_id[] = { - {PCI_DEVICE(MHI_PCIE_VENDOR_ID, 0x0303)}, //SDX20 - {PCI_DEVICE(MHI_PCIE_VENDOR_ID, 0x0304)}, //SDX24 - {PCI_DEVICE(MHI_PCIE_VENDOR_ID, 0x0305)}, - {PCI_DEVICE(MHI_PCIE_VENDOR_ID, 0x0306)}, //SDX55 - {PCI_DEVICE(0x2C7C, 0x0512)}, - {PCI_DEVICE(MHI_PCIE_VENDOR_ID, MHI_PCIE_DEBUG_ID)}, - {0}, -}; - -MODULE_DEVICE_TABLE(pci, mhi_pcie_device_id); - -static struct pci_driver mhi_pcie_driver; - -void mhi_deinit_pci_dev(struct mhi_controller *mhi_cntrl) -{ - struct mhi_dev *mhi_dev = mhi_controller_get_devdata(mhi_cntrl); - struct pci_dev *pci_dev = mhi_dev->pci_dev; - - pci_free_irq_vectors(pci_dev); - iounmap(mhi_cntrl->regs); - mhi_cntrl->regs = NULL; - pci_clear_master(pci_dev); - pci_release_region(pci_dev, mhi_dev->resn); - pci_disable_device(pci_dev); -} - -static int mhi_init_pci_dev(struct mhi_controller *mhi_cntrl) -{ - struct mhi_dev *mhi_dev = mhi_controller_get_devdata(mhi_cntrl); - struct pci_dev *pci_dev = mhi_dev->pci_dev; - int ret; - resource_size_t start, len; - int i; - - mhi_dev->resn = MHI_PCI_BAR_NUM; - ret = pci_assign_resource(pci_dev, mhi_dev->resn); - if (ret) { - MHI_ERR("Error assign pci resources, ret:%d\n", ret); - return ret; - } - - ret = pci_enable_device(pci_dev); - if (ret) { - MHI_ERR("Error enabling device, ret:%d\n", ret); - goto error_enable_device; - } - - ret = pci_request_region(pci_dev, mhi_dev->resn, "mhi"); - if (ret) { - MHI_ERR("Error pci_request_region, ret:%d\n", ret); - goto error_request_region; - } - - pci_set_master(pci_dev); - - start = pci_resource_start(pci_dev, mhi_dev->resn); - len = pci_resource_len(pci_dev, mhi_dev->resn); - mhi_cntrl->regs = ioremap_nocache(start, len); - MHI_LOG("mhi_cntrl->regs = %p\n", mhi_cntrl->regs); - if (!mhi_cntrl->regs) { - MHI_ERR("Error ioremap region\n"); - goto error_ioremap; - } - - ret = pci_alloc_irq_vectors(pci_dev, 1, mhi_cntrl->msi_required, PCI_IRQ_MSI); - if (IS_ERR_VALUE((ulong)ret) || ret < mhi_cntrl->msi_required) { - if (ret == -ENOSPC) { - /* imx_3.14.52_1.1.0_ga - diff --git a/drivers/pci/host/pcie-designware.c b/drivers/pci/host/pcie-designware.c - index f06e8f0..6a9614f 100644 - --- a/drivers/pci/host/pcie-designware.c - +++ b/drivers/pci/host/pcie-designware.c - @@ -376,6 +376,13 @@ static int dw_msi_setup_irq(struct msi_chip *chip, struct pci_dev *pdev, - if (msgvec > 5) - msgvec = 0; - - +#if 1 //Add by Quectel 20190419 - + if (msgvec > 0 && pdev->vendor == 0x17cb) { - + dev_info(&pdev->dev, "%s quectel fixup pos=%d, msg_ctr=%04x, msgvec=%d\n", __func__, desc->msi_attrib.pos, msg_ctr, msgvec); - + msgvec = 0; - + } - +#endif - + - irq = assign_irq((1 << msgvec), desc, &pos); - if (irq < 0) - return irq; - */ - } - //imx_4.1.15_2.0.0_ga & DELL_OPTIPLEX_7010 only alloc one msi interrupt for one pcie device - if (ret != 1) { - MHI_ERR("Failed to enable MSI, ret=%d, msi_required=%d\n", ret, mhi_cntrl->msi_required); - goto error_req_msi; - } - } - - mhi_cntrl->msi_allocated = ret; - MHI_LOG("msi_required = %d, msi_allocated = %d, msi_irq = %u\n", mhi_cntrl->msi_required, mhi_cntrl->msi_allocated, pci_dev->irq); - - for (i = 0; i < mhi_cntrl->msi_allocated; i++) { - mhi_cntrl->irq[i] = pci_irq_vector(pci_dev, i); - if (mhi_cntrl->irq[i] < 0) { - ret = mhi_cntrl->irq[i]; - goto error_get_irq_vec; - } - } - -#if 0 - /* configure runtime pm */ - pm_runtime_set_autosuspend_delay(&pci_dev->dev, MHI_RPM_SUSPEND_TMR_MS); - pm_runtime_dont_use_autosuspend(&pci_dev->dev); - pm_suspend_ignore_children(&pci_dev->dev, true); - - /* - * pci framework will increment usage count (twice) before - * calling local device driver probe function. - * 1st pci.c pci_pm_init() calls pm_runtime_forbid - * 2nd pci-driver.c local_pci_probe calls pm_runtime_get_sync - * Framework expect pci device driver to call - * pm_runtime_put_noidle to decrement usage count after - * successful probe and and call pm_runtime_allow to enable - * runtime suspend. - */ - pm_runtime_mark_last_busy(&pci_dev->dev); - pm_runtime_put_noidle(&pci_dev->dev); -#endif - - return 0; - -error_get_irq_vec: - pci_free_irq_vectors(pci_dev); - -error_req_msi: - iounmap(mhi_cntrl->regs); - -error_ioremap: - pci_clear_master(pci_dev); - -error_request_region: - pci_disable_device(pci_dev); - -error_enable_device: - pci_release_region(pci_dev, mhi_dev->resn); - - return ret; -} - -#ifdef CONFIG_PM -static int mhi_runtime_idle(struct device *dev) -{ - struct mhi_controller *mhi_cntrl = dev_get_drvdata(dev); - - MHI_LOG("Entered returning -EBUSY\n"); - - /* - * RPM framework during runtime resume always calls - * rpm_idle to see if device ready to suspend. - * If dev.power usage_count count is 0, rpm fw will call - * rpm_idle cb to see if device is ready to suspend. - * if cb return 0, or cb not defined the framework will - * assume device driver is ready to suspend; - * therefore, fw will schedule runtime suspend. - * In MHI power management, MHI host shall go to - * runtime suspend only after entering MHI State M2, even if - * usage count is 0. Return -EBUSY to disable automatic suspend. - */ - return -EBUSY; -} - -static int mhi_runtime_suspend(struct device *dev) -{ - int ret = 0; - struct mhi_controller *mhi_cntrl = dev_get_drvdata(dev); - - MHI_LOG("Enter\n"); - - mutex_lock(&mhi_cntrl->pm_mutex); - - ret = mhi_pm_suspend(mhi_cntrl); - if (ret) { - MHI_LOG("Abort due to ret:%d\n", ret); - goto exit_runtime_suspend; - } - - ret = mhi_arch_link_off(mhi_cntrl, true); - if (ret) - MHI_ERR("Failed to Turn off link ret:%d\n", ret); - -exit_runtime_suspend: - mutex_unlock(&mhi_cntrl->pm_mutex); - MHI_LOG("Exited with ret:%d\n", ret); - - return ret; -} - -static int mhi_runtime_resume(struct device *dev) -{ - int ret = 0; - struct mhi_controller *mhi_cntrl = dev_get_drvdata(dev); - struct mhi_dev *mhi_dev = mhi_controller_get_devdata(mhi_cntrl); - - MHI_LOG("Enter\n"); - - mutex_lock(&mhi_cntrl->pm_mutex); - - if (!mhi_dev->powered_on) { - MHI_LOG("Not fully powered, return success\n"); - mutex_unlock(&mhi_cntrl->pm_mutex); - return 0; - } - - /* turn on link */ - ret = mhi_arch_link_on(mhi_cntrl); - if (ret) - goto rpm_resume_exit; - - /* enter M0 state */ - ret = mhi_pm_resume(mhi_cntrl); - -rpm_resume_exit: - mutex_unlock(&mhi_cntrl->pm_mutex); - MHI_LOG("Exited with :%d\n", ret); - - return ret; -} - -static int mhi_system_resume(struct device *dev) -{ - int ret = 0; - struct mhi_controller *mhi_cntrl = dev_get_drvdata(dev); - - ret = mhi_runtime_resume(dev); - if (ret) { - MHI_ERR("Failed to resume link\n"); - } else { - pm_runtime_set_active(dev); - pm_runtime_enable(dev); - } - - return ret; -} - -int mhi_system_suspend(struct device *dev) -{ - struct mhi_controller *mhi_cntrl = dev_get_drvdata(dev); - - MHI_LOG("Entered\n"); - - /* if rpm status still active then force suspend */ - if (!pm_runtime_status_suspended(dev)) - return mhi_runtime_suspend(dev); - - pm_runtime_set_suspended(dev); - pm_runtime_disable(dev); - - MHI_LOG("Exit\n"); - return 0; -} -#endif - -/* checks if link is down */ -static int mhi_link_status(struct mhi_controller *mhi_cntrl, void *priv) -{ - struct mhi_dev *mhi_dev = priv; - u16 dev_id; - int ret; - - /* try reading device id, if dev id don't match, link is down */ - ret = pci_read_config_word(mhi_dev->pci_dev, PCI_DEVICE_ID, &dev_id); - - return (ret || dev_id != mhi_cntrl->dev_id) ? -EIO : 0; -} - -static int mhi_runtime_get(struct mhi_controller *mhi_cntrl, void *priv) -{ - struct mhi_dev *mhi_dev = priv; - struct device *dev = &mhi_dev->pci_dev->dev; - - return pm_runtime_get(dev); -} - -static void mhi_runtime_put(struct mhi_controller *mhi_cntrl, void *priv) -{ - struct mhi_dev *mhi_dev = priv; - struct device *dev = &mhi_dev->pci_dev->dev; - - pm_runtime_put_noidle(dev); -} - -static void mhi_status_cb(struct mhi_controller *mhi_cntrl, - void *priv, - enum MHI_CB reason) -{ - struct mhi_dev *mhi_dev = priv; - struct device *dev = &mhi_dev->pci_dev->dev; - - if (reason == MHI_CB_IDLE) { - MHI_LOG("Schedule runtime suspend 1\n"); - pm_runtime_mark_last_busy(dev); - pm_request_autosuspend(dev); - } -} - -int mhi_debugfs_trigger_m0(void *data, u64 val) -{ - struct mhi_controller *mhi_cntrl = data; - struct mhi_dev *mhi_dev = mhi_controller_get_devdata(mhi_cntrl); - - MHI_LOG("Trigger M3 Exit\n"); - pm_runtime_get(&mhi_dev->pci_dev->dev); - pm_runtime_put(&mhi_dev->pci_dev->dev); - - return 0; -} - -int mhi_debugfs_trigger_m3(void *data, u64 val) -{ - struct mhi_controller *mhi_cntrl = data; - struct mhi_dev *mhi_dev = mhi_controller_get_devdata(mhi_cntrl); - - MHI_LOG("Trigger M3 Entry\n"); - pm_runtime_mark_last_busy(&mhi_dev->pci_dev->dev); - pm_request_autosuspend(&mhi_dev->pci_dev->dev); - - return 0; -} - -DEFINE_SIMPLE_ATTRIBUTE(debugfs_trigger_m0_fops, NULL, - mhi_debugfs_trigger_m0, "%llu\n"); - -DEFINE_SIMPLE_ATTRIBUTE(debugfs_trigger_m3_fops, NULL, - mhi_debugfs_trigger_m3, "%llu\n"); - -static int mhi_init_debugfs_trigger_go(void *data, u64 val) -{ - struct mhi_controller *mhi_cntrl = data; - - MHI_LOG("Trigger power up sequence\n"); - - mhi_async_power_up(mhi_cntrl); - - return 0; -} -DEFINE_SIMPLE_ATTRIBUTE(mhi_init_debugfs_trigger_go_fops, NULL, - mhi_init_debugfs_trigger_go, "%llu\n"); - - -int mhi_init_debugfs_debug_show(struct seq_file *m, void *d) -{ - seq_puts(m, "Enable debug mode to debug external soc\n"); - seq_puts(m, - "Usage: echo 'devid,timeout,domain,smmu_cfg' > debug_mode\n"); - seq_puts(m, "No spaces between parameters\n"); - seq_puts(m, "\t1. devid : 0 or pci device id to register\n"); - seq_puts(m, "\t2. timeout: mhi cmd/state transition timeout\n"); - seq_puts(m, "\t3. domain: Rootcomplex\n"); - seq_puts(m, "\t4. smmu_cfg: smmu configuration mask:\n"); - seq_puts(m, "\t\t- BIT0: ATTACH\n"); - seq_puts(m, "\t\t- BIT1: S1 BYPASS\n"); - seq_puts(m, "\t\t-BIT2: FAST_MAP\n"); - seq_puts(m, "\t\t-BIT3: ATOMIC\n"); - seq_puts(m, "\t\t-BIT4: FORCE_COHERENT\n"); - seq_puts(m, "\t\t-BIT5: GEOMETRY\n"); - seq_puts(m, "\tAll timeout are in ms, enter 0 to keep default\n"); - seq_puts(m, "Examples inputs: '0x307,10000'\n"); - seq_puts(m, "\techo '0,10000,1'\n"); - seq_puts(m, "\techo '0x307,10000,0,0x3d'\n"); - seq_puts(m, "firmware image name will be changed to debug.mbn\n"); - - return 0; -} - -static int mhi_init_debugfs_debug_open(struct inode *node, struct file *file) -{ - return single_open(file, mhi_init_debugfs_debug_show, NULL); -} - -static ssize_t mhi_init_debugfs_debug_write(struct file *fp, - const char __user *ubuf, - size_t count, - loff_t *pos) -{ - char *buf = kmalloc(count + 1, GFP_KERNEL); - /* #,devid,timeout,domain,smmu-cfg */ - int args[5] = {0}; - static char const *dbg_fw = "debug.mbn"; - int ret; - struct mhi_controller *mhi_cntrl = fp->f_inode->i_private; - struct mhi_dev *mhi_dev = mhi_controller_get_devdata(mhi_cntrl); - struct pci_device_id *id; - - if (!buf) - return -ENOMEM; - - ret = copy_from_user(buf, ubuf, count); - if (ret) - goto error_read; - buf[count] = 0; - get_options(buf, ARRAY_SIZE(args), args); - kfree(buf); - - /* override default parameters */ - mhi_cntrl->fw_image = dbg_fw; - mhi_cntrl->edl_image = dbg_fw; - - if (args[0] >= 2 && args[2]) - mhi_cntrl->timeout_ms = args[2]; - - if (args[0] >= 3 && args[3]) - mhi_cntrl->domain = args[3]; - - if (args[0] >= 4 && args[4]) - mhi_dev->smmu_cfg = args[4]; - - /* If it's a new device id register it */ - if (args[0] && args[1]) { - /* find the debug_id and overwrite it */ - for (id = mhi_pcie_device_id; id->vendor; id++) - if (id->device == MHI_PCIE_DEBUG_ID) { - id->device = args[1]; - pci_unregister_driver(&mhi_pcie_driver); - ret = pci_register_driver(&mhi_pcie_driver); - } - } - - mhi_dev->debug_mode = true; - debugfs_create_file("go", 0444, mhi_cntrl->parent, mhi_cntrl, - &mhi_init_debugfs_trigger_go_fops); - pr_info( - "%s: ret:%d pcidev:0x%x smm_cfg:%u timeout:%u\n", - __func__, ret, args[1], mhi_dev->smmu_cfg, - mhi_cntrl->timeout_ms); - return count; - -error_read: - kfree(buf); - return ret; -} - -static const struct file_operations debugfs_debug_ops = { - .open = mhi_init_debugfs_debug_open, - .release = single_release, - .read = seq_read, - .write = mhi_init_debugfs_debug_write, -}; - -static struct mhi_controller * mhi_platform_probe(struct pci_dev *pci_dev) -{ - struct mhi_controller *mhi_cntrl; - struct mhi_dev *mhi_dev; - u64 addr_win[2]; - int ret; - - mhi_cntrl = mhi_alloc_controller(sizeof(*mhi_dev)); - if (!mhi_cntrl) { - pr_err("mhi_alloc_controller fail\n"); - return NULL; - } - - mhi_dev = mhi_controller_get_devdata(mhi_cntrl); - - mhi_cntrl->dev_id = pci_dev->device; - mhi_cntrl->domain = pci_domain_nr(pci_dev->bus); - mhi_cntrl->bus = pci_dev->bus->number; - mhi_cntrl->slot = PCI_SLOT(pci_dev->devfn); - mhi_dev->smmu_cfg = 0; - #if 0 //def CONFIG_HAVE_MEMBLOCK - addr_win[0] = memblock_start_of_DRAM(); - addr_win[1] = memblock_end_of_DRAM(); - #else -#define MHI_MEM_BASE_DEFAULT 0x000000000 -#define MHI_MEM_SIZE_DEFAULT 0x2000000000 - addr_win[0] = MHI_MEM_BASE_DEFAULT; - addr_win[1] = MHI_MEM_SIZE_DEFAULT; - if (sizeof(dma_addr_t) == 4) { - addr_win[1] = 0xFFFFFFFF; - } - #endif - - mhi_cntrl->iova_start = addr_win[0]; - mhi_cntrl->iova_stop = addr_win[1]; - - mhi_dev->pci_dev = pci_dev; - mhi_cntrl->pci_dev = pci_dev; - - /* setup power management apis */ - mhi_cntrl->status_cb = mhi_status_cb; - mhi_cntrl->runtime_get = mhi_runtime_get; - mhi_cntrl->runtime_put = mhi_runtime_put; - mhi_cntrl->link_status = mhi_link_status; - - ret = mhi_arch_platform_init(mhi_dev); - if (ret) - goto error_probe; - - ret = mhi_register_mhi_controller(mhi_cntrl); - if (ret) - goto error_register; - - if (mhi_cntrl->parent) - debugfs_create_file("debug_mode", 0444, mhi_cntrl->parent, - mhi_cntrl, &debugfs_debug_ops); - - return mhi_cntrl; - -error_register: - mhi_arch_platform_deinit(mhi_dev); - -error_probe: - mhi_free_controller(mhi_cntrl); - - return NULL; -} - -int mhi_pci_probe(struct pci_dev *pci_dev, - const struct pci_device_id *device_id) -{ - struct mhi_controller *mhi_cntrl = NULL; - u32 domain = pci_domain_nr(pci_dev->bus); - u32 bus = pci_dev->bus->number; - u32 slot = PCI_SLOT(pci_dev->devfn); - struct mhi_dev *mhi_dev; - int ret; - - pr_info("%s pci_dev->name = %s, domain=%d, bus=%d, slot=%d, vendor=%04X, device=%04X\n", - __func__, dev_name(&pci_dev->dev), domain, bus, slot, pci_dev->vendor, pci_dev->device); - - mhi_cntrl = mhi_platform_probe(pci_dev); - if (!mhi_cntrl) { - pr_err("mhi_platform_probe fail\n"); - return -EPROBE_DEFER; - } - - mhi_cntrl->dev_id = pci_dev->device; - mhi_dev = mhi_controller_get_devdata(mhi_cntrl); - mhi_dev->pci_dev = pci_dev; - mhi_dev->powered_on = true; - - ret = mhi_arch_pcie_init(mhi_cntrl); - if (ret) { - MHI_ERR("Error mhi_arch_pcie_init, ret:%d\n", ret); - return ret; - } - - ret = mhi_arch_iommu_init(mhi_cntrl); - if (ret) { - MHI_ERR("Error mhi_arch_iommu_init, ret:%d\n", ret); - goto error_iommu_init; - } - - ret = mhi_init_pci_dev(mhi_cntrl); - if (ret) { - MHI_ERR("Error mhi_init_pci_dev, ret:%d\n", ret); - goto error_init_pci; - } - - /* start power up sequence if not in debug mode */ - if (!mhi_dev->debug_mode) { - ret = mhi_async_power_up(mhi_cntrl); - if (ret) { - MHI_ERR("Error mhi_async_power_up, ret:%d\n", ret); - goto error_power_up; - } - } - -#if 0 - pm_runtime_mark_last_busy(&pci_dev->dev); - pm_runtime_allow(&pci_dev->dev); - pm_runtime_disable(&pci_dev->dev); -#endif - - if (mhi_cntrl->dentry) { - debugfs_create_file("m0", 0444, mhi_cntrl->dentry, mhi_cntrl, - &debugfs_trigger_m0_fops); - debugfs_create_file("m3", 0444, mhi_cntrl->dentry, mhi_cntrl, - &debugfs_trigger_m3_fops); - } - - dev_set_drvdata(&pci_dev->dev, mhi_cntrl); - MHI_LOG("Return successful\n"); - - return 0; - -error_power_up: - mhi_deinit_pci_dev(mhi_cntrl); - -error_init_pci: - mhi_arch_iommu_deinit(mhi_cntrl); - -error_iommu_init: - mhi_arch_pcie_deinit(mhi_cntrl); - - return ret; -} - -static void mhi_pci_remove(struct pci_dev *pci_dev) -{ - struct mhi_controller *mhi_cntrl = (struct mhi_controller *)dev_get_drvdata(&pci_dev->dev); - - if (mhi_cntrl && mhi_cntrl->pci_dev == pci_dev) { - struct mhi_dev *mhi_dev = mhi_controller_get_devdata(mhi_cntrl); - MHI_LOG("%s\n", dev_name(&pci_dev->dev)); - if (!mhi_dev->debug_mode) { - mhi_power_down(mhi_cntrl, 1); - } - mhi_deinit_pci_dev(mhi_cntrl); - mhi_arch_iommu_deinit(mhi_cntrl); - mhi_arch_pcie_deinit(mhi_cntrl); - mhi_unregister_mhi_controller(mhi_cntrl); - } -} - -static const struct dev_pm_ops pm_ops = { - SET_RUNTIME_PM_OPS(mhi_runtime_suspend, - mhi_runtime_resume, - mhi_runtime_idle) - SET_SYSTEM_SLEEP_PM_OPS(mhi_system_suspend, mhi_system_resume) -}; - -static struct pci_driver mhi_pcie_driver = { - .name = "mhi", - .id_table = mhi_pcie_device_id, - .probe = mhi_pci_probe, - .remove = mhi_pci_remove, - .driver = { - .pm = &pm_ops - } -}; - -int __init mhi_controller_qcom_init(void) -{ - return pci_register_driver(&mhi_pcie_driver); -}; - -void mhi_controller_qcom_exit(void) -{ - pr_info("%s enter\n", __func__); - pci_unregister_driver(&mhi_pcie_driver); - pr_info("%s exit\n", __func__); -} diff --git a/quectel_MHI/src/controllers/mhi_qcom.h b/quectel_MHI/src/controllers/mhi_qcom.h deleted file mode 100644 index 65ec5b8..0000000 --- a/quectel_MHI/src/controllers/mhi_qcom.h +++ /dev/null @@ -1,92 +0,0 @@ -/* Copyright (c) 2018, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ -#ifndef _MHI_QCOM_ -#define _MHI_QCOM_ - -/* iova cfg bitmask */ -#define MHI_SMMU_ATTACH BIT(0) -#define MHI_SMMU_S1_BYPASS BIT(1) -#define MHI_SMMU_FAST BIT(2) -#define MHI_SMMU_ATOMIC BIT(3) -#define MHI_SMMU_FORCE_COHERENT BIT(4) - -#define MHI_PCIE_VENDOR_ID (0x17cb) -#define MHI_PCIE_DEBUG_ID (0xffff) -#define MHI_RPM_SUSPEND_TMR_MS (3000) -#define MHI_PCI_BAR_NUM (0) - -struct mhi_dev { - struct pci_dev *pci_dev; - u32 smmu_cfg; - int resn; - void *arch_info; - bool powered_on; - bool debug_mode; -}; - -void mhi_deinit_pci_dev(struct mhi_controller *mhi_cntrl); -int mhi_pci_probe(struct pci_dev *pci_dev, - const struct pci_device_id *device_id); - -#if (LINUX_VERSION_CODE < KERNEL_VERSION( 3,10,65 )) -static inline int dma_set_mask_and_coherent(struct device *dev, u64 mask) -{ - int rc = dma_set_mask(dev, mask); - if (rc == 0) - dma_set_coherent_mask(dev, mask); - return rc; -} -#endif - -static inline int mhi_arch_iommu_init(struct mhi_controller *mhi_cntrl) -{ - struct mhi_dev *mhi_dev = mhi_controller_get_devdata(mhi_cntrl); - - mhi_cntrl->dev = &mhi_dev->pci_dev->dev; - - return dma_set_mask_and_coherent(mhi_cntrl->dev, DMA_BIT_MASK(64)); -} - -static inline void mhi_arch_iommu_deinit(struct mhi_controller *mhi_cntrl) -{ -} - -static inline int mhi_arch_pcie_init(struct mhi_controller *mhi_cntrl) -{ - return 0; -} - -static inline void mhi_arch_pcie_deinit(struct mhi_controller *mhi_cntrl) -{ -} - -static inline int mhi_arch_platform_init(struct mhi_dev *mhi_dev) -{ - return 0; -} - -static inline void mhi_arch_platform_deinit(struct mhi_dev *mhi_dev) -{ -} - -static inline int mhi_arch_link_off(struct mhi_controller *mhi_cntrl, - bool graceful) -{ - return 0; -} - -static inline int mhi_arch_link_on(struct mhi_controller *mhi_cntrl) -{ - return 0; -} - -#endif /* _MHI_QCOM_ */ diff --git a/quectel_MHI/src/controllers/mhi_qti.c b/quectel_MHI/src/controllers/mhi_qti.c deleted file mode 100644 index 4a064a7..0000000 --- a/quectel_MHI/src/controllers/mhi_qti.c +++ /dev/null @@ -1,1306 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#define MAX_MHI 8 -#ifdef CONFIG_PCI_MSM -#define QCOM_AP_AND_EFUSE_PCIE_SLEEP -#ifdef QCOM_AP_AND_EFUSE_PCIE_SLEEP -#include -#include -#endif -#endif -//#define QCOM_AP_SDM845_IOMMU_MAP -#ifdef QCOM_AP_SDM845_IOMMU_MAP -#include -#include -#include -#endif -#include "../core/mhi.h" -#include "../core/mhi_internal.h" -#include "mhi_qti.h" - -#ifdef QCOM_AP_AND_EFUSE_PCIE_SLEEP -extern int pci_write_config_byte(const struct pci_dev *dev, int where, u8 val); -struct arch_info { - struct mhi_dev *mhi_dev; - struct msm_bus_scale_pdata *msm_bus_pdata; - u32 bus_client; - struct pci_saved_state *pcie_state; - struct pci_saved_state *ref_pcie_state; - struct dma_iommu_mapping *mapping; -}; -#endif - -#if 1 -#if (LINUX_VERSION_CODE < KERNEL_VERSION( 3,10,65 )) -static inline int dma_set_mask_and_coherent(struct device *dev, u64 mask) -{ - int rc = dma_set_mask(dev, mask); - if (rc == 0) - dma_set_coherent_mask(dev, mask); - return rc; -} -#endif - -#ifdef PCI_IRQ_NOMSIX -#define PCI_IRQ_MSI PCI_IRQ_NOMSIX -#endif - -#ifndef PCI_IRQ_MSI -#define PCI_IRQ_MSI (1 << 1) /* Allow MSI interrupts */ - -#if (LINUX_VERSION_CODE < KERNEL_VERSION( 3,10,53 )) -int pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec) -{ - int nvec = maxvec; - int rc; - - if (maxvec < minvec) - return -ERANGE; - - do { - rc = pci_enable_msi_block(dev, nvec); - if (rc < 0) { - return rc; - } else if (rc > 0) { - if (rc < minvec) - return -ENOSPC; - nvec = rc; - } - } while (rc); - - return nvec; -} -#endif - -static int pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs, - unsigned int max_vecs, unsigned int flags) -{ - return pci_enable_msi_range(dev, min_vecs, max_vecs); -} - -static void pci_free_irq_vectors(struct pci_dev *dev) -{ - pci_disable_msi(dev); -} - -static int pci_irq_vector(struct pci_dev *dev, unsigned int nr) -{ -#if 0//defined(CONFIG_PINCTRL_IPQ5018) - struct pcie_port *pp = dev->bus->sysdata; - pp->msi[nr]; //msi maybe not continuous -#endif - return dev->irq + nr; -} -#endif -#endif - -struct firmware_info { - unsigned int dev_id; - const char *fw_image; - const char *edl_image; -}; - -static const struct firmware_info firmware_table[] = { - {.dev_id = 0x306, .fw_image = "sdx55m/sbl1.mbn"}, - {.dev_id = 0x305, .fw_image = "sdx50m/sbl1.mbn"}, - {.dev_id = 0x304, .fw_image = "sbl.mbn", .edl_image = "edl.mbn"}, - /* default, set to debug.mbn */ - {.fw_image = "debug.mbn"}, -}; - -static int debug_mode; -module_param_named(debug_mode, debug_mode, int, 0644); - -int mhi_debugfs_trigger_m0(void *data, u64 val) -{ - struct mhi_controller *mhi_cntrl = data; - struct mhi_dev *mhi_dev = mhi_controller_get_devdata(mhi_cntrl); - - MHI_LOG("Trigger M3 Exit\n"); - pm_runtime_get(&mhi_dev->pci_dev->dev); - pm_runtime_put(&mhi_dev->pci_dev->dev); - - return 0; -} -DEFINE_SIMPLE_ATTRIBUTE(debugfs_trigger_m0_fops, NULL, - mhi_debugfs_trigger_m0, "%llu\n"); - -int mhi_debugfs_trigger_m3(void *data, u64 val) -{ - struct mhi_controller *mhi_cntrl = data; - struct mhi_dev *mhi_dev = mhi_controller_get_devdata(mhi_cntrl); - - MHI_LOG("Trigger M3 Entry\n"); - pm_runtime_mark_last_busy(&mhi_dev->pci_dev->dev); - pm_request_autosuspend(&mhi_dev->pci_dev->dev); - - return 0; -} -DEFINE_SIMPLE_ATTRIBUTE(debugfs_trigger_m3_fops, NULL, - mhi_debugfs_trigger_m3, "%llu\n"); - -void mhi_deinit_pci_dev(struct mhi_controller *mhi_cntrl) -{ - struct mhi_dev *mhi_dev = mhi_controller_get_devdata(mhi_cntrl); - struct pci_dev *pci_dev = mhi_dev->pci_dev; - - pm_runtime_mark_last_busy(&pci_dev->dev); - pm_runtime_dont_use_autosuspend(&pci_dev->dev); - pm_runtime_disable(&pci_dev->dev); - pci_free_irq_vectors(pci_dev); - kfree(mhi_cntrl->irq); - mhi_cntrl->irq = NULL; - iounmap(mhi_cntrl->regs); - mhi_cntrl->regs = NULL; - pci_clear_master(pci_dev); - pci_release_region(pci_dev, mhi_dev->resn); - pci_disable_device(pci_dev); -} - -static int mhi_init_pci_dev(struct mhi_controller *mhi_cntrl) -{ - struct mhi_dev *mhi_dev = mhi_controller_get_devdata(mhi_cntrl); - struct pci_dev *pci_dev = mhi_dev->pci_dev; - int ret; - resource_size_t len; - int i; - - mhi_dev->resn = MHI_PCI_BAR_NUM; - ret = pci_assign_resource(pci_dev, mhi_dev->resn); - if (ret) { - MHI_ERR("Error assign pci resources, ret:%d\n", ret); - return ret; - } - - ret = pci_enable_device(pci_dev); - if (ret) { - MHI_ERR("Error enabling device, ret:%d\n", ret); - goto error_enable_device; - } - - ret = pci_request_region(pci_dev, mhi_dev->resn, "mhi"); - if (ret) { - MHI_ERR("Error pci_request_region, ret:%d\n", ret); - goto error_request_region; - } - - pci_set_master(pci_dev); - -#if 1 //some SOC like rpi_4b need next codes - ret = -EIO; -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)) - if (!dma_set_mask(&pci_dev->dev, DMA_BIT_MASK(64))) { - ret = dma_set_coherent_mask(&pci_dev->dev, DMA_BIT_MASK(64)); - } else if (!dma_set_mask(&pci_dev->dev, DMA_BIT_MASK(32))) { - ret = dma_set_coherent_mask(&pci_dev->dev, DMA_BIT_MASK(32)); - } -#else - if (!pci_set_dma_mask(pci_dev, DMA_BIT_MASK(64))) { - ret = pci_set_consistent_dma_mask(pci_dev, DMA_BIT_MASK(64)); - } else if (!pci_set_dma_mask(pci_dev, DMA_BIT_MASK(32))) { - ret = pci_set_consistent_dma_mask(pci_dev, DMA_BIT_MASK(32)); - } -#endif - if (ret) { - MHI_ERR("Error dma mask\n"); - } -#endif - - mhi_cntrl->base_addr = pci_resource_start(pci_dev, mhi_dev->resn); - len = pci_resource_len(pci_dev, mhi_dev->resn); -#ifndef ioremap_nocache //4bdc0d676a643140bdf17dbf7eafedee3d496a3c -#define ioremap_nocache ioremap -#endif - mhi_cntrl->regs = ioremap_nocache(mhi_cntrl->base_addr, len); - if (!mhi_cntrl->regs) { - MHI_ERR("Error ioremap region\n"); - goto error_ioremap; - } - -#if 0 - ret = pci_alloc_irq_vectors(pci_dev, mhi_cntrl->msi_required, - mhi_cntrl->msi_required, PCI_IRQ_NOMSIX); - if (IS_ERR_VALUE((ulong)ret) || ret < mhi_cntrl->msi_required) { - MHI_ERR("Failed to enable MSI, ret:%d\n", ret); - goto error_req_msi; - } -#else - ret = pci_alloc_irq_vectors(pci_dev, 1, mhi_cntrl->msi_required, PCI_IRQ_MSI); - if (IS_ERR_VALUE((ulong)ret) || ret < mhi_cntrl->msi_required) { - if (ret == -ENOSPC) { - /* imx_3.14.52_1.1.0_ga - diff --git a/drivers/pci/host/pcie-designware.c b/drivers/pci/host/pcie-designware.c - index f06e8f0..6a9614f 100644 - --- a/drivers/pci/host/pcie-designware.c - +++ b/drivers/pci/host/pcie-designware.c - @@ -376,6 +376,13 @@ static int dw_msi_setup_irq(struct msi_chip *chip, struct pci_dev *pdev, - if (msgvec > 5) - msgvec = 0; - - +#if 1 //Add by Quectel 20190419 - + if (msgvec > 0 && pdev->vendor == 0x17cb) { - + dev_info(&pdev->dev, "%s quectel fixup pos=%d, msg_ctr=%04x, msgvec=%d\n", __func__, desc->msi_attrib.pos, msg_ctr, msgvec); - + msgvec = 0; - + } - +#endif - + - irq = assign_irq((1 << msgvec), desc, &pos); - if (irq < 0) - return irq; - */ - } - //imx_4.1.15_2.0.0_ga & DELL_OPTIPLEX_7010 only alloc one msi interrupt for one pcie device - if (ret != 1) { - MHI_ERR("Failed to enable MSI, ret=%d, msi_required=%d\n", ret, mhi_cntrl->msi_required); - goto error_req_msi; - } - } - MHI_LOG("msi_required = %d, msi_allocated = %d, msi_irq = %u\n", mhi_cntrl->msi_required, ret, pci_dev->irq); -#endif - - mhi_cntrl->msi_allocated = ret; - mhi_cntrl->irq = kmalloc_array(mhi_cntrl->msi_allocated, - sizeof(*mhi_cntrl->irq), GFP_KERNEL); - if (!mhi_cntrl->irq) { - ret = -ENOMEM; - goto error_alloc_msi_vec; - } - - for (i = 0; i < mhi_cntrl->msi_allocated; i++) { - mhi_cntrl->irq[i] = pci_irq_vector(pci_dev, i); - if (mhi_cntrl->irq[i] < 0) { - ret = mhi_cntrl->irq[i]; - goto error_get_irq_vec; - } - } - - dev_set_drvdata(&pci_dev->dev, mhi_cntrl); - - /* configure runtime pm */ - pm_runtime_set_autosuspend_delay(&pci_dev->dev, MHI_RPM_SUSPEND_TMR_MS); - pm_runtime_use_autosuspend(&pci_dev->dev); - pm_suspend_ignore_children(&pci_dev->dev, true); - - /* - * pci framework will increment usage count (twice) before - * calling local device driver probe function. - * 1st pci.c pci_pm_init() calls pm_runtime_forbid - * 2nd pci-driver.c local_pci_probe calls pm_runtime_get_sync - * Framework expect pci device driver to call - * pm_runtime_put_noidle to decrement usage count after - * successful probe and and call pm_runtime_allow to enable - * runtime suspend. - */ - pm_runtime_mark_last_busy(&pci_dev->dev); - pm_runtime_put_noidle(&pci_dev->dev); - - return 0; - -error_get_irq_vec: - kfree(mhi_cntrl->irq); - mhi_cntrl->irq = NULL; - -error_alloc_msi_vec: - pci_free_irq_vectors(pci_dev); - -error_req_msi: - iounmap(mhi_cntrl->regs); - -error_ioremap: - pci_clear_master(pci_dev); - -error_request_region: - pci_disable_device(pci_dev); - -error_enable_device: - pci_release_region(pci_dev, mhi_dev->resn); - - return ret; -} - -#ifdef CONFIG_PM -static int mhi_runtime_suspend(struct device *dev) -{ - int ret = 0; - struct mhi_controller *mhi_cntrl = dev_get_drvdata(dev); - struct mhi_dev *mhi_dev = mhi_controller_get_devdata(mhi_cntrl); - - MHI_LOG("Enter\n"); - - mutex_lock(&mhi_cntrl->pm_mutex); - - if (!mhi_dev->powered_on) { - MHI_LOG("Not fully powered, return success\n"); - mutex_unlock(&mhi_cntrl->pm_mutex); - return 0; - } - - if (mhi_cntrl->ee != MHI_EE_AMSS) { - MHI_LOG("Not AMSS, return busy\n"); - mutex_unlock(&mhi_cntrl->pm_mutex); - return -EBUSY; - } - - ret = mhi_pm_suspend(mhi_cntrl); - if (ret) { - MHI_LOG("Abort due to ret:%d\n", ret); - goto exit_runtime_suspend; - } - - ret = mhi_arch_link_off(mhi_cntrl, true); - if (ret) - MHI_ERR("Failed to Turn off link ret:%d\n", ret); - -exit_runtime_suspend: - mutex_unlock(&mhi_cntrl->pm_mutex); - MHI_LOG("Exited with ret:%d\n", ret); - - return ret; -} - -static int mhi_runtime_idle(struct device *dev) -{ - struct mhi_controller *mhi_cntrl = dev_get_drvdata(dev); - - if ((mhi_cntrl->dev_state == MHI_STATE_M0 || mhi_cntrl->dev_state == MHI_STATE_M3) - && mhi_cntrl->ee == MHI_EE_AMSS) { - return 0; - } - MHI_LOG("Entered returning -EBUSY, mhi_state:%s exec_env:%s\n", - TO_MHI_STATE_STR(mhi_get_mhi_state(mhi_cntrl)), TO_MHI_EXEC_STR(mhi_get_exec_env(mhi_cntrl))); - - /* - * RPM framework during runtime resume always calls - * rpm_idle to see if device ready to suspend. - * If dev.power usage_count count is 0, rpm fw will call - * rpm_idle cb to see if device is ready to suspend. - * if cb return 0, or cb not defined the framework will - * assume device driver is ready to suspend; - * therefore, fw will schedule runtime suspend. - * In MHI power management, MHI host shall go to - * runtime suspend only after entering MHI State M2, even if - * usage count is 0. Return -EBUSY to disable automatic suspend. - */ - return -EBUSY; -} - -static int mhi_runtime_resume(struct device *dev) -{ - int ret = 0; - struct mhi_controller *mhi_cntrl = dev_get_drvdata(dev); - struct mhi_dev *mhi_dev = mhi_controller_get_devdata(mhi_cntrl); - - MHI_LOG("Enter\n"); - - mutex_lock(&mhi_cntrl->pm_mutex); - - if (!mhi_dev->powered_on) { - MHI_LOG("Not fully powered, return success\n"); - mutex_unlock(&mhi_cntrl->pm_mutex); - return 0; - } - - /* turn on link */ - ret = mhi_arch_link_on(mhi_cntrl); - if (ret) - goto rpm_resume_exit; - - /* enter M0 state */ - ret = mhi_pm_resume(mhi_cntrl); - -rpm_resume_exit: - mutex_unlock(&mhi_cntrl->pm_mutex); - MHI_LOG("Exited with :%d\n", ret); - - return ret; -} - -static int mhi_system_resume(struct device *dev) -{ - int ret = 0; - struct mhi_controller *mhi_cntrl = dev_get_drvdata(dev); - - ret = mhi_runtime_resume(dev); - if (ret) { - MHI_ERR("Failed to resume link\n"); - } else { - //pm_runtime_set_active(dev); - //pm_runtime_enable(dev); - } - - return ret; -} - -int mhi_system_suspend(struct device *dev) -{ - struct mhi_controller *mhi_cntrl = dev_get_drvdata(dev); - int ret; - - MHI_LOG("Entered\n"); - - if (atomic_read(&mhi_cntrl->pending_pkts)) { - MHI_LOG("Abort due to pending_pkts:%d\n", atomic_read(&mhi_cntrl->pending_pkts)); - return -EBUSY; - } - - /* if rpm status still active then force suspend */ - if (!pm_runtime_status_suspended(dev)) { - ret = mhi_runtime_suspend(dev); - if (ret) { - MHI_LOG("suspend failed ret:%d\n", ret); - return ret; - } - } - - //pm_runtime_set_suspended(dev); - //pm_runtime_disable(dev); - - MHI_LOG("Exit\n"); - return 0; -} -#endif - -/* checks if link is down */ -static int mhi_link_status(struct mhi_controller *mhi_cntrl, void *priv) -{ - struct mhi_dev *mhi_dev = priv; - u16 dev_id; - int ret; - - /* try reading device id, if dev id don't match, link is down */ - ret = pci_read_config_word(mhi_dev->pci_dev, PCI_DEVICE_ID, &dev_id); - - return (ret || dev_id != mhi_cntrl->dev_id) ? -EIO : 0; -} - -/* disable PCIe L1 */ -static int mhi_lpm_disable(struct mhi_controller *mhi_cntrl, void *priv) -{ - struct mhi_dev *mhi_dev = priv; - struct pci_dev *pci_dev = mhi_dev->pci_dev; - int lnkctl = pci_dev->pcie_cap + PCI_EXP_LNKCTL; - u8 val; - int ret; - - ret = pci_read_config_byte(pci_dev, lnkctl, &val); - if (ret) { - MHI_ERR("Error reading LNKCTL, ret:%d\n", ret); - return ret; - } - - /* L1 is not supported or already disabled */ - if (!(val & PCI_EXP_LNKCTL_ASPM_L1)) - return 0; - - val &= ~PCI_EXP_LNKCTL_ASPM_L1; - ret = pci_write_config_byte(pci_dev, lnkctl, val); - if (ret) { - MHI_ERR("Error writing LNKCTL to disable LPM, ret:%d\n", ret); - return ret; - } - - mhi_dev->lpm_disabled = true; - - return ret; -} - -/* enable PCIe L1 */ -static int mhi_lpm_enable(struct mhi_controller *mhi_cntrl, void *priv) -{ - struct mhi_dev *mhi_dev = priv; - struct pci_dev *pci_dev = mhi_dev->pci_dev; - int lnkctl = pci_dev->pcie_cap + PCI_EXP_LNKCTL; - u8 val; - int ret; - - /* L1 is not supported or already disabled */ - if (!mhi_dev->lpm_disabled) - return 0; - - ret = pci_read_config_byte(pci_dev, lnkctl, &val); - if (ret) { - MHI_ERR("Error reading LNKCTL, ret:%d\n", ret); - return ret; - } - - val |= PCI_EXP_LNKCTL_ASPM_L1; - ret = pci_write_config_byte(pci_dev, lnkctl, val); - if (ret) { - MHI_ERR("Error writing LNKCTL to enable LPM, ret:%d\n", ret); - return ret; - } - - mhi_dev->lpm_disabled = false; - - return ret; -} - -static int mhi_power_up(struct mhi_controller *mhi_cntrl) -{ - enum mhi_dev_state dev_state = mhi_get_mhi_state(mhi_cntrl); - const u32 delayus = 10; - int itr = DIV_ROUND_UP(mhi_cntrl->timeout_ms * 1000, delayus); - int ret; - - MHI_LOG("dev_state:%s\n", TO_MHI_STATE_STR(mhi_get_mhi_state(mhi_cntrl))); - - /* - * It's possible device did not go thru a cold reset before - * power up and still in error state. If device in error state, - * we need to trigger a soft reset before continue with power - * up - */ - if (dev_state == MHI_STATE_SYS_ERR) { - mhi_set_mhi_state(mhi_cntrl, MHI_STATE_RESET); - while (itr--) { - dev_state = mhi_get_mhi_state(mhi_cntrl); - if (dev_state != MHI_STATE_SYS_ERR) - break; - usleep_range(delayus, delayus << 1); - } - MHI_LOG("dev_state:%s\n", TO_MHI_STATE_STR(mhi_get_mhi_state(mhi_cntrl))); - - /* device still in error state, abort power up */ - if (dev_state == MHI_STATE_SYS_ERR) - return -EIO; - } - - ret = mhi_async_power_up(mhi_cntrl); - - /* power up create the dentry */ - if (mhi_cntrl->dentry) { - debugfs_create_file("m0", 0444, mhi_cntrl->dentry, mhi_cntrl, - &debugfs_trigger_m0_fops); - debugfs_create_file("m3", 0444, mhi_cntrl->dentry, mhi_cntrl, - &debugfs_trigger_m3_fops); - } - - return ret; -} - -static int mhi_runtime_get(struct mhi_controller *mhi_cntrl, void *priv) -{ - struct mhi_dev *mhi_dev = priv; - struct device *dev = &mhi_dev->pci_dev->dev; - - return pm_runtime_get(dev); -} - -static void mhi_runtime_put(struct mhi_controller *mhi_cntrl, void *priv) -{ - struct mhi_dev *mhi_dev = priv; - struct device *dev = &mhi_dev->pci_dev->dev; - - pm_runtime_mark_last_busy(dev); - pm_runtime_put(dev); -} - -static void mhi_runtime_mark_last_busy(struct mhi_controller *mhi_cntrl, void *priv) -{ - struct mhi_dev *mhi_dev = priv; - struct device *dev = &mhi_dev->pci_dev->dev; - - pm_runtime_mark_last_busy(dev); -} - -#ifdef QCOM_AP_AND_EFUSE_PCIE_SLEEP -static void mhi_pci_event_cb(struct msm_pcie_notify *notify) -{ - struct pci_dev *pci_dev = notify->user; - struct device *dev = &pci_dev->dev; - - dev_info(&pci_dev->dev, "Received PCIe event %d", notify->event); - switch (notify->event) { - case MSM_PCIE_EVENT_WAKEUP: - if (dev && pm_runtime_status_suspended(dev)) { - pm_request_resume(dev); - pm_runtime_mark_last_busy(dev); - } - break; - default: - break; - } -} - -static struct msm_pcie_register_event mhi_pcie_events[MAX_MHI]; -#endif - -static void mhi_status_cb(struct mhi_controller *mhi_cntrl, - void *priv, - enum MHI_CB reason) -{ - struct mhi_dev *mhi_dev = priv; - struct device *dev = &mhi_dev->pci_dev->dev; - - switch (reason) { - case MHI_CB_FATAL_ERROR: - case MHI_CB_SYS_ERROR: - pm_runtime_forbid(dev); - break; - case MHI_CB_EE_MISSION_MODE: - //pm_runtime_allow(dev); - break; - default: - break; - } -} - -/* capture host SoC XO time in ticks */ -static u64 mhi_time_get(struct mhi_controller *mhi_cntrl, void *priv) -{ - return 0; -} - -static ssize_t timeout_ms_show(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct mhi_device *mhi_dev = to_mhi_device(dev); - struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; - - /* buffer provided by sysfs has a minimum size of PAGE_SIZE */ - return snprintf(buf, PAGE_SIZE, "%u\n", mhi_cntrl->timeout_ms); -} - -static ssize_t timeout_ms_store(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t count) -{ - struct mhi_device *mhi_dev = to_mhi_device(dev); - struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; - u32 timeout_ms; - - if (kstrtou32(buf, 0, &timeout_ms) < 0) - return -EINVAL; - - mhi_cntrl->timeout_ms = timeout_ms; - - return count; -} -static DEVICE_ATTR_RW(timeout_ms); - -static ssize_t power_up_store(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t count) -{ - int ret; - struct mhi_device *mhi_dev = to_mhi_device(dev); - struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; - - ret = mhi_power_up(mhi_cntrl); - if (ret) - return ret; - - return count; -} -static DEVICE_ATTR_WO(power_up); - -static struct attribute *mhi_attrs[] = { - &dev_attr_timeout_ms.attr, - &dev_attr_power_up.attr, - NULL -}; - -static const struct attribute_group mhi_group = { - .attrs = mhi_attrs, -}; - -static struct mhi_controller *mhi_register_controller(struct pci_dev *pci_dev) -{ - struct mhi_controller *mhi_cntrl; - struct mhi_dev *mhi_dev; - struct device_node *of_node = pci_dev->dev.of_node; - const struct firmware_info *firmware_info; - bool use_bb; - u64 addr_win[2]; - int ret, i; - - //if (!of_node) - // return ERR_PTR(-ENODEV); - - mhi_cntrl = mhi_alloc_controller(sizeof(*mhi_dev)); - if (!mhi_cntrl) - return ERR_PTR(-ENOMEM); - - mhi_dev = mhi_controller_get_devdata(mhi_cntrl); - - mhi_cntrl->dev = &pci_dev->dev; - mhi_cntrl->domain = pci_domain_nr(pci_dev->bus); - mhi_cntrl->vendor = pci_dev->vendor; - mhi_cntrl->dev_id = pci_dev->device; - mhi_cntrl->bus = pci_dev->bus->number; - mhi_cntrl->slot = PCI_SLOT(pci_dev->devfn); - -#if 0 - use_bb = of_property_read_bool(of_node, "mhi,use-bb"); - - /* - * if s1 translation enabled or using bounce buffer pull iova addr - * from dt - */ - if (use_bb || (mhi_dev->smmu_cfg & MHI_SMMU_ATTACH && - !(mhi_dev->smmu_cfg & MHI_SMMU_S1_BYPASS))) { - ret = of_property_count_elems_of_size(of_node, "qti,addr-win", - sizeof(addr_win)); - if (ret != 1) - goto error_register; - ret = of_property_read_u64_array(of_node, "qti,addr-win", - addr_win, 2); - if (ret) - goto error_register; - } else { - addr_win[0] = memblock_start_of_DRAM(); - addr_win[1] = memblock_end_of_DRAM(); - } -#else - use_bb = false; - (void)use_bb; - addr_win[0] = 0x000000000; - addr_win[1] = 0x2000000000; //MHI_MEM_SIZE_DEFAULT - if (sizeof(dma_addr_t) == 4) { - addr_win[1] = 0xFFFFFFFF; - } -#endif - - mhi_dev->iova_start = addr_win[0]; - mhi_dev->iova_stop = addr_win[1]; - - /* - * If S1 is enabled, set MHI_CTRL start address to 0 so we can use low - * level mapping api to map buffers outside of smmu domain - */ - if (mhi_dev->smmu_cfg & MHI_SMMU_ATTACH && - !(mhi_dev->smmu_cfg & MHI_SMMU_S1_BYPASS)) - mhi_cntrl->iova_start = 0; - else - mhi_cntrl->iova_start = addr_win[0]; - - mhi_cntrl->iova_stop = mhi_dev->iova_stop; - mhi_cntrl->of_node = of_node; - - mhi_dev->pci_dev = pci_dev; - - /* setup power management apis */ - mhi_cntrl->status_cb = mhi_status_cb; - mhi_cntrl->runtime_get = mhi_runtime_get; - mhi_cntrl->runtime_put = mhi_runtime_put; - mhi_cntrl->runtime_mark_last_busy = mhi_runtime_mark_last_busy; - mhi_cntrl->link_status = mhi_link_status; - - mhi_cntrl->lpm_disable = mhi_lpm_disable; - mhi_cntrl->lpm_enable = mhi_lpm_enable; - mhi_cntrl->time_get = mhi_time_get; - - ret = of_register_mhi_controller(mhi_cntrl); - if (ret) - goto error_register; - - for (i = 0; i < ARRAY_SIZE(firmware_table); i++) { - firmware_info = firmware_table + i; - - /* debug mode always use default */ - if (!debug_mode && mhi_cntrl->dev_id == firmware_info->dev_id) - break; - } - -#if 0 - mhi_cntrl->fw_image = firmware_info->fw_image; - mhi_cntrl->edl_image = firmware_info->edl_image; -#endif - - if (sysfs_create_group(&mhi_cntrl->mhi_dev->dev.kobj, &mhi_group)) - MHI_ERR("Error while creating the sysfs group\n"); - - return mhi_cntrl; - -error_register: - mhi_free_controller(mhi_cntrl); - - return ERR_PTR(-EINVAL); -} - -static bool mhi_pci_is_alive(struct pci_dev *pdev) -{ - u16 vendor = 0; - - if (pci_read_config_word(pdev, PCI_VENDOR_ID, &vendor)) - return false; - - if (vendor == (u16) ~0 || vendor == 0) - return false; - - return true; -} - -static void mhi_pci_show_link(struct mhi_controller *mhi_cntrl, struct pci_dev *pci_dev) -{ - int pcie_cap_reg; - u16 stat; - u32 caps; - const char *speed; - - pcie_cap_reg = pci_find_capability(pci_dev, PCI_CAP_ID_EXP); - - if (!pcie_cap_reg) - return; - - pci_read_config_word(pci_dev, - pcie_cap_reg + PCI_EXP_LNKSTA, - &stat); - pci_read_config_dword(pci_dev, - pcie_cap_reg + PCI_EXP_LNKCAP, - &caps); - - switch (caps & PCI_EXP_LNKCAP_SLS) { - case PCI_EXP_LNKCAP_SLS_2_5GB: speed = "2.5"; break; - case PCI_EXP_LNKCAP_SLS_5_0GB: speed = "5"; break; - case 3: speed = "8"; break; - case 4: speed = "16"; break; - case 5: speed = "32"; break; - case 6: speed = "64"; break; - default: speed = "0"; break; - } - - MHI_LOG("LnkCap: Speed %sGT/s, Width x%d\n", speed, - (caps & PCI_EXP_LNKCAP_MLW) >> 4); - - switch (stat & PCI_EXP_LNKSTA_CLS) { - case PCI_EXP_LNKSTA_CLS_2_5GB: speed = "2.5"; break; - case PCI_EXP_LNKSTA_CLS_5_0GB: speed = "5"; break; - case 3: speed = "8"; break; - case 4: speed = "16"; break; - case 5: speed = "32"; break; - case 6: speed = "64"; break; - default: speed = "0"; break; - } - - MHI_LOG("LnkSta: Speed %sGT/s, Width x%d\n", speed, - (stat & PCI_EXP_LNKSTA_NLW) >> PCI_EXP_LNKSTA_NLW_SHIFT); - -} - -int mhi_pci_probe(struct pci_dev *pci_dev, - const struct pci_device_id *device_id) -{ - struct mhi_controller *mhi_cntrl; - u32 domain = pci_domain_nr(pci_dev->bus); - u32 bus = pci_dev->bus->number; - u32 dev_id = pci_dev->device; - u32 slot = PCI_SLOT(pci_dev->devfn); - struct mhi_dev *mhi_dev; - int ret; - - pr_info("%s pci_dev->name = %s, domain=%d, bus=%d, slot=%d, vendor=%04X, device=%04X\n", - __func__, dev_name(&pci_dev->dev), domain, bus, slot, pci_dev->vendor, pci_dev->device); - -#if !defined(CONFIG_PCI_MSI) - /* MT7621 RTL8198D EcoNet-EN7565 */ - #error "pcie msi is not support by this soc! and i donot support INTx (SW1SDX55-2688)" -#endif - - if (!mhi_pci_is_alive(pci_dev)) { - /* - root@OpenWrt:~# hexdump /sys/bus/pci/devices/0000:01:00.0/config - 0000000 ffff ffff ffff ffff ffff ffff ffff ffff - * - 0001000 - */ - pr_err("mhi_pci is not alive! pcie link is down\n"); - pr_err("double check by 'hexdump /sys/bus/pci/devices/%s/config'\n", dev_name(&pci_dev->dev)); - return -EIO; - } - - /* see if we already registered */ - mhi_cntrl = mhi_bdf_to_controller(domain, bus, slot, dev_id); - if (!mhi_cntrl) - mhi_cntrl = mhi_register_controller(pci_dev); - - if (IS_ERR(mhi_cntrl)) - return PTR_ERR(mhi_cntrl); - - mhi_dev = mhi_controller_get_devdata(mhi_cntrl); - mhi_dev->powered_on = true; - - mhi_arch_iommu_init(mhi_cntrl); - - ret = mhi_arch_pcie_init(mhi_cntrl); - if (ret) - goto error_init_pci_arch; - - mhi_cntrl->dev = &pci_dev->dev; - ret = mhi_init_pci_dev(mhi_cntrl); - if (ret) - goto error_init_pci; - - /* start power up sequence */ - if (!debug_mode) { - ret = mhi_power_up(mhi_cntrl); - if (ret) - goto error_power_up; - } - - pm_runtime_mark_last_busy(&pci_dev->dev); - - mhi_pci_show_link(mhi_cntrl, pci_dev); - -#ifdef QCOM_AP_AND_EFUSE_PCIE_SLEEP - { - struct msm_pcie_register_event *pcie_event = &mhi_pcie_events[mhi_cntrl->cntrl_idx]; - - pcie_event->events = MSM_PCIE_EVENT_WAKEUP; -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 4,14,117 )) - pcie_event->pcie_event.user = pci_dev; - pcie_event->pcie_event.mode = MSM_PCIE_TRIGGER_CALLBACK; - pcie_event->pcie_event.callback = mhi_pci_event_cb; -#else - pcie_event->user = pci_dev; - pcie_event->mode = MSM_PCIE_TRIGGER_CALLBACK; - pcie_event->callback = mhi_pci_event_cb; -#endif - - ret = msm_pcie_register_event(pcie_event); - if (ret) { - MHI_LOG("Failed to register for PCIe event"); - } - } -#endif - - MHI_LOG("Return successful\n"); - - return 0; - - mhi_unregister_mhi_controller(mhi_cntrl); -error_power_up: - mhi_deinit_pci_dev(mhi_cntrl); - -error_init_pci: - mhi_arch_pcie_deinit(mhi_cntrl); -error_init_pci_arch: - mhi_arch_iommu_deinit(mhi_cntrl); - - return ret; -} - -void mhi_pci_device_removed(struct pci_dev *pci_dev) -{ - struct mhi_controller *mhi_cntrl; - u32 domain = pci_domain_nr(pci_dev->bus); - u32 bus = pci_dev->bus->number; - u32 dev_id = pci_dev->device; - u32 slot = PCI_SLOT(pci_dev->devfn); - - mhi_cntrl = mhi_bdf_to_controller(domain, bus, slot, dev_id); - - if (mhi_cntrl) { - - struct mhi_dev *mhi_dev = mhi_controller_get_devdata(mhi_cntrl); - -#ifdef QCOM_AP_AND_EFUSE_PCIE_SLEEP - { - struct msm_pcie_register_event *pcie_event = &mhi_pcie_events[mhi_cntrl->cntrl_idx]; - - msm_pcie_deregister_event(pcie_event); - } -#endif - - pm_stay_awake(&mhi_cntrl->mhi_dev->dev); - - /* if link is in drv suspend, wake it up */ - pm_runtime_get_sync(&pci_dev->dev); - - mutex_lock(&mhi_cntrl->pm_mutex); - if (!mhi_dev->powered_on) { - MHI_LOG("Not in active state\n"); - mutex_unlock(&mhi_cntrl->pm_mutex); - pm_runtime_put_noidle(&pci_dev->dev); - return; - } - mhi_dev->powered_on = false; - mutex_unlock(&mhi_cntrl->pm_mutex); - - pm_runtime_put_noidle(&pci_dev->dev); - - MHI_LOG("Triggering shutdown process\n"); - mhi_power_down(mhi_cntrl, false); - - /* turn the link off */ - mhi_deinit_pci_dev(mhi_cntrl); - mhi_arch_link_off(mhi_cntrl, false); - - mhi_arch_pcie_deinit(mhi_cntrl); - mhi_arch_iommu_deinit(mhi_cntrl); - - pm_relax(&mhi_cntrl->mhi_dev->dev); - - mhi_unregister_mhi_controller(mhi_cntrl); - } -} - -static const struct dev_pm_ops pm_ops = { - SET_RUNTIME_PM_OPS(mhi_runtime_suspend, - mhi_runtime_resume, - mhi_runtime_idle) - SET_SYSTEM_SLEEP_PM_OPS(mhi_system_suspend, mhi_system_resume) -}; - -static struct pci_device_id mhi_pcie_device_id[] = { - {PCI_DEVICE(MHI_PCIE_VENDOR_ID, 0x0303)}, - {PCI_DEVICE(MHI_PCIE_VENDOR_ID, 0x0304)}, //SDX20 - {PCI_DEVICE(MHI_PCIE_VENDOR_ID, 0x0305)}, //SDX24 - {PCI_DEVICE(MHI_PCIE_VENDOR_ID, 0x0306)}, //SDX55 - {PCI_DEVICE(MHI_PCIE_VENDOR_ID, 0x0308)}, //SDX62 - {PCI_DEVICE(0x1eac, 0x1001)}, //EM120 - {PCI_DEVICE(0x1eac, 0x1002)}, //EM160 - {PCI_DEVICE(0x1eac, 0x1004)}, //RM520 - {PCI_DEVICE(MHI_PCIE_VENDOR_ID, MHI_PCIE_DEBUG_ID)}, - {0}, -}; - -MODULE_DEVICE_TABLE(pci, mhi_pcie_device_id); - -static struct pci_driver mhi_pcie_driver = { - .name = "mhi_q", - .id_table = mhi_pcie_device_id, - .probe = mhi_pci_probe, - .remove = mhi_pci_device_removed, - .driver = { - .pm = &pm_ops - } -}; - -#if 0 -module_pci_driver(mhi_pcie_driver); -#else -int __init mhi_controller_qcom_init(void) -{ - return pci_register_driver(&mhi_pcie_driver); -}; - -void mhi_controller_qcom_exit(void) -{ - pr_info("%s enter\n", __func__); - pci_unregister_driver(&mhi_pcie_driver); - pr_info("%s exit\n", __func__); -} - -#ifdef QCOM_AP_SDM845_IOMMU_MAP -struct dma_iommu_mapping *mhi_smmu_mapping[MAX_MHI]; - -#define SMMU_BASE 0x10000000 -#define SMMU_SIZE 0x40000000 -static struct dma_iommu_mapping * sdm845_smmu_init(struct pci_dev *pdev) { - int ret = 0; - int atomic_ctx = 1; - int s1_bypass = 1; - struct dma_iommu_mapping *mapping; - - mapping = arm_iommu_create_mapping(&platform_bus_type, SMMU_BASE, SMMU_SIZE); - if (IS_ERR(mapping)) { - ret = PTR_ERR(mapping); - dev_err(&pdev->dev, "Create mapping failed, err = %d\n", ret); - return NULL; - } - - ret = iommu_domain_set_attr(mapping->domain, DOMAIN_ATTR_ATOMIC, &atomic_ctx); - if (ret < 0) { - dev_err(&pdev->dev, "Set atomic_ctx attribute failed, err = %d\n", ret); - goto set_attr_fail; - } - - ret = iommu_domain_set_attr(mapping->domain, DOMAIN_ATTR_S1_BYPASS, &s1_bypass); - if (ret < 0) { - dev_err(&pdev->dev, "Set s1_bypass attribute failed, err = %d\n", ret); - arm_iommu_release_mapping(mapping); - goto set_attr_fail; - } - - ret = arm_iommu_attach_device(&pdev->dev, mapping); - if (ret < 0) { - dev_err(&pdev->dev, "Attach device failed, err = %d\n", ret); - goto attach_fail; - } - - return mapping; - -attach_fail: -set_attr_fail: - arm_iommu_release_mapping(mapping); - return NULL; -} -#endif - -int mhi_arch_iommu_init(struct mhi_controller *mhi_cntrl) -{ -#ifdef QCOM_AP_SDM845_IOMMU_MAP - struct mhi_dev *mhi_dev = mhi_controller_get_devdata(mhi_cntrl); - - mhi_smmu_mapping[mhi_cntrl->cntrl_idx] = sdm845_smmu_init(mhi_dev->pci_dev); -#endif - - return 0; -} - -void mhi_arch_iommu_deinit(struct mhi_controller *mhi_cntrl) -{ -#ifdef QCOM_AP_SDM845_IOMMU_MAP - if (mhi_smmu_mapping[mhi_cntrl->cntrl_idx]) { - struct mhi_dev *mhi_dev = mhi_controller_get_devdata(mhi_cntrl); - - arm_iommu_detach_device(&mhi_dev->pci_dev->dev); - arm_iommu_release_mapping(mhi_smmu_mapping[mhi_cntrl->cntrl_idx]); - mhi_smmu_mapping[mhi_cntrl->cntrl_idx] = NULL; - } -#endif -} - -static int mhi_arch_set_bus_request(struct mhi_controller *mhi_cntrl, int index) -{ - MHI_LOG("Setting bus request to index %d\n", index); - return 0; -} - -int mhi_arch_pcie_init(struct mhi_controller *mhi_cntrl) -{ -#ifdef QCOM_AP_AND_EFUSE_PCIE_SLEEP - struct mhi_dev *mhi_dev = mhi_controller_get_devdata(mhi_cntrl); - struct arch_info *arch_info = mhi_dev->arch_info; - - if (!arch_info) { - arch_info = devm_kzalloc(&mhi_dev->pci_dev->dev, - sizeof(*arch_info), GFP_KERNEL); - if (!arch_info) - return -ENOMEM; - - mhi_dev->arch_info = arch_info; - - /* save reference state for pcie config space */ - arch_info->ref_pcie_state = pci_store_saved_state( - mhi_dev->pci_dev); - } -#endif - - return mhi_arch_set_bus_request(mhi_cntrl, 1); -} - -void mhi_arch_pcie_deinit(struct mhi_controller *mhi_cntrl) -{ - mhi_arch_set_bus_request(mhi_cntrl, 0); -} - -int mhi_arch_platform_init(struct mhi_dev *mhi_dev) -{ - return 0; -} - -void mhi_arch_platform_deinit(struct mhi_dev *mhi_dev) -{ -} - -int mhi_arch_link_off(struct mhi_controller *mhi_cntrl, - bool graceful) -{ -#ifdef QCOM_AP_AND_EFUSE_PCIE_SLEEP - struct mhi_dev *mhi_dev = mhi_controller_get_devdata(mhi_cntrl); - struct arch_info *arch_info = mhi_dev->arch_info; - struct pci_dev *pci_dev = mhi_dev->pci_dev; - int ret; - - MHI_LOG("Entered\n"); - - if (graceful) { - pci_clear_master(pci_dev); - ret = pci_save_state(mhi_dev->pci_dev); - if (ret) { - MHI_ERR("Failed with pci_save_state, ret:%d\n", ret); - return ret; - } - - arch_info->pcie_state = pci_store_saved_state(pci_dev); - pci_disable_device(pci_dev); - } - - /* - * We will always attempt to put link into D3hot, however - * link down may have happened due to error fatal, so - * ignoring the return code - */ - pci_set_power_state(pci_dev, PCI_D3hot); - - ret = msm_pcie_pm_control(MSM_PCIE_SUSPEND, mhi_cntrl->bus, pci_dev, - NULL, 0); - MHI_ERR("msm_pcie_pm_control(MSM_PCIE_SUSPEND), ret:%d\n", ret); - - /* release the resources */ - mhi_arch_set_bus_request(mhi_cntrl, 0); - - MHI_LOG("Exited\n"); -#endif - - return 0; -} - -int mhi_arch_link_on(struct mhi_controller *mhi_cntrl) -{ -#ifdef QCOM_AP_AND_EFUSE_PCIE_SLEEP - struct mhi_dev *mhi_dev = mhi_controller_get_devdata(mhi_cntrl); - struct arch_info *arch_info = mhi_dev->arch_info; - struct pci_dev *pci_dev = mhi_dev->pci_dev; - int ret; - - MHI_LOG("Entered\n"); - - /* request resources and establish link trainning */ - ret = mhi_arch_set_bus_request(mhi_cntrl, 1); - if (ret) - MHI_LOG("Could not set bus frequency, ret:%d\n", ret); - - ret = msm_pcie_pm_control(MSM_PCIE_RESUME, mhi_cntrl->bus, pci_dev, - NULL, 0); - MHI_LOG("msm_pcie_pm_control(MSM_PCIE_RESUME), ret:%d\n", ret); - if (ret) { - MHI_ERR("Link training failed, ret:%d\n", ret); - return ret; - } - - ret = pci_set_power_state(pci_dev, PCI_D0); - if (ret) { - MHI_ERR("Failed to set PCI_D0 state, ret:%d\n", ret); - return ret; - } - - ret = pci_enable_device(pci_dev); - if (ret) { - MHI_ERR("Failed to enable device, ret:%d\n", ret); - return ret; - } - - ret = pci_load_and_free_saved_state(pci_dev, &arch_info->pcie_state); - if (ret) - MHI_LOG("Failed to load saved cfg state\n"); - - pci_restore_state(pci_dev); - pci_set_master(pci_dev); - - MHI_LOG("Exited\n"); -#endif - - return 0; -} -#endif diff --git a/quectel_MHI/src/controllers/mhi_qti.h b/quectel_MHI/src/controllers/mhi_qti.h deleted file mode 100644 index 7ac021a..0000000 --- a/quectel_MHI/src/controllers/mhi_qti.h +++ /dev/null @@ -1,44 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.*/ - -#ifndef _MHI_QTI_ -#define _MHI_QTI_ - -/* iova cfg bitmask */ -#define MHI_SMMU_ATTACH BIT(0) -#define MHI_SMMU_S1_BYPASS BIT(1) -#define MHI_SMMU_FAST BIT(2) -#define MHI_SMMU_ATOMIC BIT(3) -#define MHI_SMMU_FORCE_COHERENT BIT(4) - -#define MHI_PCIE_VENDOR_ID (0x17cb) -#define MHI_PCIE_DEBUG_ID (0xffff) - -/* runtime suspend timer */ -#define MHI_RPM_SUSPEND_TMR_MS (2000) -#define MHI_PCI_BAR_NUM (0) - -struct mhi_dev { - struct pci_dev *pci_dev; - u32 smmu_cfg; - int resn; - void *arch_info; - bool powered_on; - dma_addr_t iova_start; - dma_addr_t iova_stop; - bool lpm_disabled; -}; - -void mhi_deinit_pci_dev(struct mhi_controller *mhi_cntrl); -int mhi_pci_probe(struct pci_dev *pci_dev, - const struct pci_device_id *device_id); - -void mhi_pci_device_removed(struct pci_dev *pci_dev); -int mhi_arch_pcie_init(struct mhi_controller *mhi_cntrl); -void mhi_arch_pcie_deinit(struct mhi_controller *mhi_cntrl); -int mhi_arch_iommu_init(struct mhi_controller *mhi_cntrl); -void mhi_arch_iommu_deinit(struct mhi_controller *mhi_cntrl); -int mhi_arch_link_off(struct mhi_controller *mhi_cntrl, bool graceful); -int mhi_arch_link_on(struct mhi_controller *mhi_cntrl); - -#endif /* _MHI_QTI_ */ diff --git a/quectel_MHI/src/core/Makefile b/quectel_MHI/src/core/Makefile deleted file mode 100644 index a743fbf..0000000 --- a/quectel_MHI/src/core/Makefile +++ /dev/null @@ -1 +0,0 @@ -obj-$(CONFIG_MHI_BUS) +=mhi_init.o mhi_main.o mhi_pm.o mhi_boot.o mhi_dtr.o diff --git a/quectel_MHI/src/core/mhi.h b/quectel_MHI/src/core/mhi.h deleted file mode 100644 index fad6504..0000000 --- a/quectel_MHI/src/core/mhi.h +++ /dev/null @@ -1,908 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved. */ - -#ifndef _MHI_H_ -#define _MHI_H_ - -#define PCIE_MHI_DRIVER_VERSION "V1.3.6" -#define ENABLE_MHI_MON -//#define ENABLE_IP_SW0 - -// #define ENABLE_ADPL - -// #define ENABLE_QDSS - -#include -typedef enum -{ - MHI_CLIENT_LOOPBACK_OUT = 0, - MHI_CLIENT_LOOPBACK_IN = 1, - MHI_CLIENT_SAHARA_OUT = 2, - MHI_CLIENT_SAHARA_IN = 3, - MHI_CLIENT_DIAG_OUT = 4, - MHI_CLIENT_DIAG_IN = 5, - MHI_CLIENT_SSR_OUT = 6, - MHI_CLIENT_SSR_IN = 7, - MHI_CLIENT_QDSS_OUT = 8, - MHI_CLIENT_QDSS_IN = 9, - MHI_CLIENT_EFS_OUT = 10, - MHI_CLIENT_EFS_IN = 11, - MHI_CLIENT_MBIM_OUT = 12, - MHI_CLIENT_MBIM_IN = 13, - MHI_CLIENT_QMI_OUT = 14, - MHI_CLIENT_QMI_IN = 15, - MHI_CLIENT_QMI_2_OUT = 16, - MHI_CLIENT_QMI_2_IN = 17, - MHI_CLIENT_IP_CTRL_1_OUT = 18, - MHI_CLIENT_IP_CTRL_1_IN = 19, - MHI_CLIENT_IPCR_OUT = 20, - MHI_CLIENT_IPCR_IN = 21, - MHI_CLIENT_TEST_FW_OUT = 22, - MHI_CLIENT_TEST_FW_IN = 23, - MHI_CLIENT_RESERVED_0 = 24, - MHI_CLIENT_BOOT_LOG_IN = 25, - MHI_CLIENT_DCI_OUT = 26, - MHI_CLIENT_DCI_IN = 27, - MHI_CLIENT_QBI_OUT = 28, - MHI_CLIENT_QBI_IN = 29, - MHI_CLIENT_RESERVED_1_LOWER = 30, - MHI_CLIENT_RESERVED_1_UPPER = 31, - MHI_CLIENT_DUN_OUT = 32, - MHI_CLIENT_DUN_IN = 33, - MHI_CLIENT_EDL_OUT = 34, - MHI_CLIENT_EDL_IN = 35, - MHI_CLIENT_ADB_FB_OUT = 36, - MHI_CLIENT_ADB_FB_IN = 37, - MHI_CLIENT_RESERVED_2_LOWER = 38, - MHI_CLIENT_RESERVED_2_UPPER = 41, - MHI_CLIENT_CSVT_OUT = 42, - MHI_CLIENT_CSVT_IN = 43, - MHI_CLIENT_SMCT_OUT = 44, - MHI_CLIENT_SMCT_IN = 45, - MHI_CLIENT_IP_SW_0_OUT = 46, - MHI_CLIENT_IP_SW_0_IN = 47, - MHI_CLIENT_IP_SW_1_OUT = 48, - MHI_CLIENT_IP_SW_1_IN = 49, - MHI_CLIENT_RESERVED_3_LOWER = 50, - MHI_CLIENT_RESERVED_3_UPPER = 59, - MHI_CLIENT_TEST_0_OUT = 60, - MHI_CLIENT_TEST_0_IN = 61, - MHI_CLIENT_TEST_1_OUT = 62, - MHI_CLIENT_TEST_1_IN = 63, - MHI_CLIENT_TEST_2_OUT = 64, - MHI_CLIENT_TEST_2_IN = 65, - MHI_CLIENT_TEST_3_OUT = 66, - MHI_CLIENT_TEST_3_IN = 67, - MHI_CLIENT_RESERVED_4_LOWER = 68, - MHI_CLIENT_RESERVED_4_UPPER = 91, - MHI_CLIENT_OEM_0_OUT = 92, - MHI_CLIENT_OEM_0_IN = 93, - MHI_CLIENT_OEM_1_OUT = 94, - MHI_CLIENT_OEM_1_IN = 95, - MHI_CLIENT_OEM_2_OUT = 96, - MHI_CLIENT_OEM_2_IN = 97, - MHI_CLIENT_OEM_3_OUT = 98, - MHI_CLIENT_OEM_3_IN = 99, - MHI_CLIENT_IP_HW_0_OUT = 100, - MHI_CLIENT_IP_HW_0_IN = 101, - MHI_CLIENT_ADPL = 102, - MHI_CLIENT_IP_HW_QDSS = 103, - // MHI_CLIENT_RESERVED_5_LOWER = 103, - MHI_CLIENT_RESERVED_5_UPPER = 127, - MHI_MAX_CHANNELS = 128 -}MHI_CLIENT_CHANNEL_TYPE; - -/* Event Ring Index */ -typedef enum -{ - SW_EVT_RING = 0, - PRIMARY_EVENT_RING = SW_EVT_RING, -#ifdef ENABLE_IP_SW0 - SW_0_OUT_EVT_RING, - SW_0_IN_EVT_RING, -#endif - IPA_OUT_EVENT_RING, - IPA_IN_EVENT_RING, -#ifdef ENABLE_ADPL - ADPL_EVT_RING, -#endif -#ifdef ENABLE_QDSS - QDSS_EVT_RING, -#endif - - MAX_EVT_RING_IDX -}MHI_EVT_RING_IDX; - -#define MHI_VERSION 0x01000000 -#define MHIREGLEN_VALUE 0x100 /* **** WRONG VALUE *** */ -#define MHI_MSI_INDEX 1 -#define MAX_NUM_MHI_DEVICES 1 -#define NUM_MHI_XFER_RINGS 128 -#define NUM_MHI_EVT_RINGS MAX_EVT_RING_IDX -#define NUM_MHI_HW_EVT_RINGS 4 -#define NUM_MHI_XFER_RING_ELEMENTS 16 -#define NUM_MHI_EVT_RING_ELEMENTS (NUM_MHI_IPA_IN_RING_ELEMENTS*2) //must *2, event ring full will make x55 dump -#define NUM_MHI_IPA_IN_RING_ELEMENTS 512 -#define NUM_MHI_IPA_OUT_RING_ELEMENTS 512 //donot use ul agg, so increase -#define NUM_MHI_DIAG_IN_RING_ELEMENTS 128 -#define NUM_MHI_SW_IP_RING_ELEMENTS 512 - -#ifdef ENABLE_ADPL -#define NUM_MHI_ADPL_RING_ELEMENTS 256 -#endif - -#ifdef ENABLE_QDSS -#define NUM_MHI_QDSS_RING_ELEMENTS 256 -#endif - -/* -* for if set Interrupt moderation time as 1ms, -and transfer more than NUM_MHI_CHAN_RING_ELEMENTS data are sent to the modem in 1ms. -e.g. firehose upgrade. -modem will not trigger irq for these transfer. -*/ -#define NUM_MHI_CHAN_RING_ELEMENTS 32 //8 -#define MHI_EVT_CMD_QUEUE_SIZE 160 -#define MHI_EVT_STATE_QUEUE_SIZE 128 -#define MHI_EVT_XFER_QUEUE_SIZE 1024 - -#define CHAN_INBOUND(_x) ((_x)%2) - -#define CHAN_SBL(_x) (((_x) == MHI_CLIENT_SAHARA_OUT) || \ - ((_x) == MHI_CLIENT_SAHARA_IN) || \ - ((_x) == MHI_CLIENT_BOOT_LOG_IN)) - -#define CHAN_EDL(_x) (((_x) == MHI_CLIENT_EDL_OUT) || \ - ((_x) == MHI_CLIENT_EDL_IN)) - -struct mhi_chan; -struct mhi_event; -struct mhi_ctxt; -struct mhi_cmd; -struct image_info; -struct bhi_vec_entry; -struct mhi_timesync; -struct mhi_buf_info; - -/** - * enum MHI_CB - MHI callback - * @MHI_CB_IDLE: MHI entered idle state - * @MHI_CB_PENDING_DATA: New data available for client to process - * @MHI_CB_LPM_ENTER: MHI host entered low power mode - * @MHI_CB_LPM_EXIT: MHI host about to exit low power mode - * @MHI_CB_EE_RDDM: MHI device entered RDDM execution enviornment - * @MHI_CB_EE_MISSION_MODE: MHI device entered Mission Mode exec env - * @MHI_CB_SYS_ERROR: MHI device enter error state (may recover) - * @MHI_CB_FATAL_ERROR: MHI device entered fatal error - */ -enum MHI_CB { - MHI_CB_IDLE, - MHI_CB_PENDING_DATA, - MHI_CB_LPM_ENTER, - MHI_CB_LPM_EXIT, - MHI_CB_EE_RDDM, - MHI_CB_EE_MISSION_MODE, - MHI_CB_SYS_ERROR, - MHI_CB_FATAL_ERROR, -}; - -/** - * enum MHI_DEBUG_LEVL - various debugging level - */ -enum MHI_DEBUG_LEVEL { - MHI_MSG_LVL_VERBOSE, - MHI_MSG_LVL_INFO, - MHI_MSG_LVL_ERROR, - MHI_MSG_LVL_CRITICAL, - MHI_MSG_LVL_MASK_ALL, -}; - -/* -GSI_XFER_FLAG_BEI: Block event interrupt -1: Event generated by this ring element must not assert an interrupt to the host -0: Event generated by this ring element must assert an interrupt to the host - -GSI_XFER_FLAG_EOT: Interrupt on end of transfer -1: If an EOT condition is encountered when processing this ring element, an event is generated by the device with its completion code set to EOT. -0: If an EOT condition is encountered for this ring element, a completion event is not be generated by the device, unless IEOB is 1 - -GSI_XFER_FLAG_EOB: Interrupt on end of block -1: Device notifies host after processing this ring element by sending a completion event -0: Completion event is not required after processing this ring element - -GSI_XFER_FLAG_CHAIN: Chain bit that identifies the ring elements in a TD -*/ - -/** - * enum MHI_FLAGS - Transfer flags - * @MHI_EOB: End of buffer for bulk transfer - * @MHI_EOT: End of transfer - * @MHI_CHAIN: Linked transfer - */ -enum MHI_FLAGS { - MHI_EOB, - MHI_EOT, - MHI_CHAIN, -}; - -/** - * enum mhi_device_type - Device types - * @MHI_XFER_TYPE: Handles data transfer - * @MHI_TIMESYNC_TYPE: Use for timesync feature - * @MHI_CONTROLLER_TYPE: Control device - */ -enum mhi_device_type { - MHI_XFER_TYPE, - MHI_TIMESYNC_TYPE, - MHI_CONTROLLER_TYPE, -}; - -/** - * enum mhi_ee - device current execution enviornment - * @MHI_EE_PBL - device in PBL - * @MHI_EE_SBL - device in SBL - * @MHI_EE_AMSS - device in mission mode (firmware fully loaded) - * @MHI_EE_RDDM - device in ram dump collection mode - * @MHI_EE_WFW - device in WLAN firmware mode - * @MHI_EE_PTHRU - device in PBL but configured in pass thru mode - * @MHI_EE_EDL - device in emergency download mode - */ -enum mhi_ee { - MHI_EE_PBL = 0x0, - MHI_EE_SBL = 0x1, - MHI_EE_AMSS = 0x2, - MHI_EE_RDDM = 0x3, - MHI_EE_WFW = 0x4, - MHI_EE_PTHRU = 0x5, - MHI_EE_EDL = 0x6, - MHI_EE_FP = 0x7, /* FlashProg, Flash Programmer Environment */ - MHI_EE_MAX_SUPPORTED = MHI_EE_FP, - MHI_EE_DISABLE_TRANSITION, /* local EE, not related to mhi spec */ - MHI_EE_MAX, -}; - -/** - * enum mhi_dev_state - device current MHI state - */ -enum mhi_dev_state { - MHI_STATE_RESET = 0x0, - MHI_STATE_READY = 0x1, - MHI_STATE_M0 = 0x2, - MHI_STATE_M1 = 0x3, - MHI_STATE_M2 = 0x4, - MHI_STATE_M3 = 0x5, - MHI_STATE_BHI = 0x7, - MHI_STATE_SYS_ERR = 0xFF, - MHI_STATE_MAX, -}; - -extern const char * const mhi_ee_str[MHI_EE_MAX]; -#define TO_MHI_EXEC_STR(ee) (((ee) >= MHI_EE_MAX) ? \ - "INVALID_EE" : mhi_ee_str[ee]) - -/** - * struct image_info - firmware and rddm table table - * @mhi_buf - Contain device firmware and rddm table - * @entries - # of entries in table - */ -struct image_info { - struct mhi_buf *mhi_buf; - struct bhi_vec_entry *bhi_vec; - u32 entries; -}; - -/** - * struct mhi_controller - Master controller structure for external modem - * @dev: Device associated with this controller - * @of_node: DT that has MHI configuration information - * @regs: Points to base of MHI MMIO register space - * @bhi: Points to base of MHI BHI register space - * @bhie: Points to base of MHI BHIe register space - * @wake_db: MHI WAKE doorbell register address - * @dev_id: PCIe device id of the external device - * @domain: PCIe domain the device connected to - * @bus: PCIe bus the device assigned to - * @slot: PCIe slot for the modem - * @iova_start: IOMMU starting address for data - * @iova_stop: IOMMU stop address for data - * @fw_image: Firmware image name for normal booting - * @edl_image: Firmware image name for emergency download mode - * @fbc_download: MHI host needs to do complete image transfer - * @rddm_size: RAM dump size that host should allocate for debugging purpose - * @sbl_size: SBL image size - * @seg_len: BHIe vector size - * @fbc_image: Points to firmware image buffer - * @rddm_image: Points to RAM dump buffer - * @max_chan: Maximum number of channels controller support - * @mhi_chan: Points to channel configuration table - * @lpm_chans: List of channels that require LPM notifications - * @total_ev_rings: Total # of event rings allocated - * @hw_ev_rings: Number of hardware event rings - * @sw_ev_rings: Number of software event rings - * @msi_required: Number of msi required to operate - * @msi_allocated: Number of msi allocated by bus master - * @irq: base irq # to request - * @mhi_event: MHI event ring configurations table - * @mhi_cmd: MHI command ring configurations table - * @mhi_ctxt: MHI device context, shared memory between host and device - * @timeout_ms: Timeout in ms for state transitions - * @pm_state: Power management state - * @ee: MHI device execution environment - * @dev_state: MHI STATE - * @status_cb: CB function to notify various power states to but master - * @link_status: Query link status in case of abnormal value read from device - * @runtime_get: Async runtime resume function - * @runtimet_put: Release votes - * @time_get: Return host time in us - * @lpm_disable: Request controller to disable link level low power modes - * @lpm_enable: Controller may enable link level low power modes again - * @priv_data: Points to bus master's private data - */ -struct mhi_controller { - struct list_head node; - struct mhi_device *mhi_dev; - - /* device node for iommu ops */ - struct device *dev; - struct device_node *of_node; - - /* mmio base */ - phys_addr_t base_addr; - void __iomem *regs; - void __iomem *bhi; - void __iomem *bhie; - void __iomem *wake_db; - - /* device topology */ - u32 vendor; - u32 dev_id; - u32 domain; - u32 bus; - u32 slot; - u32 cntrl_idx; - struct device *cntrl_dev; - - /* addressing window */ - dma_addr_t iova_start; - dma_addr_t iova_stop; - - /* fw images */ - const char *fw_image; - const char *edl_image; - - /* mhi host manages downloading entire fbc images */ - bool fbc_download; - size_t rddm_size; - size_t sbl_size; - size_t seg_len; - u32 session_id; - u32 sequence_id; - struct image_info *fbc_image; - struct image_info *rddm_image; - - /* physical channel config data */ - u32 max_chan; - struct mhi_chan *mhi_chan; - struct list_head lpm_chans; /* these chan require lpm notification */ - - /* physical event config data */ - u32 total_ev_rings; - u32 hw_ev_rings; - u32 sw_ev_rings; - u32 msi_required; - u32 msi_allocated; - u32 msi_irq_base; - int *irq; /* interrupt table */ - struct mhi_event *mhi_event; - - /* cmd rings */ - struct mhi_cmd *mhi_cmd; - - /* mhi context (shared with device) */ - struct mhi_ctxt *mhi_ctxt; - - u32 timeout_ms; - - /* caller should grab pm_mutex for suspend/resume operations */ - struct mutex pm_mutex; - bool pre_init; - rwlock_t pm_lock; - u32 pm_state; - enum mhi_ee ee; - enum mhi_dev_state dev_state; - bool wake_set; - atomic_t dev_wake; - atomic_t alloc_size; - atomic_t pending_pkts; - struct list_head transition_list; - spinlock_t transition_lock; - spinlock_t wlock; - - /* debug counters */ - u32 M0, M2, M3; - - /* worker for different state transitions */ - struct work_struct st_worker; - struct work_struct fw_worker; - struct work_struct syserr_worker; - struct delayed_work ready_worker; - wait_queue_head_t state_event; - - /* shadow functions */ - void (*status_cb)(struct mhi_controller *mhi_cntrl, void *priv, - enum MHI_CB reason); - int (*link_status)(struct mhi_controller *mhi_cntrl, void *priv); - void (*wake_get)(struct mhi_controller *mhi_cntrl, bool override); - void (*wake_put)(struct mhi_controller *mhi_cntrl, bool override); - int (*runtime_get)(struct mhi_controller *mhi_cntrl, void *priv); - void (*runtime_put)(struct mhi_controller *mhi_cntrl, void *priv); - void (*runtime_mark_last_busy)(struct mhi_controller *mhi_cntrl, void *priv); - u64 (*time_get)(struct mhi_controller *mhi_cntrl, void *priv); - int (*lpm_disable)(struct mhi_controller *mhi_cntrl, void *priv); - int (*lpm_enable)(struct mhi_controller *mhi_cntrl, void *priv); - int (*map_single)(struct mhi_controller *mhi_cntrl, - struct mhi_buf_info *buf); - void (*unmap_single)(struct mhi_controller *mhi_cntrl, - struct mhi_buf_info *buf); - - /* channel to control DTR messaging */ - struct mhi_device *dtr_dev; - - /* bounce buffer settings */ - bool bounce_buf; - size_t buffer_len; - - /* supports time sync feature */ - struct mhi_timesync *mhi_tsync; - struct mhi_device *tsync_dev; - - /* kernel log level */ - enum MHI_DEBUG_LEVEL klog_lvl; - int klog_slient; - - /* private log level controller driver to set */ - enum MHI_DEBUG_LEVEL log_lvl; - - /* controller specific data */ - void *priv_data; - void *log_buf; - struct dentry *dentry; - struct dentry *parent; - - struct miscdevice miscdev; - -#ifdef ENABLE_MHI_MON - spinlock_t lock; - - /* Ref */ - int nreaders; /* Under mon_lock AND mbus->lock */ - struct list_head r_list; /* Chain of readers (usually one) */ - struct kref ref; /* Under mon_lock */ - - /* Stats */ - unsigned int cnt_events; - unsigned int cnt_text_lost; -#endif -}; - -#ifdef ENABLE_MHI_MON -struct mhi_tre; -struct mon_reader { - struct list_head r_link; - struct mhi_controller *m_bus; - void *r_data; /* Use container_of instead? */ - - void (*rnf_submit)(void *data, u32 chan, dma_addr_t wp, struct mhi_tre *mhi_tre, void *buf, size_t len); - void (*rnf_receive)(void *data, u32 chan, dma_addr_t wp, struct mhi_tre *mhi_tre, void *buf, size_t len); - void (*rnf_complete)(void *data, u32 chan, dma_addr_t wp, struct mhi_tre *mhi_tre); -}; -#endif - -/** - * struct mhi_device - mhi device structure associated bind to channel - * @dev: Device associated with the channels - * @mtu: Maximum # of bytes controller support - * @ul_chan_id: MHI channel id for UL transfer - * @dl_chan_id: MHI channel id for DL transfer - * @tiocm: Device current terminal settings - * @priv: Driver private data - */ -struct mhi_device { - struct device dev; - u32 vendor; - u32 dev_id; - u32 domain; - u32 bus; - u32 slot; - size_t mtu; - int ul_chan_id; - int dl_chan_id; - int ul_event_id; - int dl_event_id; - u32 tiocm; - const struct mhi_device_id *id; - const char *chan_name; - struct mhi_controller *mhi_cntrl; - struct mhi_chan *ul_chan; - struct mhi_chan *dl_chan; - atomic_t dev_wake; - enum mhi_device_type dev_type; - void *priv_data; - int (*ul_xfer)(struct mhi_device *mhi_dev, struct mhi_chan *mhi_chan, - void *buf, size_t len, enum MHI_FLAGS flags); - int (*dl_xfer)(struct mhi_device *mhi_dev, struct mhi_chan *mhi_chan, - void *buf, size_t size, enum MHI_FLAGS flags); - void (*status_cb)(struct mhi_device *mhi_dev, enum MHI_CB reason); -}; - -/** - * struct mhi_result - Completed buffer information - * @buf_addr: Address of data buffer - * @dir: Channel direction - * @bytes_xfer: # of bytes transferred - * @transaction_status: Status of last trasnferred - */ -struct mhi_result { - void *buf_addr; - enum dma_data_direction dir; - size_t bytes_xferd; - int transaction_status; -}; - -/** - * struct mhi_buf - Describes the buffer - * @page: buffer as a page - * @buf: cpu address for the buffer - * @phys_addr: physical address of the buffer - * @dma_addr: iommu address for the buffer - * @skb: skb of ip packet - * @len: # of bytes - * @name: Buffer label, for offload channel configurations name must be: - * ECA - Event context array data - * CCA - Channel context array data - */ -struct mhi_buf { - struct list_head node; - struct page *page; - void *buf; - phys_addr_t phys_addr; - dma_addr_t dma_addr; - struct sk_buff *skb; - size_t len; - const char *name; /* ECA, CCA */ -}; - -/** - * struct mhi_driver - mhi driver information - * @id_table: NULL terminated channel ID names - * @ul_xfer_cb: UL data transfer callback - * @dl_xfer_cb: DL data transfer callback - * @status_cb: Asynchronous status callback - */ -struct mhi_driver { - const struct mhi_device_id *id_table; - int (*probe)(struct mhi_device *mhi_dev, - const struct mhi_device_id *id); - void (*remove)(struct mhi_device *mhi_dev); - void (*ul_xfer_cb)(struct mhi_device *mhi_dev, struct mhi_result *res); - void (*dl_xfer_cb)(struct mhi_device *mhi_dev, struct mhi_result *res); - void (*status_cb)(struct mhi_device *mhi_dev, enum MHI_CB mhi_cb); - struct device_driver driver; -}; - -#define to_mhi_driver(drv) container_of(drv, struct mhi_driver, driver) -#define to_mhi_device(dev) container_of(dev, struct mhi_device, dev) - -static inline void mhi_device_set_devdata(struct mhi_device *mhi_dev, - void *priv) -{ - mhi_dev->priv_data = priv; -} - -static inline void *mhi_device_get_devdata(struct mhi_device *mhi_dev) -{ - return mhi_dev->priv_data; -} - -/** - * mhi_queue_transfer - Queue a buffer to hardware - * All transfers are asyncronous transfers - * @mhi_dev: Device associated with the channels - * @dir: Data direction - * @buf: Data buffer (skb for hardware channels) - * @len: Size in bytes - * @mflags: Interrupt flags for the device - */ -static inline int mhi_queue_transfer(struct mhi_device *mhi_dev, - enum dma_data_direction dir, - void *buf, - size_t len, - enum MHI_FLAGS mflags) -{ - if (dir == DMA_TO_DEVICE) - return mhi_dev->ul_xfer(mhi_dev, mhi_dev->ul_chan, buf, len, - mflags); - else - return mhi_dev->dl_xfer(mhi_dev, mhi_dev->dl_chan, buf, len, - mflags); -} - -static inline void *mhi_controller_get_devdata(struct mhi_controller *mhi_cntrl) -{ - return mhi_cntrl->priv_data; -} - -static inline void mhi_free_controller(struct mhi_controller *mhi_cntrl) -{ - kfree(mhi_cntrl); -} - -/** - * mhi_driver_register - Register driver with MHI framework - * @mhi_drv: mhi_driver structure - */ -int mhi_driver_register(struct mhi_driver *mhi_drv); - -/** - * mhi_driver_unregister - Unregister a driver for mhi_devices - * @mhi_drv: mhi_driver structure - */ -void mhi_driver_unregister(struct mhi_driver *mhi_drv); - -/** - * mhi_device_configure - configure ECA or CCA context - * For offload channels that client manage, call this - * function to configure channel context or event context - * array associated with the channel - * @mhi_div: Device associated with the channels - * @dir: Direction of the channel - * @mhi_buf: Configuration data - * @elements: # of configuration elements - */ -int mhi_device_configure(struct mhi_device *mhi_div, - enum dma_data_direction dir, - struct mhi_buf *mhi_buf, - int elements); - -/** - * mhi_device_get - disable all low power modes - * Only disables lpm, does not immediately exit low power mode - * if controller already in a low power mode - * @mhi_dev: Device associated with the channels - */ -void mhi_device_get(struct mhi_device *mhi_dev); - -/** - * mhi_device_get_sync - disable all low power modes - * Synchronously disable all low power, exit low power mode if - * controller already in a low power state - * @mhi_dev: Device associated with the channels - */ -int mhi_device_get_sync(struct mhi_device *mhi_dev); - -/** - * mhi_device_put - re-enable low power modes - * @mhi_dev: Device associated with the channels - */ -void mhi_device_put(struct mhi_device *mhi_dev); - -/** - * mhi_prepare_for_transfer - setup channel for data transfer - * Moves both UL and DL channel from RESET to START state - * @mhi_dev: Device associated with the channels - */ -int mhi_prepare_for_transfer(struct mhi_device *mhi_dev); - -/** - * mhi_unprepare_from_transfer -unprepare the channels - * Moves both UL and DL channels to RESET state - * @mhi_dev: Device associated with the channels - */ -void mhi_unprepare_from_transfer(struct mhi_device *mhi_dev); - -/** - * mhi_get_no_free_descriptors - Get transfer ring length - * Get # of TD available to queue buffers - * @mhi_dev: Device associated with the channels - * @dir: Direction of the channel - */ -int mhi_get_no_free_descriptors(struct mhi_device *mhi_dev, - enum dma_data_direction dir); - -/** - * mhi_poll - poll for any available data to consume - * This is only applicable for DL direction - * @mhi_dev: Device associated with the channels - * @budget: In descriptors to service before returning - */ -int mhi_poll(struct mhi_device *mhi_dev, u32 budget); - -/** - * mhi_ioctl - user space IOCTL support for MHI channels - * Native support for setting TIOCM - * @mhi_dev: Device associated with the channels - * @cmd: IOCTL cmd - * @arg: Optional parameter, iotcl cmd specific - */ -long mhi_ioctl(struct mhi_device *mhi_dev, unsigned int cmd, unsigned long arg); - -/** - * mhi_alloc_controller - Allocate mhi_controller structure - * Allocate controller structure and additional data for controller - * private data. You may get the private data pointer by calling - * mhi_controller_get_devdata - * @size: # of additional bytes to allocate - */ -struct mhi_controller *mhi_alloc_controller(size_t size); - -/** - * of_register_mhi_controller - Register MHI controller - * Registers MHI controller with MHI bus framework. DT must be supported - * @mhi_cntrl: MHI controller to register - */ -int of_register_mhi_controller(struct mhi_controller *mhi_cntrl); - -void mhi_unregister_mhi_controller(struct mhi_controller *mhi_cntrl); - -/** - * mhi_bdf_to_controller - Look up a registered controller - * Search for controller based on device identification - * @domain: RC domain of the device - * @bus: Bus device connected to - * @slot: Slot device assigned to - * @dev_id: Device Identification - */ -struct mhi_controller *mhi_bdf_to_controller(u32 domain, u32 bus, u32 slot, - u32 dev_id); - -/** - * mhi_prepare_for_power_up - Do pre-initialization before power up - * This is optional, call this before power up if controller do not - * want bus framework to automatically free any allocated memory during shutdown - * process. - * @mhi_cntrl: MHI controller - */ -int mhi_prepare_for_power_up(struct mhi_controller *mhi_cntrl); - -/** - * mhi_async_power_up - Starts MHI power up sequence - * @mhi_cntrl: MHI controller - */ -int mhi_async_power_up(struct mhi_controller *mhi_cntrl); -int mhi_sync_power_up(struct mhi_controller *mhi_cntrl); - -/** - * mhi_power_down - Start MHI power down sequence - * @mhi_cntrl: MHI controller - * @graceful: link is still accessible, do a graceful shutdown process otherwise - * we will shutdown host w/o putting device into RESET state - */ -void mhi_power_down(struct mhi_controller *mhi_cntrl, bool graceful); - -/** - * mhi_unprepare_after_powre_down - free any allocated memory for power up - * @mhi_cntrl: MHI controller - */ -void mhi_unprepare_after_power_down(struct mhi_controller *mhi_cntrl); - -/** - * mhi_pm_suspend - Move MHI into a suspended state - * Transition to MHI state M3 state from M0||M1||M2 state - * @mhi_cntrl: MHI controller - */ -int mhi_pm_suspend(struct mhi_controller *mhi_cntrl); - -/** - * mhi_pm_resume - Resume MHI from suspended state - * Transition to MHI state M0 state from M3 state - * @mhi_cntrl: MHI controller - */ -int mhi_pm_resume(struct mhi_controller *mhi_cntrl); - -/** - * mhi_download_rddm_img - Download ramdump image from device for - * debugging purpose. - * @mhi_cntrl: MHI controller - * @in_panic: If we trying to capture image while in kernel panic - */ -int mhi_download_rddm_img(struct mhi_controller *mhi_cntrl, bool in_panic); - -/** - * mhi_force_rddm_mode - Force external device into rddm mode - * to collect device ramdump. This is useful if host driver assert - * and we need to see device state as well. - * @mhi_cntrl: MHI controller - */ -int mhi_force_rddm_mode(struct mhi_controller *mhi_cntrl); - -/** - * mhi_get_remote_time_sync - Get external soc time relative to local soc time - * using MMIO method. - * @mhi_dev: Device associated with the channels - * @t_host: Pointer to output local soc time - * @t_dev: Pointer to output remote soc time - */ -int mhi_get_remote_time_sync(struct mhi_device *mhi_dev, - u64 *t_host, - u64 *t_dev); - -/** - * mhi_get_mhi_state - Return MHI state of device - * @mhi_cntrl: MHI controller - */ -enum mhi_dev_state mhi_get_mhi_state(struct mhi_controller *mhi_cntrl); - -/** - * mhi_set_mhi_state - Set device state - * @mhi_cntrl: MHI controller - * @state: state to set - */ -void mhi_set_mhi_state(struct mhi_controller *mhi_cntrl, - enum mhi_dev_state state); - - -/** - * mhi_is_active - helper function to determine if MHI in active state - * @mhi_dev: client device - */ -static inline bool mhi_is_active(struct mhi_device *mhi_dev) -{ - struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; - - return (mhi_cntrl->dev_state >= MHI_STATE_M0 && - mhi_cntrl->dev_state <= MHI_STATE_M3); -} - -/** - * mhi_debug_reg_dump - dump MHI registers for debug purpose - * @mhi_cntrl: MHI controller - */ -void mhi_debug_reg_dump(struct mhi_controller *mhi_cntrl); - -#ifdef CONFIG_MHI_DEBUG - -#define MHI_VERB(fmt, ...) do { \ - if (mhi_cntrl->klog_lvl <= MHI_MSG_LVL_VERBOSE) \ - pr_debug("[D][mhi%d][%s] " fmt, mhi_cntrl->cntrl_idx, __func__, ##__VA_ARGS__);\ -} while (0) - -#else - -#define MHI_VERB(fmt, ...) - -#endif - -#define MHI_LOG(fmt, ...) do { \ - if (mhi_cntrl->klog_lvl <= MHI_MSG_LVL_INFO) \ - pr_info("[I][mhi%d][%s] " fmt, mhi_cntrl->cntrl_idx, __func__, ##__VA_ARGS__);\ - else if (!mhi_cntrl->klog_slient) \ - printk(KERN_DEBUG "[I][mhi%d][%s] " fmt, mhi_cntrl->cntrl_idx, __func__, ##__VA_ARGS__);\ -} while (0) - -#define MHI_ERR(fmt, ...) do { \ - if (mhi_cntrl->klog_lvl <= MHI_MSG_LVL_ERROR) \ - pr_err("[E][mhi%d][%s] " fmt, mhi_cntrl->cntrl_idx, __func__, ##__VA_ARGS__); \ -} while (0) - -#define MHI_CRITICAL(fmt, ...) do { \ - if (mhi_cntrl->klog_lvl <= MHI_MSG_LVL_CRITICAL) \ - pr_alert("[C][mhi%d][%s] " fmt, mhi_cntrl->cntrl_idx, __func__, ##__VA_ARGS__); \ -} while (0) - -int mhi_register_mhi_controller(struct mhi_controller *mhi_cntrl); -void mhi_unregister_mhi_controller(struct mhi_controller *mhi_cntrl); - -#ifndef MHI_NAME_SIZE -#define MHI_NAME_SIZE 32 -/** - * * struct mhi_device_id - MHI device identification - * * @chan: MHI channel name - * * @driver_data: driver data; - * */ -struct mhi_device_id { - const char chan[MHI_NAME_SIZE]; - unsigned long driver_data; -}; -#endif - -#endif /* _MHI_H_ */ diff --git a/quectel_MHI/src/core/mhi_boot.c b/quectel_MHI/src/core/mhi_boot.c deleted file mode 100644 index 8f1924f..0000000 --- a/quectel_MHI/src/core/mhi_boot.c +++ /dev/null @@ -1,860 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved. */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "mhi.h" -#include "mhi_internal.h" - -/* Software defines */ -/* BHI Version */ -#define BHI_MAJOR_VERSION 0x1 -#define BHI_MINOR_VERSION 0x1 - -#define MSMHWID_NUMDWORDS 6 /* Number of dwords that make the MSMHWID */ -#define OEMPKHASH_NUMDWORDS 48 /* Number of dwords that make the OEM PK HASH */ - -#define IsPBLExecEnv(ExecEnv) ((ExecEnv == MHI_EE_PBL) || (ExecEnv == MHI_EE_EDL) ) - -typedef u32 ULONG; - -typedef struct _bhi_info_type -{ - ULONG bhi_ver_minor; - ULONG bhi_ver_major; - ULONG bhi_image_address_low; - ULONG bhi_image_address_high; - ULONG bhi_image_size; - ULONG bhi_rsvd1; - ULONG bhi_imgtxdb; - ULONG bhi_rsvd2; - ULONG bhi_msivec; - ULONG bhi_rsvd3; - ULONG bhi_ee; - ULONG bhi_status; - ULONG bhi_errorcode; - ULONG bhi_errdbg1; - ULONG bhi_errdbg2; - ULONG bhi_errdbg3; - ULONG bhi_sernum; - ULONG bhi_sblantirollbackver; - ULONG bhi_numsegs; - ULONG bhi_msmhwid[6]; - ULONG bhi_oempkhash[48]; - ULONG bhi_rsvd5; -}BHI_INFO_TYPE, *PBHI_INFO_TYPE; - -static void PrintBhiInfo(struct mhi_controller *mhi_cntrl, BHI_INFO_TYPE *bhi_info) -{ - ULONG index; - char str[128]; - - MHI_LOG("BHI Device Info...\n"); - MHI_LOG("BHI Version = { Major = 0x%X Minor = 0x%X}\n", bhi_info->bhi_ver_major, bhi_info->bhi_ver_minor); - MHI_LOG("BHI Execution Environment = 0x%X\n", bhi_info->bhi_ee); - MHI_LOG("BHI Status = 0x%X\n", bhi_info->bhi_status); - MHI_LOG("BHI Error code = 0x%X { Dbg1 = 0x%X Dbg2 = 0x%X Dbg3 = 0x%X }\n", bhi_info->bhi_errorcode, bhi_info->bhi_errdbg1, bhi_info->bhi_errdbg2, bhi_info->bhi_errdbg3); - MHI_LOG("BHI Serial Number = 0x%X\n", bhi_info->bhi_sernum); - MHI_LOG("BHI SBL Anti-Rollback Ver = 0x%X\n", bhi_info->bhi_sblantirollbackver); - MHI_LOG("BHI Number of Segments = 0x%X\n", bhi_info->bhi_numsegs); - for (index = 0; index < 6; index++) - { - snprintf(str+3*index, sizeof(str)-3*index, "%02x ", bhi_info->bhi_msmhwid[index]); - } - MHI_LOG("BHI MSM HW-Id = %s\n", str); - - for (index = 0; index < 24; index++) - { - snprintf(str+3*index, sizeof(str)-3*index, "%02x ", bhi_info->bhi_oempkhash[index]); - } - MHI_LOG("BHI OEM PK Hash = %s\n", str); -} - -static u32 bhi_read_reg(struct mhi_controller *mhi_cntrl, u32 offset) -{ - u32 out = 0; - int ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->bhi, BHI_EXECENV, &out); - - return (ret) ? 0 : out; -} - -static int BhiRead(struct mhi_controller *mhi_cntrl, BHI_INFO_TYPE *bhi_info) -{ - ULONG index; - - memset(bhi_info, 0x00, sizeof(BHI_INFO_TYPE)); - - /* bhi_ver */ - bhi_info->bhi_ver_minor = bhi_read_reg(mhi_cntrl, BHI_BHIVERSION_MINOR); - bhi_info->bhi_ver_major = bhi_read_reg(mhi_cntrl, BHI_BHIVERSION_MINOR); - bhi_info->bhi_image_address_low = bhi_read_reg(mhi_cntrl, BHI_IMGADDR_LOW); - bhi_info->bhi_image_address_high = bhi_read_reg(mhi_cntrl, BHI_IMGADDR_HIGH); - bhi_info->bhi_image_size = bhi_read_reg(mhi_cntrl, BHI_IMGSIZE); - bhi_info->bhi_rsvd1 = bhi_read_reg(mhi_cntrl, BHI_RSVD1); - bhi_info->bhi_imgtxdb = bhi_read_reg(mhi_cntrl, BHI_IMGTXDB); - bhi_info->bhi_rsvd2 = bhi_read_reg(mhi_cntrl, BHI_RSVD2); - bhi_info->bhi_msivec = bhi_read_reg(mhi_cntrl, BHI_INTVEC); - bhi_info->bhi_rsvd3 = bhi_read_reg(mhi_cntrl, BHI_RSVD3); - bhi_info->bhi_ee = bhi_read_reg(mhi_cntrl, BHI_EXECENV); - bhi_info->bhi_status = bhi_read_reg(mhi_cntrl, BHI_STATUS); - bhi_info->bhi_errorcode = bhi_read_reg(mhi_cntrl, BHI_ERRCODE); - bhi_info->bhi_errdbg1 = bhi_read_reg(mhi_cntrl, BHI_ERRDBG1); - bhi_info->bhi_errdbg2 = bhi_read_reg(mhi_cntrl, BHI_ERRDBG2); - bhi_info->bhi_errdbg3 = bhi_read_reg(mhi_cntrl, BHI_ERRDBG3); - bhi_info->bhi_sernum = bhi_read_reg(mhi_cntrl, BHI_SERIALNU); - bhi_info->bhi_sblantirollbackver = bhi_read_reg(mhi_cntrl, BHI_SBLANTIROLLVER); - bhi_info->bhi_numsegs = bhi_read_reg(mhi_cntrl, BHI_NUMSEG); - for (index = 0; index < MSMHWID_NUMDWORDS; index++) - { - bhi_info->bhi_msmhwid[index] = bhi_read_reg(mhi_cntrl, BHI_MSMHWID(index)); - } - for (index = 0; index < OEMPKHASH_NUMDWORDS; index++) - { - bhi_info->bhi_oempkhash[index] = bhi_read_reg(mhi_cntrl, BHI_OEMPKHASH(index)); - } - bhi_info->bhi_rsvd5 = bhi_read_reg(mhi_cntrl, BHI_RSVD5); - PrintBhiInfo(mhi_cntrl, bhi_info); - /* Check the Execution Environment */ - if (!IsPBLExecEnv(bhi_info->bhi_ee)) - { - MHI_LOG("E - EE: 0x%X Expected PBL/EDL\n", bhi_info->bhi_ee); - } - - /* Return the number of bytes read */ - return 0; -} - -/* setup rddm vector table for rddm transfer */ -static void mhi_rddm_prepare(struct mhi_controller *mhi_cntrl, - struct image_info *img_info) -{ - struct mhi_buf *mhi_buf = img_info->mhi_buf; - struct bhi_vec_entry *bhi_vec = img_info->bhi_vec; - int i = 0; - - for (i = 0; i < img_info->entries - 1; i++, mhi_buf++, bhi_vec++) { - MHI_VERB("Setting vector:%pad size:%zu\n", - &mhi_buf->dma_addr, mhi_buf->len); - bhi_vec->dma_addr = mhi_buf->dma_addr; - bhi_vec->size = mhi_buf->len; - } -} - -/* collect rddm during kernel panic */ -static int __mhi_download_rddm_in_panic(struct mhi_controller *mhi_cntrl) -{ - int ret; - struct mhi_buf *mhi_buf; - u32 sequence_id; - u32 rx_status; - enum mhi_ee ee; - struct image_info *rddm_image = mhi_cntrl->rddm_image; - const u32 delayus = 2000; - u32 retry = (mhi_cntrl->timeout_ms * 1000) / delayus; - const u32 rddm_timeout_us = 200000; - int rddm_retry = rddm_timeout_us / delayus; /* time to enter rddm */ - void __iomem *base = mhi_cntrl->bhie; - - MHI_LOG("Entered with pm_state:%s dev_state:%s ee:%s\n", - to_mhi_pm_state_str(mhi_cntrl->pm_state), - TO_MHI_STATE_STR(mhi_cntrl->dev_state), - TO_MHI_EXEC_STR(mhi_cntrl->ee)); - - /* - * This should only be executing during a kernel panic, we expect all - * other cores to shutdown while we're collecting rddm buffer. After - * returning from this function, we expect device to reset. - * - * Normaly, we would read/write pm_state only after grabbing - * pm_lock, since we're in a panic, skipping it. Also there is no - * gurantee this state change would take effect since - * we're setting it w/o grabbing pmlock, it's best effort - */ - mhi_cntrl->pm_state = MHI_PM_LD_ERR_FATAL_DETECT; - /* update should take the effect immediately */ - smp_wmb(); - - /* setup the RX vector table */ - mhi_rddm_prepare(mhi_cntrl, rddm_image); - mhi_buf = &rddm_image->mhi_buf[rddm_image->entries - 1]; - - MHI_LOG("Starting BHIe programming for RDDM\n"); - - mhi_write_reg(mhi_cntrl, base, BHIE_RXVECADDR_HIGH_OFFS, - upper_32_bits(mhi_buf->dma_addr)); - - mhi_write_reg(mhi_cntrl, base, BHIE_RXVECADDR_LOW_OFFS, - lower_32_bits(mhi_buf->dma_addr)); - - mhi_write_reg(mhi_cntrl, base, BHIE_RXVECSIZE_OFFS, mhi_buf->len); -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)) - sequence_id = get_random_u32() & BHIE_RXVECSTATUS_SEQNUM_BMSK; -#else - sequence_id = prandom_u32() & BHIE_RXVECSTATUS_SEQNUM_BMSK; -#endif - if (unlikely(!sequence_id)) - sequence_id = 1; - - - mhi_write_reg_field(mhi_cntrl, base, BHIE_RXVECDB_OFFS, - BHIE_RXVECDB_SEQNUM_BMSK, BHIE_RXVECDB_SEQNUM_SHFT, - sequence_id); - - MHI_LOG("Trigger device into RDDM mode\n"); - mhi_set_mhi_state(mhi_cntrl, MHI_STATE_SYS_ERR); - - MHI_LOG("Waiting for device to enter RDDM\n"); - while (rddm_retry--) { - ee = mhi_get_exec_env(mhi_cntrl); - if (ee == MHI_EE_RDDM) - break; - - udelay(delayus); - } - - if (rddm_retry <= 0) { - /* This is a hardware reset, will force device to enter rddm */ - MHI_LOG( - "Did not enter RDDM triggering host req. reset to force rddm\n"); - mhi_write_reg(mhi_cntrl, mhi_cntrl->regs, - MHI_SOC_RESET_REQ_OFFSET, MHI_SOC_RESET_REQ); - udelay(delayus); - } - - ee = mhi_get_exec_env(mhi_cntrl); - MHI_LOG("Waiting for image download completion, current EE:%s\n", - TO_MHI_EXEC_STR(ee)); - while (retry--) { - ret = mhi_read_reg_field(mhi_cntrl, base, BHIE_RXVECSTATUS_OFFS, - BHIE_RXVECSTATUS_STATUS_BMSK, - BHIE_RXVECSTATUS_STATUS_SHFT, - &rx_status); - if (ret) - return -EIO; - - if (rx_status == BHIE_RXVECSTATUS_STATUS_XFER_COMPL) { - MHI_LOG("RDDM successfully collected\n"); - return 0; - } - - udelay(delayus); - } - - ee = mhi_get_exec_env(mhi_cntrl); - ret = mhi_read_reg(mhi_cntrl, base, BHIE_RXVECSTATUS_OFFS, &rx_status); - - MHI_ERR("Did not complete RDDM transfer\n"); - MHI_ERR("Current EE:%s\n", TO_MHI_EXEC_STR(ee)); - MHI_ERR("RXVEC_STATUS:0x%x, ret:%d\n", rx_status, ret); - - return -EIO; -} - -/* download ramdump image from device */ -int mhi_download_rddm_img(struct mhi_controller *mhi_cntrl, bool in_panic) -{ - void __iomem *base = mhi_cntrl->bhie; - rwlock_t *pm_lock = &mhi_cntrl->pm_lock; - struct image_info *rddm_image = mhi_cntrl->rddm_image; - struct mhi_buf *mhi_buf; - int ret; - u32 rx_status; - u32 sequence_id; - - if (!rddm_image) - return -ENOMEM; - - if (in_panic) - return __mhi_download_rddm_in_panic(mhi_cntrl); - - MHI_LOG("Waiting for device to enter RDDM state from EE:%s\n", - TO_MHI_EXEC_STR(mhi_cntrl->ee)); - - ret = wait_event_timeout(mhi_cntrl->state_event, - mhi_cntrl->ee == MHI_EE_RDDM || - MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state), - msecs_to_jiffies(mhi_cntrl->timeout_ms)); - - if (!ret || MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) { - MHI_ERR("MHI is not in valid state, pm_state:%s ee:%s\n", - to_mhi_pm_state_str(mhi_cntrl->pm_state), - TO_MHI_EXEC_STR(mhi_cntrl->ee)); - return -EIO; - } - - mhi_rddm_prepare(mhi_cntrl, mhi_cntrl->rddm_image); - - /* vector table is the last entry */ - mhi_buf = &rddm_image->mhi_buf[rddm_image->entries - 1]; - - read_lock_bh(pm_lock); - if (!MHI_REG_ACCESS_VALID(mhi_cntrl->pm_state)) { - read_unlock_bh(pm_lock); - return -EIO; - } - - MHI_LOG("Starting BHIe Programming for RDDM\n"); - - mhi_write_reg(mhi_cntrl, base, BHIE_RXVECADDR_HIGH_OFFS, - upper_32_bits(mhi_buf->dma_addr)); - - mhi_write_reg(mhi_cntrl, base, BHIE_RXVECADDR_LOW_OFFS, - lower_32_bits(mhi_buf->dma_addr)); - - mhi_write_reg(mhi_cntrl, base, BHIE_RXVECSIZE_OFFS, mhi_buf->len); - -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)) - sequence_id = get_random_u32() & BHIE_RXVECSTATUS_SEQNUM_BMSK; -#else - sequence_id = prandom_u32() & BHIE_RXVECSTATUS_SEQNUM_BMSK; -#endif - mhi_write_reg_field(mhi_cntrl, base, BHIE_RXVECDB_OFFS, - BHIE_RXVECDB_SEQNUM_BMSK, BHIE_RXVECDB_SEQNUM_SHFT, - sequence_id); - read_unlock_bh(pm_lock); - - MHI_LOG("Upper:0x%x Lower:0x%x len:0x%zx sequence:%u\n", - upper_32_bits(mhi_buf->dma_addr), - lower_32_bits(mhi_buf->dma_addr), - mhi_buf->len, sequence_id); - MHI_LOG("Waiting for image download completion\n"); - - /* waiting for image download completion */ - wait_event_timeout(mhi_cntrl->state_event, - MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state) || - mhi_read_reg_field(mhi_cntrl, base, - BHIE_RXVECSTATUS_OFFS, - BHIE_RXVECSTATUS_STATUS_BMSK, - BHIE_RXVECSTATUS_STATUS_SHFT, - &rx_status) || rx_status, - msecs_to_jiffies(mhi_cntrl->timeout_ms)); - - if (MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) - return -EIO; - - return (rx_status == BHIE_RXVECSTATUS_STATUS_XFER_COMPL) ? 0 : -EIO; -} -EXPORT_SYMBOL(mhi_download_rddm_img); - -static int mhi_fw_load_amss(struct mhi_controller *mhi_cntrl, - const struct mhi_buf *mhi_buf) -{ - void __iomem *base = mhi_cntrl->bhie; - rwlock_t *pm_lock = &mhi_cntrl->pm_lock; - u32 tx_status; - - read_lock_bh(pm_lock); - if (!MHI_REG_ACCESS_VALID(mhi_cntrl->pm_state)) { - read_unlock_bh(pm_lock); - return -EIO; - } - - MHI_LOG("Starting BHIe Programming\n"); - - mhi_write_reg(mhi_cntrl, base, BHIE_TXVECADDR_HIGH_OFFS, - upper_32_bits(mhi_buf->dma_addr)); - - mhi_write_reg(mhi_cntrl, base, BHIE_TXVECADDR_LOW_OFFS, - lower_32_bits(mhi_buf->dma_addr)); - - mhi_write_reg(mhi_cntrl, base, BHIE_TXVECSIZE_OFFS, mhi_buf->len); -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)) - mhi_cntrl->sequence_id = get_random_u32() & BHIE_TXVECSTATUS_SEQNUM_BMSK; -#else - mhi_cntrl->sequence_id = prandom_u32() & BHIE_TXVECSTATUS_SEQNUM_BMSK; -#endif - mhi_write_reg_field(mhi_cntrl, base, BHIE_TXVECDB_OFFS, - BHIE_TXVECDB_SEQNUM_BMSK, BHIE_TXVECDB_SEQNUM_SHFT, - mhi_cntrl->sequence_id); - read_unlock_bh(pm_lock); - - MHI_LOG("Upper:0x%x Lower:0x%x len:0x%zx sequence:%u\n", - upper_32_bits(mhi_buf->dma_addr), - lower_32_bits(mhi_buf->dma_addr), - mhi_buf->len, mhi_cntrl->sequence_id); - MHI_LOG("Waiting for image transfer completion\n"); - - /* waiting for image download completion */ - wait_event_timeout(mhi_cntrl->state_event, - MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state) || - mhi_read_reg_field(mhi_cntrl, base, - BHIE_TXVECSTATUS_OFFS, - BHIE_TXVECSTATUS_STATUS_BMSK, - BHIE_TXVECSTATUS_STATUS_SHFT, - &tx_status) || tx_status, - msecs_to_jiffies(mhi_cntrl->timeout_ms)); - - if (MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) - return -EIO; - - return (tx_status == BHIE_TXVECSTATUS_STATUS_XFER_COMPL) ? 0 : -EIO; -} - -static int mhi_fw_load_sbl(struct mhi_controller *mhi_cntrl, - dma_addr_t dma_addr, - size_t size) -{ - u32 tx_status, val; - u32 ImgTxDb = 0x1; - int i, ret; - void __iomem *base = mhi_cntrl->bhi; - rwlock_t *pm_lock = &mhi_cntrl->pm_lock; - struct { - char *name; - u32 offset; - } error_reg[] = { - { "ERROR_CODE", BHI_ERRCODE }, - { "ERROR_DBG1", BHI_ERRDBG1 }, - { "ERROR_DBG2", BHI_ERRDBG2 }, - { "ERROR_DBG3", BHI_ERRDBG3 }, - { NULL }, - }; - - MHI_LOG("Starting BHI programming\n"); - - /* program start sbl download via bhi protocol */ - read_lock_bh(pm_lock); - if (!MHI_REG_ACCESS_VALID(mhi_cntrl->pm_state)) { - read_unlock_bh(pm_lock); - goto invalid_pm_state; - } - - mhi_write_reg(mhi_cntrl, base, BHI_STATUS, 0); - mhi_write_reg(mhi_cntrl, base, BHI_IMGADDR_HIGH, - upper_32_bits(dma_addr)); - mhi_write_reg(mhi_cntrl, base, BHI_IMGADDR_LOW, - lower_32_bits(dma_addr)); - mhi_write_reg(mhi_cntrl, base, BHI_IMGSIZE, size); - mhi_write_reg_field(mhi_cntrl, mhi_cntrl->regs, MHICFG, MHICFG_NER_MASK, MHICFG_NER_SHIFT, NUM_MHI_EVT_RINGS); - mhi_write_reg_field(mhi_cntrl, mhi_cntrl->regs, MHICFG, MHICFG_NHWER_MASK, MHICFG_NHWER_SHIFT, NUM_MHI_HW_EVT_RINGS); - mhi_write_reg(mhi_cntrl, mhi_cntrl->bhi, BHI_INTVEC, mhi_cntrl->msi_irq_base); - mhi_write_reg(mhi_cntrl, base, BHI_IMGTXDB, ImgTxDb); - read_unlock_bh(pm_lock); - - MHI_LOG("Waiting for image transfer completion\n"); - - /* waiting for image download completion */ - ret = wait_event_timeout(mhi_cntrl->state_event, - MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state) || - mhi_read_reg_field(mhi_cntrl, base, BHI_STATUS, - BHI_STATUS_MASK, BHI_STATUS_SHIFT, - &tx_status) || tx_status, - msecs_to_jiffies(mhi_cntrl->timeout_ms)); - if (MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) - goto invalid_pm_state; - - if (tx_status == BHI_STATUS_ERROR) { - MHI_ERR("Image transfer failed\n"); - read_lock_bh(pm_lock); - if (MHI_REG_ACCESS_VALID(mhi_cntrl->pm_state)) { - for (i = 0; error_reg[i].name; i++) { - ret = mhi_read_reg(mhi_cntrl, base, - error_reg[i].offset, &val); - if (ret) - break; - MHI_ERR("reg:%s value:0x%x\n", - error_reg[i].name, val); - } - } - read_unlock_bh(pm_lock); - goto invalid_pm_state; - } - - return (tx_status == BHI_STATUS_SUCCESS) ? 0 : -ETIMEDOUT; - -invalid_pm_state: - - return -EIO; -} - -void mhi_free_bhie_table(struct mhi_controller *mhi_cntrl, - struct image_info *image_info) -{ - int i; - struct mhi_buf *mhi_buf = image_info->mhi_buf; - - for (i = 0; i < image_info->entries; i++, mhi_buf++) - mhi_free_coherent(mhi_cntrl, mhi_buf->len, mhi_buf->buf, - mhi_buf->dma_addr); - - kfree(image_info->mhi_buf); - kfree(image_info); -} - -int mhi_alloc_bhie_table(struct mhi_controller *mhi_cntrl, - struct image_info **image_info, - size_t alloc_size) -{ - size_t seg_size = mhi_cntrl->seg_len; - /* requier additional entry for vec table */ - int segments = DIV_ROUND_UP(alloc_size, seg_size) + 1; - int i; - struct image_info *img_info; - struct mhi_buf *mhi_buf; - - MHI_LOG("Allocating bytes:%zu seg_size:%zu total_seg:%u\n", - alloc_size, seg_size, segments); - - img_info = kzalloc(sizeof(*img_info), GFP_KERNEL); - if (!img_info) - return -ENOMEM; - - /* allocate memory for entries */ - img_info->mhi_buf = kcalloc(segments, sizeof(*img_info->mhi_buf), - GFP_KERNEL); - if (!img_info->mhi_buf) - goto error_alloc_mhi_buf; - - /* allocate and populate vector table */ - mhi_buf = img_info->mhi_buf; - for (i = 0; i < segments; i++, mhi_buf++) { - size_t vec_size = seg_size; - - /* last entry is for vector table */ - if (i == segments - 1) - vec_size = sizeof(struct bhi_vec_entry) * i; - - mhi_buf->len = vec_size; - mhi_buf->buf = mhi_alloc_coherent(mhi_cntrl, vec_size, - &mhi_buf->dma_addr, GFP_KERNEL); - if (!mhi_buf->buf) - goto error_alloc_segment; - - MHI_LOG("Entry:%d Address:0x%llx size:%zu\n", i, - (unsigned long long)mhi_buf->dma_addr, - mhi_buf->len); - } - - img_info->bhi_vec = img_info->mhi_buf[segments - 1].buf; - img_info->entries = segments; - *image_info = img_info; - - MHI_LOG("Successfully allocated bhi vec table\n"); - - return 0; - -error_alloc_segment: - for (--i, --mhi_buf; i >= 0; i--, mhi_buf--) - mhi_free_coherent(mhi_cntrl, mhi_buf->len, mhi_buf->buf, - mhi_buf->dma_addr); - -error_alloc_mhi_buf: - kfree(img_info); - - return -ENOMEM; -} - -static void mhi_firmware_copy(struct mhi_controller *mhi_cntrl, - const struct firmware *firmware, - struct image_info *img_info) -{ - size_t remainder = firmware->size; - size_t to_cpy; - const u8 *buf = firmware->data; - int i = 0; - struct mhi_buf *mhi_buf = img_info->mhi_buf; - struct bhi_vec_entry *bhi_vec = img_info->bhi_vec; - - while (remainder) { - MHI_ASSERT(i >= img_info->entries, "malformed vector table"); - - to_cpy = min(remainder, mhi_buf->len); - memcpy(mhi_buf->buf, buf, to_cpy); - bhi_vec->dma_addr = mhi_buf->dma_addr; - bhi_vec->size = to_cpy; - - MHI_VERB("Setting Vector:0x%llx size: %llu\n", - bhi_vec->dma_addr, bhi_vec->size); - buf += to_cpy; - remainder -= to_cpy; - i++; - bhi_vec++; - mhi_buf++; - } -} - -void mhi_fw_load_worker(struct work_struct *work) -{ - int ret; - struct mhi_controller *mhi_cntrl; - const char *fw_name; - const struct firmware *firmware; - struct image_info *image_info; - void *buf; - dma_addr_t dma_addr; - size_t size; - - mhi_cntrl = container_of(work, struct mhi_controller, fw_worker); - - MHI_LOG("Waiting for device to enter PBL from EE:%s\n", - TO_MHI_EXEC_STR(mhi_cntrl->ee)); - - ret = wait_event_timeout(mhi_cntrl->state_event, - MHI_IN_PBL(mhi_cntrl->ee) || - MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state), - msecs_to_jiffies(mhi_cntrl->timeout_ms)); - - if (!ret || MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) { - MHI_ERR("MHI is not in valid state\n"); - return; - } - - MHI_LOG("Device current EE:%s\n", TO_MHI_EXEC_STR(mhi_cntrl->ee)); - - /* if device in pthru, we do not have to load firmware */ - if (mhi_cntrl->ee == MHI_EE_PTHRU) - return; - - fw_name = (mhi_cntrl->ee == MHI_EE_EDL) ? - mhi_cntrl->edl_image : mhi_cntrl->fw_image; - - if (!fw_name || (mhi_cntrl->fbc_download && (!mhi_cntrl->sbl_size || - !mhi_cntrl->seg_len))) { - MHI_ERR("No firmware image defined or !sbl_size || !seg_len\n"); - return; - } - - ret = request_firmware(&firmware, fw_name, mhi_cntrl->dev); - if (ret) { - MHI_ERR("Error loading firmware, ret:%d\n", ret); - return; - } - - size = (mhi_cntrl->fbc_download) ? mhi_cntrl->sbl_size : firmware->size; - - /* the sbl size provided is maximum size, not necessarily image size */ - if (size > firmware->size) - size = firmware->size; - - buf = mhi_alloc_coherent(mhi_cntrl, size, &dma_addr, GFP_KERNEL); - if (!buf) { - MHI_ERR("Could not allocate memory for image\n"); - release_firmware(firmware); - return; - } - - /* load sbl image */ - memcpy(buf, firmware->data, size); - ret = mhi_fw_load_sbl(mhi_cntrl, dma_addr, size); - mhi_free_coherent(mhi_cntrl, size, buf, dma_addr); - - /* error or in edl, we're done */ - if (ret || mhi_cntrl->ee == MHI_EE_EDL) { - release_firmware(firmware); - return; - } - - write_lock_irq(&mhi_cntrl->pm_lock); - mhi_cntrl->dev_state = MHI_STATE_RESET; - write_unlock_irq(&mhi_cntrl->pm_lock); - - /* - * if we're doing fbc, populate vector tables while - * device transitioning into MHI READY state - */ - if (mhi_cntrl->fbc_download) { - ret = mhi_alloc_bhie_table(mhi_cntrl, &mhi_cntrl->fbc_image, - firmware->size); - if (ret) { - MHI_ERR("Error alloc size of %zu\n", firmware->size); - goto error_alloc_fw_table; - } - - MHI_LOG("Copying firmware image into vector table\n"); - - /* load the firmware into BHIE vec table */ - mhi_firmware_copy(mhi_cntrl, firmware, mhi_cntrl->fbc_image); - } - - /* transitioning into MHI RESET->READY state */ - ret = mhi_ready_state_transition(mhi_cntrl); - - MHI_LOG("To Reset->Ready PM_STATE:%s MHI_STATE:%s EE:%s, ret:%d\n", - to_mhi_pm_state_str(mhi_cntrl->pm_state), - TO_MHI_STATE_STR(mhi_cntrl->dev_state), - TO_MHI_EXEC_STR(mhi_cntrl->ee), ret); - - if (!mhi_cntrl->fbc_download) { - release_firmware(firmware); - return; - } - - if (ret) { - MHI_ERR("Did not transition to READY state\n"); - goto error_read; - } - - /* wait for SBL event */ - ret = wait_event_timeout(mhi_cntrl->state_event, - mhi_cntrl->ee == MHI_EE_SBL || - MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state), - msecs_to_jiffies(mhi_cntrl->timeout_ms)); - - if (!ret || MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) { - MHI_ERR("MHI did not enter BHIE\n"); - goto error_read; - } - - /* start full firmware image download */ - image_info = mhi_cntrl->fbc_image; - ret = mhi_fw_load_amss(mhi_cntrl, - /* last entry is vec table */ - &image_info->mhi_buf[image_info->entries - 1]); - - MHI_LOG("amss fw_load, ret:%d\n", ret); - - release_firmware(firmware); - - return; - -error_read: - mhi_free_bhie_table(mhi_cntrl, mhi_cntrl->fbc_image); - mhi_cntrl->fbc_image = NULL; - -error_alloc_fw_table: - release_firmware(firmware); -} - -int BhiWrite(struct mhi_controller *mhi_cntrl, void __user *ubuf, size_t size) -{ - int ret; - dma_addr_t dma_addr; - void *dma_buf; - - MHI_LOG("Device current EE:%s, M:%s, PM:%s\n", - TO_MHI_EXEC_STR(mhi_get_exec_env(mhi_cntrl)), - TO_MHI_STATE_STR(mhi_get_mhi_state(mhi_cntrl)), - to_mhi_pm_state_str(mhi_cntrl->pm_state)); - -#if 0 - if (mhi_get_exec_env(mhi_cntrl) == MHI_EE_EDL && mhi_cntrl->ee != MHI_EE_EDL) { - mhi_cntrl->ee = MHI_EE_EDL; - wait_event_timeout(mhi_cntrl->state_event, - MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state), - msecs_to_jiffies(mhi_cntrl->timeout_ms + 500)); - } -#endif - -#if 0 - if (!MHI_IN_PBL(mhi_cntrl->ee) || MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) { - MHI_ERR("MHI is not in valid BHI state\n"); - return -EINVAL; - } -#endif - - if (mhi_cntrl->ee != MHI_EE_EDL) { - MHI_ERR("MHI is not in EDL state\n"); - return -EINVAL; - } - - dma_buf = mhi_alloc_coherent(mhi_cntrl, size, &dma_addr, GFP_KERNEL); - if (!dma_buf) { - MHI_ERR("Could not allocate memory for image\n"); - return -ENOMEM; - } - - ret = copy_from_user(dma_buf, ubuf, size); - if (ret) { - MHI_ERR("IOCTL_BHI_WRITEIMAGE copy buf error, ret = %d\n", ret); - mhi_free_coherent(mhi_cntrl, size, dma_buf, dma_addr);; - return ret; - } - - ret = mhi_fw_load_sbl(mhi_cntrl, dma_addr, size); - mhi_free_coherent(mhi_cntrl, size, dma_buf, dma_addr); - - if (ret) { - MHI_ERR("ret = %d, ee=%d\n", ret, mhi_cntrl->ee); - goto error_state; - } - - write_lock_irq(&mhi_cntrl->pm_lock); - mhi_cntrl->dev_state = MHI_STATE_RESET; - write_unlock_irq(&mhi_cntrl->pm_lock); - - /* transitioning into MHI RESET->READY state */ - ret = mhi_ready_state_transition(mhi_cntrl); - if (ret) { - MHI_ERR("Did not transition to READY state\n"); - goto error_state; - } - - MHI_LOG("To Reset->Ready PM_STATE:%s MHI_STATE:%s EE:%s, ret:%d\n", - to_mhi_pm_state_str(mhi_cntrl->pm_state), - TO_MHI_STATE_STR(mhi_cntrl->dev_state), - TO_MHI_EXEC_STR(mhi_cntrl->ee), ret); - - /* wait for BHIE event */ - ret = wait_event_timeout(mhi_cntrl->state_event, - mhi_cntrl->ee == MHI_EE_FP || - MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state), - msecs_to_jiffies(mhi_cntrl->timeout_ms)); - if (!ret || MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) { - MHI_ERR("MHI did not enter Flash Programmer Environment\n"); - goto error_state; - } - - MHI_LOG("MHI enter Flash Programmer Environment\n"); - return 0; - -error_state: - MHI_LOG("Device current EE:%s, M:%s\n", - TO_MHI_EXEC_STR(mhi_get_exec_env(mhi_cntrl)), - TO_MHI_STATE_STR(mhi_get_mhi_state(mhi_cntrl))); - - return ret; -} - -long bhi_get_dev_info(struct mhi_controller *mhi_cntrl, void __user *ubuf) -{ - long ret = -EINVAL; - BHI_INFO_TYPE bhi_info; - - ret = BhiRead(mhi_cntrl, &bhi_info); - if (ret) { - MHI_ERR("IOCTL_BHI_GETDEVINFO BhiRead error, ret = %ld\n", ret); - return ret; - } - - ret = copy_to_user(ubuf, &bhi_info, sizeof(bhi_info)); - if (ret) { - MHI_ERR("IOCTL_BHI_GETDEVINFO copy error, ret = %ld\n", ret); - } - - return ret; -} - -long bhi_write_image(struct mhi_controller *mhi_cntrl, void __user *ubuf) -{ - long ret = -EINVAL; - size_t size; - - ret = copy_from_user(&size, ubuf, sizeof(size)); - if (ret) { - MHI_ERR("IOCTL_BHI_WRITEIMAGE copy size error, ret = %ld\n", ret); - return ret; - } - if (size <= 0) { - MHI_ERR("IOCTL_BHI_WRITEIMAGE copy size error, size\n"); - return -EINVAL; - } - ret = BhiWrite(mhi_cntrl, ubuf+sizeof(size), size); - if (ret) { - MHI_ERR("IOCTL_BHI_WRITEIMAGE BhiWrite error, ret = %ld\n", ret); - } - - return ret; -} diff --git a/quectel_MHI/src/core/mhi_dtr.c b/quectel_MHI/src/core/mhi_dtr.c deleted file mode 100644 index 7ce44b3..0000000 --- a/quectel_MHI/src/core/mhi_dtr.c +++ /dev/null @@ -1,274 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "mhi.h" -#include "mhi_internal.h" - -struct __packed dtr_ctrl_msg { - u32 preamble; - u32 msg_id; - u32 dest_id; - u32 size; - u32 msg; -}; - -#define CTRL_MAGIC (0x4C525443) -#define CTRL_MSG_DTR BIT(0) -#define CTRL_MSG_RTS BIT(1) -#define CTRL_MSG_DCD BIT(0) -#define CTRL_MSG_DSR BIT(1) -#define CTRL_MSG_RI BIT(3) -#define CTRL_HOST_STATE (0x10) -#define CTRL_DEVICE_STATE (0x11) -#define CTRL_GET_CHID(dtr) (dtr->dest_id & 0xFF) - -static int mhi_dtr_tiocmset(struct mhi_controller *mhi_cntrl, - struct mhi_device *mhi_dev, - u32 tiocm) -{ - struct dtr_ctrl_msg *dtr_msg = NULL; - struct mhi_chan *dtr_chan = mhi_cntrl->dtr_dev->ul_chan; - spinlock_t *res_lock = &mhi_dev->dev.devres_lock; - u32 cur_tiocm; - int ret = 0; - - cur_tiocm = mhi_dev->tiocm & ~(TIOCM_CD | TIOCM_DSR | TIOCM_RI); - - tiocm &= (TIOCM_DTR | TIOCM_RTS); - - /* state did not changed */ - if (cur_tiocm == tiocm) - return 0; - - mutex_lock(&dtr_chan->mutex); - - dtr_msg = kzalloc(sizeof(*dtr_msg), GFP_KERNEL); - if (!dtr_msg) { - ret = -ENOMEM; - goto tiocm_exit; - } - - dtr_msg->preamble = CTRL_MAGIC; - dtr_msg->msg_id = CTRL_HOST_STATE; - dtr_msg->dest_id = mhi_dev->ul_chan_id; - dtr_msg->size = sizeof(u32); - if (tiocm & TIOCM_DTR) - dtr_msg->msg |= CTRL_MSG_DTR; - if (tiocm & TIOCM_RTS) - dtr_msg->msg |= CTRL_MSG_RTS; - -/* -* 'minicom -D /dev/mhi_DUN' will send RTS:1 when open, and RTS:0 when exit. -* RTS:0 will prevent modem output AT response. -* But 'busybox microcom' do not send any RTS to modem. -* [75094.969783] mhi_uci_q 0306_00.03.00_DUN: mhi_dtr_tiocmset DTR:0 RTS:1 -* [75100.210994] mhi_uci_q 0306_00.03.00_DUN: mhi_dtr_tiocmset DTR:0 RTS:0 -*/ - dev_dbg(&mhi_dev->dev, "%s DTR:%d RTS:%d\n", __func__, - !!(tiocm & TIOCM_DTR), !!(tiocm & TIOCM_RTS)); - - reinit_completion(&dtr_chan->completion); - ret = mhi_queue_transfer(mhi_cntrl->dtr_dev, DMA_TO_DEVICE, dtr_msg, - sizeof(*dtr_msg), MHI_EOT); - if (ret) - goto tiocm_exit; - - ret = wait_for_completion_timeout(&dtr_chan->completion, - msecs_to_jiffies(mhi_cntrl->timeout_ms)); - if (!ret) { - MHI_ERR("Failed to receive transfer callback\n"); - ret = -EIO; - goto tiocm_exit; - } - - ret = 0; - spin_lock_irq(res_lock); - mhi_dev->tiocm &= ~(TIOCM_DTR | TIOCM_RTS); - mhi_dev->tiocm |= tiocm; - spin_unlock_irq(res_lock); - -tiocm_exit: - kfree(dtr_msg); - mutex_unlock(&dtr_chan->mutex); - - return ret; -} - -long mhi_ioctl(struct mhi_device *mhi_dev, unsigned int cmd, unsigned long arg) -{ - struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; - int ret; - - /* ioctl not supported by this controller */ - if (!mhi_cntrl->dtr_dev) - return -EIO; - - switch (cmd) { - case TIOCMGET: - return mhi_dev->tiocm; - case TIOCMSET: - { - u32 tiocm; - - ret = get_user(tiocm, (u32 *)arg); - if (ret) - return ret; - - return mhi_dtr_tiocmset(mhi_cntrl, mhi_dev, tiocm); - } - default: - break; - } - - return -EINVAL; -} -EXPORT_SYMBOL(mhi_ioctl); - -static int mhi_dtr_queue_inbound(struct mhi_controller *mhi_cntrl) -{ - struct mhi_device *mhi_dev = mhi_cntrl->dtr_dev; - int nr_trbs = mhi_get_no_free_descriptors(mhi_dev, DMA_FROM_DEVICE); - size_t mtu = mhi_dev->mtu; - void *buf; - int ret = -EIO, i; - - for (i = 0; i < nr_trbs; i++) { - buf = kmalloc(mtu, GFP_KERNEL); - if (!buf) - return -ENOMEM; - - ret = mhi_queue_transfer(mhi_dev, DMA_FROM_DEVICE, buf, mtu, - MHI_EOT); - if (ret) { - kfree(buf); - return ret; - } - } - - return ret; -} - -static void mhi_dtr_dl_xfer_cb(struct mhi_device *mhi_dev, - struct mhi_result *mhi_result) -{ - struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; - struct dtr_ctrl_msg *dtr_msg = mhi_result->buf_addr; - u32 chan; - spinlock_t *res_lock; - - if (mhi_result->transaction_status == -ENOTCONN) { - kfree(mhi_result->buf_addr); - return; - } - - if (mhi_result->bytes_xferd != sizeof(*dtr_msg)) { - MHI_ERR("Unexpected length %zu received\n", - mhi_result->bytes_xferd); - return; - } - - MHI_LOG("preamble:0x%x msg_id:%u dest_id:%u msg:0x%x\n", - dtr_msg->preamble, dtr_msg->msg_id, dtr_msg->dest_id, - dtr_msg->msg); - - chan = CTRL_GET_CHID(dtr_msg); - if (chan >= mhi_cntrl->max_chan) - goto auto_queue; - - mhi_dev = mhi_cntrl->mhi_chan[chan].mhi_dev; - if (!mhi_dev) - goto auto_queue; - - res_lock = &mhi_dev->dev.devres_lock; - spin_lock_irq(res_lock); - mhi_dev->tiocm &= ~(TIOCM_CD | TIOCM_DSR | TIOCM_RI); - - if (dtr_msg->msg & CTRL_MSG_DCD) - mhi_dev->tiocm |= TIOCM_CD; - - if (dtr_msg->msg & CTRL_MSG_DSR) - mhi_dev->tiocm |= TIOCM_DSR; - - if (dtr_msg->msg & CTRL_MSG_RI) - mhi_dev->tiocm |= TIOCM_RI; - spin_unlock_irq(res_lock); - -auto_queue: - mhi_queue_transfer(mhi_cntrl->dtr_dev, DMA_FROM_DEVICE, mhi_result->buf_addr, - mhi_cntrl->dtr_dev->mtu, MHI_EOT); -} - -static void mhi_dtr_ul_xfer_cb(struct mhi_device *mhi_dev, - struct mhi_result *mhi_result) -{ - struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; - struct mhi_chan *dtr_chan = mhi_cntrl->dtr_dev->ul_chan; - - MHI_VERB("Received with status:%d\n", mhi_result->transaction_status); - if (!mhi_result->transaction_status) - complete(&dtr_chan->completion); -} - -static void mhi_dtr_remove(struct mhi_device *mhi_dev) -{ - struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; - - mhi_cntrl->dtr_dev = NULL; -} - -static int mhi_dtr_probe(struct mhi_device *mhi_dev, - const struct mhi_device_id *id) -{ - struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; - int ret; - - MHI_LOG("Enter for DTR control channel\n"); - - mhi_dev->mtu = min_t(size_t, id->driver_data, mhi_dev->mtu); - ret = mhi_prepare_for_transfer(mhi_dev); - if (!ret) - mhi_cntrl->dtr_dev = mhi_dev; - - if (!ret) - ret = mhi_dtr_queue_inbound(mhi_cntrl); - - MHI_LOG("Exit with ret:%d\n", ret); - - return ret; -} - -static const struct mhi_device_id mhi_dtr_table[] = { - { .chan = "IP_CTRL", .driver_data = sizeof(struct dtr_ctrl_msg) }, - {}, -}; - -static struct mhi_driver mhi_dtr_driver = { - .id_table = mhi_dtr_table, - .remove = mhi_dtr_remove, - .probe = mhi_dtr_probe, - .ul_xfer_cb = mhi_dtr_ul_xfer_cb, - .dl_xfer_cb = mhi_dtr_dl_xfer_cb, - .driver = { - .name = "MHI_DTR", - .owner = THIS_MODULE, - } -}; - -int __init mhi_dtr_init(void) -{ - return mhi_driver_register(&mhi_dtr_driver); -} -void mhi_dtr_exit(void) { - mhi_driver_unregister(&mhi_dtr_driver); -} diff --git a/quectel_MHI/src/core/mhi_init.c b/quectel_MHI/src/core/mhi_init.c deleted file mode 100644 index e0c933d..0000000 --- a/quectel_MHI/src/core/mhi_init.c +++ /dev/null @@ -1,2773 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved. */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 4,11,0 )) -#include -#else -#include -#endif -#include "mhi.h" -#include "mhi_internal.h" - -struct mhi_controller_map { - u32 dev_id; - u32 domain; - u32 bus; - u32 slot; - struct mhi_controller *mhi_cntrl; -}; - -#define MAX_MHI_CONTROLLER 16 -struct mhi_controller_map mhi_controller_minors[MAX_MHI_CONTROLLER]; - -#define MHI_CNTRL_DRIVER_NAME "mhi_cntrl_q" -struct mhi_cntrl_drv { - struct list_head head; - struct mutex lock; - struct class *class; - int major; -}; -static struct mhi_cntrl_drv mhi_cntrl_drv; - -const char * const mhi_ee_str[MHI_EE_MAX] = { - [MHI_EE_PBL] = "PBL", - [MHI_EE_SBL] = "SBL", - [MHI_EE_AMSS] = "AMSS", - [MHI_EE_RDDM] = "RDDM", - [MHI_EE_WFW] = "WFW", - [MHI_EE_PTHRU] = "PASS THRU", - [MHI_EE_EDL] = "EDL", - [MHI_EE_FP] = "FlashProg", - [MHI_EE_DISABLE_TRANSITION] = "DISABLE", -}; - -const char * const mhi_state_tran_str[MHI_ST_TRANSITION_MAX] = { - [MHI_ST_TRANSITION_PBL] = "PBL", - [MHI_ST_TRANSITION_READY] = "READY", - [MHI_ST_TRANSITION_SBL] = "SBL", - [MHI_ST_TRANSITION_MISSION_MODE] = "MISSION MODE", - [MHI_ST_TRANSITION_FP] = "FlashProg", -}; - -const char * const mhi_state_str[MHI_STATE_MAX] = { - [MHI_STATE_RESET] = "RESET", - [MHI_STATE_READY] = "READY", - [MHI_STATE_M0] = "M0", - [MHI_STATE_M1] = "M1", - [MHI_STATE_M2] = "M2", - [MHI_STATE_M3] = "M3", - [MHI_STATE_BHI] = "BHI", - [MHI_STATE_SYS_ERR] = "SYS_ERR", -}; - -static const char * const mhi_pm_state_str[] = { - [MHI_PM_BIT_DISABLE] = "DISABLE", - [MHI_PM_BIT_POR] = "POR", - [MHI_PM_BIT_M0] = "M0", - [MHI_PM_BIT_M2] = "M2", - [MHI_PM_BIT_M3_ENTER] = "M?->M3", - [MHI_PM_BIT_M3] = "M3", - [MHI_PM_BIT_M3_EXIT] = "M3->M0", - [MHI_PM_BIT_FW_DL_ERR] = "FW DL Error", - [MHI_PM_BIT_SYS_ERR_DETECT] = "SYS_ERR Detect", - [MHI_PM_BIT_SYS_ERR_PROCESS] = "SYS_ERR Process", - [MHI_PM_BIT_SHUTDOWN_PROCESS] = "SHUTDOWN Process", - [MHI_PM_BIT_LD_ERR_FATAL_DETECT] = "LD or Error Fatal Detect", -}; - -struct mhi_bus mhi_bus; - -const char *to_mhi_pm_state_str(enum MHI_PM_STATE state) -{ - int index = find_last_bit((unsigned long *)&state, 32); - - if (index >= ARRAY_SIZE(mhi_pm_state_str)) - return "Invalid State"; - - return mhi_pm_state_str[index]; -} - -#if 0 -/* MHI protocol require transfer ring to be aligned to ring length */ -static int mhi_alloc_aligned_ring(struct mhi_controller *mhi_cntrl, - struct mhi_ring *ring, - u64 len) -{ - ring->alloc_size = len + (len - 1); - ring->pre_aligned = mhi_alloc_coherent(mhi_cntrl, ring->alloc_size, - &ring->dma_handle, GFP_KERNEL); - if (!ring->pre_aligned) - return -ENOMEM; - - ring->iommu_base = (ring->dma_handle + (len - 1)) & ~(len - 1); - ring->base = ring->pre_aligned + (ring->iommu_base - ring->dma_handle); - return 0; -} -#endif - -static void mhi_ring_aligned_check(struct mhi_controller *mhi_cntrl, u64 rbase, u64 rlen) { - uint64_t ra; - - ra = rbase; - do_div(ra, roundup_pow_of_two(rlen)); - - if (rbase != ra * roundup_pow_of_two(rlen)) { - MHI_ERR("bad params ring base not aligned 0x%llx align 0x%lx\n", rbase, roundup_pow_of_two(rlen)); - } -} - -void mhi_deinit_free_irq(struct mhi_controller *mhi_cntrl) -{ - int i; - struct mhi_event *mhi_event = mhi_cntrl->mhi_event; - - - if (mhi_cntrl->msi_allocated == 1) { - free_irq(mhi_cntrl->irq[mhi_cntrl->msi_irq_base], mhi_cntrl); - return; - } - - for (i = 0; i < mhi_cntrl->total_ev_rings; i++, mhi_event++) { - if (mhi_event->offload_ev) - continue; - - free_irq(mhi_cntrl->irq[mhi_event->msi], mhi_event); - } - - free_irq(mhi_cntrl->irq[mhi_cntrl->msi_irq_base], mhi_cntrl); -} - -int mhi_init_irq_setup(struct mhi_controller *mhi_cntrl) -{ - int i; - int ret; - struct mhi_event *mhi_event = mhi_cntrl->mhi_event; - - if (mhi_cntrl->msi_allocated == 1) { - for (i = 0; i < mhi_cntrl->total_ev_rings; i++, mhi_event++) { - mhi_event->msi = 0; - } - - ret = request_threaded_irq(mhi_cntrl->irq[0], NULL, - mhi_one_msi_handlr, IRQF_ONESHOT, "mhi", mhi_cntrl); - if (ret) { - MHI_ERR("Error requesting irq:%d, ret=%d\n", mhi_cntrl->irq[0], ret); - } - return ret; - } - - /* for BHI INTVEC msi */ - ret = request_threaded_irq(mhi_cntrl->irq[mhi_cntrl->msi_irq_base], mhi_intvec_handlr, - mhi_intvec_threaded_handlr, IRQF_ONESHOT, - "mhi", mhi_cntrl); - if (ret) - return ret; - - for (i = 0; i < mhi_cntrl->total_ev_rings; i++, mhi_event++) { - if (mhi_event->offload_ev) - continue; - - ret = request_irq(mhi_cntrl->irq[mhi_event->msi], - mhi_msi_handlr, IRQF_SHARED, "mhi", - mhi_event); - if (ret) { - MHI_ERR("Error requesting irq:%d for ev:%d\n", - mhi_cntrl->irq[mhi_event->msi], i); - goto error_request; - } - } - - return 0; - -error_request: - for (--i, --mhi_event; i >= 0; i--, mhi_event--) { - if (mhi_event->offload_ev) - continue; - - free_irq(mhi_cntrl->irq[mhi_event->msi], mhi_event); - } - free_irq(mhi_cntrl->irq[0], mhi_cntrl); - - return ret; -} - -void mhi_deinit_dev_ctxt(struct mhi_controller *mhi_cntrl) -{ - int i; - struct mhi_ctxt *mhi_ctxt = mhi_cntrl->mhi_ctxt; - struct mhi_cmd *mhi_cmd; - struct mhi_event *mhi_event; - struct mhi_ring *ring; - - mhi_cmd = mhi_cntrl->mhi_cmd; - for (i = 0; i < NR_OF_CMD_RINGS; i++, mhi_cmd++) { - ring = &mhi_cmd->ring; -#if 0 - mhi_free_coherent(mhi_cntrl, ring->alloc_size, - ring->pre_aligned, ring->dma_handle); -#endif - ring->base = NULL; - ring->iommu_base = 0; - } - -#if 0 - mhi_free_coherent(mhi_cntrl, - sizeof(*mhi_ctxt->cmd_ctxt) * NR_OF_CMD_RINGS, - mhi_ctxt->cmd_ctxt, mhi_ctxt->cmd_ctxt_addr); -#endif - - mhi_event = mhi_cntrl->mhi_event; - for (i = 0; i < mhi_cntrl->total_ev_rings; i++, mhi_event++) { - if (mhi_event->offload_ev) - continue; - - ring = &mhi_event->ring; -#if 0 - mhi_free_coherent(mhi_cntrl, ring->alloc_size, - ring->pre_aligned, ring->dma_handle); -#endif - ring->base = NULL; - ring->iommu_base = 0; - } - -#if 0 - mhi_free_coherent(mhi_cntrl, sizeof(*mhi_ctxt->er_ctxt) * - mhi_cntrl->total_ev_rings, mhi_ctxt->er_ctxt, - mhi_ctxt->er_ctxt_addr); - - mhi_free_coherent(mhi_cntrl, sizeof(*mhi_ctxt->chan_ctxt) * - mhi_cntrl->max_chan, mhi_ctxt->chan_ctxt, - mhi_ctxt->chan_ctxt_addr); -#endif - - mhi_free_coherent(mhi_cntrl, sizeof(*mhi_ctxt->ctrl_seg), mhi_ctxt->ctrl_seg, mhi_ctxt->ctrl_seg_addr); - kfree(mhi_ctxt); - mhi_cntrl->mhi_ctxt = NULL; -} - -static int mhi_init_debugfs_mhi_states_open(struct inode *inode, - struct file *fp) -{ - return single_open(fp, mhi_debugfs_mhi_states_show, inode->i_private); -} - -static int mhi_init_debugfs_mhi_event_open(struct inode *inode, struct file *fp) -{ - return single_open(fp, mhi_debugfs_mhi_event_show, inode->i_private); -} - -static int mhi_init_debugfs_mhi_chan_open(struct inode *inode, struct file *fp) -{ - return single_open(fp, mhi_debugfs_mhi_chan_show, inode->i_private); -} - -static const struct file_operations debugfs_state_ops = { - .open = mhi_init_debugfs_mhi_states_open, - .release = single_release, - .read = seq_read, -}; - -static const struct file_operations debugfs_ev_ops = { - .open = mhi_init_debugfs_mhi_event_open, - .release = single_release, - .read = seq_read, -}; - -static const struct file_operations debugfs_chan_ops = { - .open = mhi_init_debugfs_mhi_chan_open, - .release = single_release, - .read = seq_read, -}; - -DEFINE_SIMPLE_ATTRIBUTE(debugfs_trigger_reset_fops, NULL, - mhi_debugfs_trigger_reset, "%llu\n"); - -#ifdef ENABLE_MHI_MON -struct mon_event_text { - struct list_head e_link; - int type; /* submit, complete, etc. */ - unsigned int tstamp; - u32 chan; - dma_addr_t wp; - struct mhi_tre mhi_tre; - u8 data[32]; - size_t len; -}; - -#define EVENT_MAX (16*PAGE_SIZE / sizeof(struct mon_event_text)) -#define PRINTF_DFL 250 -#define SLAB_NAME_SZ 30 - -struct mon_reader_text { - struct kmem_cache *e_slab; - int nevents; - struct list_head e_list; - struct mon_reader r; /* In C, parent class can be placed anywhere */ - - wait_queue_head_t wait; - int printf_size; - char *printf_buf; - int left_size; - int left_pos; - struct mutex printf_lock; - - char slab_name[SLAB_NAME_SZ]; -}; - -struct mon_text_ptr { - int cnt, limit; - char *pbuf; -}; - -static DEFINE_MUTEX(mon_lock); - -static inline unsigned int mon_get_timestamp(void) -{ - struct timespec64 now; - unsigned int stamp; - - ktime_get_ts64(&now); - stamp = now.tv_sec & 0xFFF; /* 2^32 = 4294967296. Limit to 4096s. */ - stamp = stamp * USEC_PER_SEC + now.tv_nsec / NSEC_PER_USEC; - return stamp; -} - -static void mon_text_event(struct mon_reader_text *rp, - u32 chan, dma_addr_t wp, struct mhi_tre *mhi_tre, void *buf, size_t len, - char ev_type) -{ - struct mon_event_text *ep; - - if (rp->nevents >= EVENT_MAX || - (ep = kmem_cache_alloc(rp->e_slab, GFP_ATOMIC)) == NULL) { - rp->r.m_bus->cnt_text_lost++; - return; - } - - ep->type = ev_type; - ep->tstamp = mon_get_timestamp(); - ep->chan = chan; - ep->wp = wp; - ep->mhi_tre = *mhi_tre; - if (len > sizeof(ep->data)) - len = sizeof(ep->data); - memcpy(ep->data, buf, len); - ep->len = len; - rp->nevents++; - list_add_tail(&ep->e_link, &rp->e_list); - wake_up(&rp->wait); -} - -static void mon_text_submit(void *data, u32 chan, dma_addr_t wp, struct mhi_tre *mhi_tre, void *buf, size_t len) -{ - struct mon_reader_text *rp = data; - mon_text_event(rp, chan, wp, mhi_tre, buf, len, 'W'); -} - -static void mon_text_receive(void *data, u32 chan, dma_addr_t wp, struct mhi_tre *mhi_tre, void *buf, size_t len) -{ - struct mon_reader_text *rp = data; - mon_text_event(rp, chan, wp, mhi_tre, buf, len, 'R'); -} - -static void mon_text_complete(void *data, u32 chan, dma_addr_t wp, struct mhi_tre *mhi_tre) -{ - struct mon_reader_text *rp = data; - mon_text_event(rp, chan, wp, mhi_tre, NULL, 0, 'E'); -} - -static void mon_reader_add(struct mhi_controller *mbus, struct mon_reader *r) -{ - unsigned long flags; - - spin_lock_irqsave(&mbus->lock, flags); - mbus->nreaders++; - list_add_tail(&r->r_link, &mbus->r_list); - spin_unlock_irqrestore(&mbus->lock, flags); - - kref_get(&mbus->ref); -} - -static void mon_bus_drop(struct kref *r) -{ - struct mhi_controller *mbus = container_of(r, struct mhi_controller, ref); - kfree(mbus); -} - -static void mon_reader_del(struct mhi_controller *mbus, struct mon_reader *r) -{ - unsigned long flags; - - spin_lock_irqsave(&mbus->lock, flags); - list_del(&r->r_link); - --mbus->nreaders; - spin_unlock_irqrestore(&mbus->lock, flags); - - kref_put(&mbus->ref, mon_bus_drop); -} - -static void mon_text_ctor(void *mem) -{ - /* - * Nothing to initialize. No, really! - * So, we fill it with garbage to emulate a reused object. - */ - memset(mem, 0xe5, sizeof(struct mon_event_text)); -} - -static int mon_text_open(struct inode *inode, struct file *file) -{ - struct mhi_controller *mbus; - struct mon_reader_text *rp; - int rc; - - mutex_lock(&mon_lock); - mbus = inode->i_private; - - rp = kzalloc(sizeof(struct mon_reader_text), GFP_KERNEL); - if (rp == NULL) { - rc = -ENOMEM; - goto err_alloc; - } - INIT_LIST_HEAD(&rp->e_list); - init_waitqueue_head(&rp->wait); - mutex_init(&rp->printf_lock); - - rp->printf_size = PRINTF_DFL; - rp->printf_buf = kmalloc(rp->printf_size, GFP_KERNEL); - if (rp->printf_buf == NULL) { - rc = -ENOMEM; - goto err_alloc_pr; - } - - rp->r.m_bus = mbus; - rp->r.r_data = rp; - rp->r.rnf_submit = mon_text_submit; - rp->r.rnf_receive = mon_text_receive; - rp->r.rnf_complete = mon_text_complete; - - snprintf(rp->slab_name, SLAB_NAME_SZ, "mon_text_%p", rp); - rp->e_slab = kmem_cache_create(rp->slab_name, - sizeof(struct mon_event_text), sizeof(long), 0, - mon_text_ctor); - if (rp->e_slab == NULL) { - rc = -ENOMEM; - goto err_slab; - } - - mon_reader_add(mbus, &rp->r); - - file->private_data = rp; - mutex_unlock(&mon_lock); - return 0; - -// err_busy: -// kmem_cache_destroy(rp->e_slab); -err_slab: - kfree(rp->printf_buf); -err_alloc_pr: - kfree(rp); -err_alloc: - mutex_unlock(&mon_lock); - return rc; -} - -static struct mon_event_text *mon_text_fetch(struct mon_reader_text *rp, - struct mhi_controller *mbus) -{ - struct list_head *p; - unsigned long flags; - - spin_lock_irqsave(&mbus->lock, flags); - if (list_empty(&rp->e_list)) { - spin_unlock_irqrestore(&mbus->lock, flags); - return NULL; - } - p = rp->e_list.next; - list_del(p); - --rp->nevents; - spin_unlock_irqrestore(&mbus->lock, flags); - return list_entry(p, struct mon_event_text, e_link); -} - -static struct mon_event_text *mon_text_read_wait(struct mon_reader_text *rp, - struct file *file) -{ - struct mhi_controller *mbus = rp->r.m_bus; - DECLARE_WAITQUEUE(waita, current); - struct mon_event_text *ep; - - add_wait_queue(&rp->wait, &waita); - set_current_state(TASK_INTERRUPTIBLE); - while ((ep = mon_text_fetch(rp, mbus)) == NULL) { - if (file->f_flags & O_NONBLOCK) { - set_current_state(TASK_RUNNING); - remove_wait_queue(&rp->wait, &waita); - return ERR_PTR(-EWOULDBLOCK); - } - /* - * We do not count nwaiters, because ->release is supposed - * to be called when all openers are gone only. - */ - schedule(); - if (signal_pending(current)) { - remove_wait_queue(&rp->wait, &waita); - return ERR_PTR(-EINTR); - } - set_current_state(TASK_INTERRUPTIBLE); - } - set_current_state(TASK_RUNNING); - remove_wait_queue(&rp->wait, &waita); - return ep; -} - -static ssize_t mon_text_read_u(struct file *file, char __user *buf, - size_t nbytes, loff_t *ppos) -{ - struct mon_reader_text *rp = file->private_data; - struct mon_event_text *ep; - struct mon_text_ptr ptr; - - if (rp->left_size) { - int cnt = rp->left_size; - - if (cnt > nbytes) - cnt = nbytes; - if (copy_to_user(buf, rp->printf_buf + rp->left_pos, cnt)) - return -EFAULT; - rp->left_pos += cnt; - rp->left_size -= cnt; - return cnt; - } - - if (IS_ERR(ep = mon_text_read_wait(rp, file))) - return PTR_ERR(ep); - mutex_lock(&rp->printf_lock); - ptr.cnt = 0; - ptr.pbuf = rp->printf_buf; - ptr.limit = rp->printf_size; - - ptr.cnt += snprintf(ptr.pbuf + ptr.cnt, ptr.limit - ptr.cnt, - "%u %c %03d WP:%llx TRE: %llx %08x %08x", - ep->tstamp, ep->type, ep->chan, (long long unsigned int)ep->wp, - ep->mhi_tre.ptr, ep->mhi_tre.dword[0], ep->mhi_tre.dword[1]); - - if (ep->len) { - struct mon_text_ptr *p = &ptr; - size_t i = 0; - - for (i = 0; i < ep->len; i++) { - if (i % 4 == 0) { - p->cnt += snprintf(p->pbuf + p->cnt, - p->limit - p->cnt, - " "); - } - p->cnt += snprintf(p->pbuf + p->cnt, - p->limit - p->cnt, - "%02x", ep->data[i]); - } - - } - - ptr.cnt += snprintf(ptr.pbuf +ptr.cnt, ptr.limit - ptr.cnt, "\n"); - - if (ptr.cnt > nbytes) { - rp->left_pos = nbytes; - rp->left_size = ptr.cnt - nbytes; - ptr.cnt = nbytes; - } - - if (copy_to_user(buf, rp->printf_buf, ptr.cnt)) - ptr.cnt = -EFAULT; - mutex_unlock(&rp->printf_lock); - kmem_cache_free(rp->e_slab, ep); - return ptr.cnt; -} - -static int mon_text_release(struct inode *inode, struct file *file) -{ - struct mon_reader_text *rp = file->private_data; - struct mhi_controller *mbus; - /* unsigned long flags; */ - struct list_head *p; - struct mon_event_text *ep; - - mutex_lock(&mon_lock); - mbus = inode->i_private; - - if (mbus->nreaders <= 0) { - mutex_unlock(&mon_lock); - return 0; - } - mon_reader_del(mbus, &rp->r); - - /* - * In theory, e_list is protected by mbus->lock. However, - * after mon_reader_del has finished, the following is the case: - * - we are not on reader list anymore, so new events won't be added; - * - whole mbus may be dropped if it was orphaned. - * So, we better not touch mbus. - */ - /* spin_lock_irqsave(&mbus->lock, flags); */ - while (!list_empty(&rp->e_list)) { - p = rp->e_list.next; - ep = list_entry(p, struct mon_event_text, e_link); - list_del(p); - --rp->nevents; - kmem_cache_free(rp->e_slab, ep); - } - /* spin_unlock_irqrestore(&mbus->lock, flags); */ - - kmem_cache_destroy(rp->e_slab); - kfree(rp->printf_buf); - kfree(rp); - - mutex_unlock(&mon_lock); - return 0; -} - - -static const struct file_operations mon_fops_text_u = { - .owner = THIS_MODULE, - .open = mon_text_open, - .llseek = no_llseek, - .read = mon_text_read_u, - .release = mon_text_release, -}; -#endif - -void mhi_init_debugfs(struct mhi_controller *mhi_cntrl) -{ - struct dentry *dentry; - char node[64]; - -#ifdef ENABLE_MHI_MON - struct mhi_controller *mbus = mhi_cntrl; - - mbus->nreaders = 0; - kref_init(&mbus->ref); - spin_lock_init(&mbus->lock); - INIT_LIST_HEAD(&mbus->r_list); -#endif - - if (!mhi_cntrl->parent) - snprintf(node, sizeof(node), "mhi_%04x_%02x:%02x.%02x", - mhi_cntrl->dev_id, mhi_cntrl->domain, mhi_cntrl->bus, - mhi_cntrl->slot); - else - snprintf(node, sizeof(node), "%04x_%02x:%02x.%02x", - mhi_cntrl->dev_id, mhi_cntrl->domain, mhi_cntrl->bus, - mhi_cntrl->slot); - - dentry = debugfs_create_dir(node, mhi_cntrl->parent); - if (IS_ERR_OR_NULL(dentry)) - return; - - debugfs_create_file("states", 0444, dentry, mhi_cntrl, - &debugfs_state_ops); - debugfs_create_file("events", 0444, dentry, mhi_cntrl, - &debugfs_ev_ops); - debugfs_create_file("chan", 0444, dentry, mhi_cntrl, - &debugfs_chan_ops); - debugfs_create_file("reset", 0444, dentry, mhi_cntrl, - &debugfs_trigger_reset_fops); -#ifdef ENABLE_MHI_MON - debugfs_create_file("mhimon", 0444, dentry, mhi_cntrl, - &mon_fops_text_u); -#endif - mhi_cntrl->dentry = dentry; -} - -void mhi_deinit_debugfs(struct mhi_controller *mhi_cntrl) -{ - debugfs_remove_recursive(mhi_cntrl->dentry); - mhi_cntrl->dentry = NULL; -} - -int mhi_init_dev_ctxt(struct mhi_controller *mhi_cntrl) -{ - struct mhi_ctxt *mhi_ctxt; - struct mhi_chan_ctxt *chan_ctxt; - struct mhi_event_ctxt *er_ctxt; - struct mhi_cmd_ctxt *cmd_ctxt; - struct mhi_chan *mhi_chan; - struct mhi_event *mhi_event; - struct mhi_cmd *mhi_cmd; - int ret = -ENOMEM, i; - - atomic_set(&mhi_cntrl->dev_wake, 0); - atomic_set(&mhi_cntrl->alloc_size, 0); - atomic_set(&mhi_cntrl->pending_pkts, 0); - - mhi_ctxt = kzalloc(sizeof(*mhi_ctxt), GFP_KERNEL); - if (!mhi_ctxt) - return -ENOMEM; - - mhi_ctxt->ctrl_seg = mhi_alloc_coherent(mhi_cntrl, sizeof(*mhi_ctxt->ctrl_seg), - &mhi_ctxt->ctrl_seg_addr, GFP_KERNEL); - MHI_LOG("mhi_ctxt->ctrl_seg = %p\n", mhi_ctxt->ctrl_seg); - if (!mhi_ctxt->ctrl_seg) - goto error_alloc_chan_ctxt; - - if ((unsigned long)mhi_ctxt->ctrl_seg & (4096-1)) { - mhi_free_coherent(mhi_cntrl, sizeof(*mhi_ctxt->ctrl_seg), mhi_ctxt->ctrl_seg, mhi_ctxt->ctrl_seg_addr); - goto error_alloc_chan_ctxt; - } - - /* setup channel ctxt */ -#if 1 - mhi_ctxt->chan_ctxt = mhi_ctxt->ctrl_seg->chan_ctxt; - mhi_ctxt->chan_ctxt_addr = mhi_ctxt->ctrl_seg_addr + offsetof(struct mhi_ctrl_seg, chan_ctxt); -#else - mhi_ctxt->chan_ctxt = mhi_alloc_coherent(mhi_cntrl, - sizeof(*mhi_ctxt->chan_ctxt) * mhi_cntrl->max_chan, - &mhi_ctxt->chan_ctxt_addr, GFP_KERNEL); - if (!mhi_ctxt->chan_ctxt) - goto error_alloc_chan_ctxt; -#endif - - mhi_chan = mhi_cntrl->mhi_chan; - chan_ctxt = mhi_ctxt->chan_ctxt; - for (i = 0; i < mhi_cntrl->max_chan; i++, chan_ctxt++, mhi_chan++) { - /* If it's offload channel skip this step */ - if (mhi_chan->offload_ch) - continue; - - chan_ctxt->chstate = MHI_CH_STATE_DISABLED; - chan_ctxt->brstmode = mhi_chan->db_cfg.brstmode; - chan_ctxt->pollcfg = mhi_chan->db_cfg.pollcfg; - chan_ctxt->chtype = mhi_chan->type; - chan_ctxt->erindex = mhi_chan->er_index; - - mhi_chan->ch_state = MHI_CH_STATE_DISABLED; - mhi_chan->tre_ring.db_addr = &chan_ctxt->wp; - } - - /* setup event context */ -#if 1 - mhi_ctxt->er_ctxt = mhi_ctxt->ctrl_seg->er_ctxt; - mhi_ctxt->er_ctxt_addr = mhi_ctxt->ctrl_seg_addr + offsetof(struct mhi_ctrl_seg, er_ctxt); -#else - mhi_ctxt->er_ctxt = mhi_alloc_coherent(mhi_cntrl, - sizeof(*mhi_ctxt->er_ctxt) * mhi_cntrl->total_ev_rings, - &mhi_ctxt->er_ctxt_addr, GFP_KERNEL); - if (!mhi_ctxt->er_ctxt) - goto error_alloc_er_ctxt; -#endif - - er_ctxt = mhi_ctxt->er_ctxt; - mhi_event = mhi_cntrl->mhi_event; - for (i = 0; i < mhi_cntrl->total_ev_rings; i++, er_ctxt++, - mhi_event++) { - struct mhi_ring *ring = &mhi_event->ring; - - /* it's a satellite ev, we do not touch it */ - if (mhi_event->offload_ev) - continue; - - er_ctxt->intmodc = 0; - er_ctxt->intmodt = mhi_event->intmod; - er_ctxt->ertype = MHI_ER_TYPE_VALID; - if (mhi_cntrl->msi_allocated == 1) { - mhi_event->msi = 0; - } - er_ctxt->msivec = mhi_event->msi; - mhi_event->db_cfg.db_mode = true; - - ring->el_size = sizeof(struct mhi_tre); - ring->len = ring->el_size * ring->elements; -#if 1 - ring->alloc_size = ring->len; - ring->pre_aligned = mhi_ctxt->ctrl_seg->event_ring[i]; - ring->dma_handle = mhi_ctxt->ctrl_seg_addr + offsetof(struct mhi_ctrl_seg, event_ring[i]); - ring->iommu_base = ring->dma_handle; - ring->base = ring->pre_aligned + (ring->iommu_base - ring->dma_handle); -#else - ret = mhi_alloc_aligned_ring(mhi_cntrl, ring, ring->len); - if (ret) - goto error_alloc_er; -#endif - - ring->rp = ring->wp = ring->base; - er_ctxt->rbase = ring->iommu_base; - er_ctxt->rp = er_ctxt->wp = er_ctxt->rbase; - er_ctxt->rlen = ring->len; - ring->ctxt_wp = &er_ctxt->wp; - - mhi_ring_aligned_check(mhi_cntrl, er_ctxt->rbase, er_ctxt->rlen); - memset(ring->base, 0xCC, ring->len); - } - - /* setup cmd context */ -#if 1 - mhi_ctxt->cmd_ctxt = mhi_ctxt->ctrl_seg->cmd_ctxt; - mhi_ctxt->cmd_ctxt_addr = mhi_ctxt->ctrl_seg_addr + offsetof(struct mhi_ctrl_seg, cmd_ctxt); -#else - mhi_ctxt->cmd_ctxt = mhi_alloc_coherent(mhi_cntrl, - sizeof(*mhi_ctxt->cmd_ctxt) * NR_OF_CMD_RINGS, - &mhi_ctxt->cmd_ctxt_addr, GFP_KERNEL); - if (!mhi_ctxt->cmd_ctxt) - goto error_alloc_er; -#endif - - mhi_cmd = mhi_cntrl->mhi_cmd; - cmd_ctxt = mhi_ctxt->cmd_ctxt; - for (i = 0; i < NR_OF_CMD_RINGS; i++, mhi_cmd++, cmd_ctxt++) { - struct mhi_ring *ring = &mhi_cmd->ring; - - ring->el_size = sizeof(struct mhi_tre); - ring->elements = CMD_EL_PER_RING; - ring->len = ring->el_size * ring->elements; -#if 1 - ring->alloc_size = ring->len; - ring->pre_aligned = mhi_ctxt->ctrl_seg->cmd_ring[i]; - ring->dma_handle = mhi_ctxt->ctrl_seg_addr + offsetof(struct mhi_ctrl_seg, cmd_ring[i]); - ring->iommu_base = ring->dma_handle; - ring->base = ring->pre_aligned + (ring->iommu_base - ring->dma_handle); -#else - ret = mhi_alloc_aligned_ring(mhi_cntrl, ring, ring->len); - if (ret) - goto error_alloc_cmd; -#endif - - ring->rp = ring->wp = ring->base; - cmd_ctxt->rbase = ring->iommu_base; - cmd_ctxt->rp = cmd_ctxt->wp = cmd_ctxt->rbase; - cmd_ctxt->rlen = ring->len; - ring->ctxt_wp = &cmd_ctxt->wp; - - mhi_ring_aligned_check(mhi_cntrl, cmd_ctxt->rbase, cmd_ctxt->rlen); - } - - mhi_cntrl->mhi_ctxt = mhi_ctxt; - - return 0; - -#if 0 -error_alloc_cmd: - for (--i, --mhi_cmd; i >= 0; i--, mhi_cmd--) { - struct mhi_ring *ring = &mhi_cmd->ring; - - mhi_free_coherent(mhi_cntrl, ring->alloc_size, - ring->pre_aligned, ring->dma_handle); - } - mhi_free_coherent(mhi_cntrl, - sizeof(*mhi_ctxt->cmd_ctxt) * NR_OF_CMD_RINGS, - mhi_ctxt->cmd_ctxt, mhi_ctxt->cmd_ctxt_addr); - i = mhi_cntrl->total_ev_rings; - mhi_event = mhi_cntrl->mhi_event + i; - -error_alloc_er: - for (--i, --mhi_event; i >= 0; i--, mhi_event--) { - struct mhi_ring *ring = &mhi_event->ring; - - if (mhi_event->offload_ev) - continue; - - mhi_free_coherent(mhi_cntrl, ring->alloc_size, - ring->pre_aligned, ring->dma_handle); - } - mhi_free_coherent(mhi_cntrl, sizeof(*mhi_ctxt->er_ctxt) * - mhi_cntrl->total_ev_rings, mhi_ctxt->er_ctxt, - mhi_ctxt->er_ctxt_addr); - -error_alloc_er_ctxt: - mhi_free_coherent(mhi_cntrl, sizeof(*mhi_ctxt->chan_ctxt) * - mhi_cntrl->max_chan, mhi_ctxt->chan_ctxt, - mhi_ctxt->chan_ctxt_addr); -#endif - -error_alloc_chan_ctxt: - kfree(mhi_ctxt); - - return ret; -} - -static int mhi_get_tsync_er_cfg(struct mhi_controller *mhi_cntrl) -{ - int i; - struct mhi_event *mhi_event = mhi_cntrl->mhi_event; - - /* find event ring with timesync support */ - for (i = 0; i < mhi_cntrl->total_ev_rings; i++, mhi_event++) - if (mhi_event->data_type == MHI_ER_TSYNC_ELEMENT_TYPE) - return mhi_event->er_index; - - return -ENOENT; -} - -int mhi_init_timesync(struct mhi_controller *mhi_cntrl) -{ - struct mhi_timesync *mhi_tsync; - u32 time_offset, db_offset; - int ret; - - read_lock_bh(&mhi_cntrl->pm_lock); - - if (!MHI_REG_ACCESS_VALID(mhi_cntrl->pm_state)) { - ret = -EIO; - goto exit_timesync; - } - - ret = mhi_get_capability_offset(mhi_cntrl, TIMESYNC_CAP_ID, - &time_offset); - if (ret) { - MHI_LOG("No timesync capability found\n"); - goto exit_timesync; - } - - read_unlock_bh(&mhi_cntrl->pm_lock); - - if (!mhi_cntrl->time_get || !mhi_cntrl->lpm_disable || - !mhi_cntrl->lpm_enable) - return -EINVAL; - - /* register method supported */ - mhi_tsync = kzalloc(sizeof(*mhi_tsync), GFP_KERNEL); - if (!mhi_tsync) - return -ENOMEM; - - spin_lock_init(&mhi_tsync->lock); - INIT_LIST_HEAD(&mhi_tsync->head); - init_completion(&mhi_tsync->completion); - - /* save time_offset for obtaining time */ - MHI_LOG("TIME OFFS:0x%x\n", time_offset); - mhi_tsync->time_reg = mhi_cntrl->regs + time_offset - + TIMESYNC_TIME_LOW_OFFSET; - - mhi_cntrl->mhi_tsync = mhi_tsync; - - ret = mhi_create_timesync_sysfs(mhi_cntrl); - if (unlikely(ret)) { - /* kernel method still work */ - MHI_ERR("Failed to create timesync sysfs nodes\n"); - } - - read_lock_bh(&mhi_cntrl->pm_lock); - - if (!MHI_REG_ACCESS_VALID(mhi_cntrl->pm_state)) { - ret = -EIO; - goto exit_timesync; - } - - /* get DB offset if supported, else return */ - ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->regs, - time_offset + TIMESYNC_DB_OFFSET, &db_offset); - if (ret || !db_offset) { - ret = 0; - goto exit_timesync; - } - - MHI_LOG("TIMESYNC_DB OFFS:0x%x\n", db_offset); - mhi_tsync->db = mhi_cntrl->regs + db_offset; - - read_unlock_bh(&mhi_cntrl->pm_lock); - - /* get time-sync event ring configuration */ - ret = mhi_get_tsync_er_cfg(mhi_cntrl); - if (ret < 0) { - MHI_LOG("Could not find timesync event ring\n"); - return ret; - } - - mhi_tsync->er_index = ret; - - ret = mhi_send_cmd(mhi_cntrl, NULL, MHI_CMD_TIMSYNC_CFG); - if (ret) { - MHI_ERR("Failed to send time sync cfg cmd\n"); - return ret; - } - - ret = wait_for_completion_timeout(&mhi_tsync->completion, - msecs_to_jiffies(mhi_cntrl->timeout_ms)); - - if (!ret || mhi_tsync->ccs != MHI_EV_CC_SUCCESS) { - MHI_ERR("Failed to get time cfg cmd completion\n"); - return -EIO; - } - - return 0; - -exit_timesync: - read_unlock_bh(&mhi_cntrl->pm_lock); - - return ret; -} - -int mhi_init_mmio(struct mhi_controller *mhi_cntrl) -{ - u32 val = 0; - int i, ret; - struct mhi_chan *mhi_chan; - struct mhi_event *mhi_event; - void __iomem *base = mhi_cntrl->regs; - struct { - u32 offset; - u32 mask; - u32 shift; - u32 val; - } reg_info[] = { - { - CCABAP_HIGHER, U32_MAX, 0, - upper_32_bits(mhi_cntrl->mhi_ctxt->chan_ctxt_addr), - }, - { - CCABAP_LOWER, U32_MAX, 0, - lower_32_bits(mhi_cntrl->mhi_ctxt->chan_ctxt_addr), - }, - { - ECABAP_HIGHER, U32_MAX, 0, - upper_32_bits(mhi_cntrl->mhi_ctxt->er_ctxt_addr), - }, - { - ECABAP_LOWER, U32_MAX, 0, - lower_32_bits(mhi_cntrl->mhi_ctxt->er_ctxt_addr), - }, - { - CRCBAP_HIGHER, U32_MAX, 0, - upper_32_bits(mhi_cntrl->mhi_ctxt->cmd_ctxt_addr), - }, - { - CRCBAP_LOWER, U32_MAX, 0, - lower_32_bits(mhi_cntrl->mhi_ctxt->cmd_ctxt_addr), - }, -#if 0 //carl.yin 20190527 UDE-WIN-InitMmio - { - MHICFG, MHICFG_NER_MASK, MHICFG_NER_SHIFT, - mhi_cntrl->total_ev_rings, - }, - { - MHICFG, MHICFG_NHWER_MASK, MHICFG_NHWER_SHIFT, - mhi_cntrl->hw_ev_rings, - }, -#endif - { - MHICTRLBASE_HIGHER, U32_MAX, 0, - upper_32_bits(mhi_cntrl->mhi_ctxt->ctrl_seg_addr), - }, - { - MHICTRLBASE_LOWER, U32_MAX, 0, - lower_32_bits(mhi_cntrl->mhi_ctxt->ctrl_seg_addr), - }, - { - MHIDATABASE_HIGHER, U32_MAX, 0, - upper_32_bits(mhi_cntrl->iova_start), - }, - { - MHIDATABASE_LOWER, U32_MAX, 0, - lower_32_bits(mhi_cntrl->iova_start), - }, - { - MHICTRLLIMIT_HIGHER, U32_MAX, 0, - upper_32_bits(mhi_cntrl->mhi_ctxt->ctrl_seg_addr+sizeof(struct mhi_ctrl_seg)), - }, - { - MHICTRLLIMIT_LOWER, U32_MAX, 0, - lower_32_bits(mhi_cntrl->mhi_ctxt->ctrl_seg_addr+sizeof(struct mhi_ctrl_seg)), - }, - { - MHIDATALIMIT_HIGHER, U32_MAX, 0, - upper_32_bits(mhi_cntrl->iova_stop), - }, - { - MHIDATALIMIT_LOWER, U32_MAX, 0, - lower_32_bits(mhi_cntrl->iova_stop), - }, - { 0, 0, 0, 0 } - }; - - MHI_LOG("Initializing MMIO\n"); - - /* set up DB register for all the chan rings */ - ret = mhi_read_reg_field(mhi_cntrl, base, CHDBOFF, CHDBOFF_CHDBOFF_MASK, - CHDBOFF_CHDBOFF_SHIFT, &val); - if (ret) - return -EIO; - - MHI_LOG("CHDBOFF:0x%x\n", val); - - /* setup wake db */ - mhi_cntrl->wake_db = base + val + (8 * MHI_DEV_WAKE_DB); -#if 0 //'EM120RGLAPR02A07M4G_11' will treate as chan 127's interrput, and report complete event over cmd ring, but cmd ring is not set by now - mhi_write_reg(mhi_cntrl, mhi_cntrl->wake_db, 4, 0); - mhi_write_reg(mhi_cntrl, mhi_cntrl->wake_db, 0, 0); - mhi_cntrl->wake_set = false; -#endif - - /* setup channel db addresses */ - mhi_chan = mhi_cntrl->mhi_chan; - for (i = 0; i < mhi_cntrl->max_chan; i++, val += 8, mhi_chan++) - mhi_chan->tre_ring.db_addr = base + val; - - /* setup event ring db addresses */ - ret = mhi_read_reg_field(mhi_cntrl, base, ERDBOFF, ERDBOFF_ERDBOFF_MASK, - ERDBOFF_ERDBOFF_SHIFT, &val); - if (ret) - return -EIO; - - MHI_LOG("ERDBOFF:0x%x\n", val); - - mhi_event = mhi_cntrl->mhi_event; - for (i = 0; i < mhi_cntrl->total_ev_rings; i++, val += 8, mhi_event++) { - if (mhi_event->offload_ev) - continue; - - mhi_event->ring.db_addr = base + val; - } - - /* set up DB register for primary CMD rings */ - mhi_cntrl->mhi_cmd[PRIMARY_CMD_RING].ring.db_addr = base + CRDB_LOWER; - - MHI_LOG("Programming all MMIO values.\n"); - for (i = 0; reg_info[i].offset; i++) - mhi_write_reg_field(mhi_cntrl, base, reg_info[i].offset, - reg_info[i].mask, reg_info[i].shift, - reg_info[i].val); - - return 0; -} - -void mhi_deinit_chan_ctxt(struct mhi_controller *mhi_cntrl, - struct mhi_chan *mhi_chan) -{ - struct mhi_ring *buf_ring; - struct mhi_ring *tre_ring; - struct mhi_chan_ctxt *chan_ctxt; - - buf_ring = &mhi_chan->buf_ring; - tre_ring = &mhi_chan->tre_ring; - chan_ctxt = &mhi_cntrl->mhi_ctxt->chan_ctxt[mhi_chan->chan]; - -#if 0 - mhi_free_coherent(mhi_cntrl, tre_ring->alloc_size, - tre_ring->pre_aligned, tre_ring->dma_handle); -#endif - kfree(buf_ring->base); - - buf_ring->base = tre_ring->base = NULL; - chan_ctxt->rbase = 0; -} - -int mhi_init_chan_ctxt(struct mhi_controller *mhi_cntrl, - struct mhi_chan *mhi_chan) -{ - struct mhi_ring *buf_ring; - struct mhi_ring *tre_ring; - struct mhi_chan_ctxt *chan_ctxt; - int ret; - - buf_ring = &mhi_chan->buf_ring; - tre_ring = &mhi_chan->tre_ring; - tre_ring->el_size = sizeof(struct mhi_tre); - tre_ring->len = tre_ring->el_size * tre_ring->elements; - chan_ctxt = &mhi_cntrl->mhi_ctxt->chan_ctxt[mhi_chan->chan]; -#if 1 - tre_ring->alloc_size = tre_ring->len; - if (MHI_CLIENT_IP_HW_0_IN == mhi_chan->chan) { - tre_ring->pre_aligned = &mhi_cntrl->mhi_ctxt->ctrl_seg->hw_in_chan_ring[mhi_chan->ring]; - tre_ring->dma_handle = mhi_cntrl->mhi_ctxt->ctrl_seg_addr + offsetof(struct mhi_ctrl_seg, hw_in_chan_ring[mhi_chan->ring]); - } - else if (MHI_CLIENT_IP_HW_0_OUT == mhi_chan->chan) { - tre_ring->pre_aligned = &mhi_cntrl->mhi_ctxt->ctrl_seg->hw_out_chan_ring[mhi_chan->ring]; - tre_ring->dma_handle = mhi_cntrl->mhi_ctxt->ctrl_seg_addr + offsetof(struct mhi_ctrl_seg, hw_out_chan_ring[mhi_chan->ring]); - } -#ifdef ENABLE_IP_SW0 - else if (MHI_CLIENT_IP_SW_0_IN == mhi_chan->chan) { - tre_ring->pre_aligned = &mhi_cntrl->mhi_ctxt->ctrl_seg->sw_in_chan_ring[mhi_chan->ring]; - tre_ring->dma_handle = mhi_cntrl->mhi_ctxt->ctrl_seg_addr + offsetof(struct mhi_ctrl_seg, sw_in_chan_ring[mhi_chan->ring]); - } - else if (MHI_CLIENT_IP_SW_0_OUT == mhi_chan->chan) { - tre_ring->pre_aligned = &mhi_cntrl->mhi_ctxt->ctrl_seg->sw_out_chan_ring[mhi_chan->ring]; - tre_ring->dma_handle = mhi_cntrl->mhi_ctxt->ctrl_seg_addr + offsetof(struct mhi_ctrl_seg, sw_out_chan_ring[mhi_chan->ring]); - } -#endif - -#ifdef ENABLE_ADPL - else if (MHI_CLIENT_ADPL == mhi_chan->chan) { - tre_ring->pre_aligned = &mhi_cntrl->mhi_ctxt->ctrl_seg->adpl_in_chan_ring[mhi_chan->ring]; - tre_ring->dma_handle = mhi_cntrl->mhi_ctxt->ctrl_seg_addr + offsetof(struct mhi_ctrl_seg, adpl_in_chan_ring[mhi_chan->ring]); - } -#endif - -#ifdef ENABLE_QDSS - else if (MHI_CLIENT_IP_HW_QDSS == mhi_chan->chan) { - tre_ring->pre_aligned = &mhi_cntrl->mhi_ctxt->ctrl_seg->qdss_in_chan_ring[mhi_chan->ring]; - tre_ring->dma_handle = mhi_cntrl->mhi_ctxt->ctrl_seg_addr + offsetof(struct mhi_ctrl_seg, qdss_in_chan_ring[mhi_chan->ring]); - } -#endif - - else if (MHI_CLIENT_DIAG_IN == mhi_chan->chan) { - tre_ring->pre_aligned = &mhi_cntrl->mhi_ctxt->ctrl_seg->diag_in_chan_ring[mhi_chan->ring]; - tre_ring->dma_handle = mhi_cntrl->mhi_ctxt->ctrl_seg_addr + offsetof(struct mhi_ctrl_seg, diag_in_chan_ring[mhi_chan->ring]); - } - else { - tre_ring->pre_aligned = &mhi_cntrl->mhi_ctxt->ctrl_seg->chan_ring[mhi_chan->ring]; - tre_ring->dma_handle = mhi_cntrl->mhi_ctxt->ctrl_seg_addr + offsetof(struct mhi_ctrl_seg, chan_ring[mhi_chan->ring]); - } - tre_ring->iommu_base = tre_ring->dma_handle; - tre_ring->base = tre_ring->pre_aligned + (tre_ring->iommu_base - tre_ring->dma_handle); - ret = 0; -#else - ret = mhi_alloc_aligned_ring(mhi_cntrl, tre_ring, tre_ring->len); -#endif - if (ret) - return -ENOMEM; - - buf_ring->el_size = sizeof(struct mhi_buf_info); - buf_ring->len = buf_ring->el_size * buf_ring->elements; - buf_ring->base = kzalloc(buf_ring->len, GFP_KERNEL); - - if (!buf_ring->base) { -#if 0 - mhi_free_coherent(mhi_cntrl, tre_ring->alloc_size, - tre_ring->pre_aligned, tre_ring->dma_handle); -#endif - return -ENOMEM; - } - - chan_ctxt->chstate = MHI_CH_STATE_ENABLED; - chan_ctxt->rbase = tre_ring->iommu_base; - chan_ctxt->rp = chan_ctxt->wp = chan_ctxt->rbase; - chan_ctxt->rlen = tre_ring->len; - tre_ring->ctxt_wp = &chan_ctxt->wp; - - tre_ring->rp = tre_ring->wp = tre_ring->base; - buf_ring->rp = buf_ring->wp = buf_ring->base; - mhi_chan->db_cfg.db_mode = true; - - mhi_ring_aligned_check(mhi_cntrl, chan_ctxt->rbase, chan_ctxt->rlen); - /* update to all cores */ - smp_wmb(); - - return 0; -} - -int mhi_device_configure(struct mhi_device *mhi_dev, - enum dma_data_direction dir, - struct mhi_buf *cfg_tbl, - int elements) -{ - struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; - struct mhi_chan *mhi_chan; - struct mhi_event_ctxt *er_ctxt; - struct mhi_chan_ctxt *ch_ctxt; - int er_index, chan; - - switch (dir) { - case DMA_TO_DEVICE: - mhi_chan = mhi_dev->ul_chan; - break; - case DMA_BIDIRECTIONAL: - case DMA_FROM_DEVICE: - case DMA_NONE: - mhi_chan = mhi_dev->dl_chan; - break; - default: - return -EINVAL; - } - - er_index = mhi_chan->er_index; - chan = mhi_chan->chan; - - for (; elements > 0; elements--, cfg_tbl++) { - /* update event context array */ - if (!strcmp(cfg_tbl->name, "ECA")) { - er_ctxt = &mhi_cntrl->mhi_ctxt->er_ctxt[er_index]; - if (sizeof(*er_ctxt) != cfg_tbl->len) { - MHI_ERR( - "Invalid ECA size, expected:%zu actual%zu\n", - sizeof(*er_ctxt), cfg_tbl->len); - return -EINVAL; - } - memcpy((void *)er_ctxt, cfg_tbl->buf, sizeof(*er_ctxt)); - continue; - } - - /* update channel context array */ - if (!strcmp(cfg_tbl->name, "CCA")) { - ch_ctxt = &mhi_cntrl->mhi_ctxt->chan_ctxt[chan]; - if (cfg_tbl->len != sizeof(*ch_ctxt)) { - MHI_ERR( - "Invalid CCA size, expected:%zu actual:%zu\n", - sizeof(*ch_ctxt), cfg_tbl->len); - return -EINVAL; - } - memcpy((void *)ch_ctxt, cfg_tbl->buf, sizeof(*ch_ctxt)); - continue; - } - - return -EINVAL; - } - - return 0; -} - -#if 0 -static int of_parse_ev_cfg(struct mhi_controller *mhi_cntrl, - struct device_node *of_node) -{ - int i, ret, num = 0; - struct mhi_event *mhi_event; - struct device_node *child; - - of_node = of_find_node_by_name(of_node, "mhi_events"); - if (!of_node) - return -EINVAL; - - for_each_available_child_of_node(of_node, child) { - if (!strcmp(child->name, "mhi_event")) - num++; - } - - if (!num) - return -EINVAL; - - mhi_cntrl->total_ev_rings = num; - mhi_cntrl->mhi_event = kcalloc(num, sizeof(*mhi_cntrl->mhi_event), - GFP_KERNEL); - if (!mhi_cntrl->mhi_event) - return -ENOMEM; - - /* populate ev ring */ - mhi_event = mhi_cntrl->mhi_event; - i = 0; - for_each_available_child_of_node(of_node, child) { - if (strcmp(child->name, "mhi_event")) - continue; - - mhi_event->er_index = i++; - ret = of_property_read_u32(child, "mhi,num-elements", - (u32 *)&mhi_event->ring.elements); - if (ret) - goto error_ev_cfg; - - ret = of_property_read_u32(child, "mhi,intmod", - &mhi_event->intmod); - if (ret) - goto error_ev_cfg; - - ret = of_property_read_u32(child, "mhi,msi", - &mhi_event->msi); - if (ret) - goto error_ev_cfg; - - ret = of_property_read_u32(child, "mhi,chan", - &mhi_event->chan); - if (!ret) { - if (mhi_event->chan >= mhi_cntrl->max_chan) - goto error_ev_cfg; - /* this event ring has a dedicated channel */ - mhi_event->mhi_chan = - &mhi_cntrl->mhi_chan[mhi_event->chan]; - } - - ret = of_property_read_u32(child, "mhi,priority", - &mhi_event->priority); - if (ret) - goto error_ev_cfg; - - ret = of_property_read_u32(child, "mhi,brstmode", - &mhi_event->db_cfg.brstmode); - if (ret || MHI_INVALID_BRSTMODE(mhi_event->db_cfg.brstmode)) - goto error_ev_cfg; - - mhi_event->db_cfg.process_db = - (mhi_event->db_cfg.brstmode == MHI_BRSTMODE_ENABLE) ? - mhi_db_brstmode : mhi_db_brstmode_disable; - - ret = of_property_read_u32(child, "mhi,data-type", - &mhi_event->data_type); - if (ret) - mhi_event->data_type = MHI_ER_DATA_ELEMENT_TYPE; - - if (mhi_event->data_type > MHI_ER_DATA_TYPE_MAX) - goto error_ev_cfg; - - switch (mhi_event->data_type) { - case MHI_ER_DATA_ELEMENT_TYPE: - mhi_event->process_event = mhi_process_data_event_ring; - break; - case MHI_ER_CTRL_ELEMENT_TYPE: - mhi_event->process_event = mhi_process_ctrl_ev_ring; - break; - case MHI_ER_TSYNC_ELEMENT_TYPE: - mhi_event->process_event = mhi_process_tsync_event_ring; - break; - } - - mhi_event->hw_ring = of_property_read_bool(child, "mhi,hw-ev"); - if (mhi_event->hw_ring) - mhi_cntrl->hw_ev_rings++; - else - mhi_cntrl->sw_ev_rings++; - mhi_event->cl_manage = of_property_read_bool(child, - "mhi,client-manage"); - mhi_event->offload_ev = of_property_read_bool(child, - "mhi,offload"); - mhi_event++; - } - - /* we need msi for each event ring + additional one for BHI */ - mhi_cntrl->msi_required = mhi_cntrl->total_ev_rings + 1; - - return 0; - -error_ev_cfg: - - kfree(mhi_cntrl->mhi_event); - return -EINVAL; -} -static int of_parse_ch_cfg(struct mhi_controller *mhi_cntrl, - struct device_node *of_node) -{ - int ret; - struct device_node *child; - u32 chan; - - ret = of_property_read_u32(of_node, "mhi,max-channels", - &mhi_cntrl->max_chan); - if (ret) - return ret; - - of_node = of_find_node_by_name(of_node, "mhi_channels"); - if (!of_node) - return -EINVAL; - - mhi_cntrl->mhi_chan = kcalloc(mhi_cntrl->max_chan, - sizeof(*mhi_cntrl->mhi_chan), GFP_KERNEL); - if (!mhi_cntrl->mhi_chan) - return -ENOMEM; - - INIT_LIST_HEAD(&mhi_cntrl->lpm_chans); - - /* populate channel configurations */ - for_each_available_child_of_node(of_node, child) { - struct mhi_chan *mhi_chan; - - if (strcmp(child->name, "mhi_chan")) - continue; - - ret = of_property_read_u32(child, "reg", &chan); - if (ret || chan >= mhi_cntrl->max_chan) - goto error_chan_cfg; - - mhi_chan = &mhi_cntrl->mhi_chan[chan]; - - ret = of_property_read_string(child, "label", - &mhi_chan->name); - if (ret) - goto error_chan_cfg; - - mhi_chan->chan = chan; - - ret = of_property_read_u32(child, "mhi,num-elements", - (u32 *)&mhi_chan->tre_ring.elements); - if (!ret && !mhi_chan->tre_ring.elements) - goto error_chan_cfg; - - /* - * For some channels, local ring len should be bigger than - * transfer ring len due to internal logical channels in device. - * So host can queue much more buffers than transfer ring len. - * Example, RSC channels should have a larger local channel - * than transfer ring length. - */ - ret = of_property_read_u32(child, "mhi,local-elements", - (u32 *)&mhi_chan->buf_ring.elements); - if (ret) - mhi_chan->buf_ring.elements = - mhi_chan->tre_ring.elements; - - ret = of_property_read_u32(child, "mhi,event-ring", - &mhi_chan->er_index); - if (ret) - goto error_chan_cfg; - - ret = of_property_read_u32(child, "mhi,chan-dir", - &mhi_chan->dir); - if (ret) - goto error_chan_cfg; - - /* - * For most channels, chtype is identical to channel directions, - * if not defined, assign ch direction to chtype - */ - ret = of_property_read_u32(child, "mhi,chan-type", - &mhi_chan->type); - if (ret) - mhi_chan->type = (enum mhi_ch_type)mhi_chan->dir; - - ret = of_property_read_u32(child, "mhi,ee", &mhi_chan->ee_mask); - if (ret) - goto error_chan_cfg; - - of_property_read_u32(child, "mhi,pollcfg", - &mhi_chan->db_cfg.pollcfg); - - ret = of_property_read_u32(child, "mhi,data-type", - &mhi_chan->xfer_type); - if (ret) - goto error_chan_cfg; - - switch (mhi_chan->xfer_type) { - case MHI_XFER_BUFFER: - mhi_chan->gen_tre = mhi_gen_tre; - mhi_chan->queue_xfer = mhi_queue_buf; - break; - case MHI_XFER_SKB: - mhi_chan->queue_xfer = mhi_queue_skb; - break; - case MHI_XFER_SCLIST: - mhi_chan->gen_tre = mhi_gen_tre; - mhi_chan->queue_xfer = mhi_queue_sclist; - break; - case MHI_XFER_NOP: - mhi_chan->queue_xfer = mhi_queue_nop; - break; - case MHI_XFER_DMA: - case MHI_XFER_RSC_DMA: - mhi_chan->queue_xfer = mhi_queue_dma; - break; - default: - goto error_chan_cfg; - } - - mhi_chan->lpm_notify = of_property_read_bool(child, - "mhi,lpm-notify"); - mhi_chan->offload_ch = of_property_read_bool(child, - "mhi,offload-chan"); - mhi_chan->db_cfg.reset_req = of_property_read_bool(child, - "mhi,db-mode-switch"); - mhi_chan->pre_alloc = of_property_read_bool(child, - "mhi,auto-queue"); - mhi_chan->auto_start = of_property_read_bool(child, - "mhi,auto-start"); - mhi_chan->wake_capable = of_property_read_bool(child, - "mhi,wake-capable"); - - if (mhi_chan->pre_alloc && - (mhi_chan->dir != DMA_FROM_DEVICE || - mhi_chan->xfer_type != MHI_XFER_BUFFER)) - goto error_chan_cfg; - - /* bi-dir and dirctionless channels must be a offload chan */ - if ((mhi_chan->dir == DMA_BIDIRECTIONAL || - mhi_chan->dir == DMA_NONE) && !mhi_chan->offload_ch) - goto error_chan_cfg; - - /* if mhi host allocate the buffers then client cannot queue */ - if (mhi_chan->pre_alloc) - mhi_chan->queue_xfer = mhi_queue_nop; - - if (!mhi_chan->offload_ch) { - ret = of_property_read_u32(child, "mhi,doorbell-mode", - &mhi_chan->db_cfg.brstmode); - if (ret || - MHI_INVALID_BRSTMODE(mhi_chan->db_cfg.brstmode)) - goto error_chan_cfg; - - mhi_chan->db_cfg.process_db = - (mhi_chan->db_cfg.brstmode == - MHI_BRSTMODE_ENABLE) ? - mhi_db_brstmode : mhi_db_brstmode_disable; - } - - mhi_chan->configured = true; - - if (mhi_chan->lpm_notify) - list_add_tail(&mhi_chan->node, &mhi_cntrl->lpm_chans); - } - - return 0; - -error_chan_cfg: - kfree(mhi_cntrl->mhi_chan); - - return -EINVAL; -} -#else -static int of_parse_ev_cfg(struct mhi_controller *mhi_cntrl, - struct device_node *of_node) -{ - int i, num = 0; - struct mhi_event *mhi_event; - - num = NUM_MHI_EVT_RINGS; - mhi_cntrl->total_ev_rings = num; - mhi_cntrl->mhi_event = kcalloc(num, sizeof(*mhi_cntrl->mhi_event), - GFP_KERNEL); - if (!mhi_cntrl->mhi_event) - return -ENOMEM; - - mhi_cntrl->msi_irq_base = 0; - /* populate ev ring */ - mhi_event = mhi_cntrl->mhi_event; - i = 0; - - for (i = 0; i < mhi_cntrl->total_ev_rings; i++) { - mhi_event->er_index = i; - - mhi_event->ring.elements = NUM_MHI_EVT_RING_ELEMENTS; //Event ring length in elements - if (i == PRIMARY_EVENT_RING) - mhi_event->ring.elements = 256; //256 is enough, and 1024 some times make driver fail to open channel (reason is x6x fail to malloc) - - mhi_event->intmod = 1; //Interrupt moderation time in ms - -#ifdef ENABLE_ADPL - if (i == ADPL_EVT_RING) - mhi_event->ring.elements = 256; -#endif - -#ifdef ENABLE_QDSS - if (i == QDSS_EVT_RING) - mhi_event->ring.elements = 512; -#endif - - /* see mhi_netdev_status_cb(), when interrupt come, the napi_poll maybe scheduled, so can reduce interrupts - root@OpenWrt:/# cat /proc/interrupts | grep mhi - root@OpenWrt:/# cat /sys/kernel/debug/mhi_q/mhi_netdev/pcie_mhi_0306_00.01.00_0/rx_int - */ - if (i == IPA_IN_EVENT_RING) - mhi_event->intmod = 5; - -#ifdef ENABLE_IP_SW0 - if (i == SW_0_IN_EVT_RING) - mhi_event->intmod = 5; -#endif - -#ifdef ENABLE_ADPL - if (i == ADPL_EVT_RING) - mhi_event->intmod = 0; -#endif - -#ifdef ENABLE_QDSS - if (i == QDSS_EVT_RING) - mhi_event->intmod = 0; -#endif - - mhi_event->msi = 1 + i + mhi_cntrl->msi_irq_base; //MSI associated with this event ring - - if (i == IPA_OUT_EVENT_RING) - mhi_event->chan = MHI_CLIENT_IP_HW_0_OUT; //Dedicated channel number, if it's a dedicated event ring - else if (i == IPA_IN_EVENT_RING) - mhi_event->chan = MHI_CLIENT_IP_HW_0_IN; //Dedicated channel number, if it's a dedicated event ring -#ifdef ENABLE_IP_SW0 - else if (i == SW_0_OUT_EVT_RING) - mhi_event->chan = MHI_CLIENT_IP_SW_0_OUT; - else if (i == SW_0_IN_EVT_RING) - mhi_event->chan = MHI_CLIENT_IP_SW_0_IN; -#endif - -#ifdef ENABLE_ADPL - else if (i == ADPL_EVT_RING) - mhi_event->chan = MHI_CLIENT_ADPL; -#endif - -#ifdef ENABLE_QDSS - else if (i == QDSS_EVT_RING) - mhi_event->chan = MHI_CLIENT_IP_HW_QDSS; -#endif - else - mhi_event->chan = 0; - - /* this event ring has a dedicated channel */ - mhi_event->mhi_chan = - &mhi_cntrl->mhi_chan[mhi_event->chan]; - - mhi_event->priority = 1; //Event ring priority, set to 1 for now - - if (mhi_event->chan && mhi_event->mhi_chan->db_cfg.brstmode == MHI_BRSTMODE_ENABLE) - mhi_event->db_cfg.brstmode = MHI_BRSTMODE_ENABLE; - else - mhi_event->db_cfg.brstmode = MHI_BRSTMODE_DISABLE; - - mhi_event->db_cfg.process_db = - (mhi_event->db_cfg.brstmode == MHI_BRSTMODE_ENABLE) ? - mhi_db_brstmode : mhi_db_brstmode_disable; - - if (i == IPA_OUT_EVENT_RING || i == IPA_IN_EVENT_RING) - mhi_event->data_type = MHI_ER_DATA_ELEMENT_TYPE; -#ifdef ENABLE_IP_SW0 - else if (i == SW_0_OUT_EVT_RING || i == SW_0_IN_EVT_RING) - mhi_event->data_type = MHI_ER_DATA_ELEMENT_TYPE; -#endif - -#ifdef ENABLE_ADPL - else if (i == ADPL_EVT_RING) - mhi_event->data_type = MHI_ER_DATA_ELEMENT_TYPE; -#endif - -#ifdef ENABLE_QDSS - else if (i == QDSS_EVT_RING) - mhi_event->data_type = MHI_ER_DATA_ELEMENT_TYPE; -#endif - else - mhi_event->data_type = MHI_ER_CTRL_ELEMENT_TYPE; - - switch (mhi_event->data_type) { - case MHI_ER_DATA_ELEMENT_TYPE: - mhi_event->process_event = mhi_process_data_event_ring; - break; - case MHI_ER_CTRL_ELEMENT_TYPE: - mhi_event->process_event = mhi_process_ctrl_ev_ring; - break; - case MHI_ER_TSYNC_ELEMENT_TYPE: - mhi_event->process_event = mhi_process_tsync_event_ring; - break; - } - - if (i == IPA_OUT_EVENT_RING || i == IPA_IN_EVENT_RING -#ifdef ENABLE_ADPL - || i == ADPL_EVT_RING -#endif -#ifdef ENABLE_QDSS - || i == QDSS_EVT_RING -#endif - ) - mhi_event->hw_ring = true; - else - mhi_event->hw_ring = false; - - if (mhi_event->hw_ring) - mhi_cntrl->hw_ev_rings++; - else - mhi_cntrl->sw_ev_rings++; - - mhi_event->cl_manage = false; - if (mhi_event->chan == MHI_CLIENT_IP_HW_0_IN || mhi_event->chan == MHI_CLIENT_IP_SW_0_IN) - mhi_event->cl_manage = true; - mhi_event->offload_ev = false; - mhi_event++; - } - - /* we need msi for each event ring + additional one for BHI */ - mhi_cntrl->msi_required = mhi_cntrl->total_ev_rings + 1 + mhi_cntrl->msi_irq_base; - - return 0; -} - -struct chan_cfg_t { - const char *chan_name; - u32 chan_id; - u32 elements; -}; - -static struct chan_cfg_t chan_cfg[] = { -//"Qualcomm PCIe Loopback" - {"LOOPBACK", MHI_CLIENT_LOOPBACK_OUT, NUM_MHI_CHAN_RING_ELEMENTS}, - {"LOOPBACK", MHI_CLIENT_LOOPBACK_IN, NUM_MHI_CHAN_RING_ELEMENTS}, -//"Qualcomm PCIe Sahara" - {"SAHARA", MHI_CLIENT_SAHARA_OUT, NUM_MHI_CHAN_RING_ELEMENTS}, - {"SAHARA", MHI_CLIENT_SAHARA_IN, NUM_MHI_CHAN_RING_ELEMENTS}, -//"Qualcomm PCIe Diagnostics" - {"DIAG", MHI_CLIENT_DIAG_OUT, NUM_MHI_CHAN_RING_ELEMENTS}, - {"DIAG", MHI_CLIENT_DIAG_IN, NUM_MHI_DIAG_IN_RING_ELEMENTS}, -//"Qualcomm PCIe QDSS Data" -//"Do not use this QDSS. xingduo.du 2023-02-16" -// {"QDSS", MHI_CLIENT_QDSS_OUT, NUM_MHI_CHAN_RING_ELEMENTS}, -// {"QDSS", MHI_CLIENT_QDSS_IN, NUM_MHI_CHAN_RING_ELEMENTS}, -//"Qualcomm PCIe EFS" - {"EFS", MHI_CLIENT_EFS_OUT, NUM_MHI_CHAN_RING_ELEMENTS}, - {"EFS", MHI_CLIENT_EFS_IN, NUM_MHI_CHAN_RING_ELEMENTS}, -//"Qualcomm PCIe MBIM" - {"MBIM", MHI_CLIENT_MBIM_OUT, NUM_MHI_CHAN_RING_ELEMENTS}, - {"MBIM", MHI_CLIENT_MBIM_IN, NUM_MHI_CHAN_RING_ELEMENTS}, -//"Qualcomm PCIe QMI" - {"QMI0", MHI_CLIENT_QMI_OUT, NUM_MHI_CHAN_RING_ELEMENTS}, - {"QMI0", MHI_CLIENT_QMI_IN, NUM_MHI_CHAN_RING_ELEMENTS}, -//"Qualcomm PCIe QMI" - //{"QMI1", MHI_CLIENT_QMI_2_OUT, NUM_MHI_CHAN_RING_ELEMENTS}, - //{"QMI1", MHI_CLIENT_QMI_2_IN, NUM_MHI_CHAN_RING_ELEMENTS}, -//"Qualcomm PCIe IP CTRL" - {"IP_CTRL", MHI_CLIENT_IP_CTRL_1_OUT, NUM_MHI_CHAN_RING_ELEMENTS}, - {"IP_CTRL", MHI_CLIENT_IP_CTRL_1_IN, NUM_MHI_CHAN_RING_ELEMENTS}, -#if 0 //AG15 -//"Qualcomm PCIe IPCR" - {"IPCR", MHI_CLIENT_DIAG_CONS_IF_OUT, NUM_MHI_CHAN_RING_ELEMENTS}, - {"IPCR", MHI_CLIENT_DIAG_CONS_IF_IN, NUM_MHI_CHAN_RING_ELEMENTS}, -#endif -//"Qualcomm PCIe Boot Logging" - //{"BL", MHI_CLIENT_BOOT_LOG_OUT, NUM_MHI_CHAN_RING_ELEMENTS}, - //{"BL", MHI_CLIENT_BOOT_LOG_IN, NUM_MHI_CHAN_RING_ELEMENTS}, -//"Qualcomm PCIe Modem" - {"DUN", MHI_CLIENT_DUN_OUT, NUM_MHI_CHAN_RING_ELEMENTS}, - {"DUN", MHI_CLIENT_DUN_IN, NUM_MHI_CHAN_RING_ELEMENTS}, -//"Qualcomm EDL " - {"EDL", MHI_CLIENT_EDL_OUT, NUM_MHI_CHAN_RING_ELEMENTS}, - {"EDL", MHI_CLIENT_EDL_IN, NUM_MHI_CHAN_RING_ELEMENTS}, -#ifdef ENABLE_IP_SW0 -//"Qualcomm PCIe LOCAL Adapter" - {"IP_SW0", MHI_CLIENT_IP_SW_0_OUT, NUM_MHI_SW_IP_RING_ELEMENTS}, - {"IP_SW0", MHI_CLIENT_IP_SW_0_IN, NUM_MHI_SW_IP_RING_ELEMENTS}, -#endif -//"Qualcomm PCIe WWAN Adapter" - {"IP_HW0", MHI_CLIENT_IP_HW_0_OUT, NUM_MHI_IPA_OUT_RING_ELEMENTS}, - {"IP_HW0", MHI_CLIENT_IP_HW_0_IN, NUM_MHI_IPA_IN_RING_ELEMENTS}, -#ifdef ENABLE_ADPL - {"ADPL", MHI_CLIENT_ADPL, NUM_MHI_ADPL_RING_ELEMENTS}, -#endif - -#ifdef ENABLE_QDSS - {"QDSS", MHI_CLIENT_IP_HW_QDSS, NUM_MHI_QDSS_RING_ELEMENTS}, -#endif -}; - -extern int mhi_netdev_mbin_enabled(void); -static int of_parse_ch_cfg(struct mhi_controller *mhi_cntrl, - struct device_node *of_node) -{ - u32 chan; - u32 i, num; - u32 ring = 0; - - mhi_cntrl->max_chan = MHI_MAX_CHANNELS; - num = sizeof(chan_cfg)/sizeof(chan_cfg[0]); - - mhi_cntrl->mhi_chan = kcalloc(mhi_cntrl->max_chan, - sizeof(*mhi_cntrl->mhi_chan), GFP_KERNEL); - if (!mhi_cntrl->mhi_chan) - return -ENOMEM; - - INIT_LIST_HEAD(&mhi_cntrl->lpm_chans); - - /* populate channel configurations */ - for (i = 0; i < num; i++) { - struct mhi_chan *mhi_chan; - - if (!strncmp( chan_cfg[i].chan_name, "MBIM", 4)) { - if (!mhi_netdev_mbin_enabled()) - continue; - } - else if (!strncmp( chan_cfg[i].chan_name, "QMI", 3)) { - if (mhi_netdev_mbin_enabled()) - continue; - } - - chan = chan_cfg[i].chan_id; - - mhi_chan = &mhi_cntrl->mhi_chan[chan]; - - mhi_chan->name = chan_cfg[i].chan_name; - - mhi_chan->chan = chan; - - mhi_chan->tre_ring.elements = chan_cfg[i].elements; - - /* - * For some channels, local ring len should be bigger than - * transfer ring len due to internal logical channels in device. - * So host can queue much more buffers than transfer ring len. - * Example, RSC channels should have a larger local channel - * than transfer ring length. - */ - mhi_chan->buf_ring.elements = mhi_chan->tre_ring.elements; - - if (chan == MHI_CLIENT_IP_HW_0_OUT || chan == MHI_CLIENT_IP_HW_0_IN || chan == MHI_CLIENT_DIAG_IN - || chan == MHI_CLIENT_IP_SW_0_OUT || chan == MHI_CLIENT_IP_SW_0_IN -#ifdef ENABLE_ADPL - || chan == MHI_CLIENT_ADPL -#endif -#ifdef ENABLE_QDSS - || chan == MHI_CLIENT_IP_HW_QDSS -#endif - ) { - mhi_chan->ring = 0; - } - else { - mhi_chan->ring = ring; - ring += mhi_chan->buf_ring.elements; - } - - if (chan == MHI_CLIENT_IP_HW_0_OUT) - mhi_chan->er_index = IPA_OUT_EVENT_RING; - else if (chan == MHI_CLIENT_IP_HW_0_IN) - mhi_chan->er_index = IPA_IN_EVENT_RING; -#ifdef ENABLE_IP_SW0 - else if (chan == MHI_CLIENT_IP_SW_0_OUT) - mhi_chan->er_index = SW_0_OUT_EVT_RING; - else if (chan == MHI_CLIENT_IP_SW_0_IN) - mhi_chan->er_index = SW_0_IN_EVT_RING; -#endif - -#ifdef ENABLE_ADPL - else if (chan == MHI_CLIENT_ADPL) - mhi_chan->er_index = ADPL_EVT_RING; -#endif -#ifdef ENABLE_QDSS - else if (chan == MHI_CLIENT_IP_HW_QDSS) - mhi_chan->er_index = QDSS_EVT_RING; -#endif - else - mhi_chan->er_index = PRIMARY_EVENT_RING; - - mhi_chan->dir = CHAN_INBOUND(chan) ? DMA_FROM_DEVICE : DMA_TO_DEVICE; - -#ifdef ENABLE_ADPL - if (chan == MHI_CLIENT_ADPL) - mhi_chan->dir = DMA_FROM_DEVICE; -#endif - -#ifdef ENABLE_QDSS - if (chan == MHI_CLIENT_IP_HW_QDSS) - mhi_chan->dir = DMA_FROM_DEVICE; -#endif - /* - * For most channels, chtype is identical to channel directions, - * if not defined, assign ch direction to chtype - */ - mhi_chan->type = (enum mhi_ch_type)mhi_chan->dir; - - mhi_chan->ee_mask = BIT(MHI_EE_AMSS); - if (CHAN_SBL(chan)) - mhi_chan->ee_mask = BIT(MHI_EE_SBL); - else if (CHAN_EDL(chan)) - mhi_chan->ee_mask = BIT(MHI_EE_FP); - - mhi_chan->db_cfg.pollcfg = 0; - - if (chan == MHI_CLIENT_IP_HW_0_OUT || chan == MHI_CLIENT_IP_SW_0_OUT) - mhi_chan->xfer_type = MHI_XFER_SKB; - else if (chan == MHI_CLIENT_IP_HW_0_IN || chan == MHI_CLIENT_IP_SW_0_IN) - mhi_chan->xfer_type = MHI_XFER_SKB; //MHI_XFER_DMA; -#ifdef ENABLE_ADPL - else if (chan == MHI_CLIENT_ADPL) - mhi_chan->xfer_type = MHI_XFER_BUFFER; -#endif -#ifdef ENABLE_QDSS - else if (chan == MHI_CLIENT_IP_HW_QDSS) - mhi_chan->xfer_type = MHI_XFER_BUFFER; -#endif - else - mhi_chan->xfer_type = MHI_XFER_BUFFER; - - if (chan_cfg[i].elements == 0) { - mhi_chan->dir = DMA_BIDIRECTIONAL; - mhi_chan->xfer_type = MHI_XFER_NOP; - } - - switch (mhi_chan->xfer_type) { - case MHI_XFER_BUFFER: - mhi_chan->gen_tre = mhi_gen_tre; - mhi_chan->queue_xfer = mhi_queue_buf; - break; - case MHI_XFER_SKB: - mhi_chan->queue_xfer = mhi_queue_skb; - break; - case MHI_XFER_SCLIST: - mhi_chan->gen_tre = mhi_gen_tre; - mhi_chan->queue_xfer = mhi_queue_sclist; - break; - case MHI_XFER_NOP: - mhi_chan->queue_xfer = mhi_queue_nop; - break; - case MHI_XFER_DMA: - case MHI_XFER_RSC_DMA: - mhi_chan->queue_xfer = mhi_queue_dma; - break; - default: - goto error_chan_cfg; - } - - mhi_chan->lpm_notify = false; - mhi_chan->offload_ch = (chan_cfg[i].elements == 0); - mhi_chan->db_cfg.reset_req = false; - mhi_chan->pre_alloc = false; - mhi_chan->auto_start = false; - mhi_chan->wake_capable = false; - - if (mhi_chan->pre_alloc && - (mhi_chan->dir != DMA_FROM_DEVICE || - mhi_chan->xfer_type != MHI_XFER_BUFFER)) - goto error_chan_cfg; - - /* bi-dir and dirctionless channels must be a offload chan */ - if ((mhi_chan->dir == DMA_BIDIRECTIONAL || - mhi_chan->dir == DMA_NONE) && !mhi_chan->offload_ch) - goto error_chan_cfg; - - /* if mhi host allocate the buffers then client cannot queue */ - if (mhi_chan->pre_alloc) - mhi_chan->queue_xfer = mhi_queue_nop; - - if (!mhi_chan->offload_ch) { - mhi_chan->db_cfg.brstmode = MHI_BRSTMODE_DISABLE; - if (chan == MHI_CLIENT_IP_HW_0_OUT || chan == MHI_CLIENT_IP_HW_0_IN) - mhi_chan->db_cfg.brstmode = MHI_BRSTMODE_ENABLE; - -#ifdef ENABLE_ADPL - if (chan == MHI_CLIENT_ADPL) - mhi_chan->db_cfg.brstmode = MHI_BRSTMODE_DISABLE; -#endif -#ifdef ENABLE_QDSS - if (chan == MHI_CLIENT_IP_HW_QDSS) - mhi_chan->db_cfg.brstmode = MHI_BRSTMODE_DISABLE; -#endif - if (MHI_INVALID_BRSTMODE(mhi_chan->db_cfg.brstmode)) - goto error_chan_cfg; - - mhi_chan->db_cfg.process_db = - (mhi_chan->db_cfg.brstmode == - MHI_BRSTMODE_ENABLE) ? - mhi_db_brstmode : mhi_db_brstmode_disable; - } - - mhi_chan->configured = true; - - if (mhi_chan->lpm_notify) - list_add_tail(&mhi_chan->node, &mhi_cntrl->lpm_chans); - } - - return 0; - -error_chan_cfg: - kfree(mhi_cntrl->mhi_chan); - - return -EINVAL; -} -#endif - -static int of_parse_dt(struct mhi_controller *mhi_cntrl, - struct device_node *of_node) -{ - int ret; - - /* parse MHI channel configuration */ - ret = of_parse_ch_cfg(mhi_cntrl, of_node); - if (ret) - return ret; - - /* parse MHI event configuration */ - ret = of_parse_ev_cfg(mhi_cntrl, of_node); - if (ret) - goto error_ev_cfg; -#if defined(QCOM_AP_QCA6490_DMA_IOMMU) - /* for QCS6490 iommu-dma is fastmap - for SG845 iommu-dma is set in driver - for ipq iommu-dma is disabled - */ - const char *str; - ret = of_property_read_string(of_node, "qcom,iommu-dma", &str); - if (ret) - MHI_ERR("mhi qcom,iommu-dma need set"); - -#endif -#if 0 - ret = of_property_read_u32(of_node, "mhi,timeout", - &mhi_cntrl->timeout_ms); - if (ret) - mhi_cntrl->timeout_ms = MHI_TIMEOUT_MS; - - mhi_cntrl->bounce_buf = of_property_read_bool(of_node, "mhi,use-bb"); - ret = of_property_read_u32(of_node, "mhi,buffer-len", - (u32 *)&mhi_cntrl->buffer_len); - if (ret) - mhi_cntrl->buffer_len = MHI_MAX_MTU; -#else - mhi_cntrl->timeout_ms = MHI_TIMEOUT_MS; - mhi_cntrl->bounce_buf = false; - mhi_cntrl->buffer_len = MHI_MAX_MTU; -#endif - - return 0; - -error_ev_cfg: - kfree(mhi_cntrl->mhi_chan); - - return ret; -} - -int of_register_mhi_controller(struct mhi_controller *mhi_cntrl) -{ - int ret; - int i; - struct mhi_event *mhi_event; - struct mhi_chan *mhi_chan; - struct mhi_cmd *mhi_cmd; - struct mhi_device *mhi_dev; - - //if (!mhi_cntrl->of_node) - // return -EINVAL; - - for (i = 0; i < MAX_MHI_CONTROLLER; i++) { - if (mhi_controller_minors[i].dev_id == mhi_cntrl->dev_id - && mhi_controller_minors[i].domain == mhi_cntrl->domain - && mhi_controller_minors[i].bus == mhi_cntrl->bus - && mhi_controller_minors[i].slot == mhi_cntrl->slot) { - mhi_cntrl->cntrl_idx = i; - break; - } - else if (mhi_controller_minors[i].dev_id == 0 - && mhi_controller_minors[i].domain == 0 - && mhi_controller_minors[i].bus == 0 - && mhi_controller_minors[i].slot == 0) { - mhi_controller_minors[i].dev_id = mhi_cntrl->dev_id; - mhi_controller_minors[i].domain = mhi_cntrl->domain; - mhi_controller_minors[i].bus = mhi_cntrl->bus; - mhi_controller_minors[i].slot = mhi_cntrl->slot; - mhi_controller_minors[i].mhi_cntrl = mhi_cntrl; - mhi_cntrl->cntrl_idx = i; - break; - } - } - - if (i == MAX_MHI_CONTROLLER) - return -EINVAL; - - if (!mhi_cntrl->runtime_get || !mhi_cntrl->runtime_put) - return -EINVAL; - - if (!mhi_cntrl->status_cb || !mhi_cntrl->link_status) - return -EINVAL; - - ret = of_parse_dt(mhi_cntrl, mhi_cntrl->of_node); - if (ret) - return -EINVAL; - - mhi_cntrl->mhi_cmd = kcalloc(NR_OF_CMD_RINGS, - sizeof(*mhi_cntrl->mhi_cmd), GFP_KERNEL); - if (!mhi_cntrl->mhi_cmd) { - ret = -ENOMEM; - goto error_alloc_cmd; - } - - INIT_LIST_HEAD(&mhi_cntrl->transition_list); - mutex_init(&mhi_cntrl->pm_mutex); - rwlock_init(&mhi_cntrl->pm_lock); - spin_lock_init(&mhi_cntrl->transition_lock); - spin_lock_init(&mhi_cntrl->wlock); - INIT_WORK(&mhi_cntrl->st_worker, mhi_pm_st_worker); - INIT_WORK(&mhi_cntrl->fw_worker, mhi_fw_load_worker); - INIT_WORK(&mhi_cntrl->syserr_worker, mhi_pm_sys_err_worker); - INIT_DELAYED_WORK(&mhi_cntrl->ready_worker, mhi_pm_ready_worker); - init_waitqueue_head(&mhi_cntrl->state_event); - - mhi_cmd = mhi_cntrl->mhi_cmd; - for (i = 0; i < NR_OF_CMD_RINGS; i++, mhi_cmd++) - spin_lock_init(&mhi_cmd->lock); - - mhi_event = mhi_cntrl->mhi_event; - for (i = 0; i < mhi_cntrl->total_ev_rings; i++, mhi_event++) { - if (mhi_event->offload_ev) - continue; - - mhi_event->mhi_cntrl = mhi_cntrl; - spin_lock_init(&mhi_event->lock); - if (mhi_event->data_type == MHI_ER_CTRL_ELEMENT_TYPE) - tasklet_init(&mhi_event->task, mhi_ctrl_ev_task, - (ulong)mhi_event); - else - tasklet_init(&mhi_event->task, mhi_ev_task, - (ulong)mhi_event); - } - - mhi_chan = mhi_cntrl->mhi_chan; - for (i = 0; i < mhi_cntrl->max_chan; i++, mhi_chan++) { - mutex_init(&mhi_chan->mutex); - init_completion(&mhi_chan->completion); - rwlock_init(&mhi_chan->lock); - } - - if (mhi_cntrl->bounce_buf) { - mhi_cntrl->map_single = mhi_map_single_use_bb; - mhi_cntrl->unmap_single = mhi_unmap_single_use_bb; - } else { - mhi_cntrl->map_single = mhi_map_single_no_bb; - mhi_cntrl->unmap_single = mhi_unmap_single_no_bb; - } - - /* register controller with mhi_bus */ - mhi_dev = mhi_alloc_device(mhi_cntrl); - if (!mhi_dev) { - ret = -ENOMEM; - goto error_alloc_dev; - } - - mhi_dev->dev_type = MHI_CONTROLLER_TYPE; - mhi_dev->mhi_cntrl = mhi_cntrl; - dev_set_name(&mhi_dev->dev, "%04x_%02u.%02u.%02u", mhi_dev->dev_id, - mhi_dev->domain, mhi_dev->bus, mhi_dev->slot); - - ret = device_add(&mhi_dev->dev); - if (ret) - goto error_add_dev; - - if (mhi_cntrl->cntrl_idx) - mhi_cntrl->cntrl_dev = device_create(mhi_cntrl_drv.class, mhi_cntrl->dev, - MKDEV(mhi_cntrl_drv.major, mhi_cntrl->cntrl_idx), NULL, - "mhi_BHI%d", mhi_cntrl->cntrl_idx); - else - mhi_cntrl->cntrl_dev = device_create(mhi_cntrl_drv.class, mhi_cntrl->dev, - MKDEV(mhi_cntrl_drv.major, mhi_cntrl->cntrl_idx), NULL, - "mhi_BHI"); - - mhi_cntrl->mhi_dev = mhi_dev; - - mhi_cntrl->parent = mhi_bus.dentry; - mhi_cntrl->klog_lvl = MHI_MSG_LVL_ERROR; - - /* adding it to this list only for debug purpose */ - mutex_lock(&mhi_bus.lock); - list_add_tail(&mhi_cntrl->node, &mhi_bus.controller_list); - mutex_unlock(&mhi_bus.lock); - - return 0; - -error_add_dev: - mhi_dealloc_device(mhi_cntrl, mhi_dev); - -error_alloc_dev: - kfree(mhi_cntrl->mhi_cmd); - -error_alloc_cmd: - kfree(mhi_cntrl->mhi_chan); - kfree(mhi_cntrl->mhi_event); - - return ret; -}; -EXPORT_SYMBOL(of_register_mhi_controller); - -void mhi_unregister_mhi_controller(struct mhi_controller *mhi_cntrl) -{ - struct mhi_device *mhi_dev = mhi_cntrl->mhi_dev; - - kfree(mhi_cntrl->mhi_cmd); - kfree(mhi_cntrl->mhi_event); - kfree(mhi_cntrl->mhi_chan); - kfree(mhi_cntrl->mhi_tsync); - - if (mhi_cntrl->cntrl_dev) - device_destroy(mhi_cntrl_drv.class, MKDEV(mhi_cntrl_drv.major, mhi_cntrl->cntrl_idx)); - device_del(&mhi_dev->dev); - put_device(&mhi_dev->dev); - - mutex_lock(&mhi_bus.lock); - list_del(&mhi_cntrl->node); - mutex_unlock(&mhi_bus.lock); -} - -/* set ptr to control private data */ -static inline void mhi_controller_set_devdata(struct mhi_controller *mhi_cntrl, - void *priv) -{ - mhi_cntrl->priv_data = priv; -} - - -/* allocate mhi controller to register */ -struct mhi_controller *mhi_alloc_controller(size_t size) -{ - struct mhi_controller *mhi_cntrl; - - mhi_cntrl = kzalloc(size + sizeof(*mhi_cntrl), GFP_KERNEL); - - if (mhi_cntrl && size) - mhi_controller_set_devdata(mhi_cntrl, mhi_cntrl + 1); - - return mhi_cntrl; -} -EXPORT_SYMBOL(mhi_alloc_controller); - -int mhi_prepare_for_power_up(struct mhi_controller *mhi_cntrl) -{ - int ret; - u32 bhie_off; - - mutex_lock(&mhi_cntrl->pm_mutex); - - ret = mhi_init_dev_ctxt(mhi_cntrl); - if (ret) { - MHI_ERR("Error with init dev_ctxt\n"); - goto error_dev_ctxt; - } - - ret = mhi_init_irq_setup(mhi_cntrl); - if (ret) { - MHI_ERR("Error setting up irq\n"); - goto error_setup_irq; - } - - /* - * allocate rddm table if specified, this table is for debug purpose - * so we'll ignore erros - */ - if (mhi_cntrl->rddm_size) { - mhi_alloc_bhie_table(mhi_cntrl, &mhi_cntrl->rddm_image, - mhi_cntrl->rddm_size); - - /* - * This controller supports rddm, we need to manually clear - * BHIE RX registers since por values are undefined. - */ - ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->regs, BHIEOFF, - &bhie_off); - if (ret) { - MHI_ERR("Error getting bhie offset\n"); - goto bhie_error; - } - - memset_io(mhi_cntrl->regs + bhie_off + BHIE_RXVECADDR_LOW_OFFS, - 0, BHIE_RXVECSTATUS_OFFS - BHIE_RXVECADDR_LOW_OFFS + - 4); - } - - mhi_cntrl->pre_init = true; - - mutex_unlock(&mhi_cntrl->pm_mutex); - - return 0; - -bhie_error: - if (mhi_cntrl->rddm_image) { - mhi_free_bhie_table(mhi_cntrl, mhi_cntrl->rddm_image); - mhi_cntrl->rddm_image = NULL; - } - mhi_deinit_free_irq(mhi_cntrl); - -error_setup_irq: - mhi_deinit_dev_ctxt(mhi_cntrl); - -error_dev_ctxt: - mutex_unlock(&mhi_cntrl->pm_mutex); - - return ret; -} -EXPORT_SYMBOL(mhi_prepare_for_power_up); - -void mhi_unprepare_after_power_down(struct mhi_controller *mhi_cntrl) -{ - if (mhi_cntrl->fbc_image) { - mhi_free_bhie_table(mhi_cntrl, mhi_cntrl->fbc_image); - mhi_cntrl->fbc_image = NULL; - } - - if (mhi_cntrl->rddm_image) { - mhi_free_bhie_table(mhi_cntrl, mhi_cntrl->rddm_image); - mhi_cntrl->rddm_image = NULL; - } - - mhi_deinit_free_irq(mhi_cntrl); - mhi_deinit_dev_ctxt(mhi_cntrl); - mhi_cntrl->pre_init = false; -} - -/* match dev to drv */ -static int mhi_match(struct device *dev, struct device_driver *drv) -{ - struct mhi_device *mhi_dev = to_mhi_device(dev); - struct mhi_driver *mhi_drv = to_mhi_driver(drv); - const struct mhi_device_id *id; - - /* if controller type there is no client driver associated with it */ - if (mhi_dev->dev_type == MHI_CONTROLLER_TYPE) - return 0; - - for (id = mhi_drv->id_table; id->chan[0]; id++) - if (!strcmp(mhi_dev->chan_name, id->chan)) { - mhi_dev->id = id; - return 1; - } - - return 0; -}; - -static void mhi_release_device(struct device *dev) -{ - struct mhi_device *mhi_dev = to_mhi_device(dev); - - if (mhi_dev->ul_chan) - mhi_dev->ul_chan->mhi_dev = NULL; - - if (mhi_dev->dl_chan) - mhi_dev->dl_chan->mhi_dev = NULL; - - kfree(mhi_dev); -} - -struct bus_type mhi_bus_type = { - .name = "mhi_q", - .dev_name = "mhi_q", - .match = mhi_match, -}; - -static int mhi_driver_probe(struct device *dev) -{ - struct mhi_device *mhi_dev = to_mhi_device(dev); - struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; - struct device_driver *drv = dev->driver; - struct mhi_driver *mhi_drv = to_mhi_driver(drv); - struct mhi_event *mhi_event; - struct mhi_chan *ul_chan = mhi_dev->ul_chan; - struct mhi_chan *dl_chan = mhi_dev->dl_chan; - bool auto_start = false; - int ret; - - /* bring device out of lpm */ - ret = mhi_device_get_sync(mhi_dev); - if (ret) - return ret; - - ret = -EINVAL; - if (ul_chan) { - /* lpm notification require status_cb */ - if (ul_chan->lpm_notify && !mhi_drv->status_cb) - goto exit_probe; - - if (!ul_chan->offload_ch && !mhi_drv->ul_xfer_cb) - goto exit_probe; - - ul_chan->xfer_cb = mhi_drv->ul_xfer_cb; - mhi_dev->status_cb = mhi_drv->status_cb; - auto_start = ul_chan->auto_start; - } - - if (dl_chan) { - if (dl_chan->lpm_notify && !mhi_drv->status_cb) - goto exit_probe; - - if (!dl_chan->offload_ch && !mhi_drv->dl_xfer_cb) - goto exit_probe; - - mhi_event = &mhi_cntrl->mhi_event[dl_chan->er_index]; - - /* - * if this channal event ring manage by client, then - * status_cb must be defined so we can send the async - * cb whenever there are pending data - */ - if (mhi_event->cl_manage && !mhi_drv->status_cb) - goto exit_probe; - - dl_chan->xfer_cb = mhi_drv->dl_xfer_cb; - - /* ul & dl uses same status cb */ - mhi_dev->status_cb = mhi_drv->status_cb; - auto_start = (auto_start || dl_chan->auto_start); - } - - ret = mhi_drv->probe(mhi_dev, mhi_dev->id); - - if (!ret && auto_start) - mhi_prepare_for_transfer(mhi_dev); - -exit_probe: - mhi_device_put(mhi_dev); - - return ret; -} - -static int mhi_driver_remove(struct device *dev) -{ - struct mhi_device *mhi_dev = to_mhi_device(dev); - struct mhi_driver *mhi_drv = to_mhi_driver(dev->driver); - struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; - struct mhi_chan *mhi_chan; - enum MHI_CH_STATE ch_state[] = { - MHI_CH_STATE_DISABLED, - MHI_CH_STATE_DISABLED - }; - int dir; - - /* control device has no work to do */ - if (mhi_dev->dev_type == MHI_CONTROLLER_TYPE) - return 0; - - MHI_LOG("Removing device for chan:%s\n", mhi_dev->chan_name); - - /* reset both channels */ - for (dir = 0; dir < 2; dir++) { - mhi_chan = dir ? mhi_dev->ul_chan : mhi_dev->dl_chan; - - if (!mhi_chan) - continue; - - /* wake all threads waiting for completion */ - write_lock_irq(&mhi_chan->lock); - mhi_chan->ccs = MHI_EV_CC_INVALID; - complete_all(&mhi_chan->completion); - write_unlock_irq(&mhi_chan->lock); - - /* move channel state to disable, no more processing */ - mutex_lock(&mhi_chan->mutex); - write_lock_irq(&mhi_chan->lock); - ch_state[dir] = mhi_chan->ch_state; - mhi_chan->ch_state = MHI_CH_STATE_SUSPENDED; - write_unlock_irq(&mhi_chan->lock); - - /* reset the channel */ - if (!mhi_chan->offload_ch) - mhi_reset_chan(mhi_cntrl, mhi_chan); - - mutex_unlock(&mhi_chan->mutex); - } - - /* destroy the device */ - mhi_drv->remove(mhi_dev); - - /* de_init channel if it was enabled */ - for (dir = 0; dir < 2; dir++) { - mhi_chan = dir ? mhi_dev->ul_chan : mhi_dev->dl_chan; - - if (!mhi_chan) - continue; - - mutex_lock(&mhi_chan->mutex); - - if (ch_state[dir] == MHI_CH_STATE_ENABLED && - !mhi_chan->offload_ch) - mhi_deinit_chan_ctxt(mhi_cntrl, mhi_chan); - - mhi_chan->ch_state = MHI_CH_STATE_DISABLED; - - mutex_unlock(&mhi_chan->mutex); - } - - - if (mhi_cntrl->tsync_dev == mhi_dev) - mhi_cntrl->tsync_dev = NULL; - - /* relinquish any pending votes */ - read_lock_bh(&mhi_cntrl->pm_lock); - while (atomic_read(&mhi_dev->dev_wake)) - mhi_device_put(mhi_dev); - read_unlock_bh(&mhi_cntrl->pm_lock); - - return 0; -} - -int mhi_driver_register(struct mhi_driver *mhi_drv) -{ - struct device_driver *driver = &mhi_drv->driver; - - if (!mhi_drv->probe || !mhi_drv->remove) - return -EINVAL; - - driver->bus = &mhi_bus_type; - driver->probe = mhi_driver_probe; - driver->remove = mhi_driver_remove; - return driver_register(driver); -} -EXPORT_SYMBOL(mhi_driver_register); - -void mhi_driver_unregister(struct mhi_driver *mhi_drv) -{ - driver_unregister(&mhi_drv->driver); -} -EXPORT_SYMBOL(mhi_driver_unregister); - -struct mhi_device *mhi_alloc_device(struct mhi_controller *mhi_cntrl) -{ - struct mhi_device *mhi_dev = kzalloc(sizeof(*mhi_dev), GFP_KERNEL); - struct device *dev; - - if (!mhi_dev) - return NULL; - - dev = &mhi_dev->dev; - device_initialize(dev); - dev->bus = &mhi_bus_type; - dev->release = mhi_release_device; - dev->parent = mhi_cntrl->dev; - mhi_dev->mhi_cntrl = mhi_cntrl; - mhi_dev->vendor = mhi_cntrl->vendor; - mhi_dev->dev_id = mhi_cntrl->dev_id; - mhi_dev->domain = mhi_cntrl->domain; - mhi_dev->bus = mhi_cntrl->bus; - mhi_dev->slot = mhi_cntrl->slot; - mhi_dev->mtu = MHI_MAX_MTU; - atomic_set(&mhi_dev->dev_wake, 0); - - return mhi_dev; -} - -static int mhi_cntrl_open(struct inode *inode, struct file *f) -{ - int ret = -ENODEV; - struct mhi_controller *mhi_cntrl; - - mutex_lock(&mhi_bus.lock); - list_for_each_entry(mhi_cntrl, &mhi_bus.controller_list, node) { - if (MINOR(inode->i_rdev) == mhi_cntrl->cntrl_idx) { - ret = 0; - f->private_data = mhi_cntrl; - break; - } - } - mutex_unlock(&mhi_bus.lock); - - return ret; -} - -static int mhi_cntrl_release(struct inode *inode, struct file *f) -{ - f->private_data = NULL; - return 0; -} - -#define IOCTL_BHI_GETDEVINFO 0x8BE0 + 1 -#define IOCTL_BHI_WRITEIMAGE 0x8BE0 + 2 -long bhi_get_dev_info(struct mhi_controller *mhi_cntrl, void __user *to); -long bhi_write_image(struct mhi_controller *mhi_cntrl, void __user *from); - -static long mhi_cntrl_ioctl(struct file *f, unsigned int cmd, unsigned long __arg) -{ - long ret = -ENODEV; - struct mhi_controller *mhi_cntrl; - - mutex_lock(&mhi_bus.lock); - list_for_each_entry(mhi_cntrl, &mhi_bus.controller_list, node) { - if (mhi_cntrl == (struct mhi_controller *)f->private_data) { - ret = 0; - break; - } - } - mutex_unlock(&mhi_bus.lock); - - if (ret) - return ret; - - switch (cmd) { - case IOCTL_BHI_GETDEVINFO: - ret = bhi_get_dev_info(mhi_cntrl, (void __user *)__arg); - break; - - case IOCTL_BHI_WRITEIMAGE: - ret = bhi_write_image(mhi_cntrl, (void __user *)__arg); - break; - - default: - ret = -EINVAL; - break; - } - - return ret; -} - -static const struct file_operations mhi_cntrl_fops = { - .unlocked_ioctl = mhi_cntrl_ioctl, - .open = mhi_cntrl_open, - .release = mhi_cntrl_release, -}; - -static int __init mhi_cntrl_init(void) -{ - int ret; - - ret = register_chrdev(0, MHI_CNTRL_DRIVER_NAME, &mhi_cntrl_fops); - if (ret < 0) - return ret; - - mhi_cntrl_drv.major = ret; -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 4, 0)) - mhi_cntrl_drv.class = class_create(MHI_CNTRL_DRIVER_NAME); -#else - mhi_cntrl_drv.class = class_create(THIS_MODULE, MHI_CNTRL_DRIVER_NAME); -#endif - if (IS_ERR(mhi_cntrl_drv.class)) { - unregister_chrdev(mhi_cntrl_drv.major, MHI_CNTRL_DRIVER_NAME); - return -ENODEV; - } - - mutex_init(&mhi_cntrl_drv.lock); - INIT_LIST_HEAD(&mhi_cntrl_drv.head); - - return 0; -} - -void mhi_cntrl_exit(void) -{ - class_destroy(mhi_cntrl_drv.class); - unregister_chrdev(mhi_cntrl_drv.major, MHI_CNTRL_DRIVER_NAME); -} - -extern int mhi_dtr_init(void); -extern void mhi_dtr_exit(void); -extern int mhi_device_netdev_init(struct dentry *parent); -extern void mhi_device_netdev_exit(void); -extern int mhi_device_uci_init(void); -extern void mhi_device_uci_exit(void); -extern int mhi_controller_qcom_init(void); -extern void mhi_controller_qcom_exit(void); - -static char mhi_version[] = "Quectel_Linux_PCIE_MHI_Driver_"PCIE_MHI_DRIVER_VERSION; -module_param_string(mhi_version, mhi_version, sizeof(mhi_version), S_IRUGO); - -static int __init mhi_init(void) -{ - int ret; - - pr_info("%s %s\n", __func__, mhi_version); - - mutex_init(&mhi_bus.lock); - INIT_LIST_HEAD(&mhi_bus.controller_list); - - /* parent directory */ - mhi_bus.dentry = debugfs_create_dir(mhi_bus_type.name, NULL); - - ret = bus_register(&mhi_bus_type); - if (ret) { - pr_err("Error bus_register ret:%d\n", ret); - return ret; - } - - ret = mhi_dtr_init(); - if (ret) { - pr_err("Error mhi_dtr_init ret:%d\n", ret); - bus_unregister(&mhi_bus_type); - return ret; - } - - ret = mhi_device_netdev_init(mhi_bus.dentry); - if (ret) { - pr_err("Error mhi_device_netdev_init ret:%d\n", ret); - } - - ret = mhi_device_uci_init(); - if (ret) { - pr_err("Error mhi_device_uci_init ret:%d\n", ret); - } - - ret = mhi_cntrl_init(); - if (ret) { - pr_err("Error mhi_cntrl_init ret:%d\n", ret); - } - - ret = mhi_controller_qcom_init(); - if (ret) { - pr_err("Error mhi_controller_qcom_init ret:%d\n", ret); - } - - return ret; -} - -static void mhi_exit(void) -{ - mhi_controller_qcom_exit(); - mhi_cntrl_exit(); - mhi_device_uci_exit(); - mhi_device_netdev_exit(); - mhi_dtr_exit(); - bus_unregister(&mhi_bus_type); - debugfs_remove_recursive(mhi_bus.dentry); -} - -module_init(mhi_init); -module_exit(mhi_exit); - -MODULE_LICENSE("GPL v2"); -MODULE_ALIAS("MHI_CORE"); -MODULE_DESCRIPTION("MHI Host Interface"); diff --git a/quectel_MHI/src/core/mhi_internal.h b/quectel_MHI/src/core/mhi_internal.h deleted file mode 100644 index 09f3aac..0000000 --- a/quectel_MHI/src/core/mhi_internal.h +++ /dev/null @@ -1,1190 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved. */ - -#ifndef _MHI_INT_H -#define _MHI_INT_H - -#include -#ifndef writel_relaxed -#define writel_relaxed writel -#endif - -#ifndef writel_relaxed_no_log -#define writel_relaxed_no_log writel_relaxed -#endif - -#ifndef readq -static inline u64 readq(void __iomem *reg) -{ - return ((u64) readl(reg)) | (((u64) readl(reg + 4UL)) << 32); -} -#endif - -#ifndef readq_relaxed -#define readq_relaxed readq -#endif - -#ifndef readq_relaxed_no_log -#define readq_relaxed_no_log readq_relaxed -#endif - -#ifndef U32_MAX -#define U32_MAX ((u32)~0U) -#endif - -#if (LINUX_VERSION_CODE < KERNEL_VERSION( 3,10,53 )) -static inline void reinit_completion(struct completion *x) -{ - x->done = 0; -} -#endif - -#ifndef __ATTR_RO -#define __ATTR_RO(_name) { \ - .attr = { .name = __stringify(_name), .mode = S_IRUGO }, \ - .show = _name##_show, \ -} -#endif -#ifndef __ATTR_WO -#define __ATTR_WO(_name) { \ - .attr = { .name = __stringify(_name), .mode = S_IWUSR }, \ - .store = _name##_store, \ -} -#endif -#ifndef __ATTR_RW -#define __ATTR_RW(_name) __ATTR(_name, (S_IWUSR | S_IRUGO), \ - _name##_show, _name##_store) -#endif -#ifndef DEVICE_ATTR_RO -#define DEVICE_ATTR_RO(_name) \ - struct device_attribute dev_attr_##_name = __ATTR_RO(_name) -#endif -#ifndef DEVICE_ATTR_WO -#define DEVICE_ATTR_WO(_name) \ - struct device_attribute dev_attr_##_name = __ATTR_WO(_name) -#endif -#ifndef DEVICE_ATTR_RW -#define DRIVER_ATTR_RW(_name) \ - struct driver_attribute driver_attr_##_name = __ATTR_RW(_name) -#endif - -#ifdef EXPORT_SYMBOL -#undef EXPORT_SYMBOL -#define EXPORT_SYMBOL(sym) -#endif - -extern struct bus_type mhi_bus_type; - -/* MHI mmio register mapping */ -#define PCI_INVALID_READ(val) (val == U32_MAX) - -#define MHIREGLEN (0x0) -#define MHIREGLEN_MHIREGLEN_MASK (0xFFFFFFFF) -#define MHIREGLEN_MHIREGLEN_SHIFT (0) - -#define MHIVER (0x8) -#define MHIVER_MHIVER_MASK (0xFFFFFFFF) -#define MHIVER_MHIVER_SHIFT (0) - -#define MHICFG (0x10) -#define MHICFG_NHWER_MASK (0xFF000000) -#define MHICFG_NHWER_SHIFT (24) -#define MHICFG_NER_MASK (0xFF0000) -#define MHICFG_NER_SHIFT (16) -#define MHICFG_NHWCH_MASK (0xFF00) -#define MHICFG_NHWCH_SHIFT (8) -#define MHICFG_NCH_MASK (0xFF) -#define MHICFG_NCH_SHIFT (0) - -#define CHDBOFF (0x18) -#define CHDBOFF_CHDBOFF_MASK (0xFFFFFFFF) -#define CHDBOFF_CHDBOFF_SHIFT (0) - -#define ERDBOFF (0x20) -#define ERDBOFF_ERDBOFF_MASK (0xFFFFFFFF) -#define ERDBOFF_ERDBOFF_SHIFT (0) - -#define BHIOFF (0x28) -#define BHIOFF_BHIOFF_MASK (0xFFFFFFFF) -#define BHIOFF_BHIOFF_SHIFT (0) - -#define BHIEOFF (0x2C) -#define BHIEOFF_BHIEOFF_MASK (0xFFFFFFFF) -#define BHIEOFF_BHIEOFF_SHIFT (0) - -#define DEBUGOFF (0x30) -#define DEBUGOFF_DEBUGOFF_MASK (0xFFFFFFFF) -#define DEBUGOFF_DEBUGOFF_SHIFT (0) - -#define MHICTRL (0x38) -#define MHICTRL_MHISTATE_MASK (0x0000FF00) -#define MHICTRL_MHISTATE_SHIFT (8) -#define MHICTRL_RESET_MASK (0x2) -#define MHICTRL_RESET_SHIFT (1) - -#define MHISTATUS (0x48) -#define MHISTATUS_MHISTATE_MASK (0x0000FF00) -#define MHISTATUS_MHISTATE_SHIFT (8) -#define MHISTATUS_SYSERR_MASK (0x4) -#define MHISTATUS_SYSERR_SHIFT (2) -#define MHISTATUS_READY_MASK (0x1) -#define MHISTATUS_READY_SHIFT (0) - -#define CCABAP_LOWER (0x58) -#define CCABAP_LOWER_CCABAP_LOWER_MASK (0xFFFFFFFF) -#define CCABAP_LOWER_CCABAP_LOWER_SHIFT (0) - -#define CCABAP_HIGHER (0x5C) -#define CCABAP_HIGHER_CCABAP_HIGHER_MASK (0xFFFFFFFF) -#define CCABAP_HIGHER_CCABAP_HIGHER_SHIFT (0) - -#define ECABAP_LOWER (0x60) -#define ECABAP_LOWER_ECABAP_LOWER_MASK (0xFFFFFFFF) -#define ECABAP_LOWER_ECABAP_LOWER_SHIFT (0) - -#define ECABAP_HIGHER (0x64) -#define ECABAP_HIGHER_ECABAP_HIGHER_MASK (0xFFFFFFFF) -#define ECABAP_HIGHER_ECABAP_HIGHER_SHIFT (0) - -#define CRCBAP_LOWER (0x68) -#define CRCBAP_LOWER_CRCBAP_LOWER_MASK (0xFFFFFFFF) -#define CRCBAP_LOWER_CRCBAP_LOWER_SHIFT (0) - -#define CRCBAP_HIGHER (0x6C) -#define CRCBAP_HIGHER_CRCBAP_HIGHER_MASK (0xFFFFFFFF) -#define CRCBAP_HIGHER_CRCBAP_HIGHER_SHIFT (0) - -#define CRDB_LOWER (0x70) -#define CRDB_LOWER_CRDB_LOWER_MASK (0xFFFFFFFF) -#define CRDB_LOWER_CRDB_LOWER_SHIFT (0) - -#define CRDB_HIGHER (0x74) -#define CRDB_HIGHER_CRDB_HIGHER_MASK (0xFFFFFFFF) -#define CRDB_HIGHER_CRDB_HIGHER_SHIFT (0) - -#define MHICTRLBASE_LOWER (0x80) -#define MHICTRLBASE_LOWER_MHICTRLBASE_LOWER_MASK (0xFFFFFFFF) -#define MHICTRLBASE_LOWER_MHICTRLBASE_LOWER_SHIFT (0) - -#define MHICTRLBASE_HIGHER (0x84) -#define MHICTRLBASE_HIGHER_MHICTRLBASE_HIGHER_MASK (0xFFFFFFFF) -#define MHICTRLBASE_HIGHER_MHICTRLBASE_HIGHER_SHIFT (0) - -#define MHICTRLLIMIT_LOWER (0x88) -#define MHICTRLLIMIT_LOWER_MHICTRLLIMIT_LOWER_MASK (0xFFFFFFFF) -#define MHICTRLLIMIT_LOWER_MHICTRLLIMIT_LOWER_SHIFT (0) - -#define MHICTRLLIMIT_HIGHER (0x8C) -#define MHICTRLLIMIT_HIGHER_MHICTRLLIMIT_HIGHER_MASK (0xFFFFFFFF) -#define MHICTRLLIMIT_HIGHER_MHICTRLLIMIT_HIGHER_SHIFT (0) - -#define MHIDATABASE_LOWER (0x98) -#define MHIDATABASE_LOWER_MHIDATABASE_LOWER_MASK (0xFFFFFFFF) -#define MHIDATABASE_LOWER_MHIDATABASE_LOWER_SHIFT (0) - -#define MHIDATABASE_HIGHER (0x9C) -#define MHIDATABASE_HIGHER_MHIDATABASE_HIGHER_MASK (0xFFFFFFFF) -#define MHIDATABASE_HIGHER_MHIDATABASE_HIGHER_SHIFT (0) - -#define MHIDATALIMIT_LOWER (0xA0) -#define MHIDATALIMIT_LOWER_MHIDATALIMIT_LOWER_MASK (0xFFFFFFFF) -#define MHIDATALIMIT_LOWER_MHIDATALIMIT_LOWER_SHIFT (0) - -#define MHIDATALIMIT_HIGHER (0xA4) -#define MHIDATALIMIT_HIGHER_MHIDATALIMIT_HIGHER_MASK (0xFFFFFFFF) -#define MHIDATALIMIT_HIGHER_MHIDATALIMIT_HIGHER_SHIFT (0) - -#define MHI_READ_REG_FIELD(_VAR,_REG,_FIELD) \ - ((_VAR & _REG ## _ ## _FIELD ## _MASK) >> _REG ## _ ## _FIELD ## _SHIFT) - -#define MHI_WRITE_REG_FIELD(_VAR,_REG,_FIELD,_VAL) \ - do { \ - _VAR &= ~_REG ## _ ## _FIELD ## _MASK; \ - _VAR |= (_VAL << _REG ## _ ## _FIELD ## _SHIFT); \ - } while(0) - -/* Host request register */ -#define MHI_SOC_RESET_REQ_OFFSET (0xB0) -#define MHI_SOC_RESET_REQ BIT(0) - -/* MHI misc capability registers */ -#define MISC_OFFSET (0x24) -#define MISC_CAP_MASK (0xFFFFFFFF) -#define MISC_CAP_SHIFT (0) - -#define CAP_CAPID_MASK (0xFF000000) -#define CAP_CAPID_SHIFT (24) -#define CAP_NEXT_CAP_MASK (0x00FFF000) -#define CAP_NEXT_CAP_SHIFT (12) - -/* MHI Timesync offsets */ -#define TIMESYNC_CFG_OFFSET (0x00) -#define TIMESYNC_CFG_CAPID_MASK (CAP_CAPID_MASK) -#define TIMESYNC_CFG_CAPID_SHIFT (CAP_CAPID_SHIFT) -#define TIMESYNC_CFG_NEXT_OFF_MASK (CAP_NEXT_CAP_MASK) -#define TIMESYNC_CFG_NEXT_OFF_SHIFT (CAP_NEXT_CAP_SHIFT) -#define TIMESYNC_CFG_NUMCMD_MASK (0xFF) -#define TIMESYNC_CFG_NUMCMD_SHIFT (0) -#define TIMESYNC_DB_OFFSET (0x4) -#define TIMESYNC_TIME_LOW_OFFSET (0x8) -#define TIMESYNC_TIME_HIGH_OFFSET (0xC) - -#define TIMESYNC_CAP_ID (2) - -/* MHI BHI offfsets */ -#define BHI_BHIVERSION_MINOR (0x00) -#define BHI_BHIVERSION_MAJOR (0x04) -#define BHI_IMGADDR_LOW (0x08) -#define BHI_IMGADDR_HIGH (0x0C) -#define BHI_IMGSIZE (0x10) -#define BHI_RSVD1 (0x14) -#define BHI_IMGTXDB (0x18) -#define BHI_TXDB_SEQNUM_BMSK (0x3FFFFFFF) -#define BHI_TXDB_SEQNUM_SHFT (0) -#define BHI_RSVD2 (0x1C) -#define BHI_INTVEC (0x20) -#define BHI_RSVD3 (0x24) -#define BHI_EXECENV (0x28) -#define BHI_STATUS (0x2C) -#define BHI_ERRCODE (0x30) -#define BHI_ERRDBG1 (0x34) -#define BHI_ERRDBG2 (0x38) -#define BHI_ERRDBG3 (0x3C) -#define BHI_SERIALNU (0x40) -#define BHI_SBLANTIROLLVER (0x44) -#define BHI_NUMSEG (0x48) -#define BHI_MSMHWID(n) (0x4C + (0x4 * n)) -#define BHI_OEMPKHASH(n) (0x64 + (0x4 * n)) -#define BHI_RSVD5 (0xC4) -#define BHI_STATUS_MASK (0xC0000000) -#define BHI_STATUS_SHIFT (30) -#define BHI_STATUS_ERROR (3) -#define BHI_STATUS_SUCCESS (2) -#define BHI_STATUS_RESET (0) - -/* MHI BHIE offsets */ -#define BHIE_MSMSOCID_OFFS (0x0000) -#define BHIE_TXVECADDR_LOW_OFFS (0x002C) -#define BHIE_TXVECADDR_HIGH_OFFS (0x0030) -#define BHIE_TXVECSIZE_OFFS (0x0034) -#define BHIE_TXVECDB_OFFS (0x003C) -#define BHIE_TXVECDB_SEQNUM_BMSK (0x3FFFFFFF) -#define BHIE_TXVECDB_SEQNUM_SHFT (0) -#define BHIE_TXVECSTATUS_OFFS (0x0044) -#define BHIE_TXVECSTATUS_SEQNUM_BMSK (0x3FFFFFFF) -#define BHIE_TXVECSTATUS_SEQNUM_SHFT (0) -#define BHIE_TXVECSTATUS_STATUS_BMSK (0xC0000000) -#define BHIE_TXVECSTATUS_STATUS_SHFT (30) -#define BHIE_TXVECSTATUS_STATUS_RESET (0x00) -#define BHIE_TXVECSTATUS_STATUS_XFER_COMPL (0x02) -#define BHIE_TXVECSTATUS_STATUS_ERROR (0x03) -#define BHIE_RXVECADDR_LOW_OFFS (0x0060) -#define BHIE_RXVECADDR_HIGH_OFFS (0x0064) -#define BHIE_RXVECSIZE_OFFS (0x0068) -#define BHIE_RXVECDB_OFFS (0x0070) -#define BHIE_RXVECDB_SEQNUM_BMSK (0x3FFFFFFF) -#define BHIE_RXVECDB_SEQNUM_SHFT (0) -#define BHIE_RXVECSTATUS_OFFS (0x0078) -#define BHIE_RXVECSTATUS_SEQNUM_BMSK (0x3FFFFFFF) -#define BHIE_RXVECSTATUS_SEQNUM_SHFT (0) -#define BHIE_RXVECSTATUS_STATUS_BMSK (0xC0000000) -#define BHIE_RXVECSTATUS_STATUS_SHFT (30) -#define BHIE_RXVECSTATUS_STATUS_RESET (0x00) -#define BHIE_RXVECSTATUS_STATUS_XFER_COMPL (0x02) -#define BHIE_RXVECSTATUS_STATUS_ERROR (0x03) - -/* convert ticks to micro seconds by dividing by 19.2 */ -#define TIME_TICKS_TO_US(x) (div_u64((x) * 10, 192)) - -struct mhi_event_ctxt { - u32 reserved : 8; - u32 intmodc : 8; - u32 intmodt : 16; - u32 ertype; - u32 msivec; - - u64 rbase __packed __aligned(4); - u64 rlen __packed __aligned(4); - u64 rp __packed __aligned(4); - u64 wp __packed __aligned(4); -}; - -struct mhi_chan_ctxt { - u32 chstate : 8; - u32 brstmode : 2; - u32 pollcfg : 6; - u32 reserved : 16; - u32 chtype; - u32 erindex; - - u64 rbase __packed __aligned(4); - u64 rlen __packed __aligned(4); - u64 rp __packed __aligned(4); - u64 wp __packed __aligned(4); -}; - -struct mhi_cmd_ctxt { - u32 reserved0; - u32 reserved1; - u32 reserved2; - - u64 rbase __packed __aligned(4); - u64 rlen __packed __aligned(4); - u64 rp __packed __aligned(4); - u64 wp __packed __aligned(4); -}; - -struct mhi_tre { - u64 ptr; - u32 dword[2]; -}; - -/* Channel context state */ -enum mhi_dev_ch_ctx_state { - MHI_DEV_CH_STATE_DISABLED, - MHI_DEV_CH_STATE_ENABLED, - MHI_DEV_CH_STATE_RUNNING, - MHI_DEV_CH_STATE_SUSPENDED, - MHI_DEV_CH_STATE_STOP, - MHI_DEV_CH_STATE_ERROR, - MHI_DEV_CH_STATE_RESERVED, - MHI_DEV_CH_STATE_32BIT = 0x7FFFFFFF -}; - -/* Channel type */ -enum mhi_dev_ch_ctx_type { - MHI_DEV_CH_TYPE_NONE, - MHI_DEV_CH_TYPE_OUTBOUND_CHANNEL, - MHI_DEV_CH_TYPE_INBOUND_CHANNEL, - MHI_DEV_CH_RESERVED -}; - -/* Channel context type */ -struct mhi_dev_ch_ctx { - enum mhi_dev_ch_ctx_state ch_state; - enum mhi_dev_ch_ctx_type ch_type; - uint32_t err_indx; - uint64_t rbase; - uint64_t rlen; - uint64_t rp; - uint64_t wp; -} __packed; - -enum mhi_dev_ring_element_type_id { - MHI_DEV_RING_EL_INVALID = 0, - MHI_DEV_RING_EL_NOOP = 1, - MHI_DEV_RING_EL_TRANSFER = 2, - MHI_DEV_RING_EL_RESET = 16, - MHI_DEV_RING_EL_STOP = 17, - MHI_DEV_RING_EL_START = 18, - MHI_DEV_RING_EL_MHI_STATE_CHG = 32, - MHI_DEV_RING_EL_CMD_COMPLETION_EVT = 33, - MHI_DEV_RING_EL_TRANSFER_COMPLETION_EVENT = 34, - MHI_DEV_RING_EL_EE_STATE_CHANGE_NOTIFY = 64, - MHI_DEV_RING_EL_UNDEF -}; - -enum mhi_dev_ring_state { - RING_STATE_UINT = 0, - RING_STATE_IDLE, - RING_STATE_PENDING, -}; - -enum mhi_dev_ring_type { - RING_TYPE_CMD = 0, - RING_TYPE_ER, - RING_TYPE_CH, - RING_TYPE_INVAL -}; - -/* Event context interrupt moderation */ -enum mhi_dev_evt_ctx_int_mod_timer { - MHI_DEV_EVT_INT_MODERATION_DISABLED -}; - -/* Event ring type */ -enum mhi_dev_evt_ctx_event_ring_type { - MHI_DEV_EVT_TYPE_DEFAULT, - MHI_DEV_EVT_TYPE_VALID, - MHI_DEV_EVT_RESERVED -}; - -/* Event ring context type */ -struct mhi_dev_ev_ctx { - uint32_t res1:16; - enum mhi_dev_evt_ctx_int_mod_timer intmodt:16; - enum mhi_dev_evt_ctx_event_ring_type ertype; - uint32_t msivec; - uint64_t rbase; - uint64_t rlen; - uint64_t rp; - uint64_t wp; -} __packed; - -/* Command context */ -struct mhi_dev_cmd_ctx { - uint32_t res1; - uint32_t res2; - uint32_t res3; - uint64_t rbase; - uint64_t rlen; - uint64_t rp; - uint64_t wp; -} __packed; - -/* generic context */ -struct mhi_dev_gen_ctx { - uint32_t res1; - uint32_t res2; - uint32_t res3; - uint64_t rbase; - uint64_t rlen; - uint64_t rp; - uint64_t wp; -} __packed; - -/* Transfer ring element */ -struct mhi_dev_transfer_ring_element { - uint64_t data_buf_ptr; - uint32_t len:16; - uint32_t res1:16; - uint32_t chain:1; - uint32_t res2:7; - uint32_t ieob:1; - uint32_t ieot:1; - uint32_t bei:1; - uint32_t res3:5; - enum mhi_dev_ring_element_type_id type:8; - uint32_t res4:8; -} __packed; - -/* Command ring element */ -/* Command ring No op command */ -struct mhi_dev_cmd_ring_op { - uint64_t res1; - uint32_t res2; - uint32_t res3:16; - enum mhi_dev_ring_element_type_id type:8; - uint32_t chid:8; -} __packed; - -/* Command ring reset channel command */ -struct mhi_dev_cmd_ring_reset_channel_cmd { - uint64_t res1; - uint32_t res2; - uint32_t res3:16; - enum mhi_dev_ring_element_type_id type:8; - uint32_t chid:8; -} __packed; - -/* Command ring stop channel command */ -struct mhi_dev_cmd_ring_stop_channel_cmd { - uint64_t res1; - uint32_t res2; - uint32_t res3:16; - enum mhi_dev_ring_element_type_id type:8; - uint32_t chid:8; -} __packed; - -/* Command ring start channel command */ -struct mhi_dev_cmd_ring_start_channel_cmd { - uint64_t res1; - uint32_t seqnum; - uint32_t reliable:1; - uint32_t res2:15; - enum mhi_dev_ring_element_type_id type:8; - uint32_t chid:8; -} __packed; - -enum mhi_dev_cmd_completion_code { - MHI_CMD_COMPL_CODE_INVALID = 0, - MHI_CMD_COMPL_CODE_SUCCESS = 1, - MHI_CMD_COMPL_CODE_EOT = 2, - MHI_CMD_COMPL_CODE_OVERFLOW = 3, - MHI_CMD_COMPL_CODE_EOB = 4, - MHI_CMD_COMPL_CODE_UNDEFINED = 16, - MHI_CMD_COMPL_CODE_RING_EL = 17, - MHI_CMD_COMPL_CODE_RES -}; - -/* Event ring elements */ -/* Transfer completion event */ -struct mhi_dev_event_ring_transfer_completion { - uint64_t ptr; - uint32_t len:16; - uint32_t res1:8; - enum mhi_dev_cmd_completion_code code:8; - uint32_t res2:16; - enum mhi_dev_ring_element_type_id type:8; - uint32_t chid:8; -} __packed; - -/* Command completion event */ -struct mhi_dev_event_ring_cmd_completion { - uint64_t ptr; - uint32_t res1:24; - enum mhi_dev_cmd_completion_code code:8; - uint32_t res2:16; - enum mhi_dev_ring_element_type_id type:8; - uint32_t res3:8; -} __packed; - -/* MHI state change event */ -struct mhi_dev_event_ring_state_change { - uint64_t ptr; - uint32_t res1:24; - uint32_t /*enum mhi_dev_state*/ mhistate:8; - uint32_t res2:16; - enum mhi_dev_ring_element_type_id type:8; - uint32_t res3:8; -} __packed; - -enum mhi_dev_execenv { - MHI_DEV_SBL_EE = 1, - MHI_DEV_AMSS_EE = 2, - MHI_DEV_UNRESERVED -}; - -/* EE state change event */ -struct mhi_dev_event_ring_ee_state_change { - uint64_t ptr; - uint32_t res1:24; - enum mhi_dev_execenv execenv:8; - uint32_t res2:16; - enum mhi_dev_ring_element_type_id type:8; - uint32_t res3:8; -} __packed; - -/* Generic cmd to parse common details like type and channel id */ -struct mhi_dev_ring_generic { - uint64_t ptr; - uint32_t res1:24; - uint32_t /*enum mhi_dev_state*/ mhistate:8; - uint32_t res2:16; - enum mhi_dev_ring_element_type_id type:8; - uint32_t chid:8; -} __packed; - -struct mhi_config { - uint32_t mhi_reg_len; - uint32_t version; - uint32_t event_rings; - uint32_t channels; - uint32_t chdb_offset; - uint32_t erdb_offset; -}; - -/* Possible ring element types */ -union mhi_dev_ring_element_type { - struct mhi_dev_cmd_ring_op cmd_no_op; - struct mhi_dev_cmd_ring_reset_channel_cmd cmd_reset; - struct mhi_dev_cmd_ring_stop_channel_cmd cmd_stop; - struct mhi_dev_cmd_ring_start_channel_cmd cmd_start; - struct mhi_dev_transfer_ring_element cmd_transfer; - struct mhi_dev_event_ring_transfer_completion evt_tr_comp; - struct mhi_dev_event_ring_cmd_completion evt_cmd_comp; - struct mhi_dev_event_ring_state_change evt_state_change; - struct mhi_dev_event_ring_ee_state_change evt_ee_state; - struct mhi_dev_ring_generic generic; -}; - -struct bhi_vec_entry { - u64 dma_addr; - u64 size; -}; - -enum mhi_cmd_type { - MHI_CMD_TYPE_NOP = 1, - MHI_CMD_TYPE_RESET = 16, - MHI_CMD_TYPE_STOP = 17, - MHI_CMD_TYPE_START = 18, - MHI_CMD_TYPE_TSYNC = 24, -}; - -/* no operation command */ -#define MHI_TRE_CMD_NOOP_PTR (0) -#define MHI_TRE_CMD_NOOP_DWORD0 (0) -#define MHI_TRE_CMD_NOOP_DWORD1 (MHI_CMD_TYPE_NOP << 16) - -/* channel reset command */ -#define MHI_TRE_CMD_RESET_PTR (0) -#define MHI_TRE_CMD_RESET_DWORD0 (0) -#define MHI_TRE_CMD_RESET_DWORD1(chid) ((chid << 24) | \ - (MHI_CMD_TYPE_RESET << 16)) - -/* channel stop command */ -#define MHI_TRE_CMD_STOP_PTR (0) -#define MHI_TRE_CMD_STOP_DWORD0 (0) -#define MHI_TRE_CMD_STOP_DWORD1(chid) ((chid << 24) | (MHI_CMD_TYPE_STOP << 16)) - -/* channel start command */ -#define MHI_TRE_CMD_START_PTR (0) -#define MHI_TRE_CMD_START_DWORD0 (0) -#define MHI_TRE_CMD_START_DWORD1(chid) ((chid << 24) | \ - (MHI_CMD_TYPE_START << 16)) - -/* time sync cfg command */ -#define MHI_TRE_CMD_TSYNC_CFG_PTR (0) -#define MHI_TRE_CMD_TSYNC_CFG_DWORD0 (0) -#define MHI_TRE_CMD_TSYNC_CFG_DWORD1(er) ((MHI_CMD_TYPE_TSYNC << 16) | \ - (er << 24)) - -#define MHI_TRE_GET_CMD_CHID(tre) (((tre)->dword[1] >> 24) & 0xFF) -#define MHI_TRE_GET_CMD_TYPE(tre) (((tre)->dword[1] >> 16) & 0xFF) - -/* event descriptor macros */ -#define MHI_TRE_EV_PTR(ptr) (ptr) -#define MHI_TRE_EV_DWORD0(code, len) ((code << 24) | len) -#define MHI_TRE_EV_DWORD1(chid, type) ((chid << 24) | (type << 16)) -#define MHI_TRE_GET_EV_PTR(tre) ((tre)->ptr) -#define MHI_TRE_GET_EV_CODE(tre) (((tre)->dword[0] >> 24) & 0xFF) -#define MHI_TRE_GET_EV_LEN(tre) ((tre)->dword[0] & 0xFFFF) -#define MHI_TRE_GET_EV_CHID(tre) (((tre)->dword[1] >> 24) & 0xFF) -#define MHI_TRE_GET_EV_TYPE(tre) (((tre)->dword[1] >> 16) & 0xFF) -#define MHI_TRE_GET_EV_STATE(tre) (((tre)->dword[0] >> 24) & 0xFF) -#define MHI_TRE_GET_EV_EXECENV(tre) (((tre)->dword[0] >> 24) & 0xFF) -#define MHI_TRE_GET_EV_SEQ(tre) ((tre)->dword[0]) -#define MHI_TRE_GET_EV_TIME(tre) ((tre)->ptr) -#define MHI_TRE_GET_EV_COOKIE(tre) lower_32_bits((tre)->ptr) -#define MHI_TRE_GET_EV_VEID(tre) (((tre)->dword[0] >> 16) & 0xFF) - -/* transfer descriptor macros */ -#define MHI_TRE_DATA_PTR(ptr) (ptr) -#define MHI_TRE_DATA_DWORD0(len) (len & MHI_MAX_MTU) -#define MHI_TRE_DATA_DWORD1(bei, ieot, ieob, chain) ((2 << 16) | (bei << 10) \ - | (ieot << 9) | (ieob << 8) | chain) - -/* rsc transfer descriptor macros */ -#define MHI_RSCTRE_DATA_PTR(ptr, len) (((u64)len << 48) | ptr) -#define MHI_RSCTRE_DATA_DWORD0(cookie) (cookie) -#define MHI_RSCTRE_DATA_DWORD1 (MHI_PKT_TYPE_COALESCING << 16) - -enum MHI_CMD { - MHI_CMD_RESET_CHAN, - MHI_CMD_START_CHAN, - MHI_CMD_TIMSYNC_CFG, -}; - -enum MHI_PKT_TYPE { - MHI_PKT_TYPE_INVALID = 0x0, - MHI_PKT_TYPE_NOOP_CMD = 0x1, - MHI_PKT_TYPE_TRANSFER = 0x2, - MHI_PKT_TYPE_COALESCING = 0x8, - MHI_PKT_TYPE_RESET_CHAN_CMD = 0x10, - MHI_PKT_TYPE_STOP_CHAN_CMD = 0x11, - MHI_PKT_TYPE_START_CHAN_CMD = 0x12, - MHI_PKT_TYPE_STATE_CHANGE_EVENT = 0x20, - MHI_PKT_TYPE_CMD_COMPLETION_EVENT = 0x21, - MHI_PKT_TYPE_TX_EVENT = 0x22, - MHI_PKT_TYPE_RSC_TX_EVENT = 0x28, - MHI_PKT_TYPE_EE_EVENT = 0x40, - MHI_PKT_TYPE_TSYNC_EVENT = 0x48, - MHI_PKT_TYPE_STALE_EVENT, /* internal event */ -}; - -/* MHI transfer completion events */ -enum MHI_EV_CCS { - MHI_EV_CC_INVALID = 0x0, - MHI_EV_CC_SUCCESS = 0x1, - MHI_EV_CC_EOT = 0x2, - MHI_EV_CC_OVERFLOW = 0x3, - MHI_EV_CC_EOB = 0x4, - MHI_EV_CC_OOB = 0x5, - MHI_EV_CC_DB_MODE = 0x6, - MHI_EV_CC_UNDEFINED_ERR = 0x10, - MHI_EV_CC_BAD_TRE = 0x11, -}; - -enum MHI_CH_STATE { - MHI_CH_STATE_DISABLED = 0x0, - MHI_CH_STATE_ENABLED = 0x1, - MHI_CH_STATE_RUNNING = 0x2, - MHI_CH_STATE_SUSPENDED = 0x3, - MHI_CH_STATE_STOP = 0x4, - MHI_CH_STATE_ERROR = 0x5, -}; - -enum MHI_BRSTMODE { - MHI_BRSTMODE_DISABLE = 0x2, - MHI_BRSTMODE_ENABLE = 0x3, -}; - -#define MHI_INVALID_BRSTMODE(mode) (mode != MHI_BRSTMODE_DISABLE && \ - mode != MHI_BRSTMODE_ENABLE) - -#define MHI_IN_PBL(ee) (ee == MHI_EE_PBL || ee == MHI_EE_PTHRU || \ - ee == MHI_EE_EDL) - -#define MHI_IN_MISSION_MODE(ee) (ee == MHI_EE_AMSS || ee == MHI_EE_WFW) - -enum MHI_ST_TRANSITION { - MHI_ST_TRANSITION_PBL, - MHI_ST_TRANSITION_READY, - MHI_ST_TRANSITION_SBL, - MHI_ST_TRANSITION_MISSION_MODE, - MHI_ST_TRANSITION_FP, - MHI_ST_TRANSITION_MAX, -}; - -extern const char * const mhi_state_tran_str[MHI_ST_TRANSITION_MAX]; -#define TO_MHI_STATE_TRANS_STR(state) (((state) >= MHI_ST_TRANSITION_MAX) ? \ - "INVALID_STATE" : mhi_state_tran_str[state]) - -extern const char * const mhi_state_str[MHI_STATE_MAX]; -#define TO_MHI_STATE_STR(state) ((state >= MHI_STATE_MAX || \ - !mhi_state_str[state]) ? \ - "INVALID_STATE" : mhi_state_str[state]) - -enum { - MHI_PM_BIT_DISABLE, - MHI_PM_BIT_POR, - MHI_PM_BIT_M0, - MHI_PM_BIT_M2, - MHI_PM_BIT_M3_ENTER, - MHI_PM_BIT_M3, - MHI_PM_BIT_M3_EXIT, - MHI_PM_BIT_FW_DL_ERR, - MHI_PM_BIT_SYS_ERR_DETECT, - MHI_PM_BIT_SYS_ERR_PROCESS, - MHI_PM_BIT_SHUTDOWN_PROCESS, - MHI_PM_BIT_LD_ERR_FATAL_DETECT, - MHI_PM_BIT_MAX -}; - -/* internal power states */ -enum MHI_PM_STATE { - MHI_PM_DISABLE = BIT(MHI_PM_BIT_DISABLE), /* MHI is not enabled */ - MHI_PM_POR = BIT(MHI_PM_BIT_POR), /* reset state */ - MHI_PM_M0 = BIT(MHI_PM_BIT_M0), - MHI_PM_M2 = BIT(MHI_PM_BIT_M2), - MHI_PM_M3_ENTER = BIT(MHI_PM_BIT_M3_ENTER), - MHI_PM_M3 = BIT(MHI_PM_BIT_M3), - MHI_PM_M3_EXIT = BIT(MHI_PM_BIT_M3_EXIT), - /* firmware download failure state */ - MHI_PM_FW_DL_ERR = BIT(MHI_PM_BIT_FW_DL_ERR), - MHI_PM_SYS_ERR_DETECT = BIT(MHI_PM_BIT_SYS_ERR_DETECT), - MHI_PM_SYS_ERR_PROCESS = BIT(MHI_PM_BIT_SYS_ERR_PROCESS), - MHI_PM_SHUTDOWN_PROCESS = BIT(MHI_PM_BIT_SHUTDOWN_PROCESS), - /* link not accessible */ - MHI_PM_LD_ERR_FATAL_DETECT = BIT(MHI_PM_BIT_LD_ERR_FATAL_DETECT), -}; - -#define MHI_REG_ACCESS_VALID(pm_state) ((pm_state & (MHI_PM_POR | MHI_PM_M0 | \ - MHI_PM_M2 | MHI_PM_M3_ENTER | MHI_PM_M3_EXIT | \ - MHI_PM_SYS_ERR_DETECT | MHI_PM_SYS_ERR_PROCESS | \ - MHI_PM_SHUTDOWN_PROCESS | MHI_PM_FW_DL_ERR))) -#define MHI_PM_IN_ERROR_STATE(pm_state) (pm_state >= MHI_PM_FW_DL_ERR) -#define MHI_PM_IN_FATAL_STATE(pm_state) (pm_state == MHI_PM_LD_ERR_FATAL_DETECT) -#define MHI_DB_ACCESS_VALID(pm_state) (pm_state & MHI_PM_M0) -#define MHI_WAKE_DB_CLEAR_VALID(pm_state) (pm_state & (MHI_PM_M0 | \ - MHI_PM_M2 | MHI_PM_M3_EXIT)) -#define MHI_WAKE_DB_SET_VALID(pm_state) (pm_state & MHI_PM_M2) -#define MHI_WAKE_DB_FORCE_SET_VALID(pm_state) MHI_WAKE_DB_CLEAR_VALID(pm_state) -#define MHI_EVENT_ACCESS_INVALID(pm_state) (pm_state == MHI_PM_DISABLE || \ - MHI_PM_IN_ERROR_STATE(pm_state)) -#define MHI_PM_IN_SUSPEND_STATE(pm_state) (pm_state & \ - (MHI_PM_M3_ENTER | MHI_PM_M3)) - -/* accepted buffer type for the channel */ -enum MHI_XFER_TYPE { - MHI_XFER_BUFFER, - MHI_XFER_SKB, - MHI_XFER_SCLIST, - MHI_XFER_NOP, /* CPU offload channel, host does not accept transfer */ - MHI_XFER_DMA, /* receive dma address, already mapped by client */ - MHI_XFER_RSC_DMA, /* RSC type, accept premapped buffer */ -}; - -#define NR_OF_CMD_RINGS (1) -#define CMD_EL_PER_RING (128) -#define PRIMARY_CMD_RING (0) -#define MHI_DEV_WAKE_DB (127) -#define MHI_MAX_MTU (0xffff) - -enum MHI_ER_TYPE { - MHI_ER_TYPE_INVALID = 0x0, - MHI_ER_TYPE_VALID = 0x1, -}; - -enum mhi_er_data_type { - MHI_ER_DATA_ELEMENT_TYPE, - MHI_ER_CTRL_ELEMENT_TYPE, - MHI_ER_TSYNC_ELEMENT_TYPE, - MHI_ER_DATA_TYPE_MAX = MHI_ER_TSYNC_ELEMENT_TYPE, -}; - -enum mhi_ch_ee_mask { - MHI_CH_EE_PBL = BIT(MHI_EE_PBL), - MHI_CH_EE_SBL = BIT(MHI_EE_SBL), - MHI_CH_EE_AMSS = BIT(MHI_EE_AMSS), - MHI_CH_EE_RDDM = BIT(MHI_EE_RDDM), - MHI_CH_EE_PTHRU = BIT(MHI_EE_PTHRU), - MHI_CH_EE_WFW = BIT(MHI_EE_WFW), - MHI_CH_EE_EDL = BIT(MHI_EE_EDL), -}; - -enum mhi_ch_type { - MHI_CH_TYPE_INVALID = 0, - MHI_CH_TYPE_OUTBOUND = DMA_TO_DEVICE, - MHI_CH_TYPE_INBOUND = DMA_FROM_DEVICE, - MHI_CH_TYPE_INBOUND_COALESCED = 3, -}; - -struct db_cfg { - bool reset_req; - bool db_mode; - u32 pollcfg; - enum MHI_BRSTMODE brstmode; - dma_addr_t db_val; - void (*process_db)(struct mhi_controller *mhi_cntrl, - struct db_cfg *db_cfg, void __iomem *io_addr, - dma_addr_t db_val); -}; - -struct mhi_pm_transitions { - enum MHI_PM_STATE from_state; - u32 to_states; -}; - -struct state_transition { - struct list_head node; - enum MHI_ST_TRANSITION state; -}; - -/* Control Segment */ -struct mhi_ctrl_seg -{ - struct mhi_tre hw_in_chan_ring[NUM_MHI_IPA_IN_RING_ELEMENTS] __packed __aligned(NUM_MHI_IPA_IN_RING_ELEMENTS*16); - struct mhi_tre hw_out_chan_ring[NUM_MHI_IPA_OUT_RING_ELEMENTS] __packed __aligned(NUM_MHI_IPA_OUT_RING_ELEMENTS*16); -#ifdef ENABLE_IP_SW0 - struct mhi_tre sw_in_chan_ring[NUM_MHI_SW_IP_RING_ELEMENTS] __packed __aligned(NUM_MHI_IPA_IN_RING_ELEMENTS*16); - struct mhi_tre sw_out_chan_ring[NUM_MHI_SW_IP_RING_ELEMENTS] __packed __aligned(NUM_MHI_IPA_OUT_RING_ELEMENTS*16); -#endif - -#ifdef ENABLE_ADPL - struct mhi_tre adpl_in_chan_ring[NUM_MHI_ADPL_RING_ELEMENTS] __packed __aligned(NUM_MHI_IPA_IN_RING_ELEMENTS*16); -#endif - -#ifdef ENABLE_QDSS - struct mhi_tre qdss_in_chan_ring[NUM_MHI_QDSS_RING_ELEMENTS] __packed __aligned(NUM_MHI_IPA_IN_RING_ELEMENTS*16); -#endif - - struct mhi_tre diag_in_chan_ring[NUM_MHI_DIAG_IN_RING_ELEMENTS] __packed __aligned(NUM_MHI_IPA_OUT_RING_ELEMENTS*16); - struct mhi_tre chan_ring[NUM_MHI_CHAN_RING_ELEMENTS*2*12] __packed __aligned(NUM_MHI_CHAN_RING_ELEMENTS*16); - struct mhi_tre event_ring[NUM_MHI_EVT_RINGS][NUM_MHI_EVT_RING_ELEMENTS] __packed __aligned(NUM_MHI_EVT_RING_ELEMENTS*16); - struct mhi_tre cmd_ring[NR_OF_CMD_RINGS][CMD_EL_PER_RING] __packed __aligned(CMD_EL_PER_RING*16); - - struct mhi_chan_ctxt chan_ctxt[NUM_MHI_XFER_RINGS] __aligned(128); - struct mhi_event_ctxt er_ctxt[NUM_MHI_EVT_RINGS] __aligned(128); - struct mhi_cmd_ctxt cmd_ctxt[NR_OF_CMD_RINGS] __aligned(128); -} __aligned(4096); - -struct mhi_ctxt { - struct mhi_event_ctxt *er_ctxt; - struct mhi_chan_ctxt *chan_ctxt; - struct mhi_cmd_ctxt *cmd_ctxt; - dma_addr_t er_ctxt_addr; - dma_addr_t chan_ctxt_addr; - dma_addr_t cmd_ctxt_addr; - struct mhi_ctrl_seg *ctrl_seg; - dma_addr_t ctrl_seg_addr; -}; - -struct mhi_ring { - dma_addr_t dma_handle; - dma_addr_t iommu_base; - u64 *ctxt_wp; /* point to ctxt wp */ - void *pre_aligned; - void *base; - void *rp; - void *wp; - size_t el_size; - size_t len; - size_t elements; - size_t alloc_size; - void __iomem *db_addr; -}; - -struct mhi_cmd { - struct mhi_ring ring; - spinlock_t lock; -}; - -struct mhi_buf_info { - dma_addr_t p_addr; - void *v_addr; - void *bb_addr; - void *wp; - size_t len; - void *cb_buf; - bool used; /* indicate element is free to use */ - bool pre_mapped; /* already pre-mapped by client */ - enum dma_data_direction dir; -}; - -struct mhi_event { - u32 er_index; - u32 intmod; - u32 msi; - int chan; /* this event ring is dedicated to a channel */ - u32 priority; - enum mhi_er_data_type data_type; - struct mhi_ring ring; - struct db_cfg db_cfg; - u32 used_elements; - bool hw_ring; - bool cl_manage; - bool offload_ev; /* managed by a device driver */ - spinlock_t lock; - struct mhi_chan *mhi_chan; /* dedicated to channel */ - struct tasklet_struct task; - int (*process_event)(struct mhi_controller *mhi_cntrl, - struct mhi_event *mhi_event, - u32 event_quota); - struct mhi_controller *mhi_cntrl; -}; - -struct mhi_chan { - u32 chan; - const char *name; - /* - * important, when consuming increment tre_ring first, when releasing - * decrement buf_ring first. If tre_ring has space, buf_ring - * guranteed to have space so we do not need to check both rings. - */ - struct mhi_ring buf_ring; - struct mhi_ring tre_ring; - - u32 used_elements; - u32 used_events[MHI_EV_CC_DB_MODE+1]; - - u32 er_index; - u32 intmod; - enum mhi_ch_type type; - enum dma_data_direction dir; - struct db_cfg db_cfg; - u32 ee_mask; - enum MHI_XFER_TYPE xfer_type; - enum MHI_CH_STATE ch_state; - enum MHI_EV_CCS ccs; - bool lpm_notify; - bool configured; - bool offload_ch; - bool pre_alloc; - bool auto_start; - bool wake_capable; /* channel should wake up system */ - /* functions that generate the transfer ring elements */ - int (*gen_tre)(struct mhi_controller *mhi_cntrl, - struct mhi_chan *mhi_chan, void *buf, void *cb, - size_t len, enum MHI_FLAGS flags); - int (*queue_xfer)(struct mhi_device *mhi_dev, - struct mhi_chan *mhi_chan, void *buf, - size_t len, enum MHI_FLAGS flags); - /* xfer call back */ - struct mhi_device *mhi_dev; - void (*xfer_cb)(struct mhi_device *mhi_dev, struct mhi_result *result); - struct mutex mutex; - struct completion completion; - rwlock_t lock; - u32 ring; - u32 tiocm; - struct list_head node; -}; - -struct tsync_node { - struct list_head node; - u32 sequence; - u64 local_time; - u64 remote_time; - struct mhi_device *mhi_dev; - void (*cb_func)(struct mhi_device *mhi_dev, u32 sequence, - u64 local_time, u64 remote_time); -}; - -struct mhi_timesync { - u32 er_index; - void __iomem *db; - void __iomem *time_reg; - enum MHI_EV_CCS ccs; - struct completion completion; - spinlock_t lock; /* list protection */ - struct mutex lpm_mutex; /* lpm protection */ - struct list_head head; -}; - -struct mhi_bus { - struct list_head controller_list; - struct mutex lock; - struct dentry *dentry; -}; - -/* default MHI timeout */ -#define MHI_TIMEOUT_MS (3000) -extern struct mhi_bus mhi_bus; - -/* debug fs related functions */ -int mhi_debugfs_mhi_chan_show(struct seq_file *m, void *d); -int mhi_debugfs_mhi_event_show(struct seq_file *m, void *d); -int mhi_debugfs_mhi_states_show(struct seq_file *m, void *d); -int mhi_debugfs_trigger_reset(void *data, u64 val); - -void mhi_deinit_debugfs(struct mhi_controller *mhi_cntrl); -void mhi_init_debugfs(struct mhi_controller *mhi_cntrl); - -/* power management apis */ -enum MHI_PM_STATE __must_check mhi_tryset_pm_state( - struct mhi_controller *mhi_cntrl, - enum MHI_PM_STATE state); -const char *to_mhi_pm_state_str(enum MHI_PM_STATE state); -void mhi_reset_chan(struct mhi_controller *mhi_cntrl, - struct mhi_chan *mhi_chan); -enum mhi_ee mhi_get_exec_env(struct mhi_controller *mhi_cntrl); -int mhi_queue_state_transition(struct mhi_controller *mhi_cntrl, - enum MHI_ST_TRANSITION state); -void mhi_pm_st_worker(struct work_struct *work); -void mhi_fw_load_worker(struct work_struct *work); -void mhi_pm_sys_err_worker(struct work_struct *work); -void mhi_pm_ready_worker(struct work_struct *work); -int mhi_ready_state_transition(struct mhi_controller *mhi_cntrl); -void mhi_ctrl_ev_task(unsigned long data); -int mhi_pm_m0_transition(struct mhi_controller *mhi_cntrl); -void mhi_pm_m1_transition(struct mhi_controller *mhi_cntrl); -int mhi_pm_m3_transition(struct mhi_controller *mhi_cntrl); -void mhi_notify(struct mhi_device *mhi_dev, enum MHI_CB cb_reason); -int mhi_process_data_event_ring(struct mhi_controller *mhi_cntrl, - struct mhi_event *mhi_event, u32 event_quota); -int mhi_process_ctrl_ev_ring(struct mhi_controller *mhi_cntrl, - struct mhi_event *mhi_event, u32 event_quota); -int mhi_process_tsync_event_ring(struct mhi_controller *mhi_cntrl, - struct mhi_event *mhi_event, u32 event_quota); -int mhi_send_cmd(struct mhi_controller *mhi_cntrl, struct mhi_chan *mhi_chan, - enum MHI_CMD cmd); -int __mhi_device_get_sync(struct mhi_controller *mhi_cntrl); - -/* queue transfer buffer */ -int mhi_gen_tre(struct mhi_controller *mhi_cntrl, struct mhi_chan *mhi_chan, - void *buf, void *cb, size_t buf_len, enum MHI_FLAGS flags); -int mhi_queue_buf(struct mhi_device *mhi_dev, struct mhi_chan *mhi_chan, - void *buf, size_t len, enum MHI_FLAGS mflags); -int mhi_queue_skb(struct mhi_device *mhi_dev, struct mhi_chan *mhi_chan, - void *buf, size_t len, enum MHI_FLAGS mflags); -int mhi_queue_sclist(struct mhi_device *mhi_dev, struct mhi_chan *mhi_chan, - void *buf, size_t len, enum MHI_FLAGS mflags); -int mhi_queue_nop(struct mhi_device *mhi_dev, struct mhi_chan *mhi_chan, - void *buf, size_t len, enum MHI_FLAGS mflags); -int mhi_queue_dma(struct mhi_device *mhi_dev, struct mhi_chan *mhi_chan, - void *buf, size_t len, enum MHI_FLAGS mflags); - -/* register access methods */ -void mhi_db_brstmode(struct mhi_controller *mhi_cntrl, struct db_cfg *db_cfg, - void __iomem *db_addr, dma_addr_t wp); -void mhi_db_brstmode_disable(struct mhi_controller *mhi_cntrl, - struct db_cfg *db_mode, void __iomem *db_addr, - dma_addr_t wp); -int __must_check mhi_read_reg(struct mhi_controller *mhi_cntrl, - void __iomem *base, u32 offset, u32 *out); -int __must_check mhi_read_reg_field(struct mhi_controller *mhi_cntrl, - void __iomem *base, u32 offset, u32 mask, - u32 shift, u32 *out); -void mhi_write_reg(struct mhi_controller *mhi_cntrl, void __iomem *base, - u32 offset, u32 val); -void mhi_write_reg_field(struct mhi_controller *mhi_cntrl, void __iomem *base, - u32 offset, u32 mask, u32 shift, u32 val); -void mhi_ring_er_db(struct mhi_event *mhi_event); -void mhi_write_db(struct mhi_controller *mhi_cntrl, void __iomem *db_addr, - dma_addr_t wp); -void mhi_ring_cmd_db(struct mhi_controller *mhi_cntrl, struct mhi_cmd *mhi_cmd); -void mhi_ring_chan_db(struct mhi_controller *mhi_cntrl, - struct mhi_chan *mhi_chan); -int mhi_get_capability_offset(struct mhi_controller *mhi_cntrl, u32 capability, - u32 *offset); -int mhi_init_timesync(struct mhi_controller *mhi_cntrl); -int mhi_create_timesync_sysfs(struct mhi_controller *mhi_cntrl); -void mhi_destroy_timesync(struct mhi_controller *mhi_cntrl); - -/* memory allocation methods */ -static inline void *mhi_alloc_coherent(struct mhi_controller *mhi_cntrl, - size_t size, - dma_addr_t *dma_handle, - gfp_t gfp) -{ -#if (LINUX_VERSION_CODE < KERNEL_VERSION( 5,0,0 )) - void *buf = dma_zalloc_coherent(mhi_cntrl->dev, size, dma_handle, gfp); -#else - void *buf = dma_alloc_coherent(mhi_cntrl->dev, size, dma_handle, gfp | __GFP_ZERO); -#endif - - MHI_LOG("size = %zd, dma_handle = %llx\n", size, (u64)*dma_handle); - if (buf) - atomic_add(size, &mhi_cntrl->alloc_size); - - return buf; -} -static inline void mhi_free_coherent(struct mhi_controller *mhi_cntrl, - size_t size, - void *vaddr, - dma_addr_t dma_handle) -{ - atomic_sub(size, &mhi_cntrl->alloc_size); - dma_free_coherent(mhi_cntrl->dev, size, vaddr, dma_handle); -} -struct mhi_device *mhi_alloc_device(struct mhi_controller *mhi_cntrl); -static inline void mhi_dealloc_device(struct mhi_controller *mhi_cntrl, - struct mhi_device *mhi_dev) -{ - kfree(mhi_dev); -} -int mhi_destroy_device(struct device *dev, void *data); -void mhi_create_devices(struct mhi_controller *mhi_cntrl); -int mhi_alloc_bhie_table(struct mhi_controller *mhi_cntrl, - struct image_info **image_info, size_t alloc_size); -void mhi_free_bhie_table(struct mhi_controller *mhi_cntrl, - struct image_info *image_info); - -int mhi_map_single_no_bb(struct mhi_controller *mhi_cntrl, - struct mhi_buf_info *buf_info); -int mhi_map_single_use_bb(struct mhi_controller *mhi_cntrl, - struct mhi_buf_info *buf_info); -void mhi_unmap_single_no_bb(struct mhi_controller *mhi_cntrl, - struct mhi_buf_info *buf_info); -void mhi_unmap_single_use_bb(struct mhi_controller *mhi_cntrl, - struct mhi_buf_info *buf_info); - -/* initialization methods */ -int mhi_init_chan_ctxt(struct mhi_controller *mhi_cntrl, - struct mhi_chan *mhi_chan); -void mhi_deinit_chan_ctxt(struct mhi_controller *mhi_cntrl, - struct mhi_chan *mhi_chan); -int mhi_init_mmio(struct mhi_controller *mhi_cntrl); -int mhi_init_dev_ctxt(struct mhi_controller *mhi_cntrl); -void mhi_deinit_dev_ctxt(struct mhi_controller *mhi_cntrl); -int mhi_init_irq_setup(struct mhi_controller *mhi_cntrl); -void mhi_deinit_free_irq(struct mhi_controller *mhi_cntrl); -int mhi_dtr_init(void); - -/* isr handlers */ -irqreturn_t mhi_one_msi_handlr(int irq_number, void *dev); -irqreturn_t mhi_msi_handlr(int irq_number, void *dev); -irqreturn_t mhi_intvec_threaded_handlr(int irq_number, void *dev); -irqreturn_t mhi_intvec_handlr(int irq_number, void *dev); -void mhi_ev_task(unsigned long data); - -#ifdef CONFIG_MHI_DEBUG - -#define MHI_ASSERT(cond, msg) do { \ - if (cond) \ - panic(msg); \ -} while (0) - -#else - -#define MHI_ASSERT(cond, msg) do { \ - if (cond) { \ - MHI_ERR(msg); \ - WARN_ON(cond); \ - } \ -} while (0) - -#endif - -#endif /* _MHI_INT_H */ diff --git a/quectel_MHI/src/core/mhi_main.c b/quectel_MHI/src/core/mhi_main.c deleted file mode 100644 index 12d44e6..0000000 --- a/quectel_MHI/src/core/mhi_main.c +++ /dev/null @@ -1,2722 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved. */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "mhi.h" -#include "mhi_internal.h" - -static void __mhi_unprepare_channel(struct mhi_controller *mhi_cntrl, - struct mhi_chan *mhi_chan); - -int __must_check mhi_read_reg(struct mhi_controller *mhi_cntrl, - void __iomem *base, - u32 offset, - u32 *out) -{ - u32 tmp = readl_relaxed(base + offset); - - /* unexpected value, query the link status */ - if (PCI_INVALID_READ(tmp) && - mhi_cntrl->link_status(mhi_cntrl, mhi_cntrl->priv_data)) - return -EIO; - - *out = tmp; - - return 0; -} - -int __must_check mhi_read_reg_field(struct mhi_controller *mhi_cntrl, - void __iomem *base, - u32 offset, - u32 mask, - u32 shift, - u32 *out) -{ - u32 tmp; - int ret; - - ret = mhi_read_reg(mhi_cntrl, base, offset, &tmp); - if (ret) - return ret; - - *out = (tmp & mask) >> shift; - - return 0; -} - -int mhi_get_capability_offset(struct mhi_controller *mhi_cntrl, - u32 capability, - u32 *offset) -{ - u32 cur_cap, next_offset; - int ret; - - /* get the 1st supported capability offset */ - ret = mhi_read_reg_field(mhi_cntrl, mhi_cntrl->regs, MISC_OFFSET, - MISC_CAP_MASK, MISC_CAP_SHIFT, offset); - if (ret) - return ret; - if (*offset >= 0x1000) - return -ENXIO; - do { - ret = mhi_read_reg_field(mhi_cntrl, mhi_cntrl->regs, *offset, - CAP_CAPID_MASK, CAP_CAPID_SHIFT, - &cur_cap); - if (ret) - return ret; - - if (cur_cap == capability) - return 0; - - ret = mhi_read_reg_field(mhi_cntrl, mhi_cntrl->regs, *offset, - CAP_NEXT_CAP_MASK, CAP_NEXT_CAP_SHIFT, - &next_offset); - if (ret) - return ret; - - *offset += next_offset; - } while (next_offset); - - return -ENXIO; -} - -void mhi_write_reg(struct mhi_controller *mhi_cntrl, - void __iomem *base, - u32 offset, - u32 val) -{ - writel_relaxed(val, base + offset); -} - -void mhi_write_reg_field(struct mhi_controller *mhi_cntrl, - void __iomem *base, - u32 offset, - u32 mask, - u32 shift, - u32 val) -{ - int ret; - u32 tmp; - - ret = mhi_read_reg(mhi_cntrl, base, offset, &tmp); - if (ret) - return; - - tmp &= ~mask; - tmp |= (val << shift); - mhi_write_reg(mhi_cntrl, base, offset, tmp); -} - -void mhi_write_db(struct mhi_controller *mhi_cntrl, - void __iomem *db_addr, - dma_addr_t wp) -{ - mhi_write_reg(mhi_cntrl, db_addr, 4, upper_32_bits(wp)); - mhi_write_reg(mhi_cntrl, db_addr, 0, lower_32_bits(wp)); -#if 0 //carl.yin 20190527 for debug - if ((lower_32_bits(db_addr)&0xFFF) != 0x620) - { - u32 out = 0; - int ret = mhi_read_reg(mhi_cntrl, db_addr, 0, &out); - if (out != lower_32_bits(wp)) - MHI_ERR("%s db=%x, wp=w:%x - r:%x, ret=%d\n", __func__, lower_32_bits(db_addr), lower_32_bits(wp), out, ret); - } -#endif -} - -void mhi_db_brstmode(struct mhi_controller *mhi_cntrl, - struct db_cfg *db_cfg, - void __iomem *db_addr, - dma_addr_t wp) -{ - if (db_cfg->db_mode) { - db_cfg->db_val = wp; - mhi_write_db(mhi_cntrl, db_addr, wp); - db_cfg->db_mode = false; - } -} - -void mhi_db_brstmode_disable(struct mhi_controller *mhi_cntrl, - struct db_cfg *db_cfg, - void __iomem *db_addr, - dma_addr_t wp) -{ - db_cfg->db_val = wp; - mhi_write_db(mhi_cntrl, db_addr, wp); -} - -void mhi_ring_er_db(struct mhi_event *mhi_event) -{ - struct mhi_ring *ring = &mhi_event->ring; - - mhi_event->db_cfg.process_db(mhi_event->mhi_cntrl, &mhi_event->db_cfg, - ring->db_addr, *ring->ctxt_wp); -} - -void mhi_ring_cmd_db(struct mhi_controller *mhi_cntrl, struct mhi_cmd *mhi_cmd) -{ - dma_addr_t db; - struct mhi_ring *ring = &mhi_cmd->ring; - - db = ring->iommu_base + (ring->wp - ring->base); - *ring->ctxt_wp = db; - mhi_write_db(mhi_cntrl, ring->db_addr, db); -} - -//#define DEBUG_CHAN100_DB -#ifdef DEBUG_CHAN100_DB -static atomic_t chan100_seq = ATOMIC_INIT(0); -#define CHAN100_SIZE 0x1000 -static unsigned int chan100_t[CHAN100_SIZE]; -#endif - -void mhi_ring_chan_db(struct mhi_controller *mhi_cntrl, - struct mhi_chan *mhi_chan) -{ - struct mhi_ring *ring = &mhi_chan->tre_ring; - dma_addr_t db; - - db = ring->iommu_base + (ring->wp - ring->base); - /* - * Writes to the new ring element must be visible to the hardware - * before letting h/w know there is new element to fetch. - */ - dma_wmb(); - *ring->ctxt_wp = db; - mhi_chan->db_cfg.process_db(mhi_cntrl, &mhi_chan->db_cfg, ring->db_addr, - db); -} - -enum mhi_ee mhi_get_exec_env(struct mhi_controller *mhi_cntrl) -{ - u32 exec; - int ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->bhi, BHI_EXECENV, &exec); - - return (ret) ? MHI_EE_MAX : exec; -} - -enum mhi_dev_state mhi_get_mhi_state(struct mhi_controller *mhi_cntrl) -{ - u32 state; - int ret = mhi_read_reg_field(mhi_cntrl, mhi_cntrl->regs, MHISTATUS, - MHISTATUS_MHISTATE_MASK, - MHISTATUS_MHISTATE_SHIFT, &state); - return ret ? MHI_STATE_MAX : state; -} - -int mhi_queue_sclist(struct mhi_device *mhi_dev, - struct mhi_chan *mhi_chan, - void *buf, - size_t len, - enum MHI_FLAGS mflags) -{ - return -EINVAL; -} - -int mhi_queue_nop(struct mhi_device *mhi_dev, - struct mhi_chan *mhi_chan, - void *buf, - size_t len, - enum MHI_FLAGS mflags) -{ - return -EINVAL; -} - -static void mhi_add_ring_element(struct mhi_controller *mhi_cntrl, - struct mhi_ring *ring) -{ - void *wp = ring->wp; - wp += ring->el_size; - if (wp >= (ring->base + ring->len)) - wp = ring->base; - ring->wp = wp; - /* smp update */ - smp_wmb(); -} - -static void mhi_del_ring_element(struct mhi_controller *mhi_cntrl, - struct mhi_ring *ring) -{ - void *rp = ring->rp; - rp += ring->el_size; - if (rp >= (ring->base + ring->len)) - rp = ring->base; - ring->rp = rp; - /* smp update */ - smp_wmb(); -} - -static int get_nr_avail_ring_elements(struct mhi_controller *mhi_cntrl, - struct mhi_ring *ring) -{ - int nr_el; - - if (ring->wp < ring->rp) - nr_el = ((ring->rp - ring->wp) / ring->el_size) - 1; - else { - nr_el = (ring->rp - ring->base) / ring->el_size; - nr_el += ((ring->base + ring->len - ring->wp) / - ring->el_size) - 1; - } - return nr_el; -} - -static u32 get_used_ring_elements(void *rp, void *wp, u32 el_num) -{ - u32 nr_el; - - if (wp >= rp) - nr_el = (wp - rp)/sizeof(struct mhi_tre); - else { - nr_el = (rp - wp)/sizeof(struct mhi_tre); - nr_el = el_num - nr_el; - } - return nr_el; -} - -static void *mhi_to_virtual(struct mhi_ring *ring, dma_addr_t addr) -{ - return (addr - ring->iommu_base) + ring->base; -} - -dma_addr_t mhi_to_physical(struct mhi_ring *ring, void *addr) -{ - return (addr - ring->base) + ring->iommu_base; -} - -static void mhi_recycle_ev_ring_element(struct mhi_controller *mhi_cntrl, - struct mhi_ring *ring) -{ - void *rp, *wp; - - /* update the WP */ - wp = ring->wp; - wp += ring->el_size; - if (wp >= (ring->base + ring->len)) { - wp = ring->base; - } - ring->wp = wp; - - *ring->ctxt_wp = ring->iommu_base + (ring->wp - ring->base); - - /* update the RP */ - rp = ring->rp; - rp += ring->el_size; - if (rp >= (ring->base + ring->len)) - rp = ring->base; - ring->rp = rp; - - /* visible to other cores */ - smp_wmb(); -} - -static bool mhi_is_ring_full(struct mhi_controller *mhi_cntrl, - struct mhi_ring *ring) -{ - void *tmp = ring->wp + ring->el_size; - - if (tmp >= (ring->base + ring->len)) - tmp = ring->base; - - return (tmp == ring->rp); -} - -int mhi_map_single_no_bb(struct mhi_controller *mhi_cntrl, - struct mhi_buf_info *buf_info) -{ - buf_info->p_addr = dma_map_single(mhi_cntrl->dev, buf_info->v_addr, - buf_info->len, buf_info->dir); - if (dma_mapping_error(mhi_cntrl->dev, buf_info->p_addr)) - return -ENOMEM; - - return 0; -} - -int mhi_map_single_use_bb(struct mhi_controller *mhi_cntrl, - struct mhi_buf_info *buf_info) -{ - void *buf = mhi_alloc_coherent(mhi_cntrl, buf_info->len, - &buf_info->p_addr, GFP_ATOMIC); - - if (!buf) - return -ENOMEM; - - if (buf_info->dir == DMA_TO_DEVICE) - memcpy(buf, buf_info->v_addr, buf_info->len); - - buf_info->bb_addr = buf; - - return 0; -} - -void mhi_unmap_single_no_bb(struct mhi_controller *mhi_cntrl, - struct mhi_buf_info *buf_info) -{ - dma_unmap_single(mhi_cntrl->dev, buf_info->p_addr, buf_info->len, - buf_info->dir); -} - -void mhi_unmap_single_use_bb(struct mhi_controller *mhi_cntrl, - struct mhi_buf_info *buf_info) -{ - if (buf_info->dir == DMA_FROM_DEVICE) - memcpy(buf_info->v_addr, buf_info->bb_addr, buf_info->len); - - mhi_free_coherent(mhi_cntrl, buf_info->len, buf_info->bb_addr, - buf_info->p_addr); -} - -#ifdef ENABLE_MHI_MON -static void mon_bus_submit(struct mhi_controller *mbus, u32 chan, dma_addr_t wp, struct mhi_tre *mhi_tre, void *buf, size_t len) -{ - unsigned long flags; - struct list_head *pos; - struct mon_reader *r; - - spin_lock_irqsave(&mbus->lock, flags); - mbus->cnt_events++; - list_for_each (pos, &mbus->r_list) { - r = list_entry(pos, struct mon_reader, r_link); - r->rnf_submit(r->r_data, chan, wp, mhi_tre, buf, len); - } - spin_unlock_irqrestore(&mbus->lock, flags); -} - -static void mon_bus_receive(struct mhi_controller *mbus, u32 chan, dma_addr_t wp, struct mhi_tre *mhi_tre, void *buf, size_t len) -{ - unsigned long flags; - struct list_head *pos; - struct mon_reader *r; - - spin_lock_irqsave(&mbus->lock, flags); - mbus->cnt_events++; - list_for_each (pos, &mbus->r_list) { - r = list_entry(pos, struct mon_reader, r_link); - r->rnf_receive(r->r_data, chan, wp, mhi_tre, buf, len); - } - spin_unlock_irqrestore(&mbus->lock, flags); -} - -static void mon_bus_complete(struct mhi_controller *mbus, u32 chan, dma_addr_t wp, struct mhi_tre *mhi_tre) -{ - unsigned long flags; - struct list_head *pos; - struct mon_reader *r; - - spin_lock_irqsave(&mbus->lock, flags); - mbus->cnt_events++; - list_for_each (pos, &mbus->r_list) { - r = list_entry(pos, struct mon_reader, r_link); - r->rnf_complete(r->r_data, chan, wp, mhi_tre); - } - spin_unlock_irqrestore(&mbus->lock, flags); -} -#endif - -int mhi_queue_skb(struct mhi_device *mhi_dev, - struct mhi_chan *mhi_chan, - void *buf, - size_t len, - enum MHI_FLAGS mflags) -{ - struct sk_buff *skb = buf; - struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; - struct mhi_ring *tre_ring = &mhi_chan->tre_ring; - struct mhi_ring *buf_ring = &mhi_chan->buf_ring; - struct mhi_buf_info *buf_info; - struct mhi_tre *mhi_tre; - bool assert_wake = false; - int ret; - - if (mhi_is_ring_full(mhi_cntrl, tre_ring)) - return -ENOMEM; - - read_lock_bh(&mhi_cntrl->pm_lock); - if (unlikely(MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state))) { - MHI_VERB("MHI is not in activate state, pm_state:%s\n", - to_mhi_pm_state_str(mhi_cntrl->pm_state)); - read_unlock_bh(&mhi_cntrl->pm_lock); - - return -EIO; - } - - /* we're in M3 or transitioning to M3 */ - if (MHI_PM_IN_SUSPEND_STATE(mhi_cntrl->pm_state)) { - mhi_cntrl->runtime_get(mhi_cntrl, mhi_cntrl->priv_data); - mhi_cntrl->runtime_put(mhi_cntrl, mhi_cntrl->priv_data); - } - - /* - * For UL channels always assert WAKE until work is done, - * For DL channels only assert if MHI is in a LPM - */ - if (mhi_chan->dir == DMA_TO_DEVICE || - (mhi_chan->dir == DMA_FROM_DEVICE && - mhi_cntrl->pm_state != MHI_PM_M0)) { - assert_wake = true; - mhi_cntrl->wake_get(mhi_cntrl, false); - } - - /* generate the tre */ - buf_info = buf_ring->wp; - buf_info->v_addr = skb->data; - buf_info->cb_buf = skb; - buf_info->wp = tre_ring->wp; - buf_info->dir = mhi_chan->dir; - buf_info->len = len; - ret = mhi_cntrl->map_single(mhi_cntrl, buf_info); - if (ret) - goto map_error; - - mhi_tre = tre_ring->wp; - - mhi_tre->ptr = MHI_TRE_DATA_PTR(buf_info->p_addr); - mhi_tre->dword[0] = MHI_TRE_DATA_DWORD0(buf_info->len); - mhi_tre->dword[1] = MHI_TRE_DATA_DWORD1(1, 1, 0, 0); - -#ifdef ENABLE_MHI_MON - if (mhi_cntrl->nreaders) { - mon_bus_submit(mhi_cntrl, mhi_chan->chan, - mhi_to_physical(tre_ring, mhi_tre), mhi_tre, buf_info->v_addr, mhi_chan->chan&0x1 ? 0 : buf_info->len); - } -#endif - - MHI_VERB("chan:%d WP:0x%llx TRE:0x%llx 0x%08x 0x%08x\n", mhi_chan->chan, - (u64)mhi_to_physical(tre_ring, mhi_tre), mhi_tre->ptr, - mhi_tre->dword[0], mhi_tre->dword[1]); - - if (mhi_chan->dir == DMA_TO_DEVICE) { - if (atomic_inc_return(&mhi_cntrl->pending_pkts) == 1) - mhi_cntrl->runtime_get(mhi_cntrl, mhi_cntrl->priv_data); - } - - read_lock_bh(&mhi_chan->lock); - /* increment WP */ - mhi_add_ring_element(mhi_cntrl, tre_ring); - mhi_add_ring_element(mhi_cntrl, buf_ring); - -#ifdef DEBUG_CHAN100_DB - if (mhi_chan->chan == 100) { - chan100_t[atomic_inc_return(&chan100_seq)&(CHAN100_SIZE-1)] = (((unsigned long)tre_ring->wp)&0xffff) | (mhi_chan->db_cfg.db_mode<<31) | (0<<30); - } -#endif - if (likely(MHI_DB_ACCESS_VALID(mhi_cntrl->pm_state))) { - mhi_ring_chan_db(mhi_cntrl, mhi_chan); - } - read_unlock_bh(&mhi_chan->lock); - - if (mhi_chan->dir == DMA_FROM_DEVICE && assert_wake) - mhi_cntrl->wake_put(mhi_cntrl, true); - - read_unlock_bh(&mhi_cntrl->pm_lock); - - return 0; - -map_error: - if (assert_wake) - mhi_cntrl->wake_put(mhi_cntrl, false); - - read_unlock_bh(&mhi_cntrl->pm_lock); - - return ret; -} - -int mhi_queue_dma(struct mhi_device *mhi_dev, - struct mhi_chan *mhi_chan, - void *buf, - size_t len, - enum MHI_FLAGS mflags) -{ - struct mhi_buf *mhi_buf = buf; - struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; - struct mhi_ring *tre_ring = &mhi_chan->tre_ring; - struct mhi_ring *buf_ring = &mhi_chan->buf_ring; - struct mhi_buf_info *buf_info; - struct mhi_tre *mhi_tre; - bool assert_wake = false; - - if (mhi_is_ring_full(mhi_cntrl, tre_ring)) - return -ENOMEM; - - read_lock_bh(&mhi_cntrl->pm_lock); - if (unlikely(MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state))) { - MHI_VERB("MHI is not in activate state, pm_state:%s\n", - to_mhi_pm_state_str(mhi_cntrl->pm_state)); - read_unlock_bh(&mhi_cntrl->pm_lock); - - return -EIO; - } - - /* we're in M3 or transitioning to M3 */ - if (MHI_PM_IN_SUSPEND_STATE(mhi_cntrl->pm_state)) { - mhi_cntrl->runtime_get(mhi_cntrl, mhi_cntrl->priv_data); - mhi_cntrl->runtime_put(mhi_cntrl, mhi_cntrl->priv_data); - } - - /* - * For UL channels always assert WAKE until work is done, - * For DL channels only assert if MHI is in a LPM - */ - if (mhi_chan->dir == DMA_TO_DEVICE || - (mhi_chan->dir == DMA_FROM_DEVICE && - mhi_cntrl->pm_state != MHI_PM_M0)) { - assert_wake = true; - mhi_cntrl->wake_get(mhi_cntrl, false); - } - - /* generate the tre */ - buf_info = buf_ring->wp; - MHI_ASSERT(buf_info->used, "TRE Not Freed\n"); - buf_info->p_addr = mhi_buf->dma_addr; - buf_info->pre_mapped = true; - buf_info->cb_buf = mhi_buf; - buf_info->wp = tre_ring->wp; - buf_info->dir = mhi_chan->dir; - buf_info->len = len; - - mhi_tre = tre_ring->wp; - - if (mhi_chan->xfer_type == MHI_XFER_RSC_DMA) { - buf_info->used = true; - mhi_tre->ptr = - MHI_RSCTRE_DATA_PTR(buf_info->p_addr, buf_info->len); - mhi_tre->dword[0] = - MHI_RSCTRE_DATA_DWORD0(buf_ring->wp - buf_ring->base); - mhi_tre->dword[1] = MHI_RSCTRE_DATA_DWORD1; - } else { - mhi_tre->ptr = MHI_TRE_DATA_PTR(buf_info->p_addr); - mhi_tre->dword[0] = MHI_TRE_DATA_DWORD0(buf_info->len); - mhi_tre->dword[1] = MHI_TRE_DATA_DWORD1(1, 1, 0, 0); - } - -#ifdef ENABLE_MHI_MON - if (mhi_cntrl->nreaders) { - mon_bus_submit(mhi_cntrl, mhi_chan->chan, - mhi_to_physical(tre_ring, mhi_tre), mhi_tre, buf_info->v_addr, mhi_chan->chan&0x1 ? 0: buf_info->len); - } -#endif - - MHI_VERB("chan:%d WP:0x%llx TRE:0x%llx 0x%08x 0x%08x\n", mhi_chan->chan, - (u64)mhi_to_physical(tre_ring, mhi_tre), mhi_tre->ptr, - mhi_tre->dword[0], mhi_tre->dword[1]); - - if (mhi_chan->dir == DMA_TO_DEVICE) { - if (atomic_inc_return(&mhi_cntrl->pending_pkts) == 1) - mhi_cntrl->runtime_get(mhi_cntrl, mhi_cntrl->priv_data); - } - - read_lock_bh(&mhi_chan->lock); - /* increment WP */ - mhi_add_ring_element(mhi_cntrl, tre_ring); - mhi_add_ring_element(mhi_cntrl, buf_ring); - - if (likely(MHI_DB_ACCESS_VALID(mhi_cntrl->pm_state))) { - mhi_ring_chan_db(mhi_cntrl, mhi_chan); - } - read_unlock_bh(&mhi_chan->lock); - - if (mhi_chan->dir == DMA_FROM_DEVICE && assert_wake) - mhi_cntrl->wake_put(mhi_cntrl, true); - - read_unlock_bh(&mhi_cntrl->pm_lock); - - return 0; -} - -int mhi_gen_tre(struct mhi_controller *mhi_cntrl, - struct mhi_chan *mhi_chan, - void *buf, - void *cb, - size_t buf_len, - enum MHI_FLAGS flags) -{ - struct mhi_ring *buf_ring, *tre_ring; - struct mhi_tre *mhi_tre; - struct mhi_buf_info *buf_info; - int eot, eob, chain, bei; - int ret; - - buf_ring = &mhi_chan->buf_ring; - tre_ring = &mhi_chan->tre_ring; - - buf_info = buf_ring->wp; - buf_info->v_addr = buf; - buf_info->cb_buf = cb; - buf_info->wp = tre_ring->wp; - buf_info->dir = mhi_chan->dir; - buf_info->len = buf_len; - - ret = mhi_cntrl->map_single(mhi_cntrl, buf_info); - if (ret) - return ret; - - eob = !!(flags & MHI_EOB); - eot = !!(flags & MHI_EOT); - chain = !!(flags & MHI_CHAIN); - bei = !!(mhi_chan->intmod); - - mhi_tre = tre_ring->wp; - mhi_tre->ptr = MHI_TRE_DATA_PTR(buf_info->p_addr); - mhi_tre->dword[0] = MHI_TRE_DATA_DWORD0(buf_len); - mhi_tre->dword[1] = MHI_TRE_DATA_DWORD1(bei, eot, eob, chain); - -#ifdef ENABLE_MHI_MON - if (mhi_cntrl->nreaders) { - mon_bus_submit(mhi_cntrl, mhi_chan->chan, - mhi_to_physical(tre_ring, mhi_tre), mhi_tre, buf_info->v_addr, mhi_chan->chan&0x1 ? 0 : buf_info->len); - } -#endif - MHI_VERB("chan:%d WP:0x%llx TRE:0x%llx 0x%08x 0x%08x\n", mhi_chan->chan, - (u64)mhi_to_physical(tre_ring, mhi_tre), mhi_tre->ptr, - mhi_tre->dword[0], mhi_tre->dword[1]); - - /* increment WP */ - mhi_add_ring_element(mhi_cntrl, tre_ring); - mhi_add_ring_element(mhi_cntrl, buf_ring); - - return 0; -} - -int mhi_queue_buf(struct mhi_device *mhi_dev, - struct mhi_chan *mhi_chan, - void *buf, - size_t len, - enum MHI_FLAGS mflags) -{ - struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; - struct mhi_ring *tre_ring; - unsigned long flags; - bool assert_wake = false; - int ret; - - /* - * this check here only as a guard, it's always - * possible mhi can enter error while executing rest of function, - * which is not fatal so we do not need to hold pm_lock - */ - if (unlikely(MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state))) { - MHI_VERB("MHI is not in active state, pm_state:%s\n", - to_mhi_pm_state_str(mhi_cntrl->pm_state)); - - return -EIO; - } - - tre_ring = &mhi_chan->tre_ring; - if (mhi_is_ring_full(mhi_cntrl, tre_ring)) - return -ENOMEM; - - ret = mhi_chan->gen_tre(mhi_cntrl, mhi_chan, buf, buf, len, mflags); - if (unlikely(ret)) - return ret; - - read_lock_irqsave(&mhi_cntrl->pm_lock, flags); - - /* we're in M3 or transitioning to M3 */ - if (MHI_PM_IN_SUSPEND_STATE(mhi_cntrl->pm_state)) { - mhi_cntrl->runtime_get(mhi_cntrl, mhi_cntrl->priv_data); - mhi_cntrl->runtime_put(mhi_cntrl, mhi_cntrl->priv_data); - } - - /* - * For UL channels always assert WAKE until work is done, - * For DL channels only assert if MHI is in a LPM - */ - if (mhi_chan->dir == DMA_TO_DEVICE || - (mhi_chan->dir == DMA_FROM_DEVICE && - mhi_cntrl->pm_state != MHI_PM_M0)) { - assert_wake = true; - mhi_cntrl->wake_get(mhi_cntrl, false); - } - - if (mhi_chan->dir == DMA_TO_DEVICE) { - if (atomic_inc_return(&mhi_cntrl->pending_pkts) == 1) - mhi_cntrl->runtime_get(mhi_cntrl, mhi_cntrl->priv_data); - } - - if (likely(MHI_DB_ACCESS_VALID(mhi_cntrl->pm_state))) { - unsigned long flags; - - read_lock_irqsave(&mhi_chan->lock, flags); - mhi_ring_chan_db(mhi_cntrl, mhi_chan); - read_unlock_irqrestore(&mhi_chan->lock, flags); - } - - if (mhi_chan->dir == DMA_FROM_DEVICE && assert_wake) - mhi_cntrl->wake_put(mhi_cntrl, true); - - read_unlock_irqrestore(&mhi_cntrl->pm_lock, flags); - - return 0; -} - -static ssize_t ul_chan_id_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct mhi_device *mhi_dev = to_mhi_device(dev); - - return snprintf(buf, PAGE_SIZE, "%d\n", mhi_dev->ul_chan_id); -} - -static DEVICE_ATTR_RO(ul_chan_id); - -static struct attribute *mhi_dev_attrs[] = { - &dev_attr_ul_chan_id.attr, - NULL, -}; - -static struct attribute_group mhi_dev_attr_group = { - .attrs = mhi_dev_attrs, -}; - -/* destroy specific device */ -int mhi_destroy_device(struct device *dev, void *data) -{ - struct mhi_device *mhi_dev; - struct mhi_controller *mhi_cntrl; - - if (dev->bus != &mhi_bus_type) - return 0; - - mhi_dev = to_mhi_device(dev); - mhi_cntrl = mhi_dev->mhi_cntrl; - - /* only destroying virtual devices thats attached to bus */ - if (mhi_dev->dev_type == MHI_CONTROLLER_TYPE) - return 0; - - MHI_LOG("destroy device for chan:%s\n", mhi_dev->chan_name); - - sysfs_remove_group(&mhi_dev->dev.kobj, &mhi_dev_attr_group); - /* notify the client and remove the device from mhi bus */ - device_del(dev); - put_device(dev); - - return 0; -} - -void mhi_notify(struct mhi_device *mhi_dev, enum MHI_CB cb_reason) -{ - struct mhi_driver *mhi_drv; - - if (!mhi_dev->dev.driver) - return; - - mhi_drv = to_mhi_driver(mhi_dev->dev.driver); - - if (mhi_drv->status_cb) - mhi_drv->status_cb(mhi_dev, cb_reason); -} - -static void mhi_assign_of_node(struct mhi_controller *mhi_cntrl, - struct mhi_device *mhi_dev) -{ - struct device_node *controller, *node; - const char *dt_name; - int ret; - - controller = of_find_node_by_name(mhi_cntrl->of_node, "mhi_devices"); - if (!controller) - return; - - for_each_available_child_of_node(controller, node) { - ret = of_property_read_string(node, "mhi,chan", &dt_name); - if (ret) - continue; - if (!strcmp(mhi_dev->chan_name, dt_name)) { - mhi_dev->dev.of_node = node; - break; - } - } -} - -static ssize_t time_show(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct mhi_device *mhi_dev = to_mhi_device(dev); - struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; - u64 t_host, t_device; - int ret; - - ret = mhi_get_remote_time_sync(mhi_dev, &t_host, &t_device); - if (ret) { - MHI_ERR("Failed to obtain time, ret:%d\n", ret); - return ret; - } - - return scnprintf(buf, PAGE_SIZE, "local: %llu remote: %llu (ticks)\n", - t_host, t_device); -} -static DEVICE_ATTR_RO(time); - -static ssize_t time_us_show(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct mhi_device *mhi_dev = to_mhi_device(dev); - struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; - u64 t_host, t_device; - int ret; - - ret = mhi_get_remote_time_sync(mhi_dev, &t_host, &t_device); - if (ret) { - MHI_ERR("Failed to obtain time, ret:%d\n", ret); - return ret; - } - - return scnprintf(buf, PAGE_SIZE, "local: %llu remote: %llu (us)\n", - TIME_TICKS_TO_US(t_host), TIME_TICKS_TO_US(t_device)); -} -static DEVICE_ATTR_RO(time_us); - -static struct attribute *mhi_tsync_attrs[] = { - &dev_attr_time.attr, - &dev_attr_time_us.attr, - NULL, -}; - -static const struct attribute_group mhi_tsync_group = { - .attrs = mhi_tsync_attrs, -}; - -void mhi_destroy_timesync(struct mhi_controller *mhi_cntrl) -{ - if (mhi_cntrl->mhi_tsync) { - sysfs_remove_group(&mhi_cntrl->mhi_dev->dev.kobj, - &mhi_tsync_group); - kfree(mhi_cntrl->mhi_tsync); - mhi_cntrl->mhi_tsync = NULL; - } -} - -int mhi_create_timesync_sysfs(struct mhi_controller *mhi_cntrl) -{ - return sysfs_create_group(&mhi_cntrl->mhi_dev->dev.kobj, - &mhi_tsync_group); -} - -static void mhi_create_time_sync_dev(struct mhi_controller *mhi_cntrl) -{ - struct mhi_device *mhi_dev; - int ret; - - if (!MHI_IN_MISSION_MODE(mhi_cntrl->ee)) - return; - - mhi_dev = mhi_alloc_device(mhi_cntrl); - if (!mhi_dev) - return; - - mhi_dev->dev_type = MHI_TIMESYNC_TYPE; - mhi_dev->chan_name = "TIME_SYNC"; - dev_set_name(&mhi_dev->dev, "%04x_%02x.%02x.%02x_%s", mhi_dev->dev_id, - mhi_dev->domain, mhi_dev->bus, mhi_dev->slot, - mhi_dev->chan_name); - - /* add if there is a matching DT node */ - mhi_assign_of_node(mhi_cntrl, mhi_dev); - - ret = device_add(&mhi_dev->dev); - if (ret) { - MHI_ERR("Failed to register dev for chan:%s\n", - mhi_dev->chan_name); - mhi_dealloc_device(mhi_cntrl, mhi_dev); - return; - } - - mhi_cntrl->tsync_dev = mhi_dev; -} - -/* bind mhi channels into mhi devices */ -void mhi_create_devices(struct mhi_controller *mhi_cntrl) -{ - int i; - struct mhi_chan *mhi_chan; - struct mhi_device *mhi_dev; - int ret; - - /* - * we need to create time sync device before creating other - * devices, because client may try to capture time during - * clint probe. - */ - mhi_create_time_sync_dev(mhi_cntrl); - - mhi_chan = mhi_cntrl->mhi_chan; - for (i = 0; i < mhi_cntrl->max_chan; i++, mhi_chan++) { - if (!mhi_chan->configured || mhi_chan->mhi_dev || - !(mhi_chan->ee_mask & BIT(mhi_cntrl->ee))) - continue; - mhi_dev = mhi_alloc_device(mhi_cntrl); - if (!mhi_dev) - return; - - mhi_dev->dev_type = MHI_XFER_TYPE; - switch (mhi_chan->dir) { - case DMA_TO_DEVICE: - mhi_dev->ul_chan = mhi_chan; - mhi_dev->ul_chan_id = mhi_chan->chan; - mhi_dev->ul_xfer = mhi_chan->queue_xfer; - mhi_dev->ul_event_id = mhi_chan->er_index; - break; - case DMA_NONE: - case DMA_BIDIRECTIONAL: - mhi_dev->ul_chan_id = mhi_chan->chan; - mhi_dev->ul_event_id = mhi_chan->er_index; - mhi_dev->dl_chan = mhi_chan; - mhi_dev->dl_chan_id = mhi_chan->chan; - mhi_dev->dl_xfer = mhi_chan->queue_xfer; - mhi_dev->dl_event_id = mhi_chan->er_index; - break; - case DMA_FROM_DEVICE: - /* we use dl_chan for offload channels */ - mhi_dev->dl_chan = mhi_chan; - mhi_dev->dl_chan_id = mhi_chan->chan; - mhi_dev->dl_xfer = mhi_chan->queue_xfer; - mhi_dev->dl_event_id = mhi_chan->er_index; - break; - } - - mhi_chan->mhi_dev = mhi_dev; - - /* check next channel if it matches */ - if ((i + 1) < mhi_cntrl->max_chan && mhi_chan[1].configured) { - if (!strcmp(mhi_chan[1].name, mhi_chan->name)) { - i++; - mhi_chan++; - if (mhi_chan->dir == DMA_TO_DEVICE) { - mhi_dev->ul_chan = mhi_chan; - mhi_dev->ul_chan_id = mhi_chan->chan; - mhi_dev->ul_xfer = mhi_chan->queue_xfer; - mhi_dev->ul_event_id = - mhi_chan->er_index; - } else { - mhi_dev->dl_chan = mhi_chan; - mhi_dev->dl_chan_id = mhi_chan->chan; - mhi_dev->dl_xfer = mhi_chan->queue_xfer; - mhi_dev->dl_event_id = - mhi_chan->er_index; - } - mhi_chan->mhi_dev = mhi_dev; - } - } - - mhi_dev->chan_name = mhi_chan->name; - dev_set_name(&mhi_dev->dev, "%04x_%02x.%02x.%02x_%s", - mhi_dev->dev_id, mhi_dev->domain, mhi_dev->bus, - mhi_dev->slot, mhi_dev->chan_name); - - /* add if there is a matching DT node */ - mhi_assign_of_node(mhi_cntrl, mhi_dev); - - /* init wake source */ - if (mhi_dev->dl_chan && mhi_dev->dl_chan->wake_capable) - device_init_wakeup(&mhi_dev->dev, true); - - ret = device_add(&mhi_dev->dev); - if (ret) { - MHI_ERR("Failed to register dev for chan:%s\n", - mhi_dev->chan_name); - mhi_dealloc_device(mhi_cntrl, mhi_dev); - } - ret = sysfs_create_group(&mhi_dev->dev.kobj, &mhi_dev_attr_group); - } -} - -static void mhi_dump_tre(struct mhi_controller *mhi_cntrl, struct mhi_tre *_ev) { - union mhi_dev_ring_element_type *ev = (union mhi_dev_ring_element_type *)_ev; - - switch (ev->generic.type) { - case MHI_DEV_RING_EL_INVALID: { - MHI_ERR("carl_ev cmd_invalid, ptr=%llx, %x, %x\n", _ev->ptr, _ev->dword[0], _ev->dword[1]); - } - break; - case MHI_DEV_RING_EL_NOOP: { - MHI_LOG("carl_ev cmd_no_op chan=%u\n", ev->cmd_no_op.chid); - } - break; - case MHI_DEV_RING_EL_TRANSFER: { - MHI_LOG("carl_ev cmd_transfer data=%llx, len=%u, chan=%u\n", - ev->cmd_transfer.data_buf_ptr, ev->cmd_transfer.len, ev->cmd_transfer.chain); - } - break; - case MHI_DEV_RING_EL_RESET: { - MHI_LOG("carl_ev cmd_reset chan=%u\n", ev->cmd_reset.chid); - } - break; - case MHI_DEV_RING_EL_STOP: { - MHI_LOG("carl_ev cmd_stop chan=%u\n", ev->cmd_stop.chid); - } - break; - case MHI_DEV_RING_EL_START: { - MHI_LOG("carl_ev cmd_start chan=%u\n", ev->cmd_start.chid); - } - break; - case MHI_DEV_RING_EL_MHI_STATE_CHG: { - MHI_LOG("carl_ev evt_state_change mhistate=%u\n", ev->evt_state_change.mhistate); - } - break; - case MHI_DEV_RING_EL_CMD_COMPLETION_EVT:{ - MHI_LOG("carl_ev evt_cmd_comp code=%u, type=%u\n", ev->evt_cmd_comp.code, ev->evt_cmd_comp.type); - } - break; - case MHI_DEV_RING_EL_TRANSFER_COMPLETION_EVENT:{ - MHI_VERB("carl_ev evt_tr_comp ptr=%llx, len=%u, code=%u, chan=%u\n", - ev->evt_tr_comp.ptr, ev->evt_tr_comp.len, ev->evt_tr_comp.code, ev->evt_tr_comp.chid); - } - break; - case MHI_DEV_RING_EL_EE_STATE_CHANGE_NOTIFY:{ - MHI_LOG("carl_ev evt_ee_state execenv=%u\n", ev->evt_ee_state.execenv); - } - break; - case MHI_DEV_RING_EL_UNDEF: - default: { - MHI_ERR("carl_ev el_undef type=%d\n", ev->generic.type); - }; - break; - } -} - -static int parse_xfer_event(struct mhi_controller *mhi_cntrl, - struct mhi_tre *event, - struct mhi_chan *mhi_chan) -{ - struct mhi_ring *buf_ring, *tre_ring; - u32 ev_code; - struct mhi_result result; - unsigned long flags = 0; - - ev_code = MHI_TRE_GET_EV_CODE(event); - buf_ring = &mhi_chan->buf_ring; - tre_ring = &mhi_chan->tre_ring; - - result.transaction_status = (ev_code == MHI_EV_CC_OVERFLOW) ? - -EOVERFLOW : 0; - - /* - * if it's a DB Event then we need to grab the lock - * with preemption disable and as a write because we - * have to update db register and another thread could - * be doing same. - */ - if (ev_code >= MHI_EV_CC_OOB) - write_lock_irqsave(&mhi_chan->lock, flags); - else - read_lock_bh(&mhi_chan->lock); - - if (mhi_chan->ch_state != MHI_CH_STATE_ENABLED) - goto end_process_tx_event; - - switch (ev_code) { - case MHI_EV_CC_OVERFLOW: - case MHI_EV_CC_EOB: - case MHI_EV_CC_EOT: - { - dma_addr_t ptr = MHI_TRE_GET_EV_PTR(event); - struct mhi_tre *local_rp, *ev_tre; - void *dev_rp; - struct mhi_buf_info *buf_info; - u16 xfer_len; - - /* Get the TRB this event points to */ - ev_tre = mhi_to_virtual(tre_ring, ptr); - - /* device rp after servicing the TREs */ - dev_rp = ev_tre + 1; - if (dev_rp >= (tre_ring->base + tre_ring->len)) - dev_rp = tre_ring->base; - - mhi_chan->used_events[ev_code]++; - - result.dir = mhi_chan->dir; - - /* local rp */ - local_rp = tre_ring->rp; - while (local_rp != dev_rp) { - buf_info = buf_ring->rp; - /* Always get the get len from the event */ - xfer_len = MHI_TRE_GET_EV_LEN(event); - - /* unmap if it's not premapped by client */ - if (likely(!buf_info->pre_mapped)) - mhi_cntrl->unmap_single(mhi_cntrl, buf_info); - - result.buf_addr = buf_info->cb_buf; - result.bytes_xferd = xfer_len; -#ifdef ENABLE_MHI_MON - if (mhi_cntrl->nreaders) { - void *buf = NULL; - size_t len = 0; - - if (mhi_chan->queue_xfer == mhi_queue_skb) { - struct sk_buff *skb = result.buf_addr; - buf = skb->data; - len = result.bytes_xferd; - } - else if (CHAN_INBOUND(mhi_chan->chan)) { - buf = result.buf_addr; - len = result.bytes_xferd; - } - mon_bus_receive(mhi_cntrl, mhi_chan->chan, - mhi_to_physical(tre_ring, local_rp), local_rp, buf, len); - } -#endif - mhi_del_ring_element(mhi_cntrl, buf_ring); - mhi_del_ring_element(mhi_cntrl, tre_ring); - local_rp = tre_ring->rp; - - /* notify client */ - mhi_chan->xfer_cb(mhi_chan->mhi_dev, &result); - - if (mhi_chan->dir == DMA_TO_DEVICE) { - if (atomic_dec_return(&mhi_cntrl->pending_pkts) == 0) - mhi_cntrl->runtime_put(mhi_cntrl, mhi_cntrl->priv_data); - } - - if (mhi_chan->dir == DMA_TO_DEVICE) { - read_lock_bh(&mhi_cntrl->pm_lock); - mhi_cntrl->wake_put(mhi_cntrl, false); - read_unlock_bh(&mhi_cntrl->pm_lock); - } - - /* - * recycle the buffer if buffer is pre-allocated, - * if there is error, not much we can do apart from - * dropping the packet - */ - if (mhi_chan->pre_alloc) { - if (mhi_queue_buf(mhi_chan->mhi_dev, mhi_chan, - buf_info->cb_buf, - buf_info->len, MHI_EOT)) { - MHI_ERR( - "Error recycling buffer for chan:%d\n", - mhi_chan->chan); - kfree(buf_info->cb_buf); - } - } - } - break; - } /* CC_EOT */ - case MHI_EV_CC_OOB: - case MHI_EV_CC_DB_MODE: - { - unsigned long flags; - - mhi_chan->used_events[ev_code]++; - MHI_VERB("DB_MODE/OOB Detected chan %d.\n", mhi_chan->chan); - mhi_chan->db_cfg.db_mode = true; - read_lock_irqsave(&mhi_cntrl->pm_lock, flags); -#ifdef DEBUG_CHAN100_DB - if (mhi_chan->chan == 100) { - chan100_t[atomic_inc_return(&chan100_seq)&(CHAN100_SIZE-1)] = (((unsigned long)tre_ring->rp)&0xffff) | (0xf0000); - chan100_t[atomic_inc_return(&chan100_seq)&(CHAN100_SIZE-1)] = (((unsigned long)tre_ring->wp)&0xffff) | (mhi_chan->db_cfg.db_mode<<31) | (1<<30); - } -#endif - if (tre_ring->wp != tre_ring->rp && - MHI_DB_ACCESS_VALID(mhi_cntrl->pm_state)) { - mhi_ring_chan_db(mhi_cntrl, mhi_chan); - } - read_unlock_irqrestore(&mhi_cntrl->pm_lock, flags); - break; - } - case MHI_EV_CC_BAD_TRE: - MHI_ASSERT(1, "Received BAD TRE event for ring"); - break; - default: - MHI_CRITICAL("Unknown TX completion.\n"); - - break; - } /* switch(MHI_EV_READ_CODE(EV_TRB_CODE,event)) */ - -end_process_tx_event: - if (ev_code >= MHI_EV_CC_OOB) - write_unlock_irqrestore(&mhi_chan->lock, flags); - else - read_unlock_bh(&mhi_chan->lock); - - return 0; -} - -static int parse_rsc_event(struct mhi_controller *mhi_cntrl, - struct mhi_tre *event, - struct mhi_chan *mhi_chan) -{ - struct mhi_ring *buf_ring, *tre_ring; - struct mhi_buf_info *buf_info; - struct mhi_result result; - int ev_code; - u32 cookie; /* offset to local descriptor */ - u16 xfer_len; - - buf_ring = &mhi_chan->buf_ring; - tre_ring = &mhi_chan->tre_ring; - - ev_code = MHI_TRE_GET_EV_CODE(event); - cookie = MHI_TRE_GET_EV_COOKIE(event); - xfer_len = MHI_TRE_GET_EV_LEN(event); - - /* received out of bound cookie */ - MHI_ASSERT(cookie >= buf_ring->len, "Invalid Cookie\n"); - - buf_info = buf_ring->base + cookie; - - result.transaction_status = (ev_code == MHI_EV_CC_OVERFLOW) ? - -EOVERFLOW : 0; - result.bytes_xferd = xfer_len; - result.buf_addr = buf_info->cb_buf; - result.dir = mhi_chan->dir; - - read_lock_bh(&mhi_chan->lock); - - if (mhi_chan->ch_state != MHI_CH_STATE_ENABLED) - goto end_process_rsc_event; - - MHI_ASSERT(!buf_info->used, "TRE already Freed\n"); - - /* notify the client */ - mhi_chan->xfer_cb(mhi_chan->mhi_dev, &result); - - /* - * Note: We're arbitrarily incrementing RP even though, completion - * packet we processed might not be the same one, reason we can do this - * is because device guaranteed to cache descriptors in order it - * receive, so even though completion event is different we can re-use - * all descriptors in between. - * Example: - * Transfer Ring has descriptors: A, B, C, D - * Last descriptor host queue is D (WP) and first descriptor - * host queue is A (RP). - * The completion event we just serviced is descriptor C. - * Then we can safely queue descriptors to replace A, B, and C - * even though host did not receive any completions. - */ - mhi_del_ring_element(mhi_cntrl, tre_ring); - buf_info->used = false; - -end_process_rsc_event: - read_unlock_bh(&mhi_chan->lock); - - return 0; -} - -static void mhi_process_cmd_completion(struct mhi_controller *mhi_cntrl, - struct mhi_tre *tre) -{ - dma_addr_t ptr = MHI_TRE_GET_EV_PTR(tre); - struct mhi_cmd *cmd_ring = &mhi_cntrl->mhi_cmd[PRIMARY_CMD_RING]; - struct mhi_ring *mhi_ring = &cmd_ring->ring; - struct mhi_tre *cmd_pkt; - struct mhi_chan *mhi_chan; - struct mhi_timesync *mhi_tsync; - enum mhi_cmd_type type; - u32 chan; - - cmd_pkt = mhi_to_virtual(mhi_ring, ptr); - - /* out of order completion received */ - MHI_ASSERT(cmd_pkt != mhi_ring->rp, "Out of order cmd completion"); - - type = MHI_TRE_GET_CMD_TYPE(cmd_pkt); - - if (type == MHI_CMD_TYPE_TSYNC) { - mhi_tsync = mhi_cntrl->mhi_tsync; - mhi_tsync->ccs = MHI_TRE_GET_EV_CODE(tre); - complete(&mhi_tsync->completion); - } else { - chan = MHI_TRE_GET_CMD_CHID(cmd_pkt); - mhi_chan = &mhi_cntrl->mhi_chan[chan]; - write_lock_bh(&mhi_chan->lock); - mhi_chan->ccs = MHI_TRE_GET_EV_CODE(tre); - complete(&mhi_chan->completion); - write_unlock_bh(&mhi_chan->lock); - } - - mhi_del_ring_element(mhi_cntrl, mhi_ring); -} - -int mhi_process_ctrl_ev_ring(struct mhi_controller *mhi_cntrl, - struct mhi_event *mhi_event, - u32 event_quota) -{ - struct mhi_tre *dev_rp, *local_rp; - struct mhi_ring *ev_ring = &mhi_event->ring; - struct mhi_event_ctxt *er_ctxt = - &mhi_cntrl->mhi_ctxt->er_ctxt[mhi_event->er_index]; - int count = 0; - - /* - * this is a quick check to avoid unnecessary event processing - * in case we already in error state, but it's still possible - * to transition to error state while processing events - */ - if (unlikely(MHI_EVENT_ACCESS_INVALID(mhi_cntrl->pm_state))) { - MHI_ERR("No EV access, PM_STATE:%s\n", - to_mhi_pm_state_str(mhi_cntrl->pm_state)); - return -EIO; - } - - dev_rp = mhi_to_virtual(ev_ring, er_ctxt->rp); - local_rp = ev_ring->rp; - - while (dev_rp != local_rp) { - enum MHI_PKT_TYPE type = MHI_TRE_GET_EV_TYPE(local_rp); - -//#define QL_READ_EVENT_WA //from Quectel Windows driver -#ifdef QL_READ_EVENT_WA - if (mhi_event->er_index == 0) { - if (local_rp->ptr == 0 && local_rp->dword[0] == 0 && local_rp->dword[1] == 0) { - // event content no sync to memory, just break and wait next event. - MHI_ERR("Zero Event!\n"); - break; - } - } -#endif - - mhi_dump_tre(mhi_cntrl, local_rp); - MHI_VERB("Processing Event:0x%llx 0x%08x 0x%08x\n", - local_rp->ptr, local_rp->dword[0], local_rp->dword[1]); -#ifdef ENABLE_MHI_MON - if (mhi_cntrl->nreaders) { - mon_bus_complete(mhi_cntrl, mhi_event->er_index, mhi_to_physical(ev_ring, local_rp), local_rp); - } -#endif - - switch (type) { - case MHI_PKT_TYPE_STATE_CHANGE_EVENT: - { - enum mhi_dev_state new_state; - - new_state = MHI_TRE_GET_EV_STATE(local_rp); - - MHI_LOG("MHI state change event to state:%s\n", - TO_MHI_STATE_STR(new_state)); - - switch (new_state) { - case MHI_STATE_M0: - mhi_pm_m0_transition(mhi_cntrl); - break; - case MHI_STATE_M1: - mhi_pm_m1_transition(mhi_cntrl); - break; - case MHI_STATE_M3: - mhi_pm_m3_transition(mhi_cntrl); - break; - case MHI_STATE_SYS_ERR: - { - enum MHI_PM_STATE new_state; - - MHI_ERR("MHI system error detected\n"); - write_lock_irq(&mhi_cntrl->pm_lock); - new_state = mhi_tryset_pm_state(mhi_cntrl, - MHI_PM_SYS_ERR_DETECT); - write_unlock_irq(&mhi_cntrl->pm_lock); - if (new_state == MHI_PM_SYS_ERR_DETECT) - schedule_work( - &mhi_cntrl->syserr_worker); - break; - } - default: - MHI_ERR("Unsupported STE:%s\n", - TO_MHI_STATE_STR(new_state)); - } - - break; - } - case MHI_PKT_TYPE_CMD_COMPLETION_EVENT: - mhi_process_cmd_completion(mhi_cntrl, local_rp); - break; - case MHI_PKT_TYPE_EE_EVENT: - { - enum MHI_ST_TRANSITION st = MHI_ST_TRANSITION_MAX; - enum mhi_ee event = MHI_TRE_GET_EV_EXECENV(local_rp); - - MHI_LOG("MHI EE received event:%s\n", - TO_MHI_EXEC_STR(event)); - switch (event) { - case MHI_EE_SBL: - st = MHI_ST_TRANSITION_SBL; - break; - case MHI_EE_FP: - st = MHI_ST_TRANSITION_FP; - break; - case MHI_EE_WFW: - case MHI_EE_AMSS: - st = MHI_ST_TRANSITION_MISSION_MODE; - break; - case MHI_EE_RDDM: - mhi_cntrl->status_cb(mhi_cntrl, - mhi_cntrl->priv_data, - MHI_CB_EE_RDDM); - write_lock_irq(&mhi_cntrl->pm_lock); - mhi_cntrl->ee = event; - write_unlock_irq(&mhi_cntrl->pm_lock); - wake_up_all(&mhi_cntrl->state_event); - break; - default: - MHI_ERR("Unhandled EE event:%s\n", - TO_MHI_EXEC_STR(event)); - } - if (st != MHI_ST_TRANSITION_MAX) - mhi_queue_state_transition(mhi_cntrl, st); - break; - } -#if 1 //Add by Quectel - case MHI_PKT_TYPE_TX_EVENT: - case MHI_PKT_TYPE_RSC_TX_EVENT: - { - u32 chan = MHI_TRE_GET_EV_CHID(local_rp); - struct mhi_chan *mhi_chan = &mhi_cntrl->mhi_chan[chan]; - - if (likely(type == MHI_PKT_TYPE_TX_EVENT)) { - parse_xfer_event(mhi_cntrl, local_rp, mhi_chan); - } else if (type == MHI_PKT_TYPE_RSC_TX_EVENT) { - parse_rsc_event(mhi_cntrl, local_rp, mhi_chan); - } - break; - } -#endif - default: - MHI_ASSERT(1, "Unsupported ev type"); - break; - } - -#ifdef QL_READ_EVENT_WA - if (mhi_event->er_index == 0) { - local_rp->ptr = 0; - local_rp->dword[0] = local_rp->dword[1] = 0; - } -#endif - - mhi_recycle_ev_ring_element(mhi_cntrl, ev_ring); - local_rp = ev_ring->rp; - dev_rp = mhi_to_virtual(ev_ring, er_ctxt->rp); - count++; - } - - if (count > mhi_event->used_elements) { - mhi_event->used_elements = count; - } - - read_lock_bh(&mhi_cntrl->pm_lock); - if (likely(MHI_DB_ACCESS_VALID(mhi_cntrl->pm_state))) - mhi_ring_er_db(mhi_event); - read_unlock_bh(&mhi_cntrl->pm_lock); - - MHI_VERB("exit er_index:%u\n", mhi_event->er_index); - - return count; -} - -int mhi_process_data_event_ring(struct mhi_controller *mhi_cntrl, - struct mhi_event *mhi_event, - u32 event_quota) -{ - struct mhi_tre *dev_rp, *local_rp; - struct mhi_ring *ev_ring = &mhi_event->ring; - struct mhi_event_ctxt *er_ctxt = - &mhi_cntrl->mhi_ctxt->er_ctxt[mhi_event->er_index]; - int count = 0; - u32 chan; - struct mhi_chan *mhi_chan = NULL; - u32 chan_count = 0; - void *chan_local_rp = NULL; - - if (unlikely(MHI_EVENT_ACCESS_INVALID(mhi_cntrl->pm_state))) { - MHI_ERR("No EV access, PM_STATE:%s\n", - to_mhi_pm_state_str(mhi_cntrl->pm_state)); - return -EIO; - } - - dev_rp = mhi_to_virtual(ev_ring, er_ctxt->rp); - local_rp = ev_ring->rp; - - while (dev_rp != local_rp && event_quota > 0) { - enum MHI_PKT_TYPE type = MHI_TRE_GET_EV_TYPE(local_rp); - - mhi_dump_tre(mhi_cntrl, local_rp); - MHI_VERB("Processing Event:0x%llx 0x%08x 0x%08x\n", - local_rp->ptr, local_rp->dword[0], local_rp->dword[1]); - - chan = MHI_TRE_GET_EV_CHID(local_rp); - mhi_chan = &mhi_cntrl->mhi_chan[chan]; - chan_local_rp = mhi_chan->tre_ring.rp; - -#ifdef ENABLE_MHI_MON - if (mhi_cntrl->nreaders) { - mon_bus_complete(mhi_cntrl, mhi_event->er_index, mhi_to_physical(ev_ring, local_rp), local_rp); - } -#endif - if (likely(type == MHI_PKT_TYPE_TX_EVENT)) { - parse_xfer_event(mhi_cntrl, local_rp, mhi_chan); - event_quota--; - } else if (type == MHI_PKT_TYPE_RSC_TX_EVENT) { - parse_rsc_event(mhi_cntrl, local_rp, mhi_chan); - event_quota--; - } - - chan_count += get_used_ring_elements(chan_local_rp, mhi_chan->tre_ring.rp, mhi_chan->tre_ring.elements); - mhi_recycle_ev_ring_element(mhi_cntrl, ev_ring); - local_rp = ev_ring->rp; - if (local_rp == dev_rp || event_quota == 0) { - if (chan_count > mhi_chan->used_elements) - mhi_chan->used_elements = chan_count; - chan_count = 0; - dev_rp = mhi_to_virtual(ev_ring, er_ctxt->rp); - } - count++; - } - - if (count > mhi_event->used_elements) { - mhi_event->used_elements = count; - } - - read_lock_bh(&mhi_cntrl->pm_lock); - if (likely(MHI_DB_ACCESS_VALID(mhi_cntrl->pm_state))) - mhi_ring_er_db(mhi_event); - read_unlock_bh(&mhi_cntrl->pm_lock); - - MHI_VERB("exit er_index:%u\n", mhi_event->er_index); - - return count; -} - -int mhi_process_tsync_event_ring(struct mhi_controller *mhi_cntrl, - struct mhi_event *mhi_event, - u32 event_quota) -{ - struct mhi_tre *dev_rp, *local_rp; - struct mhi_ring *ev_ring = &mhi_event->ring; - struct mhi_event_ctxt *er_ctxt = - &mhi_cntrl->mhi_ctxt->er_ctxt[mhi_event->er_index]; - struct mhi_timesync *mhi_tsync = mhi_cntrl->mhi_tsync; - int count = 0; - u32 sequence; - u64 remote_time; - - if (unlikely(MHI_EVENT_ACCESS_INVALID(mhi_cntrl->pm_state))) { - MHI_ERR("No EV access, PM_STATE:%s\n", - to_mhi_pm_state_str(mhi_cntrl->pm_state)); - read_unlock_bh(&mhi_cntrl->pm_lock); - return -EIO; - } - - dev_rp = mhi_to_virtual(ev_ring, er_ctxt->rp); - local_rp = ev_ring->rp; - - while (dev_rp != local_rp) { - enum MHI_PKT_TYPE type = MHI_TRE_GET_EV_TYPE(local_rp); - struct tsync_node *tsync_node; - - MHI_VERB("Processing Event:0x%llx 0x%08x 0x%08x\n", - local_rp->ptr, local_rp->dword[0], local_rp->dword[1]); - - MHI_ASSERT(type != MHI_PKT_TYPE_TSYNC_EVENT, "!TSYNC event"); - - sequence = MHI_TRE_GET_EV_SEQ(local_rp); - remote_time = MHI_TRE_GET_EV_TIME(local_rp); - - do { - spin_lock_irq(&mhi_tsync->lock); - tsync_node = list_first_entry_or_null(&mhi_tsync->head, - struct tsync_node, node); - MHI_ASSERT(!tsync_node, "Unexpected Event"); - - if (unlikely(!tsync_node)) - break; - - list_del(&tsync_node->node); - spin_unlock_irq(&mhi_tsync->lock); - - /* - * device may not able to process all time sync commands - * host issue and only process last command it receive - */ - if (tsync_node->sequence == sequence) { - tsync_node->cb_func(tsync_node->mhi_dev, - sequence, - tsync_node->local_time, - remote_time); - kfree(tsync_node); - } else { - kfree(tsync_node); - } - } while (true); - - mhi_recycle_ev_ring_element(mhi_cntrl, ev_ring); - local_rp = ev_ring->rp; - dev_rp = mhi_to_virtual(ev_ring, er_ctxt->rp); - count++; - } - - read_lock_bh(&mhi_cntrl->pm_lock); - if (likely(MHI_DB_ACCESS_VALID(mhi_cntrl->pm_state))) - mhi_ring_er_db(mhi_event); - read_unlock_bh(&mhi_cntrl->pm_lock); - - MHI_VERB("exit er_index:%u\n", mhi_event->er_index); - - return count; -} - -void mhi_ev_task(unsigned long data) -{ - struct mhi_event *mhi_event = (struct mhi_event *)data; - struct mhi_controller *mhi_cntrl = mhi_event->mhi_cntrl; - - MHI_VERB("Enter for ev_index:%d\n", mhi_event->er_index); - - mhi_cntrl->runtime_mark_last_busy(mhi_cntrl, mhi_cntrl->priv_data); - /* process all pending events */ - spin_lock_bh(&mhi_event->lock); - mhi_event->process_event(mhi_cntrl, mhi_event, U32_MAX); - spin_unlock_bh(&mhi_event->lock); -} - -void mhi_ctrl_ev_task(unsigned long data) -{ - struct mhi_event *mhi_event = (struct mhi_event *)data; - struct mhi_controller *mhi_cntrl = mhi_event->mhi_cntrl; - enum mhi_dev_state state; - enum MHI_PM_STATE pm_state = 0; - int ret; - - MHI_VERB("Enter for ev_index:%d\n", mhi_event->er_index); - - /* - * we can check pm_state w/o a lock here because there is no way - * pm_state can change from reg access valid to no access while this - * therad being executed. - */ - if (!MHI_REG_ACCESS_VALID(mhi_cntrl->pm_state)) - return; - - mhi_cntrl->runtime_mark_last_busy(mhi_cntrl, mhi_cntrl->priv_data); - /* process ctrl events events */ - ret = mhi_event->process_event(mhi_cntrl, mhi_event, U32_MAX); - - /* - * we received a MSI but no events to process maybe device went to - * SYS_ERR state, check the state - */ - if (!ret) { - write_lock_irq(&mhi_cntrl->pm_lock); - state = mhi_get_mhi_state(mhi_cntrl); - if (state == MHI_STATE_SYS_ERR) { - MHI_ERR("MHI system error detected\n"); - pm_state = mhi_tryset_pm_state(mhi_cntrl, - MHI_PM_SYS_ERR_DETECT); - } - write_unlock_irq(&mhi_cntrl->pm_lock); - if (pm_state == MHI_PM_SYS_ERR_DETECT) - schedule_work(&mhi_cntrl->syserr_worker); - } -} - -irqreturn_t mhi_msi_handlr(int irq_number, void *dev) -{ - struct mhi_event *mhi_event = dev; - struct mhi_controller *mhi_cntrl = mhi_event->mhi_cntrl; - struct mhi_event_ctxt *er_ctxt = - &mhi_cntrl->mhi_ctxt->er_ctxt[mhi_event->er_index]; - struct mhi_ring *ev_ring = &mhi_event->ring; - void *dev_rp = mhi_to_virtual(ev_ring, er_ctxt->rp); - - /* confirm ER has pending events to process before scheduling work */ - if (ev_ring->rp == dev_rp) - return IRQ_HANDLED; - - /* client managed event ring, notify pending data */ - if (mhi_event->cl_manage) { - struct mhi_chan *mhi_chan = mhi_event->mhi_chan; - struct mhi_device *mhi_dev = mhi_chan->mhi_dev; - - if (mhi_dev) - mhi_dev->status_cb(mhi_dev, MHI_CB_PENDING_DATA); - } else - tasklet_schedule(&mhi_event->task); - - return IRQ_HANDLED; -} - -/* this is the threaded fn */ -irqreturn_t mhi_intvec_threaded_handlr(int irq_number, void *dev) -{ - struct mhi_controller *mhi_cntrl = dev; - enum mhi_dev_state state = MHI_STATE_MAX; - enum MHI_PM_STATE pm_state = 0; - enum mhi_ee ee = MHI_EE_MAX; - unsigned long flags; - - MHI_VERB("Enter\n"); - - write_lock_irqsave(&mhi_cntrl->pm_lock, flags); - if (MHI_REG_ACCESS_VALID(mhi_cntrl->pm_state)) { - state = mhi_get_mhi_state(mhi_cntrl); - ee = mhi_get_exec_env(mhi_cntrl); - if (mhi_cntrl->msi_allocated >= 5 ||(mhi_cntrl->msi_allocated == 1 && (mhi_cntrl->dev_state != state || mhi_cntrl->ee != ee))) - MHI_LOG("device ee:%s dev_state:%s, pm_state:%s\n", TO_MHI_EXEC_STR(ee), - TO_MHI_STATE_STR(state), to_mhi_pm_state_str(mhi_cntrl->pm_state)); - } - - if (state == MHI_STATE_SYS_ERR) { - MHI_ERR("MHI system error detected\n"); - if (mhi_cntrl->pm_state != MHI_PM_SYS_ERR_DETECT) - pm_state = mhi_tryset_pm_state(mhi_cntrl, - MHI_PM_SYS_ERR_DETECT); - } - write_unlock_irqrestore(&mhi_cntrl->pm_lock, flags); - if (pm_state == MHI_PM_SYS_ERR_DETECT) { - wake_up_all(&mhi_cntrl->state_event); - - if (mhi_cntrl->ee != ee) { - MHI_LOG("device ee:%s -> %s\n", TO_MHI_EXEC_STR(mhi_cntrl->ee), TO_MHI_EXEC_STR(ee)); - schedule_work(&mhi_cntrl->syserr_worker); - } - /* for fatal errors, we let controller decide next step */ - else if (MHI_IN_PBL(ee)) - mhi_cntrl->status_cb(mhi_cntrl, mhi_cntrl->priv_data, - MHI_CB_FATAL_ERROR); - else - schedule_work(&mhi_cntrl->syserr_worker); - } - if (mhi_cntrl->msi_allocated >= 5||(mhi_cntrl->msi_allocated == 1 && (mhi_cntrl->dev_state != state || mhi_cntrl->ee != ee))) - MHI_LOG("device ee:%s dev_state:%s, %s\n", TO_MHI_EXEC_STR(ee), - TO_MHI_STATE_STR(state), TO_MHI_EXEC_STR(mhi_cntrl->ee)); - - if (pm_state == MHI_PM_POR) { - wake_up_all(&mhi_cntrl->state_event); - } - - MHI_VERB("Exit\n"); - - return IRQ_HANDLED; -} - -irqreturn_t mhi_intvec_handlr(int irq_number, void *dev) -{ - - struct mhi_controller *mhi_cntrl = dev; - - /* wake up any events waiting for state change */ - MHI_VERB("Enter\n"); - wake_up_all(&mhi_cntrl->state_event); - MHI_VERB("Exit\n"); - - return IRQ_WAKE_THREAD; -} - -irqreturn_t mhi_one_msi_handlr(int irq_number, void *dev) -{ - struct mhi_controller *mhi_cntrl = dev; - struct mhi_event_ctxt *er_ctxt = mhi_cntrl->mhi_ctxt->er_ctxt; - struct mhi_event *mhi_event = mhi_cntrl->mhi_event; - u32 i; - u32 handle = 0; - - for (i = 0; i < NUM_MHI_EVT_RINGS; i++, er_ctxt++, mhi_event++) { - struct mhi_ring *ev_ring = &mhi_event->ring; - void *dev_rp = mhi_to_virtual(ev_ring, er_ctxt->rp); - if (ev_ring->rp != dev_rp) { - handle++; - mhi_msi_handlr(irq_number, mhi_event); - } - } - - if (handle ==0) { - mhi_intvec_threaded_handlr(irq_number, dev); - } - - return IRQ_HANDLED; -} - -int mhi_send_cmd(struct mhi_controller *mhi_cntrl, - struct mhi_chan *mhi_chan, - enum MHI_CMD cmd) -{ - struct mhi_tre *cmd_tre = NULL; - struct mhi_cmd *mhi_cmd = &mhi_cntrl->mhi_cmd[PRIMARY_CMD_RING]; - struct mhi_ring *ring = &mhi_cmd->ring; - int chan = 0; - - MHI_VERB("Entered, MHI pm_state:%s dev_state:%s ee:%s\n", - to_mhi_pm_state_str(mhi_cntrl->pm_state), - TO_MHI_STATE_STR(mhi_cntrl->dev_state), - TO_MHI_EXEC_STR(mhi_cntrl->ee)); - - if (mhi_chan) - chan = mhi_chan->chan; - - spin_lock_bh(&mhi_cmd->lock); - if (!get_nr_avail_ring_elements(mhi_cntrl, ring)) { - spin_unlock_bh(&mhi_cmd->lock); - return -ENOMEM; - } - - /* prepare the cmd tre */ - cmd_tre = ring->wp; - switch (cmd) { - case MHI_CMD_RESET_CHAN: - cmd_tre->ptr = MHI_TRE_CMD_RESET_PTR; - cmd_tre->dword[0] = MHI_TRE_CMD_RESET_DWORD0; - cmd_tre->dword[1] = MHI_TRE_CMD_RESET_DWORD1(chan); - break; - case MHI_CMD_START_CHAN: - cmd_tre->ptr = MHI_TRE_CMD_START_PTR; - cmd_tre->dword[0] = MHI_TRE_CMD_START_DWORD0; - cmd_tre->dword[1] = MHI_TRE_CMD_START_DWORD1(chan); - break; - case MHI_CMD_TIMSYNC_CFG: - cmd_tre->ptr = MHI_TRE_CMD_TSYNC_CFG_PTR; - cmd_tre->dword[0] = MHI_TRE_CMD_TSYNC_CFG_DWORD0; - cmd_tre->dword[1] = MHI_TRE_CMD_TSYNC_CFG_DWORD1 - (mhi_cntrl->mhi_tsync->er_index); - break; - } - -#ifdef ENABLE_MHI_MON - if (mhi_cntrl->nreaders) { - mon_bus_submit(mhi_cntrl, 128, mhi_to_physical(ring, cmd_tre), cmd_tre, NULL, 0); - } -#endif - MHI_VERB("WP:0x%llx TRE: 0x%llx 0x%08x 0x%08x\n", - (u64)mhi_to_physical(ring, cmd_tre), cmd_tre->ptr, - cmd_tre->dword[0], cmd_tre->dword[1]); - - /* queue to hardware */ - mhi_add_ring_element(mhi_cntrl, ring); - read_lock_bh(&mhi_cntrl->pm_lock); - if (likely(MHI_DB_ACCESS_VALID(mhi_cntrl->pm_state))) - mhi_ring_cmd_db(mhi_cntrl, mhi_cmd); - read_unlock_bh(&mhi_cntrl->pm_lock); - spin_unlock_bh(&mhi_cmd->lock); - - return 0; -} - -static int __mhi_prepare_channel(struct mhi_controller *mhi_cntrl, - struct mhi_chan *mhi_chan) -{ - int ret = 0; - - MHI_LOG("Entered: preparing channel:%d\n", mhi_chan->chan); - - if (!(BIT(mhi_cntrl->ee) & mhi_chan->ee_mask)) { - MHI_ERR("Current EE:%s Required EE Mask:0x%x for chan:%s\n", - TO_MHI_EXEC_STR(mhi_cntrl->ee), mhi_chan->ee_mask, - mhi_chan->name); - return -ENOTCONN; - } - - mutex_lock(&mhi_chan->mutex); - - /* if channel is not disable state do not allow to start */ - if (mhi_chan->ch_state != MHI_CH_STATE_DISABLED) { - ret = -EIO; - MHI_LOG("channel:%d is not in disabled state, ch_state%d\n", - mhi_chan->chan, mhi_chan->ch_state); - goto error_init_chan; - } - - /* client manages channel context for offload channels */ - if (!mhi_chan->offload_ch) { - ret = mhi_init_chan_ctxt(mhi_cntrl, mhi_chan); - if (ret) { - MHI_ERR("Error with init chan\n"); - goto error_init_chan; - } - } - - reinit_completion(&mhi_chan->completion); - read_lock_bh(&mhi_cntrl->pm_lock); - if (MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) { - MHI_ERR("MHI host is not in active state\n"); - read_unlock_bh(&mhi_cntrl->pm_lock); - ret = -EIO; - goto error_pm_state; - } - - mhi_cntrl->wake_get(mhi_cntrl, false); - read_unlock_bh(&mhi_cntrl->pm_lock); - mhi_cntrl->runtime_get(mhi_cntrl, mhi_cntrl->priv_data); - - ret = mhi_send_cmd(mhi_cntrl, mhi_chan, MHI_CMD_START_CHAN); - if (ret) { - MHI_ERR("Failed to send start chan cmd\n"); - goto error_send_cmd; - } - - ret = wait_for_completion_timeout(&mhi_chan->completion, - msecs_to_jiffies(mhi_cntrl->timeout_ms)); - if (!ret || mhi_chan->ccs != MHI_EV_CC_SUCCESS) { - MHI_ERR("Failed to receive cmd completion for chan:%d\n", - mhi_chan->chan); - ret = -EIO; - goto error_send_cmd; - } - - mhi_cntrl->runtime_put(mhi_cntrl, mhi_cntrl->priv_data); - - write_lock_irq(&mhi_chan->lock); - mhi_chan->ch_state = MHI_CH_STATE_ENABLED; - write_unlock_irq(&mhi_chan->lock); - - /* pre allocate buffer for xfer ring */ - if (mhi_chan->pre_alloc) { - int nr_el = get_nr_avail_ring_elements(mhi_cntrl, - &mhi_chan->tre_ring); - size_t len = mhi_cntrl->buffer_len; - - while (nr_el--) { - void *buf; - - buf = kmalloc(len, GFP_KERNEL); - if (!buf) { - ret = -ENOMEM; - goto error_pre_alloc; - } - - /* prepare transfer descriptors */ - ret = mhi_chan->gen_tre(mhi_cntrl, mhi_chan, buf, buf, - len, MHI_EOT); - if (ret) { - MHI_ERR("Chan:%d error prepare buffer\n", - mhi_chan->chan); - kfree(buf); - goto error_pre_alloc; - } - } - - read_lock_bh(&mhi_cntrl->pm_lock); - if (MHI_DB_ACCESS_VALID(mhi_cntrl->pm_state)) { - read_lock_irq(&mhi_chan->lock); - mhi_ring_chan_db(mhi_cntrl, mhi_chan); - read_unlock_irq(&mhi_chan->lock); - } - read_unlock_bh(&mhi_cntrl->pm_lock); - } - - read_lock_bh(&mhi_cntrl->pm_lock); - mhi_cntrl->wake_put(mhi_cntrl, false); - read_unlock_bh(&mhi_cntrl->pm_lock); - - mutex_unlock(&mhi_chan->mutex); - - MHI_LOG("Chan:%d successfully moved to start state\n", mhi_chan->chan); - - return 0; - -error_send_cmd: - mhi_cntrl->runtime_put(mhi_cntrl, mhi_cntrl->priv_data); - read_lock_bh(&mhi_cntrl->pm_lock); - mhi_cntrl->wake_put(mhi_cntrl, false); - read_unlock_bh(&mhi_cntrl->pm_lock); - -error_pm_state: - if (!mhi_chan->offload_ch) - mhi_deinit_chan_ctxt(mhi_cntrl, mhi_chan); - -error_init_chan: - mutex_unlock(&mhi_chan->mutex); - - return ret; - -error_pre_alloc: - - read_lock_bh(&mhi_cntrl->pm_lock); - mhi_cntrl->wake_put(mhi_cntrl, false); - read_unlock_bh(&mhi_cntrl->pm_lock); - - mutex_unlock(&mhi_chan->mutex); - __mhi_unprepare_channel(mhi_cntrl, mhi_chan); - - return ret; -} - -static void mhi_mark_stale_events(struct mhi_controller *mhi_cntrl, - struct mhi_event *mhi_event, - struct mhi_event_ctxt *er_ctxt, - int chan) -{ - struct mhi_tre *dev_rp, *local_rp; - struct mhi_ring *ev_ring; - unsigned long flags; - - MHI_LOG("Marking all events for chan:%d as stale\n", chan); - - ev_ring = &mhi_event->ring; - - /* mark all stale events related to channel as STALE event */ - spin_lock_irqsave(&mhi_event->lock, flags); - dev_rp = mhi_to_virtual(ev_ring, er_ctxt->rp); - - local_rp = ev_ring->rp; - while (dev_rp != local_rp) { - if (MHI_TRE_GET_EV_TYPE(local_rp) == - MHI_PKT_TYPE_TX_EVENT && - chan == MHI_TRE_GET_EV_CHID(local_rp)) - local_rp->dword[1] = MHI_TRE_EV_DWORD1(chan, - MHI_PKT_TYPE_STALE_EVENT); - local_rp++; - if (local_rp == (ev_ring->base + ev_ring->len)) - local_rp = ev_ring->base; - } - - - MHI_LOG("Finished marking events as stale events\n"); - spin_unlock_irqrestore(&mhi_event->lock, flags); -} - -static void mhi_reset_data_chan(struct mhi_controller *mhi_cntrl, - struct mhi_chan *mhi_chan) -{ - struct mhi_ring *buf_ring, *tre_ring; - struct mhi_result result; - - /* reset any pending buffers */ - buf_ring = &mhi_chan->buf_ring; - tre_ring = &mhi_chan->tre_ring; - result.transaction_status = -ENOTCONN; - result.bytes_xferd = 0; - while (tre_ring->rp != tre_ring->wp) { - struct mhi_buf_info *buf_info = buf_ring->rp; - - if (mhi_chan->dir == DMA_TO_DEVICE) { - if (atomic_dec_return(&mhi_cntrl->pending_pkts) == 0) - mhi_cntrl->runtime_put(mhi_cntrl, mhi_cntrl->priv_data); - } - - if (mhi_chan->dir == DMA_TO_DEVICE) - mhi_cntrl->wake_put(mhi_cntrl, false); - if (!buf_info->pre_mapped) - mhi_cntrl->unmap_single(mhi_cntrl, buf_info); - mhi_del_ring_element(mhi_cntrl, buf_ring); - mhi_del_ring_element(mhi_cntrl, tre_ring); - - if (mhi_chan->pre_alloc) { - kfree(buf_info->cb_buf); - } else { - result.buf_addr = buf_info->cb_buf; - mhi_chan->xfer_cb(mhi_chan->mhi_dev, &result); - } - } -} - -static void mhi_reset_rsc_chan(struct mhi_controller *mhi_cntrl, - struct mhi_chan *mhi_chan) -{ - struct mhi_ring *buf_ring, *tre_ring; - struct mhi_result result; - struct mhi_buf_info *buf_info; - - /* reset any pending buffers */ - buf_ring = &mhi_chan->buf_ring; - tre_ring = &mhi_chan->tre_ring; - result.transaction_status = -ENOTCONN; - result.bytes_xferd = 0; - - buf_info = buf_ring->base; - for (; (void *)buf_info < buf_ring->base + buf_ring->len; buf_info++) { - if (!buf_info->used) - continue; - - result.buf_addr = buf_info->cb_buf; - mhi_chan->xfer_cb(mhi_chan->mhi_dev, &result); - buf_info->used = false; - } -} - -void mhi_reset_chan(struct mhi_controller *mhi_cntrl, struct mhi_chan *mhi_chan) -{ - - struct mhi_event *mhi_event; - struct mhi_event_ctxt *er_ctxt; - int chan = mhi_chan->chan; - - /* nothing to reset, client don't queue buffers */ - if (mhi_chan->offload_ch) - return; - - read_lock_bh(&mhi_cntrl->pm_lock); - mhi_event = &mhi_cntrl->mhi_event[mhi_chan->er_index]; - er_ctxt = &mhi_cntrl->mhi_ctxt->er_ctxt[mhi_chan->er_index]; - - mhi_mark_stale_events(mhi_cntrl, mhi_event, er_ctxt, chan); - - if (mhi_chan->xfer_type == MHI_XFER_RSC_DMA) - mhi_reset_rsc_chan(mhi_cntrl, mhi_chan); - else - mhi_reset_data_chan(mhi_cntrl, mhi_chan); - - read_unlock_bh(&mhi_cntrl->pm_lock); - MHI_LOG("Reset complete.\n"); -} - -static void __mhi_unprepare_channel(struct mhi_controller *mhi_cntrl, - struct mhi_chan *mhi_chan) -{ - int ret; - - MHI_LOG("Entered: unprepare channel:%d\n", mhi_chan->chan); - - /* no more processing events for this channel */ - mutex_lock(&mhi_chan->mutex); - write_lock_irq(&mhi_chan->lock); - if (mhi_chan->ch_state != MHI_CH_STATE_ENABLED) { - MHI_LOG("chan:%d is already disabled\n", mhi_chan->chan); - write_unlock_irq(&mhi_chan->lock); - mutex_unlock(&mhi_chan->mutex); - return; - } - - mhi_chan->ch_state = MHI_CH_STATE_DISABLED; - write_unlock_irq(&mhi_chan->lock); - - reinit_completion(&mhi_chan->completion); - read_lock_bh(&mhi_cntrl->pm_lock); - if (MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) { - read_unlock_bh(&mhi_cntrl->pm_lock); - goto error_invalid_state; - } - - mhi_cntrl->wake_get(mhi_cntrl, false); - read_unlock_bh(&mhi_cntrl->pm_lock); - - mhi_cntrl->runtime_get(mhi_cntrl, mhi_cntrl->priv_data); - ret = mhi_send_cmd(mhi_cntrl, mhi_chan, MHI_CMD_RESET_CHAN); - if (ret) { - MHI_ERR("Failed to send reset chan cmd\n"); - goto error_completion; - } - - /* even if it fails we will still reset */ - ret = wait_for_completion_timeout(&mhi_chan->completion, - msecs_to_jiffies(mhi_cntrl->timeout_ms)); - if (!ret || mhi_chan->ccs != MHI_EV_CC_SUCCESS) - MHI_ERR("Failed to receive cmd completion, still resetting\n"); - -error_completion: - mhi_cntrl->runtime_put(mhi_cntrl, mhi_cntrl->priv_data); - read_lock_bh(&mhi_cntrl->pm_lock); - mhi_cntrl->wake_put(mhi_cntrl, false); - read_unlock_bh(&mhi_cntrl->pm_lock); - -error_invalid_state: - if (!mhi_chan->offload_ch) { - mhi_reset_chan(mhi_cntrl, mhi_chan); - mhi_deinit_chan_ctxt(mhi_cntrl, mhi_chan); - } - MHI_LOG("chan:%d successfully resetted\n", mhi_chan->chan); - mutex_unlock(&mhi_chan->mutex); -} - -int mhi_debugfs_mhi_states_show(struct seq_file *m, void *d) -{ - struct mhi_controller *mhi_cntrl = m->private; - int reg = 0; - int ret; - u32 val[4]; - - seq_printf(m, - "pm_state:%s dev_state:%s EE:%s M0:%u M2:%u M3:%u wake:%d dev_wake:%u alloc_size:%u\n", - to_mhi_pm_state_str(mhi_cntrl->pm_state), - TO_MHI_STATE_STR(mhi_cntrl->dev_state), - TO_MHI_EXEC_STR(mhi_cntrl->ee), - mhi_cntrl->M0, mhi_cntrl->M2, mhi_cntrl->M3, - mhi_cntrl->wake_set, - atomic_read(&mhi_cntrl->dev_wake), - atomic_read(&mhi_cntrl->alloc_size)); - - seq_printf(m, - "mhi_state:%s exec_env:%s\n", - TO_MHI_STATE_STR(mhi_get_mhi_state(mhi_cntrl)), TO_MHI_EXEC_STR(mhi_get_exec_env(mhi_cntrl))); - - seq_printf(m, "dump mhi reg addr:%p\n", mhi_cntrl->regs); - for (reg = 0; reg < 0x100; reg+=16) { - val[0] = val[1] = val[2] = val[3] = 0xFFFFFFFF; - ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->regs, reg+0, &val[0]); - ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->regs, reg+4, &val[1]); - ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->regs, reg+8, &val[2]); - ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->regs, reg+12, &val[3]); - seq_printf(m, "%02x: %08x %08x %08x %08x\n", reg, val[0], val[1], val[2], val[3]); - } - - seq_printf(m, "dump bhi reg addr:%p\n", mhi_cntrl->bhi); - for (reg = 0; reg < 0x100; reg+=16) { - val[0] = val[1] = val[2] = val[3] = 0xFFFFFFFF; - ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->bhi, reg+0, &val[0]); - ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->bhi, reg+4, &val[1]); - ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->bhi, reg+8, &val[2]); - ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->bhi, reg+12, &val[3]); - seq_printf(m, "%02x: %08x %08x %08x %08x\n", reg, val[0], val[1], val[2], val[3]); - } - - return 0; -} - -int mhi_debugfs_mhi_event_show(struct seq_file *m, void *d) -{ - struct mhi_controller *mhi_cntrl = m->private; - struct mhi_event *mhi_event; - struct mhi_event_ctxt *er_ctxt; - - int i; - - er_ctxt = mhi_cntrl->mhi_ctxt->er_ctxt; - mhi_event = mhi_cntrl->mhi_event; - for (i = 0; i < mhi_cntrl->total_ev_rings; i++, er_ctxt++, - mhi_event++) { - struct mhi_ring *ring = &mhi_event->ring; - - if (mhi_event->offload_ev) { - seq_printf(m, "Index:%d offload event ring\n", i); - } else { - seq_printf(m, - "Index:%d modc:%d modt:%d base:0x%0llx len:0x%llx", - i, er_ctxt->intmodc, er_ctxt->intmodt, - er_ctxt->rbase, er_ctxt->rlen); - seq_printf(m, - " rp:0x%llx wp:0x%llx local_rp:0x%llx local_wp:0x%llx db:0x%llx\n", - er_ctxt->rp, er_ctxt->wp, - (unsigned long long)mhi_to_physical(ring, ring->rp), - (unsigned long long)mhi_to_physical(ring, ring->wp), - (unsigned long long)mhi_event->db_cfg.db_val); - seq_printf(m, "used:%u\n", mhi_event->used_elements); - -#ifdef DEBUG_CHAN100_DB - if (mhi_event->mhi_chan && mhi_event->chan == 100) { - struct mhi_tre *tre = (struct mhi_tre *)ring->base; - size_t j; - - for (j = 0; j < ring->elements; j++, tre++) { - seq_printf(m, - "%08x: %llx, %08x, %08x\n", - (unsigned int)(j*sizeof(struct mhi_tre)), - tre->ptr, tre->dword[0], tre->dword[1]); - } - } -#endif - } - } - - return 0; -} - -int mhi_debugfs_mhi_chan_show(struct seq_file *m, void *d) -{ - struct mhi_controller *mhi_cntrl = m->private; - struct mhi_chan *mhi_chan; - struct mhi_chan_ctxt *chan_ctxt; - int i; - - mhi_chan = mhi_cntrl->mhi_chan; - chan_ctxt = mhi_cntrl->mhi_ctxt->chan_ctxt; - for (i = 0; i < mhi_cntrl->max_chan; i++, chan_ctxt++, mhi_chan++) { - struct mhi_ring *ring = &mhi_chan->tre_ring; - - if (mhi_chan->ch_state == MHI_CH_STATE_DISABLED) - continue; - - if (mhi_chan->offload_ch) { - seq_printf(m, "%s(%u) offload channel\n", - mhi_chan->name, mhi_chan->chan); - } else if (mhi_chan->mhi_dev) { - seq_printf(m, - "%s(%u) state:0x%x brstmode:0x%x pllcfg:0x%x type:0x%x erindex:%u", - mhi_chan->name, mhi_chan->chan, - chan_ctxt->chstate, chan_ctxt->brstmode, - chan_ctxt->pollcfg, chan_ctxt->chtype, - chan_ctxt->erindex); - seq_printf(m, - " base:0x%llx len:0x%llx rp:%llx wp:0x%llx local_rp:0x%llx local_wp:0x%llx db:0x%llx\n", - chan_ctxt->rbase, chan_ctxt->rlen, - chan_ctxt->rp, chan_ctxt->wp, - (unsigned long long)mhi_to_physical(ring, ring->rp), - (unsigned long long)mhi_to_physical(ring, ring->wp), - (unsigned long long)mhi_chan->db_cfg.db_val); - seq_printf(m, "used:%u, EOB:%u, EOT:%u, OOB:%u, DB_MODE:%u\n", mhi_chan->used_elements, - mhi_chan->used_events[MHI_EV_CC_EOB], mhi_chan->used_events[MHI_EV_CC_EOT], - mhi_chan->used_events[MHI_EV_CC_OOB],mhi_chan->used_events[MHI_EV_CC_DB_MODE]); - -#ifdef DEBUG_CHAN100_DB - if (mhi_chan->chan == 100) { - unsigned int n = 0; - seq_printf(m, "chan100_seq = %04x\n", atomic_read(&chan100_seq)%CHAN100_SIZE); - for (n = 0; n < CHAN100_SIZE; n++) { - seq_printf(m, "%04x: %08x\n", n, chan100_t[n]); - } - } -#endif - -#if 0 - if (ring->base && /*(i&1) &&*/ (i < MHI_CLIENT_IP_HW_0_OUT)) { - struct mhi_tre *tre = (struct mhi_tre *)ring->base; - size_t e; - - for (e = 0; e < ring->elements; e++, tre++) { - seq_printf(m, "[%03d] %llx, %08x, %08x\n", i, tre->ptr, tre->dword[0], tre->dword[1]); - } - } -#endif - } - } - - return 0; -} - -/* move channel to start state */ -int mhi_prepare_for_transfer(struct mhi_device *mhi_dev) -{ - int ret, dir; - struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; - struct mhi_chan *mhi_chan; - - for (dir = 0; dir < 2; dir++) { - mhi_chan = dir ? mhi_dev->dl_chan : mhi_dev->ul_chan; - - if (!mhi_chan) - continue; - - ret = __mhi_prepare_channel(mhi_cntrl, mhi_chan); - if (ret) { - MHI_ERR("Error moving chan %s,%d to START state\n", - mhi_chan->name, mhi_chan->chan); - goto error_open_chan; - } - - if (mhi_dev->dl_chan == mhi_dev->ul_chan) { - break; - } - } - - return 0; - -error_open_chan: - for (--dir; dir >= 0; dir--) { - mhi_chan = dir ? mhi_dev->dl_chan : mhi_dev->ul_chan; - - if (!mhi_chan) - continue; - - __mhi_unprepare_channel(mhi_cntrl, mhi_chan); - } - - return ret; -} -EXPORT_SYMBOL(mhi_prepare_for_transfer); - -void mhi_unprepare_from_transfer(struct mhi_device *mhi_dev) -{ - struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; - struct mhi_chan *mhi_chan; - int dir; - - for (dir = 0; dir < 2; dir++) { - mhi_chan = dir ? mhi_dev->ul_chan : mhi_dev->dl_chan; - - if (!mhi_chan) - continue; - - __mhi_unprepare_channel(mhi_cntrl, mhi_chan); - - if (mhi_dev->dl_chan == mhi_dev->ul_chan) { - break; - } - } -} -EXPORT_SYMBOL(mhi_unprepare_from_transfer); - -int mhi_get_no_free_descriptors(struct mhi_device *mhi_dev, - enum dma_data_direction dir) -{ - struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; - struct mhi_chan *mhi_chan = (dir == DMA_TO_DEVICE) ? - mhi_dev->ul_chan : mhi_dev->dl_chan; - struct mhi_ring *tre_ring = &mhi_chan->tre_ring; - - if (mhi_chan->offload_ch) - return 0; - - return get_nr_avail_ring_elements(mhi_cntrl, tre_ring); -} -EXPORT_SYMBOL(mhi_get_no_free_descriptors); - -#if (LINUX_VERSION_CODE < KERNEL_VERSION( 5,3,0 )) -static int __mhi_bdf_to_controller(struct device *dev, void *tmp) -{ - struct mhi_device *mhi_dev = to_mhi_device(dev); - struct mhi_device *match = tmp; - - /* return any none-zero value if match */ - if (mhi_dev->dev_type == MHI_CONTROLLER_TYPE && - mhi_dev->domain == match->domain && mhi_dev->bus == match->bus && - mhi_dev->slot == match->slot && mhi_dev->dev_id == match->dev_id) - return 1; - - return 0; -} -#else -static int __mhi_bdf_to_controller(struct device *dev, const void *tmp) -{ - struct mhi_device *mhi_dev = to_mhi_device(dev); - const struct mhi_device *match = tmp; - - /* return any none-zero value if match */ - if (mhi_dev->dev_type == MHI_CONTROLLER_TYPE && - mhi_dev->domain == match->domain && mhi_dev->bus == match->bus && - mhi_dev->slot == match->slot && mhi_dev->dev_id == match->dev_id) - return 1; - - return 0; -} -#endif - -struct mhi_controller *mhi_bdf_to_controller(u32 domain, - u32 bus, - u32 slot, - u32 dev_id) -{ - struct mhi_device tmp, *mhi_dev; - struct device *dev; - - tmp.domain = domain; - tmp.bus = bus; - tmp.slot = slot; - tmp.dev_id = dev_id; - - dev = bus_find_device(&mhi_bus_type, NULL, &tmp, - __mhi_bdf_to_controller); - if (!dev) - return NULL; - - mhi_dev = to_mhi_device(dev); - - return mhi_dev->mhi_cntrl; -} -EXPORT_SYMBOL(mhi_bdf_to_controller); - -int mhi_poll(struct mhi_device *mhi_dev, - u32 budget) -{ - struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; - struct mhi_chan *mhi_chan = mhi_dev->dl_chan; - struct mhi_event *mhi_event = &mhi_cntrl->mhi_event[mhi_chan->er_index]; - int ret; - - spin_lock_bh(&mhi_event->lock); - ret = mhi_event->process_event(mhi_cntrl, mhi_event, budget); - spin_unlock_bh(&mhi_event->lock); - - return ret; -} -EXPORT_SYMBOL(mhi_poll); - -int mhi_get_remote_time_sync(struct mhi_device *mhi_dev, - u64 *t_host, - u64 *t_dev) -{ - struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; - struct mhi_timesync *mhi_tsync = mhi_cntrl->mhi_tsync; - int ret; - - /* not all devices support time feature */ - if (!mhi_tsync) - return -EIO; - - /* bring to M0 state */ - ret = __mhi_device_get_sync(mhi_cntrl); - if (ret) - return ret; - - mutex_lock(&mhi_tsync->lpm_mutex); - - read_lock_bh(&mhi_cntrl->pm_lock); - if (unlikely(MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state))) { - MHI_ERR("MHI is not in active state, pm_state:%s\n", - to_mhi_pm_state_str(mhi_cntrl->pm_state)); - ret = -EIO; - goto error_invalid_state; - } - - /* disable link level low power modes */ - ret = mhi_cntrl->lpm_disable(mhi_cntrl, mhi_cntrl->priv_data); - if (ret) - goto error_invalid_state; - - /* - * time critical code to fetch device times, - * delay between these two steps should be - * deterministic as possible. - */ - preempt_disable(); - local_irq_disable(); - - *t_host = mhi_cntrl->time_get(mhi_cntrl, mhi_cntrl->priv_data); - *t_dev = readq_relaxed_no_log(mhi_tsync->time_reg); - - local_irq_enable(); - preempt_enable(); - - mhi_cntrl->lpm_enable(mhi_cntrl, mhi_cntrl->priv_data); - -error_invalid_state: - mhi_cntrl->wake_put(mhi_cntrl, false); - read_unlock_bh(&mhi_cntrl->pm_lock); - mutex_unlock(&mhi_tsync->lpm_mutex); - - return ret; -} -EXPORT_SYMBOL(mhi_get_remote_time_sync); - -/** - * mhi_get_remote_time - Get external modem time relative to host time - * Trigger event to capture modem time, also capture host time so client - * can do a relative drift comparision. - * Recommended only tsync device calls this method and do not call this - * from atomic context - * @mhi_dev: Device associated with the channels - * @sequence:unique sequence id track event - * @cb_func: callback function to call back - */ -int mhi_get_remote_time(struct mhi_device *mhi_dev, - u32 sequence, - void (*cb_func)(struct mhi_device *mhi_dev, - u32 sequence, - u64 local_time, - u64 remote_time)) -{ - struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; - struct mhi_timesync *mhi_tsync = mhi_cntrl->mhi_tsync; - struct tsync_node *tsync_node; - int ret; - - /* not all devices support time feature */ - if (!mhi_tsync) - return -EIO; - - /* tsync db can only be rung in M0 state */ - ret = __mhi_device_get_sync(mhi_cntrl); - if (ret) - return ret; - - /* - * technically we can use GFP_KERNEL, but wants to avoid - * # of times scheduling out - */ - tsync_node = kzalloc(sizeof(*tsync_node), GFP_ATOMIC); - if (!tsync_node) { - ret = -ENOMEM; - goto error_no_mem; - } - - tsync_node->sequence = sequence; - tsync_node->cb_func = cb_func; - tsync_node->mhi_dev = mhi_dev; - - /* disable link level low power modes */ - mhi_cntrl->lpm_disable(mhi_cntrl, mhi_cntrl->priv_data); - - read_lock_bh(&mhi_cntrl->pm_lock); - if (unlikely(MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state))) { - MHI_ERR("MHI is not in active state, pm_state:%s\n", - to_mhi_pm_state_str(mhi_cntrl->pm_state)); - ret = -EIO; - goto error_invalid_state; - } - - spin_lock_irq(&mhi_tsync->lock); - list_add_tail(&tsync_node->node, &mhi_tsync->head); - spin_unlock_irq(&mhi_tsync->lock); - - /* - * time critical code, delay between these two steps should be - * deterministic as possible. - */ - preempt_disable(); - local_irq_disable(); - - tsync_node->local_time = - mhi_cntrl->time_get(mhi_cntrl, mhi_cntrl->priv_data); - writel_relaxed_no_log(tsync_node->sequence, mhi_tsync->db); - /* write must go thru immediately */ - wmb(); - - local_irq_enable(); - preempt_enable(); - - ret = 0; - -error_invalid_state: - if (ret) - kfree(tsync_node); - read_unlock_bh(&mhi_cntrl->pm_lock); - mhi_cntrl->lpm_enable(mhi_cntrl, mhi_cntrl->priv_data); - -error_no_mem: - read_lock_bh(&mhi_cntrl->pm_lock); - mhi_cntrl->wake_put(mhi_cntrl, false); - read_unlock_bh(&mhi_cntrl->pm_lock); - - return ret; -} -EXPORT_SYMBOL(mhi_get_remote_time); - -void mhi_debug_reg_dump(struct mhi_controller *mhi_cntrl) -{ - enum mhi_dev_state state; - enum mhi_ee ee; - int i, ret; - u32 val = 0; - void __iomem *mhi_base = mhi_cntrl->regs; - void __iomem *bhi_base = mhi_cntrl->bhi; - void __iomem *bhie_base = mhi_cntrl->bhie; - void __iomem *wake_db = mhi_cntrl->wake_db; - struct { - const char *name; - int offset; - void *base; - } debug_reg[] = { - { "MHI_CNTRL", MHICTRL, mhi_base}, - { "MHI_STATUS", MHISTATUS, mhi_base}, - { "MHI_WAKE_DB", 0, wake_db}, - { "BHI_EXECENV", BHI_EXECENV, bhi_base}, - { "BHI_STATUS", BHI_STATUS, bhi_base}, - { "BHI_ERRCODE", BHI_ERRCODE, bhi_base}, - { "BHI_ERRDBG1", BHI_ERRDBG1, bhi_base}, - { "BHI_ERRDBG2", BHI_ERRDBG2, bhi_base}, - { "BHI_ERRDBG3", BHI_ERRDBG3, bhi_base}, - { "BHIE_TXVEC_DB", BHIE_TXVECDB_OFFS, bhie_base}, - { "BHIE_TXVEC_STATUS", BHIE_TXVECSTATUS_OFFS, bhie_base}, - { "BHIE_RXVEC_DB", BHIE_RXVECDB_OFFS, bhie_base}, - { "BHIE_RXVEC_STATUS", BHIE_RXVECSTATUS_OFFS, bhie_base}, - { NULL }, - }; - - MHI_LOG("host pm_state:%s dev_state:%s ee:%s\n", - to_mhi_pm_state_str(mhi_cntrl->pm_state), - TO_MHI_STATE_STR(mhi_cntrl->dev_state), - TO_MHI_EXEC_STR(mhi_cntrl->ee)); - - state = mhi_get_mhi_state(mhi_cntrl); - ee = mhi_get_exec_env(mhi_cntrl); - - MHI_LOG("device ee:%s dev_state:%s\n", TO_MHI_EXEC_STR(ee), - TO_MHI_STATE_STR(state)); - - for (i = 0; debug_reg[i].name; i++) { - ret = mhi_read_reg(mhi_cntrl, debug_reg[i].base, - debug_reg[i].offset, &val); - MHI_LOG("reg:%s val:0x%x, ret:%d\n", debug_reg[i].name, val, - ret); - } -} -EXPORT_SYMBOL(mhi_debug_reg_dump); diff --git a/quectel_MHI/src/core/mhi_pm.c b/quectel_MHI/src/core/mhi_pm.c deleted file mode 100644 index 117a600..0000000 --- a/quectel_MHI/src/core/mhi_pm.c +++ /dev/null @@ -1,1255 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved. */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "mhi.h" -#include "mhi_internal.h" - -/* - * Not all MHI states transitions are sync transitions. Linkdown, SSR, and - * shutdown can happen anytime asynchronously. This function will transition to - * new state only if we're allowed to transitions. - * - * Priority increase as we go down, example while in any states from L0, start - * state from L1, L2, or L3 can be set. Notable exception to this rule is state - * DISABLE. From DISABLE state we can transition to only POR or state. Also - * for example while in L2 state, user cannot jump back to L1 or L0 states. - * Valid transitions: - * L0: DISABLE <--> POR - * POR <--> POR - * POR -> M0 -> M2 --> M0 - * POR -> FW_DL_ERR - * FW_DL_ERR <--> FW_DL_ERR - * M0 -> FW_DL_ERR - * M0 -> M3_ENTER -> M3 -> M3_EXIT --> M0 - * L1: SYS_ERR_DETECT -> SYS_ERR_PROCESS --> POR - * L2: SHUTDOWN_PROCESS -> DISABLE - * L3: LD_ERR_FATAL_DETECT <--> LD_ERR_FATAL_DETECT - * LD_ERR_FATAL_DETECT -> SHUTDOWN_PROCESS - */ -static struct mhi_pm_transitions const mhi_state_transitions[] = { - /* L0 States */ - { - MHI_PM_DISABLE, - MHI_PM_POR - }, - { - MHI_PM_POR, - MHI_PM_POR | MHI_PM_DISABLE | MHI_PM_M0 | - MHI_PM_SYS_ERR_DETECT | MHI_PM_SHUTDOWN_PROCESS | - MHI_PM_LD_ERR_FATAL_DETECT | MHI_PM_FW_DL_ERR - }, - { - MHI_PM_M0, - MHI_PM_M2 | MHI_PM_M3_ENTER | MHI_PM_SYS_ERR_DETECT | - MHI_PM_SHUTDOWN_PROCESS | MHI_PM_LD_ERR_FATAL_DETECT | - MHI_PM_FW_DL_ERR - }, - { - MHI_PM_M2, - MHI_PM_M0 | MHI_PM_SYS_ERR_DETECT | MHI_PM_SHUTDOWN_PROCESS | - MHI_PM_LD_ERR_FATAL_DETECT - }, - { - MHI_PM_M3_ENTER, - MHI_PM_M3 | MHI_PM_SYS_ERR_DETECT | MHI_PM_SHUTDOWN_PROCESS | - MHI_PM_LD_ERR_FATAL_DETECT - }, - { - MHI_PM_M3, - MHI_PM_M3_EXIT | MHI_PM_SYS_ERR_DETECT | - MHI_PM_SHUTDOWN_PROCESS | MHI_PM_LD_ERR_FATAL_DETECT - }, - { - MHI_PM_M3_EXIT, - MHI_PM_M0 | MHI_PM_SYS_ERR_DETECT | MHI_PM_SHUTDOWN_PROCESS | - MHI_PM_LD_ERR_FATAL_DETECT - }, - { - MHI_PM_FW_DL_ERR, - MHI_PM_FW_DL_ERR | MHI_PM_SYS_ERR_DETECT | - MHI_PM_SHUTDOWN_PROCESS | MHI_PM_LD_ERR_FATAL_DETECT - }, - /* L1 States */ - { - MHI_PM_SYS_ERR_DETECT, - MHI_PM_SYS_ERR_PROCESS | MHI_PM_SHUTDOWN_PROCESS | - MHI_PM_LD_ERR_FATAL_DETECT - }, - { - MHI_PM_SYS_ERR_PROCESS, - MHI_PM_POR | MHI_PM_SHUTDOWN_PROCESS | - MHI_PM_LD_ERR_FATAL_DETECT - }, - /* L2 States */ - { - MHI_PM_SHUTDOWN_PROCESS, - MHI_PM_DISABLE | MHI_PM_LD_ERR_FATAL_DETECT - }, - /* L3 States */ - { - MHI_PM_LD_ERR_FATAL_DETECT, - MHI_PM_LD_ERR_FATAL_DETECT | MHI_PM_SHUTDOWN_PROCESS - }, -}; - -enum MHI_PM_STATE __must_check mhi_tryset_pm_state( - struct mhi_controller *mhi_cntrl, - enum MHI_PM_STATE state) -{ - unsigned long cur_state = mhi_cntrl->pm_state; - int index = find_last_bit(&cur_state, 32); - - if (unlikely(index >= ARRAY_SIZE(mhi_state_transitions))) { - MHI_CRITICAL("cur_state:%s is not a valid pm_state\n", - to_mhi_pm_state_str(cur_state)); - return cur_state; - } - - if (unlikely(mhi_state_transitions[index].from_state != cur_state)) { - MHI_ERR("index:%u cur_state:%s != actual_state: %s\n", - index, to_mhi_pm_state_str(cur_state), - to_mhi_pm_state_str - (mhi_state_transitions[index].from_state)); - return cur_state; - } - - if (unlikely(!(mhi_state_transitions[index].to_states & state))) { - MHI_LOG( - "Not allowing pm state transition from:%s to:%s state\n", - to_mhi_pm_state_str(cur_state), - to_mhi_pm_state_str(state)); - return cur_state; - } - - MHI_LOG("Transition to pm state from:%s to:%s\n", - to_mhi_pm_state_str(cur_state), to_mhi_pm_state_str(state)); - - mhi_cntrl->pm_state = state; - return mhi_cntrl->pm_state; -} - -void mhi_set_mhi_state(struct mhi_controller *mhi_cntrl, - enum mhi_dev_state state) -{ - if (state == MHI_STATE_RESET) { - mhi_write_reg_field(mhi_cntrl, mhi_cntrl->regs, MHICTRL, - MHICTRL_RESET_MASK, MHICTRL_RESET_SHIFT, 1); - } else { - mhi_write_reg_field(mhi_cntrl, mhi_cntrl->regs, MHICTRL, - MHICTRL_MHISTATE_MASK, MHICTRL_MHISTATE_SHIFT, state); - } -} - -/* set device wake */ -void mhi_assert_dev_wake(struct mhi_controller *mhi_cntrl, bool force) -{ - unsigned long flags; - -#if 1 //carl.yin 20200907, according to WIN driver, only in M2 state, need to assert, and do not need to deassert - if (mhi_cntrl->dev_state == MHI_STATE_M2) { - spin_lock_irqsave(&mhi_cntrl->wlock, flags); - mhi_write_db(mhi_cntrl, mhi_cntrl->wake_db, 1); - spin_unlock_irqrestore(&mhi_cntrl->wlock, flags); - } - return; -#endif - - /* if set, regardless of count set the bit if not set */ - if (unlikely(force)) { - spin_lock_irqsave(&mhi_cntrl->wlock, flags); - atomic_inc(&mhi_cntrl->dev_wake); - if (MHI_WAKE_DB_FORCE_SET_VALID(mhi_cntrl->pm_state) && - !mhi_cntrl->wake_set) { - mhi_write_db(mhi_cntrl, mhi_cntrl->wake_db, 1); - mhi_cntrl->wake_set = true; - } - spin_unlock_irqrestore(&mhi_cntrl->wlock, flags); - } else { - /* if resources requested already, then increment and exit */ - if (likely(atomic_add_unless(&mhi_cntrl->dev_wake, 1, 0))) - return; - - spin_lock_irqsave(&mhi_cntrl->wlock, flags); - if ((atomic_inc_return(&mhi_cntrl->dev_wake) == 1) && - MHI_WAKE_DB_SET_VALID(mhi_cntrl->pm_state) && - !mhi_cntrl->wake_set) { - mhi_write_db(mhi_cntrl, mhi_cntrl->wake_db, 1); - mhi_cntrl->wake_set = true; - } - spin_unlock_irqrestore(&mhi_cntrl->wlock, flags); - } -} - -/* clear device wake */ -void mhi_deassert_dev_wake(struct mhi_controller *mhi_cntrl, bool override) -{ - unsigned long flags; - -#if 1 //carl.yin 20200907, according to WIN driver, only in M2 state, need to assert, and do not need to deassert - return; -#endif - -#if 1 //Add by Quectel - if (atomic_read(&mhi_cntrl->dev_wake) == 0) - return; -#endif - - MHI_ASSERT(atomic_read(&mhi_cntrl->dev_wake) == 0, "dev_wake == 0"); - - /* resources not dropping to 0, decrement and exit */ - if (likely(atomic_add_unless(&mhi_cntrl->dev_wake, -1, 1))) - return; - - spin_lock_irqsave(&mhi_cntrl->wlock, flags); - if ((atomic_dec_return(&mhi_cntrl->dev_wake) == 0) && - MHI_WAKE_DB_CLEAR_VALID(mhi_cntrl->pm_state) && !override && - mhi_cntrl->wake_set) { - mhi_write_db(mhi_cntrl, mhi_cntrl->wake_db, 0); - mhi_cntrl->wake_set = false; - } - spin_unlock_irqrestore(&mhi_cntrl->wlock, flags); -} - -int mhi_ready_state_transition(struct mhi_controller *mhi_cntrl) -{ - void __iomem *base = mhi_cntrl->regs; - u32 reset = 1, ready = 0; - struct mhi_event *mhi_event; - enum MHI_PM_STATE cur_state; - int ret, i; - - MHI_LOG("Waiting to enter READY state\n"); - - /* wait for RESET to be cleared and READY bit to be set */ - wait_event_timeout(mhi_cntrl->state_event, - MHI_PM_IN_FATAL_STATE(mhi_cntrl->pm_state) || - mhi_read_reg_field(mhi_cntrl, base, MHICTRL, - MHICTRL_RESET_MASK, - MHICTRL_RESET_SHIFT, &reset) || - mhi_read_reg_field(mhi_cntrl, base, MHISTATUS, - MHISTATUS_READY_MASK, - MHISTATUS_READY_SHIFT, &ready) || - (!reset && ready), - msecs_to_jiffies(mhi_cntrl->timeout_ms)); - - /* device enter into error state */ - if (MHI_PM_IN_FATAL_STATE(mhi_cntrl->pm_state)) - return -EIO; - - /* device did not transition to ready state */ - if (reset || !ready) - return -ETIMEDOUT; - - MHI_LOG("Device in READY State\n"); - write_lock_irq(&mhi_cntrl->pm_lock); - cur_state = mhi_tryset_pm_state(mhi_cntrl, MHI_PM_POR); - mhi_cntrl->dev_state = MHI_STATE_READY; - write_unlock_irq(&mhi_cntrl->pm_lock); - - if (cur_state != MHI_PM_POR) { - MHI_ERR("Error moving to state %s from %s\n", - to_mhi_pm_state_str(MHI_PM_POR), - to_mhi_pm_state_str(cur_state)); - return -EIO; - } - read_lock_bh(&mhi_cntrl->pm_lock); - if (!MHI_REG_ACCESS_VALID(mhi_cntrl->pm_state)) - goto error_mmio; - - ret = mhi_init_mmio(mhi_cntrl); - if (ret) { - MHI_ERR("Error programming mmio registers\n"); - goto error_mmio; - } - - /* add elements to all sw event rings */ - mhi_event = mhi_cntrl->mhi_event; - for (i = 0; i < mhi_cntrl->total_ev_rings; i++, mhi_event++) { - struct mhi_ring *ring = &mhi_event->ring; - - if (mhi_event->offload_ev || mhi_event->hw_ring) - continue; - - ring->wp = ring->base + ring->len - ring->el_size; - *ring->ctxt_wp = ring->iommu_base + ring->len - ring->el_size; - /* needs to update to all cores */ - smp_wmb(); - - /* ring the db for event rings */ - spin_lock_irq(&mhi_event->lock); - mhi_ring_er_db(mhi_event); - spin_unlock_irq(&mhi_event->lock); - } - - /* set device into M0 state */ - mhi_set_mhi_state(mhi_cntrl, MHI_STATE_M0); - read_unlock_bh(&mhi_cntrl->pm_lock); - - return 0; - -error_mmio: - read_unlock_bh(&mhi_cntrl->pm_lock); - - return -EIO; -} - -int mhi_pm_m0_transition(struct mhi_controller *mhi_cntrl) -{ - enum MHI_PM_STATE cur_state; - struct mhi_chan *mhi_chan; - int i; - - MHI_LOG("Entered With State:%s PM_STATE:%s\n", - TO_MHI_STATE_STR(mhi_cntrl->dev_state), - to_mhi_pm_state_str(mhi_cntrl->pm_state)); - - write_lock_irq(&mhi_cntrl->pm_lock); - mhi_cntrl->dev_state = MHI_STATE_M0; - cur_state = mhi_tryset_pm_state(mhi_cntrl, MHI_PM_M0); - write_unlock_irq(&mhi_cntrl->pm_lock); - if (unlikely(cur_state != MHI_PM_M0)) { - MHI_ERR("Failed to transition to state %s from %s\n", - to_mhi_pm_state_str(MHI_PM_M0), - to_mhi_pm_state_str(cur_state)); - return -EIO; - } - mhi_cntrl->M0++; - read_lock_bh(&mhi_cntrl->pm_lock); - mhi_cntrl->wake_get(mhi_cntrl, false); - - /* ring all event rings and CMD ring only if we're in mission mode */ - if (MHI_IN_MISSION_MODE(mhi_cntrl->ee)) { - struct mhi_event *mhi_event = mhi_cntrl->mhi_event; - struct mhi_cmd *mhi_cmd = - &mhi_cntrl->mhi_cmd[PRIMARY_CMD_RING]; - - for (i = 0; i < mhi_cntrl->total_ev_rings; i++, mhi_event++) { - if (mhi_event->offload_ev) - continue; - - spin_lock_irq(&mhi_event->lock); - mhi_ring_er_db(mhi_event); - spin_unlock_irq(&mhi_event->lock); - } - - /* only ring primary cmd ring */ - spin_lock_irq(&mhi_cmd->lock); - if (mhi_cmd->ring.rp != mhi_cmd->ring.wp) - mhi_ring_cmd_db(mhi_cntrl, mhi_cmd); - spin_unlock_irq(&mhi_cmd->lock); - } - - /* ring channel db registers */ - mhi_chan = mhi_cntrl->mhi_chan; - for (i = 0; i < mhi_cntrl->max_chan; i++, mhi_chan++) { - struct mhi_ring *tre_ring = &mhi_chan->tre_ring; - - write_lock_irq(&mhi_chan->lock); - if (mhi_chan->db_cfg.reset_req) - mhi_chan->db_cfg.db_mode = true; - - /* only ring DB if ring is not empty */ - if (tre_ring->base && tre_ring->wp != tre_ring->rp) - mhi_ring_chan_db(mhi_cntrl, mhi_chan); - write_unlock_irq(&mhi_chan->lock); - } - - mhi_cntrl->wake_put(mhi_cntrl, false); - read_unlock_bh(&mhi_cntrl->pm_lock); - wake_up_all(&mhi_cntrl->state_event); - MHI_VERB("Exited\n"); - - return 0; -} - -void mhi_pm_m1_transition(struct mhi_controller *mhi_cntrl) -{ - enum MHI_PM_STATE state; - - write_lock_irq(&mhi_cntrl->pm_lock); - /* if it fails, means we transition to M3 */ - state = mhi_tryset_pm_state(mhi_cntrl, MHI_PM_M2); - if (state == MHI_PM_M2) { - MHI_VERB("Entered M2 State\n"); - mhi_set_mhi_state(mhi_cntrl, MHI_STATE_M2); - mhi_cntrl->dev_state = MHI_STATE_M2; - mhi_cntrl->M2++; - - write_unlock_irq(&mhi_cntrl->pm_lock); - wake_up_all(&mhi_cntrl->state_event); - - /* transfer pending, exit M2 immediately */ - if (unlikely(atomic_read(&mhi_cntrl->dev_wake))) { - MHI_VERB("Exiting M2 Immediately, count:%d\n", - atomic_read(&mhi_cntrl->dev_wake)); - read_lock_bh(&mhi_cntrl->pm_lock); - mhi_cntrl->wake_get(mhi_cntrl, true); - mhi_cntrl->wake_put(mhi_cntrl, false); - read_unlock_bh(&mhi_cntrl->pm_lock); - } else { - mhi_cntrl->status_cb(mhi_cntrl, mhi_cntrl->priv_data, - MHI_CB_IDLE); - } - } else { - write_unlock_irq(&mhi_cntrl->pm_lock); - } -} - -int mhi_pm_m3_transition(struct mhi_controller *mhi_cntrl) -{ - enum MHI_PM_STATE state; - - write_lock_irq(&mhi_cntrl->pm_lock); - mhi_cntrl->dev_state = MHI_STATE_M3; - state = mhi_tryset_pm_state(mhi_cntrl, MHI_PM_M3); - write_unlock_irq(&mhi_cntrl->pm_lock); - if (state != MHI_PM_M3) { - MHI_ERR("Failed to transition to state %s from %s\n", - to_mhi_pm_state_str(MHI_PM_M3), - to_mhi_pm_state_str(mhi_cntrl->pm_state)); - return -EIO; - } - wake_up_all(&mhi_cntrl->state_event); - mhi_cntrl->M3++; - - MHI_LOG("Entered mhi_state:%s pm_state:%s\n", - TO_MHI_STATE_STR(mhi_cntrl->dev_state), - to_mhi_pm_state_str(mhi_cntrl->pm_state)); - return 0; -} - -static int mhi_pm_mission_mode_transition(struct mhi_controller *mhi_cntrl) -{ - int i, ret; - struct mhi_event *mhi_event; - - MHI_LOG("Processing Mission Mode Transition\n"); - mhi_cntrl->status_cb(mhi_cntrl, mhi_cntrl->priv_data, MHI_CB_EE_MISSION_MODE); - - /* force MHI to be in M0 state before continuing */ - ret = __mhi_device_get_sync(mhi_cntrl); - if (ret) - return ret; - - ret = -EIO; - - write_lock_irq(&mhi_cntrl->pm_lock); - if (MHI_REG_ACCESS_VALID(mhi_cntrl->pm_state)) - mhi_cntrl->ee = mhi_get_exec_env(mhi_cntrl); - write_unlock_irq(&mhi_cntrl->pm_lock); - - read_lock_bh(&mhi_cntrl->pm_lock); - if (!MHI_IN_MISSION_MODE(mhi_cntrl->ee)) - goto error_mission_mode; - - wake_up_all(&mhi_cntrl->state_event); - - /* add elements to all HW event rings */ - if (MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) - goto error_mission_mode; - - mhi_event = mhi_cntrl->mhi_event; - for (i = 0; i < mhi_cntrl->total_ev_rings; i++, mhi_event++) { - struct mhi_ring *ring = &mhi_event->ring; - - if (mhi_event->offload_ev || !mhi_event->hw_ring) - continue; - - ring->wp = ring->base + ring->len - ring->el_size; - *ring->ctxt_wp = ring->iommu_base + ring->len - ring->el_size; - /* all ring updates must get updated immediately */ - smp_wmb(); - - spin_lock_irq(&mhi_event->lock); - if (MHI_DB_ACCESS_VALID(mhi_cntrl->pm_state)) - mhi_ring_er_db(mhi_event); - spin_unlock_irq(&mhi_event->lock); - - } - - read_unlock_bh(&mhi_cntrl->pm_lock); - - /* setup support for time sync */ - mhi_init_timesync(mhi_cntrl); - - MHI_LOG("Adding new devices\n"); - - /* add supported devices */ - mhi_create_devices(mhi_cntrl); - - ret = 0; - - read_lock_bh(&mhi_cntrl->pm_lock); - -error_mission_mode: - mhi_cntrl->wake_put(mhi_cntrl, false); - read_unlock_bh(&mhi_cntrl->pm_lock); - - MHI_LOG("Exit with ret:%d\n", ret); - - return ret; -} - -/* handles both sys_err and shutdown transitions */ -static void mhi_pm_disable_transition(struct mhi_controller *mhi_cntrl, - enum MHI_PM_STATE transition_state) -{ - enum MHI_PM_STATE cur_state, prev_state; - struct mhi_event *mhi_event; - struct mhi_cmd_ctxt *cmd_ctxt; - struct mhi_cmd *mhi_cmd; - struct mhi_event_ctxt *er_ctxt; - int ret, i; - - MHI_LOG("Enter with from pm_state:%s MHI_STATE:%s to pm_state:%s\n", - to_mhi_pm_state_str(mhi_cntrl->pm_state), - TO_MHI_STATE_STR(mhi_cntrl->dev_state), - to_mhi_pm_state_str(transition_state)); - - /* We must notify MHI control driver so it can clean up first */ - if (transition_state == MHI_PM_SYS_ERR_PROCESS) - mhi_cntrl->status_cb(mhi_cntrl, mhi_cntrl->priv_data, - MHI_CB_SYS_ERROR); - - mutex_lock(&mhi_cntrl->pm_mutex); - write_lock_irq(&mhi_cntrl->pm_lock); - prev_state = mhi_cntrl->pm_state; - cur_state = mhi_tryset_pm_state(mhi_cntrl, transition_state); - if (cur_state == transition_state) { - mhi_cntrl->ee = MHI_EE_DISABLE_TRANSITION; - mhi_cntrl->dev_state = MHI_STATE_RESET; - } - write_unlock_irq(&mhi_cntrl->pm_lock); - - /* wake up any threads waiting for state transitions */ - wake_up_all(&mhi_cntrl->state_event); - - /* not handling sys_err, could be middle of shut down */ - if (cur_state != transition_state) { - MHI_LOG("Failed to transition to state:0x%x from:0x%x\n", - transition_state, cur_state); - mutex_unlock(&mhi_cntrl->pm_mutex); - return; - } - - /* trigger MHI RESET so device will not access host ddr */ - if (MHI_REG_ACCESS_VALID(prev_state)) { - u32 in_reset = -1; - unsigned long timeout = msecs_to_jiffies(mhi_cntrl->timeout_ms); - - MHI_LOG("Trigger device into MHI_RESET\n"); - mhi_set_mhi_state(mhi_cntrl, MHI_STATE_RESET); - - /* wait for reset to be cleared */ - ret = wait_event_timeout(mhi_cntrl->state_event, - mhi_read_reg_field(mhi_cntrl, - mhi_cntrl->regs, MHICTRL, - MHICTRL_RESET_MASK, - MHICTRL_RESET_SHIFT, &in_reset) - || !in_reset, timeout); - if ((!ret || in_reset) && cur_state == MHI_PM_SYS_ERR_PROCESS) { - MHI_CRITICAL("Device failed to exit RESET state\n"); - mutex_unlock(&mhi_cntrl->pm_mutex); - return; - } - - /* Set the numbers of Event Rings supported */ - mhi_write_reg_field(mhi_cntrl, mhi_cntrl->regs, MHICFG, MHICFG_NER_MASK, MHICFG_NER_SHIFT, NUM_MHI_EVT_RINGS); - mhi_write_reg_field(mhi_cntrl, mhi_cntrl->regs, MHICFG, MHICFG_NHWER_MASK, MHICFG_NHWER_SHIFT, NUM_MHI_HW_EVT_RINGS); - - /* - * device cleares INTVEC as part of RESET processing, - * re-program it - */ - mhi_write_reg(mhi_cntrl, mhi_cntrl->bhi, BHI_INTVEC, mhi_cntrl->msi_irq_base); - } - - MHI_LOG("Waiting for all pending event ring processing to complete\n"); - mhi_event = mhi_cntrl->mhi_event; - for (i = 0; i < mhi_cntrl->total_ev_rings; i++, mhi_event++) { - if (mhi_event->offload_ev) - continue; - tasklet_kill(&mhi_event->task); - } - - mutex_unlock(&mhi_cntrl->pm_mutex); - - MHI_LOG("Reset all active channels and remove mhi devices\n"); - mhi_cntrl->klog_slient = 1; - device_for_each_child(mhi_cntrl->dev, NULL, mhi_destroy_device); - mhi_cntrl->klog_slient = 0; - - MHI_LOG("Finish resetting channels\n"); - - MHI_LOG("Waiting for all pending threads to complete\n"); - wake_up_all(&mhi_cntrl->state_event); - flush_delayed_work(&mhi_cntrl->ready_worker); - flush_work(&mhi_cntrl->st_worker); - flush_work(&mhi_cntrl->fw_worker); - - mutex_lock(&mhi_cntrl->pm_mutex); - - MHI_ASSERT(atomic_read(&mhi_cntrl->dev_wake), "dev_wake != 0"); - - /* reset the ev rings and cmd rings */ - MHI_LOG("Resetting EV CTXT and CMD CTXT\n"); - mhi_cmd = mhi_cntrl->mhi_cmd; - cmd_ctxt = mhi_cntrl->mhi_ctxt->cmd_ctxt; - for (i = 0; i < NR_OF_CMD_RINGS; i++, mhi_cmd++, cmd_ctxt++) { - struct mhi_ring *ring = &mhi_cmd->ring; - - ring->rp = ring->base; - ring->wp = ring->base; - cmd_ctxt->rp = cmd_ctxt->rbase; - cmd_ctxt->wp = cmd_ctxt->rbase; - } - - mhi_event = mhi_cntrl->mhi_event; - er_ctxt = mhi_cntrl->mhi_ctxt->er_ctxt; - for (i = 0; i < mhi_cntrl->total_ev_rings; i++, er_ctxt++, - mhi_event++) { - struct mhi_ring *ring = &mhi_event->ring; - - /* do not touch offload er */ - if (mhi_event->offload_ev) - continue; - - ring->rp = ring->base; - ring->wp = ring->base; - er_ctxt->rp = er_ctxt->rbase; - er_ctxt->wp = er_ctxt->rbase; - } - - /* remove support for time sync */ - mhi_destroy_timesync(mhi_cntrl); - - if (cur_state == MHI_PM_SYS_ERR_PROCESS) { - if (mhi_get_exec_env(mhi_cntrl) == MHI_EE_EDL && mhi_get_mhi_state(mhi_cntrl) == MHI_STATE_RESET) { - write_lock_irq(&mhi_cntrl->pm_lock); - mhi_cntrl->ee = MHI_EE_EDL; - cur_state = mhi_tryset_pm_state(mhi_cntrl, MHI_PM_POR); - write_unlock_irq(&mhi_cntrl->pm_lock); - } - else - mhi_ready_state_transition(mhi_cntrl); - } else { - /* move to disable state */ - write_lock_irq(&mhi_cntrl->pm_lock); - cur_state = mhi_tryset_pm_state(mhi_cntrl, MHI_PM_DISABLE); - write_unlock_irq(&mhi_cntrl->pm_lock); - if (unlikely(cur_state != MHI_PM_DISABLE)) - MHI_ERR("Error moving from pm state:%s to state:%s\n", - to_mhi_pm_state_str(cur_state), - to_mhi_pm_state_str(MHI_PM_DISABLE)); - } - - MHI_LOG("Exit with pm_state:%s mhi_state:%s\n", - to_mhi_pm_state_str(mhi_cntrl->pm_state), - TO_MHI_STATE_STR(mhi_cntrl->dev_state)); - - mutex_unlock(&mhi_cntrl->pm_mutex); -} - -int mhi_debugfs_trigger_reset(void *data, u64 val) -{ - struct mhi_controller *mhi_cntrl = data; - enum MHI_PM_STATE cur_state; - int ret; - - MHI_LOG("Trigger MHI Reset\n"); - - /* exit lpm first */ - mhi_cntrl->runtime_get(mhi_cntrl, mhi_cntrl->priv_data); - mhi_cntrl->runtime_put(mhi_cntrl, mhi_cntrl->priv_data); - - ret = wait_event_timeout(mhi_cntrl->state_event, - mhi_cntrl->dev_state == MHI_STATE_M0 || - MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state), - msecs_to_jiffies(mhi_cntrl->timeout_ms)); - - if (!ret || MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) { - MHI_ERR("Did not enter M0 state, cur_state:%s pm_state:%s\n", - TO_MHI_STATE_STR(mhi_cntrl->dev_state), - to_mhi_pm_state_str(mhi_cntrl->pm_state)); - return -EIO; - } - - write_lock_irq(&mhi_cntrl->pm_lock); - cur_state = mhi_tryset_pm_state(mhi_cntrl, MHI_PM_SYS_ERR_DETECT); - write_unlock_irq(&mhi_cntrl->pm_lock); - - if (cur_state == MHI_PM_SYS_ERR_DETECT) - schedule_work(&mhi_cntrl->syserr_worker); - - return 0; -} - -/* queue a new work item and scheduler work */ -int mhi_queue_state_transition(struct mhi_controller *mhi_cntrl, - enum MHI_ST_TRANSITION state) -{ - struct state_transition *item = kmalloc(sizeof(*item), GFP_ATOMIC); - unsigned long flags; - - if (!item) - return -ENOMEM; - - item->state = state; - spin_lock_irqsave(&mhi_cntrl->transition_lock, flags); - list_add_tail(&item->node, &mhi_cntrl->transition_list); - spin_unlock_irqrestore(&mhi_cntrl->transition_lock, flags); - - schedule_work(&mhi_cntrl->st_worker); - - return 0; -} - -void mhi_pm_sys_err_worker(struct work_struct *work) -{ - struct mhi_controller *mhi_cntrl = container_of(work, - struct mhi_controller, - syserr_worker); - - MHI_LOG("Enter with pm_state:%s MHI_STATE:%s\n", - to_mhi_pm_state_str(mhi_cntrl->pm_state), - TO_MHI_STATE_STR(mhi_cntrl->dev_state)); - - mhi_pm_disable_transition(mhi_cntrl, MHI_PM_SYS_ERR_PROCESS); -} - -void mhi_pm_ready_worker(struct work_struct *work) -{ - struct mhi_controller *mhi_cntrl = container_of(work, - struct mhi_controller, - ready_worker.work); - enum mhi_ee ee = MHI_EE_MAX; - - if (mhi_cntrl->dev_state != MHI_STATE_RESET) - return; - - write_lock_irq(&mhi_cntrl->pm_lock); - if (MHI_REG_ACCESS_VALID(mhi_cntrl->pm_state)) - ee = mhi_get_exec_env(mhi_cntrl); - write_unlock_irq(&mhi_cntrl->pm_lock); - - if (ee == MHI_EE_PTHRU) - schedule_delayed_work(&mhi_cntrl->ready_worker, msecs_to_jiffies(10)); - else if (ee == MHI_EE_AMSS || ee == MHI_EE_SBL) - mhi_queue_state_transition(mhi_cntrl, MHI_ST_TRANSITION_READY); - else if (ee == MHI_EE_EDL) - mhi_queue_state_transition(mhi_cntrl, MHI_ST_TRANSITION_PBL); -} - -void mhi_pm_st_worker(struct work_struct *work) -{ - struct state_transition *itr, *tmp; - LIST_HEAD(head); - struct mhi_controller *mhi_cntrl = container_of(work, - struct mhi_controller, - st_worker); - spin_lock_irq(&mhi_cntrl->transition_lock); - list_splice_tail_init(&mhi_cntrl->transition_list, &head); - spin_unlock_irq(&mhi_cntrl->transition_lock); - - list_for_each_entry_safe(itr, tmp, &head, node) { - list_del(&itr->node); - MHI_LOG("Transition to state:%s\n", - TO_MHI_STATE_TRANS_STR(itr->state)); - - if (mhi_cntrl->ee != mhi_get_exec_env(mhi_cntrl)) { - MHI_LOG("%s -> %s\n", TO_MHI_EXEC_STR(mhi_cntrl->ee), - TO_MHI_EXEC_STR(mhi_get_exec_env(mhi_cntrl))); - } - - switch (itr->state) { - case MHI_ST_TRANSITION_PBL: - write_lock_irq(&mhi_cntrl->pm_lock); - if (MHI_REG_ACCESS_VALID(mhi_cntrl->pm_state)) - mhi_cntrl->ee = mhi_get_exec_env(mhi_cntrl); - write_unlock_irq(&mhi_cntrl->pm_lock); - if (MHI_IN_PBL(mhi_cntrl->ee)) - wake_up_all(&mhi_cntrl->state_event); - break; - case MHI_ST_TRANSITION_SBL: - write_lock_irq(&mhi_cntrl->pm_lock); - mhi_cntrl->ee = MHI_EE_SBL; - write_unlock_irq(&mhi_cntrl->pm_lock); - wake_up_all(&mhi_cntrl->state_event); - mhi_create_devices(mhi_cntrl); - break; - case MHI_ST_TRANSITION_MISSION_MODE: - mhi_pm_mission_mode_transition(mhi_cntrl); - break; - case MHI_ST_TRANSITION_READY: - mhi_ready_state_transition(mhi_cntrl); - break; - case MHI_ST_TRANSITION_FP: - write_lock_irq(&mhi_cntrl->pm_lock); - mhi_cntrl->ee = MHI_EE_FP; - write_unlock_irq(&mhi_cntrl->pm_lock); - wake_up(&mhi_cntrl->state_event); - mhi_create_devices(mhi_cntrl); - break; - default: - break; - } - kfree(itr); - } -} - -int mhi_async_power_up(struct mhi_controller *mhi_cntrl) -{ - int ret; - u32 val, regVal; - enum mhi_ee current_ee; - enum MHI_ST_TRANSITION next_state; - - MHI_LOG("Requested to power on\n"); - -#if 0 - if (mhi_cntrl->msi_allocated < mhi_cntrl->total_ev_rings) - return -EINVAL; -#endif - - if (mhi_get_mhi_state(mhi_cntrl) >= MHI_STATE_M0) { - MHI_LOG("mhi_state = %s\n", mhi_state_str[mhi_get_mhi_state(mhi_cntrl)]); - MHI_LOG("Trigger device into MHI_RESET\n"); - mhi_set_mhi_state(mhi_cntrl, MHI_STATE_RESET); - msleep(50); - MHI_LOG("mhi_state = %s\n", mhi_state_str[mhi_get_mhi_state(mhi_cntrl)]); - } - -#if 1 //GLUE.SDX55_LE.1.0-00098-NOOP_TEST-1\common\hostdrivers\win\MhiHost MhiInitNewDev() - /* Check device Channels support */ - ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->regs, MHICFG, ®Val); -#if 0 - val = MHI_READ_REG_FIELD(regVal, MHICFG, NCH); - MHI_LOG("Device CHs: %d\n", val); - val = MHI_READ_REG_FIELD(regVal, MHICFG, NHWCH); - MHI_LOG("Device HW CHs: %d\n", val); - val = MHI_READ_REG_FIELD(regVal, MHICFG, NER); - MHI_LOG("Device ERs: %d\n", val); - val = MHI_READ_REG_FIELD(regVal, MHICFG, NHWER); - MHI_LOG("Device HW ERs: %d\n", val); -#endif - /* Set the numbers of Event Rings supported */ - MHI_WRITE_REG_FIELD(regVal, MHICFG, NER, NUM_MHI_EVT_RINGS); - MHI_WRITE_REG_FIELD(regVal, MHICFG, NHWER, NUM_MHI_HW_EVT_RINGS); - mhi_write_reg(mhi_cntrl, mhi_cntrl->regs, MHICFG, regVal); -#endif - - /* set to default wake if not set */ - if (!mhi_cntrl->wake_get || !mhi_cntrl->wake_put) { - mhi_cntrl->wake_get = mhi_assert_dev_wake; - mhi_cntrl->wake_put = mhi_deassert_dev_wake; - } - - mutex_lock(&mhi_cntrl->pm_mutex); - mhi_cntrl->pm_state = MHI_PM_DISABLE; - mhi_cntrl->dev_state = MHI_STATE_RESET; - - if (!mhi_cntrl->pre_init) { - /* setup device context */ - ret = mhi_init_dev_ctxt(mhi_cntrl); - if (ret) { - MHI_ERR("Error setting dev_context\n"); - goto error_dev_ctxt; - } - - ret = mhi_init_irq_setup(mhi_cntrl); - if (ret) { - MHI_ERR("Error setting up irq\n"); - goto error_setup_irq; - } - } - - /* setup bhi offset & intvec */ - write_lock_irq(&mhi_cntrl->pm_lock); - ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->regs, BHIOFF, &val); - if (ret) { - write_unlock_irq(&mhi_cntrl->pm_lock); - MHI_ERR("Error getting bhi offset\n"); - goto error_bhi_offset; - } - - mhi_cntrl->bhi = mhi_cntrl->regs + val; - - /* setup bhie offset */ - if (mhi_cntrl->fbc_download || true) { - ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->regs, BHIEOFF, &val); - if (ret) { - write_unlock_irq(&mhi_cntrl->pm_lock); - MHI_ERR("Error getting bhie offset\n"); - goto error_bhi_offset; - } - - mhi_cntrl->bhie = mhi_cntrl->regs + val; - } - - mhi_write_reg(mhi_cntrl, mhi_cntrl->bhi, BHI_INTVEC, mhi_cntrl->msi_irq_base); - mhi_cntrl->pm_state = MHI_PM_POR; - mhi_cntrl->ee = MHI_EE_MAX; - current_ee = mhi_get_exec_env(mhi_cntrl); - write_unlock_irq(&mhi_cntrl->pm_lock); - - MHI_LOG("dev_state:%s ee:%s\n", - TO_MHI_STATE_STR(mhi_get_mhi_state(mhi_cntrl)), - TO_MHI_EXEC_STR(mhi_get_exec_env(mhi_cntrl))); - - /* confirm device is in valid exec env */ - if (!MHI_IN_PBL(current_ee) && current_ee != MHI_EE_AMSS) { - //MHI_ERR("Not a valid ee for power on\n"); - //ret = -EIO; - //goto error_bhi_offset; - } - - /* transition to next state */ - next_state = MHI_IN_PBL(current_ee) ? - MHI_ST_TRANSITION_PBL : MHI_ST_TRANSITION_READY; - - //if (next_state == MHI_ST_TRANSITION_PBL) - // schedule_work(&mhi_cntrl->fw_worker); - - if (next_state == MHI_ST_TRANSITION_PBL) - schedule_delayed_work(&mhi_cntrl->ready_worker, msecs_to_jiffies(10)); - else - mhi_queue_state_transition(mhi_cntrl, next_state); - - mhi_init_debugfs(mhi_cntrl); - - mutex_unlock(&mhi_cntrl->pm_mutex); - - MHI_LOG("Power on setup success\n"); - - return 0; - -error_bhi_offset: - if (!mhi_cntrl->pre_init) - mhi_deinit_free_irq(mhi_cntrl); - -error_setup_irq: - if (!mhi_cntrl->pre_init) - mhi_deinit_dev_ctxt(mhi_cntrl); - -error_dev_ctxt: - mutex_unlock(&mhi_cntrl->pm_mutex); - - return ret; -} -EXPORT_SYMBOL(mhi_async_power_up); - -void mhi_power_down(struct mhi_controller *mhi_cntrl, bool graceful) -{ - enum MHI_PM_STATE cur_state; - - /* if it's not graceful shutdown, force MHI to a linkdown state */ - if (!graceful) { - mutex_lock(&mhi_cntrl->pm_mutex); - write_lock_irq(&mhi_cntrl->pm_lock); - cur_state = mhi_tryset_pm_state(mhi_cntrl, - MHI_PM_LD_ERR_FATAL_DETECT); - write_unlock_irq(&mhi_cntrl->pm_lock); - mutex_unlock(&mhi_cntrl->pm_mutex); - if (cur_state != MHI_PM_LD_ERR_FATAL_DETECT) - MHI_ERR("Failed to move to state:%s from:%s\n", - to_mhi_pm_state_str(MHI_PM_LD_ERR_FATAL_DETECT), - to_mhi_pm_state_str(mhi_cntrl->pm_state)); - } - mhi_pm_disable_transition(mhi_cntrl, MHI_PM_SHUTDOWN_PROCESS); - - mhi_deinit_debugfs(mhi_cntrl); - - if (!mhi_cntrl->pre_init) { - /* free all allocated resources */ - if (mhi_cntrl->fbc_image) { - mhi_free_bhie_table(mhi_cntrl, mhi_cntrl->fbc_image); - mhi_cntrl->fbc_image = NULL; - } - mhi_deinit_free_irq(mhi_cntrl); - mhi_deinit_dev_ctxt(mhi_cntrl); - } -} -EXPORT_SYMBOL(mhi_power_down); - -int mhi_sync_power_up(struct mhi_controller *mhi_cntrl) -{ - int ret = mhi_async_power_up(mhi_cntrl); - - if (ret) - return ret; - - wait_event_timeout(mhi_cntrl->state_event, - MHI_IN_MISSION_MODE(mhi_cntrl->ee) || - MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state), - msecs_to_jiffies(mhi_cntrl->timeout_ms)); - - return (MHI_IN_MISSION_MODE(mhi_cntrl->ee)) ? 0 : -EIO; -} -EXPORT_SYMBOL(mhi_sync_power_up); - -int mhi_pm_suspend(struct mhi_controller *mhi_cntrl) -{ - int ret; - enum MHI_PM_STATE new_state; - struct mhi_chan *itr, *tmp; - - if (mhi_cntrl->pm_state == MHI_PM_DISABLE) - return -EINVAL; - - if (MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) - return -EIO; - - /* do a quick check to see if any pending data, then exit */ - if (atomic_read(&mhi_cntrl->dev_wake)) { - MHI_VERB("Busy, aborting M3\n"); - return -EBUSY; - } - - /* exit MHI out of M2 state */ - read_lock_bh(&mhi_cntrl->pm_lock); - mhi_cntrl->wake_get(mhi_cntrl, false); - read_unlock_bh(&mhi_cntrl->pm_lock); - - ret = wait_event_timeout(mhi_cntrl->state_event, - mhi_cntrl->dev_state == MHI_STATE_M0 || - mhi_cntrl->dev_state == MHI_STATE_M1 || - MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state), - msecs_to_jiffies(mhi_cntrl->timeout_ms)); - - if (!ret || MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) { - MHI_ERR( - "Did not enter M0||M1 state, cur_state:%s pm_state:%s\n", - TO_MHI_STATE_STR(mhi_cntrl->dev_state), - to_mhi_pm_state_str(mhi_cntrl->pm_state)); - ret = -EIO; - goto error_m0_entry; - } - - write_lock_irq(&mhi_cntrl->pm_lock); - - /* we're asserting wake so count would be @ least 1 */ - if (atomic_read(&mhi_cntrl->dev_wake) > 1) { - MHI_VERB("Busy, aborting M3\n"); - write_unlock_irq(&mhi_cntrl->pm_lock); - ret = -EBUSY; - goto error_m0_entry; - } - - /* anytime after this, we will resume thru runtime pm framework */ - MHI_LOG("Allowing M3 transition\n"); - new_state = mhi_tryset_pm_state(mhi_cntrl, MHI_PM_M3_ENTER); - if (new_state != MHI_PM_M3_ENTER) { - write_unlock_irq(&mhi_cntrl->pm_lock); - MHI_ERR("Error setting to pm_state:%s from pm_state:%s\n", - to_mhi_pm_state_str(MHI_PM_M3_ENTER), - to_mhi_pm_state_str(mhi_cntrl->pm_state)); - - ret = -EIO; - goto error_m0_entry; - } - - /* set dev to M3 and wait for completion */ - mhi_set_mhi_state(mhi_cntrl, MHI_STATE_M3); - mhi_cntrl->wake_put(mhi_cntrl, false); - write_unlock_irq(&mhi_cntrl->pm_lock); - MHI_LOG("Wait for M3 completion\n"); - - ret = wait_event_timeout(mhi_cntrl->state_event, - mhi_cntrl->dev_state == MHI_STATE_M3 || - MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state), - msecs_to_jiffies(mhi_cntrl->timeout_ms)); - - if (!ret || MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) { - MHI_ERR("Did not enter M3 state, cur_state:%s pm_state:%s\n", - TO_MHI_STATE_STR(mhi_cntrl->dev_state), - to_mhi_pm_state_str(mhi_cntrl->pm_state)); - return -EIO; - } - - /* notify any clients we enter lpm */ - list_for_each_entry_safe(itr, tmp, &mhi_cntrl->lpm_chans, node) { - mutex_lock(&itr->mutex); - if (itr->mhi_dev) - mhi_notify(itr->mhi_dev, MHI_CB_LPM_ENTER); - mutex_unlock(&itr->mutex); - } - - return 0; - -error_m0_entry: - read_lock_bh(&mhi_cntrl->pm_lock); - mhi_cntrl->wake_put(mhi_cntrl, false); - read_unlock_bh(&mhi_cntrl->pm_lock); - - return ret; -} -EXPORT_SYMBOL(mhi_pm_suspend); - -int mhi_pm_resume(struct mhi_controller *mhi_cntrl) -{ - enum MHI_PM_STATE cur_state; - int ret; - struct mhi_chan *itr, *tmp; - - MHI_LOG("Entered with pm_state:%s dev_state:%s\n", - to_mhi_pm_state_str(mhi_cntrl->pm_state), - TO_MHI_STATE_STR(mhi_cntrl->dev_state)); - - if (mhi_cntrl->pm_state == MHI_PM_DISABLE) - return 0; - - if (MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) - return -EIO; - - MHI_ASSERT(mhi_cntrl->pm_state != MHI_PM_M3, "mhi_pm_state != M3"); - - /* notify any clients we enter lpm */ - list_for_each_entry_safe(itr, tmp, &mhi_cntrl->lpm_chans, node) { - mutex_lock(&itr->mutex); - if (itr->mhi_dev) - mhi_notify(itr->mhi_dev, MHI_CB_LPM_EXIT); - mutex_unlock(&itr->mutex); - } - - write_lock_irq(&mhi_cntrl->pm_lock); - cur_state = mhi_tryset_pm_state(mhi_cntrl, MHI_PM_M3_EXIT); - if (cur_state != MHI_PM_M3_EXIT) { - write_unlock_irq(&mhi_cntrl->pm_lock); - MHI_ERR("Error setting to pm_state:%s from pm_state:%s\n", - to_mhi_pm_state_str(MHI_PM_M3_EXIT), - to_mhi_pm_state_str(mhi_cntrl->pm_state)); - return -EIO; - } - - /* set dev to M0 and wait for completion */ - mhi_cntrl->wake_get(mhi_cntrl, true); - mhi_set_mhi_state(mhi_cntrl, MHI_STATE_M0); - write_unlock_irq(&mhi_cntrl->pm_lock); - - ret = wait_event_timeout(mhi_cntrl->state_event, - mhi_cntrl->dev_state == MHI_STATE_M0 || - MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state), - msecs_to_jiffies(mhi_cntrl->timeout_ms)); - - read_lock_bh(&mhi_cntrl->pm_lock); - mhi_cntrl->wake_put(mhi_cntrl, false); - read_unlock_bh(&mhi_cntrl->pm_lock); - - if (!ret || MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) { - MHI_ERR("Did not enter M0 state, cur_state:%s pm_state:%s\n", - TO_MHI_STATE_STR(mhi_cntrl->dev_state), - to_mhi_pm_state_str(mhi_cntrl->pm_state)); - - /* - * It's possible device already in error state and we didn't - * process it due to low power mode, force a check - */ - mhi_intvec_threaded_handlr(0, mhi_cntrl); - return -EIO; - } - - return 0; -} - -int __mhi_device_get_sync(struct mhi_controller *mhi_cntrl) -{ - int ret; - - read_lock_bh(&mhi_cntrl->pm_lock); - mhi_cntrl->wake_get(mhi_cntrl, true); - if (MHI_PM_IN_SUSPEND_STATE(mhi_cntrl->pm_state)) { - mhi_cntrl->runtime_get(mhi_cntrl, mhi_cntrl->priv_data); - mhi_cntrl->runtime_put(mhi_cntrl, mhi_cntrl->priv_data); - } - read_unlock_bh(&mhi_cntrl->pm_lock); - - ret = wait_event_timeout(mhi_cntrl->state_event, - mhi_cntrl->pm_state == MHI_PM_M0 || - MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state), - msecs_to_jiffies(mhi_cntrl->timeout_ms)); - - if (!ret || MHI_PM_IN_ERROR_STATE(mhi_cntrl->pm_state)) { - MHI_ERR("Did not enter M0 state, cur_state:%s pm_state:%s\n", - TO_MHI_STATE_STR(mhi_cntrl->dev_state), - to_mhi_pm_state_str(mhi_cntrl->pm_state)); - read_lock_bh(&mhi_cntrl->pm_lock); - mhi_cntrl->wake_put(mhi_cntrl, false); - read_unlock_bh(&mhi_cntrl->pm_lock); - return -EIO; - } - - return 0; -} - -void mhi_device_get(struct mhi_device *mhi_dev) -{ - struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; - - atomic_inc(&mhi_dev->dev_wake); - read_lock_bh(&mhi_cntrl->pm_lock); - mhi_cntrl->wake_get(mhi_cntrl, true); - read_unlock_bh(&mhi_cntrl->pm_lock); -} -EXPORT_SYMBOL(mhi_device_get); - -int mhi_device_get_sync(struct mhi_device *mhi_dev) -{ - struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; - int ret; - - ret = __mhi_device_get_sync(mhi_cntrl); - if (!ret) - atomic_inc(&mhi_dev->dev_wake); - - return ret; -} -EXPORT_SYMBOL(mhi_device_get_sync); - -void mhi_device_put(struct mhi_device *mhi_dev) -{ - struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl; - - atomic_dec(&mhi_dev->dev_wake); - read_lock_bh(&mhi_cntrl->pm_lock); - mhi_cntrl->wake_put(mhi_cntrl, false); - read_unlock_bh(&mhi_cntrl->pm_lock); -} -EXPORT_SYMBOL(mhi_device_put); - -int mhi_force_rddm_mode(struct mhi_controller *mhi_cntrl) -{ - int ret; - - MHI_LOG("Enter with pm_state:%s ee:%s\n", - to_mhi_pm_state_str(mhi_cntrl->pm_state), - TO_MHI_EXEC_STR(mhi_cntrl->ee)); - - MHI_LOG("Triggering SYS_ERR to force rddm state\n"); - mhi_set_mhi_state(mhi_cntrl, MHI_STATE_SYS_ERR); - - /* wait for rddm event */ - MHI_LOG("Waiting for device to enter RDDM state\n"); - ret = wait_event_timeout(mhi_cntrl->state_event, - mhi_cntrl->ee == MHI_EE_RDDM, - msecs_to_jiffies(mhi_cntrl->timeout_ms)); - ret = ret ? 0 : -EIO; - - MHI_LOG("Exiting with pm_state:%s ee:%s ret:%d\n", - to_mhi_pm_state_str(mhi_cntrl->pm_state), - TO_MHI_EXEC_STR(mhi_cntrl->ee), ret); - - return ret; -} -EXPORT_SYMBOL(mhi_force_rddm_mode); diff --git a/quectel_MHI/src/core/mhi_sdx20.h b/quectel_MHI/src/core/mhi_sdx20.h deleted file mode 100644 index 2bc5dc7..0000000 --- a/quectel_MHI/src/core/mhi_sdx20.h +++ /dev/null @@ -1,362 +0,0 @@ -#ifndef __SDX20_MHI_H -#define __SDX20_MHI_H - -#include - -/* MHI control data structures alloted by the host, including - * channel context array, event context array, command context and rings */ - -/* Channel context state */ -enum mhi_dev_ch_ctx_state { - MHI_DEV_CH_STATE_DISABLED, - MHI_DEV_CH_STATE_ENABLED, - MHI_DEV_CH_STATE_RUNNING, - MHI_DEV_CH_STATE_SUSPENDED, - MHI_DEV_CH_STATE_STOP, - MHI_DEV_CH_STATE_ERROR, - MHI_DEV_CH_STATE_RESERVED, - MHI_DEV_CH_STATE_32BIT = 0x7FFFFFFF -}; - -/* Channel type */ -enum mhi_dev_ch_ctx_type { - MHI_DEV_CH_TYPE_NONE, - MHI_DEV_CH_TYPE_OUTBOUND_CHANNEL, - MHI_DEV_CH_TYPE_INBOUND_CHANNEL, - MHI_DEV_CH_RESERVED -}; - -/* Channel context type */ -struct mhi_dev_ch_ctx { - enum mhi_dev_ch_ctx_state ch_state; - enum mhi_dev_ch_ctx_type ch_type; - uint32_t err_indx; - uint64_t rbase; - uint64_t rlen; - uint64_t rp; - uint64_t wp; -} __packed; - -enum mhi_dev_ring_element_type_id { - MHI_DEV_RING_EL_INVALID = 0, - MHI_DEV_RING_EL_NOOP = 1, - MHI_DEV_RING_EL_TRANSFER = 2, - MHI_DEV_RING_EL_RESET = 16, - MHI_DEV_RING_EL_STOP = 17, - MHI_DEV_RING_EL_START = 18, - MHI_DEV_RING_EL_MHI_STATE_CHG = 32, - MHI_DEV_RING_EL_CMD_COMPLETION_EVT = 33, - MHI_DEV_RING_EL_TRANSFER_COMPLETION_EVENT = 34, - MHI_DEV_RING_EL_EE_STATE_CHANGE_NOTIFY = 64, - MHI_DEV_RING_EL_UNDEF -}; - -enum mhi_dev_ring_state { - RING_STATE_UINT = 0, - RING_STATE_IDLE, - RING_STATE_PENDING, -}; - -enum mhi_dev_ring_type { - RING_TYPE_CMD = 0, - RING_TYPE_ER, - RING_TYPE_CH, - RING_TYPE_INVAL -}; - -/* Event context interrupt moderation */ -enum mhi_dev_evt_ctx_int_mod_timer { - MHI_DEV_EVT_INT_MODERATION_DISABLED -}; - -/* Event ring type */ -enum mhi_dev_evt_ctx_event_ring_type { - MHI_DEV_EVT_TYPE_DEFAULT, - MHI_DEV_EVT_TYPE_VALID, - MHI_DEV_EVT_RESERVED -}; - -/* Event ring context type */ -struct mhi_dev_ev_ctx { - uint32_t res1:16; - enum mhi_dev_evt_ctx_int_mod_timer intmodt:16; - enum mhi_dev_evt_ctx_event_ring_type ertype; - uint32_t msivec; - uint64_t rbase; - uint64_t rlen; - uint64_t rp; - uint64_t wp; -} __packed; - -/* Command context */ -struct mhi_dev_cmd_ctx { - uint32_t res1; - uint32_t res2; - uint32_t res3; - uint64_t rbase; - uint64_t rlen; - uint64_t rp; - uint64_t wp; -} __packed; - -/* generic context */ -struct mhi_dev_gen_ctx { - uint32_t res1; - uint32_t res2; - uint32_t res3; - uint64_t rbase; - uint64_t rlen; - uint64_t rp; - uint64_t wp; -} __packed; - -/* Transfer ring element */ -struct mhi_dev_transfer_ring_element { - uint64_t data_buf_ptr; - uint32_t len:16; - uint32_t res1:16; - uint32_t chain:1; - uint32_t res2:7; - uint32_t ieob:1; - uint32_t ieot:1; - uint32_t bei:1; - uint32_t res3:5; - enum mhi_dev_ring_element_type_id type:8; - uint32_t res4:8; -} __packed; - -/* Command ring element */ -/* Command ring No op command */ -struct mhi_dev_cmd_ring_op { - uint64_t res1; - uint32_t res2; - uint32_t res3:16; - enum mhi_dev_ring_element_type_id type:8; - uint32_t chid:8; -} __packed; - -/* Command ring reset channel command */ -struct mhi_dev_cmd_ring_reset_channel_cmd { - uint64_t res1; - uint32_t res2; - uint32_t res3:16; - enum mhi_dev_ring_element_type_id type:8; - uint32_t chid:8; -} __packed; - -/* Command ring stop channel command */ -struct mhi_dev_cmd_ring_stop_channel_cmd { - uint64_t res1; - uint32_t res2; - uint32_t res3:16; - enum mhi_dev_ring_element_type_id type:8; - uint32_t chid:8; -} __packed; - -/* Command ring start channel command */ -struct mhi_dev_cmd_ring_start_channel_cmd { - uint64_t res1; - uint32_t seqnum; - uint32_t reliable:1; - uint32_t res2:15; - enum mhi_dev_ring_element_type_id type:8; - uint32_t chid:8; -} __packed; - -enum mhi_dev_cmd_completion_code { - MHI_CMD_COMPL_CODE_INVALID = 0, - MHI_CMD_COMPL_CODE_SUCCESS = 1, - MHI_CMD_COMPL_CODE_EOT = 2, - MHI_CMD_COMPL_CODE_OVERFLOW = 3, - MHI_CMD_COMPL_CODE_EOB = 4, - MHI_CMD_COMPL_CODE_UNDEFINED = 16, - MHI_CMD_COMPL_CODE_RING_EL = 17, - MHI_CMD_COMPL_CODE_RES -}; - -/* Event ring elements */ -/* Transfer completion event */ -struct mhi_dev_event_ring_transfer_completion { - uint64_t ptr; - uint32_t len:16; - uint32_t res1:8; - enum mhi_dev_cmd_completion_code code:8; - uint32_t res2:16; - enum mhi_dev_ring_element_type_id type:8; - uint32_t chid:8; -} __packed; - -/* Command completion event */ -struct mhi_dev_event_ring_cmd_completion { - uint64_t ptr; - uint32_t res1:24; - enum mhi_dev_cmd_completion_code code:8; - uint32_t res2:16; - enum mhi_dev_ring_element_type_id type:8; - uint32_t res3:8; -} __packed; - -enum mhi_dev_state { - MHI_DEV_RESET_STATE = 0, - MHI_DEV_READY_STATE, - MHI_DEV_M0_STATE, - MHI_DEV_M1_STATE, - MHI_DEV_M2_STATE, - MHI_DEV_M3_STATE, - MHI_DEV_MAX_STATE, - MHI_DEV_SYSERR_STATE = 0xff -}; - -/* MHI state change event */ -struct mhi_dev_event_ring_state_change { - uint64_t ptr; - uint32_t res1:24; - enum mhi_dev_state mhistate:8; - uint32_t res2:16; - enum mhi_dev_ring_element_type_id type:8; - uint32_t res3:8; -} __packed; - -enum mhi_dev_execenv { - MHI_DEV_SBL_EE = 1, - MHI_DEV_AMSS_EE = 2, - MHI_DEV_UNRESERVED -}; - -/* EE state change event */ -struct mhi_dev_event_ring_ee_state_change { - uint64_t ptr; - uint32_t res1:24; - enum mhi_dev_execenv execenv:8; - uint32_t res2:16; - enum mhi_dev_ring_element_type_id type:8; - uint32_t res3:8; -} __packed; - -/* Generic cmd to parse common details like type and channel id */ -struct mhi_dev_ring_generic { - uint64_t ptr; - uint32_t res1:24; - enum mhi_dev_state mhistate:8; - uint32_t res2:16; - enum mhi_dev_ring_element_type_id type:8; - uint32_t chid:8; -} __packed; - -struct mhi_config { - uint32_t mhi_reg_len; - uint32_t version; - uint32_t event_rings; - uint32_t channels; - uint32_t chdb_offset; - uint32_t erdb_offset; -}; - -#define NUM_CHANNELS 128 -#define HW_CHANNEL_BASE 100 -#define HW_CHANNEL_END 107 -#define MHI_ENV_VALUE 2 -#define MHI_MASK_ROWS_CH_EV_DB 4 -#define TRB_MAX_DATA_SIZE 8192 -#define MHI_CTRL_STATE 25 -#define IPA_DMA_SYNC 1 -#define IPA_DMA_ASYNC 0 - -/*maximum trasnfer completion events buffer*/ -#define MAX_TR_EVENTS 50 -/*maximum event requests */ -#define MHI_MAX_EVT_REQ 50 - -/* Possible ring element types */ -union mhi_dev_ring_element_type { - struct mhi_dev_cmd_ring_op cmd_no_op; - struct mhi_dev_cmd_ring_reset_channel_cmd cmd_reset; - struct mhi_dev_cmd_ring_stop_channel_cmd cmd_stop; - struct mhi_dev_cmd_ring_start_channel_cmd cmd_start; - struct mhi_dev_transfer_ring_element cmd_transfer; - struct mhi_dev_event_ring_transfer_completion evt_tr_comp; - struct mhi_dev_event_ring_cmd_completion evt_cmd_comp; - struct mhi_dev_event_ring_state_change evt_state_change; - struct mhi_dev_event_ring_ee_state_change evt_ee_state; - struct mhi_dev_ring_generic generic; -}; - -/* Transfer ring element type */ -union mhi_dev_ring_ctx { - struct mhi_dev_cmd_ctx cmd; - struct mhi_dev_ev_ctx ev; - struct mhi_dev_ch_ctx ch; - struct mhi_dev_gen_ctx generic; -}; - -/* MHI host Control and data address region */ -struct mhi_host_addr { - uint32_t ctrl_base_lsb; - uint32_t ctrl_base_msb; - uint32_t ctrl_limit_lsb; - uint32_t ctrl_limit_msb; - uint32_t data_base_lsb; - uint32_t data_base_msb; - uint32_t data_limit_lsb; - uint32_t data_limit_msb; -}; - -/* MHI physical and virtual address region */ -struct mhi_meminfo { - struct device *dev; - uintptr_t pa_aligned; - uintptr_t pa_unaligned; - uintptr_t va_aligned; - uintptr_t va_unaligned; - uintptr_t size; -}; - -struct mhi_addr { - uint64_t host_pa; - uintptr_t device_pa; - uintptr_t device_va; - size_t size; - dma_addr_t phy_addr; - void *virt_addr; - bool use_ipa_dma; -}; - -struct mhi_interrupt_state { - uint32_t mask; - uint32_t status; -}; - -enum mhi_dev_channel_state { - MHI_DEV_CH_UNINT, - MHI_DEV_CH_STARTED, - MHI_DEV_CH_PENDING_START, - MHI_DEV_CH_PENDING_STOP, - MHI_DEV_CH_STOPPED, - MHI_DEV_CH_CLOSED, -}; - -enum mhi_dev_ch_operation { - MHI_DEV_OPEN_CH, - MHI_DEV_CLOSE_CH, - MHI_DEV_READ_CH, - MHI_DEV_READ_WR, - MHI_DEV_POLL, -}; - -enum mhi_ctrl_info { - MHI_STATE_CONFIGURED = 0, - MHI_STATE_CONNECTED = 1, - MHI_STATE_DISCONNECTED = 2, - MHI_STATE_INVAL, -}; - -enum mhi_dev_tr_compl_evt_type { - SEND_EVENT_BUFFER, - SEND_EVENT_RD_OFFSET, -}; - -enum mhi_dev_transfer_type { - MHI_DEV_DMA_SYNC, - MHI_DEV_DMA_ASYNC, -}; -#endif /* _SDX20_MHI_H_ */ diff --git a/quectel_MHI/src/core/sdx20_mhi.h b/quectel_MHI/src/core/sdx20_mhi.h deleted file mode 100644 index 29c4a3a..0000000 --- a/quectel_MHI/src/core/sdx20_mhi.h +++ /dev/null @@ -1,426 +0,0 @@ -#ifndef __SDX20_MHI_H -#define __SDX20_MHI_H - -#include - -/* MHI control data structures alloted by the host, including - * channel context array, event context array, command context and rings */ - -/* Channel context state */ -enum mhi_dev_ch_ctx_state { - MHI_DEV_CH_STATE_DISABLED, - MHI_DEV_CH_STATE_ENABLED, - MHI_DEV_CH_STATE_RUNNING, - MHI_DEV_CH_STATE_SUSPENDED, - MHI_DEV_CH_STATE_STOP, - MHI_DEV_CH_STATE_ERROR, - MHI_DEV_CH_STATE_RESERVED, - MHI_DEV_CH_STATE_32BIT = 0x7FFFFFFF -}; - -/* Channel type */ -enum mhi_dev_ch_ctx_type { - MHI_DEV_CH_TYPE_NONE, - MHI_DEV_CH_TYPE_OUTBOUND_CHANNEL, - MHI_DEV_CH_TYPE_INBOUND_CHANNEL, - MHI_DEV_CH_RESERVED -}; - -/* Channel context type */ -struct mhi_dev_ch_ctx { - enum mhi_dev_ch_ctx_state ch_state; - enum mhi_dev_ch_ctx_type ch_type; - uint32_t err_indx; - uint64_t rbase; - uint64_t rlen; - uint64_t rp; - uint64_t wp; -} __packed; - -enum mhi_dev_ring_element_type_id { - MHI_DEV_RING_EL_INVALID = 0, - MHI_DEV_RING_EL_NOOP = 1, - MHI_DEV_RING_EL_TRANSFER = 2, - MHI_DEV_RING_EL_RESET = 16, - MHI_DEV_RING_EL_STOP = 17, - MHI_DEV_RING_EL_START = 18, - MHI_DEV_RING_EL_MHI_STATE_CHG = 32, - MHI_DEV_RING_EL_CMD_COMPLETION_EVT = 33, - MHI_DEV_RING_EL_TRANSFER_COMPLETION_EVENT = 34, - MHI_DEV_RING_EL_EE_STATE_CHANGE_NOTIFY = 64, - MHI_DEV_RING_EL_UNDEF -}; - -enum mhi_dev_ring_state { - RING_STATE_UINT = 0, - RING_STATE_IDLE, - RING_STATE_PENDING, -}; - -enum mhi_dev_ring_type { - RING_TYPE_CMD = 0, - RING_TYPE_ER, - RING_TYPE_CH, - RING_TYPE_INVAL -}; - -/* Event context interrupt moderation */ -enum mhi_dev_evt_ctx_int_mod_timer { - MHI_DEV_EVT_INT_MODERATION_DISABLED -}; - -/* Event ring type */ -enum mhi_dev_evt_ctx_event_ring_type { - MHI_DEV_EVT_TYPE_DEFAULT, - MHI_DEV_EVT_TYPE_VALID, - MHI_DEV_EVT_RESERVED -}; - -/* Event ring context type */ -struct mhi_dev_ev_ctx { - uint32_t res1:16; - enum mhi_dev_evt_ctx_int_mod_timer intmodt:16; - enum mhi_dev_evt_ctx_event_ring_type ertype; - uint32_t msivec; - uint64_t rbase; - uint64_t rlen; - uint64_t rp; - uint64_t wp; -} __packed; - -/* Command context */ -struct mhi_dev_cmd_ctx { - uint32_t res1; - uint32_t res2; - uint32_t res3; - uint64_t rbase; - uint64_t rlen; - uint64_t rp; - uint64_t wp; -} __packed; - -/* generic context */ -struct mhi_dev_gen_ctx { - uint32_t res1; - uint32_t res2; - uint32_t res3; - uint64_t rbase; - uint64_t rlen; - uint64_t rp; - uint64_t wp; -} __packed; - -/* Transfer ring element */ -struct mhi_dev_transfer_ring_element { - uint64_t data_buf_ptr; - uint32_t len:16; - uint32_t res1:16; - uint32_t chain:1; - uint32_t res2:7; - uint32_t ieob:1; - uint32_t ieot:1; - uint32_t bei:1; - uint32_t res3:5; - enum mhi_dev_ring_element_type_id type:8; - uint32_t res4:8; -} __packed; - -/* Command ring element */ -/* Command ring No op command */ -struct mhi_dev_cmd_ring_op { - uint64_t res1; - uint32_t res2; - uint32_t res3:16; - enum mhi_dev_ring_element_type_id type:8; - uint32_t chid:8; -} __packed; - -/* Command ring reset channel command */ -struct mhi_dev_cmd_ring_reset_channel_cmd { - uint64_t res1; - uint32_t res2; - uint32_t res3:16; - enum mhi_dev_ring_element_type_id type:8; - uint32_t chid:8; -} __packed; - -/* Command ring stop channel command */ -struct mhi_dev_cmd_ring_stop_channel_cmd { - uint64_t res1; - uint32_t res2; - uint32_t res3:16; - enum mhi_dev_ring_element_type_id type:8; - uint32_t chid:8; -} __packed; - -/* Command ring start channel command */ -struct mhi_dev_cmd_ring_start_channel_cmd { - uint64_t res1; - uint32_t seqnum; - uint32_t reliable:1; - uint32_t res2:15; - enum mhi_dev_ring_element_type_id type:8; - uint32_t chid:8; -} __packed; - -enum mhi_dev_cmd_completion_code { - MHI_CMD_COMPL_CODE_INVALID = 0, - MHI_CMD_COMPL_CODE_SUCCESS = 1, - MHI_CMD_COMPL_CODE_EOT = 2, - MHI_CMD_COMPL_CODE_OVERFLOW = 3, - MHI_CMD_COMPL_CODE_EOB = 4, - MHI_CMD_COMPL_CODE_UNDEFINED = 16, - MHI_CMD_COMPL_CODE_RING_EL = 17, - MHI_CMD_COMPL_CODE_RES -}; - -/* Event ring elements */ -/* Transfer completion event */ -struct mhi_dev_event_ring_transfer_completion { - uint64_t ptr; - uint32_t len:16; - uint32_t res1:8; - enum mhi_dev_cmd_completion_code code:8; - uint32_t res2:16; - enum mhi_dev_ring_element_type_id type:8; - uint32_t chid:8; -} __packed; - -/* Command completion event */ -struct mhi_dev_event_ring_cmd_completion { - uint64_t ptr; - uint32_t res1:24; - enum mhi_dev_cmd_completion_code code:8; - uint32_t res2:16; - enum mhi_dev_ring_element_type_id type:8; - uint32_t res3:8; -} __packed; - -enum mhi_dev_state { - MHI_DEV_RESET_STATE = 0, - MHI_DEV_READY_STATE, - MHI_DEV_M0_STATE, - MHI_DEV_M1_STATE, - MHI_DEV_M2_STATE, - MHI_DEV_M3_STATE, - MHI_DEV_MAX_STATE, - MHI_DEV_SYSERR_STATE = 0xff -}; - -/* MHI state change event */ -struct mhi_dev_event_ring_state_change { - uint64_t ptr; - uint32_t res1:24; - enum mhi_dev_state mhistate:8; - uint32_t res2:16; - enum mhi_dev_ring_element_type_id type:8; - uint32_t res3:8; -} __packed; - -enum mhi_dev_execenv { - MHI_DEV_SBL_EE = 1, - MHI_DEV_AMSS_EE = 2, - MHI_DEV_UNRESERVED -}; - -/* EE state change event */ -struct mhi_dev_event_ring_ee_state_change { - uint64_t ptr; - uint32_t res1:24; - enum mhi_dev_execenv execenv:8; - uint32_t res2:16; - enum mhi_dev_ring_element_type_id type:8; - uint32_t res3:8; -} __packed; - -/* Generic cmd to parse common details like type and channel id */ -struct mhi_dev_ring_generic { - uint64_t ptr; - uint32_t res1:24; - enum mhi_dev_state mhistate:8; - uint32_t res2:16; - enum mhi_dev_ring_element_type_id type:8; - uint32_t chid:8; -} __packed; - -struct mhi_config { - uint32_t mhi_reg_len; - uint32_t version; - uint32_t event_rings; - uint32_t channels; - uint32_t chdb_offset; - uint32_t erdb_offset; -}; - -#define NUM_CHANNELS 128 -#define HW_CHANNEL_BASE 100 -#define HW_CHANNEL_END 107 -#define MHI_ENV_VALUE 2 -#define MHI_MASK_ROWS_CH_EV_DB 4 -#define TRB_MAX_DATA_SIZE 8192 -#define MHI_CTRL_STATE 25 -#define IPA_DMA_SYNC 1 -#define IPA_DMA_ASYNC 0 - -/*maximum trasnfer completion events buffer*/ -#define MAX_TR_EVENTS 50 -/*maximum event requests */ -#define MHI_MAX_EVT_REQ 50 - -/* Possible ring element types */ -union mhi_dev_ring_element_type { - struct mhi_dev_cmd_ring_op cmd_no_op; - struct mhi_dev_cmd_ring_reset_channel_cmd cmd_reset; - struct mhi_dev_cmd_ring_stop_channel_cmd cmd_stop; - struct mhi_dev_cmd_ring_start_channel_cmd cmd_start; - struct mhi_dev_transfer_ring_element tre; - struct mhi_dev_event_ring_transfer_completion evt_tr_comp; - struct mhi_dev_event_ring_cmd_completion evt_cmd_comp; - struct mhi_dev_event_ring_state_change evt_state_change; - struct mhi_dev_event_ring_ee_state_change evt_ee_state; - struct mhi_dev_ring_generic generic; -}; - -/* Transfer ring element type */ -union mhi_dev_ring_ctx { - struct mhi_dev_cmd_ctx cmd; - struct mhi_dev_ev_ctx ev; - struct mhi_dev_ch_ctx ch; - struct mhi_dev_gen_ctx generic; -}; - -/* MHI host Control and data address region */ -struct mhi_host_addr { - uint32_t ctrl_base_lsb; - uint32_t ctrl_base_msb; - uint32_t ctrl_limit_lsb; - uint32_t ctrl_limit_msb; - uint32_t data_base_lsb; - uint32_t data_base_msb; - uint32_t data_limit_lsb; - uint32_t data_limit_msb; -}; - -/* MHI physical and virtual address region */ -struct mhi_meminfo { - struct device *dev; - uintptr_t pa_aligned; - uintptr_t pa_unaligned; - uintptr_t va_aligned; - uintptr_t va_unaligned; - uintptr_t size; -}; - -struct mhi_addr { - uint64_t host_pa; - uintptr_t device_pa; - uintptr_t device_va; - size_t size; - dma_addr_t phy_addr; - void *virt_addr; - bool use_ipa_dma; -}; - -struct mhi_interrupt_state { - uint32_t mask; - uint32_t status; -}; - -enum mhi_dev_channel_state { - MHI_DEV_CH_UNINT, - MHI_DEV_CH_STARTED, - MHI_DEV_CH_PENDING_START, - MHI_DEV_CH_PENDING_STOP, - MHI_DEV_CH_STOPPED, - MHI_DEV_CH_CLOSED, -}; - -enum mhi_dev_ch_operation { - MHI_DEV_OPEN_CH, - MHI_DEV_CLOSE_CH, - MHI_DEV_READ_CH, - MHI_DEV_READ_WR, - MHI_DEV_POLL, -}; - -enum mhi_ctrl_info { - MHI_STATE_CONFIGURED = 0, - MHI_STATE_CONNECTED = 1, - MHI_STATE_DISCONNECTED = 2, - MHI_STATE_INVAL, -}; - -enum mhi_dev_tr_compl_evt_type { - SEND_EVENT_BUFFER, - SEND_EVENT_RD_OFFSET, -}; - -enum mhi_dev_transfer_type { - MHI_DEV_DMA_SYNC, - MHI_DEV_DMA_ASYNC, -}; - -#if 0 -/* SW channel client list */ -enum mhi_client_channel { - MHI_CLIENT_LOOPBACK_OUT = 0, - MHI_CLIENT_LOOPBACK_IN = 1, - MHI_CLIENT_SAHARA_OUT = 2, - MHI_CLIENT_SAHARA_IN = 3, - MHI_CLIENT_DIAG_OUT = 4, - MHI_CLIENT_DIAG_IN = 5, - MHI_CLIENT_SSR_OUT = 6, - MHI_CLIENT_SSR_IN = 7, - MHI_CLIENT_QDSS_OUT = 8, - MHI_CLIENT_QDSS_IN = 9, - MHI_CLIENT_EFS_OUT = 10, - MHI_CLIENT_EFS_IN = 11, - MHI_CLIENT_MBIM_OUT = 12, - MHI_CLIENT_MBIM_IN = 13, - MHI_CLIENT_QMI_OUT = 14, - MHI_CLIENT_QMI_IN = 15, - MHI_CLIENT_IP_CTRL_0_OUT = 16, - MHI_CLIENT_IP_CTRL_0_IN = 17, - MHI_CLIENT_IP_CTRL_1_OUT = 18, - MHI_CLIENT_IP_CTRL_1_IN = 19, - MHI_CLIENT_DCI_OUT = 20, - MHI_CLIENT_DCI_IN = 21, - MHI_CLIENT_IP_CTRL_3_OUT = 22, - MHI_CLIENT_IP_CTRL_3_IN = 23, - MHI_CLIENT_IP_CTRL_4_OUT = 24, - MHI_CLIENT_IP_CTRL_4_IN = 25, - MHI_CLIENT_IP_CTRL_5_OUT = 26, - MHI_CLIENT_IP_CTRL_5_IN = 27, - MHI_CLIENT_IP_CTRL_6_OUT = 28, - MHI_CLIENT_IP_CTRL_6_IN = 29, - MHI_CLIENT_IP_CTRL_7_OUT = 30, - MHI_CLIENT_IP_CTRL_7_IN = 31, - MHI_CLIENT_DUN_OUT = 32, - MHI_CLIENT_DUN_IN = 33, - MHI_CLIENT_IP_SW_0_OUT = 34, - MHI_CLIENT_IP_SW_0_IN = 35, - MHI_CLIENT_IP_SW_1_OUT = 36, - MHI_CLIENT_IP_SW_1_IN = 37, - MHI_CLIENT_IP_SW_2_OUT = 38, - MHI_CLIENT_IP_SW_2_IN = 39, - MHI_CLIENT_IP_SW_3_OUT = 40, - MHI_CLIENT_IP_SW_3_IN = 41, - MHI_CLIENT_CSVT_OUT = 42, - MHI_CLIENT_CSVT_IN = 43, - MHI_CLIENT_SMCT_OUT = 44, - MHI_CLIENT_SMCT_IN = 45, - MHI_CLIENT_IP_SW_4_OUT = 46, - MHI_CLIENT_IP_SW_4_IN = 47, - MHI_MAX_SOFTWARE_CHANNELS = 48, - MHI_CLIENT_TEST_OUT = 60, - MHI_CLIENT_TEST_IN = 61, - MHI_CLIENT_RESERVED_1_LOWER = 62, - MHI_CLIENT_RESERVED_1_UPPER = 99, - MHI_CLIENT_IP_HW_0_OUT = 100, - MHI_CLIENT_IP_HW_0_IN = 101, - MHI_CLIENT_RESERVED_2_LOWER = 102, - MHI_CLIENT_RESERVED_2_UPPER = 127, - MHI_MAX_CHANNELS = 102, -}; -#endif -#endif /* _SDX20_MHI_H_ */ diff --git a/quectel_MHI/src/devices/Kconfig b/quectel_MHI/src/devices/Kconfig deleted file mode 100644 index d92e95b..0000000 --- a/quectel_MHI/src/devices/Kconfig +++ /dev/null @@ -1,33 +0,0 @@ -menu "MHI device support" - -config MHI_NETDEV - tristate "MHI NETDEV" - depends on MHI_BUS - help - MHI based net device driver for transferring IP traffic - between host and modem. By enabling this driver, clients - can transfer data using standard network interface. Over - the air traffic goes thru mhi netdev interface. - -config MHI_UCI - tristate "MHI UCI" - depends on MHI_BUS - help - MHI based uci driver is for transferring data between host and - modem using standard file operations from user space. Open, read, - write, ioctl, and close operations are supported by this driver. - Please check mhi_uci_match_table for all supported channels that - are exposed to userspace. - -config MHI_SATELLITE - tristate "MHI SATELLITE" - depends on MHI_BUS - help - MHI proxy satellite device driver enables NON-HLOS MHI satellite - drivers to communicate with device over PCIe link without host - involvement. Host facilitates propagation of events from device - to NON-HLOS MHI satellite drivers, channel states, and power - management over IPC communication. It helps in HLOS power - savings. - -endmenu diff --git a/quectel_MHI/src/devices/Makefile b/quectel_MHI/src/devices/Makefile deleted file mode 100644 index e720069..0000000 --- a/quectel_MHI/src/devices/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -obj-$(CONFIG_MHI_NETDEV) +=mhi_netdev.o -obj-$(CONFIG_MHI_UCI) +=mhi_uci.o -obj-$(CONFIG_MHI_SATELLITE) +=mhi_satellite.o diff --git a/quectel_MHI/src/devices/mhi_netdev.c b/quectel_MHI/src/devices/mhi_netdev.c deleted file mode 100644 index ed7b24b..0000000 --- a/quectel_MHI/src/devices/mhi_netdev.c +++ /dev/null @@ -1,1063 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.*/ - -#include -#include -#include -#include -//#include -#include -#include -#include -//#include -#if 1 -static inline void *ipc_log_context_create(int max_num_pages, - const char *modname, uint16_t user_version) -{ return NULL; } -static inline int ipc_log_string(void *ilctxt, const char *fmt, ...) -{ return -EINVAL; } -#endif -#include -#include -#include -#include -#include -#include "../core/mhi.h" - -#define QUECTEL_NO_DTS - -extern void rmnet_data_init(struct net_device *real_dev, u32 nr_rmnet_devs); -extern void rmnet_data_deinit(struct net_device *real_dev, u32 nr_rmnet_devs); - -static const unsigned char node_id[ETH_ALEN] = {0x02, 0x50, 0xf4, 0x00, 0x00, 0x00}; -static const unsigned char default_modem_addr[ETH_ALEN] = {0x02, 0x50, 0xf3, 0x00, 0x00, 0x00}; -static void qmap_hex_dump(const char *tag, unsigned char *data, unsigned len) { - uint i; - uint *d = (uint *)data; - - printk(KERN_DEBUG "%s data=%p, len=%x\n", tag, data, len); - len = (len+3)/4; - for (i = 0; i < len; i+=4) { - printk(KERN_DEBUG "%08x %08x %08x %08x %08x\n", i*4, d[i+0], d[i+1], d[i+2], d[i+3]); - } -} - -#define MHI_NETDEV_DRIVER_NAME "mhi_netdev" -#define WATCHDOG_TIMEOUT (30 * HZ) -#define IPC_LOG_PAGES (100) -#define MAX_NETBUF_SIZE (128) - -#ifdef CONFIG_MHI_DEBUG - -#define IPC_LOG_LVL (MHI_MSG_LVL_VERBOSE) - -#define MHI_ASSERT(cond, msg) do { \ - if (cond) \ - panic(msg); \ -} while (0) - -#define MSG_VERB(fmt, ...) do { \ - if (mhi_netdev->msg_lvl <= MHI_MSG_LVL_VERBOSE) \ - pr_err("[D][%s] " fmt, __func__, ##__VA_ARGS__);\ - if (mhi_netdev->ipc_log && (mhi_netdev->ipc_log_lvl <= \ - MHI_MSG_LVL_VERBOSE)) \ - ipc_log_string(mhi_netdev->ipc_log, "[D][%s] " fmt, \ - __func__, ##__VA_ARGS__); \ -} while (0) - -#else - -#define IPC_LOG_LVL (MHI_MSG_LVL_ERROR) - -#define MHI_ASSERT(cond, msg) do { \ - if (cond) { \ - MSG_ERR(msg); \ - WARN_ON(cond); \ - } \ -} while (0) - -#define MSG_VERB(fmt, ...) - -#endif - -#define MSG_LOG(fmt, ...) do { \ - if (mhi_netdev->msg_lvl <= MHI_MSG_LVL_INFO) \ - pr_err("[I][%s] " fmt, __func__, ##__VA_ARGS__);\ - if (mhi_netdev->ipc_log && (mhi_netdev->ipc_log_lvl <= \ - MHI_MSG_LVL_INFO)) \ - ipc_log_string(mhi_netdev->ipc_log, "[I][%s] " fmt, \ - __func__, ##__VA_ARGS__); \ -} while (0) - -#define MSG_ERR(fmt, ...) do { \ - if (mhi_netdev->msg_lvl <= MHI_MSG_LVL_ERROR) \ - pr_err("[E][%s] " fmt, __func__, ##__VA_ARGS__); \ - if (mhi_netdev->ipc_log && (mhi_netdev->ipc_log_lvl <= \ - MHI_MSG_LVL_ERROR)) \ - ipc_log_string(mhi_netdev->ipc_log, "[E][%s] " fmt, \ - __func__, ##__VA_ARGS__); \ -} while (0) - -struct mhi_net_chain { - struct sk_buff *head, *tail; /* chained skb */ -}; - -struct mhi_netdev { - int alias; - struct mhi_device *mhi_dev; - struct mhi_netdev *rsc_dev; /* rsc linked node */ - bool is_rsc_dev; - int wake; - - u32 mru; - u32 order; - const char *interface_name; - struct napi_struct *napi; - struct net_device *ndev; - bool ethernet_interface; - - struct mhi_netbuf **netbuf_pool; - int pool_size; /* must be power of 2 */ - int current_index; - bool chain_skb; - struct mhi_net_chain *chain; - - struct dentry *dentry; - enum MHI_DEBUG_LEVEL msg_lvl; - enum MHI_DEBUG_LEVEL ipc_log_lvl; - void *ipc_log; - - //struct rmnet_port port; -}; - -struct mhi_netdev_priv { - struct mhi_netdev *mhi_netdev; -}; - -/* Try not to make this structure bigger than 128 bytes, since this take space - * in payload packet. - * Example: If MRU = 16K, effective MRU = 16K - sizeof(mhi_netbuf) - */ -struct mhi_netbuf { - struct mhi_buf mhi_buf; /* this must be first element */ - void (*unmap)(struct device *dev, dma_addr_t addr, size_t size, - enum dma_data_direction dir); -}; - -static struct mhi_driver mhi_netdev_driver; -static void mhi_netdev_create_debugfs(struct mhi_netdev *mhi_netdev); - -static __be16 mhi_netdev_ip_type_trans(u8 data) -{ - __be16 protocol = 0; - - /* determine L3 protocol */ - switch (data & 0xf0) { - case 0x40: - protocol = htons(ETH_P_IP); - break; - case 0x60: - protocol = htons(ETH_P_IPV6); - break; - default: - /* default is QMAP */ - protocol = htons(ETH_P_MAP); - break; - } - protocol = htons(ETH_P_MAP); //carl.yin fix set - return protocol; -} - -static struct mhi_netbuf *mhi_netdev_alloc(struct device *dev, - gfp_t gfp, - unsigned int order) -{ - struct page *page; - struct mhi_netbuf *netbuf; - struct mhi_buf *mhi_buf; - void *vaddr; - - page = __dev_alloc_pages(gfp, order); - if (!page) - return NULL; - - vaddr = page_address(page); - - /* we going to use the end of page to store cached data */ - netbuf = vaddr + (PAGE_SIZE << order) - sizeof(*netbuf); - - mhi_buf = (struct mhi_buf *)netbuf; - mhi_buf->page = page; - mhi_buf->buf = vaddr; - mhi_buf->len = (void *)netbuf - vaddr; - mhi_buf->dma_addr = dma_map_page(dev, page, 0, mhi_buf->len, - DMA_FROM_DEVICE); - if (dma_mapping_error(dev, mhi_buf->dma_addr)) { - __free_pages(mhi_buf->page, order); - return NULL; - } - - return netbuf; -} - -static void mhi_netdev_unmap_page(struct device *dev, - dma_addr_t dma_addr, - size_t len, - enum dma_data_direction dir) -{ - dma_unmap_page(dev, dma_addr, len, dir); -} - -static int mhi_netdev_tmp_alloc(struct mhi_netdev *mhi_netdev, int nr_tre) -{ - struct mhi_device *mhi_dev = mhi_netdev->mhi_dev; - struct device *dev = mhi_dev->dev.parent; - const u32 order = mhi_netdev->order; - int i, ret; - - for (i = 0; i < nr_tre; i++) { - struct mhi_buf *mhi_buf; - struct mhi_netbuf *netbuf = mhi_netdev_alloc(dev, GFP_ATOMIC, - order); - if (!netbuf) - return -ENOMEM; - - mhi_buf = (struct mhi_buf *)netbuf; - netbuf->unmap = mhi_netdev_unmap_page; - - ret = mhi_queue_transfer(mhi_dev, DMA_FROM_DEVICE, mhi_buf, - mhi_buf->len, MHI_EOT); - if (unlikely(ret)) { - MSG_ERR("Failed to queue transfer, ret:%d\n", ret); - mhi_netdev_unmap_page(dev, mhi_buf->dma_addr, - mhi_buf->len, DMA_FROM_DEVICE); - __free_pages(mhi_buf->page, order); - return ret; - } - } - - return 0; -} - -static void mhi_netdev_queue(struct mhi_netdev *mhi_netdev) -{ - struct mhi_device *mhi_dev = mhi_netdev->mhi_dev; - struct device *dev = mhi_dev->dev.parent; - struct mhi_netbuf *netbuf; - struct mhi_buf *mhi_buf; - struct mhi_netbuf **netbuf_pool = mhi_netdev->netbuf_pool; - int nr_tre = mhi_get_no_free_descriptors(mhi_dev, DMA_FROM_DEVICE); - int i, peak, cur_index, ret; - const int pool_size = mhi_netdev->pool_size - 1, max_peak = 4; - - MSG_VERB("Enter free_desc:%d\n", nr_tre); - - if (!nr_tre) - return; - - /* try going thru reclaim pool first */ - for (i = 0; i < nr_tre; i++) { - /* peak for the next buffer, we going to peak several times, - * and we going to give up if buffers are not yet free - */ - cur_index = mhi_netdev->current_index; - netbuf = NULL; - for (peak = 0; peak < max_peak; peak++) { - struct mhi_netbuf *tmp = netbuf_pool[cur_index]; - - mhi_buf = &tmp->mhi_buf; - - cur_index = (cur_index + 1) & pool_size; - - /* page == 1 idle, buffer is free to reclaim */ - if (page_count(mhi_buf->page) == 1) { - netbuf = tmp; - break; - } - } - - /* could not find a free buffer */ - if (!netbuf) - break; - - /* increment reference count so when network stack is done - * with buffer, the buffer won't be freed - */ - get_page(mhi_buf->page); - dma_sync_single_for_device(dev, mhi_buf->dma_addr, mhi_buf->len, - DMA_FROM_DEVICE); - ret = mhi_queue_transfer(mhi_dev, DMA_FROM_DEVICE, mhi_buf, - mhi_buf->len, MHI_EOT); - if (unlikely(ret)) { - MSG_ERR("Failed to queue buffer, ret:%d\n", ret); - netbuf->unmap(dev, mhi_buf->dma_addr, mhi_buf->len, - DMA_FROM_DEVICE); - put_page(mhi_buf->page); - return; - } - mhi_netdev->current_index = cur_index; - } - - /* recyling did not work, buffers are still busy allocate temp pkts */ - if (i < nr_tre) - mhi_netdev_tmp_alloc(mhi_netdev, nr_tre - i); -} - -/* allocating pool of memory */ -static int mhi_netdev_alloc_pool(struct mhi_netdev *mhi_netdev) -{ - int i; - struct mhi_netbuf *netbuf, **netbuf_pool; - struct mhi_buf *mhi_buf; - const u32 order = mhi_netdev->order; - struct device *dev = mhi_netdev->mhi_dev->dev.parent; - - netbuf_pool = kmalloc_array(mhi_netdev->pool_size, sizeof(*netbuf_pool), - GFP_KERNEL); - if (!netbuf_pool) - return -ENOMEM; - - for (i = 0; i < mhi_netdev->pool_size; i++) { - /* allocate paged data */ - netbuf = mhi_netdev_alloc(dev, GFP_KERNEL, order); - if (!netbuf) - goto error_alloc_page; - - netbuf->unmap = dma_sync_single_for_cpu; - netbuf_pool[i] = netbuf; - } - - mhi_netdev->netbuf_pool = netbuf_pool; - - return 0; - -error_alloc_page: - for (--i; i >= 0; i--) { - netbuf = netbuf_pool[i]; - mhi_buf = &netbuf->mhi_buf; - dma_unmap_page(dev, mhi_buf->dma_addr, mhi_buf->len, - DMA_FROM_DEVICE); - __free_pages(mhi_buf->page, order); - } - - kfree(netbuf_pool); - - return -ENOMEM; -} - -static void mhi_netdev_free_pool(struct mhi_netdev *mhi_netdev) -{ - int i; - struct mhi_netbuf *netbuf, **netbuf_pool = mhi_netdev->netbuf_pool; - struct device *dev = mhi_netdev->mhi_dev->dev.parent; - struct mhi_buf *mhi_buf; - - for (i = 0; i < mhi_netdev->pool_size; i++) { - netbuf = netbuf_pool[i]; - mhi_buf = &netbuf->mhi_buf; - dma_unmap_page(dev, mhi_buf->dma_addr, mhi_buf->len, - DMA_FROM_DEVICE); - __free_pages(mhi_buf->page, mhi_netdev->order); - } - - kfree(mhi_netdev->netbuf_pool); - mhi_netdev->netbuf_pool = NULL; -} - -static int mhi_netdev_poll(struct napi_struct *napi, int budget) -{ - struct net_device *dev = napi->dev; - struct mhi_netdev_priv *mhi_netdev_priv = netdev_priv(dev); - struct mhi_netdev *mhi_netdev = mhi_netdev_priv->mhi_netdev; - struct mhi_device *mhi_dev = mhi_netdev->mhi_dev; - struct mhi_netdev *rsc_dev = mhi_netdev->rsc_dev; - struct mhi_net_chain *chain = mhi_netdev->chain; - int rx_work = 0; - - MSG_VERB("Entered\n"); - - rx_work = mhi_poll(mhi_dev, budget); - - /* chained skb, push it to stack */ - if (chain && chain->head) { - netif_receive_skb(chain->head); - chain->head = NULL; - } - - if (rx_work < 0) { - MSG_ERR("Error polling ret:%d\n", rx_work); - napi_complete(napi); - return 0; - } - - /* queue new buffers */ - mhi_netdev_queue(mhi_netdev); - - if (rsc_dev) - mhi_netdev_queue(rsc_dev); - - /* complete work if # of packet processed less than allocated budget */ - if (rx_work < budget) - napi_complete(napi); - - MSG_VERB("polled %d pkts\n", rx_work); - - return rx_work; -} - -static int mhi_netdev_open(struct net_device *dev) -{ - struct mhi_netdev_priv *mhi_netdev_priv = netdev_priv(dev); - struct mhi_netdev *mhi_netdev = mhi_netdev_priv->mhi_netdev; - struct mhi_device *mhi_dev = mhi_netdev->mhi_dev; - - MSG_LOG("Opened net dev interface\n"); - - /* tx queue may not necessarily be stopped already - * so stop the queue if tx path is not enabled - */ - if (!mhi_dev->ul_chan) - netif_stop_queue(dev); - else - netif_start_queue(dev); - - return 0; - -} - -static int mhi_netdev_change_mtu(struct net_device *dev, int new_mtu) -{ - struct mhi_netdev_priv *mhi_netdev_priv = netdev_priv(dev); - struct mhi_netdev *mhi_netdev = mhi_netdev_priv->mhi_netdev; - struct mhi_device *mhi_dev = mhi_netdev->mhi_dev; - - if (new_mtu < 0 || mhi_dev->mtu < new_mtu) - return -EINVAL; - - dev->mtu = new_mtu; - return 0; -} - -static int mhi_netdev_xmit(struct sk_buff *skb, struct net_device *dev) -{ - struct mhi_netdev_priv *mhi_netdev_priv = netdev_priv(dev); - struct mhi_netdev *mhi_netdev = mhi_netdev_priv->mhi_netdev; - struct mhi_device *mhi_dev = mhi_netdev->mhi_dev; - int res = 0; - - MSG_VERB("Entered\n"); - - //printk("%s skb=%p, len=%d, protocol=%x, hdr_len=%d\n", __func__, skb, skb->len, skb->protocol, skb->hdr_len); - //qmap_hex_dump(__func__, skb->data, 32); - if (skb->protocol != htons(ETH_P_MAP)) { - dev_kfree_skb_any(skb); - return NETDEV_TX_OK; - } - - res = mhi_queue_transfer(mhi_dev, DMA_TO_DEVICE, skb, skb->len, - MHI_EOT); - if (res) { - MSG_VERB("Failed to queue with reason:%d\n", res); - netif_stop_queue(dev); - res = NETDEV_TX_BUSY; - } - - MSG_VERB("Exited\n"); - - return res; -} - -#if 0 -static int mhi_netdev_ioctl_extended(struct net_device *dev, struct ifreq *ifr) -{ - struct rmnet_ioctl_extended_s ext_cmd; - int rc = 0; - struct mhi_netdev_priv *mhi_netdev_priv = netdev_priv(dev); - struct mhi_netdev *mhi_netdev = mhi_netdev_priv->mhi_netdev; - struct mhi_device *mhi_dev = mhi_netdev->mhi_dev; - - rc = copy_from_user(&ext_cmd, ifr->ifr_ifru.ifru_data, - sizeof(struct rmnet_ioctl_extended_s)); - if (rc) - return rc; - - switch (ext_cmd.extended_ioctl) { - case RMNET_IOCTL_GET_SUPPORTED_FEATURES: - ext_cmd.u.data = 0; - break; - case RMNET_IOCTL_GET_DRIVER_NAME: - strlcpy(ext_cmd.u.if_name, mhi_netdev->interface_name, - sizeof(ext_cmd.u.if_name)); - break; - case RMNET_IOCTL_SET_SLEEP_STATE: - if (ext_cmd.u.data && mhi_netdev->wake) { - /* Request to enable LPM */ - MSG_VERB("Enable MHI LPM"); - mhi_netdev->wake--; - mhi_device_put(mhi_dev); - } else if (!ext_cmd.u.data && !mhi_netdev->wake) { - /* Request to disable LPM */ - MSG_VERB("Disable MHI LPM"); - mhi_netdev->wake++; - mhi_device_get(mhi_dev); - } - break; - default: - rc = -EINVAL; - break; - } - - rc = copy_to_user(ifr->ifr_ifru.ifru_data, &ext_cmd, - sizeof(struct rmnet_ioctl_extended_s)); - return rc; -} - -static int mhi_netdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) -{ - int rc = 0; - struct rmnet_ioctl_data_s ioctl_data; - - switch (cmd) { - case RMNET_IOCTL_SET_LLP_IP: /* set RAWIP protocol */ - break; - case RMNET_IOCTL_GET_LLP: /* get link protocol state */ - ioctl_data.u.operation_mode = RMNET_MODE_LLP_IP; - if (copy_to_user(ifr->ifr_ifru.ifru_data, &ioctl_data, - sizeof(struct rmnet_ioctl_data_s))) - rc = -EFAULT; - break; - case RMNET_IOCTL_GET_OPMODE: /* get operation mode */ - ioctl_data.u.operation_mode = RMNET_MODE_LLP_IP; - if (copy_to_user(ifr->ifr_ifru.ifru_data, &ioctl_data, - sizeof(struct rmnet_ioctl_data_s))) - rc = -EFAULT; - break; - case RMNET_IOCTL_SET_QOS_ENABLE: - rc = -EINVAL; - break; - case RMNET_IOCTL_SET_QOS_DISABLE: - rc = 0; - break; - case RMNET_IOCTL_OPEN: - case RMNET_IOCTL_CLOSE: - /* we just ignore them and return success */ - rc = 0; - break; - case RMNET_IOCTL_EXTENDED: - rc = mhi_netdev_ioctl_extended(dev, ifr); - break; - default: - /* don't fail any IOCTL right now */ - rc = 0; - break; - } - - return rc; -} -#endif - -static void mhi_netdev_get_drvinfo (struct net_device *ndev, struct ethtool_drvinfo *info) -{ - //struct mhi_netdev *mhi_netdev = ndev_to_mhi(ndev); - - strlcpy (info->driver, "pcie_mhi", sizeof info->driver); - strlcpy (info->version, PCIE_MHI_DRIVER_VERSION, sizeof info->version); -} - -static const struct ethtool_ops mhi_netdev_ethtool_ops = { - .get_drvinfo = mhi_netdev_get_drvinfo, -}; - -static const struct net_device_ops mhi_netdev_ops_ip = { - .ndo_open = mhi_netdev_open, - .ndo_start_xmit = mhi_netdev_xmit, - //.ndo_do_ioctl = mhi_netdev_ioctl, - .ndo_change_mtu = mhi_netdev_change_mtu, - .ndo_set_mac_address = 0, - .ndo_validate_addr = 0, -}; - -static void mhi_netdev_setup(struct net_device *dev) -{ - dev->netdev_ops = &mhi_netdev_ops_ip; - ether_setup(dev); - - /* set this after calling ether_setup */ - dev->header_ops = 0; /* No header */ - dev->type = ARPHRD_RAWIP; - dev->hard_header_len = 0; - dev->addr_len = 0; - dev->flags &= ~(IFF_BROADCAST | IFF_MULTICAST); - dev->watchdog_timeo = WATCHDOG_TIMEOUT; - - dev->ethtool_ops = &mhi_netdev_ethtool_ops; - memcpy (dev->dev_addr, node_id, sizeof node_id); - dev->flags |= IFF_NOARP; -} - -/* enable mhi_netdev netdev, call only after grabbing mhi_netdev.mutex */ -static int mhi_netdev_enable_iface(struct mhi_netdev *mhi_netdev) -{ - int ret = 0; - char ifalias[IFALIASZ]; - char ifname[IFNAMSIZ]; - struct mhi_device *mhi_dev = mhi_netdev->mhi_dev; -#ifndef QUECTEL_NO_DTS - struct device_node *of_node = mhi_dev->dev.of_node; -#endif - struct mhi_netdev_priv *mhi_netdev_priv; - - mhi_netdev->alias = 0;//of_alias_get_id(of_node, "mhi-netdev"); - if (mhi_netdev->alias < 0) - mhi_netdev->alias = 0; - -#ifdef QUECTEL_NO_DTS - mhi_netdev->interface_name = "rmnet_mhi"; -#else - - ret = of_property_read_string(of_node, "mhi,interface-name", - &mhi_netdev->interface_name); -#endif - if (ret) - mhi_netdev->interface_name = mhi_netdev_driver.driver.name; - - snprintf(ifalias, sizeof(ifalias), "%s_%04x_%02u.%02u.%02u_%u", - mhi_netdev->interface_name, mhi_dev->dev_id, mhi_dev->domain, - mhi_dev->bus, mhi_dev->slot, mhi_netdev->alias); - - snprintf(ifname, sizeof(ifname), "%s%%d", mhi_netdev->interface_name); - -#ifdef QUECTEL_NO_DTS - mhi_netdev->ethernet_interface = 0; -#else - mhi_netdev->ethernet_interface = of_property_read_bool(of_node, - "mhi,ethernet-interface"); -#endif - rtnl_lock(); - mhi_netdev->ndev = alloc_netdev(sizeof(*mhi_netdev_priv), - ifname, NET_NAME_PREDICTABLE, - mhi_netdev_setup); - if (!mhi_netdev->ndev) { - rtnl_unlock(); - return -ENOMEM; - } - - mhi_netdev->ndev->mtu = mhi_dev->mtu; - SET_NETDEV_DEV(mhi_netdev->ndev, &mhi_dev->dev); - //dev_set_alias(mhi_netdev->ndev, ifalias, strlen(ifalias)); - mhi_netdev_priv = netdev_priv(mhi_netdev->ndev); - mhi_netdev_priv->mhi_netdev = mhi_netdev; - rtnl_unlock(); - - mhi_netdev->napi = devm_kzalloc(&mhi_dev->dev, - sizeof(*mhi_netdev->napi), GFP_KERNEL); - if (!mhi_netdev->napi) { - ret = -ENOMEM; - goto napi_alloc_fail; - } - - netif_napi_add(mhi_netdev->ndev, mhi_netdev->napi, - mhi_netdev_poll, NAPI_POLL_WEIGHT); - ret = register_netdev(mhi_netdev->ndev); - if (ret) { - MSG_ERR("Network device registration failed\n"); - goto net_dev_reg_fail; - } - - napi_enable(mhi_netdev->napi); - - MSG_LOG("Exited.\n"); - - return 0; - -net_dev_reg_fail: - netif_napi_del(mhi_netdev->napi); - -napi_alloc_fail: - free_netdev(mhi_netdev->ndev); - mhi_netdev->ndev = NULL; - - return ret; -} - -static void mhi_netdev_xfer_ul_cb(struct mhi_device *mhi_dev, - struct mhi_result *mhi_result) -{ - struct mhi_netdev *mhi_netdev = mhi_device_get_devdata(mhi_dev); - struct sk_buff *skb = mhi_result->buf_addr; - struct net_device *ndev = mhi_netdev->ndev; - - ndev->stats.tx_packets++; - ndev->stats.tx_bytes += skb->len; - dev_kfree_skb(skb); - - if (netif_queue_stopped(ndev)) - netif_wake_queue(ndev); -} - -static void mhi_netdev_push_skb(struct mhi_netdev *mhi_netdev, - struct mhi_buf *mhi_buf, - struct mhi_result *mhi_result) -{ - struct sk_buff *skb; - - skb = alloc_skb(0, GFP_ATOMIC); - if (!skb) { - __free_pages(mhi_buf->page, mhi_netdev->order); - return; - } - - if (!mhi_netdev->ethernet_interface) { - skb_add_rx_frag(skb, 0, mhi_buf->page, 0, - mhi_result->bytes_xferd, mhi_netdev->mru); - skb->dev = mhi_netdev->ndev; - skb->protocol = mhi_netdev_ip_type_trans(*(u8 *)mhi_buf->buf); - if (skb_linearize(skb)) - return; - } else { - skb_add_rx_frag(skb, 0, mhi_buf->page, ETH_HLEN, - mhi_result->bytes_xferd - ETH_HLEN, - mhi_netdev->mru); - skb->dev = mhi_netdev->ndev; - skb->protocol = mhi_netdev_ip_type_trans(((u8 *)mhi_buf->buf)[ETH_HLEN]); - } - netif_receive_skb(skb); -} - -static void mhi_netdev_xfer_dl_cb(struct mhi_device *mhi_dev, - struct mhi_result *mhi_result) -{ - struct mhi_netdev *mhi_netdev = mhi_device_get_devdata(mhi_dev); - struct mhi_netbuf *netbuf = mhi_result->buf_addr; - struct mhi_buf *mhi_buf = &netbuf->mhi_buf; - struct sk_buff *skb; - struct net_device *ndev = mhi_netdev->ndev; - struct device *dev = mhi_dev->dev.parent; - struct mhi_net_chain *chain = mhi_netdev->chain; - - netbuf->unmap(dev, mhi_buf->dma_addr, mhi_buf->len, DMA_FROM_DEVICE); - - /* modem is down, drop the buffer */ - if (mhi_result->transaction_status == -ENOTCONN) { - __free_pages(mhi_buf->page, mhi_netdev->order); - return; - } - - ndev->stats.rx_packets++; - ndev->stats.rx_bytes += mhi_result->bytes_xferd; - - if (unlikely(!chain)) { - mhi_netdev_push_skb(mhi_netdev, mhi_buf, mhi_result); - return; - } - - /* we support chaining */ - skb = alloc_skb(0, GFP_ATOMIC); - if (likely(skb)) { - if (!mhi_netdev->ethernet_interface) { - skb_add_rx_frag(skb, 0, mhi_buf->page, 0, - mhi_result->bytes_xferd, mhi_netdev->mru); - } else { - skb_add_rx_frag(skb, 0, mhi_buf->page, ETH_HLEN, - mhi_result->bytes_xferd - ETH_HLEN, - mhi_netdev->mru); - } - - /* this is first on list */ - if (!chain->head) { - skb->dev = ndev; - if (!mhi_netdev->ethernet_interface) { - skb->protocol = - mhi_netdev_ip_type_trans(*(u8 *)mhi_buf->buf); - } else { - skb->protocol = - mhi_netdev_ip_type_trans(((u8 *)mhi_buf->buf)[ETH_HLEN]); - } - chain->head = skb; - } else { - skb_shinfo(chain->tail)->frag_list = skb; - } - - chain->tail = skb; - } else { - __free_pages(mhi_buf->page, mhi_netdev->order); - } -} - -static void mhi_netdev_status_cb(struct mhi_device *mhi_dev, enum MHI_CB mhi_cb) -{ - struct mhi_netdev *mhi_netdev = mhi_device_get_devdata(mhi_dev); - - if (mhi_cb != MHI_CB_PENDING_DATA) - return; - - napi_schedule(mhi_netdev->napi); -} - -#ifdef CONFIG_DEBUG_FS - -struct dentry *dentry; - -static void mhi_netdev_create_debugfs(struct mhi_netdev *mhi_netdev) -{ - char node_name[32]; - struct mhi_device *mhi_dev = mhi_netdev->mhi_dev; - - /* Both tx & rx client handle contain same device info */ - snprintf(node_name, sizeof(node_name), "%s_%04x_%02u.%02u.%02u_%u", - mhi_netdev->interface_name, mhi_dev->dev_id, mhi_dev->domain, - mhi_dev->bus, mhi_dev->slot, mhi_netdev->alias); - - if (IS_ERR_OR_NULL(dentry)) - return; - - mhi_netdev->dentry = debugfs_create_dir(node_name, dentry); - if (IS_ERR_OR_NULL(mhi_netdev->dentry)) - return; -} - -static void mhi_netdev_create_debugfs_dir(void) -{ - dentry = debugfs_create_dir(MHI_NETDEV_DRIVER_NAME, 0); -} - -#else - -static void mhi_netdev_create_debugfs(struct mhi_netdev_private *mhi_netdev) -{ -} - -static void mhi_netdev_create_debugfs_dir(void) -{ -} - -#endif - -static void mhi_netdev_remove(struct mhi_device *mhi_dev) -{ - struct mhi_netdev *mhi_netdev = mhi_device_get_devdata(mhi_dev); - - MSG_LOG("Remove notification received\n"); - - /* rsc parent takes cares of the cleanup */ - if (mhi_netdev->is_rsc_dev) { - mhi_netdev_free_pool(mhi_netdev); - return; - } - - rmnet_data_deinit(mhi_netdev->ndev, 1); - netif_stop_queue(mhi_netdev->ndev); - napi_disable(mhi_netdev->napi); - unregister_netdev(mhi_netdev->ndev); - netif_napi_del(mhi_netdev->napi); - free_netdev(mhi_netdev->ndev); - mhi_netdev_free_pool(mhi_netdev); - - if (!IS_ERR_OR_NULL(mhi_netdev->dentry)) - debugfs_remove_recursive(mhi_netdev->dentry); -} - -static int mhi_netdev_match(struct device *dev, void *data) -{ - /* if phandle dt == device dt, we found a match */ - return (dev->of_node == data); -} - -static void mhi_netdev_clone_dev(struct mhi_netdev *mhi_netdev, - struct mhi_netdev *parent) -{ - mhi_netdev->ndev = parent->ndev; - mhi_netdev->napi = parent->napi; - mhi_netdev->ipc_log = parent->ipc_log; - mhi_netdev->msg_lvl = parent->msg_lvl; - mhi_netdev->ipc_log_lvl = parent->ipc_log_lvl; - mhi_netdev->is_rsc_dev = true; - mhi_netdev->chain = parent->chain; -} - -static int mhi_netdev_probe(struct mhi_device *mhi_dev, - const struct mhi_device_id *id) -{ - int ret; - struct mhi_netdev *mhi_netdev, *p_netdev = NULL; -#ifndef QUECTEL_NO_DTS - struct device_node *of_node = mhi_dev->dev.of_node; -#endif - int nr_tre; - char node_name[32]; - struct device_node *phandle; - bool no_chain; - -#ifndef QUECTEL_NO_DTS - if (!of_node) - return -ENODEV; -#endif - - mhi_netdev = devm_kzalloc(&mhi_dev->dev, sizeof(*mhi_netdev), - GFP_KERNEL); - if (!mhi_netdev) - return -ENOMEM; - - mhi_netdev->mhi_dev = mhi_dev; - mhi_device_set_devdata(mhi_dev, mhi_netdev); - -#ifdef QUECTEL_NO_DTS - mhi_netdev->mru = 16384; - ret = 0; -#else - ret = of_property_read_u32(of_node, "mhi,mru", &mhi_netdev->mru); -#endif - if (ret) - return -ENODEV; - - /* MRU must be multiplication of page size */ - mhi_netdev->order = __ilog2_u32(mhi_netdev->mru / PAGE_SIZE); - if ((PAGE_SIZE << mhi_netdev->order) < mhi_netdev->mru) - return -EINVAL; - - /* check if this device shared by a parent device */ -#ifdef QUECTEL_NO_DTS - phandle = NULL; -#else - phandle = of_parse_phandle(of_node, "mhi,rsc-parent", 0); -#endif - if (phandle) { - struct device *dev; - struct mhi_device *pdev; - /* find the parent device */ - dev = driver_find_device(mhi_dev->dev.driver, NULL, phandle, - mhi_netdev_match); - if (!dev) - return -ENODEV; - - /* this device is shared with parent device. so we won't be - * creating a new network interface. Clone parent - * information to child node - */ - pdev = to_mhi_device(dev); - p_netdev = mhi_device_get_devdata(pdev); - mhi_netdev_clone_dev(mhi_netdev, p_netdev); - put_device(dev); - } else { - mhi_netdev->msg_lvl = MHI_MSG_LVL_ERROR; -#ifdef QUECTEL_NO_DTS - no_chain = 0; -#else - no_chain = of_property_read_bool(of_node, - "mhi,disable-chain-skb"); -#endif - if (!no_chain) { - mhi_netdev->chain = devm_kzalloc(&mhi_dev->dev, - sizeof(*mhi_netdev->chain), - GFP_KERNEL); - if (!mhi_netdev->chain) - return -ENOMEM; - } - - ret = mhi_netdev_enable_iface(mhi_netdev); - if (ret) - return ret; - - /* create ipc log buffer */ - snprintf(node_name, sizeof(node_name), - "%s_%04x_%02u.%02u.%02u_%u", - mhi_netdev->interface_name, mhi_dev->dev_id, - mhi_dev->domain, mhi_dev->bus, mhi_dev->slot, - mhi_netdev->alias); - mhi_netdev->ipc_log = ipc_log_context_create(IPC_LOG_PAGES, - node_name, 0); - mhi_netdev->ipc_log_lvl = IPC_LOG_LVL; - - mhi_netdev_create_debugfs(mhi_netdev); - } - - /* move mhi channels to start state */ - ret = mhi_prepare_for_transfer(mhi_dev); - if (ret) { - MSG_ERR("Failed to start channels ret %d\n", ret); - goto error_start; - } - - rmnet_data_init(mhi_netdev->ndev, 1); - - /* setup pool size ~2x ring length*/ - nr_tre = mhi_get_no_free_descriptors(mhi_dev, DMA_FROM_DEVICE); - mhi_netdev->pool_size = 1 << __ilog2_u32(nr_tre); - if (nr_tre > mhi_netdev->pool_size) - mhi_netdev->pool_size <<= 1; - mhi_netdev->pool_size <<= 1; - - /* allocate memory pool */ - ret = mhi_netdev_alloc_pool(mhi_netdev); - if (ret) - goto error_start; - - /* link child node with parent node if it's children dev */ - if (p_netdev) - p_netdev->rsc_dev = mhi_netdev; - - /* now we have a pool of buffers allocated, queue to hardware - * by triggering a napi_poll - */ - napi_schedule(mhi_netdev->napi); - - return 0; - -error_start: - if (phandle) - return ret; - - netif_stop_queue(mhi_netdev->ndev); - napi_disable(mhi_netdev->napi); - unregister_netdev(mhi_netdev->ndev); - netif_napi_del(mhi_netdev->napi); - free_netdev(mhi_netdev->ndev); - - return ret; -} - -static const struct mhi_device_id mhi_netdev_match_table[] = { - { .chan = "IP_HW0" }, - { .chan = "IP_HW_ADPL" }, - { .chan = "IP_HW0_RSC" }, - { .chan = "IP_SW0" }, - {}, -}; - -static struct mhi_driver mhi_netdev_driver = { - .id_table = mhi_netdev_match_table, - .probe = mhi_netdev_probe, - .remove = mhi_netdev_remove, - .ul_xfer_cb = mhi_netdev_xfer_ul_cb, - .dl_xfer_cb = mhi_netdev_xfer_dl_cb, - .status_cb = mhi_netdev_status_cb, - .driver = { - .name = "mhi_netdev", - .owner = THIS_MODULE, - } -}; - -static int __init mhi_netdev_init(void) -{ - BUILD_BUG_ON(sizeof(struct mhi_netbuf) > MAX_NETBUF_SIZE); - mhi_netdev_create_debugfs_dir(); - - return mhi_driver_register(&mhi_netdev_driver); -} -//module_init(mhi_netdev_init); - -int __init mhi_device_netdev_init(struct dentry *parent) -{ - BUILD_BUG_ON(sizeof(struct mhi_netbuf) > MAX_NETBUF_SIZE); - - return mhi_netdev_init(); -} - -void mhi_device_netdev_exit(void) -{ -#ifdef CONFIG_DEBUG_FS - debugfs_remove_recursive(dentry); -#endif - mhi_driver_unregister(&mhi_netdev_driver); -} - diff --git a/quectel_MHI/src/devices/mhi_netdev_quectel.c b/quectel_MHI/src/devices/mhi_netdev_quectel.c deleted file mode 100644 index 1812c02..0000000 --- a/quectel_MHI/src/devices/mhi_netdev_quectel.c +++ /dev/null @@ -1,3034 +0,0 @@ -/* Copyright (c) 2018, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//#define CONFIG_IPQ5018_RATE_CONTROL //Only used with spf11.5 for IPQ5018 -#if defined(CONFIG_IPQ5018_RATE_CONTROL) -//#include -#include -#endif - -#include "../core/mhi.h" -//#define MHI_NETDEV_ONE_CARD_MODE -//#define ANDROID_gki //some fuction not allow used in this TEST - -#ifndef ETH_P_MAP -#define ETH_P_MAP 0xDA1A -#endif - -#if (ETH_P_MAP == 0x00F9) -#undef ETH_P_MAP -#define ETH_P_MAP 0xDA1A -#endif - -#ifndef ARPHRD_RAWIP -#define ARPHRD_RAWIP ARPHRD_NONE -#endif - -#if (LINUX_VERSION_CODE < KERNEL_VERSION( 4,2,0 )) -static bool netdev_is_rx_handler_busy(struct net_device *dev) -{ - ASSERT_RTNL(); - return dev && rtnl_dereference(dev->rx_handler); -} -#endif - -struct rmnet_nss_cb { - int (*nss_create)(struct net_device *dev); - int (*nss_free)(struct net_device *dev); - int (*nss_tx)(struct sk_buff *skb); -}; -static struct rmnet_nss_cb __read_mostly *nss_cb = NULL; -#if defined(CONFIG_PINCTRL_IPQ807x) || defined(CONFIG_PINCTRL_IPQ5018) || defined(CONFIG_PINCTRL_IPQ8074) -//#ifdef CONFIG_RMNET_DATA //spf12.x have no macro defined, just for spf11.x -#define CONFIG_QCA_NSS_DRV -/* define at qsdk/qca/src/linux-4.4/net/rmnet_data/rmnet_data_main.c */ //for spf11.x -/* define at qsdk/qca/src/datarmnet/core/rmnet_config.c */ //for spf12.x -/* set at qsdk/qca/src/data-kernel/drivers/rmnet-nss/rmnet_nss.c */ -/* need add DEPENDS:= kmod-rmnet-core in feeds/makefile */ -extern struct rmnet_nss_cb *rmnet_nss_callbacks __rcu __read_mostly; -//#endif -#endif - -static const unsigned char node_id[ETH_ALEN] = {0x02, 0x50, 0xf4, 0x00, 0x00, 0x00}; -static const unsigned char default_modem_addr[ETH_ALEN] = {0x02, 0x50, 0xf3, 0x00, 0x00, 0x00}; - -#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE) -#define QUECTEL_BRIDGE_MODE -#endif - -#define QUECTEL_RMNET_MODE - -#ifdef QUECTEL_BRIDGE_MODE -static uint __read_mostly bridge_mode = 0/*|BIT(1)*/; -module_param( bridge_mode, uint, S_IRUGO ); -#endif - -struct qmap_hdr { - u8 cd_rsvd_pad; - u8 mux_id; - u16 pkt_len; -} __packed; -#define QUECTEL_QMAP_MUX_ID 0x81 - -enum rmnet_map_v5_header_type { - RMNET_MAP_HEADER_TYPE_UNKNOWN, - RMNET_MAP_HEADER_TYPE_COALESCING = 0x1, - RMNET_MAP_HEADER_TYPE_CSUM_OFFLOAD = 0x2, - RMNET_MAP_HEADER_TYPE_ENUM_LENGTH -}; - -enum rmnet_map_commands { - RMNET_MAP_COMMAND_NONE, - RMNET_MAP_COMMAND_FLOW_DISABLE, - RMNET_MAP_COMMAND_FLOW_ENABLE, - RMNET_MAP_COMMAND_FLOW_START = 7, - RMNET_MAP_COMMAND_FLOW_END = 8, - /* These should always be the last 2 elements */ - RMNET_MAP_COMMAND_UNKNOWN, - RMNET_MAP_COMMAND_ENUM_LENGTH -}; - -#define RMNET_MAP_COMMAND_REQUEST 0 -#define RMNET_MAP_COMMAND_ACK 1 -#define RMNET_MAP_COMMAND_UNSUPPORTED 2 -#define RMNET_MAP_COMMAND_INVALID 3 - -/* Main QMAP header */ -struct rmnet_map_header { - u8 pad_len:6; - u8 next_hdr:1; - u8 cd_bit:1; - u8 mux_id; - __be16 pkt_len; -} __aligned(1); - -/* QMAP v5 headers */ -struct rmnet_map_v5_csum_header { - u8 next_hdr:1; - u8 header_type:7; - u8 hw_reserved:7; - u8 csum_valid_required:1; - __be16 reserved; -} __aligned(1); - -struct rmnet_map_control_command { - u8 command_name; - u8 cmd_type:2; - u8 reserved:6; - u16 reserved2; - u32 transaction_id; - union { - struct { - u8 reserved2; - u8 ip_family:2; - u8 reserved:6; - __be16 flow_control_seq_num; - __be32 qos_id; - } flow_control; - u8 data[0]; - }; -} __aligned(1); - -struct mhi_mbim_hdr { - struct usb_cdc_ncm_nth16 nth16; - struct usb_cdc_ncm_ndp16 ndp16; - struct usb_cdc_ncm_dpe16 dpe16[2]; -} __attribute__ ((packed)); - -#define QCUSB_MRECEIVE_MAX_BUFFER_SIZE (1024*32) //maybe 31KB is enough -#define QCUSB_MTRANSMIT_MAX_BUFFER_SIZE (1024*16) -#define NTB_OUT_MAX_DATAGRAMS 16 - -static const struct usb_cdc_ncm_ntb_parameters ncmNTBParams = { - .bmNtbFormatsSupported = USB_CDC_NCM_NTB16_SUPPORTED, - .dwNtbInMaxSize = QCUSB_MRECEIVE_MAX_BUFFER_SIZE, - .wNdpInDivisor = 0x04, - .wNdpInPayloadRemainder = 0x0, - .wNdpInAlignment = 0x4, - - .dwNtbOutMaxSize = QCUSB_MTRANSMIT_MAX_BUFFER_SIZE, - .wNdpOutDivisor = 0x04, - .wNdpOutPayloadRemainder = 0x0, - .wNdpOutAlignment = 0x4, - .wNtbOutMaxDatagrams = NTB_OUT_MAX_DATAGRAMS, -}; - -#if 0 -static void qmap_hex_dump(const char *tag, unsigned char *data, unsigned len) { - uint i; - uint *d = (uint *)data; - - printk(KERN_DEBUG "%s data=%p, len=%x\n", tag, data, len); - len = (len+3)/4; - for (i = 0; i < len; i+=4) { - printk(KERN_DEBUG "%08x %08x %08x %08x %08x\n", i*4, d[i+0], d[i+1], d[i+2], d[i+3]); - } -} -#else -static void qmap_hex_dump(const char *tag, unsigned char *data, unsigned len) { -} -#endif - -static uint __read_mostly mhi_mbim_enabled = 0; -module_param(mhi_mbim_enabled, uint, S_IRUGO); -int mhi_netdev_mbin_enabled(void) { return mhi_mbim_enabled; } - -static uint __read_mostly qmap_mode = 1; -module_param(qmap_mode, uint, S_IRUGO); - -static uint __read_mostly poll_weight = NAPI_POLL_WEIGHT; -module_param(poll_weight, uint, S_IRUGO); - -#define MHI_NETDEV_DRIVER_NAME "mhi_netdev" -#define WATCHDOG_TIMEOUT (30 * HZ) - -#define MSG_VERB(fmt, ...) do { \ - if (mhi_netdev->msg_lvl <= MHI_MSG_LVL_VERBOSE) \ - pr_err("[D][%s] " fmt, __func__, ##__VA_ARGS__);\ -} while (0) - -#define MHI_ASSERT(cond, msg) do { \ - if (cond) { \ - MSG_ERR(msg); \ - WARN_ON(cond); \ - } \ -} while (0) - -#define MSG_LOG(fmt, ...) do { \ - if (mhi_netdev->msg_lvl <= MHI_MSG_LVL_INFO) \ - pr_err("[I][%s] " fmt, __func__, ##__VA_ARGS__);\ -} while (0) - -#define MSG_ERR(fmt, ...) do { \ - if (mhi_netdev->msg_lvl <= MHI_MSG_LVL_ERROR) \ - pr_err("[E][%s] " fmt, __func__, ##__VA_ARGS__); \ -} while (0) - -struct mhi_stats { - u32 rx_int; - u32 tx_full; - u32 tx_pkts; - u32 rx_budget_overflow; - u32 tx_allocated; - u32 rx_allocated; - u32 alloc_failed; -}; - -/* important: do not exceed sk_buf->cb (48 bytes) */ -struct mhi_skb_priv { - void *buf; - size_t size; - struct mhi_netdev *bind_netdev; -}; - -struct skb_data { /* skb->cb is one of these */ - struct mhi_netdev *bind_netdev; - unsigned int length; - unsigned int packets; -}; - -#define MHI_NETDEV_STATUS64 1 - -typedef struct { - uint size; - uint rx_urb_size; - uint ep_type; - uint iface_id; - uint MuxId; - uint ul_data_aggregation_max_datagrams; //0x17 - uint ul_data_aggregation_max_size ;//0x18 - uint dl_minimum_padding; //0x1A -} QMAP_SETTING; - -typedef struct { - unsigned int size; - unsigned int rx_urb_size; - unsigned int ep_type; - unsigned int iface_id; - unsigned int qmap_mode; - unsigned int qmap_version; - unsigned int dl_minimum_padding; - char ifname[8][16]; - unsigned char mux_id[8]; -} RMNET_INFO; - -typedef struct { - u16 tx_seq; - u16 rx_seq; - u32 rx_max; -} MHI_MBIM_CTX; - -enum mhi_net_type { - MHI_NET_UNKNOW, - MHI_NET_RMNET, - MHI_NET_MBIM, - MHI_NET_ETHER -}; - -//#define TS_DEBUG -struct mhi_netdev { - int alias; - struct mhi_device *mhi_dev; - spinlock_t rx_lock; - bool enabled; - rwlock_t pm_lock; /* state change lock */ - int (*rx_queue)(struct mhi_netdev *mhi_netdev, gfp_t gfp_t); - struct delayed_work alloc_work; - int wake; - - struct sk_buff_head tx_allocated; - struct sk_buff_head rx_allocated; - struct sk_buff_head qmap_chain; - struct sk_buff_head skb_chain; -#ifdef TS_DEBUG - uint clear_ts; - struct timespec diff_ts; - struct timespec qmap_ts; - struct timespec skb_ts; -#endif - - MHI_MBIM_CTX mbim_ctx; - - u32 mru; - u32 max_mtu; - const char *interface_name; - struct napi_struct napi; - struct net_device *ndev; - enum mhi_net_type net_type; - struct sk_buff *frag_skb; - bool recycle_buf; - -#if defined(MHI_NETDEV_STATUS64) - struct pcpu_sw_netstats __percpu *stats64; -#endif - struct mhi_stats stats; - - struct dentry *dentry; - enum MHI_DEBUG_LEVEL msg_lvl; - - struct net_device *mpQmapNetDev[8]; - u32 qmap_mode; - u32 qmap_version; // 5 ~ QMAP V1, 9 ~ QMAP V5 - u32 qmap_size; - u32 link_state; - u32 flow_control; - u32 dl_minimum_padding; - -#ifdef QUECTEL_BRIDGE_MODE - uint bridge_mode; - uint bridge_ipv4; - unsigned char bridge_mac[ETH_ALEN]; -#endif - uint use_rmnet_usb; - RMNET_INFO rmnet_info; - -#if defined(CONFIG_IPQ5018_RATE_CONTROL) - u64 first_jiffy; - u64 bytes_received_1; - u64 bytes_received_2; - u32 cntfrq_per_msec; - bool mhi_rate_control; -#endif - - u32 rmnet_map_command_stats[RMNET_MAP_COMMAND_ENUM_LENGTH]; -}; - -struct mhi_netdev_priv { - struct mhi_netdev *mhi_netdev; -}; - -struct qmap_priv { - void *pQmapDev; - struct net_device *real_dev; - struct net_device *self_dev; - u8 offset_id; - u8 mux_id; - u8 qmap_version; // 5~v1, 9~v5 - -#if defined(MHI_NETDEV_STATUS64) - struct pcpu_sw_netstats __percpu *stats64; -#endif - - spinlock_t agg_lock; - struct sk_buff *agg_skb; - unsigned agg_count; - struct timespec64 agg_time; - struct hrtimer agg_hrtimer; - struct work_struct agg_wq; - -#ifdef QUECTEL_BRIDGE_MODE - uint bridge_mode; - uint bridge_ipv4; - unsigned char bridge_mac[ETH_ALEN]; -#endif - uint use_qca_nss; -}; - -static struct mhi_netdev *ndev_to_mhi(struct net_device *ndev) { - struct mhi_netdev_priv *mhi_netdev_priv = netdev_priv(ndev); - struct mhi_netdev *mhi_netdev = mhi_netdev_priv->mhi_netdev; - return mhi_netdev; -} - -static struct mhi_driver mhi_netdev_driver; -static void mhi_netdev_create_debugfs(struct mhi_netdev *mhi_netdev); - -#if 0 -static void mhi_netdev_skb_destructor(struct sk_buff *skb) -{ - struct mhi_skb_priv *skb_priv = (struct mhi_skb_priv *)(skb->cb); - struct mhi_netdev *mhi_netdev = skb_priv->mhi_netdev; - - skb->data = skb->head; - skb_reset_tail_pointer(skb); - skb->len = 0; - MHI_ASSERT(skb->data != skb_priv->buf, "incorrect buf"); - skb_queue_tail(&mhi_netdev->rx_allocated, skb); -} -#endif - -#ifdef QUECTEL_BRIDGE_MODE -static const struct net_device_ops mhi_netdev_ops_ip; -static const struct net_device_ops rmnet_vnd_ops; - -static int is_qmap_netdev(const struct net_device *ndev) { - return ndev->netdev_ops == &rmnet_vnd_ops; -} - -static int bridge_arp_reply(struct net_device *net, struct sk_buff *skb, uint bridge_ipv4) { - struct arphdr *parp; - u8 *arpptr, *sha; - u8 sip[4], tip[4], ipv4[4]; - struct sk_buff *reply = NULL; - - ipv4[0] = (bridge_ipv4 >> 24) & 0xFF; - ipv4[1] = (bridge_ipv4 >> 16) & 0xFF; - ipv4[2] = (bridge_ipv4 >> 8) & 0xFF; - ipv4[3] = (bridge_ipv4 >> 0) & 0xFF; - - parp = arp_hdr(skb); - - if (parp->ar_hrd == htons(ARPHRD_ETHER) && parp->ar_pro == htons(ETH_P_IP) - && parp->ar_op == htons(ARPOP_REQUEST) && parp->ar_hln == 6 && parp->ar_pln == 4) { - arpptr = (u8 *)parp + sizeof(struct arphdr); - sha = arpptr; - arpptr += net->addr_len; /* sha */ - memcpy(sip, arpptr, sizeof(sip)); - arpptr += sizeof(sip); - arpptr += net->addr_len; /* tha */ - memcpy(tip, arpptr, sizeof(tip)); - - pr_info("%s sip = %d.%d.%d.%d, tip=%d.%d.%d.%d, ipv4=%d.%d.%d.%d\n", netdev_name(net), - sip[0], sip[1], sip[2], sip[3], tip[0], tip[1], tip[2], tip[3], ipv4[0], ipv4[1], ipv4[2], ipv4[3]); - //wwan0 sip = 10.151.137.255, tip=10.151.138.0, ipv4=10.151.137.255 -#ifndef ANDROID_gki - if (tip[0] == ipv4[0] && tip[1] == ipv4[1] && (tip[2]&0xFC) == (ipv4[2]&0xFC) && tip[3] != ipv4[3]) - reply = arp_create(ARPOP_REPLY, ETH_P_ARP, *((__be32 *)sip), net, *((__be32 *)tip), sha, default_modem_addr, sha); -#endif - - if (reply) { - skb_reset_mac_header(reply); - __skb_pull(reply, skb_network_offset(reply)); - reply->ip_summed = CHECKSUM_UNNECESSARY; - reply->pkt_type = PACKET_HOST; -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)) - netif_rx(reply); -#else - netif_rx_ni(reply); -#endif - } - return 1; - } - - return 0; -} - -static struct sk_buff *bridge_mode_tx_fixup(struct net_device *net, struct sk_buff *skb, uint bridge_ipv4, unsigned char *bridge_mac) { - struct ethhdr *ehdr; - const struct iphdr *iph; - - skb_reset_mac_header(skb); - ehdr = eth_hdr(skb); - - if (ehdr->h_proto == htons(ETH_P_ARP)) { - if (bridge_ipv4) - bridge_arp_reply(net, skb, bridge_ipv4); - return NULL; - } - - iph = ip_hdr(skb); - //DBG("iphdr: "); - //PrintHex((void *)iph, sizeof(struct iphdr)); - -// 1 0.000000000 0.0.0.0 255.255.255.255 DHCP 362 DHCP Request - Transaction ID 0xe7643ad7 - if (ehdr->h_proto == htons(ETH_P_IP) && iph->protocol == IPPROTO_UDP && iph->saddr == 0x00000000 && iph->daddr == 0xFFFFFFFF) { - //if (udp_hdr(skb)->dest == htons(67)) //DHCP Request - { - memcpy(bridge_mac, ehdr->h_source, ETH_ALEN); - pr_info("%s PC Mac Address: %02x:%02x:%02x:%02x:%02x:%02x\n", netdev_name(net), - bridge_mac[0], bridge_mac[1], bridge_mac[2], bridge_mac[3], bridge_mac[4], bridge_mac[5]); - } - } - - if (memcmp(ehdr->h_source, bridge_mac, ETH_ALEN)) { - return NULL; - } - - return skb; -} - -static void bridge_mode_rx_fixup(struct mhi_netdev *mhi_netdev, struct net_device *net, struct sk_buff *skb) { - uint bridge_mode = 0; - unsigned char *bridge_mac; - - if (mhi_netdev->qmap_mode > 0) { - struct qmap_priv *priv = netdev_priv(net); - bridge_mode = priv->bridge_mode; - bridge_mac = priv->bridge_mac; - } - else { - bridge_mode = mhi_netdev->bridge_mode; - bridge_mac = mhi_netdev->bridge_mac; - } - - if (bridge_mode) - memcpy(eth_hdr(skb)->h_dest, bridge_mac, ETH_ALEN); -} - -static ssize_t bridge_mode_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct net_device *ndev = to_net_dev(dev); - uint bridge_mode = 0; - - if (is_qmap_netdev(ndev)) { - struct qmap_priv *priv = netdev_priv(ndev); - bridge_mode = priv->bridge_mode; - } - else { - struct mhi_netdev *mhi_netdev = ndev_to_mhi(ndev); - bridge_mode = mhi_netdev->bridge_mode; - } - - return snprintf(buf, PAGE_SIZE, "%u\n", bridge_mode); -} - -static ssize_t bridge_mode_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - struct net_device *ndev = to_net_dev(dev); - uint bridge_mode = simple_strtoul(buf, NULL, 0); - - if (ndev->type != ARPHRD_ETHER) { - if (bridge_mode) - netdev_err(ndev, "netdevice is not ARPHRD_ETHER\n"); - return count; - } - - if (is_qmap_netdev(ndev)) { - struct qmap_priv *priv = netdev_priv(ndev); - priv->bridge_mode = bridge_mode; - } - else { - struct mhi_netdev *mhi_netdev = ndev_to_mhi(ndev); - mhi_netdev->bridge_mode = bridge_mode; - } - - return count; -} - - -static ssize_t bridge_ipv4_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct net_device *ndev = to_net_dev(dev); - unsigned int bridge_ipv4 = 0; - unsigned char ipv4[4]; - - if (is_qmap_netdev(ndev)) { - struct qmap_priv *priv = netdev_priv(ndev); - bridge_ipv4 = priv->bridge_ipv4; - } - else { - struct mhi_netdev *mhi_netdev = ndev_to_mhi(ndev); - bridge_ipv4 = mhi_netdev->bridge_ipv4; - } - - ipv4[0] = (bridge_ipv4 >> 24) & 0xFF; - ipv4[1] = (bridge_ipv4 >> 16) & 0xFF; - ipv4[2] = (bridge_ipv4 >> 8) & 0xFF; - ipv4[3] = (bridge_ipv4 >> 0) & 0xFF; - - return snprintf(buf, PAGE_SIZE, "%d.%d.%d.%d\n", ipv4[0], ipv4[1], ipv4[2], ipv4[3]); -} - -static ssize_t bridge_ipv4_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - struct net_device *ndev = to_net_dev(dev); - - if (is_qmap_netdev(ndev)) { - struct qmap_priv *priv = netdev_priv(ndev); - priv->bridge_ipv4 = simple_strtoul(buf, NULL, 16); - } - else { - struct mhi_netdev *mhi_netdev = ndev_to_mhi(ndev); - mhi_netdev->bridge_ipv4 = simple_strtoul(buf, NULL, 16); - } - - return count; -} - -static DEVICE_ATTR(bridge_mode, S_IWUSR | S_IRUGO, bridge_mode_show, bridge_mode_store); -static DEVICE_ATTR(bridge_ipv4, S_IWUSR | S_IRUGO, bridge_ipv4_show, bridge_ipv4_store); - -#ifndef MHI_NETDEV_ONE_CARD_MODE -static struct attribute *pcie_mhi_qmap_sysfs_attrs[] = { - &dev_attr_bridge_mode.attr, - &dev_attr_bridge_ipv4.attr, - NULL, -}; - -static struct attribute_group pcie_mhi_qmap_sysfs_attr_group = { - .attrs = pcie_mhi_qmap_sysfs_attrs, -}; -#endif -#endif - -static struct sk_buff * add_mbim_hdr(struct sk_buff *skb, u8 mux_id) { - struct mhi_mbim_hdr *mhdr; - __le32 sign; - u8 *c; - u16 tci = mux_id - QUECTEL_QMAP_MUX_ID; - unsigned int skb_len = skb->len; - - if (qmap_mode > 1) - tci += 1; //rmnet_mhi0.X map to session X - - if (skb_headroom(skb) < sizeof(struct mhi_mbim_hdr)) { - printk("skb_headroom small! headroom is %u, need %zd\n", skb_headroom(skb), sizeof(struct mhi_mbim_hdr)); - return NULL; - } - - skb_push(skb, sizeof(struct mhi_mbim_hdr)); - - mhdr = (struct mhi_mbim_hdr *)skb->data; - - //printk("%s %p\n", __func__, skb->data); - mhdr->nth16.dwSignature = cpu_to_le32(USB_CDC_NCM_NTH16_SIGN); - mhdr->nth16.wHeaderLength = cpu_to_le16(sizeof(struct usb_cdc_ncm_nth16)); -/* - Sequence number. The transmitter of a block shall set this to zero in the first NTB transferred after every 'function reset' event, - and shall increment for every NTB subsequently transferred. - The effect of an out-of-sequence block on the receiver is not specified. - Thespecification allows the receiver to decide whether tocheck the sequence number, - and to decide how to respond if it's incorrect. The sequence number is pri-marily supplied for debugging purposes. -*/ - //mhdr->nth16.wSequence = cpu_to_le16(mhi_netdev->tx_seq++); -/* - Size of this NTB in bytes. Represented in little-endian form. - NTB size (IN/OUT) shall not exceed dwNtbInMaxSize or dwNtbOutMaxSize respectively -*/ - mhdr->nth16.wBlockLength = cpu_to_le16(skb->len); -/* - Offset, in little endian, of the first NDP16 from byte zeroof the NTB. - This value must be a multiple of 4, and must be >= 0x000C -*/ - mhdr->nth16.wNdpIndex = cpu_to_le16(sizeof(struct usb_cdc_ncm_nth16)); - - sign = cpu_to_le32(USB_CDC_MBIM_NDP16_IPS_SIGN); - c = (u8 *)&sign; - c[3] = tci; - - mhdr->ndp16.dwSignature = sign; - mhdr->ndp16.wLength = cpu_to_le16(sizeof(struct usb_cdc_ncm_ndp16) + sizeof(struct usb_cdc_ncm_dpe16) * 2); - mhdr->ndp16.wNextNdpIndex = 0; - - mhdr->ndp16.dpe16[0].wDatagramIndex = sizeof(struct mhi_mbim_hdr); - mhdr->ndp16.dpe16[0].wDatagramLength = skb_len; - - mhdr->ndp16.dpe16[1].wDatagramIndex = 0; - mhdr->ndp16.dpe16[1].wDatagramLength = 0; - - return skb; -} - -static struct sk_buff * add_qhdr(struct sk_buff *skb, u8 mux_id) { - struct qmap_hdr *qhdr; - int pad = 0; - - pad = skb->len%4; - if (pad) { - pad = 4 - pad; - if (skb_tailroom(skb) < pad) { - printk("skb_tailroom small!\n"); - pad = 0; - } - if (pad) - __skb_put(skb, pad); - } - - qhdr = (struct qmap_hdr *)skb_push(skb, sizeof(struct qmap_hdr)); - qhdr->cd_rsvd_pad = pad; - qhdr->mux_id = mux_id; - qhdr->pkt_len = cpu_to_be16(skb->len - sizeof(struct qmap_hdr)); - - return skb; -} - -static struct sk_buff * add_qhdr_v5(struct sk_buff *skb, u8 mux_id) { - struct rmnet_map_header *map_header; - struct rmnet_map_v5_csum_header *ul_header; - u32 padding, map_datalen; - - map_datalen = skb->len; - padding = map_datalen%4; - if (padding) { - padding = 4 - padding; - if (skb_tailroom(skb) < padding) { - printk("skb_tailroom small!\n"); - padding = 0; - } - if (padding) - __skb_put(skb, padding); - } - - map_header = (struct rmnet_map_header *)skb_push(skb, (sizeof(struct rmnet_map_header) + sizeof(struct rmnet_map_v5_csum_header))); - map_header->cd_bit = 0; - map_header->next_hdr = 1; - map_header->pad_len = padding; - map_header->mux_id = mux_id; - map_header->pkt_len = htons(map_datalen + padding); - - ul_header = (struct rmnet_map_v5_csum_header *)(map_header + 1); - memset(ul_header, 0, sizeof(*ul_header)); - ul_header->header_type = RMNET_MAP_HEADER_TYPE_CSUM_OFFLOAD; - if (skb->ip_summed == CHECKSUM_PARTIAL) { -#if 0 //TODO - skb->ip_summed = CHECKSUM_NONE; - /* Ask for checksum offloading */ - ul_header->csum_valid_required = 1; -#endif - } - - return skb; -} - -static void rmnet_map_send_ack(struct mhi_netdev *pQmapDev, - unsigned char type, - struct rmnet_map_header *map_header) -{ - struct rmnet_map_control_command *cmd; - struct sk_buff *skb; - size_t skb_len = sizeof(struct rmnet_map_header) + sizeof(struct rmnet_map_control_command); - - skb = alloc_skb(skb_len, GFP_ATOMIC); - if (!skb) - return; - - skb_put(skb, skb_len); - memcpy(skb->data, map_header, skb_len); - cmd = (struct rmnet_map_control_command *)(skb->data + sizeof(struct rmnet_map_header)); - cmd->cmd_type = type & 0x03; - skb->protocol = htons(ETH_P_MAP); - skb->dev = pQmapDev->ndev; - dev_queue_xmit(skb); -} - -static int rmnet_data_vnd_do_flow_control(struct net_device *dev, - uint32_t map_flow_id, - uint16_t v4_seq, - uint16_t v6_seq, - int enable) -{ - //TODO - return 0; -} - -static uint8_t rmnet_map_do_flow_control(struct mhi_netdev *pQmapDev, - struct rmnet_map_header *map_header, - int enable) { - struct net_device *ndev = pQmapDev->ndev; - struct rmnet_map_control_command *cmd; - struct net_device *vnd; - uint8_t mux_id; - uint16_t ip_family; - uint16_t fc_seq; - uint32_t qos_id; - int r; - - cmd = (struct rmnet_map_control_command *)(map_header + 1); - - mux_id = map_header->mux_id - QUECTEL_QMAP_MUX_ID; - if (mux_id >= pQmapDev->qmap_mode) { - netdev_info(ndev, "drop qmap unknow mux_id %x\n", map_header->mux_id); - return RMNET_MAP_COMMAND_UNSUPPORTED; - } - - vnd = pQmapDev->mpQmapNetDev[mux_id]; - if (vnd == NULL) { - netdev_info(ndev, "drop qmap unknow mux_id %x\n", map_header->mux_id); - return RMNET_MAP_COMMAND_UNSUPPORTED; - } - - ip_family = cmd->flow_control.ip_family; - fc_seq = ntohs(cmd->flow_control.flow_control_seq_num); - qos_id = ntohl(cmd->flow_control.qos_id); - - if (enable) - pQmapDev->flow_control |= (1 << mux_id); - else - pQmapDev->flow_control &= ~(1 << mux_id); - /* Ignore the ip family and pass the sequence number for both v4 and v6 - * sequence. User space does not support creating dedicated flows for - * the 2 protocols - */ - r = rmnet_data_vnd_do_flow_control(vnd, qos_id, fc_seq, fc_seq, enable); - netdev_dbg(vnd, "qos_id:0x%08X, ip_family:%hd, fc_seq %hd, en:%d", - qos_id, ip_family & 3, fc_seq, enable); - - return RMNET_MAP_COMMAND_ACK; -} - -static void rmnet_data_map_command(struct mhi_netdev *pQmapDev, - struct rmnet_map_header *map_header) { - struct net_device *ndev = pQmapDev->ndev; - struct rmnet_map_control_command *cmd; - unsigned char command_name; - unsigned char rc = 0; - - cmd = (struct rmnet_map_control_command *)(map_header + 1); - command_name = cmd->command_name; - - if (command_name < RMNET_MAP_COMMAND_ENUM_LENGTH) - pQmapDev->rmnet_map_command_stats[command_name]++; - - switch (command_name) { - case RMNET_MAP_COMMAND_FLOW_ENABLE: - rc = rmnet_map_do_flow_control(pQmapDev, map_header, 1); - break; - - case RMNET_MAP_COMMAND_FLOW_DISABLE: - rc = rmnet_map_do_flow_control(pQmapDev, map_header, 0); - break; - - default: - pQmapDev->rmnet_map_command_stats[RMNET_MAP_COMMAND_UNKNOWN]++; - netdev_info(ndev, "UNSupport MAP command: %d", command_name); - rc = RMNET_MAP_COMMAND_UNSUPPORTED; - break; - } - - if (rc == RMNET_MAP_COMMAND_ACK) - rmnet_map_send_ack(pQmapDev, rc, map_header); - - return; -} - -#ifndef MHI_NETDEV_ONE_CARD_MODE -static void rmnet_vnd_upate_rx_stats(struct net_device *net, - unsigned rx_packets, unsigned rx_bytes) { -#if defined(MHI_NETDEV_STATUS64) - struct qmap_priv *dev = netdev_priv(net); - struct pcpu_sw_netstats *stats64 = this_cpu_ptr(dev->stats64); - - u64_stats_update_begin(&stats64->syncp); -#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0)) - stats64->rx_packets += rx_packets; - stats64->rx_bytes += rx_bytes; -#else - u64_stats_add(&stats64->rx_packets, rx_packets); - u64_stats_add(&stats64->rx_bytes, rx_bytes); -#endif - u64_stats_update_end(&stats64->syncp); -#else - priv->self_dev->stats.rx_packets += rx_packets; - priv->self_dev->stats.rx_bytes += rx_bytes; -#endif -} - -static void rmnet_vnd_upate_tx_stats(struct net_device *net, - unsigned tx_packets, unsigned tx_bytes) { -#if defined(MHI_NETDEV_STATUS64) - struct qmap_priv *dev = netdev_priv(net); - struct pcpu_sw_netstats *stats64 = this_cpu_ptr(dev->stats64); - - u64_stats_update_begin(&stats64->syncp); -#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0)) - stats64->tx_packets += tx_packets; - stats64->tx_bytes += tx_bytes; -#else - u64_stats_add(&stats64->tx_packets, tx_packets); - u64_stats_add(&stats64->tx_bytes, tx_bytes); -#endif - u64_stats_update_end(&stats64->syncp); -#else - net->stats.rx_packets += tx_packets; - net->stats.rx_bytes += tx_bytes; -#endif -} - -#if defined(MHI_NETDEV_STATUS64) -#ifdef ANDROID_gki -static void _netdev_stats_to_stats64(struct rtnl_link_stats64 *stats64, - const struct net_device_stats *netdev_stats) -{ -#if BITS_PER_LONG == 64 - BUILD_BUG_ON(sizeof(*stats64) < sizeof(*netdev_stats)); - memcpy(stats64, netdev_stats, sizeof(*netdev_stats)); - /* zero out counters that only exist in rtnl_link_stats64 */ - memset((char *)stats64 + sizeof(*netdev_stats), 0, - sizeof(*stats64) - sizeof(*netdev_stats)); -#else - size_t i, n = sizeof(*netdev_stats) / sizeof(unsigned long); - const unsigned long *src = (const unsigned long *)netdev_stats; - u64 *dst = (u64 *)stats64; - - BUILD_BUG_ON(n > sizeof(*stats64) / sizeof(u64)); - for (i = 0; i < n; i++) - dst[i] = src[i]; - /* zero out counters that only exist in rtnl_link_stats64 */ - memset((char *)stats64 + n * sizeof(u64), 0, - sizeof(*stats64) - n * sizeof(u64)); -#endif -} -#else -static void my_netdev_stats_to_stats64(struct rtnl_link_stats64 *stats64, - const struct net_device_stats *netdev_stats) -{ - netdev_stats_to_stats64(stats64, netdev_stats); -} -#endif - -static struct rtnl_link_stats64 *_rmnet_vnd_get_stats64(struct net_device *net, struct rtnl_link_stats64 *stats) -{ - struct qmap_priv *dev = netdev_priv(net); - unsigned int start; - int cpu; - - my_netdev_stats_to_stats64(stats, &net->stats); - - if (nss_cb && dev->use_qca_nss) { // rmnet_nss.c:rmnet_nss_tx() will update rx stats - stats->rx_packets = 0; - stats->rx_bytes = 0; - } - - for_each_possible_cpu(cpu) { - struct pcpu_sw_netstats *stats64; -#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0)) - u64 rx_packets, rx_bytes; - u64 tx_packets, tx_bytes; - - stats64 = per_cpu_ptr(dev->stats64, cpu); - - do { - start = u64_stats_fetch_begin_irq(&stats64->syncp); - rx_packets = stats64->rx_packets; - rx_bytes = stats64->rx_bytes; - tx_packets = stats64->tx_packets; - tx_bytes = stats64->tx_bytes; - } while (u64_stats_fetch_retry_irq(&stats64->syncp, start)); - - stats->rx_packets += rx_packets; - stats->rx_bytes += rx_bytes; - stats->tx_packets += tx_packets; - stats->tx_bytes += tx_bytes; -#else - u64_stats_t rx_packets, rx_bytes; - u64_stats_t tx_packets, tx_bytes; - - stats64 = per_cpu_ptr(dev->stats64, cpu); - - do { - start = u64_stats_fetch_begin(&stats64->syncp); - rx_packets = stats64->rx_packets; - rx_bytes = stats64->rx_bytes; - tx_packets = stats64->tx_packets; - tx_bytes = stats64->tx_bytes; - } while (u64_stats_fetch_retry(&stats64->syncp, start)); - - stats->rx_packets += u64_stats_read(&rx_packets); - stats->rx_bytes += u64_stats_read(&rx_bytes); - stats->tx_packets += u64_stats_read(&tx_packets); - stats->tx_bytes += u64_stats_read(&tx_bytes); -#endif - } - - return stats; -} - -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 4,10,0 )) //bc1f44709cf27fb2a5766cadafe7e2ad5e9cb221 -static void rmnet_vnd_get_stats64(struct net_device *net, struct rtnl_link_stats64 *stats) { - _rmnet_vnd_get_stats64(net, stats); -} -#else -static struct rtnl_link_stats64 *rmnet_vnd_get_stats64(struct net_device *net, struct rtnl_link_stats64 *stats) { - return _rmnet_vnd_get_stats64(net, stats); -} -#endif -#endif - -static void rmnet_vnd_tx_agg_work(struct work_struct *work) -{ - struct qmap_priv *priv = - container_of(work, struct qmap_priv, agg_wq); - struct sk_buff *skb = NULL; - unsigned long flags; - - spin_lock_irqsave(&priv->agg_lock, flags); - if (likely(priv->agg_skb)) { - skb = priv->agg_skb; - priv->agg_skb = NULL; - priv->agg_count = 0; - skb->protocol = htons(ETH_P_MAP); - skb->dev = priv->real_dev; - ktime_get_ts64(&priv->agg_time); - } - spin_unlock_irqrestore(&priv->agg_lock, flags); - - if (skb) - dev_queue_xmit(skb); -} - -static enum hrtimer_restart rmnet_vnd_tx_agg_timer_cb(struct hrtimer *timer) -{ - struct qmap_priv *priv = - container_of(timer, struct qmap_priv, agg_hrtimer); - - schedule_work(&priv->agg_wq); - return HRTIMER_NORESTART; -} - -static int rmnet_vnd_tx_agg(struct sk_buff *skb, struct qmap_priv *priv) { - skb->protocol = htons(ETH_P_MAP); - skb->dev = priv->real_dev; - - return dev_queue_xmit(skb); -} - - -static int rmnet_vnd_open(struct net_device *dev) -{ - struct qmap_priv *priv = netdev_priv(dev); - struct net_device *real_dev = priv->real_dev; - - if (!(priv->real_dev->flags & IFF_UP)) - return -ENETDOWN; - - if (netif_carrier_ok(real_dev)) - netif_carrier_on(dev); - - return 0; -} - -static int rmnet_vnd_stop(struct net_device *pNet) -{ - netif_carrier_off(pNet); - return 0; -} - -static netdev_tx_t rmnet_vnd_start_xmit(struct sk_buff *skb, - struct net_device *pNet) -{ - int err; - struct qmap_priv *priv = netdev_priv(pNet); - struct mhi_netdev *mhi_netdev = ndev_to_mhi(priv->real_dev); - int skb_len = skb->len; - - if (netif_queue_stopped(priv->real_dev)) { - netif_stop_queue(pNet); - return NETDEV_TX_BUSY; - } - - //printk("%s 1 skb=%p, len=%d, protocol=%x, hdr_len=%d\n", __func__, skb, skb->len, skb->protocol, skb->hdr_len); - if (pNet->type == ARPHRD_ETHER) { - skb_reset_mac_header(skb); - -#ifdef QUECTEL_BRIDGE_MODE - if (priv->bridge_mode && bridge_mode_tx_fixup(pNet, skb, priv->bridge_ipv4, priv->bridge_mac) == NULL) { - dev_kfree_skb_any (skb); - return NETDEV_TX_OK; - } -#endif - - if (skb_pull(skb, ETH_HLEN) == NULL) { - dev_kfree_skb_any (skb); - return NETDEV_TX_OK; - } - } - //printk("%s 2 skb=%p, len=%d, protocol=%x, hdr_len=%d\n", __func__, skb, skb->len, skb->protocol, skb->hdr_len); - if (mhi_netdev->net_type == MHI_NET_MBIM) { - if (add_mbim_hdr(skb, priv->mux_id) == NULL) { - dev_kfree_skb_any (skb); - return NETDEV_TX_OK; - } - } - else { - if (priv->qmap_version == 5) { - add_qhdr(skb, priv->mux_id); - } - else if (priv->qmap_version == 9) { - add_qhdr_v5(skb, priv->mux_id); - } - else { - dev_kfree_skb_any (skb); - return NETDEV_TX_OK; - } - } - //printk("%s skb=%p, len=%d, protocol=%x, hdr_len=%d\n", __func__, skb, skb->len, skb->protocol, skb->hdr_len); - - err = rmnet_vnd_tx_agg(skb, priv); - if (err == NET_XMIT_SUCCESS) { - rmnet_vnd_upate_tx_stats(pNet, 1, skb_len); - } else { - pNet->stats.tx_errors++; - } - - return err; -} - -static int rmnet_vnd_change_mtu(struct net_device *rmnet_dev, int new_mtu) -{ - struct mhi_netdev *mhi_netdev; - - mhi_netdev = (struct mhi_netdev *)ndev_to_mhi(rmnet_dev); - - if (mhi_netdev == NULL) { - printk("warning, mhi_netdev == null\n"); - return -EINVAL; - } - - if (new_mtu < 0 ) - return -EINVAL; - - if (new_mtu > mhi_netdev->max_mtu) { - printk("warning, set mtu=%d greater than max mtu=%d\n", new_mtu, mhi_netdev->max_mtu); - return -EINVAL; - } - - rmnet_dev->mtu = new_mtu; - return 0; -} - -/* drivers may override default ethtool_ops in their bind() routine */ -static const struct ethtool_ops rmnet_vnd_ethtool_ops = { - .get_link = ethtool_op_get_link, -}; - -static void rmnet_vnd_rawip_setup(struct net_device *rmnet_dev) -{ - rmnet_dev->needed_headroom = 16; - - /* Raw IP mode */ - rmnet_dev->header_ops = NULL; /* No header */ -//for Qualcomm's NSS, must set type as ARPHRD_RAWIP, or NSS performace is very bad. - rmnet_dev->type = ARPHRD_RAWIP; // do not support moify mac, for dev_set_mac_address() need ARPHRD_ETHER - rmnet_dev->hard_header_len = 0; -//for Qualcomm's SFE, do not add IFF_POINTOPOINT to type, or SFE donot work. - rmnet_dev->flags &= ~(IFF_BROADCAST | IFF_MULTICAST); -} - -static const struct net_device_ops rmnet_vnd_ops = { - .ndo_open = rmnet_vnd_open, - .ndo_stop = rmnet_vnd_stop, - .ndo_start_xmit = rmnet_vnd_start_xmit, -#if defined(MHI_NETDEV_STATUS64) - .ndo_get_stats64 = rmnet_vnd_get_stats64, -#endif - .ndo_change_mtu = rmnet_vnd_change_mtu, - .ndo_set_mac_address = eth_mac_addr, - .ndo_validate_addr = eth_validate_addr, -}; - -static rx_handler_result_t qca_nss_rx_handler(struct sk_buff **pskb) -{ - struct sk_buff *skb = *pskb; - - if (!skb) - return RX_HANDLER_CONSUMED; - - //printk("%s skb=%p, len=%d, protocol=%x, hdr_len=%d\n", __func__, skb, skb->len, skb->protocol, skb->hdr_len); - - if (skb->pkt_type == PACKET_LOOPBACK) - return RX_HANDLER_PASS; - - /* Check this so that we dont loop around netif_receive_skb */ - if (skb->cb[0] == 1) { - skb->cb[0] = 0; - - return RX_HANDLER_PASS; - } - - if (nss_cb) { - nss_cb->nss_tx(skb); - return RX_HANDLER_CONSUMED; - } - - return RX_HANDLER_PASS; -} -#endif - -static void rmnet_mbim_rx_handler(void *dev, struct sk_buff *skb_in) -{ - struct mhi_netdev *pQmapDev = (struct mhi_netdev *)dev; - struct mhi_netdev *mhi_netdev = (struct mhi_netdev *)dev; - MHI_MBIM_CTX *ctx = &pQmapDev->mbim_ctx; - //struct net_device *ndev = pQmapDev->ndev; - struct usb_cdc_ncm_nth16 *nth16; - int ndpoffset, len; - u16 wSequence; - struct sk_buff_head skb_chain; - struct sk_buff *qmap_skb; - - __skb_queue_head_init(&skb_chain); - - if (skb_in->len < (sizeof(struct usb_cdc_ncm_nth16) + sizeof(struct usb_cdc_ncm_ndp16))) { - MSG_ERR("frame too short\n"); - goto error; - } - - nth16 = (struct usb_cdc_ncm_nth16 *)skb_in->data; - - if (nth16->dwSignature != cpu_to_le32(USB_CDC_NCM_NTH16_SIGN)) { - MSG_ERR("invalid NTH16 signature <%#010x>\n", le32_to_cpu(nth16->dwSignature)); - goto error; - } - - len = le16_to_cpu(nth16->wBlockLength); - if (len > ctx->rx_max) { - MSG_ERR("unsupported NTB block length %u/%u\n", len, ctx->rx_max); - goto error; - } - - wSequence = le16_to_cpu(nth16->wSequence); - if (ctx->rx_seq != wSequence) { - MSG_ERR("sequence number glitch prev=%d curr=%d\n", ctx->rx_seq, wSequence); - } - ctx->rx_seq = wSequence + 1; - - ndpoffset = nth16->wNdpIndex; - - while (ndpoffset > 0) { - struct usb_cdc_ncm_ndp16 *ndp16 ; - struct usb_cdc_ncm_dpe16 *dpe16; - int nframes, x; - u8 *c; - u16 tci = 0; - struct net_device *qmap_net; - - if (skb_in->len < (ndpoffset + sizeof(struct usb_cdc_ncm_ndp16))) { - MSG_ERR("invalid NDP offset <%u>\n", ndpoffset); - goto error; - } - - ndp16 = (struct usb_cdc_ncm_ndp16 *)(skb_in->data + ndpoffset); - - if (le16_to_cpu(ndp16->wLength) < 0x10) { - MSG_ERR("invalid DPT16 length <%u>\n", le16_to_cpu(ndp16->wLength)); - goto error; - } - - nframes = ((le16_to_cpu(ndp16->wLength) - sizeof(struct usb_cdc_ncm_ndp16)) / sizeof(struct usb_cdc_ncm_dpe16)); - - if (skb_in->len < (sizeof(struct usb_cdc_ncm_ndp16) + nframes * (sizeof(struct usb_cdc_ncm_dpe16)))) { - MSG_ERR("Invalid nframes = %d\n", nframes); - goto error; - } - - switch (ndp16->dwSignature & cpu_to_le32(0x00ffffff)) { - case cpu_to_le32(USB_CDC_MBIM_NDP16_IPS_SIGN): - c = (u8 *)&ndp16->dwSignature; - tci = c[3]; - /* tag IPS<0> packets too if MBIM_IPS0_VID exists */ - //if (!tci && info->flags & FLAG_IPS0_VLAN) - // tci = MBIM_IPS0_VID; - break; - case cpu_to_le32(USB_CDC_MBIM_NDP16_DSS_SIGN): - c = (u8 *)&ndp16->dwSignature; - tci = c[3] + 256; - break; - default: - MSG_ERR("unsupported NDP signature <0x%08x>\n", le32_to_cpu(ndp16->dwSignature)); - goto error; - } - - if ((qmap_mode == 1 && tci != 0) || (qmap_mode > 1 && tci > qmap_mode)) { - MSG_ERR("unsupported tci %d by now\n", tci); - goto error; - } - tci = abs(tci); - qmap_net = pQmapDev->mpQmapNetDev[qmap_mode == 1 ? 0 : tci - 1]; - - dpe16 = ndp16->dpe16; - - for (x = 0; x < nframes; x++, dpe16++) { - int offset = le16_to_cpu(dpe16->wDatagramIndex); - int skb_len = le16_to_cpu(dpe16->wDatagramLength); - - if (offset == 0 || skb_len == 0) { - break; - } - - /* sanity checking */ - if (((offset + skb_len) > skb_in->len) || (skb_len > ctx->rx_max)) { - MSG_ERR("invalid frame detected (ignored) x=%d, offset=%d, skb_len=%u\n", x, offset, skb_len); - goto error; - } - - qmap_skb = netdev_alloc_skb(qmap_net, skb_len); - if (!qmap_skb) { - mhi_netdev->stats.alloc_failed++; - //MSG_ERR("skb_clone fail\n"); //do not print in softirq - goto error; - } - - switch (skb_in->data[offset] & 0xf0) { - case 0x40: -#ifdef CONFIG_QCA_NSS_PACKET_FILTER - { - struct iphdr *ip4h = (struct iphdr *)(&skb_in->data[offset]); - if (ip4h->protocol == IPPROTO_ICMP) { - qmap_skb->cb[0] = 1; - } - } -#endif - qmap_skb->protocol = htons(ETH_P_IP); - break; - case 0x60: -#ifdef CONFIG_QCA_NSS_PACKET_FILTER - { - struct ipv6hdr *ip6h = (struct ipv6hdr *)(&skb_in->data[offset]); - if (ip6h->nexthdr == NEXTHDR_ICMP) { - qmap_skb->cb[0] = 1; - } - } -#endif - qmap_skb->protocol = htons(ETH_P_IPV6); - break; - default: - MSG_ERR("unknow skb->protocol %02x\n", skb_in->data[offset]); - goto error; - } - - skb_put(qmap_skb, skb_len); - memcpy(qmap_skb->data, skb_in->data + offset, skb_len); - - skb_reset_transport_header(qmap_skb); - skb_reset_network_header(qmap_skb); - qmap_skb->pkt_type = PACKET_HOST; - skb_set_mac_header(qmap_skb, 0); - - if (qmap_skb->dev->type == ARPHRD_ETHER) { - skb_push(qmap_skb, ETH_HLEN); - skb_reset_mac_header(qmap_skb); - memcpy(eth_hdr(qmap_skb)->h_source, default_modem_addr, ETH_ALEN); - memcpy(eth_hdr(qmap_skb)->h_dest, qmap_net->dev_addr, ETH_ALEN); - eth_hdr(qmap_skb)->h_proto = qmap_skb->protocol; -#ifdef QUECTEL_BRIDGE_MODE - bridge_mode_rx_fixup(pQmapDev, qmap_net, qmap_skb); -#endif - __skb_pull(qmap_skb, ETH_HLEN); - } - -#ifndef MHI_NETDEV_ONE_CARD_MODE - rmnet_vnd_upate_rx_stats(qmap_net, 1, skb_len); -#endif - __skb_queue_tail(&skb_chain, qmap_skb); - } - - /* are there more NDPs to process? */ - ndpoffset = le16_to_cpu(ndp16->wNextNdpIndex); - } - -error: - while ((qmap_skb = __skb_dequeue (&skb_chain))) { - netif_receive_skb(qmap_skb); - } -} - -static void rmnet_qmi_rx_handler(void *dev, struct sk_buff *skb_in) -{ - struct mhi_netdev *pQmapDev = (struct mhi_netdev *)dev; - struct net_device *ndev = pQmapDev->ndev; - struct sk_buff *qmap_skb; - struct sk_buff_head skb_chain; - uint dl_minimum_padding = 0; - - if (pQmapDev->qmap_version == 9) - dl_minimum_padding = pQmapDev->dl_minimum_padding; - - __skb_queue_head_init(&skb_chain); - - while (skb_in->len > sizeof(struct qmap_hdr)) { - struct rmnet_map_header *map_header = (struct rmnet_map_header *)skb_in->data; - struct rmnet_map_v5_csum_header *ul_header = NULL; - size_t hdr_size = sizeof(struct rmnet_map_header); - struct net_device *qmap_net; - int pkt_len = ntohs(map_header->pkt_len); - int skb_len; - __be16 protocol; - int mux_id; - int skip_nss = 0; - - if (map_header->next_hdr) { - ul_header = (struct rmnet_map_v5_csum_header *)(map_header + 1); - hdr_size += sizeof(struct rmnet_map_v5_csum_header); - } - - skb_len = pkt_len - (map_header->pad_len&0x3F); -#if 0 //just for debug dl_minimum_padding BUG - if ((skb_in->data[hdr_size] & 0xf0) == 0x45) { - struct iphdr *ip4h = (struct iphdr *)(&skb_in->data[hdr_size]); - if (ntohs(ip4h->tot_len) != skb_len) { - netdev_info(ndev, "tot_len=%d skb_len=%d\n", ntohs(ip4h->tot_len), skb_len); - } - } -#endif - skb_len -= dl_minimum_padding; - - mux_id = map_header->mux_id - QUECTEL_QMAP_MUX_ID; - if (mux_id >= pQmapDev->qmap_mode) { - netdev_info(ndev, "drop qmap unknow mux_id %x\n", map_header->mux_id); - goto error_pkt; - } - mux_id = abs(mux_id); - qmap_net = pQmapDev->mpQmapNetDev[mux_id]; - if (qmap_net == NULL) { - netdev_info(ndev, "drop qmap unknow mux_id %x\n", map_header->mux_id); - goto skip_pkt; - } - - if (skb_len > qmap_net->mtu) { - netdev_info(ndev, "drop skb_len=%x larger than qmap mtu=%d\n", skb_len, qmap_net->mtu); - goto error_pkt; - } - - if (skb_in->len < (pkt_len + hdr_size)) { - netdev_info(ndev, "drop qmap unknow pkt, len=%d, pkt_len=%d\n", skb_in->len, pkt_len); - goto error_pkt; - } - - if (map_header->cd_bit) { - rmnet_data_map_command(pQmapDev, map_header); - goto skip_pkt; - } - - switch (skb_in->data[hdr_size] & 0xf0) { - case 0x40: -#ifdef CONFIG_QCA_NSS_PACKET_FILTER - { - struct iphdr *ip4h = (struct iphdr *)(&skb_in->data[hdr_size]); - if (ip4h->protocol == IPPROTO_ICMP) { - skip_nss = 1; - } - } -#endif - protocol = htons(ETH_P_IP); - break; - case 0x60: -#ifdef CONFIG_QCA_NSS_PACKET_FILTER - { - struct ipv6hdr *ip6h = (struct ipv6hdr *)(&skb_in->data[hdr_size]); - if (ip6h->nexthdr == NEXTHDR_ICMP) { - skip_nss = 1; - } - } -#endif - protocol = htons(ETH_P_IPV6); - break; - default: - netdev_info(ndev, "unknow skb->protocol %02x\n", skb_in->data[hdr_size]); - goto error_pkt; - } - -//for Qualcomm's SFE, do not use skb_clone(), or SFE 's performace is very bad. -//for Qualcomm's NSS, do not use skb_clone(), or NSS 's performace is very bad. - qmap_skb = netdev_alloc_skb(qmap_net, skb_len); - if (qmap_skb) { - skb_put(qmap_skb, skb_len); - memcpy(qmap_skb->data, skb_in->data + hdr_size, skb_len); - } - - if (qmap_skb == NULL) { - pQmapDev->stats.alloc_failed++; - //netdev_info(ndev, "fail to alloc skb, pkt_len = %d\n", skb_len); //do not print in softirq - goto error_pkt; - } - - skb_reset_transport_header(qmap_skb); - skb_reset_network_header(qmap_skb); - qmap_skb->pkt_type = PACKET_HOST; - skb_set_mac_header(qmap_skb, 0); - qmap_skb->protocol = protocol; - - if(skip_nss) - qmap_skb->cb[0] = 1; - - if (ul_header && ul_header->header_type == RMNET_MAP_HEADER_TYPE_CSUM_OFFLOAD - && ul_header->csum_valid_required) { -#if 0 //TODO - qmap_skb->ip_summed = CHECKSUM_UNNECESSARY; -#endif - } - - if (qmap_skb->dev->type == ARPHRD_ETHER) { - skb_push(qmap_skb, ETH_HLEN); - skb_reset_mac_header(qmap_skb); - memcpy(eth_hdr(qmap_skb)->h_source, default_modem_addr, ETH_ALEN); - memcpy(eth_hdr(qmap_skb)->h_dest, qmap_net->dev_addr, ETH_ALEN); - eth_hdr(qmap_skb)->h_proto = protocol; -#ifdef QUECTEL_BRIDGE_MODE - bridge_mode_rx_fixup(pQmapDev, qmap_net, qmap_skb); -#endif - __skb_pull(qmap_skb, ETH_HLEN); - } - -#ifndef MHI_NETDEV_ONE_CARD_MODE - rmnet_vnd_upate_rx_stats(qmap_net, 1, skb_len); -#endif - __skb_queue_tail(&skb_chain, qmap_skb); - -skip_pkt: - skb_pull(skb_in, pkt_len + hdr_size); - } - -error_pkt: - while ((qmap_skb = __skb_dequeue (&skb_chain))) { - netif_receive_skb(qmap_skb); - } -} - -#ifndef MHI_NETDEV_ONE_CARD_MODE -static rx_handler_result_t rmnet_rx_handler(struct sk_buff **pskb) -{ - struct sk_buff *skb = *pskb; - struct mhi_netdev *mhi_netdev; - - if (!skb) - goto done; - - //printk("%s skb=%p, protocol=%x, len=%d\n", __func__, skb, skb->protocol, skb->len); - - if (skb->pkt_type == PACKET_LOOPBACK) - return RX_HANDLER_PASS; - - if (skb->protocol != htons(ETH_P_MAP)) { - WARN_ON(1); - return RX_HANDLER_PASS; - } - /* when open hyfi function, run cm will make system crash */ - //dev = rcu_dereference(skb->dev->rx_handler_data); - mhi_netdev = (struct mhi_netdev *)ndev_to_mhi(skb->dev); - - if (mhi_netdev == NULL) { - WARN_ON(1); - return RX_HANDLER_PASS; - } - - if (mhi_netdev->net_type == MHI_NET_MBIM) - rmnet_mbim_rx_handler(mhi_netdev, skb); - else - rmnet_qmi_rx_handler(mhi_netdev, skb); - - if (!skb_cloned(skb)) { - if (skb_queue_len(&mhi_netdev->rx_allocated) < 128) { - skb->data = skb->head; - skb_reset_tail_pointer(skb); - skb->len = 0; - skb_queue_tail(&mhi_netdev->rx_allocated, skb); - return RX_HANDLER_CONSUMED; - } - } - - consume_skb(skb); - -done: - return RX_HANDLER_CONSUMED; -} - -static struct net_device * rmnet_vnd_register_device(struct mhi_netdev *pQmapDev, u8 offset_id, u8 mux_id) -{ - struct net_device *real_dev = pQmapDev->ndev; - struct net_device *qmap_net; - struct qmap_priv *priv; - int err; - int use_qca_nss = !!nss_cb; - unsigned char temp_addr[ETH_ALEN]; - - qmap_net = alloc_etherdev(sizeof(*priv)); - if (!qmap_net) - return NULL; - - SET_NETDEV_DEV(qmap_net, &real_dev->dev); - priv = netdev_priv(qmap_net); - priv->offset_id = offset_id; - priv->real_dev = pQmapDev->ndev; - priv->self_dev = qmap_net; - priv->pQmapDev = pQmapDev; - priv->qmap_version = pQmapDev->qmap_version; - priv->mux_id = mux_id; - sprintf(qmap_net->name, "%.12s.%d", real_dev->name, offset_id + 1); -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0)) - __dev_addr_set(qmap_net, real_dev->dev_addr, ETH_ALEN); -#else - memcpy (qmap_net->dev_addr, real_dev->dev_addr, ETH_ALEN); -#endif - //qmap_net->dev_addr[5] = offset_id + 1; - //eth_random_addr(qmap_net->dev_addr); - memcpy(temp_addr, qmap_net->dev_addr, ETH_ALEN); - temp_addr[5] = offset_id + 1; -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0)) - __dev_addr_set(qmap_net, temp_addr, ETH_ALEN); -#else - memcpy(qmap_net->dev_addr, temp_addr, ETH_ALEN); -#endif -#if defined(MHI_NETDEV_STATUS64) - priv->stats64 = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); - if (!priv->stats64) - goto out_free_newdev; -#endif - -#ifdef QUECTEL_BRIDGE_MODE - priv->bridge_mode = !!(pQmapDev->bridge_mode & BIT(offset_id)); - qmap_net->sysfs_groups[0] = &pcie_mhi_qmap_sysfs_attr_group; - if (priv->bridge_mode) - use_qca_nss = 0; -#endif - - priv->agg_skb = NULL; - priv->agg_count = 0; - hrtimer_init(&priv->agg_hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); - priv->agg_hrtimer.function = rmnet_vnd_tx_agg_timer_cb; - INIT_WORK(&priv->agg_wq, rmnet_vnd_tx_agg_work); - ktime_get_ts64(&priv->agg_time); - spin_lock_init(&priv->agg_lock); - priv->use_qca_nss = 0; - - qmap_net->ethtool_ops = &rmnet_vnd_ethtool_ops; - qmap_net->netdev_ops = &rmnet_vnd_ops; - qmap_net->flags |= IFF_NOARP; - qmap_net->flags &= ~(IFF_BROADCAST | IFF_MULTICAST); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0) - qmap_net->max_mtu = pQmapDev->max_mtu; -#endif - - if (nss_cb && use_qca_nss) { - rmnet_vnd_rawip_setup(qmap_net); - } -#ifdef CONFIG_PINCTRL_IPQ9574 - rmnet_vnd_rawip_setup(qmap_net); -#endif - if (pQmapDev->net_type == MHI_NET_MBIM) { - qmap_net->needed_headroom = sizeof(struct mhi_mbim_hdr); - } - - err = register_netdev(qmap_net); - pr_info("%s(%s)=%d\n", __func__, qmap_net->name, err); - if (err == -EEXIST) { - //'ifdown wan' for openwrt, why? - } - if (err < 0) - goto out_free_newdev; - - netif_device_attach (qmap_net); - netif_carrier_off(qmap_net); - - if (nss_cb && use_qca_nss) { - int rc = nss_cb->nss_create(qmap_net); - WARN_ON(rc); - if (rc) { - /* Log, but don't fail the device creation */ - netdev_err(qmap_net, "Device will not use NSS path: %d\n", rc); - } else { - priv->use_qca_nss = 1; - netdev_info(qmap_net, "NSS context created\n"); - rtnl_lock(); - netdev_rx_handler_register(qmap_net, qca_nss_rx_handler, NULL); - rtnl_unlock(); - } - } - - return qmap_net; - -out_free_newdev: - free_netdev(qmap_net); - return qmap_net; -} - -static void rmnet_vnd_unregister_device(struct net_device *qmap_net) { - struct qmap_priv *priv; - unsigned long flags; - - pr_info("%s(%s)\n", __func__, qmap_net->name); - netif_carrier_off(qmap_net); - - priv = netdev_priv(qmap_net); - hrtimer_cancel(&priv->agg_hrtimer); - cancel_work_sync(&priv->agg_wq); - - spin_lock_irqsave(&priv->agg_lock, flags); - if (priv->agg_skb) { - kfree_skb(priv->agg_skb); - priv->agg_skb = NULL; - priv->agg_count = 0; - } - spin_unlock_irqrestore(&priv->agg_lock, flags); - - if (nss_cb && priv->use_qca_nss) { - rtnl_lock(); - netdev_rx_handler_unregister(qmap_net); - rtnl_unlock(); - nss_cb->nss_free(qmap_net); - } -#if defined(MHI_NETDEV_STATUS64) - free_percpu(priv->stats64); -#endif - unregister_netdev (qmap_net); - free_netdev(qmap_net); -} -#endif - -static void rmnet_info_set(struct mhi_netdev *pQmapDev, RMNET_INFO *rmnet_info) -{ - rmnet_info->size = sizeof(RMNET_INFO); - rmnet_info->rx_urb_size = pQmapDev->qmap_size; - rmnet_info->ep_type = 3; //DATA_EP_TYPE_PCIE - rmnet_info->iface_id = 4; - rmnet_info->qmap_mode = pQmapDev->qmap_mode; - rmnet_info->qmap_version = pQmapDev->qmap_version; - rmnet_info->dl_minimum_padding = 0; -} - -static ssize_t qmap_mode_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct net_device *ndev = to_net_dev(dev); - struct mhi_netdev *mhi_netdev = ndev_to_mhi(ndev); - - return snprintf(buf, PAGE_SIZE, "%u\n", mhi_netdev->qmap_mode); -} - -static DEVICE_ATTR(qmap_mode, S_IRUGO, qmap_mode_show, NULL); - -static ssize_t qmap_size_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct net_device *ndev = to_net_dev(dev); - struct mhi_netdev *mhi_netdev = ndev_to_mhi(ndev); - - return snprintf(buf, PAGE_SIZE, "%u\n", mhi_netdev->qmap_size); -} - -static DEVICE_ATTR(qmap_size, S_IRUGO, qmap_size_show, NULL); - -static ssize_t link_state_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct net_device *ndev = to_net_dev(dev); - struct mhi_netdev *mhi_netdev = ndev_to_mhi(ndev); - - return snprintf(buf, PAGE_SIZE, "0x%x\n", mhi_netdev->link_state); -} - -static ssize_t link_state_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - struct net_device *ndev = to_net_dev(dev); - struct mhi_netdev *mhi_netdev = ndev_to_mhi(ndev); - //struct mhi_device *mhi_dev = mhi_netdev->mhi_dev; - unsigned link_state = 0; - unsigned old_link = mhi_netdev->link_state; - uint offset_id = 0; - - link_state = simple_strtoul(buf, NULL, 0); - if (mhi_netdev->qmap_mode > 1) { - offset_id = ((link_state&0xF) - 1); - - if (0 < link_state && link_state <= mhi_netdev->qmap_mode) - mhi_netdev->link_state |= (1 << offset_id); - else if (0x80 < link_state && link_state <= (0x80 + mhi_netdev->qmap_mode)) - mhi_netdev->link_state &= ~(1 << offset_id); - } - else { - mhi_netdev->link_state = !!link_state; - } - - if (old_link != mhi_netdev->link_state) { - struct net_device *qmap_net = mhi_netdev->mpQmapNetDev[offset_id]; - - if (mhi_netdev->link_state) - netif_carrier_on(mhi_netdev->ndev); - else { - netif_carrier_off(mhi_netdev->ndev); - } - - if (qmap_net) { - if (mhi_netdev->link_state & (1 << offset_id)) - netif_carrier_on(qmap_net); - else - netif_carrier_off(qmap_net); - } - - dev_info(dev, "link_state 0x%x -> 0x%x\n", old_link, mhi_netdev->link_state); - } - - return count; -} - -static DEVICE_ATTR(link_state, S_IWUSR | S_IRUGO, link_state_show, link_state_store); - -static struct attribute *pcie_mhi_sysfs_attrs[] = { - &dev_attr_qmap_mode.attr, - &dev_attr_qmap_size.attr, - &dev_attr_link_state.attr, -#ifdef QUECTEL_BRIDGE_MODE - &dev_attr_bridge_mode.attr, - &dev_attr_bridge_ipv4.attr, -#endif - NULL, -}; - -static struct attribute_group pcie_mhi_sysfs_attr_group = { - .attrs = pcie_mhi_sysfs_attrs, -}; - -static void mhi_netdev_upate_rx_stats(struct mhi_netdev *mhi_netdev, - unsigned rx_packets, unsigned rx_bytes) { -#if defined(MHI_NETDEV_STATUS64) - struct pcpu_sw_netstats *stats64 = this_cpu_ptr(mhi_netdev->stats64); - - u64_stats_update_begin(&stats64->syncp); -#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0)) - stats64->rx_packets += rx_packets; - stats64->rx_bytes += rx_bytes; -#else - u64_stats_add(&stats64->rx_packets, rx_packets); - u64_stats_add(&stats64->rx_bytes, rx_bytes); -#endif - u64_stats_update_begin(&stats64->syncp); -#else - mhi_netdev->ndev->stats.rx_packets += rx_packets; - mhi_netdev->ndev->stats.rx_bytes += rx_bytes; -#endif -} - -static void mhi_netdev_upate_tx_stats(struct mhi_netdev *mhi_netdev, - unsigned tx_packets, unsigned tx_bytes) { -#if defined(MHI_NETDEV_STATUS64) - struct pcpu_sw_netstats *stats64 = this_cpu_ptr(mhi_netdev->stats64); - - u64_stats_update_begin(&stats64->syncp); -#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0)) - stats64->tx_packets += tx_packets; - stats64->tx_bytes += tx_bytes; -#else - u64_stats_add(&stats64->tx_packets, tx_packets); - u64_stats_add(&stats64->tx_bytes, tx_bytes); -#endif - u64_stats_update_begin(&stats64->syncp); -#else - mhi_netdev->ndev->stats.tx_packets += tx_packets; - mhi_netdev->ndev->stats.tx_bytes += tx_bytes; -#endif -} - -static __be16 mhi_netdev_ip_type_trans(u8 data) -{ - __be16 protocol = 0; - - /* determine L3 protocol */ - switch (data & 0xf0) { - case 0x40: - protocol = htons(ETH_P_IP); - break; - case 0x60: - protocol = htons(ETH_P_IPV6); - break; - default: - protocol = htons(ETH_P_MAP); - break; - } - - return protocol; -} - -static int mhi_netdev_alloc_skb(struct mhi_netdev *mhi_netdev, gfp_t gfp_t) -{ - u32 cur_mru = mhi_netdev->mru; - struct mhi_device *mhi_dev = mhi_netdev->mhi_dev; - struct mhi_skb_priv *skb_priv; - int ret; - struct sk_buff *skb; - int no_tre = mhi_get_no_free_descriptors(mhi_dev, DMA_FROM_DEVICE); - int i; - - for (i = 0; i < no_tre; i++) { - skb = skb_dequeue(&mhi_netdev->rx_allocated); - if (!skb) { - skb = alloc_skb(/*32+*/cur_mru, gfp_t); - if (skb) - mhi_netdev->stats.rx_allocated++; - } - if (!skb) - return -ENOMEM; - - read_lock_bh(&mhi_netdev->pm_lock); - if (unlikely(!mhi_netdev->enabled)) { - MSG_ERR("Interface not enabled\n"); - ret = -EIO; - goto error_queue; - } - - skb_priv = (struct mhi_skb_priv *)skb->cb; - skb_priv->buf = skb->data; - skb_priv->size = cur_mru; - skb_priv->bind_netdev = mhi_netdev; - skb->dev = mhi_netdev->ndev; - //skb_reserve(skb, 32); //for ethernet header - - spin_lock_bh(&mhi_netdev->rx_lock); - ret = mhi_queue_transfer(mhi_dev, DMA_FROM_DEVICE, skb, - skb_priv->size, MHI_EOT); - spin_unlock_bh(&mhi_netdev->rx_lock); - - if (ret) { - skb_priv->bind_netdev = NULL; - MSG_ERR("Failed to queue skb, ret:%d\n", ret); - ret = -EIO; - goto error_queue; - } - - read_unlock_bh(&mhi_netdev->pm_lock); - } - - return 0; - -error_queue: - skb->destructor = NULL; - read_unlock_bh(&mhi_netdev->pm_lock); - dev_kfree_skb_any(skb); - - return ret; -} - -static void mhi_netdev_alloc_work(struct work_struct *work) -{ - struct mhi_netdev *mhi_netdev = container_of(work, struct mhi_netdev, - alloc_work.work); - /* sleep about 1 sec and retry, that should be enough time - * for system to reclaim freed memory back. - */ - const int sleep_ms = 1000; - int retry = 60; - int ret; - - MSG_LOG("Entered\n"); - do { - ret = mhi_netdev_alloc_skb(mhi_netdev, GFP_KERNEL); - /* sleep and try again */ - if (ret == -ENOMEM) { - schedule_delayed_work(&mhi_netdev->alloc_work, msecs_to_jiffies(20)); - return; - msleep(sleep_ms); - retry--; - } - } while (ret == -ENOMEM && retry); - - MSG_LOG("Exit with status:%d retry:%d\n", ret, retry); -} - -static void mhi_netdev_dealloc(struct mhi_netdev *mhi_netdev) -{ - struct sk_buff *skb; - - skb = skb_dequeue(&mhi_netdev->rx_allocated); - while (skb) { - skb->destructor = NULL; - kfree_skb(skb); - skb = skb_dequeue(&mhi_netdev->rx_allocated); - } -} - -static int mhi_netdev_poll(struct napi_struct *napi, int budget) -{ - struct net_device *dev = napi->dev; - struct mhi_netdev_priv *mhi_netdev_priv = netdev_priv(dev); - struct mhi_netdev *mhi_netdev = mhi_netdev_priv->mhi_netdev; - struct mhi_device *mhi_dev = mhi_netdev->mhi_dev; - struct sk_buff *skb; - int rx_work = 0; - int ret; - - MSG_VERB("Entered\n"); - - rx_work = mhi_poll(mhi_dev, budget); - - if (rx_work < 0) { - MSG_ERR("Error polling ret:%d\n", rx_work); - napi_complete(napi); - return 0; - } - - if (mhi_netdev->net_type == MHI_NET_MBIM || mhi_netdev->net_type == MHI_NET_RMNET) { - while ((skb = skb_dequeue (&mhi_netdev->qmap_chain))) { -#ifdef MHI_NETDEV_ONE_CARD_MODE - int recly_skb = 0; - - mhi_netdev_upate_rx_stats(mhi_netdev, 1, skb->len); - if (mhi_netdev->net_type == MHI_NET_MBIM) - rmnet_mbim_rx_handler(mhi_netdev, skb); - else - rmnet_qmi_rx_handler(mhi_netdev, skb); - - if (!skb_cloned(skb)) { - if (skb_queue_len(&mhi_netdev->rx_allocated) < 128) { - skb->data = skb->head; - skb_reset_tail_pointer(skb); - skb->len = 0; - skb_queue_tail(&mhi_netdev->rx_allocated, skb); - recly_skb = 1; - } - } - if (recly_skb == 0) - dev_kfree_skb(skb); -#else - mhi_netdev_upate_rx_stats(mhi_netdev, 1, skb->len); - skb->dev = mhi_netdev->ndev; - skb->protocol = htons(ETH_P_MAP); - netif_receive_skb(skb); -#endif - } - } - else if (mhi_netdev->net_type == MHI_NET_ETHER) { - while ((skb = skb_dequeue (&mhi_netdev->qmap_chain))) { - mhi_netdev_upate_rx_stats(mhi_netdev, 1, skb->len); - skb->dev = mhi_netdev->ndev; - skb->protocol = mhi_netdev_ip_type_trans(skb->data[0]); - netif_receive_skb(skb); - } - } - - /* queue new buffers */ - if (!delayed_work_pending(&mhi_netdev->alloc_work)) { - ret = mhi_netdev->rx_queue(mhi_netdev, GFP_ATOMIC); - if (ret == -ENOMEM) { - //MSG_LOG("out of tre, queuing bg worker\n"); //do not print in softirq - mhi_netdev->stats.alloc_failed++; - schedule_delayed_work(&mhi_netdev->alloc_work, msecs_to_jiffies(20)); - } - } - - /* complete work if # of packet processed less than allocated budget */ - if (rx_work < budget) - napi_complete(napi); - - MSG_VERB("polled %d pkts\n", rx_work); - - return rx_work; -} - -static int mhi_netdev_open(struct net_device *ndev) -{ - struct mhi_netdev *mhi_netdev = ndev_to_mhi(ndev); - struct mhi_device *mhi_dev = mhi_netdev->mhi_dev; - - MSG_LOG("Opened net dev interface\n"); - - /* tx queue may not necessarily be stopped already - * so stop the queue if tx path is not enabled - */ - if (!mhi_dev->ul_chan) - netif_stop_queue(ndev); - else - netif_start_queue(ndev); - - return 0; - -} - -static int mhi_netdev_change_mtu(struct net_device *ndev, int new_mtu) -{ - struct mhi_netdev *mhi_netdev = ndev_to_mhi(ndev); - struct mhi_device *mhi_dev = mhi_netdev->mhi_dev; - - if (new_mtu < 0 || mhi_dev->mtu < new_mtu) - return -EINVAL; - - ndev->mtu = new_mtu; - return 0; -} - -static netdev_tx_t mhi_netdev_xmit(struct sk_buff *skb, struct net_device *dev) -{ - struct mhi_netdev_priv *mhi_netdev_priv = netdev_priv(dev); - struct mhi_netdev *mhi_netdev = mhi_netdev_priv->mhi_netdev; - struct mhi_device *mhi_dev = mhi_netdev->mhi_dev; - int res = 0; - struct skb_data *entry = (struct skb_data *)(skb->cb); - - entry->packets = 1; - entry->length = skb->len; - entry->bind_netdev = mhi_netdev; - - MSG_VERB("Entered\n"); - - //printk("%s skb=%p, len=%d, protocol=%x, hdr_len=%d\n", __func__, skb, skb->len, skb->protocol, skb->hdr_len); - //qmap_hex_dump(__func__, skb->data, 32); - -#ifdef MHI_NETDEV_ONE_CARD_MODE - //printk("%s dev->type=%d\n", __func__, dev->type); - - if (dev->type == ARPHRD_ETHER) { - skb_reset_mac_header(skb); - -#ifdef QUECTEL_BRIDGE_MODE - if (mhi_netdev->bridge_mode && bridge_mode_tx_fixup(dev, skb, mhi_netdev->bridge_ipv4, mhi_netdev->bridge_mac) == NULL) { - dev_kfree_skb_any (skb); - return NETDEV_TX_OK; - } -#endif - - if ((mhi_netdev->net_type == MHI_NET_RMNET || mhi_netdev->net_type == MHI_NET_MBIM) - && (skb_pull(skb, ETH_HLEN) == NULL)) { - dev_kfree_skb_any (skb); - return NETDEV_TX_OK; - } - } - - if (mhi_netdev->net_type == MHI_NET_MBIM) { - if (add_mbim_hdr(skb, QUECTEL_QMAP_MUX_ID) == NULL) { - dev_kfree_skb_any (skb); - return NETDEV_TX_OK; - } - } - else if (mhi_netdev->net_type == MHI_NET_RMNET) { - if (mhi_netdev->qmap_version == 5) { - add_qhdr(skb, QUECTEL_QMAP_MUX_ID); - } - else if (mhi_netdev->qmap_version == 9) { - add_qhdr_v5(skb, QUECTEL_QMAP_MUX_ID); - } - else { - dev_kfree_skb_any (skb); - return NETDEV_TX_OK; - } - } -#else - if ((mhi_netdev->net_type == MHI_NET_RMNET || mhi_netdev->net_type == MHI_NET_MBIM) - && skb->protocol != htons(ETH_P_MAP)) { - dev_kfree_skb_any(skb); - return NETDEV_TX_OK; - } -#endif - - if (mhi_netdev->net_type == MHI_NET_MBIM) { - struct mhi_mbim_hdr *mhdr = (struct mhi_mbim_hdr *)skb->data; - mhdr->nth16.wSequence = cpu_to_le16(mhi_netdev->mbim_ctx.tx_seq++); - } - - if (unlikely(mhi_get_no_free_descriptors(mhi_dev, DMA_TO_DEVICE) < 16)) { - u32 i = 0; - for (i = 0; i < mhi_netdev->qmap_mode; i++) { - struct net_device *qmap_net = mhi_netdev->mpQmapNetDev[i]; - if (qmap_net) { - netif_stop_queue(qmap_net); - } - } - - netif_stop_queue(dev); - } - - res = mhi_queue_transfer(mhi_dev, DMA_TO_DEVICE, skb, skb->len, - MHI_EOT); - - //printk("%s transfer res=%d\n", __func__, res); - if (unlikely(res)) { - dev_kfree_skb_any(skb); - dev->stats.tx_errors++; - } - - MSG_VERB("Exited\n"); - - return NETDEV_TX_OK; -} - -#if defined(MHI_NETDEV_STATUS64) -static struct rtnl_link_stats64 * _mhi_netdev_get_stats64(struct net_device *ndev, struct rtnl_link_stats64 *stats) -{ - struct mhi_netdev *mhi_netdev = ndev_to_mhi(ndev); - - unsigned int start; - int cpu; - - netdev_stats_to_stats64(stats, &ndev->stats); - - for_each_possible_cpu(cpu) { - struct pcpu_sw_netstats *stats64; -#if (LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0)) - u64 rx_packets, rx_bytes; - u64 tx_packets, tx_bytes; - - stats64 = per_cpu_ptr(mhi_netdev->stats64, cpu); - - do { - start = u64_stats_fetch_begin_irq(&stats64->syncp); - rx_packets = stats64->rx_packets; - rx_bytes = stats64->rx_bytes; - tx_packets = stats64->tx_packets; - tx_bytes = stats64->tx_bytes; - } while (u64_stats_fetch_retry_irq(&stats64->syncp, start)); - - stats->rx_packets += rx_packets; - stats->rx_bytes += rx_bytes; - stats->tx_packets += tx_packets; - stats->tx_bytes += tx_bytes; -#else - u64_stats_t rx_packets, rx_bytes; - u64_stats_t tx_packets, tx_bytes; - - stats64 = per_cpu_ptr(mhi_netdev->stats64, cpu); - - do { - start = u64_stats_fetch_begin(&stats64->syncp); - rx_packets = stats64->rx_packets; - rx_bytes = stats64->rx_bytes; - tx_packets = stats64->tx_packets; - tx_bytes = stats64->tx_bytes; - } while (u64_stats_fetch_retry(&stats64->syncp, start)); - - stats->rx_packets += u64_stats_read(&rx_packets); - stats->rx_bytes += u64_stats_read(&rx_bytes); - stats->tx_packets += u64_stats_read(&tx_packets); - stats->tx_bytes += u64_stats_read(&tx_bytes); -#endif - } - - return stats; -} - -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 4,10,0 )) //bc1f44709cf27fb2a5766cadafe7e2ad5e9cb221 -static void mhi_netdev_get_stats64(struct net_device *ndev, struct rtnl_link_stats64 *stats) { - _mhi_netdev_get_stats64(ndev, stats); -} -#else -static struct rtnl_link_stats64 * mhi_netdev_get_stats64(struct net_device *ndev, struct rtnl_link_stats64 *stats) { - _mhi_netdev_get_stats64(ndev, stats); - return stats; -} -#endif -#endif - -static int qmap_setting_store(struct mhi_netdev *mhi_netdev, QMAP_SETTING *qmap_settings, size_t size) { - if (qmap_settings->size != size) { - netdev_err(mhi_netdev->ndev, "ERROR: qmap_settings.size donot match!\n"); - return -EOPNOTSUPP; - } - - mhi_netdev->dl_minimum_padding = qmap_settings->dl_minimum_padding; - - return 0; -} - -static int qmap_ndo_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) { - struct mhi_netdev *mhi_netdev = ndev_to_mhi(dev); - int rc = -EOPNOTSUPP; - uint link_state = 0; - QMAP_SETTING qmap_settings = {0}; - - switch (cmd) { - case 0x89F1: //SIOCDEVPRIVATE - rc = copy_from_user(&link_state, ifr->ifr_ifru.ifru_data, sizeof(link_state)); - if (!rc) { - char buf[32]; - snprintf(buf, sizeof(buf), "%u", link_state); - link_state_store(&dev->dev, NULL, buf, strlen(buf)); - } - break; - - case 0x89F2: //SIOCDEVPRIVATE - rc = copy_from_user(&qmap_settings, ifr->ifr_ifru.ifru_data, sizeof(qmap_settings)); - if (!rc) { - rc = qmap_setting_store(mhi_netdev, &qmap_settings, sizeof(qmap_settings)); - } - break; - - case 0x89F3: //SIOCDEVPRIVATE - if (mhi_netdev->use_rmnet_usb) { - rc = copy_to_user(ifr->ifr_ifru.ifru_data, &mhi_netdev->rmnet_info, sizeof(RMNET_INFO)); - } - break; - - default: - break; - } - - return rc; -} - -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 5,14,0 )) //b9067f5dc4a07c8e24e01a1b277c6722d91be39e -#define use_ndo_siocdevprivate -#endif -#ifdef use_ndo_siocdevprivate -static int qmap_ndo_siocdevprivate(struct net_device *dev, struct ifreq *ifr, void __user *data, int cmd) { - return qmap_ndo_do_ioctl(dev, ifr, cmd); -} -#endif - -static const struct net_device_ops mhi_netdev_ops_ip = { - .ndo_open = mhi_netdev_open, - .ndo_start_xmit = mhi_netdev_xmit, - //.ndo_do_ioctl = mhi_netdev_ioctl, - .ndo_change_mtu = mhi_netdev_change_mtu, -#if defined(MHI_NETDEV_STATUS64) - .ndo_get_stats64 = mhi_netdev_get_stats64, -#endif - .ndo_set_mac_address = eth_mac_addr, - .ndo_validate_addr = eth_validate_addr, - .ndo_do_ioctl = qmap_ndo_do_ioctl, -#ifdef use_ndo_siocdevprivate - .ndo_siocdevprivate = qmap_ndo_siocdevprivate, -#endif -}; - -static void mhi_netdev_get_drvinfo (struct net_device *ndev, struct ethtool_drvinfo *info) -{ - //struct mhi_netdev *mhi_netdev = ndev_to_mhi(ndev); - - strlcpy (info->driver, "pcie_mhi", sizeof info->driver); - strlcpy (info->version, PCIE_MHI_DRIVER_VERSION, sizeof info->version); -} - -static const struct ethtool_ops mhi_netdev_ethtool_ops = { - .get_drvinfo = mhi_netdev_get_drvinfo, - .get_link = ethtool_op_get_link, -}; - -static void mhi_netdev_setup(struct net_device *dev) -{ - dev->netdev_ops = &mhi_netdev_ops_ip; - ether_setup(dev); - - dev->ethtool_ops = &mhi_netdev_ethtool_ops; -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0)) - __dev_addr_set (dev, node_id, sizeof node_id); -#else - memcpy (dev->dev_addr, node_id, sizeof node_id); -#endif - /* set this after calling ether_setup */ - dev->header_ops = 0; /* No header */ - dev->hard_header_len = 0; - dev->type = ARPHRD_NONE; - dev->addr_len = 0; - dev->flags |= IFF_NOARP; - dev->flags &= ~(IFF_BROADCAST | IFF_MULTICAST); //POINTOPOINT will make SFE work wrong - dev->watchdog_timeo = WATCHDOG_TIMEOUT; - //on OpenWrt, if set rmnet_mhi0.1 as WAN, '/sbin/netifd' will auto create VLAN for rmnet_mhi0 - dev->features |= (NETIF_F_VLAN_CHALLENGED); - -#ifdef MHI_NETDEV_ONE_CARD_MODE - if (mhi_mbim_enabled) { - dev->needed_headroom = sizeof(struct mhi_mbim_hdr); - } -#endif -} - -/* enable mhi_netdev netdev, call only after grabbing mhi_netdev.mutex */ -static int mhi_netdev_enable_iface(struct mhi_netdev *mhi_netdev) -{ - int ret = 0; -#if 0 - char ifalias[IFALIASZ]; -#endif - char ifname[IFNAMSIZ]; - struct mhi_device *mhi_dev = mhi_netdev->mhi_dev; - int no_tre; - - MSG_LOG("Prepare the channels for transfer\n"); - - ret = mhi_prepare_for_transfer(mhi_dev); - if (ret) { - MSG_ERR("Failed to start TX chan ret %d\n", ret); - goto mhi_failed_to_start; - } - - /* first time enabling the node */ - if (!mhi_netdev->ndev) { - struct mhi_netdev_priv *mhi_netdev_priv; - -#if 0 - snprintf(ifalias, sizeof(ifalias), "%s_%04x_%02u.%02u.%02u_%u", - mhi_netdev->interface_name, mhi_dev->dev_id, - mhi_dev->domain, mhi_dev->bus, mhi_dev->slot, - mhi_netdev->alias); -#endif - - snprintf(ifname, sizeof(ifname), "%s%d", - mhi_netdev->interface_name, mhi_netdev->mhi_dev->mhi_cntrl->cntrl_idx); - - rtnl_lock(); -#ifdef NET_NAME_PREDICTABLE - mhi_netdev->ndev = alloc_netdev(sizeof(*mhi_netdev_priv), - ifname, NET_NAME_PREDICTABLE, - mhi_netdev_setup); -#else - mhi_netdev->ndev = alloc_netdev(sizeof(*mhi_netdev_priv), - ifname, - mhi_netdev_setup); -#endif - - if (!mhi_netdev->ndev) { - ret = -ENOMEM; - rtnl_unlock(); - goto net_dev_alloc_fail; - } - - //mhi_netdev->ndev->mtu = mhi_dev->mtu; - SET_NETDEV_DEV(mhi_netdev->ndev, &mhi_dev->dev); -#if 0 - dev_set_alias(mhi_netdev->ndev, ifalias, strlen(ifalias)); -#endif - mhi_netdev_priv = netdev_priv(mhi_netdev->ndev); - mhi_netdev_priv->mhi_netdev = mhi_netdev; - - if (mhi_netdev->net_type == MHI_NET_RMNET || mhi_netdev->net_type == MHI_NET_MBIM) { -#ifdef QUECTEL_BRIDGE_MODE - mhi_netdev->bridge_mode = bridge_mode; -#endif - mhi_netdev->ndev->sysfs_groups[0] = &pcie_mhi_sysfs_attr_group; - } - else if (mhi_netdev->net_type == MHI_NET_ETHER) { - mhi_netdev->ndev->mtu = mhi_netdev->mru; - } - rtnl_unlock(); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0) - mhi_netdev->ndev->max_mtu = mhi_netdev->max_mtu; //first net card -#endif - -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)) - netif_napi_add_weight(mhi_netdev->ndev, &mhi_netdev->napi, mhi_netdev_poll, poll_weight); -#else - netif_napi_add(mhi_netdev->ndev, &mhi_netdev->napi, mhi_netdev_poll, poll_weight); -#endif - ret = register_netdev(mhi_netdev->ndev); - if (ret) { - MSG_ERR("Network device registration failed\n"); - goto net_dev_reg_fail; - } - - netif_carrier_off(mhi_netdev->ndev); - } - - write_lock_irq(&mhi_netdev->pm_lock); - mhi_netdev->enabled = true; - write_unlock_irq(&mhi_netdev->pm_lock); - - /* queue buffer for rx path */ - no_tre = mhi_get_no_free_descriptors(mhi_dev, DMA_FROM_DEVICE); - ret = mhi_netdev_alloc_skb(mhi_netdev, GFP_KERNEL); - if (ret) - schedule_delayed_work(&mhi_netdev->alloc_work, msecs_to_jiffies(20)); - - napi_enable(&mhi_netdev->napi); - - MSG_LOG("Exited.\n"); - - return 0; - -net_dev_reg_fail: - netif_napi_del(&mhi_netdev->napi); - free_netdev(mhi_netdev->ndev); - mhi_netdev->ndev = NULL; - -net_dev_alloc_fail: - mhi_unprepare_from_transfer(mhi_dev); - -mhi_failed_to_start: - MSG_ERR("Exited ret %d.\n", ret); - - return ret; -} - -static void mhi_netdev_xfer_ul_cb(struct mhi_device *mhi_dev, - struct mhi_result *mhi_result) -{ - struct mhi_netdev *mhi_netdev = mhi_device_get_devdata(mhi_dev); - struct sk_buff *skb = mhi_result->buf_addr; - struct net_device *ndev = mhi_netdev->ndev; - struct skb_data *entry = (struct skb_data *)(skb->cb); - - if (entry->bind_netdev != mhi_netdev) { - MSG_ERR("%s error!\n", __func__); - return; - } - - if (likely(mhi_result->transaction_status == 0)) { - mhi_netdev_upate_tx_stats(mhi_netdev, entry->packets, entry->length); - - if (netif_queue_stopped(ndev) && mhi_netdev->enabled - && mhi_get_no_free_descriptors(mhi_dev, DMA_TO_DEVICE) > 32) { - int i = 0; - - netif_wake_queue(ndev); - for (i = 0; i < mhi_netdev->qmap_mode; i++) { - struct net_device *qmap_net = mhi_netdev->mpQmapNetDev[i]; - if (qmap_net) { - if (netif_queue_stopped(qmap_net)) - netif_wake_queue(qmap_net); - } - } - } - } - - entry->bind_netdev = NULL; - entry->packets = 1; - entry->length = 0; - dev_kfree_skb(skb); -} - -static void mhi_netdev_xfer_dl_cb(struct mhi_device *mhi_dev, - struct mhi_result *mhi_result) -{ - struct mhi_netdev *mhi_netdev = mhi_device_get_devdata(mhi_dev); - struct sk_buff *skb = mhi_result->buf_addr; - struct mhi_skb_priv *skb_priv = (struct mhi_skb_priv *)(skb->cb); - - if (unlikely(skb_priv->bind_netdev != mhi_netdev)) { - MSG_ERR("%s error!\n", __func__); - return; - } - - if (unlikely(mhi_result->transaction_status)) { - if (mhi_result->transaction_status != -ENOTCONN) - MSG_ERR("%s transaction_status = %d!\n", __func__, mhi_result->transaction_status); - skb_priv->bind_netdev = NULL; - dev_kfree_skb(skb); - return; - } - -#if defined(CONFIG_IPQ5018_RATE_CONTROL) - if (likely(mhi_netdev->mhi_rate_control)) { - u32 time_interval = 0; - u32 time_difference = 0; - u32 cntfrq; - u64 second_jiffy; - u64 bytes_received_2; - struct net_device *ndev = mhi_netdev->ndev; - - if (mhi_netdev->first_jiffy) { - #if LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0) - second_jiffy = arch_counter_get_cntvct(); - #else - second_jiffy = __arch_counter_get_cntvct(); - #endif - bytes_received_2 = mhi_netdev->bytes_received_2; - if ((second_jiffy > mhi_netdev->first_jiffy) && - (bytes_received_2 > mhi_netdev->bytes_received_1)) { - - time_difference = (second_jiffy - mhi_netdev->first_jiffy); - time_interval = (time_difference / mhi_netdev->cntfrq_per_msec); - - /* 1.8Gbps is 225,000,000bytes per second */ - /* We wills sample at 100ms interval */ - /* For 1ms 225000 bytes */ - /* For 100ms 22,500,000 bytes */ - /* For 10ms 2,250,000 bytes */ - - /* 1.7Gbps is 212,500,000bytes per second */ - /* We wills sample at 100ms interval */ - /* For 1ms 212500 bytes */ - /* For 100ms 21,250,000 bytes */ - /* For 10ms 2,125,000 bytes */ - - /* 1.6Gbps is 200,000,000bytes per second */ - /* We wills sample at 100ms interval */ - /* For 1ms 200,000 bytes */ - /* For 100ms 20,000,000 bytes */ - /* For 10ms 2,000,000 bytes */ - - if (time_interval < 100) { - if ((bytes_received_2 - mhi_netdev->bytes_received_1) > 22500000) { - ndev->stats.rx_dropped ++; - dev_kfree_skb(skb); - return; - } - } else { - mhi_netdev->first_jiffy = second_jiffy; - mhi_netdev->bytes_received_1 = bytes_received_2; - } - } else { - mhi_netdev->first_jiffy = second_jiffy; - mhi_netdev->bytes_received_1 = bytes_received_2; - } - } else { - #if LINUX_VERSION_CODE < KERNEL_VERSION(5,2,0) - mhi_netdev->first_jiffy = arch_counter_get_cntvct(); - #else - mhi_netdev->first_jiffy = __arch_counter_get_cntvct(); - #endif - - cntfrq = arch_timer_get_cntfrq(); - mhi_netdev->cntfrq_per_msec = cntfrq / 1000; - } - mhi_netdev->bytes_received_2 += mhi_result->bytes_xferd; - } -#endif - -#if 0 - { - static size_t bytes_xferd = 0; - if (mhi_result->bytes_xferd > bytes_xferd) { - bytes_xferd = mhi_result->bytes_xferd; - printk(KERN_DEBUG "bytes_xferd=%zd\n", bytes_xferd); - } - } -#endif - - skb_put(skb, mhi_result->bytes_xferd); - - qmap_hex_dump(__func__, skb->data, skb->len); - - skb_priv->bind_netdev = NULL; - skb_queue_tail(&mhi_netdev->qmap_chain, skb); -} - -static void mhi_netdev_status_cb(struct mhi_device *mhi_dev, enum MHI_CB mhi_cb) -{ - struct mhi_netdev *mhi_netdev = mhi_device_get_devdata(mhi_dev); - - if (mhi_cb != MHI_CB_PENDING_DATA) - return; - - if (napi_schedule_prep(&mhi_netdev->napi)) { - __napi_schedule(&mhi_netdev->napi); - mhi_netdev->stats.rx_int++; - return; - } -} - -#ifdef CONFIG_DEBUG_FS - -struct dentry *mhi_netdev_debugfs_dentry; - -static int mhi_netdev_init_debugfs_states_show(struct seq_file *m, void *d) -{ - struct mhi_netdev *mhi_netdev = m->private; - struct mhi_device *mhi_dev = mhi_netdev->mhi_dev; - -#ifdef TS_DEBUG - struct timespec now_ts, diff_ts; - getnstimeofday(&now_ts); - diff_ts = timespec_sub(now_ts, mhi_netdev->diff_ts); - mhi_netdev->diff_ts = now_ts; -#endif - - seq_printf(m, - "tx_tre:%d rx_tre:%d qmap_chain:%u skb_chain:%u tx_allocated:%u rx_allocated:%u\n", - mhi_get_no_free_descriptors(mhi_dev, DMA_TO_DEVICE), - mhi_get_no_free_descriptors(mhi_dev, DMA_FROM_DEVICE), - mhi_netdev->qmap_chain.qlen, - mhi_netdev->skb_chain.qlen, - mhi_netdev->tx_allocated.qlen, - mhi_netdev->rx_allocated.qlen); - - seq_printf(m, - "netif_queue_stopped:%d, link_state:0x%x, flow_control:0x%x\n", - netif_queue_stopped(mhi_netdev->ndev), mhi_netdev->link_state, mhi_netdev->flow_control); - - seq_printf(m, - "rmnet_map_command_stats: %u, %u, %u, %u, %u, %u, %u, %u, %u, %u\n", - mhi_netdev->rmnet_map_command_stats[RMNET_MAP_COMMAND_NONE], - mhi_netdev->rmnet_map_command_stats[RMNET_MAP_COMMAND_FLOW_DISABLE], - mhi_netdev->rmnet_map_command_stats[RMNET_MAP_COMMAND_FLOW_ENABLE], - mhi_netdev->rmnet_map_command_stats[3], - mhi_netdev->rmnet_map_command_stats[4], - mhi_netdev->rmnet_map_command_stats[5], - mhi_netdev->rmnet_map_command_stats[6], - mhi_netdev->rmnet_map_command_stats[RMNET_MAP_COMMAND_FLOW_START], - mhi_netdev->rmnet_map_command_stats[RMNET_MAP_COMMAND_FLOW_END], - mhi_netdev->rmnet_map_command_stats[RMNET_MAP_COMMAND_UNKNOWN]); - -#ifdef TS_DEBUG - seq_printf(m, - "qmap_ts:%ld.%ld, skb_ts:%ld.%ld, diff_ts:%ld.%ld\n", - mhi_netdev->qmap_ts.tv_sec, mhi_netdev->qmap_ts.tv_nsec, - mhi_netdev->skb_ts.tv_sec, mhi_netdev->skb_ts.tv_nsec, - diff_ts.tv_sec, diff_ts.tv_nsec); - mhi_netdev->clear_ts = 1; -#endif - - return 0; -} - -static int mhi_netdev_init_debugfs_states_open(struct inode *inode, - struct file *fp) -{ - return single_open(fp, mhi_netdev_init_debugfs_states_show, inode->i_private); -} - -static const struct file_operations mhi_netdev_debugfs_state_ops = { - .open = mhi_netdev_init_debugfs_states_open, - .release = single_release, - .read = seq_read, -}; - -static int mhi_netdev_debugfs_trigger_reset(void *data, u64 val) -{ - struct mhi_netdev *mhi_netdev = data; - struct mhi_device *mhi_dev = mhi_netdev->mhi_dev; - int ret; - - MSG_LOG("Triggering channel reset\n"); - - /* disable the interface so no data processing */ - write_lock_irq(&mhi_netdev->pm_lock); - mhi_netdev->enabled = false; - write_unlock_irq(&mhi_netdev->pm_lock); - napi_disable(&mhi_netdev->napi); - - /* disable all hardware channels */ - mhi_unprepare_from_transfer(mhi_dev); - - /* clean up all alocated buffers */ - mhi_netdev_dealloc(mhi_netdev); - - MSG_LOG("Restarting iface\n"); - - ret = mhi_netdev_enable_iface(mhi_netdev); - if (ret) - return ret; - - return 0; -} -DEFINE_SIMPLE_ATTRIBUTE(mhi_netdev_debugfs_trigger_reset_fops, NULL, - mhi_netdev_debugfs_trigger_reset, "%llu\n"); - -static void mhi_netdev_create_debugfs(struct mhi_netdev *mhi_netdev) -{ - char node_name[32]; - int i; - const umode_t mode = 0600; - struct mhi_device *mhi_dev = mhi_netdev->mhi_dev; - struct dentry *dentry = mhi_netdev_debugfs_dentry; - - const struct { - char *name; - u32 *ptr; - } debugfs_table[] = { - { - "rx_int", - &mhi_netdev->stats.rx_int - }, - { - "tx_full", - &mhi_netdev->stats.tx_full - }, - { - "tx_pkts", - &mhi_netdev->stats.tx_pkts - }, - { - "rx_budget_overflow", - &mhi_netdev->stats.rx_budget_overflow - }, - { - "rx_allocated", - &mhi_netdev->stats.rx_allocated - }, - { - "tx_allocated", - &mhi_netdev->stats.tx_allocated - }, - { - "alloc_failed", - &mhi_netdev->stats.alloc_failed - }, - { - NULL, NULL - }, - }; - - /* Both tx & rx client handle contain same device info */ - snprintf(node_name, sizeof(node_name), "%s_%04x_%02u.%02u.%02u_%u", - mhi_netdev->interface_name, mhi_dev->dev_id, mhi_dev->domain, - mhi_dev->bus, mhi_dev->slot, mhi_netdev->alias); - - if (IS_ERR_OR_NULL(dentry)) - return; - - mhi_netdev->dentry = debugfs_create_dir(node_name, dentry); - if (IS_ERR_OR_NULL(mhi_netdev->dentry)) - return; - - debugfs_create_u32("msg_lvl", mode, mhi_netdev->dentry, - (u32 *)&mhi_netdev->msg_lvl); - - /* Add debug stats table */ - for (i = 0; debugfs_table[i].name; i++) { - debugfs_create_u32(debugfs_table[i].name, mode, - mhi_netdev->dentry, - debugfs_table[i].ptr); - } - - debugfs_create_file("reset", mode, mhi_netdev->dentry, mhi_netdev, - &mhi_netdev_debugfs_trigger_reset_fops); - debugfs_create_file("states", 0444, mhi_netdev->dentry, mhi_netdev, - &mhi_netdev_debugfs_state_ops); -} - -static void mhi_netdev_create_debugfs_dir(struct dentry *parent) -{ - mhi_netdev_debugfs_dentry = debugfs_create_dir(MHI_NETDEV_DRIVER_NAME, parent); -} - -#else - -static void mhi_netdev_create_debugfs(struct mhi_netdev *mhi_netdev) -{ -} - -static void mhi_netdev_create_debugfs_dir(struct dentry *parent) -{ -} - -#endif - -static void mhi_netdev_remove(struct mhi_device *mhi_dev) -{ - struct mhi_netdev *mhi_netdev = mhi_device_get_devdata(mhi_dev); - struct sk_buff *skb; - - MSG_LOG("Remove notification received\n"); - - write_lock_irq(&mhi_netdev->pm_lock); - mhi_netdev->enabled = false; - write_unlock_irq(&mhi_netdev->pm_lock); - - if (mhi_netdev->use_rmnet_usb) { -#ifndef MHI_NETDEV_ONE_CARD_MODE - unsigned i; - - for (i = 0; i < mhi_netdev->qmap_mode; i++) { - if (mhi_netdev->mpQmapNetDev[i]) { - rmnet_vnd_unregister_device(mhi_netdev->mpQmapNetDev[i]); - mhi_netdev->mpQmapNetDev[i] = NULL; - } - } - - rtnl_lock(); -#ifdef ANDROID_gki - if (mhi_netdev->ndev && rtnl_dereference(mhi_netdev->ndev->rx_handler)) -#else - if (netdev_is_rx_handler_busy(mhi_netdev->ndev)) -#endif - netdev_rx_handler_unregister(mhi_netdev->ndev); - rtnl_unlock(); -#endif - } - - while ((skb = skb_dequeue (&mhi_netdev->skb_chain))) - dev_kfree_skb_any(skb); - while ((skb = skb_dequeue (&mhi_netdev->qmap_chain))) - dev_kfree_skb_any(skb); - while ((skb = skb_dequeue (&mhi_netdev->rx_allocated))) - dev_kfree_skb_any(skb); - while ((skb = skb_dequeue (&mhi_netdev->tx_allocated))) - dev_kfree_skb_any(skb); - - napi_disable(&mhi_netdev->napi); - netif_napi_del(&mhi_netdev->napi); - mhi_netdev_dealloc(mhi_netdev); - unregister_netdev(mhi_netdev->ndev); -#if defined(MHI_NETDEV_STATUS64) - free_percpu(mhi_netdev->stats64); -#endif - free_netdev(mhi_netdev->ndev); - flush_delayed_work(&mhi_netdev->alloc_work); - - if (!IS_ERR_OR_NULL(mhi_netdev->dentry)) - debugfs_remove_recursive(mhi_netdev->dentry); -} - -static int mhi_netdev_probe(struct mhi_device *mhi_dev, - const struct mhi_device_id *id) -{ - int ret; - struct mhi_netdev *mhi_netdev; - - mhi_netdev = devm_kzalloc(&mhi_dev->dev, sizeof(*mhi_netdev), - GFP_KERNEL); - if (!mhi_netdev) - return -ENOMEM; - - if (!strcmp(id->chan, "IP_HW0")) { - if (mhi_mbim_enabled) - mhi_netdev->net_type = MHI_NET_MBIM; - else - mhi_netdev->net_type = MHI_NET_RMNET; - } - else if (!strcmp(id->chan, "IP_SW0")) { - mhi_netdev->net_type = MHI_NET_ETHER; - } - else { - return -EINVAL; - } - - mhi_netdev->alias = 0; - - mhi_netdev->mhi_dev = mhi_dev; - mhi_device_set_devdata(mhi_dev, mhi_netdev); - - mhi_netdev->mru = (15*1024); ///etc/data/qnicorn_config.xml dataformat_agg_dl_size 15*1024 - mhi_netdev->max_mtu = mhi_netdev->mru - (sizeof(struct rmnet_map_v5_csum_header) + sizeof(struct rmnet_map_header)); - if (mhi_netdev->net_type == MHI_NET_MBIM) { - mhi_netdev->mru = ncmNTBParams.dwNtbInMaxSize; - mhi_netdev->mbim_ctx.rx_max = mhi_netdev->mru; - mhi_netdev->max_mtu = mhi_netdev->mru - sizeof(struct mhi_mbim_hdr); - } - else if (mhi_netdev->net_type == MHI_NET_ETHER) { - mhi_netdev->mru = 8*1024; - mhi_netdev->max_mtu = mhi_netdev->mru; - } - mhi_netdev->qmap_size = mhi_netdev->mru; - -#if defined(MHI_NETDEV_STATUS64) - mhi_netdev->stats64 = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); - if (!mhi_netdev->stats64) - return -ENOMEM; -#endif - - if (!strcmp(id->chan, "IP_HW0")) - mhi_netdev->interface_name = "rmnet_mhi"; - else if (!strcmp(id->chan, "IP_SW0")) - mhi_netdev->interface_name = "mhi_swip"; - else - mhi_netdev->interface_name = id->chan; - - mhi_netdev->qmap_mode = qmap_mode; - mhi_netdev->qmap_version = 5; - mhi_netdev->use_rmnet_usb = 1; - if ((mhi_dev->vendor == 0x17cb && mhi_dev->dev_id == 0x0306) - || (mhi_dev->vendor == 0x17cb && mhi_dev->dev_id == 0x0308) - || (mhi_dev->vendor == 0x1eac && mhi_dev->dev_id == 0x1004) - ) { - mhi_netdev->qmap_version = 9; - } - if (mhi_netdev->net_type == MHI_NET_ETHER) { - mhi_netdev->qmap_mode = 1; - mhi_netdev->qmap_version = 0; - mhi_netdev->use_rmnet_usb = 0; - } - rmnet_info_set(mhi_netdev, &mhi_netdev->rmnet_info); - - mhi_netdev->rx_queue = mhi_netdev_alloc_skb; - - spin_lock_init(&mhi_netdev->rx_lock); - rwlock_init(&mhi_netdev->pm_lock); - INIT_DELAYED_WORK(&mhi_netdev->alloc_work, mhi_netdev_alloc_work); - skb_queue_head_init(&mhi_netdev->qmap_chain); - skb_queue_head_init(&mhi_netdev->skb_chain); - skb_queue_head_init(&mhi_netdev->tx_allocated); - skb_queue_head_init(&mhi_netdev->rx_allocated); - - mhi_netdev->msg_lvl = MHI_MSG_LVL_INFO; - - /* setup network interface */ - ret = mhi_netdev_enable_iface(mhi_netdev); - if (ret) { - pr_err("Error mhi_netdev_enable_iface ret:%d\n", ret); - return ret; - } - - mhi_netdev_create_debugfs(mhi_netdev); - - if (mhi_netdev->net_type == MHI_NET_ETHER) { - mhi_netdev->mpQmapNetDev[0] = mhi_netdev->ndev; - netif_carrier_on(mhi_netdev->ndev); - } - else if (mhi_netdev->use_rmnet_usb) { -#ifdef MHI_NETDEV_ONE_CARD_MODE - mhi_netdev->mpQmapNetDev[0] = mhi_netdev->ndev; - strcpy(mhi_netdev->rmnet_info.ifname[0], mhi_netdev->mpQmapNetDev[0]->name); - mhi_netdev->rmnet_info.mux_id[0] = QUECTEL_QMAP_MUX_ID; -#else - unsigned i; - - for (i = 0; i < mhi_netdev->qmap_mode; i++) { - u8 mux_id = QUECTEL_QMAP_MUX_ID+i; - mhi_netdev->mpQmapNetDev[i] = rmnet_vnd_register_device(mhi_netdev, i, mux_id); - if (mhi_netdev->mpQmapNetDev[i]) { - strcpy(mhi_netdev->rmnet_info.ifname[i], mhi_netdev->mpQmapNetDev[i]->name); - mhi_netdev->rmnet_info.mux_id[i] = mux_id; - } - } - - rtnl_lock(); - /* when open hyfi function, run cm will make system crash */ - //netdev_rx_handler_register(mhi_netdev->ndev, rmnet_rx_handler, mhi_netdev); - netdev_rx_handler_register(mhi_netdev->ndev, rmnet_rx_handler, NULL); - rtnl_unlock(); -#endif - } - -#if defined(CONFIG_IPQ5018_RATE_CONTROL) - mhi_netdev->mhi_rate_control = 1; -#endif - - return 0; -} - -static const struct mhi_device_id mhi_netdev_match_table[] = { - { .chan = "IP_HW0" }, - { .chan = "IP_SW0" }, - // ADPL do not register as a netcard. xingduo.du 2023-02-20 - // { .chan = "IP_HW_ADPL" }, - { }, -}; - -static struct mhi_driver mhi_netdev_driver = { - .id_table = mhi_netdev_match_table, - .probe = mhi_netdev_probe, - .remove = mhi_netdev_remove, - .ul_xfer_cb = mhi_netdev_xfer_ul_cb, - .dl_xfer_cb = mhi_netdev_xfer_dl_cb, - .status_cb = mhi_netdev_status_cb, - .driver = { - .name = "mhi_netdev", - .owner = THIS_MODULE, - } -}; - -int __init mhi_device_netdev_init(struct dentry *parent) -{ -#ifdef CONFIG_QCA_NSS_DRV - nss_cb = rcu_dereference(rmnet_nss_callbacks); - if (!nss_cb) { - printk(KERN_ERR "mhi_device_netdev_init: driver load must after '/etc/modules.d/42-rmnet-nss'\n"); - } -#endif - - mhi_netdev_create_debugfs_dir(parent); - - return mhi_driver_register(&mhi_netdev_driver); -} - -void mhi_device_netdev_exit(void) -{ -#ifdef CONFIG_DEBUG_FS - debugfs_remove_recursive(mhi_netdev_debugfs_dentry); -#endif - mhi_driver_unregister(&mhi_netdev_driver); -} diff --git a/quectel_MHI/src/devices/mhi_satellite.c b/quectel_MHI/src/devices/mhi_satellite.c deleted file mode 100644 index d1071ec..0000000 --- a/quectel_MHI/src/devices/mhi_satellite.c +++ /dev/null @@ -1,1153 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* Copyright (c) 2019, The Linux Foundation. All rights reserved.*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define MHI_SAT_DRIVER_NAME "mhi_satellite" - -static bool mhi_sat_defer_init = true; /* set by default */ - -/* logging macros */ -#define IPC_LOG_PAGES (10) -#define IPC_LOG_LVL (MHI_MSG_LVL_INFO) -#define KLOG_LVL (MHI_MSG_LVL_ERROR) - -#define MHI_SUBSYS_LOG(fmt, ...) do { \ - if (!subsys) \ - break; \ - if (mhi_sat_driver.klog_lvl <= MHI_MSG_LVL_INFO) \ - pr_info("[I][%s][%s] " fmt, __func__, subsys->name, \ - ##__VA_ARGS__);\ - if (subsys->ipc_log && mhi_sat_driver.ipc_log_lvl <= \ - MHI_MSG_LVL_INFO) \ - ipc_log_string(subsys->ipc_log, "[I][%s] " fmt, __func__, \ - ##__VA_ARGS__); \ -} while (0) - -#define MHI_SAT_LOG(fmt, ...) do { \ - if (!subsys || !sat_cntrl) \ - break; \ - if (mhi_sat_driver.klog_lvl <= MHI_MSG_LVL_INFO) \ - pr_info("[I][%s][%s][%x] " fmt, __func__, subsys->name, \ - sat_cntrl->dev_id, ##__VA_ARGS__);\ - if (subsys->ipc_log && mhi_sat_driver.ipc_log_lvl <= \ - MHI_MSG_LVL_INFO) \ - ipc_log_string(subsys->ipc_log, "[I][%s][%x] " fmt, __func__, \ - sat_cntrl->dev_id, ##__VA_ARGS__); \ -} while (0) - -#define MHI_SAT_ERR(fmt, ...) do { \ - if (!subsys || !sat_cntrl) \ - break; \ - if (mhi_sat_driver.klog_lvl <= MHI_MSG_LVL_ERROR) \ - pr_err("[E][%s][%s][%x] " fmt, __func__, subsys->name, \ - sat_cntrl->dev_id, ##__VA_ARGS__); \ - if (subsys->ipc_log && mhi_sat_driver.ipc_log_lvl <= \ - MHI_MSG_LVL_ERROR) \ - ipc_log_string(subsys->ipc_log, "[E][%s][%x] " fmt, __func__, \ - sat_cntrl->dev_id, ##__VA_ARGS__); \ -} while (0) - -#define MHI_SAT_ASSERT(cond, msg) do { \ - if (cond) \ - panic(msg); \ -} while (0) - -/* mhi sys error command */ -#define MHI_TRE_CMD_SYS_ERR_PTR (0) -#define MHI_TRE_CMD_SYS_ERR_D0 (0) -#define MHI_TRE_CMD_SYS_ERR_D1 (MHI_PKT_TYPE_SYS_ERR_CMD << 16) - -/* mhi state change event */ -#define MHI_TRE_EVT_MHI_STATE_PTR (0) -#define MHI_TRE_EVT_MHI_STATE_D0(state) (state << 24) -#define MHI_TRE_EVT_MHI_STATE_D1 (MHI_PKT_TYPE_STATE_CHANGE_EVENT << 16) - -/* mhi exec env change event */ -#define MHI_TRE_EVT_EE_PTR (0) -#define MHI_TRE_EVT_EE_D0(ee) (ee << 24) -#define MHI_TRE_EVT_EE_D1 (MHI_PKT_TYPE_EE_EVENT << 16) - -/* mhi config event */ -#define MHI_TRE_EVT_CFG_PTR(base_addr) (base_addr) -#define MHI_TRE_EVT_CFG_D0(er_base, num) ((er_base << 16) | (num & 0xFFFF)) -#define MHI_TRE_EVT_CFG_D1 (MHI_PKT_TYPE_CFG_EVENT << 16) - -/* command completion event */ -#define MHI_TRE_EVT_CMD_COMPLETION_PTR(ptr) (ptr) -#define MHI_TRE_EVT_CMD_COMPLETION_D0(code) (code << 24) -#define MHI_TRE_EVT_CMD_COMPLETION_D1 (MHI_PKT_TYPE_CMD_COMPLETION_EVENT << 16) - -/* packet parser macros */ -#define MHI_TRE_GET_PTR(tre) ((tre)->ptr) -#define MHI_TRE_GET_SIZE(tre) ((tre)->dword[0]) -#define MHI_TRE_GET_CCS(tre) (((tre)->dword[0] >> 24) & 0xFF) -#define MHI_TRE_GET_ID(tre) (((tre)->dword[1] >> 24) & 0xFF) -#define MHI_TRE_GET_TYPE(tre) (((tre)->dword[1] >> 16) & 0xFF) -#define MHI_TRE_IS_ER_CTXT_TYPE(tre) (((tre)->dword[1]) & 0x1) - -/* creates unique device ID based on connection topology */ -#define MHI_SAT_CREATE_DEVICE_ID(dev, domain, bus, slot) \ - ((dev & 0xFFFF) << 16 | (domain & 0xF) << 12 | (bus & 0xFF) << 4 | \ - (slot & 0xF)) - -/* mhi core definitions */ -#define MHI_CTXT_TYPE_GENERIC (0xA) - -struct __packed mhi_generic_ctxt { - u32 reserved0; - u32 type; - u32 reserved1; - u64 ctxt_base; - u64 ctxt_size; - u64 reserved[2]; -}; - -enum mhi_pkt_type { - MHI_PKT_TYPE_INVALID = 0x0, - MHI_PKT_TYPE_RESET_CHAN_CMD = 0x10, - MHI_PKT_TYPE_STOP_CHAN_CMD = 0x11, - MHI_PKT_TYPE_START_CHAN_CMD = 0x12, - MHI_PKT_TYPE_STATE_CHANGE_EVENT = 0x20, - MHI_PKT_TYPE_CMD_COMPLETION_EVENT = 0x21, - MHI_PKT_TYPE_EE_EVENT = 0x40, - MHI_PKT_TYPE_CTXT_UPDATE_CMD = 0x64, - MHI_PKT_TYPE_IOMMU_MAP_CMD = 0x65, - MHI_PKT_TYPE_CFG_EVENT = 0x6E, - MHI_PKT_TYPE_SYS_ERR_CMD = 0xFF, -}; - -enum mhi_cmd_type { - MHI_CMD_TYPE_RESET = 0x10, - MHI_CMD_TYPE_STOP = 0x11, - MHI_CMD_TYPE_START = 0x12, -}; - -/* mhi event completion codes */ -enum mhi_ev_ccs { - MHI_EV_CC_INVALID = 0x0, - MHI_EV_CC_SUCCESS = 0x1, - MHI_EV_CC_BAD_TRE = 0x11, -}; - -/* satellite subsystem definitions */ -enum subsys_id { - SUBSYS_ADSP, - SUBSYS_CDSP, - SUBSYS_SLPI, - SUBSYS_MODEM, - SUBSYS_MAX, -}; - -static const char * const subsys_names[SUBSYS_MAX] = { - [SUBSYS_ADSP] = "adsp", - [SUBSYS_CDSP] = "cdsp", - [SUBSYS_SLPI] = "slpi", - [SUBSYS_MODEM] = "modem", -}; - -struct mhi_sat_subsys { - const char *name; - - struct rpmsg_device *rpdev; /* rpmsg device */ - - /* - * acquire either mutex or spinlock to walk controller list - * acquire both when modifying list - */ - struct list_head cntrl_list; /* controllers list */ - struct mutex cntrl_mutex; /* mutex to walk/modify controllers list */ - spinlock_t cntrl_lock; /* lock to walk/modify controllers list */ - - void *ipc_log; -}; - -/* satellite IPC definitions */ -#define SAT_MAJOR_VERSION (1) -#define SAT_MINOR_VERSION (0) -#define SAT_RESERVED_SEQ_NUM (0xFFFF) -#define SAT_MSG_SIZE(n) (sizeof(struct sat_header) + \ - (n * sizeof(struct sat_tre))) -#define SAT_TRE_SIZE(msg_size) (msg_size - sizeof(struct sat_header)) -#define SAT_TRE_OFFSET(msg) (msg + sizeof(struct sat_header)) -#define SAT_TRE_NUM_PKTS(payload_size) ((payload_size) / sizeof(struct sat_tre)) - -/* satellite IPC msg type */ -enum sat_msg_id { - SAT_MSG_ID_ACK = 0xA, - SAT_MSG_ID_CMD = 0xC, - SAT_MSG_ID_EVT = 0xE, -}; - -/* satellite IPC context type */ -enum sat_ctxt_type { - SAT_CTXT_TYPE_CHAN = 0x0, - SAT_CTXT_TYPE_EVENT = 0x1, - SAT_CTXT_TYPE_MAX, -}; - -/* satellite IPC context string */ -#define TO_SAT_CTXT_TYPE_STR(type) (type >= SAT_CTXT_TYPE_MAX ? "INVALID" : \ - sat_ctxt_str[type]) - -const char * const sat_ctxt_str[SAT_CTXT_TYPE_MAX] = { - [SAT_CTXT_TYPE_CHAN] = "CCA", - [SAT_CTXT_TYPE_EVENT] = "ECA", -}; - -/* satellite IPC transfer ring element */ -struct __packed sat_tre { - u64 ptr; - u32 dword[2]; -}; - -/* satellite IPC header */ -struct __packed sat_header { - u16 major_ver; - u16 minor_ver; - u16 msg_id; - u16 seq; - u16 reply_seq; - u16 payload_size; - u32 dev_id; - u8 reserved[8]; -}; - -/* satellite driver definitions */ -struct mhi_sat_packet { - struct list_head node; - - struct mhi_sat_cntrl *cntrl; /* satellite controller reference */ - void *msg; /* incoming message */ -}; - -struct mhi_sat_cntrl { - struct list_head node; - - struct mhi_controller *mhi_cntrl; /* device MHI controller reference */ - struct mhi_sat_subsys *subsys; - - struct list_head dev_list; - struct list_head addr_map_list; /* IOMMU mapped addresses list */ - struct mutex list_mutex; /* mutex for devices and address map lists */ - - struct list_head packet_list; - spinlock_t pkt_lock; /* lock to walk/modify received packets list */ - - struct work_struct connect_work; /* subsystem connection worker */ - struct work_struct process_work; /* incoming packets processor */ - - /* mhi core/controller configurations */ - u32 dev_id; /* unique device ID with BDF as per connection topology */ - int er_base; /* event rings base index */ - int er_max; /* event rings max index */ - int num_er; /* total number of event rings */ - - /* satellite controller function counts */ - int num_devices; /* mhi devices current count */ - int max_devices; /* count of maximum devices for subsys/controller */ - u16 seq; /* internal sequence number for all outgoing packets */ - bool active; /* flag set if hello packet/MHI_CFG event was sent */ - - /* command completion variables */ - u16 last_cmd_seq; /* sequence number of last sent command packet */ - enum mhi_ev_ccs last_cmd_ccs; /* last command completion event code */ - struct completion completion; /* command completion event wait */ - struct mutex cmd_wait_mutex; /* command completion wait mutex */ -}; - -struct mhi_sat_device { - struct list_head node; - - struct mhi_device *mhi_dev; /* mhi device pointer */ - struct mhi_sat_cntrl *cntrl; /* parent controller */ - - bool chan_started; -}; - -struct mhi_sat_driver { - enum MHI_DEBUG_LEVEL ipc_log_lvl; /* IPC log level */ - enum MHI_DEBUG_LEVEL klog_lvl; /* klog/dmesg levels */ - - struct mhi_sat_subsys *subsys; /* pointer to subsystem array */ - unsigned int num_subsys; - - struct dentry *dentry; /* debugfs directory */ - bool deferred_init_done; /* flag for deferred init protection */ -}; - -static struct mhi_sat_driver mhi_sat_driver; - -static struct mhi_sat_subsys *find_subsys_by_name(const char *name) -{ - int i; - struct mhi_sat_subsys *subsys = mhi_sat_driver.subsys; - - for (i = 0; i < mhi_sat_driver.num_subsys; i++, subsys++) { - if (!strcmp(name, subsys->name)) - return subsys; - } - - return NULL; -} - -static struct mhi_sat_cntrl *find_sat_cntrl_by_id(struct mhi_sat_subsys *subsys, - u32 dev_id) -{ - struct mhi_sat_cntrl *sat_cntrl; - unsigned long flags; - - spin_lock_irqsave(&subsys->cntrl_lock, flags); - list_for_each_entry(sat_cntrl, &subsys->cntrl_list, node) { - if (sat_cntrl->dev_id == dev_id) { - spin_unlock_irqrestore(&subsys->cntrl_lock, flags); - return sat_cntrl; - } - } - spin_unlock_irqrestore(&subsys->cntrl_lock, flags); - - return NULL; -} - -static struct mhi_sat_device *find_sat_dev_by_id( - struct mhi_sat_cntrl *sat_cntrl, int id, - enum sat_ctxt_type evt) -{ - struct mhi_sat_device *sat_dev; - int compare_id; - - mutex_lock(&sat_cntrl->list_mutex); - list_for_each_entry(sat_dev, &sat_cntrl->dev_list, node) { - compare_id = (evt == SAT_CTXT_TYPE_EVENT) ? - sat_dev->mhi_dev->dl_event_id : - sat_dev->mhi_dev->dl_chan_id; - - if (compare_id == id) { - mutex_unlock(&sat_cntrl->list_mutex); - return sat_dev; - } - } - mutex_unlock(&sat_cntrl->list_mutex); - - return NULL; -} - -static bool mhi_sat_isvalid_header(struct sat_header *hdr, int len) -{ - /* validate payload size */ - if (len >= sizeof(*hdr) && (len != hdr->payload_size + sizeof(*hdr))) - return false; - - /* validate SAT IPC version */ - if (hdr->major_ver != SAT_MAJOR_VERSION && - hdr->minor_ver != SAT_MINOR_VERSION) - return false; - - /* validate msg ID */ - if (hdr->msg_id != SAT_MSG_ID_CMD && hdr->msg_id != SAT_MSG_ID_EVT) - return false; - - return true; -} - -static int mhi_sat_wait_cmd_completion(struct mhi_sat_cntrl *sat_cntrl) -{ - struct mhi_sat_subsys *subsys = sat_cntrl->subsys; - int ret; - - reinit_completion(&sat_cntrl->completion); - - MHI_SAT_LOG("Wait for command completion\n"); - ret = wait_for_completion_timeout(&sat_cntrl->completion, - msecs_to_jiffies(sat_cntrl->mhi_cntrl->timeout_ms)); - if (!ret || sat_cntrl->last_cmd_ccs != MHI_EV_CC_SUCCESS) { - MHI_SAT_ERR("Command completion failure:seq:%u:ret:%d:ccs:%d\n", - sat_cntrl->last_cmd_seq, ret, sat_cntrl->last_cmd_ccs); - return -EIO; - } - - MHI_SAT_LOG("Command completion successful for seq:%u\n", - sat_cntrl->last_cmd_seq); - - return 0; -} - -static int mhi_sat_send_msg(struct mhi_sat_cntrl *sat_cntrl, - enum sat_msg_id type, u16 reply_seq, - void *msg, u16 msg_size) -{ - struct mhi_sat_subsys *subsys = sat_cntrl->subsys; - struct sat_header *hdr = msg; - - /* create sequence number for controller */ - sat_cntrl->seq++; - if (sat_cntrl->seq == SAT_RESERVED_SEQ_NUM) - sat_cntrl->seq = 0; - - /* populate header */ - hdr->major_ver = SAT_MAJOR_VERSION; - hdr->minor_ver = SAT_MINOR_VERSION; - hdr->msg_id = type; - hdr->seq = sat_cntrl->seq; - hdr->reply_seq = reply_seq; - hdr->payload_size = SAT_TRE_SIZE(msg_size); - hdr->dev_id = sat_cntrl->dev_id; - - /* save last sent command sequence number for completion event */ - if (type == SAT_MSG_ID_CMD) - sat_cntrl->last_cmd_seq = sat_cntrl->seq; - - return rpmsg_send(subsys->rpdev->ept, msg, msg_size); -} - -static void mhi_sat_process_cmds(struct mhi_sat_cntrl *sat_cntrl, - struct sat_header *hdr, struct sat_tre *pkt) -{ - struct mhi_sat_subsys *subsys = sat_cntrl->subsys; - int num_pkts = SAT_TRE_NUM_PKTS(hdr->payload_size), i; - - for (i = 0; i < num_pkts; i++, pkt++) { - enum mhi_ev_ccs code = MHI_EV_CC_INVALID; - - switch (MHI_TRE_GET_TYPE(pkt)) { - case MHI_PKT_TYPE_IOMMU_MAP_CMD: - { - struct mhi_buf *buf; - struct mhi_controller *mhi_cntrl = sat_cntrl->mhi_cntrl; - dma_addr_t iova = DMA_ERROR_CODE; - - buf = kmalloc(sizeof(*buf), GFP_ATOMIC); - if (!buf) - goto iommu_map_cmd_completion; - - buf->phys_addr = MHI_TRE_GET_PTR(pkt); - buf->len = MHI_TRE_GET_SIZE(pkt); - - iova = dma_map_resource(mhi_cntrl->dev, buf->phys_addr, - buf->len, DMA_BIDIRECTIONAL, 0); - if (dma_mapping_error(mhi_cntrl->dev, iova)) { - kfree(buf); - goto iommu_map_cmd_completion; - } - - buf->dma_addr = iova; - - mutex_lock(&sat_cntrl->list_mutex); - list_add_tail(&buf->node, - &sat_cntrl->addr_map_list); - mutex_unlock(&sat_cntrl->list_mutex); - - code = MHI_EV_CC_SUCCESS; - -iommu_map_cmd_completion: - MHI_SAT_LOG("IOMMU MAP 0x%llx CMD processing %s\n", - MHI_TRE_GET_PTR(pkt), - (code == MHI_EV_CC_SUCCESS) ? "successful" : - "failed"); - - pkt->ptr = MHI_TRE_EVT_CMD_COMPLETION_PTR(iova); - pkt->dword[0] = MHI_TRE_EVT_CMD_COMPLETION_D0(code); - pkt->dword[1] = MHI_TRE_EVT_CMD_COMPLETION_D1; - break; - } - case MHI_PKT_TYPE_CTXT_UPDATE_CMD: - { - u64 ctxt_ptr = MHI_TRE_GET_PTR(pkt); - u64 ctxt_size = MHI_TRE_GET_SIZE(pkt); - int id = MHI_TRE_GET_ID(pkt); - enum sat_ctxt_type evt = MHI_TRE_IS_ER_CTXT_TYPE(pkt); - struct mhi_generic_ctxt gen_ctxt; - struct mhi_buf buf; - struct mhi_sat_device *sat_dev = find_sat_dev_by_id( - sat_cntrl, id, evt); - int ret; - - MHI_SAT_ASSERT(!sat_dev, - "No device with given chan/evt ID"); - - memset(&gen_ctxt, 0, sizeof(gen_ctxt)); - memset(&buf, 0, sizeof(buf)); - - gen_ctxt.type = MHI_CTXT_TYPE_GENERIC; - gen_ctxt.ctxt_base = ctxt_ptr; - gen_ctxt.ctxt_size = ctxt_size; - - buf.buf = &gen_ctxt; - buf.len = sizeof(gen_ctxt); - buf.name = TO_SAT_CTXT_TYPE_STR(evt); - - ret = mhi_device_configure(sat_dev->mhi_dev, - DMA_BIDIRECTIONAL, &buf, 1); - if (!ret) - code = MHI_EV_CC_SUCCESS; - - MHI_SAT_LOG("CTXT UPDATE CMD %s:%d processing %s\n", - buf.name, id, (code == MHI_EV_CC_SUCCESS) ? - "successful" : "failed"); - - pkt->ptr = MHI_TRE_EVT_CMD_COMPLETION_PTR(0); - pkt->dword[0] = MHI_TRE_EVT_CMD_COMPLETION_D0(code); - pkt->dword[1] = MHI_TRE_EVT_CMD_COMPLETION_D1; - break; - } - case MHI_PKT_TYPE_START_CHAN_CMD: - { - int id = MHI_TRE_GET_ID(pkt); - struct mhi_sat_device *sat_dev = find_sat_dev_by_id( - sat_cntrl, id, - SAT_CTXT_TYPE_CHAN); - int ret; - - MHI_SAT_ASSERT(!sat_dev, - "No device with given channel ID\n"); - - MHI_SAT_ASSERT(sat_dev->chan_started, - "Channel already started!"); - - ret = mhi_prepare_for_transfer(sat_dev->mhi_dev); - if (!ret) { - sat_dev->chan_started = true; - code = MHI_EV_CC_SUCCESS; - } - - MHI_SAT_LOG("START CHANNEL %d CMD processing %s\n", - id, (code == MHI_EV_CC_SUCCESS) ? "successful" : - "failure"); - - pkt->ptr = MHI_TRE_EVT_CMD_COMPLETION_PTR(0); - pkt->dword[0] = MHI_TRE_EVT_CMD_COMPLETION_D0(code); - pkt->dword[1] = MHI_TRE_EVT_CMD_COMPLETION_D1; - break; - } - case MHI_PKT_TYPE_RESET_CHAN_CMD: - { - int id = MHI_TRE_GET_ID(pkt); - struct mhi_sat_device *sat_dev = - find_sat_dev_by_id(sat_cntrl, id, - SAT_CTXT_TYPE_CHAN); - - MHI_SAT_ASSERT(!sat_dev, - "No device with given channel ID\n"); - - MHI_SAT_ASSERT(!sat_dev->chan_started, - "Resetting unstarted channel!"); - - mhi_unprepare_from_transfer(sat_dev->mhi_dev); - sat_dev->chan_started = false; - - MHI_SAT_LOG( - "RESET CHANNEL %d CMD processing successful\n", - id); - - pkt->ptr = MHI_TRE_EVT_CMD_COMPLETION_PTR(0); - pkt->dword[0] = MHI_TRE_EVT_CMD_COMPLETION_D0( - MHI_EV_CC_SUCCESS); - pkt->dword[1] = MHI_TRE_EVT_CMD_COMPLETION_D1; - break; - } - default: - MHI_SAT_ASSERT(1, "Unhandled command!"); - break; - } - } -} - -static void mhi_sat_process_worker(struct work_struct *work) -{ - struct mhi_sat_cntrl *sat_cntrl = container_of(work, - struct mhi_sat_cntrl, process_work); - struct mhi_sat_subsys *subsys = sat_cntrl->subsys; - struct mhi_sat_packet *packet, *tmp; - struct sat_header *hdr; - struct sat_tre *pkt; - LIST_HEAD(head); - - MHI_SAT_LOG("Entered\n"); - - spin_lock_irq(&sat_cntrl->pkt_lock); - list_splice_tail_init(&sat_cntrl->packet_list, &head); - spin_unlock_irq(&sat_cntrl->pkt_lock); - - list_for_each_entry_safe(packet, tmp, &head, node) { - hdr = packet->msg; - pkt = SAT_TRE_OFFSET(packet->msg); - - list_del(&packet->node); - - mhi_sat_process_cmds(sat_cntrl, hdr, pkt); - - /* send response event(s) */ - mhi_sat_send_msg(sat_cntrl, SAT_MSG_ID_EVT, hdr->seq, - packet->msg, - SAT_MSG_SIZE(SAT_TRE_NUM_PKTS( - hdr->payload_size))); - - kfree(packet); - } - - MHI_SAT_LOG("Exited\n"); -} - -static void mhi_sat_connect_worker(struct work_struct *work) -{ - struct mhi_sat_cntrl *sat_cntrl = container_of(work, - struct mhi_sat_cntrl, connect_work); - struct mhi_sat_subsys *subsys = sat_cntrl->subsys; - struct sat_tre *pkt; - void *msg; - int ret; - - if (!subsys->rpdev || sat_cntrl->max_devices != sat_cntrl->num_devices - || sat_cntrl->active) - return; - - MHI_SAT_LOG("Entered\n"); - - msg = kmalloc(SAT_MSG_SIZE(3), GFP_ATOMIC); - if (!msg) - return; - - sat_cntrl->active = true; - - pkt = SAT_TRE_OFFSET(msg); - - /* prepare #1 MHI_CFG HELLO event */ - pkt->ptr = MHI_TRE_EVT_CFG_PTR(sat_cntrl->mhi_cntrl->base_addr); - pkt->dword[0] = MHI_TRE_EVT_CFG_D0(sat_cntrl->er_base, - sat_cntrl->num_er); - pkt->dword[1] = MHI_TRE_EVT_CFG_D1; - pkt++; - - /* prepare M0 event */ - pkt->ptr = MHI_TRE_EVT_MHI_STATE_PTR; - pkt->dword[0] = MHI_TRE_EVT_MHI_STATE_D0(MHI_STATE_M0); - pkt->dword[1] = MHI_TRE_EVT_MHI_STATE_D1; - pkt++; - - /* prepare AMSS event */ - pkt->ptr = MHI_TRE_EVT_EE_PTR; - pkt->dword[0] = MHI_TRE_EVT_EE_D0(MHI_EE_AMSS); - pkt->dword[1] = MHI_TRE_EVT_EE_D1; - - ret = mhi_sat_send_msg(sat_cntrl, SAT_MSG_ID_EVT, SAT_RESERVED_SEQ_NUM, - msg, SAT_MSG_SIZE(3)); - kfree(msg); - if (ret) { - MHI_SAT_ERR("Failed to send hello packet:%d\n", ret); - sat_cntrl->active = false; - return; - } - - MHI_SAT_LOG("Device 0x%x sent hello packet\n", sat_cntrl->dev_id); -} - -static void mhi_sat_process_events(struct mhi_sat_cntrl *sat_cntrl, - struct sat_header *hdr, struct sat_tre *pkt) -{ - int num_pkts = SAT_TRE_NUM_PKTS(hdr->payload_size); - int i; - - for (i = 0; i < num_pkts; i++, pkt++) { - if (MHI_TRE_GET_TYPE(pkt) == - MHI_PKT_TYPE_CMD_COMPLETION_EVENT) { - if (hdr->reply_seq != sat_cntrl->last_cmd_seq) - continue; - - sat_cntrl->last_cmd_ccs = MHI_TRE_GET_CCS(pkt); - complete(&sat_cntrl->completion); - } - } -} - -static int mhi_sat_rpmsg_cb(struct rpmsg_device *rpdev, void *data, int len, - void *priv, u32 src) -{ - struct mhi_sat_subsys *subsys = dev_get_drvdata(&rpdev->dev); - struct sat_header *hdr = data; - struct sat_tre *pkt = SAT_TRE_OFFSET(data); - struct mhi_sat_cntrl *sat_cntrl; - struct mhi_sat_packet *packet; - - MHI_SAT_ASSERT(!mhi_sat_isvalid_header(hdr, len), "Invalid header!\n"); - - /* find controller packet was sent for */ - sat_cntrl = find_sat_cntrl_by_id(subsys, hdr->dev_id); - - MHI_SAT_ASSERT(!sat_cntrl, "Packet for unknown device!\n"); - - /* handle events directly regardless of controller active state */ - if (hdr->msg_id == SAT_MSG_ID_EVT) { - mhi_sat_process_events(sat_cntrl, hdr, pkt); - return 0; - } - - /* Inactive controller cannot process incoming commands */ - if (unlikely(!sat_cntrl->active)) { - MHI_SAT_ERR("Message for inactive controller!\n"); - return 0; - } - - /* offload commands to process worker */ - packet = kmalloc(sizeof(*packet) + len, GFP_ATOMIC); - if (!packet) - return 0; - - packet->cntrl = sat_cntrl; - packet->msg = packet + 1; - memcpy(packet->msg, data, len); - - spin_lock_irq(&sat_cntrl->pkt_lock); - list_add_tail(&packet->node, &sat_cntrl->packet_list); - spin_unlock_irq(&sat_cntrl->pkt_lock); - - schedule_work(&sat_cntrl->process_work); - - return 0; -} - -static void mhi_sat_rpmsg_remove(struct rpmsg_device *rpdev) -{ - struct mhi_sat_subsys *subsys = dev_get_drvdata(&rpdev->dev); - struct mhi_sat_cntrl *sat_cntrl; - struct mhi_sat_device *sat_dev; - struct mhi_buf *buf, *tmp; - - MHI_SUBSYS_LOG("Enter\n"); - - /* unprepare each controller/device from transfer */ - mutex_lock(&subsys->cntrl_mutex); - list_for_each_entry(sat_cntrl, &subsys->cntrl_list, node) { - sat_cntrl->active = false; - - flush_work(&sat_cntrl->connect_work); - flush_work(&sat_cntrl->process_work); - - mutex_lock(&sat_cntrl->list_mutex); - list_for_each_entry(sat_dev, &sat_cntrl->dev_list, node) { - if (sat_dev->chan_started) { - mhi_unprepare_from_transfer(sat_dev->mhi_dev); - sat_dev->chan_started = false; - } - } - - list_for_each_entry_safe(buf, tmp, &sat_cntrl->addr_map_list, - node) { - dma_unmap_resource(sat_cntrl->mhi_cntrl->dev, - buf->dma_addr, buf->len, - DMA_BIDIRECTIONAL, 0); - list_del(&buf->node); - kfree(buf); - } - mutex_unlock(&sat_cntrl->list_mutex); - - MHI_SAT_LOG("Removed RPMSG link\n"); - } - mutex_unlock(&subsys->cntrl_mutex); - - subsys->rpdev = NULL; -} - -static int mhi_sat_rpmsg_probe(struct rpmsg_device *rpdev) -{ - struct mhi_sat_subsys *subsys; - struct mhi_sat_cntrl *sat_cntrl; - const char *subsys_name; - int ret; - - ret = of_property_read_string(rpdev->dev.parent->of_node, "label", - &subsys_name); - if (ret) - return ret; - - /* find which subsystem has probed */ - subsys = find_subsys_by_name(subsys_name); - if (!subsys) - return -EINVAL; - - MHI_SUBSYS_LOG("Received RPMSG probe\n"); - - dev_set_drvdata(&rpdev->dev, subsys); - - subsys->rpdev = rpdev; - - /* schedule work for each controller as GLINK has connected */ - spin_lock_irq(&subsys->cntrl_lock); - list_for_each_entry(sat_cntrl, &subsys->cntrl_list, node) - schedule_work(&sat_cntrl->connect_work); - spin_unlock_irq(&subsys->cntrl_lock); - - return 0; -} - -static struct rpmsg_device_id mhi_sat_rpmsg_match_table[] = { - { .name = "mhi_sat" }, - { }, -}; - -static struct rpmsg_driver mhi_sat_rpmsg_driver = { - .id_table = mhi_sat_rpmsg_match_table, - .probe = mhi_sat_rpmsg_probe, - .remove = mhi_sat_rpmsg_remove, - .callback = mhi_sat_rpmsg_cb, - .drv = { - .name = "mhi,sat_rpmsg", - }, -}; - -static void mhi_sat_dev_status_cb(struct mhi_device *mhi_dev, - enum MHI_CB mhi_cb) -{ -} - -static void mhi_sat_dev_remove(struct mhi_device *mhi_dev) -{ - struct mhi_sat_device *sat_dev = mhi_device_get_devdata(mhi_dev); - struct mhi_sat_cntrl *sat_cntrl = sat_dev->cntrl; - struct mhi_sat_subsys *subsys = sat_cntrl->subsys; - struct mhi_buf *buf, *tmp; - struct sat_tre *pkt; - void *msg; - int ret; - - /* remove device node from probed list */ - mutex_lock(&sat_cntrl->list_mutex); - list_del(&sat_dev->node); - mutex_unlock(&sat_cntrl->list_mutex); - - sat_cntrl->num_devices--; - - /* prepare SYS_ERR command if first device is being removed */ - if (sat_cntrl->active) { - sat_cntrl->active = false; - - /* flush all pending work */ - flush_work(&sat_cntrl->connect_work); - flush_work(&sat_cntrl->process_work); - - msg = kmalloc(SAT_MSG_SIZE(1), GFP_KERNEL); - - MHI_SAT_ASSERT(!msg, "Unable to malloc for SYS_ERR message!\n"); - - pkt = SAT_TRE_OFFSET(msg); - pkt->ptr = MHI_TRE_CMD_SYS_ERR_PTR; - pkt->dword[0] = MHI_TRE_CMD_SYS_ERR_D0; - pkt->dword[1] = MHI_TRE_CMD_SYS_ERR_D1; - - /* acquire cmd_wait_mutex before sending command */ - mutex_lock(&sat_cntrl->cmd_wait_mutex); - - ret = mhi_sat_send_msg(sat_cntrl, SAT_MSG_ID_CMD, - SAT_RESERVED_SEQ_NUM, msg, - SAT_MSG_SIZE(1)); - kfree(msg); - if (ret) { - MHI_SAT_ERR("Failed to notify SYS_ERR\n"); - mutex_unlock(&sat_cntrl->cmd_wait_mutex); - goto exit_sys_err_send; - } - - MHI_SAT_LOG("SYS_ERR command sent\n"); - - /* blocking call to wait for command completion event */ - mhi_sat_wait_cmd_completion(sat_cntrl); - - mutex_unlock(&sat_cntrl->cmd_wait_mutex); - } - -exit_sys_err_send: - /* exit if some devices are still present */ - if (sat_cntrl->num_devices) - return; - - /* remove address mappings */ - mutex_lock(&sat_cntrl->list_mutex); - list_for_each_entry_safe(buf, tmp, &sat_cntrl->addr_map_list, node) { - dma_unmap_resource(sat_cntrl->mhi_cntrl->dev, buf->dma_addr, - buf->len, DMA_BIDIRECTIONAL, 0); - list_del(&buf->node); - kfree(buf); - } - mutex_unlock(&sat_cntrl->list_mutex); - - /* remove controller */ - mutex_lock(&subsys->cntrl_mutex); - spin_lock_irq(&subsys->cntrl_lock); - list_del(&sat_cntrl->node); - spin_unlock_irq(&subsys->cntrl_lock); - mutex_unlock(&subsys->cntrl_mutex); - - mutex_destroy(&sat_cntrl->cmd_wait_mutex); - mutex_destroy(&sat_cntrl->list_mutex); - MHI_SAT_LOG("Satellite controller node removed\n"); - kfree(sat_cntrl); -} - -static int mhi_sat_dev_probe(struct mhi_device *mhi_dev, - const struct mhi_device_id *id) -{ - struct mhi_sat_device *sat_dev; - struct mhi_sat_cntrl *sat_cntrl; - struct device_node *of_node = mhi_dev->dev.of_node; - struct mhi_sat_subsys *subsys = &mhi_sat_driver.subsys[id->driver_data]; - u32 dev_id = MHI_SAT_CREATE_DEVICE_ID(mhi_dev->dev_id, mhi_dev->domain, - mhi_dev->bus, mhi_dev->slot); - int ret; - - /* find controller with unique device ID based on topology */ - sat_cntrl = find_sat_cntrl_by_id(subsys, dev_id); - if (!sat_cntrl) { - sat_cntrl = kzalloc(sizeof(*sat_cntrl), GFP_KERNEL); - if (!sat_cntrl) - return -ENOMEM; - - /* - * max_devices will be read from device tree node. Set it to - * -1 before it is populated to avoid false positive when - * RPMSG probe schedules connect worker but no device has - * probed in which case num_devices and max_devices are both - * zero. - */ - sat_cntrl->max_devices = -1; - sat_cntrl->dev_id = dev_id; - sat_cntrl->er_base = mhi_dev->dl_event_id; - sat_cntrl->mhi_cntrl = mhi_dev->mhi_cntrl; - sat_cntrl->last_cmd_seq = SAT_RESERVED_SEQ_NUM; - sat_cntrl->subsys = subsys; - init_completion(&sat_cntrl->completion); - mutex_init(&sat_cntrl->list_mutex); - mutex_init(&sat_cntrl->cmd_wait_mutex); - spin_lock_init(&sat_cntrl->pkt_lock); - INIT_WORK(&sat_cntrl->connect_work, mhi_sat_connect_worker); - INIT_WORK(&sat_cntrl->process_work, mhi_sat_process_worker); - INIT_LIST_HEAD(&sat_cntrl->dev_list); - INIT_LIST_HEAD(&sat_cntrl->addr_map_list); - INIT_LIST_HEAD(&sat_cntrl->packet_list); - - mutex_lock(&subsys->cntrl_mutex); - spin_lock_irq(&subsys->cntrl_lock); - list_add(&sat_cntrl->node, &subsys->cntrl_list); - spin_unlock_irq(&subsys->cntrl_lock); - mutex_unlock(&subsys->cntrl_mutex); - - MHI_SAT_LOG("Controller allocated for 0x%x\n", dev_id); - } - - /* set maximum devices for subsystem from device tree */ - if (of_node) { - ret = of_property_read_u32(of_node, "mhi,max-devices", - &sat_cntrl->max_devices); - if (ret) { - MHI_SAT_ERR("Could not find max-devices in DT node\n"); - return -EINVAL; - } - } - - /* get event ring base and max indexes */ - sat_cntrl->er_base = min(sat_cntrl->er_base, mhi_dev->dl_event_id); - sat_cntrl->er_max = max(sat_cntrl->er_base, mhi_dev->dl_event_id); - - sat_dev = devm_kzalloc(&mhi_dev->dev, sizeof(*sat_dev), GFP_KERNEL); - if (!sat_dev) - return -ENOMEM; - - sat_dev->mhi_dev = mhi_dev; - sat_dev->cntrl = sat_cntrl; - - mutex_lock(&sat_cntrl->list_mutex); - list_add(&sat_dev->node, &sat_cntrl->dev_list); - mutex_unlock(&sat_cntrl->list_mutex); - - mhi_device_set_devdata(mhi_dev, sat_dev); - - sat_cntrl->num_devices++; - - /* schedule connect worker if all devices for controller have probed */ - if (sat_cntrl->num_devices == sat_cntrl->max_devices) { - /* number of event rings is 1 more than difference in IDs */ - sat_cntrl->num_er = (sat_cntrl->er_max - sat_cntrl->er_base) + - 1; - MHI_SAT_LOG("All satellite channels probed!\n"); - schedule_work(&sat_cntrl->connect_work); - } - - return 0; -} - -/* .driver_data stores subsys id */ -static const struct mhi_device_id mhi_sat_dev_match_table[] = { - /* ADSP */ - { .chan = "ADSP_0", .driver_data = SUBSYS_ADSP }, - { .chan = "ADSP_1", .driver_data = SUBSYS_ADSP }, - { .chan = "ADSP_2", .driver_data = SUBSYS_ADSP }, - { .chan = "ADSP_3", .driver_data = SUBSYS_ADSP }, - { .chan = "ADSP_4", .driver_data = SUBSYS_ADSP }, - { .chan = "ADSP_5", .driver_data = SUBSYS_ADSP }, - { .chan = "ADSP_6", .driver_data = SUBSYS_ADSP }, - { .chan = "ADSP_7", .driver_data = SUBSYS_ADSP }, - { .chan = "ADSP_8", .driver_data = SUBSYS_ADSP }, - { .chan = "ADSP_9", .driver_data = SUBSYS_ADSP }, - /* CDSP */ - { .chan = "CDSP_0", .driver_data = SUBSYS_CDSP }, - { .chan = "CDSP_1", .driver_data = SUBSYS_CDSP }, - { .chan = "CDSP_2", .driver_data = SUBSYS_CDSP }, - { .chan = "CDSP_3", .driver_data = SUBSYS_CDSP }, - { .chan = "CDSP_4", .driver_data = SUBSYS_CDSP }, - { .chan = "CDSP_5", .driver_data = SUBSYS_CDSP }, - { .chan = "CDSP_6", .driver_data = SUBSYS_CDSP }, - { .chan = "CDSP_7", .driver_data = SUBSYS_CDSP }, - { .chan = "CDSP_8", .driver_data = SUBSYS_CDSP }, - { .chan = "CDSP_9", .driver_data = SUBSYS_CDSP }, - /* SLPI */ - { .chan = "SLPI_0", .driver_data = SUBSYS_SLPI }, - { .chan = "SLPI_1", .driver_data = SUBSYS_SLPI }, - { .chan = "SLPI_2", .driver_data = SUBSYS_SLPI }, - { .chan = "SLPI_3", .driver_data = SUBSYS_SLPI }, - { .chan = "SLPI_4", .driver_data = SUBSYS_SLPI }, - { .chan = "SLPI_5", .driver_data = SUBSYS_SLPI }, - { .chan = "SLPI_6", .driver_data = SUBSYS_SLPI }, - { .chan = "SLPI_7", .driver_data = SUBSYS_SLPI }, - { .chan = "SLPI_8", .driver_data = SUBSYS_SLPI }, - { .chan = "SLPI_9", .driver_data = SUBSYS_SLPI }, - /* MODEM */ - { .chan = "MODEM_0", .driver_data = SUBSYS_MODEM }, - { .chan = "MODEM_1", .driver_data = SUBSYS_MODEM }, - { .chan = "MODEM_2", .driver_data = SUBSYS_MODEM }, - { .chan = "MODEM_3", .driver_data = SUBSYS_MODEM }, - { .chan = "MODEM_4", .driver_data = SUBSYS_MODEM }, - { .chan = "MODEM_5", .driver_data = SUBSYS_MODEM }, - { .chan = "MODEM_6", .driver_data = SUBSYS_MODEM }, - { .chan = "MODEM_7", .driver_data = SUBSYS_MODEM }, - { .chan = "MODEM_8", .driver_data = SUBSYS_MODEM }, - { .chan = "MODEM_9", .driver_data = SUBSYS_MODEM }, - {}, -}; - -static struct mhi_driver mhi_sat_dev_driver = { - .id_table = mhi_sat_dev_match_table, - .probe = mhi_sat_dev_probe, - .remove = mhi_sat_dev_remove, - .status_cb = mhi_sat_dev_status_cb, - .driver = { - .name = MHI_SAT_DRIVER_NAME, - .owner = THIS_MODULE, - }, -}; - -int mhi_sat_trigger_init(void *data, u64 val) -{ - struct mhi_sat_subsys *subsys; - int i, ret; - - if (mhi_sat_driver.deferred_init_done) - return -EIO; - - ret = register_rpmsg_driver(&mhi_sat_rpmsg_driver); - if (ret) - goto error_sat_trigger_init; - - ret = mhi_driver_register(&mhi_sat_dev_driver); - if (ret) - goto error_sat_trigger_register; - - mhi_sat_driver.deferred_init_done = true; - - return 0; - -error_sat_trigger_register: - unregister_rpmsg_driver(&mhi_sat_rpmsg_driver); - -error_sat_trigger_init: - subsys = mhi_sat_driver.subsys; - for (i = 0; i < mhi_sat_driver.num_subsys; i++, subsys++) { - ipc_log_context_destroy(subsys->ipc_log); - mutex_destroy(&subsys->cntrl_mutex); - } - kfree(mhi_sat_driver.subsys); - mhi_sat_driver.subsys = NULL; - - return ret; -} - -DEFINE_SIMPLE_ATTRIBUTE(mhi_sat_debugfs_fops, NULL, - mhi_sat_trigger_init, "%llu\n"); - -static int mhi_sat_init(void) -{ - struct mhi_sat_subsys *subsys; - int i, ret; - - subsys = kcalloc(SUBSYS_MAX, sizeof(*subsys), GFP_KERNEL); - if (!subsys) - return -ENOMEM; - - mhi_sat_driver.subsys = subsys; - mhi_sat_driver.num_subsys = SUBSYS_MAX; - mhi_sat_driver.klog_lvl = KLOG_LVL; - mhi_sat_driver.ipc_log_lvl = IPC_LOG_LVL; - - for (i = 0; i < mhi_sat_driver.num_subsys; i++, subsys++) { - char log[32]; - - subsys->name = subsys_names[i]; - mutex_init(&subsys->cntrl_mutex); - spin_lock_init(&subsys->cntrl_lock); - INIT_LIST_HEAD(&subsys->cntrl_list); - scnprintf(log, sizeof(log), "mhi_sat_%s", subsys->name); - subsys->ipc_log = ipc_log_context_create(IPC_LOG_PAGES, log, 0); - } - - /* create debugfs entry if defer_init is enabled */ - if (mhi_sat_defer_init) { - mhi_sat_driver.dentry = debugfs_create_dir("mhi_sat", NULL); - if (IS_ERR_OR_NULL(mhi_sat_driver.dentry)) { - ret = -ENODEV; - goto error_sat_init; - } - - debugfs_create_file("debug", 0444, mhi_sat_driver.dentry, NULL, - &mhi_sat_debugfs_fops); - - return 0; - } - - ret = register_rpmsg_driver(&mhi_sat_rpmsg_driver); - if (ret) - goto error_sat_init; - - ret = mhi_driver_register(&mhi_sat_dev_driver); - if (ret) - goto error_sat_register; - - return 0; - -error_sat_register: - unregister_rpmsg_driver(&mhi_sat_rpmsg_driver); - -error_sat_init: - subsys = mhi_sat_driver.subsys; - for (i = 0; i < mhi_sat_driver.num_subsys; i++, subsys++) { - ipc_log_context_destroy(subsys->ipc_log); - mutex_destroy(&subsys->cntrl_mutex); - } - kfree(mhi_sat_driver.subsys); - mhi_sat_driver.subsys = NULL; - - return ret; -} - -module_init(mhi_sat_init); - diff --git a/quectel_MHI/src/devices/mhi_uci.c b/quectel_MHI/src/devices/mhi_uci.c deleted file mode 100644 index 474b022..0000000 --- a/quectel_MHI/src/devices/mhi_uci.c +++ /dev/null @@ -1,981 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#if 1 -static inline void *ipc_log_context_create(int max_num_pages, - const char *modname, uint16_t user_version) -{ return NULL; } -static inline int ipc_log_string(void *ilctxt, const char *fmt, ...) -{ return -EINVAL; } -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "../core/mhi.h" - -#define DEVICE_NAME "mhi" -#define MHI_UCI_DRIVER_NAME "mhi_uci_q" - -struct uci_chan { - wait_queue_head_t wq; - spinlock_t lock; - struct list_head pending; /* user space waiting to read */ - struct uci_buf *cur_buf; /* current buffer user space reading */ - size_t rx_size; -}; - -struct uci_buf { - struct page *page; - void *data; - size_t len; - unsigned nr_trb; - struct list_head node; -}; - -struct uci_dev { - struct list_head node; - dev_t devt; - struct device *dev; - struct mhi_device *mhi_dev; - const char *chan; - struct mutex mutex; /* sync open and close */ - struct mutex r_mutex; - struct mutex w_mutex; - struct uci_chan ul_chan; - struct uci_chan dl_chan; - size_t mtu; - int ref_count; - bool enabled; - unsigned rx_error; - unsigned nr_trb; - unsigned nr_trbs; - struct uci_buf *uci_buf; - struct ktermios termios; - size_t bytes_xferd; -}; - -struct mhi_uci_drv { - struct list_head head; - struct mutex lock; - struct class *class; - int major; - dev_t dev_t; -}; - -static int uci_msg_lvl = MHI_MSG_LVL_ERROR; -module_param( uci_msg_lvl, uint, S_IRUGO | S_IWUSR); - -#define MSG_VERB(fmt, ...) do { \ - if (uci_msg_lvl <= MHI_MSG_LVL_VERBOSE) \ - pr_err("[D][%s] " fmt, __func__, ##__VA_ARGS__); \ - } while (0) - -#define MSG_LOG(fmt, ...) do { \ - if (uci_msg_lvl <= MHI_MSG_LVL_INFO) \ - pr_err("[I][%s] " fmt, __func__, ##__VA_ARGS__); \ - } while (0) - -#define MSG_ERR(fmt, ...) do { \ - if (uci_msg_lvl <= MHI_MSG_LVL_ERROR) \ - pr_err("[E][%s] " fmt, __func__, ##__VA_ARGS__); \ - } while (0) - -#define MAX_UCI_DEVICES (64) -#define QUEC_MHI_UCI_ALWAYS_OPEN //by now, sdx20 can not handle "start-reset-start" operation, so the simply solution is keep start state - -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)) -#ifdef TCGETS2 -__weak int user_termios_to_kernel_termios(struct ktermios *k, - struct termios2 __user *u) -{ - return copy_from_user(k, u, sizeof(struct termios2)); -} -__weak int kernel_termios_to_user_termios(struct termios2 __user *u, - struct ktermios *k) -{ - return copy_to_user(u, k, sizeof(struct termios2)); -} -__weak int user_termios_to_kernel_termios_1(struct ktermios *k, - struct termios __user *u) -{ - return copy_from_user(k, u, sizeof(struct termios)); -} -__weak int kernel_termios_to_user_termios_1(struct termios __user *u, - struct ktermios *k) -{ - return copy_to_user(u, k, sizeof(struct termios)); -} - -#else - -__weak int user_termios_to_kernel_termios(struct ktermios *k, - struct termios __user *u) -{ - return copy_from_user(k, u, sizeof(struct termios)); -} -__weak int kernel_termios_to_user_termios(struct termios __user *u, - struct ktermios *k) -{ - return copy_to_user(u, k, sizeof(struct termios)); -} -#endif /* TCGETS2 */ -#endif - -static DECLARE_BITMAP(uci_minors, MAX_UCI_DEVICES); -static struct mhi_uci_drv mhi_uci_drv; - -static int mhi_queue_inbound(struct uci_dev *uci_dev) -{ - struct mhi_device *mhi_dev = uci_dev->mhi_dev; - int nr_trbs = mhi_get_no_free_descriptors(mhi_dev, DMA_FROM_DEVICE); - size_t mtu = uci_dev->mtu; - void *buf; - struct uci_buf *uci_buf; - int ret = -EIO, i; - - if (uci_dev->uci_buf == NULL) { - uci_dev->nr_trb = 0; - uci_dev->nr_trbs = (nr_trbs + 1); - uci_dev->uci_buf = kmalloc_array(uci_dev->nr_trbs, sizeof(*uci_buf), GFP_KERNEL); - if (!uci_dev->uci_buf) - return -ENOMEM; - - uci_buf = uci_dev->uci_buf; - for (i = 0; i < uci_dev->nr_trbs; i++, uci_buf++) { - uci_buf->page = alloc_pages(GFP_KERNEL, get_order(mtu)); - if (!uci_buf->page) - return -ENOMEM; - uci_buf->data = page_address(uci_buf->page); - uci_buf->len = 0; - uci_buf->nr_trb = i; - if (mhi_dev->dl_chan_id == MHI_CLIENT_DUN_IN) { - //MSG_ERR("[%d] = %p\n", i, uci_buf->data); - } - } - } - - for (i = 0; i < nr_trbs; i++) { - #if 0 - buf = kmalloc(mtu + sizeof(*uci_buf), GFP_KERNEL); - if (!buf) - return -ENOMEM; - - uci_buf = buf + mtu; - uci_buf->data = buf; - #else - uci_buf = &uci_dev->uci_buf[i]; - buf = uci_buf->data; - #endif - - MSG_VERB("Allocated buf %d of %d size %zu\n", i, nr_trbs, mtu); - - ret = mhi_queue_transfer(mhi_dev, DMA_FROM_DEVICE, buf, mtu, - MHI_EOT); - if (ret) { - #if 0 - kfree(buf); - #endif - MSG_ERR("Failed to queue buffer %d\n", i); - return ret; - } - } - - return ret; -} - -static long mhi_uci_ioctl(struct file *file, - unsigned int cmd, - unsigned long arg) -{ - struct uci_dev *uci_dev = file->private_data; - struct mhi_device *mhi_dev = uci_dev->mhi_dev; - long ret = -ERESTARTSYS; - - mutex_lock(&uci_dev->mutex); - if (uci_dev->enabled) - ret = mhi_ioctl(mhi_dev, cmd, arg); - - if (uci_dev->enabled) { - switch (cmd) { - case TCGETS: -#ifndef TCGETS2 - ret = kernel_termios_to_user_termios((struct termios __user *)arg, &uci_dev->termios); -#else - ret = kernel_termios_to_user_termios_1((struct termios __user *)arg, &uci_dev->termios); -#endif - break; - - case TCSETSF: - case TCSETS: -#ifndef TCGETS2 - ret = user_termios_to_kernel_termios(&uci_dev->termios, (struct termios __user *)arg); -#else - ret = user_termios_to_kernel_termios_1(&uci_dev->termios, (struct termios __user *)arg); -#endif - break; - - case TCFLSH: - ret = 0; - break; - - default: - break; - } - } - mutex_unlock(&uci_dev->mutex); - - return ret; -} - -static int mhi_uci_release(struct inode *inode, struct file *file) -{ - struct uci_dev *uci_dev = file->private_data; - - mutex_lock(&uci_dev->mutex); - uci_dev->ref_count--; - if (!uci_dev->ref_count) { - struct uci_chan *uci_chan; - - MSG_LOG("Last client left, closing node\n"); - - if (uci_dev->enabled) - mhi_unprepare_from_transfer(uci_dev->mhi_dev); - - /* clean inbound channel */ - uci_chan = &uci_dev->dl_chan; - if (uci_dev->uci_buf) { - unsigned nr_trb = 0; - - for (nr_trb = 0; nr_trb < uci_dev->nr_trbs; nr_trb++) { - if (uci_dev->uci_buf[nr_trb].page) - __free_pages(uci_dev->uci_buf[nr_trb].page, get_order(uci_dev->mtu)); - } - kfree(uci_dev->uci_buf); - } - - uci_chan->cur_buf = NULL; - - if (!uci_dev->enabled) { - MSG_LOG("Node is deleted, freeing dev node\n"); - mutex_unlock(&uci_dev->mutex); - mutex_destroy(&uci_dev->mutex); - clear_bit(MINOR(uci_dev->devt), uci_minors); - kfree(uci_dev); - return 0; - } - } - - MSG_LOG("exit: ref_count:%d\n", uci_dev->ref_count); - - mutex_unlock(&uci_dev->mutex); - - return 0; -} - -static unsigned int mhi_uci_poll(struct file *file, poll_table *wait) -{ - struct uci_dev *uci_dev = file->private_data; - struct mhi_device *mhi_dev = uci_dev->mhi_dev; - struct uci_chan *uci_chan; - unsigned int mask = 0; - - poll_wait(file, &uci_dev->dl_chan.wq, wait); - // ADPL and QDSS do not need poll write. xingduo.du 2023-02-16 - // poll_wait(file, &uci_dev->ul_chan.wq, wait); - - uci_chan = &uci_dev->dl_chan; - spin_lock_bh(&uci_chan->lock); - if (!uci_dev->enabled) { - mask = POLLERR; - } else if (!list_empty(&uci_chan->pending) || uci_chan->cur_buf) { - MSG_VERB("Client can read from node\n"); - mask |= POLLIN | POLLRDNORM; - } - spin_unlock_bh(&uci_chan->lock); - - // ADPL and QDSS are single channel, ul_chan not be initilized. xingduo.du 2023-02-27 - if (mhi_dev->ul_chan) { - poll_wait(file, &uci_dev->ul_chan.wq, wait); - uci_chan = &uci_dev->ul_chan; - spin_lock_bh(&uci_chan->lock); - if (!uci_dev->enabled) { - mask |= POLLERR; - } else if (mhi_get_no_free_descriptors(mhi_dev, DMA_TO_DEVICE) > 0) { - MSG_VERB("Client can write to node\n"); - mask |= POLLOUT | POLLWRNORM; - } - - if (!uci_dev->enabled) - mask |= POLLHUP; - if (uci_dev->rx_error) - mask |= POLLERR; - - spin_unlock_bh(&uci_chan->lock); - } - - MSG_LOG("Client attempted to poll, returning mask 0x%x\n", mask); - - return mask; -} - -static ssize_t mhi_uci_write(struct file *file, - const char __user *buf, - size_t count, - loff_t *offp) -{ - struct uci_dev *uci_dev = file->private_data; - struct mhi_device *mhi_dev = uci_dev->mhi_dev; - struct uci_chan *uci_chan = &uci_dev->ul_chan; - size_t bytes_xfered = 0; - int ret, nr_avail; - - if (!buf || !count || uci_dev->rx_error) - return -EINVAL; - - /* confirm channel is active */ - spin_lock_bh(&uci_chan->lock); - if (!uci_dev->enabled) { - spin_unlock_bh(&uci_chan->lock); - return -ERESTARTSYS; - } - - MSG_VERB("Enter: to xfer:%zu bytes\n", count); - - while (count) { - size_t xfer_size; - void *kbuf; - enum MHI_FLAGS flags; - - spin_unlock_bh(&uci_chan->lock); - - nr_avail = mhi_get_no_free_descriptors(mhi_dev, DMA_TO_DEVICE); - if ((nr_avail == 0) && (file->f_flags & O_NONBLOCK)) - return -EAGAIN; - - /* wait for free descriptors */ - ret = wait_event_interruptible(uci_chan->wq, - (!uci_dev->enabled) || - (nr_avail = mhi_get_no_free_descriptors(mhi_dev, - DMA_TO_DEVICE)) > 0); - - if (ret == -ERESTARTSYS || !uci_dev->enabled) { - MSG_LOG("Exit signal caught for node or not enabled\n"); - return -ERESTARTSYS; - } - - xfer_size = min_t(size_t, count, uci_dev->mtu); - kbuf = kmalloc(xfer_size, GFP_KERNEL); - if (!kbuf) { - MSG_ERR("Failed to allocate memory %zu\n", xfer_size); - return -ENOMEM; - } - - ret = copy_from_user(kbuf, buf, xfer_size); - if (unlikely(ret)) { - kfree(kbuf); - return ret; - } - - spin_lock_bh(&uci_chan->lock); - - /* if ring is full after this force EOT */ - if (nr_avail > 1 && (count - xfer_size)) - flags = MHI_CHAIN; - else - flags = MHI_EOT; - - if (uci_dev->enabled) - ret = mhi_queue_transfer(mhi_dev, DMA_TO_DEVICE, kbuf, - xfer_size, flags); - else - ret = -ERESTARTSYS; - - if (ret) { - kfree(kbuf); - goto sys_interrupt; - } - - bytes_xfered += xfer_size; - count -= xfer_size; - buf += xfer_size; - } - - spin_unlock_bh(&uci_chan->lock); - MSG_VERB("Exit: Number of bytes xferred:%zu\n", bytes_xfered); - - return bytes_xfered; - -sys_interrupt: - spin_unlock_bh(&uci_chan->lock); - - return ret; -} - -static ssize_t mhi_uci_read(struct file *file, - char __user *buf, - size_t count, - loff_t *ppos) -{ - struct uci_dev *uci_dev = file->private_data; - struct mhi_device *mhi_dev = uci_dev->mhi_dev; - struct uci_chan *uci_chan = &uci_dev->dl_chan; - struct uci_buf *uci_buf; - char *ptr; - size_t to_copy; - int ret = 0; - - if (!buf || uci_dev->rx_error) - return -EINVAL; - - MSG_VERB("Client provided buf len:%zu\n", count); - - /* confirm channel is active */ - spin_lock_bh(&uci_chan->lock); - if (!uci_dev->enabled) { - spin_unlock_bh(&uci_chan->lock); - return -ERESTARTSYS; - } - - /* No data available to read, wait */ - if (!uci_chan->cur_buf && list_empty(&uci_chan->pending)) { - MSG_VERB("No data available to read waiting\n"); - - spin_unlock_bh(&uci_chan->lock); - - if (file->f_flags & O_NONBLOCK) - return -EAGAIN; - - ret = wait_event_interruptible(uci_chan->wq, - (!uci_dev->enabled || - !list_empty(&uci_chan->pending))); - if (ret == -ERESTARTSYS) { - MSG_LOG("Exit signal caught for node\n"); - return -ERESTARTSYS; - } - - spin_lock_bh(&uci_chan->lock); - if (!uci_dev->enabled) { - MSG_LOG("node is disabled\n"); - ret = -ERESTARTSYS; - goto read_error; - } - } - - /* new read, get the next descriptor from the list */ - if (!uci_chan->cur_buf) { - uci_buf = list_first_entry_or_null(&uci_chan->pending, - struct uci_buf, node); - if (unlikely(!uci_buf)) { - ret = -EIO; - goto read_error; - } - - if (uci_buf->node.next == LIST_POISON1 || uci_buf->node.prev == LIST_POISON1) { - dump_stack(); - ret = -EIO; - MSG_ERR("chan[%d] data=%p, len=%zd, nr_trb=%d\n", - mhi_dev->dl_chan_id, uci_buf->data, uci_buf->len, uci_buf->nr_trb); - goto read_error; - } - - list_del(&uci_buf->node); - uci_chan->cur_buf = uci_buf; - uci_chan->rx_size = uci_buf->len; - MSG_VERB("Got pkt of size:%zu\n", uci_chan->rx_size); - } - - uci_buf = uci_chan->cur_buf; - spin_unlock_bh(&uci_chan->lock); - - /* Copy the buffer to user space */ - to_copy = min_t(size_t, count, uci_chan->rx_size); - ptr = uci_buf->data + (uci_buf->len - uci_chan->rx_size); - ret = copy_to_user(buf, ptr, to_copy); - if (ret) - return ret; - - MSG_VERB("Copied %zu of %zu bytes\n", to_copy, uci_chan->rx_size); - uci_chan->rx_size -= to_copy; - - /* we finished with this buffer, queue it back to hardware */ - if (!uci_chan->rx_size) { - spin_lock_bh(&uci_chan->lock); - uci_chan->cur_buf = NULL; - - if (uci_dev->enabled) -#if 1 //this can make the address in ring do not change - { - if (uci_buf->page) { - unsigned nr_trb = uci_buf->nr_trb ? (uci_buf->nr_trb - 1) : (uci_dev->nr_trbs - 1); - - uci_buf = &uci_dev->uci_buf[nr_trb]; - ret = mhi_queue_transfer(mhi_dev, DMA_FROM_DEVICE, - uci_buf->data, uci_dev->mtu, - MHI_EOT); - } else { - kfree(uci_buf); - ret = 0; - } - } -#endif - else - ret = -ERESTARTSYS; - - if (ret) { - MSG_ERR("Failed to recycle element for chan:%d , ret=%d\n", mhi_dev->ul_chan_id, ret); -#if 0 - kfree(uci_buf->data); -#endif - goto read_error; - } - - spin_unlock_bh(&uci_chan->lock); - } - - MSG_VERB("Returning %zu bytes\n", to_copy); - - return to_copy; - -read_error: - spin_unlock_bh(&uci_chan->lock); - - return ret; -} - -static ssize_t mhi_uci_write_mutex(struct file *file, - const char __user *buf, - size_t count, - loff_t *offp) -{ - struct uci_dev *uci_dev = file->private_data; - int ret; - - ret = mutex_lock_interruptible(&uci_dev->w_mutex); /*concurrent writes */ - if (ret < 0) - return -ERESTARTSYS; - - ret = mhi_uci_write(file, buf, count, offp); - mutex_unlock(&uci_dev->w_mutex); - - return ret; -} - -static ssize_t mhi_uci_read_mutex(struct file *file, - char __user *buf, - size_t count, - loff_t *ppos) -{ - struct uci_dev *uci_dev = file->private_data; - int ret; - - ret = mutex_lock_interruptible(&uci_dev->r_mutex); /*concurrent reads */ - if (ret < 0) - return -ERESTARTSYS; - - ret = mhi_uci_read(file, buf, count, ppos); - mutex_unlock(&uci_dev->r_mutex); - - return ret; -} - -static int mhi_uci_open(struct inode *inode, struct file *filp) -{ - struct uci_dev *uci_dev = NULL, *tmp_dev; - int ret = -EIO; - struct uci_chan *dl_chan; - - mutex_lock(&mhi_uci_drv.lock); - list_for_each_entry(tmp_dev, &mhi_uci_drv.head, node) { - if (tmp_dev->devt == inode->i_rdev) { - uci_dev = tmp_dev; - break; - } - } - - /* could not find a minor node */ - if (!uci_dev) - goto error_exit; - - mutex_lock(&uci_dev->mutex); - if (!uci_dev->enabled) { - MSG_ERR("Node exist, but not in active state!\n"); - goto error_open_chan; - } - - uci_dev->ref_count++; - - MSG_LOG("Node open, ref counts %u\n", uci_dev->ref_count); - - if (uci_dev->ref_count == 1) { - MSG_LOG("Starting channel\n"); - ret = mhi_prepare_for_transfer(uci_dev->mhi_dev); - if (ret) { - MSG_ERR("Error starting transfer channels\n"); - uci_dev->ref_count--; - goto error_open_chan; - } - - ret = mhi_queue_inbound(uci_dev); - if (ret) - goto error_rx_queue; - -#ifdef QUEC_MHI_UCI_ALWAYS_OPEN - uci_dev->ref_count++; -#endif - } - - filp->private_data = uci_dev; - mutex_unlock(&uci_dev->mutex); - mutex_unlock(&mhi_uci_drv.lock); - - return 0; - - error_rx_queue: - dl_chan = &uci_dev->dl_chan; - mhi_unprepare_from_transfer(uci_dev->mhi_dev); - if (uci_dev->uci_buf) { - unsigned nr_trb = 0; - - for (nr_trb = 0; nr_trb < uci_dev->nr_trbs; nr_trb++) { - if (uci_dev->uci_buf[nr_trb].page) - __free_pages(uci_dev->uci_buf[nr_trb].page, get_order(uci_dev->mtu)); - } - kfree(uci_dev->uci_buf); - } - - error_open_chan: - mutex_unlock(&uci_dev->mutex); - -error_exit: - mutex_unlock(&mhi_uci_drv.lock); - - return ret; -} - -static const struct file_operations mhidev_fops = { - .open = mhi_uci_open, - .release = mhi_uci_release, - .read = mhi_uci_read_mutex, - .write = mhi_uci_write_mutex, - .poll = mhi_uci_poll, - .unlocked_ioctl = mhi_uci_ioctl, -}; - -static void mhi_uci_remove(struct mhi_device *mhi_dev) -{ - struct uci_dev *uci_dev = mhi_device_get_devdata(mhi_dev); - - MSG_LOG("Enter\n"); - - - mutex_lock(&mhi_uci_drv.lock); - mutex_lock(&uci_dev->mutex); - - /* disable the node */ - spin_lock_irq(&uci_dev->dl_chan.lock); - spin_lock_irq(&uci_dev->ul_chan.lock); - uci_dev->enabled = false; - spin_unlock_irq(&uci_dev->ul_chan.lock); - spin_unlock_irq(&uci_dev->dl_chan.lock); - wake_up(&uci_dev->dl_chan.wq); - wake_up(&uci_dev->ul_chan.wq); - - /* delete the node to prevent new opens */ - device_destroy(mhi_uci_drv.class, uci_dev->devt); - uci_dev->dev = NULL; - list_del(&uci_dev->node); - -#ifdef QUEC_MHI_UCI_ALWAYS_OPEN - if (uci_dev->ref_count > 0) - uci_dev->ref_count--; -#endif - - /* safe to free memory only if all file nodes are closed */ - if (!uci_dev->ref_count) { - mutex_unlock(&uci_dev->mutex); - mutex_destroy(&uci_dev->mutex); - clear_bit(MINOR(uci_dev->devt), uci_minors); - kfree(uci_dev); - mutex_unlock(&mhi_uci_drv.lock); - return; - } - - MSG_LOG("Exit\n"); - mutex_unlock(&uci_dev->mutex); - mutex_unlock(&mhi_uci_drv.lock); - -} - -static int mhi_uci_probe(struct mhi_device *mhi_dev, - const struct mhi_device_id *id) -{ - struct uci_dev *uci_dev; - int minor; - char node_name[32]; - int dir; - - uci_dev = kzalloc(sizeof(*uci_dev), GFP_KERNEL); - if (!uci_dev) - return -ENOMEM; - - mutex_init(&uci_dev->mutex); - mutex_init(&uci_dev->r_mutex); - mutex_init(&uci_dev->w_mutex); - uci_dev->mhi_dev = mhi_dev; - - minor = find_first_zero_bit(uci_minors, MAX_UCI_DEVICES); - if (minor >= MAX_UCI_DEVICES) { - kfree(uci_dev); - return -ENOSPC; - } - - mutex_lock(&uci_dev->mutex); - mutex_lock(&mhi_uci_drv.lock); - - uci_dev->devt = MKDEV(mhi_uci_drv.major, minor); -#if 1 - if (mhi_dev->mhi_cntrl->cntrl_idx) - uci_dev->dev = device_create(mhi_uci_drv.class, &mhi_dev->dev, - uci_dev->devt, uci_dev, - DEVICE_NAME "_%s%d", - mhi_dev->chan_name, mhi_dev->mhi_cntrl->cntrl_idx); - else - uci_dev->dev = device_create(mhi_uci_drv.class, &mhi_dev->dev, - uci_dev->devt, uci_dev, - DEVICE_NAME "_%s", - mhi_dev->chan_name); -#else - uci_dev->dev = device_create(mhi_uci_drv.class, &mhi_dev->dev, - uci_dev->devt, uci_dev, - DEVICE_NAME "_%04x_%02u.%02u.%02u%s%d", - mhi_dev->dev_id, mhi_dev->domain, - mhi_dev->bus, mhi_dev->slot, "_pipe_", - mhi_dev->ul_chan_id); -#endif - - set_bit(minor, uci_minors); - - /* create debugging buffer */ - snprintf(node_name, sizeof(node_name), "mhi_uci_%04x_%02u.%02u.%02u_%d", - mhi_dev->dev_id, mhi_dev->domain, mhi_dev->bus, mhi_dev->slot, - mhi_dev->ul_chan_id); - - for (dir = 0; dir < 2; dir++) { - struct uci_chan *uci_chan = (dir) ? - &uci_dev->ul_chan : &uci_dev->dl_chan; - spin_lock_init(&uci_chan->lock); - init_waitqueue_head(&uci_chan->wq); - INIT_LIST_HEAD(&uci_chan->pending); - } - - uci_dev->termios = tty_std_termios; - - uci_dev->mtu = min_t(size_t, id->driver_data, mhi_dev->mtu); - mhi_device_set_devdata(mhi_dev, uci_dev); - uci_dev->enabled = true; - - list_add(&uci_dev->node, &mhi_uci_drv.head); - mutex_unlock(&mhi_uci_drv.lock); - mutex_unlock(&uci_dev->mutex); - - MSG_LOG("channel:%s successfully probed\n", mhi_dev->chan_name); - - return 0; -}; - -static void mhi_ul_xfer_cb(struct mhi_device *mhi_dev, - struct mhi_result *mhi_result) -{ - struct uci_dev *uci_dev = mhi_device_get_devdata(mhi_dev); - struct uci_chan *uci_chan = &uci_dev->ul_chan; - - MSG_VERB("status:%d xfer_len:%zu\n", mhi_result->transaction_status, - mhi_result->bytes_xferd); - - kfree(mhi_result->buf_addr); - if (!mhi_result->transaction_status) - wake_up(&uci_chan->wq); -} - -static void mhi_dl_xfer_cb(struct mhi_device *mhi_dev, - struct mhi_result *mhi_result) -{ - struct uci_dev *uci_dev = mhi_device_get_devdata(mhi_dev); - struct uci_chan *uci_chan = &uci_dev->dl_chan; - unsigned long flags; - struct uci_buf *buf; - unsigned nr_trb = uci_dev->nr_trb; - - buf = &uci_dev->uci_buf[nr_trb]; - if (buf == NULL) { - MSG_ERR("buf = NULL"); - return; - } - if (buf->nr_trb != nr_trb || buf->data != mhi_result->buf_addr) - { - uci_dev->rx_error++; - MSG_ERR("chan[%d]: uci_buf[%u] = %p , mhi_result[%u] = %p\n", - mhi_dev->dl_chan_id, buf->nr_trb, buf->data, nr_trb, mhi_result->buf_addr); - return; - } - - uci_dev->nr_trb++; - if (uci_dev->nr_trb == uci_dev->nr_trbs) - uci_dev->nr_trb = 0; - - if (mhi_result->transaction_status == -ENOTCONN) { - return; - } - - if (mhi_result->bytes_xferd > uci_dev->mtu || mhi_result->bytes_xferd <= 0) - { - MSG_ERR("chan[%d]: bytes_xferd = %zd , mtu = %zd\n", - mhi_dev->dl_chan_id, mhi_result->bytes_xferd, uci_dev->mtu); - return; - } - if (mhi_result->bytes_xferd > uci_dev->bytes_xferd) - { - uci_dev->bytes_xferd = mhi_result->bytes_xferd; - //MSG_ERR("chan[%d]: bytes_xferd = %zd , mtu = %zd\n", - // mhi_dev->dl_chan_id, mhi_result->bytes_xferd, uci_dev->mtu); - } - - MSG_VERB("status:%d receive_len:%zu\n", mhi_result->transaction_status, - mhi_result->bytes_xferd); - - spin_lock_irqsave(&uci_chan->lock, flags); -#if 0 - buf = mhi_result->buf_addr + uci_dev->mtu; - buf->data = mhi_result->buf_addr; -#endif - buf->len = mhi_result->bytes_xferd; - if (mhi_dev->dl_chan_id == MHI_CLIENT_DUN_IN - || mhi_dev->dl_chan_id == MHI_CLIENT_QMI_IN - || mhi_dev->dl_chan_id == MHI_CLIENT_MBIM_IN) - { - struct uci_buf *tmp_buf = NULL; - int skip_buf = 0; - -#ifdef QUEC_MHI_UCI_ALWAYS_OPEN - if (uci_dev->ref_count == 1) - skip_buf++; -#endif - if (!skip_buf) - tmp_buf = (struct uci_buf *)kmalloc(buf->len + sizeof(struct uci_buf), GFP_ATOMIC);; - - if (tmp_buf) { - tmp_buf->page = NULL; - tmp_buf->data = ((void *)tmp_buf) + sizeof(struct uci_buf); - tmp_buf->len = buf->len; - memcpy(tmp_buf->data, buf->data, buf->len); - } - - if (buf) { - struct uci_buf *uci_buf = buf; - unsigned nr_trb = uci_buf->nr_trb ? (uci_buf->nr_trb - 1) : (uci_dev->nr_trbs - 1); - - uci_buf = &uci_dev->uci_buf[nr_trb]; - mhi_queue_transfer(mhi_dev, DMA_FROM_DEVICE, uci_buf->data, uci_dev->mtu, MHI_EOT); - } - - buf = tmp_buf; - } - - if (buf) - list_add_tail(&buf->node, &uci_chan->pending); - spin_unlock_irqrestore(&uci_chan->lock, flags); - -#ifdef CONFIG_PM_SLEEP - if (mhi_dev->dev.power.wakeup) - __pm_wakeup_event(mhi_dev->dev.power.wakeup, 0); -#endif - - wake_up(&uci_chan->wq); -} - -// repaire sdx6x module can not read qdb file. xingduo.du 2023-01-18 -#define DIAG_MAX_PCIE_PKT_SZ 8192 //define by module - -/* .driver_data stores max mtu */ -static const struct mhi_device_id mhi_uci_match_table[] = { - { .chan = "LOOPBACK", .driver_data = 0x1000 }, - { .chan = "SAHARA", .driver_data = 0x4000 }, - { .chan = "EDL", .driver_data = 0x4000 }, - { .chan = "DIAG", .driver_data = DIAG_MAX_PCIE_PKT_SZ }, - { .chan = "MBIM", .driver_data = 0x1000 }, - { .chan = "QMI0", .driver_data = 0x1000 }, - { .chan = "QMI1", .driver_data = 0x1000 }, - { .chan = "DUN", .driver_data = 0x1000 }, -#ifdef ENABLE_ADPL - { .chan = "ADPL", .driver_data = 0x1000 }, -#endif -#ifdef ENABLE_QDSS - { .chan = "QDSS", .driver_data = 0x1000 }, -#endif - {}, -}; - -static struct mhi_driver mhi_uci_driver = { - .id_table = mhi_uci_match_table, - .remove = mhi_uci_remove, - .probe = mhi_uci_probe, - .ul_xfer_cb = mhi_ul_xfer_cb, - .dl_xfer_cb = mhi_dl_xfer_cb, - .driver = { - .name = MHI_UCI_DRIVER_NAME, - .owner = THIS_MODULE, - }, -}; - -int mhi_device_uci_init(void) -{ - int ret; - - ret = register_chrdev(0, MHI_UCI_DRIVER_NAME, &mhidev_fops); - if (ret < 0) - return ret; - - mhi_uci_drv.major = ret; -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 4, 0)) - mhi_uci_drv.class = class_create(MHI_UCI_DRIVER_NAME); -#else - mhi_uci_drv.class = class_create(THIS_MODULE, MHI_UCI_DRIVER_NAME); -#endif - if (IS_ERR(mhi_uci_drv.class)) { - unregister_chrdev(mhi_uci_drv.major, MHI_UCI_DRIVER_NAME); - return -ENODEV; - } - - mutex_init(&mhi_uci_drv.lock); - INIT_LIST_HEAD(&mhi_uci_drv.head); - - ret = mhi_driver_register(&mhi_uci_driver); - if (ret) { - class_destroy(mhi_uci_drv.class); - unregister_chrdev(mhi_uci_drv.major, MHI_UCI_DRIVER_NAME); - } - - return ret; -} - -void mhi_device_uci_exit(void) -{ - mhi_driver_unregister(&mhi_uci_driver); - class_destroy(mhi_uci_drv.class); - unregister_chrdev(mhi_uci_drv.major, MHI_UCI_DRIVER_NAME); -} diff --git a/quectel_MHI/src/devices/rmnet/Kconfig b/quectel_MHI/src/devices/rmnet/Kconfig deleted file mode 100644 index 9bb06d2..0000000 --- a/quectel_MHI/src/devices/rmnet/Kconfig +++ /dev/null @@ -1,13 +0,0 @@ -# -# RMNET MAP driver -# - -menuconfig RMNET - tristate "RmNet MAP driver" - default n - select GRO_CELLS - ---help--- - If you select this, you will enable the RMNET module which is used - for handling data in the multiplexing and aggregation protocol (MAP) - format in the embedded data path. RMNET devices can be attached to - any IP mode physical device. diff --git a/quectel_MHI/src/devices/rmnet/Makefile b/quectel_MHI/src/devices/rmnet/Makefile deleted file mode 100644 index b175fbb..0000000 --- a/quectel_MHI/src/devices/rmnet/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -# -# Makefile for the RMNET module -# - -rmnet-y := rmnet_config.o -rmnet-y += rmnet_vnd.o -rmnet-y += rmnet_handlers.o -rmnet-y += rmnet_map_data.o -rmnet-y += rmnet_map_command.o -rmnet-y += rmnet_descriptor.o -obj-$(CONFIG_RMNET) += rmnet.o diff --git a/quectel_MHI/src/devices/rmnet/rmnet_config.c b/quectel_MHI/src/devices/rmnet/rmnet_config.c deleted file mode 100644 index c5ec0c8..0000000 --- a/quectel_MHI/src/devices/rmnet/rmnet_config.c +++ /dev/null @@ -1,141 +0,0 @@ -/* Copyright (c) 2013-2019, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * RMNET configuration engine - * - */ - -#include -#include -#include -#include -#include -#include "rmnet_config.h" -#include "rmnet_handlers.h" -#include "rmnet_vnd.h" -#include "rmnet_private.h" -#include "rmnet_map.h" -#include "rmnet_descriptor.h" - -/* Locking scheme - - * The shared resource which needs to be protected is realdev->rx_handler_data. - * For the writer path, this is using rtnl_lock(). The writer paths are - * rmnet_newlink(), rmnet_dellink() and rmnet_force_unassociate_device(). These - * paths are already called with rtnl_lock() acquired in. There is also an - * ASSERT_RTNL() to ensure that we are calling with rtnl acquired. For - * dereference here, we will need to use rtnl_dereference(). Dev list writing - * needs to happen with rtnl_lock() acquired for netdev_master_upper_dev_link(). - * For the reader path, the real_dev->rx_handler_data is called in the TX / RX - * path. We only need rcu_read_lock() for these scenarios. In these cases, - * the rcu_read_lock() is held in __dev_queue_xmit() and - * netif_receive_skb_internal(), so readers need to use rcu_dereference_rtnl() - * to get the relevant information. For dev list reading, we again acquire - * rcu_read_lock() in rmnet_dellink() for netdev_master_upper_dev_get_rcu(). - * We also use unregister_netdevice_many() to free all rmnet devices in - * rmnet_force_unassociate_device() so we dont lose the rtnl_lock() and free in - * same context. - */ - -/* Local Definitions and Declarations */ - -static int rmnet_is_real_dev_registered(const struct net_device *real_dev) -{ - return rcu_access_pointer(real_dev->rx_handler) == rmnet_rx_handler; -} - -/* Needs rtnl lock */ -static struct rmnet_port* -rmnet_get_port_rtnl(const struct net_device *real_dev) -{ - return rtnl_dereference(real_dev->rx_handler_data); -} - -static int rmnet_unregister_real_device(struct net_device *real_dev, - struct rmnet_port *port) -{ - if (port->nr_rmnet_devs) - return -EINVAL; - - rmnet_map_cmd_exit(port); - rmnet_map_tx_aggregate_exit(port); - - rmnet_descriptor_deinit(port); - - kfree(port); - - netdev_rx_handler_unregister(real_dev); - - /* release reference on real_dev */ - dev_put(real_dev); - - netdev_dbg(real_dev, "Removed from rmnet\n"); - return 0; -} - -static int rmnet_register_real_device(struct net_device *real_dev) -{ - struct rmnet_port *port; - int rc, entry; - - ASSERT_RTNL(); - - if (rmnet_is_real_dev_registered(real_dev)) - return 0; - - port = kzalloc(sizeof(*port), GFP_ATOMIC); - if (!port) - return -ENOMEM; - - port->dev = real_dev; - rc = netdev_rx_handler_register(real_dev, rmnet_rx_handler, port); - if (rc) { - kfree(port); - return -EBUSY; - } - /* hold on to real dev for MAP data */ - dev_hold(real_dev); - - for (entry = 0; entry < RMNET_MAX_LOGICAL_EP; entry++) - INIT_HLIST_HEAD(&port->muxed_ep[entry]); - - rc = rmnet_descriptor_init(port); - if (rc) { - rmnet_descriptor_deinit(port); - return rc; - } - - rmnet_map_tx_aggregate_init(port); - rmnet_map_cmd_init(port); - - netdev_dbg(real_dev, "registered with rmnet\n"); - return 0; -} - -/* Needs either rcu_read_lock() or rtnl lock */ -static struct rmnet_port *rmnet_get_port(struct net_device *real_dev) -{ - if (rmnet_is_real_dev_registered(real_dev)) - return rcu_dereference_rtnl(real_dev->rx_handler_data); - else - return NULL; -} - -static struct rmnet_endpoint *rmnet_get_endpoint(struct rmnet_port *port, u8 mux_id) -{ - struct rmnet_endpoint *ep; - - hlist_for_each_entry_rcu(ep, &port->muxed_ep[mux_id], hlnode) { - if (ep->mux_id == mux_id) - return ep; - } - - return NULL; -} diff --git a/quectel_MHI/src/devices/rmnet/rmnet_config.h b/quectel_MHI/src/devices/rmnet/rmnet_config.h deleted file mode 100644 index c74fcdf..0000000 --- a/quectel_MHI/src/devices/rmnet/rmnet_config.h +++ /dev/null @@ -1,174 +0,0 @@ -/* Copyright (c) 2013-2017, 2019 The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * RMNET Data configuration engine - * - */ - -#include -#include - -#ifndef _RMNET_CONFIG_H_ -#define _RMNET_CONFIG_H_ - -#define RMNET_MAX_LOGICAL_EP 255 -#define RMNET_MAX_VEID 4 - -struct rmnet_endpoint { - u8 mux_id; - struct net_device *egress_dev; - struct hlist_node hlnode; -}; - -struct rmnet_port_priv_stats { - u64 dl_hdr_last_qmap_vers; - u64 dl_hdr_last_ep_id; - u64 dl_hdr_last_trans_id; - u64 dl_hdr_last_seq; - u64 dl_hdr_last_bytes; - u64 dl_hdr_last_pkts; - u64 dl_hdr_last_flows; - u64 dl_hdr_count; - u64 dl_hdr_total_bytes; - u64 dl_hdr_total_pkts; - u64 dl_trl_last_seq; - u64 dl_trl_count; -}; - -struct rmnet_egress_agg_params { - u16 agg_size; - u16 agg_count; - u32 agg_time; -}; - -/* One instance of this structure is instantiated for each real_dev associated - * with rmnet. - */ -struct rmnet_port { - struct net_device *dev; - u32 data_format; - u8 nr_rmnet_devs; - u8 rmnet_mode; - struct hlist_head muxed_ep[RMNET_MAX_LOGICAL_EP]; - struct net_device *bridge_ep; - void *rmnet_perf; - - struct rmnet_egress_agg_params egress_agg_params; - - /* Protect aggregation related elements */ - spinlock_t agg_lock; - - struct sk_buff *agg_skb; - int agg_state; - u8 agg_count; - struct timespec agg_time; - struct timespec agg_last; - struct hrtimer hrtimer; - struct work_struct agg_wq; - - /* dl marker elements */ - struct list_head dl_list; - struct rmnet_port_priv_stats stats; - int dl_marker_flush; - - /* Descriptor pool */ - spinlock_t desc_pool_lock; - struct rmnet_frag_descriptor_pool *frag_desc_pool; - struct sk_buff *chain_head; - struct sk_buff *chain_tail; -}; - -extern struct rtnl_link_ops rmnet_link_ops; - -struct rmnet_vnd_stats { - u64 rx_pkts; - u64 rx_bytes; - u64 tx_pkts; - u64 tx_bytes; - u32 tx_drops; -}; - -struct rmnet_pcpu_stats { - struct rmnet_vnd_stats stats; - struct u64_stats_sync syncp; -}; - -struct rmnet_coal_close_stats { - u64 non_coal; - u64 ip_miss; - u64 trans_miss; - u64 hw_nl; - u64 hw_pkt; - u64 hw_byte; - u64 hw_time; - u64 hw_evict; - u64 coal; -}; - -struct rmnet_coal_stats { - u64 coal_rx; - u64 coal_pkts; - u64 coal_hdr_nlo_err; - u64 coal_hdr_pkt_err; - u64 coal_csum_err; - u64 coal_reconstruct; - u64 coal_ip_invalid; - u64 coal_trans_invalid; - struct rmnet_coal_close_stats close; - u64 coal_veid[RMNET_MAX_VEID]; -}; - -struct rmnet_priv_stats { - u64 csum_ok; - u64 csum_valid_unset; - u64 csum_validation_failed; - u64 csum_err_bad_buffer; - u64 csum_err_invalid_ip_version; - u64 csum_err_invalid_transport; - u64 csum_fragmented_pkt; - u64 csum_skipped; - u64 csum_sw; - u64 csum_hw; - struct rmnet_coal_stats coal; -}; - -struct rmnet_priv { - u8 mux_id; - struct net_device *real_dev; - struct rmnet_pcpu_stats __percpu *pcpu_stats; - struct gro_cells gro_cells; - struct rmnet_priv_stats stats; -}; - -enum rmnet_dl_marker_prio { - RMNET_PERF, - RMNET_SHS, -}; - -enum rmnet_trace_func { - RMNET_MODULE, - NW_STACK_MODULE, -}; - -enum rmnet_trace_evt { - RMNET_DLVR_SKB, - RMNET_RCV_FROM_PND, - RMNET_TX_UL_PKT, - NW_STACK_DEV_Q_XMIT, - NW_STACK_NAPI_GRO_FLUSH, - NW_STACK_RX, - NW_STACK_TX, -}; - -static int rmnet_is_real_dev_registered(const struct net_device *real_dev); -static struct rmnet_port *rmnet_get_port(struct net_device *real_dev); -static struct rmnet_endpoint *rmnet_get_endpoint(struct rmnet_port *port, u8 mux_id); -#endif /* _RMNET_CONFIG_H_ */ diff --git a/quectel_MHI/src/devices/rmnet/rmnet_data.c b/quectel_MHI/src/devices/rmnet/rmnet_data.c deleted file mode 100644 index ad8953c..0000000 --- a/quectel_MHI/src/devices/rmnet/rmnet_data.c +++ /dev/null @@ -1,1150 +0,0 @@ -#if 0 - -#define RMNET_MAX_PACKET_SIZE 16384 -#define RMNET_DFLT_PACKET_SIZE 1500 -#define RMNET_NEEDED_HEADROOM 16 -#define RMNET_TX_QUEUE_LEN 1000 - -#define RMNET_MAX_LOGICAL_EP 255 -#define RMNET_MAP_DESC_HEADROOM 128 -#define RMNET_FRAG_DESCRIPTOR_POOL_SIZE 64 - -/* Pass the frame up the stack with no modifications to skb->dev */ -#define RMNET_EPMODE_NONE (0) -/* Replace skb->dev to a virtual rmnet device and pass up the stack */ -#define RMNET_EPMODE_VND (1) -/* Pass the frame directly to another device with dev_queue_xmit() */ -#define RMNET_EPMODE_BRIDGE (2) - -/* rmnet section */ - -#define RMNET_FLAGS_INGRESS_DEAGGREGATION (1U << 0) -#define RMNET_FLAGS_INGRESS_MAP_COMMANDS (1U << 1) -#define RMNET_FLAGS_INGRESS_MAP_CKSUMV4 (1U << 2) -#define RMNET_FLAGS_EGRESS_MAP_CKSUMV4 (1U << 3) -#define RMNET_FLAGS_INGRESS_COALESCE (1U << 4) -#define RMNET_FLAGS_INGRESS_MAP_CKSUMV5 (1U << 5) -#define RMNET_FLAGS_EGRESS_MAP_CKSUMV5 (1U << 6) - -enum rmnet_map_v5_header_type { - RMNET_MAP_HEADER_TYPE_UNKNOWN, - RMNET_MAP_HEADER_TYPE_COALESCING = 0x1, - RMNET_MAP_HEADER_TYPE_CSUM_OFFLOAD = 0x2, - RMNET_MAP_HEADER_TYPE_ENUM_LENGTH -}; - -/* Main QMAP header */ -struct rmnet_map_header { - u8 pad_len:6; - u8 next_hdr:1; - u8 cd_bit:1; - u8 mux_id; - __be16 pkt_len; -} __aligned(1); - -/* QMAP v5 headers */ -struct rmnet_map_v5_csum_header { - u8 next_hdr:1; - u8 header_type:7; - u8 hw_reserved:7; - u8 csum_valid_required:1; - __be16 reserved; -} __aligned(1); - -struct rmnet_map_v5_nl_pair { - __be16 pkt_len; - u8 csum_error_bitmap; - u8 num_packets; -} __aligned(1); - -/* NLO: Number-length object */ -#define RMNET_MAP_V5_MAX_NLOS (6) -#define RMNET_MAP_V5_MAX_PACKETS (48) - -struct rmnet_map_v5_coal_header { - u8 next_hdr:1; - u8 header_type:7; - u8 reserved1:4; - u8 num_nlos:3; - u8 csum_valid:1; - u8 close_type:4; - u8 close_value:4; - u8 reserved2:4; - u8 virtual_channel_id:4; - - struct rmnet_map_v5_nl_pair nl_pairs[RMNET_MAP_V5_MAX_NLOS]; -} __aligned(1); - -/* QMAP v4 headers */ -struct rmnet_map_dl_csum_trailer { - u8 reserved1; - u8 valid:1; - u8 reserved2:7; - u16 csum_start_offset; - u16 csum_length; - __be16 csum_value; -} __aligned(1); - -struct rmnet_frag_descriptor_pool { - struct list_head free_list; - u32 pool_size; -}; - -struct rmnet_frag_descriptor { - struct list_head list; - struct list_head sub_frags; - skb_frag_t frag; - u8 *hdr_ptr; - struct net_device *dev; - u32 hash; - __be32 tcp_seq; - __be16 ip_id; - u16 data_offset; - u16 gso_size; - u16 gso_segs; - u16 ip_len; - u16 trans_len; - u8 ip_proto; - u8 trans_proto; - u8 pkt_id; - u8 csum_valid:1, - hdrs_valid:1, - ip_id_set:1, - tcp_seq_set:1, - flush_shs:1, - reserved:3; -}; - -struct rmnet_endpoint { - u8 rmnet_mode; - u8 mux_id; - struct net_device *rmnet_dev; -}; - -/* One instance of this structure is instantiated for each real_dev associated - * with rmnet. - */ -struct rmnet_port { - struct net_device *dev; - u8 rmnet_mode; - u32 data_format; - u32 nr_rmnet_devs; - struct rmnet_endpoint muxed_ep[16]; - - /* Descriptor pool */ - spinlock_t desc_pool_lock; - struct rmnet_frag_descriptor_pool *frag_desc_pool; - struct sk_buff *chain_head; - struct sk_buff *chain_tail; -}; - -static struct sk_buff * add_qhdr_v5(struct sk_buff *skb, u8 mux_id) -{ - struct rmnet_map_header *map_header; - struct rmnet_map_v5_csum_header *ul_header; - u32 padding, map_datalen; - - map_datalen = skb->len; - padding = map_datalen%4; - if (padding) { - padding = 4 - padding; - if (skb_tailroom(skb) < padding) { - printk("skb_tailroom small!\n"); - padding = 0; - } - if (padding) - __skb_put(skb, padding); - } - - map_header = (struct rmnet_map_header *)skb_push(skb, (sizeof(struct rmnet_map_header) + sizeof(struct rmnet_map_v5_csum_header))); - - BUILD_BUG_ON((sizeof(struct rmnet_map_header) + sizeof(struct rmnet_map_v5_csum_header)) != 8); - - map_header->cd_bit = 0; - map_header->next_hdr = 1; - map_header->pad_len = padding; - map_header->mux_id = mux_id; - map_header->pkt_len = htons(map_datalen + padding); - - ul_header = (struct rmnet_map_v5_csum_header *)(map_header + 1); - memset(ul_header, 0, sizeof(*ul_header)); - ul_header->header_type = RMNET_MAP_HEADER_TYPE_CSUM_OFFLOAD; - - return skb; -} - -struct rmnet_endpoint *rmnet_get_endpoint(struct rmnet_port *port, u8 mux_id) -{ - return &port->muxed_ep[0]; -} - -static void -rmnet_deliver_skb(struct sk_buff *skb, struct rmnet_port *port) -{ - struct rmnet_nss_cb *nss_cb; - - //rmnet_vnd_rx_fixup(skb->dev, skb->len); - - /* Pass off the packet to NSS driver if we can */ - nss_cb = rcu_dereference(rmnet_nss_callbacks); - if (nss_cb) { - if (!port->chain_head) - port->chain_head = skb; - else - skb_shinfo(port->chain_tail)->frag_list = skb; - - port->chain_tail = skb; - return; - } - - skb_reset_transport_header(skb); - skb_reset_network_header(skb); - - skb->pkt_type = PACKET_HOST; - skb_set_mac_header(skb, 0); - - //if (port->data_format & RMNET_INGRESS_FORMAT_DL_MARKER) { - //} else { - //if (!rmnet_check_skb_can_gro(skb)) - // gro_cells_receive(&priv->gro_cells, skb); - //else - netif_receive_skb(skb); - //} -} - -static inline unsigned char *rmnet_map_data_ptr(struct sk_buff *skb) -{ - /* Nonlinear packets we receive are entirely within frag 0 */ - if (skb_is_nonlinear(skb) && skb->len == skb->data_len) - return skb_frag_address(skb_shinfo(skb)->frags); - - return skb->data; -} - -static inline void *rmnet_frag_data_ptr(struct rmnet_frag_descriptor *frag_desc) -{ - return skb_frag_address(&frag_desc->frag); -} - -static struct rmnet_frag_descriptor * -rmnet_get_frag_descriptor(struct rmnet_port *port) -{ - struct rmnet_frag_descriptor_pool *pool = port->frag_desc_pool; - struct rmnet_frag_descriptor *frag_desc; - - spin_lock(&port->desc_pool_lock); - if (!list_empty(&pool->free_list)) { - frag_desc = list_first_entry(&pool->free_list, - struct rmnet_frag_descriptor, - list); - list_del_init(&frag_desc->list); - } else { - frag_desc = kzalloc(sizeof(*frag_desc), GFP_ATOMIC); - if (!frag_desc) - goto out; - - INIT_LIST_HEAD(&frag_desc->list); - INIT_LIST_HEAD(&frag_desc->sub_frags); - pool->pool_size++; - } - -out: - spin_unlock(&port->desc_pool_lock); - return frag_desc; -} - -static void rmnet_recycle_frag_descriptor(struct rmnet_frag_descriptor *frag_desc, - struct rmnet_port *port) -{ - struct rmnet_frag_descriptor_pool *pool = port->frag_desc_pool; - struct page *page = skb_frag_page(&frag_desc->frag); - - list_del(&frag_desc->list); - if (page) - put_page(page); - - memset(frag_desc, 0, sizeof(*frag_desc)); - INIT_LIST_HEAD(&frag_desc->list); - INIT_LIST_HEAD(&frag_desc->sub_frags); - spin_lock(&port->desc_pool_lock); - list_add_tail(&frag_desc->list, &pool->free_list); - spin_unlock(&port->desc_pool_lock); -} - -static inline void rmnet_frag_fill(struct rmnet_frag_descriptor *frag_desc, - struct page *p, u32 page_offset, u32 len) -{ - get_page(p); - __skb_frag_set_page(&frag_desc->frag, p); - skb_frag_size_set(&frag_desc->frag, len); - frag_desc->frag.page_offset = page_offset; -} - -static inline void *rmnet_frag_pull(struct rmnet_frag_descriptor *frag_desc, - struct rmnet_port *port, - unsigned int size) -{ - if (size >= skb_frag_size(&frag_desc->frag)) { - pr_info("%s(): Pulling %u bytes from %u byte pkt. Dropping\n", - __func__, size, skb_frag_size(&frag_desc->frag)); - rmnet_recycle_frag_descriptor(frag_desc, port); - return NULL; - } - - frag_desc->frag.page_offset += size; - skb_frag_size_sub(&frag_desc->frag, size); - - return rmnet_frag_data_ptr(frag_desc); -} - -static inline void *rmnet_frag_trim(struct rmnet_frag_descriptor *frag_desc, - struct rmnet_port *port, - unsigned int size) -{ - if (!size) { - pr_info("%s(): Trimming %u byte pkt to 0. Dropping\n", - __func__, skb_frag_size(&frag_desc->frag)); - rmnet_recycle_frag_descriptor(frag_desc, port); - return NULL; - } - - if (size < skb_frag_size(&frag_desc->frag)) - skb_frag_size_set(&frag_desc->frag, size); - - return rmnet_frag_data_ptr(frag_desc); -} - -static inline u8 -rmnet_frag_get_next_hdr_type(struct rmnet_frag_descriptor *frag_desc) -{ - unsigned char *data = rmnet_frag_data_ptr(frag_desc); - - data += sizeof(struct rmnet_map_header); - return ((struct rmnet_map_v5_coal_header *)data)->header_type; -} - -static inline bool -rmnet_frag_get_csum_valid(struct rmnet_frag_descriptor *frag_desc) -{ - unsigned char *data = rmnet_frag_data_ptr(frag_desc); - - data += sizeof(struct rmnet_map_header); - return ((struct rmnet_map_v5_csum_header *)data)->csum_valid_required; -} - -static void rmnet_descriptor_add_frag(struct rmnet_port *port, struct list_head *list, - struct page *p, u32 page_offset, u32 len) -{ - struct rmnet_frag_descriptor *frag_desc; - - frag_desc = rmnet_get_frag_descriptor(port); - if (!frag_desc) - return; - - rmnet_frag_fill(frag_desc, p, page_offset, len); - list_add_tail(&frag_desc->list, list); -} - -static void rmnet_frag_deaggregate(skb_frag_t *frag, struct rmnet_port *port, - struct list_head *list) -{ - struct rmnet_map_header *maph; - u8 *data = skb_frag_address(frag); - u32 offset = 0; - u32 packet_len; - - while (offset < skb_frag_size(frag)) { - maph = (struct rmnet_map_header *)data; - packet_len = ntohs(maph->pkt_len); - - /* Some hardware can send us empty frames. Catch them */ - if (packet_len == 0) - return; - - packet_len += sizeof(*maph); - - if (port->data_format & RMNET_FLAGS_INGRESS_MAP_CKSUMV4) { - packet_len += sizeof(struct rmnet_map_dl_csum_trailer); - WARN_ON(1); - } else if (port->data_format & - (RMNET_FLAGS_INGRESS_MAP_CKSUMV5 | - RMNET_FLAGS_INGRESS_COALESCE) && !maph->cd_bit) { - u32 hsize = 0; - u8 type; - - type = ((struct rmnet_map_v5_coal_header *) - (data + sizeof(*maph)))->header_type; - switch (type) { - case RMNET_MAP_HEADER_TYPE_COALESCING: - hsize = sizeof(struct rmnet_map_v5_coal_header); - break; - case RMNET_MAP_HEADER_TYPE_CSUM_OFFLOAD: - hsize = sizeof(struct rmnet_map_v5_csum_header); - break; - } - - packet_len += hsize; - } - else { - qmap_hex_dump(__func__, data, 64); - WARN_ON(1); - } - - if ((int)skb_frag_size(frag) - (int)packet_len < 0) - return; - - rmnet_descriptor_add_frag(port, list, skb_frag_page(frag), - frag->page_offset + offset, - packet_len); - - offset += packet_len; - data += packet_len; - } -} - - -#define RMNET_IP_VERSION_4 0x40 -#define RMNET_IP_VERSION_6 0x60 - -/* Helper Functions */ - -static void rmnet_set_skb_proto(struct sk_buff *skb) -{ - switch (rmnet_map_data_ptr(skb)[0] & 0xF0) { - case RMNET_IP_VERSION_4: - skb->protocol = htons(ETH_P_IP); - break; - case RMNET_IP_VERSION_6: - skb->protocol = htons(ETH_P_IPV6); - break; - default: - skb->protocol = htons(ETH_P_MAP); - WARN_ON(1); - break; - } -} - -/* Allocate and populate an skb to contain the packet represented by the - * frag descriptor. - */ -static struct sk_buff *rmnet_alloc_skb(struct rmnet_frag_descriptor *frag_desc, - struct rmnet_port *port) -{ - struct sk_buff *head_skb, *current_skb, *skb; - struct skb_shared_info *shinfo; - struct rmnet_frag_descriptor *sub_frag, *tmp; - - /* Use the exact sizes if we know them (i.e. RSB/RSC, rmnet_perf) */ - if (frag_desc->hdrs_valid) { - u16 hdr_len = frag_desc->ip_len + frag_desc->trans_len; - - head_skb = alloc_skb(hdr_len + RMNET_MAP_DESC_HEADROOM, - GFP_ATOMIC); - if (!head_skb) - return NULL; - - skb_reserve(head_skb, RMNET_MAP_DESC_HEADROOM); - skb_put_data(head_skb, frag_desc->hdr_ptr, hdr_len); - skb_reset_network_header(head_skb); - - if (frag_desc->trans_len) - skb_set_transport_header(head_skb, frag_desc->ip_len); - - /* Packets that have no data portion don't need any frags */ - if (hdr_len == skb_frag_size(&frag_desc->frag)) - goto skip_frags; - - /* If the headers we added are the start of the page, - * we don't want to add them twice - */ - if (frag_desc->hdr_ptr == rmnet_frag_data_ptr(frag_desc)) { - if (!rmnet_frag_pull(frag_desc, port, hdr_len)) { - kfree_skb(head_skb); - return NULL; - } - } - } else { - /* Allocate enough space to avoid penalties in the stack - * from __pskb_pull_tail() - */ - head_skb = alloc_skb(256 + RMNET_MAP_DESC_HEADROOM, - GFP_ATOMIC); - if (!head_skb) - return NULL; - - skb_reserve(head_skb, RMNET_MAP_DESC_HEADROOM); - } - - /* Add main fragment */ - get_page(skb_frag_page(&frag_desc->frag)); - skb_add_rx_frag(head_skb, 0, skb_frag_page(&frag_desc->frag), - frag_desc->frag.page_offset, - skb_frag_size(&frag_desc->frag), - skb_frag_size(&frag_desc->frag)); - - shinfo = skb_shinfo(head_skb); - current_skb = head_skb; - - /* Add in any frags from rmnet_perf */ - list_for_each_entry_safe(sub_frag, tmp, &frag_desc->sub_frags, list) { - skb_frag_t *frag; - u32 frag_size; - - frag = &sub_frag->frag; - frag_size = skb_frag_size(frag); - -add_frag: - if (shinfo->nr_frags < MAX_SKB_FRAGS) { - get_page(skb_frag_page(frag)); - skb_add_rx_frag(current_skb, shinfo->nr_frags, - skb_frag_page(frag), frag->page_offset, - frag_size, frag_size); - if (current_skb != head_skb) { - head_skb->len += frag_size; - head_skb->data_len += frag_size; - } - } else { - /* Alloc a new skb and try again */ - skb = alloc_skb(0, GFP_ATOMIC); - if (!skb) - break; - - if (current_skb == head_skb) - shinfo->frag_list = skb; - else - current_skb->next = skb; - - current_skb = skb; - shinfo = skb_shinfo(current_skb); - goto add_frag; - } - - rmnet_recycle_frag_descriptor(sub_frag, port); - } - -skip_frags: - head_skb->dev = frag_desc->dev; - rmnet_set_skb_proto(head_skb); - - /* Handle any header metadata that needs to be updated after RSB/RSC - * segmentation - */ - if (frag_desc->ip_id_set) { - struct iphdr *iph; - - iph = (struct iphdr *)rmnet_map_data_ptr(head_skb); - csum_replace2(&iph->check, iph->id, frag_desc->ip_id); - iph->id = frag_desc->ip_id; - } - - if (frag_desc->tcp_seq_set) { - struct tcphdr *th; - - th = (struct tcphdr *) - (rmnet_map_data_ptr(head_skb) + frag_desc->ip_len); - th->seq = frag_desc->tcp_seq; - } - - /* Handle csum offloading */ - if (frag_desc->csum_valid && frag_desc->hdrs_valid) { - /* Set the partial checksum information */ - //rmnet_frag_partial_csum(head_skb, frag_desc); - WARN_ON(1); - } else if (frag_desc->csum_valid) { - /* Non-RSB/RSC/perf packet. The current checksum is fine */ - head_skb->ip_summed = CHECKSUM_UNNECESSARY; - } else if (frag_desc->hdrs_valid && - (frag_desc->trans_proto == IPPROTO_TCP || - frag_desc->trans_proto == IPPROTO_UDP)) { - /* Unfortunately, we have to fake a bad checksum here, since - * the original bad value is lost by the hardware. The only - * reliable way to do it is to calculate the actual checksum - * and corrupt it. - */ - __sum16 *check; - __wsum csum; - unsigned int offset = skb_transport_offset(head_skb); - __sum16 pseudo; - - WARN_ON(1); - /* Calculate pseudo header and update header fields */ - if (frag_desc->ip_proto == 4) { - struct iphdr *iph = ip_hdr(head_skb); - __be16 tot_len = htons(head_skb->len); - - csum_replace2(&iph->check, iph->tot_len, tot_len); - iph->tot_len = tot_len; - pseudo = ~csum_tcpudp_magic(iph->saddr, iph->daddr, - head_skb->len - - frag_desc->ip_len, - frag_desc->trans_proto, 0); - } else { - struct ipv6hdr *ip6h = ipv6_hdr(head_skb); - - ip6h->payload_len = htons(head_skb->len - - sizeof(*ip6h)); - pseudo = ~csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr, - head_skb->len - - frag_desc->ip_len, - frag_desc->trans_proto, 0); - } - - if (frag_desc->trans_proto == IPPROTO_TCP) { - check = &tcp_hdr(head_skb)->check; - } else { - udp_hdr(head_skb)->len = htons(head_skb->len - - frag_desc->ip_len); - check = &udp_hdr(head_skb)->check; - } - - *check = pseudo; - csum = skb_checksum(head_skb, offset, head_skb->len - offset, - 0); - /* Add 1 to corrupt. This cannot produce a final value of 0 - * since csum_fold() can't return a value of 0xFFFF - */ - *check = csum16_add(csum_fold(csum), htons(1)); - head_skb->ip_summed = CHECKSUM_NONE; - } - - /* Handle any rmnet_perf metadata */ - if (frag_desc->hash) { - head_skb->hash = frag_desc->hash; - head_skb->sw_hash = 1; - } - - if (frag_desc->flush_shs) - head_skb->cb[0] = 1; - - /* Handle coalesced packets */ - //if (frag_desc->gso_segs > 1) - // rmnet_frag_gso_stamp(head_skb, frag_desc); - - return head_skb; -} - -/* Deliver the packets contained within a frag descriptor */ -static void rmnet_frag_deliver(struct rmnet_frag_descriptor *frag_desc, - struct rmnet_port *port) -{ - struct sk_buff *skb; - - skb = rmnet_alloc_skb(frag_desc, port); - if (skb) - rmnet_deliver_skb(skb, port); - rmnet_recycle_frag_descriptor(frag_desc, port); -} - -/* Process a QMAPv5 packet header */ -static int rmnet_frag_process_next_hdr_packet(struct rmnet_frag_descriptor *frag_desc, - struct rmnet_port *port, - struct list_head *list, - u16 len) -{ - int rc = 0; - - switch (rmnet_frag_get_next_hdr_type(frag_desc)) { - case RMNET_MAP_HEADER_TYPE_COALESCING: - rc = -1; - WARN_ON(1); - break; - case RMNET_MAP_HEADER_TYPE_CSUM_OFFLOAD: - if (rmnet_frag_get_csum_valid(frag_desc)) { - frag_desc->csum_valid = true; - } else { - } - - if (!rmnet_frag_pull(frag_desc, port, - sizeof(struct rmnet_map_header) + - sizeof(struct rmnet_map_v5_csum_header))) { - rc = -EINVAL; - break; - } - - frag_desc->hdr_ptr = rmnet_frag_data_ptr(frag_desc); - - /* Remove padding only for csum offload packets. - * Coalesced packets should never have padding. - */ - if (!rmnet_frag_trim(frag_desc, port, len)) { - rc = -EINVAL; - break; - } - - list_del_init(&frag_desc->list); - list_add_tail(&frag_desc->list, list); - break; - default: - qmap_hex_dump(__func__, rmnet_frag_data_ptr(frag_desc), 64); - rc = -EINVAL; - break; - } - - return rc; -} - -static void -__rmnet_frag_ingress_handler(struct rmnet_frag_descriptor *frag_desc, - struct rmnet_port *port) -{ - struct rmnet_map_header *qmap; - struct rmnet_endpoint *ep; - struct rmnet_frag_descriptor *frag, *tmp; - LIST_HEAD(segs); - u16 len, pad; - u8 mux_id; - - qmap = (struct rmnet_map_header *)skb_frag_address(&frag_desc->frag); - mux_id = qmap->mux_id; - pad = qmap->pad_len; - len = ntohs(qmap->pkt_len) - pad; - - if (qmap->cd_bit) { - goto recycle; - } - - if (mux_id >= RMNET_MAX_LOGICAL_EP) - goto recycle; - - ep = rmnet_get_endpoint(port, mux_id); - if (!ep) - goto recycle; - - frag_desc->dev = ep->rmnet_dev; - - /* Handle QMAPv5 packet */ - if (qmap->next_hdr && - (port->data_format & (RMNET_FLAGS_INGRESS_COALESCE | - RMNET_FLAGS_INGRESS_MAP_CKSUMV5))) { - if (rmnet_frag_process_next_hdr_packet(frag_desc, port, &segs, - len)) - goto recycle; - } else { - /* We only have the main QMAP header to worry about */ - if (!rmnet_frag_pull(frag_desc, port, sizeof(*qmap))) - return; - - frag_desc->hdr_ptr = rmnet_frag_data_ptr(frag_desc); - - if (!rmnet_frag_trim(frag_desc, port, len)) - return; - - list_add_tail(&frag_desc->list, &segs); - } - - list_for_each_entry_safe(frag, tmp, &segs, list) { - list_del_init(&frag->list); - rmnet_frag_deliver(frag, port); - } - return; - -recycle: - rmnet_recycle_frag_descriptor(frag_desc, port); -} - -static void rmnet_frag_ingress_handler(struct sk_buff *skb, - struct rmnet_port *port) -{ - LIST_HEAD(desc_list); - int i = 0; - struct rmnet_nss_cb *nss_cb; - - /* Deaggregation and freeing of HW originating - * buffers is done within here - */ - while (skb) { - struct sk_buff *skb_frag; - - port->chain_head = NULL; - port->chain_tail = NULL; - - for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { - rmnet_frag_deaggregate(&skb_shinfo(skb)->frags[i], port, - &desc_list); - if (!list_empty(&desc_list)) { - struct rmnet_frag_descriptor *frag_desc, *tmp; - - list_for_each_entry_safe(frag_desc, tmp, - &desc_list, list) { - list_del_init(&frag_desc->list); - __rmnet_frag_ingress_handler(frag_desc, - port); - } - } - } - - nss_cb = rcu_dereference(rmnet_nss_callbacks); - if (nss_cb && port->chain_head) { - port->chain_head->cb[0] = 0; - netif_receive_skb(port->chain_head); - } - - skb_frag = skb_shinfo(skb)->frag_list; - skb_shinfo(skb)->frag_list = NULL; - consume_skb(skb); - skb = skb_frag; - } -} - -static void -rmnet_map_ingress_handler(struct sk_buff *skb, - struct rmnet_port *port) -{ - if (port->data_format & (RMNET_FLAGS_INGRESS_COALESCE | - RMNET_FLAGS_INGRESS_MAP_CKSUMV5)) { - if (skb_is_nonlinear(skb)) { - rmnet_frag_ingress_handler(skb, port); - return; - } - } - - WARN_ON(1); -} - -static rx_handler_result_t rmnet_rx_handler(struct sk_buff **pskb); -static int rmnet_is_real_dev_registered(const struct net_device *real_dev) -{ - return rcu_access_pointer(real_dev->rx_handler) == rmnet_rx_handler; -} - - -/* Needs either rcu_read_lock() or rtnl lock */ -struct rmnet_port *rmnet_get_port(struct net_device *real_dev) -{ - if (rmnet_is_real_dev_registered(real_dev)) - return rcu_dereference_rtnl(real_dev->rx_handler_data); - else - return NULL; -} - -static rx_handler_result_t rmnet_rx_priv_handler(struct sk_buff **pskb) -{ - struct sk_buff *skb = *pskb; - struct rmnet_nss_cb *nss_cb; - - if (!skb) - return RX_HANDLER_CONSUMED; - if (nss_debug) printk("%s skb=%p, len=%d, protocol=%x, hdr_len=%d\n", __func__, skb, skb->len, skb->protocol, skb->hdr_len); - - if (skb->pkt_type == PACKET_LOOPBACK) - return RX_HANDLER_PASS; - - /* Check this so that we dont loop around netif_receive_skb */ - if (skb->cb[0] == 1) { - skb->cb[0] = 0; - - skb->dev->stats.rx_packets++; - return RX_HANDLER_PASS; - } - - while (skb) { - struct sk_buff *skb_frag = skb_shinfo(skb)->frag_list; - - skb_shinfo(skb)->frag_list = NULL; - - nss_cb = rcu_dereference(rmnet_nss_callbacks); - if (nss_cb) - nss_cb->nss_tx(skb); - - skb = skb_frag; - } - - return RX_HANDLER_CONSUMED; -} - -/* Ingress / Egress Entry Points */ - -/* Processes packet as per ingress data format for receiving device. Logical - * endpoint is determined from packet inspection. Packet is then sent to the - * egress device listed in the logical endpoint configuration. - */ -static rx_handler_result_t rmnet_rx_handler(struct sk_buff **pskb) -{ - struct sk_buff *skb = *pskb; - struct rmnet_port *port; - struct net_device *dev; - - if (!skb) - goto done; - - if (nss_debug) printk("%s skb=%p, len=%d, protocol=%x, hdr_len=%d\n", __func__, skb, skb->len, skb->protocol, skb->hdr_len); - - if (skb->pkt_type == PACKET_LOOPBACK) - return RX_HANDLER_PASS; - - if (skb->protocol != htons(ETH_P_MAP)) { - WARN_ON(1); - return RX_HANDLER_PASS; - } - - dev = skb->dev; - port = rmnet_get_port(dev); - - if (port == NULL) - return RX_HANDLER_PASS; - - port->chain_head = NULL; - port->chain_tail = NULL; - - switch (port->rmnet_mode) { - case RMNET_EPMODE_VND: - rmnet_map_ingress_handler(skb, port); - break; - case RMNET_EPMODE_BRIDGE: - //rmnet_bridge_handler(skb, port->bridge_ep); - break; - } - -done: - return RX_HANDLER_CONSUMED; -} - -static void rmnet_descriptor_deinit(struct rmnet_port *port) -{ - struct rmnet_frag_descriptor_pool *pool; - struct rmnet_frag_descriptor *frag_desc, *tmp; - - pool = port->frag_desc_pool; - - list_for_each_entry_safe(frag_desc, tmp, &pool->free_list, list) { - kfree(frag_desc); - pool->pool_size--; - } - - kfree(pool); -} - -static int rmnet_descriptor_init(struct rmnet_port *port) -{ - struct rmnet_frag_descriptor_pool *pool; - int i; - - spin_lock_init(&port->desc_pool_lock); - pool = kzalloc(sizeof(*pool), GFP_ATOMIC); - if (!pool) - return -ENOMEM; - - INIT_LIST_HEAD(&pool->free_list); - port->frag_desc_pool = pool; - - for (i = 0; i < RMNET_FRAG_DESCRIPTOR_POOL_SIZE; i++) { - struct rmnet_frag_descriptor *frag_desc; - - frag_desc = kzalloc(sizeof(*frag_desc), GFP_ATOMIC); - if (!frag_desc) - return -ENOMEM; - - INIT_LIST_HEAD(&frag_desc->list); - INIT_LIST_HEAD(&frag_desc->sub_frags); - list_add_tail(&frag_desc->list, &pool->free_list); - pool->pool_size++; - } - - return 0; -} - -struct rmnet_priv { - //struct rmnet_endpoint local_ep; - struct net_device *real_dev; - u8 mux_id; -}; - -static netdev_tx_t rmnet_vnd_start_xmit(struct sk_buff *skb, - struct net_device *dev) -{ - struct rmnet_priv *priv; - - if (nss_debug) printk("%s skb=%p, len=%d, protocol=%x, hdr_len=%d\n", __func__, skb, skb->len, skb->protocol, skb->hdr_len); - - priv = netdev_priv(dev); - if (priv->real_dev) { - add_qhdr_v5(skb, priv->mux_id); - skb->protocol = htons(ETH_P_MAP); - skb->dev = priv->real_dev; - dev_queue_xmit(skb); - dev->stats.tx_packets++; - //rmnet_egress_handler(skb); - } else { - //this_cpu_inc(priv->pcpu_stats->stats.tx_drops); - kfree_skb(skb); - } - return NETDEV_TX_OK; -} - -static int rmnet_vnd_change_mtu(struct net_device *rmnet_dev, int new_mtu) -{ - if (new_mtu < 0 || new_mtu > RMNET_MAX_PACKET_SIZE) - return -EINVAL; - - rmnet_dev->mtu = new_mtu; - return 0; -} - -static const struct net_device_ops rmnet_vnd_ops = { - .ndo_start_xmit = rmnet_vnd_start_xmit, - .ndo_change_mtu = rmnet_vnd_change_mtu, - //.ndo_get_iflink = rmnet_vnd_get_iflink, - //.ndo_add_slave = rmnet_add_bridge, - //.ndo_del_slave = rmnet_del_bridge, - //.ndo_init = rmnet_vnd_init, - //.ndo_uninit = rmnet_vnd_uninit, - //.ndo_get_stats64 = rmnet_get_stats64, -}; - -static void rmnet_vnd_setup(struct net_device *rmnet_dev) -{ - rmnet_dev->netdev_ops = &rmnet_vnd_ops; - rmnet_dev->mtu = RMNET_DFLT_PACKET_SIZE; - rmnet_dev->needed_headroom = RMNET_NEEDED_HEADROOM; - random_ether_addr(rmnet_dev->dev_addr); - rmnet_dev->tx_queue_len = RMNET_TX_QUEUE_LEN; - - /* Raw IP mode */ - rmnet_dev->header_ops = NULL; /* No header */ - rmnet_dev->type = ARPHRD_RAWIP; - rmnet_dev->hard_header_len = 0; - rmnet_dev->flags &= ~(IFF_BROADCAST | IFF_MULTICAST); - - //rmnet_dev->needs_free_netdev = true; - - rmnet_dev->hw_features = NETIF_F_RXCSUM; - rmnet_dev->hw_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; - //rmnet_dev->hw_features |= NETIF_F_SG; - //rmnet_dev->hw_features |= NETIF_F_GRO_HW; -} -#else -#include -#include -#include -#include -#include -#include -#include -#include - -static uint nss_debug = 0; -module_param( nss_debug, uint, S_IRUGO | S_IWUSR); - -/* rmnet section */ - -#define RMNET_FLAGS_INGRESS_DEAGGREGATION (1U << 0) -#define RMNET_FLAGS_INGRESS_MAP_COMMANDS (1U << 1) -#define RMNET_FLAGS_INGRESS_MAP_CKSUMV4 (1U << 2) -#define RMNET_FLAGS_EGRESS_MAP_CKSUMV4 (1U << 3) -#define RMNET_FLAGS_INGRESS_COALESCE (1U << 4) -#define RMNET_FLAGS_INGRESS_MAP_CKSUMV5 (1U << 5) -#define RMNET_FLAGS_EGRESS_MAP_CKSUMV5 (1U << 6) - -#ifdef CONFIG_ARCH_IPQ807x -#define CONFIG_QCA_NSS_DRV -#endif -#ifdef CONFIG_QCA_NSS_DRV -#include "rmnet_nss.c" -#else -#include "rmnet_nss.h" -#endif - -#include "rmnet_vnd.c" -#include "rmnet_map_command.c" -#include "rmnet_map_data.c" -#include "rmnet_descriptor.c" -#include "rmnet_config.c" -#include "rmnet_handlers.c" - -struct rmnet_nss_cb *rmnet_nss_callbacks __rcu __read_mostly; - -void rmnet_data_init(struct net_device *real_dev, u32 nr_rmnet_devs) -{ - struct rmnet_port *port; - struct rmnet_endpoint *ep; - struct net_device *rmnet_dev = NULL; - u32 nr = 0; - struct rmnet_nss_cb *nss_cb; - int rc = 0; - - nss_cb = rcu_dereference(rmnet_nss_callbacks); - if (!nss_cb) - { -#ifdef CONFIG_QCA_NSS_DRV - pr_err("%s(): initializing rmnet_nss\n", __func__); - RCU_INIT_POINTER(rmnet_nss_callbacks, &rmnet_nss); -#endif - } - - rtnl_lock(); - rc = rmnet_register_real_device(real_dev); - rtnl_unlock(); - - if (rc) { - pr_err("%s rmnet_register_real_device = %d\n", __func__, rc); - return; - } - - port = rmnet_get_port_rtnl(real_dev); - port->data_format = RMNET_FLAGS_INGRESS_DEAGGREGATION - | RMNET_FLAGS_INGRESS_MAP_CKSUMV5 | RMNET_FLAGS_EGRESS_MAP_CKSUMV5; - port->rmnet_mode = RMNET_EPMODE_VND; - - for (nr = 0; nr < nr_rmnet_devs; nr++) { - u8 mux_id = 0x81+nr; - - ep = kzalloc(sizeof(*ep), GFP_ATOMIC); - - rtnl_lock(); - rmnet_dev = alloc_netdev(sizeof(struct rmnet_priv), - "rmnet_data%d", NET_NAME_PREDICTABLE, - rmnet_vnd_setup); - - rmnet_vnd_newlink(mux_id, rmnet_dev, port, real_dev, ep); - netdev_rx_handler_register(rmnet_dev, rmnet_rx_priv_handler, NULL); - rtnl_unlock(); - - hlist_add_head_rcu(&ep->hlnode, &port->muxed_ep[mux_id]); - } - - port->nr_rmnet_devs = nr_rmnet_devs; -} - -void rmnet_data_deinit(struct net_device *real_dev, u32 nr_rmnet_devs) -{ - struct rmnet_port *port; - u32 nr = 0; - struct rmnet_nss_cb *nss_cb; - - if (!real_dev || !rmnet_is_real_dev_registered(real_dev)) - return; - - port = rmnet_get_port_rtnl(real_dev); - - for (nr = 0; nr < nr_rmnet_devs; nr++) { - struct rmnet_endpoint *ep; - u8 mux_id = 0x81+nr; - - ep = rmnet_get_endpoint(port, mux_id); - if (ep) { - hlist_del_init_rcu(&ep->hlnode); - rmnet_vnd_dellink(mux_id, port, ep); - synchronize_rcu(); - kfree(ep); - } - } - - rmnet_unregister_real_device(real_dev, port); - - nss_cb = rcu_dereference(rmnet_nss_callbacks); - if (nss_cb) { -#ifdef CONFIG_QCA_NSS_DRV - struct hlist_node *tmp; - struct rmnet_nss_ctx *ctx; - int bkt; - - pr_err("%s(): exiting rmnet_nss\n", __func__); - RCU_INIT_POINTER(rmnet_nss_callbacks, NULL); - - /* Tear down all NSS contexts */ - hash_for_each_safe(rmnet_nss_ctx_hashtable, bkt, tmp, ctx, hnode) - rmnet_nss_free_ctx(ctx); -#endif - } -} -#endif diff --git a/quectel_MHI/src/devices/rmnet/rmnet_descriptor.c b/quectel_MHI/src/devices/rmnet/rmnet_descriptor.c deleted file mode 100644 index 75006d1..0000000 --- a/quectel_MHI/src/devices/rmnet/rmnet_descriptor.c +++ /dev/null @@ -1,661 +0,0 @@ -/* Copyright (c) 2013-2019, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * RMNET Packet Descriptor Framework - * - */ - -#include -#include -#include -#include -#include "rmnet_config.h" -#include "rmnet_descriptor.h" -#include "rmnet_handlers.h" -#include "rmnet_private.h" -#include "rmnet_vnd.h" - -#define RMNET_FRAG_DESCRIPTOR_POOL_SIZE 64 -#define RMNET_DL_IND_HDR_SIZE (sizeof(struct rmnet_map_dl_ind_hdr) + \ - sizeof(struct rmnet_map_header) + \ - sizeof(struct rmnet_map_control_command_header)) -#define RMNET_DL_IND_TRL_SIZE (sizeof(struct rmnet_map_dl_ind_trl) + \ - sizeof(struct rmnet_map_header) + \ - sizeof(struct rmnet_map_control_command_header)) - -typedef void (*rmnet_perf_desc_hook_t)(struct rmnet_frag_descriptor *frag_desc, - struct rmnet_port *port); -typedef void (*rmnet_perf_chain_hook_t)(void); - -static struct rmnet_frag_descriptor * -rmnet_get_frag_descriptor(struct rmnet_port *port) -{ - struct rmnet_frag_descriptor_pool *pool = port->frag_desc_pool; - struct rmnet_frag_descriptor *frag_desc; - - spin_lock(&port->desc_pool_lock); - if (!list_empty(&pool->free_list)) { - frag_desc = list_first_entry(&pool->free_list, - struct rmnet_frag_descriptor, - list); - list_del_init(&frag_desc->list); - } else { - frag_desc = kzalloc(sizeof(*frag_desc), GFP_ATOMIC); - if (!frag_desc) - goto out; - - INIT_LIST_HEAD(&frag_desc->list); - INIT_LIST_HEAD(&frag_desc->sub_frags); - pool->pool_size++; - } - -out: - spin_unlock(&port->desc_pool_lock); - return frag_desc; -} - -static void rmnet_recycle_frag_descriptor(struct rmnet_frag_descriptor *frag_desc, - struct rmnet_port *port) -{ - struct rmnet_frag_descriptor_pool *pool = port->frag_desc_pool; - struct page *page = skb_frag_page(&frag_desc->frag); - - list_del(&frag_desc->list); - if (page) - put_page(page); - - memset(frag_desc, 0, sizeof(*frag_desc)); - INIT_LIST_HEAD(&frag_desc->list); - INIT_LIST_HEAD(&frag_desc->sub_frags); - spin_lock(&port->desc_pool_lock); - list_add_tail(&frag_desc->list, &pool->free_list); - spin_unlock(&port->desc_pool_lock); -} - -static void rmnet_descriptor_add_frag(struct rmnet_port *port, struct list_head *list, - struct page *p, u32 page_offset, u32 len) -{ - struct rmnet_frag_descriptor *frag_desc; - - frag_desc = rmnet_get_frag_descriptor(port); - if (!frag_desc) - return; - - rmnet_frag_fill(frag_desc, p, page_offset, len); - list_add_tail(&frag_desc->list, list); -} - -static u8 rmnet_frag_do_flow_control(struct rmnet_map_header *qmap, - struct rmnet_port *port, - int enable) -{ - struct rmnet_map_control_command *cmd; - struct rmnet_endpoint *ep; - struct net_device *vnd; - u16 ip_family; - u16 fc_seq; - u32 qos_id; - u8 mux_id; - int r; - - mux_id = qmap->mux_id; - cmd = (struct rmnet_map_control_command *) - ((char *)qmap + sizeof(*qmap)); - - if (mux_id >= RMNET_MAX_LOGICAL_EP) - return RX_HANDLER_CONSUMED; - - ep = rmnet_get_endpoint(port, mux_id); - if (!ep) - return RX_HANDLER_CONSUMED; - - vnd = ep->egress_dev; - - ip_family = cmd->flow_control.ip_family; - fc_seq = ntohs(cmd->flow_control.flow_control_seq_num); - qos_id = ntohl(cmd->flow_control.qos_id); - - /* Ignore the ip family and pass the sequence number for both v4 and v6 - * sequence. User space does not support creating dedicated flows for - * the 2 protocols - */ - r = rmnet_vnd_do_flow_control(vnd, enable); - if (r) - return RMNET_MAP_COMMAND_UNSUPPORTED; - else - return RMNET_MAP_COMMAND_ACK; -} - -static void rmnet_frag_send_ack(struct rmnet_map_header *qmap, - unsigned char type, - struct rmnet_port *port) -{ - struct rmnet_map_control_command *cmd; - struct net_device *dev = port->dev; - struct sk_buff *skb; - u16 alloc_len = ntohs(qmap->pkt_len) + sizeof(*qmap); - - skb = alloc_skb(alloc_len, GFP_ATOMIC); - if (!skb) - return; - - skb->protocol = htons(ETH_P_MAP); - skb->dev = dev; - - cmd = rmnet_map_get_cmd_start(skb); - cmd->cmd_type = type & 0x03; - - netif_tx_lock(dev); - dev->netdev_ops->ndo_start_xmit(skb, dev); - netif_tx_unlock(dev); -} - - -/* Process MAP command frame and send N/ACK message as appropriate. Message cmd - * name is decoded here and appropriate handler is called. - */ -static void rmnet_frag_command(struct rmnet_map_header *qmap, struct rmnet_port *port) -{ - struct rmnet_map_control_command *cmd; - unsigned char command_name; - unsigned char rc = 0; - - cmd = (struct rmnet_map_control_command *) - ((char *)qmap + sizeof(*qmap)); - command_name = cmd->command_name; - - switch (command_name) { - case RMNET_MAP_COMMAND_FLOW_ENABLE: - rc = rmnet_frag_do_flow_control(qmap, port, 1); - break; - - case RMNET_MAP_COMMAND_FLOW_DISABLE: - rc = rmnet_frag_do_flow_control(qmap, port, 0); - break; - - default: - rc = RMNET_MAP_COMMAND_UNSUPPORTED; - break; - } - if (rc == RMNET_MAP_COMMAND_ACK) - rmnet_frag_send_ack(qmap, rc, port); -} - -static void rmnet_frag_deaggregate(skb_frag_t *frag, struct rmnet_port *port, - struct list_head *list) -{ - struct rmnet_map_header *maph; - u8 *data = skb_frag_address(frag); - u32 offset = 0; - u32 packet_len; - - while (offset < skb_frag_size(frag)) { - maph = (struct rmnet_map_header *)data; - packet_len = ntohs(maph->pkt_len); - - /* Some hardware can send us empty frames. Catch them */ - if (packet_len == 0) - return; - - packet_len += sizeof(*maph); - - if (port->data_format & RMNET_FLAGS_INGRESS_MAP_CKSUMV4) { - packet_len += sizeof(struct rmnet_map_dl_csum_trailer); - WARN_ON(1); - } else if (port->data_format & - (RMNET_FLAGS_INGRESS_MAP_CKSUMV5 | - RMNET_FLAGS_INGRESS_COALESCE) && !maph->cd_bit) { - u32 hsize = 0; - u8 type; - - type = ((struct rmnet_map_v5_coal_header *) - (data + sizeof(*maph)))->header_type; - switch (type) { - case RMNET_MAP_HEADER_TYPE_COALESCING: - hsize = sizeof(struct rmnet_map_v5_coal_header); - break; - case RMNET_MAP_HEADER_TYPE_CSUM_OFFLOAD: - hsize = sizeof(struct rmnet_map_v5_csum_header); - break; - } - - packet_len += hsize; - } - else { - //qmap_hex_dump(__func__, data, 64); - WARN_ON(1); - } - - if ((int)skb_frag_size(frag) - (int)packet_len < 0) - return; - - rmnet_descriptor_add_frag(port, list, skb_frag_page(frag), - frag->page_offset + offset, - packet_len); - - offset += packet_len; - data += packet_len; - } -} - -/* Allocate and populate an skb to contain the packet represented by the - * frag descriptor. - */ -static struct sk_buff *rmnet_alloc_skb(struct rmnet_frag_descriptor *frag_desc, - struct rmnet_port *port) -{ - struct sk_buff *head_skb, *current_skb, *skb; - struct skb_shared_info *shinfo; - struct rmnet_frag_descriptor *sub_frag, *tmp; - - /* Use the exact sizes if we know them (i.e. RSB/RSC, rmnet_perf) */ - if (frag_desc->hdrs_valid) { - u16 hdr_len = frag_desc->ip_len + frag_desc->trans_len; - - head_skb = alloc_skb(hdr_len + RMNET_MAP_DESC_HEADROOM, - GFP_ATOMIC); - if (!head_skb) - return NULL; - - skb_reserve(head_skb, RMNET_MAP_DESC_HEADROOM); - skb_put_data(head_skb, frag_desc->hdr_ptr, hdr_len); - skb_reset_network_header(head_skb); - - if (frag_desc->trans_len) - skb_set_transport_header(head_skb, frag_desc->ip_len); - - /* Packets that have no data portion don't need any frags */ - if (hdr_len == skb_frag_size(&frag_desc->frag)) - goto skip_frags; - - /* If the headers we added are the start of the page, - * we don't want to add them twice - */ - if (frag_desc->hdr_ptr == rmnet_frag_data_ptr(frag_desc)) { - if (!rmnet_frag_pull(frag_desc, port, hdr_len)) { - kfree_skb(head_skb); - return NULL; - } - } - } else { - /* Allocate enough space to avoid penalties in the stack - * from __pskb_pull_tail() - */ - head_skb = alloc_skb(256 + RMNET_MAP_DESC_HEADROOM, - GFP_ATOMIC); - if (!head_skb) - return NULL; - - skb_reserve(head_skb, RMNET_MAP_DESC_HEADROOM); - } - - /* Add main fragment */ - get_page(skb_frag_page(&frag_desc->frag)); - skb_add_rx_frag(head_skb, 0, skb_frag_page(&frag_desc->frag), - frag_desc->frag.page_offset, - skb_frag_size(&frag_desc->frag), - skb_frag_size(&frag_desc->frag)); - - shinfo = skb_shinfo(head_skb); - current_skb = head_skb; - - /* Add in any frags from rmnet_perf */ - list_for_each_entry_safe(sub_frag, tmp, &frag_desc->sub_frags, list) { - skb_frag_t *frag; - u32 frag_size; - - frag = &sub_frag->frag; - frag_size = skb_frag_size(frag); - -add_frag: - if (shinfo->nr_frags < MAX_SKB_FRAGS) { - get_page(skb_frag_page(frag)); - skb_add_rx_frag(current_skb, shinfo->nr_frags, - skb_frag_page(frag), frag->page_offset, - frag_size, frag_size); - if (current_skb != head_skb) { - head_skb->len += frag_size; - head_skb->data_len += frag_size; - } - } else { - /* Alloc a new skb and try again */ - skb = alloc_skb(0, GFP_ATOMIC); - if (!skb) - break; - - if (current_skb == head_skb) - shinfo->frag_list = skb; - else - current_skb->next = skb; - - current_skb = skb; - shinfo = skb_shinfo(current_skb); - goto add_frag; - } - - rmnet_recycle_frag_descriptor(sub_frag, port); - } - -skip_frags: - head_skb->dev = frag_desc->dev; - rmnet_set_skb_proto(head_skb); - - /* Handle any header metadata that needs to be updated after RSB/RSC - * segmentation - */ - if (frag_desc->ip_id_set) { - struct iphdr *iph; - - iph = (struct iphdr *)rmnet_map_data_ptr(head_skb); - csum_replace2(&iph->check, iph->id, frag_desc->ip_id); - iph->id = frag_desc->ip_id; - } - - if (frag_desc->tcp_seq_set) { - struct tcphdr *th; - - th = (struct tcphdr *) - (rmnet_map_data_ptr(head_skb) + frag_desc->ip_len); - th->seq = frag_desc->tcp_seq; - } - - /* Handle csum offloading */ - if (frag_desc->csum_valid && frag_desc->hdrs_valid) { - /* Set the partial checksum information */ - //rmnet_frag_partial_csum(head_skb, frag_desc); - WARN_ON(1); - } else if (frag_desc->csum_valid) { - /* Non-RSB/RSC/perf packet. The current checksum is fine */ - head_skb->ip_summed = CHECKSUM_UNNECESSARY; - } else if (frag_desc->hdrs_valid && - (frag_desc->trans_proto == IPPROTO_TCP || - frag_desc->trans_proto == IPPROTO_UDP)) { - /* Unfortunately, we have to fake a bad checksum here, since - * the original bad value is lost by the hardware. The only - * reliable way to do it is to calculate the actual checksum - * and corrupt it. - */ - __sum16 *check; - __wsum csum; - unsigned int offset = skb_transport_offset(head_skb); - __sum16 pseudo; - - WARN_ON(1); - /* Calculate pseudo header and update header fields */ - if (frag_desc->ip_proto == 4) { - struct iphdr *iph = ip_hdr(head_skb); - __be16 tot_len = htons(head_skb->len); - - csum_replace2(&iph->check, iph->tot_len, tot_len); - iph->tot_len = tot_len; - pseudo = ~csum_tcpudp_magic(iph->saddr, iph->daddr, - head_skb->len - - frag_desc->ip_len, - frag_desc->trans_proto, 0); - } else { - struct ipv6hdr *ip6h = ipv6_hdr(head_skb); - - ip6h->payload_len = htons(head_skb->len - - sizeof(*ip6h)); - pseudo = ~csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr, - head_skb->len - - frag_desc->ip_len, - frag_desc->trans_proto, 0); - } - - if (frag_desc->trans_proto == IPPROTO_TCP) { - check = &tcp_hdr(head_skb)->check; - } else { - udp_hdr(head_skb)->len = htons(head_skb->len - - frag_desc->ip_len); - check = &udp_hdr(head_skb)->check; - } - - *check = pseudo; - csum = skb_checksum(head_skb, offset, head_skb->len - offset, - 0); - /* Add 1 to corrupt. This cannot produce a final value of 0 - * since csum_fold() can't return a value of 0xFFFF - */ - *check = csum16_add(csum_fold(csum), htons(1)); - head_skb->ip_summed = CHECKSUM_NONE; - } - - /* Handle any rmnet_perf metadata */ - if (frag_desc->hash) { - head_skb->hash = frag_desc->hash; - head_skb->sw_hash = 1; - } - - if (frag_desc->flush_shs) - head_skb->cb[0] = 1; - - /* Handle coalesced packets */ - //if (frag_desc->gso_segs > 1) - // rmnet_frag_gso_stamp(head_skb, frag_desc); - - return head_skb; -} - -/* Deliver the packets contained within a frag descriptor */ -static void rmnet_frag_deliver(struct rmnet_frag_descriptor *frag_desc, - struct rmnet_port *port) -{ - struct sk_buff *skb; - - skb = rmnet_alloc_skb(frag_desc, port); - if (skb) - rmnet_deliver_skb(skb, port); - rmnet_recycle_frag_descriptor(frag_desc, port); -} - -/* Process a QMAPv5 packet header */ -static int rmnet_frag_process_next_hdr_packet(struct rmnet_frag_descriptor *frag_desc, - struct rmnet_port *port, - struct list_head *list, - u16 len) -{ - int rc = 0; - - switch (rmnet_frag_get_next_hdr_type(frag_desc)) { - case RMNET_MAP_HEADER_TYPE_COALESCING: - rc = -1; - WARN_ON(1); - break; - case RMNET_MAP_HEADER_TYPE_CSUM_OFFLOAD: - if (rmnet_frag_get_csum_valid(frag_desc)) { - frag_desc->csum_valid = true; - } else { - } - - if (!rmnet_frag_pull(frag_desc, port, - sizeof(struct rmnet_map_header) + - sizeof(struct rmnet_map_v5_csum_header))) { - rc = -EINVAL; - break; - } - - frag_desc->hdr_ptr = rmnet_frag_data_ptr(frag_desc); - - /* Remove padding only for csum offload packets. - * Coalesced packets should never have padding. - */ - if (!rmnet_frag_trim(frag_desc, port, len)) { - rc = -EINVAL; - break; - } - - list_del_init(&frag_desc->list); - list_add_tail(&frag_desc->list, list); - break; - default: - //qmap_hex_dump(__func__, rmnet_frag_data_ptr(frag_desc), 64); - rc = -EINVAL; - break; - } - - return rc; -} - -static void -__rmnet_frag_ingress_handler(struct rmnet_frag_descriptor *frag_desc, - struct rmnet_port *port) -{ - struct rmnet_map_header *qmap; - struct rmnet_endpoint *ep; - struct rmnet_frag_descriptor *frag, *tmp; - LIST_HEAD(segs); - u16 len, pad; - u8 mux_id; - - qmap = (struct rmnet_map_header *)skb_frag_address(&frag_desc->frag); - mux_id = qmap->mux_id; - pad = qmap->pad_len; - len = ntohs(qmap->pkt_len) - pad; - - if (qmap->cd_bit) { - if (port->data_format & RMNET_INGRESS_FORMAT_DL_MARKER) { - //rmnet_frag_flow_command(qmap, port, len); - goto recycle; - } - - if (port->data_format & RMNET_FLAGS_INGRESS_MAP_COMMANDS) - rmnet_frag_command(qmap, port); - - goto recycle; - } - - if (mux_id >= RMNET_MAX_LOGICAL_EP) - goto recycle; - - ep = rmnet_get_endpoint(port, mux_id); - if (!ep) - goto recycle; - - frag_desc->dev = ep->egress_dev; - - /* Handle QMAPv5 packet */ - if (qmap->next_hdr && - (port->data_format & (RMNET_FLAGS_INGRESS_COALESCE | - RMNET_FLAGS_INGRESS_MAP_CKSUMV5))) { - if (rmnet_frag_process_next_hdr_packet(frag_desc, port, &segs, - len)) - goto recycle; - } else { - /* We only have the main QMAP header to worry about */ - if (!rmnet_frag_pull(frag_desc, port, sizeof(*qmap))) - return; - - frag_desc->hdr_ptr = rmnet_frag_data_ptr(frag_desc); - - if (!rmnet_frag_trim(frag_desc, port, len)) - return; - - list_add_tail(&frag_desc->list, &segs); - } - - list_for_each_entry_safe(frag, tmp, &segs, list) { - list_del_init(&frag->list); - rmnet_frag_deliver(frag, port); - } - return; - -recycle: - rmnet_recycle_frag_descriptor(frag_desc, port); -} - -static void rmnet_frag_ingress_handler(struct sk_buff *skb, - struct rmnet_port *port) -{ - LIST_HEAD(desc_list); - int i = 0; - struct rmnet_nss_cb *nss_cb; - - /* Deaggregation and freeing of HW originating - * buffers is done within here - */ - while (skb) { - struct sk_buff *skb_frag; - - port->chain_head = NULL; - port->chain_tail = NULL; - - for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { - rmnet_frag_deaggregate(&skb_shinfo(skb)->frags[i], port, - &desc_list); - if (!list_empty(&desc_list)) { - struct rmnet_frag_descriptor *frag_desc, *tmp; - - list_for_each_entry_safe(frag_desc, tmp, - &desc_list, list) { - list_del_init(&frag_desc->list); - __rmnet_frag_ingress_handler(frag_desc, - port); - } - } - } - - nss_cb = rcu_dereference(rmnet_nss_callbacks); - if (nss_cb && port->chain_head) { - port->chain_head->cb[0] = 0; - netif_receive_skb(port->chain_head); - } - - skb_frag = skb_shinfo(skb)->frag_list; - skb_shinfo(skb)->frag_list = NULL; - consume_skb(skb); - skb = skb_frag; - } -} - -void rmnet_descriptor_deinit(struct rmnet_port *port) -{ - struct rmnet_frag_descriptor_pool *pool; - struct rmnet_frag_descriptor *frag_desc, *tmp; - - pool = port->frag_desc_pool; - - list_for_each_entry_safe(frag_desc, tmp, &pool->free_list, list) { - kfree(frag_desc); - pool->pool_size--; - } - - kfree(pool); -} - -int rmnet_descriptor_init(struct rmnet_port *port) -{ - struct rmnet_frag_descriptor_pool *pool; - int i; - - spin_lock_init(&port->desc_pool_lock); - pool = kzalloc(sizeof(*pool), GFP_ATOMIC); - if (!pool) - return -ENOMEM; - - INIT_LIST_HEAD(&pool->free_list); - port->frag_desc_pool = pool; - - for (i = 0; i < RMNET_FRAG_DESCRIPTOR_POOL_SIZE; i++) { - struct rmnet_frag_descriptor *frag_desc; - - frag_desc = kzalloc(sizeof(*frag_desc), GFP_ATOMIC); - if (!frag_desc) - return -ENOMEM; - - INIT_LIST_HEAD(&frag_desc->list); - INIT_LIST_HEAD(&frag_desc->sub_frags); - list_add_tail(&frag_desc->list, &pool->free_list); - pool->pool_size++; - } - - return 0; -} diff --git a/quectel_MHI/src/devices/rmnet/rmnet_descriptor.h b/quectel_MHI/src/devices/rmnet/rmnet_descriptor.h deleted file mode 100644 index 962c663..0000000 --- a/quectel_MHI/src/devices/rmnet/rmnet_descriptor.h +++ /dev/null @@ -1,146 +0,0 @@ -/* Copyright (c) 2013-2019, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * RMNET Packet Descriptor Framework - * - */ - -#ifndef _RMNET_DESCRIPTOR_H_ -#define _RMNET_DESCRIPTOR_H_ - -#include -#include -#include -#include "rmnet_config.h" -#include "rmnet_map.h" - -struct rmnet_frag_descriptor_pool { - struct list_head free_list; - u32 pool_size; -}; - -struct rmnet_frag_descriptor { - struct list_head list; - struct list_head sub_frags; - skb_frag_t frag; - u8 *hdr_ptr; - struct net_device *dev; - u32 hash; - __be32 tcp_seq; - __be16 ip_id; - u16 data_offset; - u16 gso_size; - u16 gso_segs; - u16 ip_len; - u16 trans_len; - u8 ip_proto; - u8 trans_proto; - u8 pkt_id; - u8 csum_valid:1, - hdrs_valid:1, - ip_id_set:1, - tcp_seq_set:1, - flush_shs:1, - reserved:3; -}; - -/* Descriptor management */ -static struct rmnet_frag_descriptor * -rmnet_get_frag_descriptor(struct rmnet_port *port); -static void rmnet_recycle_frag_descriptor(struct rmnet_frag_descriptor *frag_desc, - struct rmnet_port *port); -static void rmnet_descriptor_add_frag(struct rmnet_port *port, struct list_head *list, - struct page *p, u32 page_offset, u32 len); - -/* QMAP command packets */ - -/* Ingress data handlers */ -static void rmnet_frag_deaggregate(skb_frag_t *frag, struct rmnet_port *port, - struct list_head *list); -static void rmnet_frag_deliver(struct rmnet_frag_descriptor *frag_desc, - struct rmnet_port *port); -static int rmnet_frag_process_next_hdr_packet(struct rmnet_frag_descriptor *frag_desc, - struct rmnet_port *port, - struct list_head *list, - u16 len); -static void rmnet_frag_ingress_handler(struct sk_buff *skb, - struct rmnet_port *port); - -static int rmnet_descriptor_init(struct rmnet_port *port); -static void rmnet_descriptor_deinit(struct rmnet_port *port); - -static inline void *rmnet_frag_data_ptr(struct rmnet_frag_descriptor *frag_desc) -{ - return skb_frag_address(&frag_desc->frag); -} - -static inline void *rmnet_frag_pull(struct rmnet_frag_descriptor *frag_desc, - struct rmnet_port *port, - unsigned int size) -{ - if (size >= skb_frag_size(&frag_desc->frag)) { - pr_info("%s(): Pulling %u bytes from %u byte pkt. Dropping\n", - __func__, size, skb_frag_size(&frag_desc->frag)); - rmnet_recycle_frag_descriptor(frag_desc, port); - return NULL; - } - - frag_desc->frag.page_offset += size; - skb_frag_size_sub(&frag_desc->frag, size); - - return rmnet_frag_data_ptr(frag_desc); -} - -static inline void *rmnet_frag_trim(struct rmnet_frag_descriptor *frag_desc, - struct rmnet_port *port, - unsigned int size) -{ - if (!size) { - pr_info("%s(): Trimming %u byte pkt to 0. Dropping\n", - __func__, skb_frag_size(&frag_desc->frag)); - rmnet_recycle_frag_descriptor(frag_desc, port); - return NULL; - } - - if (size < skb_frag_size(&frag_desc->frag)) - skb_frag_size_set(&frag_desc->frag, size); - - return rmnet_frag_data_ptr(frag_desc); -} - -static inline void rmnet_frag_fill(struct rmnet_frag_descriptor *frag_desc, - struct page *p, u32 page_offset, u32 len) -{ - get_page(p); - __skb_frag_set_page(&frag_desc->frag, p); - skb_frag_size_set(&frag_desc->frag, len); - frag_desc->frag.page_offset = page_offset; -} - -static inline u8 -rmnet_frag_get_next_hdr_type(struct rmnet_frag_descriptor *frag_desc) -{ - unsigned char *data = rmnet_frag_data_ptr(frag_desc); - - data += sizeof(struct rmnet_map_header); - return ((struct rmnet_map_v5_coal_header *)data)->header_type; -} - -static inline bool -rmnet_frag_get_csum_valid(struct rmnet_frag_descriptor *frag_desc) -{ - unsigned char *data = rmnet_frag_data_ptr(frag_desc); - - data += sizeof(struct rmnet_map_header); - return ((struct rmnet_map_v5_csum_header *)data)->csum_valid_required; -} - -#endif /* _RMNET_DESCRIPTOR_H_ */ diff --git a/quectel_MHI/src/devices/rmnet/rmnet_handlers.c b/quectel_MHI/src/devices/rmnet/rmnet_handlers.c deleted file mode 100644 index 6f1ce9d..0000000 --- a/quectel_MHI/src/devices/rmnet/rmnet_handlers.c +++ /dev/null @@ -1,374 +0,0 @@ -/* Copyright (c) 2013-2019, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * RMNET Data ingress/egress handler - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include "rmnet_private.h" -#include "rmnet_config.h" -#include "rmnet_vnd.h" -#include "rmnet_map.h" -#include "rmnet_handlers.h" -#include "rmnet_descriptor.h" - -#define RMNET_IP_VERSION_4 0x40 -#define RMNET_IP_VERSION_6 0x60 - -/* Helper Functions */ - -static void rmnet_set_skb_proto(struct sk_buff *skb) -{ - switch (rmnet_map_data_ptr(skb)[0] & 0xF0) { - case RMNET_IP_VERSION_4: - skb->protocol = htons(ETH_P_IP); - break; - case RMNET_IP_VERSION_6: - skb->protocol = htons(ETH_P_IPV6); - break; - default: - skb->protocol = htons(ETH_P_MAP); - break; - } -} - -/* Generic handler */ - -static void -rmnet_deliver_skb(struct sk_buff *skb, struct rmnet_port *port) -{ - struct rmnet_nss_cb *nss_cb; - - rmnet_vnd_rx_fixup(skb->dev, skb->len); - - /* Pass off the packet to NSS driver if we can */ - nss_cb = rcu_dereference(rmnet_nss_callbacks); - if (nss_cb) { - if (!port->chain_head) - port->chain_head = skb; - else - skb_shinfo(port->chain_tail)->frag_list = skb; - - port->chain_tail = skb; - return; - } - - skb_reset_transport_header(skb); - skb_reset_network_header(skb); - - skb->pkt_type = PACKET_HOST; - skb_set_mac_header(skb, 0); - - //if (port->data_format & RMNET_INGRESS_FORMAT_DL_MARKER) { - //} else { - //if (!rmnet_check_skb_can_gro(skb)) - // gro_cells_receive(&priv->gro_cells, skb); - //else - netif_receive_skb(skb); - //} -} - -/* Deliver a list of skbs after undoing coalescing */ -static void rmnet_deliver_skb_list(struct sk_buff_head *head, - struct rmnet_port *port) -{ - struct sk_buff *skb; - - while ((skb = __skb_dequeue(head))) { - rmnet_set_skb_proto(skb); - rmnet_deliver_skb(skb, port); - } -} - -/* MAP handler */ - -static void -_rmnet_map_ingress_handler(struct sk_buff *skb, - struct rmnet_port *port) -{ - struct rmnet_map_header *qmap; - struct rmnet_endpoint *ep; - struct sk_buff_head list; - u16 len, pad; - u8 mux_id; - - /* We don't need the spinlock since only we touch this */ - __skb_queue_head_init(&list); - - qmap = (struct rmnet_map_header *)rmnet_map_data_ptr(skb); - if (qmap->cd_bit) { - if (port->data_format & RMNET_INGRESS_FORMAT_DL_MARKER) { - //if (!rmnet_map_flow_command(skb, port, false)) - return; - } - - if (port->data_format & RMNET_FLAGS_INGRESS_MAP_COMMANDS) - return rmnet_map_command(skb, port); - - goto free_skb; - } - - mux_id = qmap->mux_id; - pad = qmap->pad_len; - len = ntohs(qmap->pkt_len) - pad; - - if (mux_id >= RMNET_MAX_LOGICAL_EP) - goto free_skb; - - ep = rmnet_get_endpoint(port, mux_id); - if (!ep) - goto free_skb; - - skb->dev = ep->egress_dev; - - /* Handle QMAPv5 packet */ - if (qmap->next_hdr && - (port->data_format & (RMNET_FLAGS_INGRESS_COALESCE | - RMNET_FLAGS_INGRESS_MAP_CKSUMV5))) { - if (rmnet_map_process_next_hdr_packet(skb, &list, len)) - goto free_skb; - } else { - /* We only have the main QMAP header to worry about */ - pskb_pull(skb, sizeof(*qmap)); - - rmnet_set_skb_proto(skb); - - if (port->data_format & RMNET_FLAGS_INGRESS_MAP_CKSUMV4) { - //if (!rmnet_map_checksum_downlink_packet(skb, len + pad)) - // skb->ip_summed = CHECKSUM_UNNECESSARY; - } - - pskb_trim(skb, len); - - /* Push the single packet onto the list */ - __skb_queue_tail(&list, skb); - } - - rmnet_deliver_skb_list(&list, port); - return; - -free_skb: - kfree_skb(skb); -} - -static void -rmnet_map_ingress_handler(struct sk_buff *skb, - struct rmnet_port *port) -{ - struct sk_buff *skbn; - - if (port->data_format & (RMNET_FLAGS_INGRESS_COALESCE | - RMNET_FLAGS_INGRESS_MAP_CKSUMV5)) { - if (skb_is_nonlinear(skb)) { - rmnet_frag_ingress_handler(skb, port); - return; - } - } - - /* Deaggregation and freeing of HW originating - * buffers is done within here - */ - while (skb) { - struct sk_buff *skb_frag = skb_shinfo(skb)->frag_list; - - skb_shinfo(skb)->frag_list = NULL; - while ((skbn = rmnet_map_deaggregate(skb, port)) != NULL) { - _rmnet_map_ingress_handler(skbn, port); - - if (skbn == skb) - goto next_skb; - } - - consume_skb(skb); -next_skb: - skb = skb_frag; - } -} - -static int rmnet_map_egress_handler(struct sk_buff *skb, - struct rmnet_port *port, u8 mux_id, - struct net_device *orig_dev) -{ - int required_headroom, additional_header_len, csum_type; - struct rmnet_map_header *map_header; - - additional_header_len = 0; - required_headroom = sizeof(struct rmnet_map_header); - csum_type = 0; - - if (port->data_format & RMNET_FLAGS_EGRESS_MAP_CKSUMV4) { - additional_header_len = sizeof(struct rmnet_map_ul_csum_header); - csum_type = RMNET_FLAGS_EGRESS_MAP_CKSUMV4; - } else if (port->data_format & RMNET_FLAGS_EGRESS_MAP_CKSUMV5) { - additional_header_len = sizeof(struct rmnet_map_v5_csum_header); - csum_type = RMNET_FLAGS_EGRESS_MAP_CKSUMV5; - } - - required_headroom += additional_header_len; - - if (skb_headroom(skb) < required_headroom) { - if (pskb_expand_head(skb, required_headroom, 0, GFP_ATOMIC)) - return -ENOMEM; - } - - if (csum_type) - rmnet_map_checksum_uplink_packet(skb, orig_dev, csum_type); - - map_header = rmnet_map_add_map_header(skb, additional_header_len, 0, - port); - if (!map_header) - return -ENOMEM; - - map_header->mux_id = mux_id; - - if (port->data_format & RMNET_EGRESS_FORMAT_AGGREGATION) { - if (rmnet_map_tx_agg_skip(skb, required_headroom)) - goto done; - - rmnet_map_tx_aggregate(skb, port); - return -EINPROGRESS; - } - -done: - skb->protocol = htons(ETH_P_MAP); - return 0; -} - -static void -rmnet_bridge_handler(struct sk_buff *skb, struct net_device *bridge_dev) -{ - if (bridge_dev) { - skb->dev = bridge_dev; - dev_queue_xmit(skb); - } -} - -/* Ingress / Egress Entry Points */ - -/* Processes packet as per ingress data format for receiving device. Logical - * endpoint is determined from packet inspection. Packet is then sent to the - * egress device listed in the logical endpoint configuration. - */ -static rx_handler_result_t rmnet_rx_handler(struct sk_buff **pskb) -{ - struct sk_buff *skb = *pskb; - struct rmnet_port *port; - struct net_device *dev; - - if (!skb) - goto done; - - if (skb->pkt_type == PACKET_LOOPBACK) - return RX_HANDLER_PASS; - - dev = skb->dev; - port = rmnet_get_port(dev); - - port->chain_head = NULL; - port->chain_tail = NULL; - - switch (port->rmnet_mode) { - case RMNET_EPMODE_VND: - rmnet_map_ingress_handler(skb, port); - break; - case RMNET_EPMODE_BRIDGE: - rmnet_bridge_handler(skb, port->bridge_ep); - break; - } - -done: - return RX_HANDLER_CONSUMED; -} - -static rx_handler_result_t rmnet_rx_priv_handler(struct sk_buff **pskb) -{ - struct sk_buff *skb = *pskb; - struct rmnet_nss_cb *nss_cb; - - if (!skb) - return RX_HANDLER_CONSUMED; - if (nss_debug) printk("%s skb=%p, len=%d, protocol=%x, hdr_len=%d\n", __func__, skb, skb->len, skb->protocol, skb->hdr_len); - - if (skb->pkt_type == PACKET_LOOPBACK) - return RX_HANDLER_PASS; - - /* Check this so that we dont loop around netif_receive_skb */ - if (skb->cb[0] == 1) { - skb->cb[0] = 0; - - skb->dev->stats.rx_packets++; - return RX_HANDLER_PASS; - } - - while (skb) { - struct sk_buff *skb_frag = skb_shinfo(skb)->frag_list; - - skb_shinfo(skb)->frag_list = NULL; - - nss_cb = rcu_dereference(rmnet_nss_callbacks); - if (nss_cb) - nss_cb->nss_tx(skb); - - skb = skb_frag; - } - - return RX_HANDLER_CONSUMED; -} - -/* Modifies packet as per logical endpoint configuration and egress data format - * for egress device configured in logical endpoint. Packet is then transmitted - * on the egress device. - */ -static void rmnet_egress_handler(struct sk_buff *skb) -{ - struct net_device *orig_dev; - struct rmnet_port *port; - struct rmnet_priv *priv; - u8 mux_id; - int err; - u32 skb_len; - - skb_orphan(skb); - - orig_dev = skb->dev; - priv = netdev_priv(orig_dev); - skb->dev = priv->real_dev; - mux_id = priv->mux_id; - - port = rmnet_get_port(skb->dev); - if (!port) - goto drop; - - skb_len = skb->len; - err = rmnet_map_egress_handler(skb, port, mux_id, orig_dev); - if (err == -ENOMEM) - goto drop; - else if (err == -EINPROGRESS) { - rmnet_vnd_tx_fixup(orig_dev, skb_len); - return; - } - - rmnet_vnd_tx_fixup(orig_dev, skb_len); - - dev_queue_xmit(skb); - return; - -drop: - this_cpu_inc(priv->pcpu_stats->stats.tx_drops); - kfree_skb(skb); -} diff --git a/quectel_MHI/src/devices/rmnet/rmnet_handlers.h b/quectel_MHI/src/devices/rmnet/rmnet_handlers.h deleted file mode 100644 index 29837ba..0000000 --- a/quectel_MHI/src/devices/rmnet/rmnet_handlers.h +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright (c) 2013, 2016-2017, 2019 - * The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * RMNET Data ingress/egress handler - * - */ - -#ifndef _RMNET_HANDLERS_H_ -#define _RMNET_HANDLERS_H_ - -#include "rmnet_config.h" - -enum rmnet_packet_context { - RMNET_NET_RX_CTX, - RMNET_WQ_CTX, -}; - -static void rmnet_egress_handler(struct sk_buff *skb); -static void rmnet_deliver_skb(struct sk_buff *skb, struct rmnet_port *port); -static void rmnet_set_skb_proto(struct sk_buff *skb); -static rx_handler_result_t rmnet_rx_handler(struct sk_buff **pskb); -static rx_handler_result_t rmnet_rx_priv_handler(struct sk_buff **pskb); -#endif /* _RMNET_HANDLERS_H_ */ diff --git a/quectel_MHI/src/devices/rmnet/rmnet_map.h b/quectel_MHI/src/devices/rmnet/rmnet_map.h deleted file mode 100644 index ab49149..0000000 --- a/quectel_MHI/src/devices/rmnet/rmnet_map.h +++ /dev/null @@ -1,272 +0,0 @@ -/* Copyright (c) 2013-2019, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef _RMNET_MAP_H_ -#define _RMNET_MAP_H_ - -#include -#include "rmnet_config.h" - -struct rmnet_map_control_command { - u8 command_name; - u8 cmd_type:2; - u8 reserved:6; - u16 reserved2; - u32 transaction_id; - union { - struct { - u16 ip_family:2; - u16 reserved:14; - __be16 flow_control_seq_num; - __be32 qos_id; - } flow_control; - u8 data[0]; - }; -} __aligned(1); - -enum rmnet_map_commands { - RMNET_MAP_COMMAND_NONE, - RMNET_MAP_COMMAND_FLOW_DISABLE, - RMNET_MAP_COMMAND_FLOW_ENABLE, - RMNET_MAP_COMMAND_FLOW_START = 7, - RMNET_MAP_COMMAND_FLOW_END = 8, - /* These should always be the last 2 elements */ - RMNET_MAP_COMMAND_UNKNOWN, - RMNET_MAP_COMMAND_ENUM_LENGTH -}; - -enum rmnet_map_v5_header_type { - RMNET_MAP_HEADER_TYPE_UNKNOWN, - RMNET_MAP_HEADER_TYPE_COALESCING = 0x1, - RMNET_MAP_HEADER_TYPE_CSUM_OFFLOAD = 0x2, - RMNET_MAP_HEADER_TYPE_ENUM_LENGTH -}; - -enum rmnet_map_v5_close_type { - RMNET_MAP_COAL_CLOSE_NON_COAL, - RMNET_MAP_COAL_CLOSE_IP_MISS, - RMNET_MAP_COAL_CLOSE_TRANS_MISS, - RMNET_MAP_COAL_CLOSE_HW, - RMNET_MAP_COAL_CLOSE_COAL, -}; - -enum rmnet_map_v5_close_value { - RMNET_MAP_COAL_CLOSE_HW_NL, - RMNET_MAP_COAL_CLOSE_HW_PKT, - RMNET_MAP_COAL_CLOSE_HW_BYTE, - RMNET_MAP_COAL_CLOSE_HW_TIME, - RMNET_MAP_COAL_CLOSE_HW_EVICT, -}; - -/* Main QMAP header */ -struct rmnet_map_header { - u8 pad_len:6; - u8 next_hdr:1; - u8 cd_bit:1; - u8 mux_id; - __be16 pkt_len; -} __aligned(1); - -/* QMAP v5 headers */ -struct rmnet_map_v5_csum_header { - u8 next_hdr:1; - u8 header_type:7; - u8 hw_reserved:7; - u8 csum_valid_required:1; - __be16 reserved; -} __aligned(1); - -struct rmnet_map_v5_nl_pair { - __be16 pkt_len; - u8 csum_error_bitmap; - u8 num_packets; -} __aligned(1); - -/* NLO: Number-length object */ -#define RMNET_MAP_V5_MAX_NLOS (6) -#define RMNET_MAP_V5_MAX_PACKETS (48) - -struct rmnet_map_v5_coal_header { - u8 next_hdr:1; - u8 header_type:7; - u8 reserved1:4; - u8 num_nlos:3; - u8 csum_valid:1; - u8 close_type:4; - u8 close_value:4; - u8 reserved2:4; - u8 virtual_channel_id:4; - - struct rmnet_map_v5_nl_pair nl_pairs[RMNET_MAP_V5_MAX_NLOS]; -} __aligned(1); - -/* QMAP v4 headers */ -struct rmnet_map_dl_csum_trailer { - u8 reserved1; - u8 valid:1; - u8 reserved2:7; - u16 csum_start_offset; - u16 csum_length; - __be16 csum_value; -} __aligned(1); - -struct rmnet_map_ul_csum_header { - __be16 csum_start_offset; - u16 csum_insert_offset:14; - u16 udp_ind:1; - u16 csum_enabled:1; -} __aligned(1); - -struct rmnet_map_control_command_header { - u8 command_name; - u8 cmd_type:2; - u8 reserved:5; - u8 e:1; - u16 source_id:15; - u16 ext:1; - u32 transaction_id; -} __aligned(1); - -struct rmnet_map_flow_info_le { - __be32 mux_id; - __be32 flow_id; - __be32 bytes; - __be32 pkts; -} __aligned(1); - -struct rmnet_map_flow_info_be { - u32 mux_id; - u32 flow_id; - u32 bytes; - u32 pkts; -} __aligned(1); - -struct rmnet_map_dl_ind_hdr { - union { - struct { - u32 seq; - u32 bytes; - u32 pkts; - u32 flows; - struct rmnet_map_flow_info_le flow[0]; - } le __aligned(1); - struct { - __be32 seq; - __be32 bytes; - __be32 pkts; - __be32 flows; - struct rmnet_map_flow_info_be flow[0]; - } be __aligned(1); - } __aligned(1); -} __aligned(1); - -struct rmnet_map_dl_ind_trl { - union { - __be32 seq_be; - u32 seq_le; - } __aligned(1); -} __aligned(1); - -struct rmnet_map_dl_ind { - u8 priority; - union { - void (*dl_hdr_handler)(struct rmnet_map_dl_ind_hdr *); - void (*dl_hdr_handler_v2)(struct rmnet_map_dl_ind_hdr *, - struct - rmnet_map_control_command_header *); - } __aligned(1); - union { - void (*dl_trl_handler)(struct rmnet_map_dl_ind_trl *); - void (*dl_trl_handler_v2)(struct rmnet_map_dl_ind_trl *, - struct - rmnet_map_control_command_header *); - } __aligned(1); - struct list_head list; -}; - -#define RMNET_MAP_GET_MUX_ID(Y) (((struct rmnet_map_header *) \ - (Y)->data)->mux_id) -#define RMNET_MAP_GET_CD_BIT(Y) (((struct rmnet_map_header *) \ - (Y)->data)->cd_bit) -#define RMNET_MAP_GET_PAD(Y) (((struct rmnet_map_header *) \ - (Y)->data)->pad_len) -#define RMNET_MAP_GET_CMD_START(Y) ((struct rmnet_map_control_command *) \ - ((Y)->data + \ - sizeof(struct rmnet_map_header))) -#define RMNET_MAP_GET_LENGTH(Y) (ntohs(((struct rmnet_map_header *) \ - (Y)->data)->pkt_len)) - -#define RMNET_MAP_DEAGGR_SPACING 64 -#define RMNET_MAP_DEAGGR_HEADROOM (RMNET_MAP_DEAGGR_SPACING / 2) -#define RMNET_MAP_DESC_HEADROOM 128 - -#define RMNET_MAP_COMMAND_REQUEST 0 -#define RMNET_MAP_COMMAND_ACK 1 -#define RMNET_MAP_COMMAND_UNSUPPORTED 2 -#define RMNET_MAP_COMMAND_INVALID 3 - -#define RMNET_MAP_NO_PAD_BYTES 0 -#define RMNET_MAP_ADD_PAD_BYTES 1 - -static inline unsigned char *rmnet_map_data_ptr(struct sk_buff *skb) -{ - /* Nonlinear packets we receive are entirely within frag 0 */ - if (skb_is_nonlinear(skb) && skb->len == skb->data_len) - return skb_frag_address(skb_shinfo(skb)->frags); - - return skb->data; -} - -static inline struct rmnet_map_control_command * -rmnet_map_get_cmd_start(struct sk_buff *skb) -{ - unsigned char *data = rmnet_map_data_ptr(skb); - - data += sizeof(struct rmnet_map_header); - return (struct rmnet_map_control_command *)data; -} - -static inline u8 rmnet_map_get_next_hdr_type(struct sk_buff *skb) -{ - unsigned char *data = rmnet_map_data_ptr(skb); - - data += sizeof(struct rmnet_map_header); - return ((struct rmnet_map_v5_coal_header *)data)->header_type; -} - -static inline bool rmnet_map_get_csum_valid(struct sk_buff *skb) -{ - unsigned char *data = rmnet_map_data_ptr(skb); - - data += sizeof(struct rmnet_map_header); - return ((struct rmnet_map_v5_csum_header *)data)->csum_valid_required; -} - -static struct sk_buff *rmnet_map_deaggregate(struct sk_buff *skb, - struct rmnet_port *port); -static struct rmnet_map_header *rmnet_map_add_map_header(struct sk_buff *skb, - int hdrlen, int pad, - struct rmnet_port *port); -static void rmnet_map_command(struct sk_buff *skb, struct rmnet_port *port); -static void rmnet_map_checksum_uplink_packet(struct sk_buff *skb, - struct net_device *orig_dev, - int csum_type); -static int rmnet_map_process_next_hdr_packet(struct sk_buff *skb, - struct sk_buff_head *list, - u16 len); -static int rmnet_map_tx_agg_skip(struct sk_buff *skb, int offset); -static void rmnet_map_tx_aggregate(struct sk_buff *skb, struct rmnet_port *port); -static void rmnet_map_tx_aggregate_init(struct rmnet_port *port); -static void rmnet_map_tx_aggregate_exit(struct rmnet_port *port); -static void rmnet_map_cmd_init(struct rmnet_port *port); -static void rmnet_map_cmd_exit(struct rmnet_port *port); -#endif /* _RMNET_MAP_H_ */ diff --git a/quectel_MHI/src/devices/rmnet/rmnet_map_command.c b/quectel_MHI/src/devices/rmnet/rmnet_map_command.c deleted file mode 100644 index 6c33184..0000000 --- a/quectel_MHI/src/devices/rmnet/rmnet_map_command.c +++ /dev/null @@ -1,143 +0,0 @@ -/* Copyright (c) 2013-2019, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include -#include "rmnet_config.h" -#include "rmnet_map.h" -#include "rmnet_private.h" -#include "rmnet_vnd.h" - -#define RMNET_DL_IND_HDR_SIZE (sizeof(struct rmnet_map_dl_ind_hdr) + \ - sizeof(struct rmnet_map_header) + \ - sizeof(struct rmnet_map_control_command_header)) - -#define RMNET_MAP_CMD_SIZE (sizeof(struct rmnet_map_header) + \ - sizeof(struct rmnet_map_control_command_header)) - -#define RMNET_DL_IND_TRL_SIZE (sizeof(struct rmnet_map_dl_ind_trl) + \ - sizeof(struct rmnet_map_header) + \ - sizeof(struct rmnet_map_control_command_header)) - -static u8 rmnet_map_do_flow_control(struct sk_buff *skb, - struct rmnet_port *port, - int enable) -{ - struct rmnet_map_header *qmap; - struct rmnet_map_control_command *cmd; - struct rmnet_endpoint *ep; - struct net_device *vnd; - u16 ip_family; - u16 fc_seq; - u32 qos_id; - u8 mux_id; - int r; - - qmap = (struct rmnet_map_header *)rmnet_map_data_ptr(skb); - mux_id = qmap->mux_id; - cmd = rmnet_map_get_cmd_start(skb); - - if (mux_id >= RMNET_MAX_LOGICAL_EP) { - kfree_skb(skb); - return RX_HANDLER_CONSUMED; - } - - ep = rmnet_get_endpoint(port, mux_id); - if (!ep) { - kfree_skb(skb); - return RX_HANDLER_CONSUMED; - } - - vnd = ep->egress_dev; - - ip_family = cmd->flow_control.ip_family; - fc_seq = ntohs(cmd->flow_control.flow_control_seq_num); - qos_id = ntohl(cmd->flow_control.qos_id); - - /* Ignore the ip family and pass the sequence number for both v4 and v6 - * sequence. User space does not support creating dedicated flows for - * the 2 protocols - */ - r = rmnet_vnd_do_flow_control(vnd, enable); - if (r) { - kfree_skb(skb); - return RMNET_MAP_COMMAND_UNSUPPORTED; - } else { - return RMNET_MAP_COMMAND_ACK; - } -} - -static void rmnet_map_send_ack(struct sk_buff *skb, - unsigned char type, - struct rmnet_port *port) -{ - struct rmnet_map_control_command *cmd; - struct net_device *dev = skb->dev; - - if (port->data_format & RMNET_FLAGS_INGRESS_MAP_CKSUMV4) - pskb_trim(skb, - skb->len - sizeof(struct rmnet_map_dl_csum_trailer)); - - skb->protocol = htons(ETH_P_MAP); - - cmd = rmnet_map_get_cmd_start(skb); - cmd->cmd_type = type & 0x03; - - netif_tx_lock(dev); - dev->netdev_ops->ndo_start_xmit(skb, dev); - netif_tx_unlock(dev); -} - -/* Process MAP command frame and send N/ACK message as appropriate. Message cmd - * name is decoded here and appropriate handler is called. - */ -static void rmnet_map_command(struct sk_buff *skb, struct rmnet_port *port) -{ - struct rmnet_map_control_command *cmd; - unsigned char command_name; - unsigned char rc = 0; - - cmd = rmnet_map_get_cmd_start(skb); - command_name = cmd->command_name; - - switch (command_name) { - case RMNET_MAP_COMMAND_FLOW_ENABLE: - rc = rmnet_map_do_flow_control(skb, port, 1); - break; - - case RMNET_MAP_COMMAND_FLOW_DISABLE: - rc = rmnet_map_do_flow_control(skb, port, 0); - break; - - default: - rc = RMNET_MAP_COMMAND_UNSUPPORTED; - kfree_skb(skb); - break; - } - if (rc == RMNET_MAP_COMMAND_ACK) - rmnet_map_send_ack(skb, rc, port); -} - - -static void rmnet_map_cmd_exit(struct rmnet_port *port) -{ - struct rmnet_map_dl_ind *tmp, *idx; - - list_for_each_entry_safe(tmp, idx, &port->dl_list, list) - list_del_rcu(&tmp->list); -} - -static void rmnet_map_cmd_init(struct rmnet_port *port) -{ - INIT_LIST_HEAD(&port->dl_list); - - port->dl_marker_flush = -1; -} diff --git a/quectel_MHI/src/devices/rmnet/rmnet_map_data.c b/quectel_MHI/src/devices/rmnet/rmnet_map_data.c deleted file mode 100644 index 783412c..0000000 --- a/quectel_MHI/src/devices/rmnet/rmnet_map_data.c +++ /dev/null @@ -1,682 +0,0 @@ -/* Copyright (c) 2013-2019, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * RMNET Data MAP protocol - * - */ - -#include -#include -#include -#include -#include "rmnet_config.h" -#include "rmnet_map.h" -#include "rmnet_private.h" -#include "rmnet_handlers.h" - -#define RMNET_MAP_PKT_COPY_THRESHOLD 64 -#define RMNET_MAP_DEAGGR_SPACING 64 -#define RMNET_MAP_DEAGGR_HEADROOM (RMNET_MAP_DEAGGR_SPACING / 2) - -struct rmnet_map_coal_metadata { - void *ip_header; - void *trans_header; - u16 ip_len; - u16 trans_len; - u16 data_offset; - u16 data_len; - u8 ip_proto; - u8 trans_proto; - u8 pkt_id; - u8 pkt_count; -}; - -static __sum16 *rmnet_map_get_csum_field(unsigned char protocol, - const void *txporthdr) -{ - __sum16 *check = NULL; - - switch (protocol) { - case IPPROTO_TCP: - check = &(((struct tcphdr *)txporthdr)->check); - break; - - case IPPROTO_UDP: - check = &(((struct udphdr *)txporthdr)->check); - break; - - default: - check = NULL; - break; - } - - return check; -} - -static void rmnet_map_complement_ipv4_txporthdr_csum_field(void *iphdr) -{ - struct iphdr *ip4h = (struct iphdr *)iphdr; - void *txphdr; - u16 *csum; - - txphdr = iphdr + ip4h->ihl * 4; - - if (ip4h->protocol == IPPROTO_TCP || ip4h->protocol == IPPROTO_UDP) { - csum = (u16 *)rmnet_map_get_csum_field(ip4h->protocol, txphdr); - *csum = ~(*csum); - } -} - -static void -rmnet_map_ipv4_ul_csum_header(void *iphdr, - struct rmnet_map_ul_csum_header *ul_header, - struct sk_buff *skb) -{ - struct iphdr *ip4h = (struct iphdr *)iphdr; - __be16 *hdr = (__be16 *)ul_header, offset; - - offset = htons((__force u16)(skb_transport_header(skb) - - (unsigned char *)iphdr)); - ul_header->csum_start_offset = offset; - ul_header->csum_insert_offset = skb->csum_offset; - ul_header->csum_enabled = 1; - if (ip4h->protocol == IPPROTO_UDP) - ul_header->udp_ind = 1; - else - ul_header->udp_ind = 0; - - /* Changing remaining fields to network order */ - hdr++; - *hdr = htons((__force u16)*hdr); - - skb->ip_summed = CHECKSUM_NONE; - - rmnet_map_complement_ipv4_txporthdr_csum_field(iphdr); -} - -#if IS_ENABLED(CONFIG_IPV6) -static void rmnet_map_complement_ipv6_txporthdr_csum_field(void *ip6hdr) -{ - struct ipv6hdr *ip6h = (struct ipv6hdr *)ip6hdr; - void *txphdr; - u16 *csum; - - txphdr = ip6hdr + sizeof(struct ipv6hdr); - - if (ip6h->nexthdr == IPPROTO_TCP || ip6h->nexthdr == IPPROTO_UDP) { - csum = (u16 *)rmnet_map_get_csum_field(ip6h->nexthdr, txphdr); - *csum = ~(*csum); - } -} - -static void -rmnet_map_ipv6_ul_csum_header(void *ip6hdr, - struct rmnet_map_ul_csum_header *ul_header, - struct sk_buff *skb) -{ - struct ipv6hdr *ip6h = (struct ipv6hdr *)ip6hdr; - __be16 *hdr = (__be16 *)ul_header, offset; - - offset = htons((__force u16)(skb_transport_header(skb) - - (unsigned char *)ip6hdr)); - ul_header->csum_start_offset = offset; - ul_header->csum_insert_offset = skb->csum_offset; - ul_header->csum_enabled = 1; - - if (ip6h->nexthdr == IPPROTO_UDP) - ul_header->udp_ind = 1; - else - ul_header->udp_ind = 0; - - /* Changing remaining fields to network order */ - hdr++; - *hdr = htons((__force u16)*hdr); - - skb->ip_summed = CHECKSUM_NONE; - - rmnet_map_complement_ipv6_txporthdr_csum_field(ip6hdr); -} -#endif - -/* Adds MAP header to front of skb->data - * Padding is calculated and set appropriately in MAP header. Mux ID is - * initialized to 0. - */ -static struct rmnet_map_header *rmnet_map_add_map_header(struct sk_buff *skb, - int hdrlen, int pad, - struct rmnet_port *port) -{ - struct rmnet_map_header *map_header; - u32 padding, map_datalen; - u8 *padbytes; - - map_datalen = skb->len - hdrlen; - map_header = (struct rmnet_map_header *) - skb_push(skb, sizeof(struct rmnet_map_header)); - memset(map_header, 0, sizeof(struct rmnet_map_header)); - - /* Set next_hdr bit for csum offload packets */ - if (port->data_format & RMNET_FLAGS_EGRESS_MAP_CKSUMV5) - map_header->next_hdr = 1; - - if (pad == RMNET_MAP_NO_PAD_BYTES) { - map_header->pkt_len = htons(map_datalen); - return map_header; - } - - padding = ALIGN(map_datalen, 4) - map_datalen; - - if (padding == 0) - goto done; - - if (skb_tailroom(skb) < padding) - return NULL; - - padbytes = (u8 *)skb_put(skb, padding); - memset(padbytes, 0, padding); - -done: - map_header->pkt_len = htons(map_datalen + padding); - map_header->pad_len = padding & 0x3F; - - return map_header; -} - -/* Deaggregates a single packet - * A whole new buffer is allocated for each portion of an aggregated frame. - * Caller should keep calling deaggregate() on the source skb until 0 is - * returned, indicating that there are no more packets to deaggregate. Caller - * is responsible for freeing the original skb. - */ -static struct sk_buff *rmnet_map_deaggregate(struct sk_buff *skb, - struct rmnet_port *port) -{ - struct rmnet_map_header *maph; - struct sk_buff *skbn; - unsigned char *data = rmnet_map_data_ptr(skb), *next_hdr = NULL; - u32 packet_len; - - if (skb->len == 0) - return NULL; - - maph = (struct rmnet_map_header *)data; - packet_len = ntohs(maph->pkt_len) + sizeof(struct rmnet_map_header); - - if (port->data_format & RMNET_FLAGS_INGRESS_MAP_CKSUMV4) - packet_len += sizeof(struct rmnet_map_dl_csum_trailer); - else if (port->data_format & RMNET_FLAGS_INGRESS_MAP_CKSUMV5) { - if (!maph->cd_bit) { - packet_len += sizeof(struct rmnet_map_v5_csum_header); - - /* Coalescing headers require MAPv5 */ - next_hdr = data + sizeof(*maph); - } - } - - if (((int)skb->len - (int)packet_len) < 0) - return NULL; - - /* Some hardware can send us empty frames. Catch them */ - if (ntohs(maph->pkt_len) == 0) - return NULL; - - if (next_hdr && - ((struct rmnet_map_v5_coal_header *)next_hdr)->header_type == - RMNET_MAP_HEADER_TYPE_COALESCING) - return skb; - - if (skb_is_nonlinear(skb)) { - skb_frag_t *frag0 = skb_shinfo(skb)->frags; - struct page *page = skb_frag_page(frag0); - - skbn = alloc_skb(RMNET_MAP_DEAGGR_HEADROOM, GFP_ATOMIC); - if (!skbn) - return NULL; - - skb_append_pagefrags(skbn, page, frag0->page_offset, - packet_len); - skbn->data_len += packet_len; - skbn->len += packet_len; - } else { - skbn = alloc_skb(packet_len + RMNET_MAP_DEAGGR_SPACING, - GFP_ATOMIC); - if (!skbn) - return NULL; - - skb_reserve(skbn, RMNET_MAP_DEAGGR_HEADROOM); - skb_put(skbn, packet_len); - memcpy(skbn->data, data, packet_len); - } - - pskb_pull(skb, packet_len); - - return skbn; -} - -static void rmnet_map_v4_checksum_uplink_packet(struct sk_buff *skb, - struct net_device *orig_dev) -{ - struct rmnet_priv *priv = netdev_priv(orig_dev); - struct rmnet_map_ul_csum_header *ul_header; - void *iphdr; - - ul_header = (struct rmnet_map_ul_csum_header *) - skb_push(skb, sizeof(struct rmnet_map_ul_csum_header)); - - if (unlikely(!(orig_dev->features & - (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM)))) - goto sw_csum; - - if (skb->ip_summed == CHECKSUM_PARTIAL) { - iphdr = (char *)ul_header + - sizeof(struct rmnet_map_ul_csum_header); - - if (skb->protocol == htons(ETH_P_IP)) { - rmnet_map_ipv4_ul_csum_header(iphdr, ul_header, skb); - priv->stats.csum_hw++; - return; - } else if (skb->protocol == htons(ETH_P_IPV6)) { -#if IS_ENABLED(CONFIG_IPV6) - rmnet_map_ipv6_ul_csum_header(iphdr, ul_header, skb); - priv->stats.csum_hw++; - return; -#else - priv->stats.csum_err_invalid_ip_version++; - goto sw_csum; -#endif - } else { - priv->stats.csum_err_invalid_ip_version++; - } - } - -sw_csum: - ul_header->csum_start_offset = 0; - ul_header->csum_insert_offset = 0; - ul_header->csum_enabled = 0; - ul_header->udp_ind = 0; - - priv->stats.csum_sw++; -} - -static void rmnet_map_v5_checksum_uplink_packet(struct sk_buff *skb, - struct net_device *orig_dev) -{ - struct rmnet_priv *priv = netdev_priv(orig_dev); - struct rmnet_map_v5_csum_header *ul_header; - - ul_header = (struct rmnet_map_v5_csum_header *) - skb_push(skb, sizeof(*ul_header)); - memset(ul_header, 0, sizeof(*ul_header)); - ul_header->header_type = RMNET_MAP_HEADER_TYPE_CSUM_OFFLOAD; - - if (skb->ip_summed == CHECKSUM_PARTIAL) { - void *iph = (char *)ul_header + sizeof(*ul_header); - void *trans; - __sum16 *check; - u8 proto; - - if (skb->protocol == htons(ETH_P_IP)) { - u16 ip_len = ((struct iphdr *)iph)->ihl * 4; - - proto = ((struct iphdr *)iph)->protocol; - trans = iph + ip_len; - } else if (skb->protocol == htons(ETH_P_IPV6)) { - u16 ip_len = sizeof(struct ipv6hdr); - - proto = ((struct ipv6hdr *)iph)->nexthdr; - trans = iph + ip_len; - } else { - priv->stats.csum_err_invalid_ip_version++; - goto sw_csum; - } - - check = rmnet_map_get_csum_field(proto, trans); - if (check) { - *check = 0; - skb->ip_summed = CHECKSUM_NONE; - /* Ask for checksum offloading */ - ul_header->csum_valid_required = 1; - priv->stats.csum_hw++; - return; - } - } - -sw_csum: - priv->stats.csum_sw++; -} - - -/* Generates UL checksum meta info header for IPv4 and IPv6 over TCP and UDP - * packets that are supported for UL checksum offload. - */ -void rmnet_map_checksum_uplink_packet(struct sk_buff *skb, - struct net_device *orig_dev, - int csum_type) -{ - switch (csum_type) { - case RMNET_FLAGS_EGRESS_MAP_CKSUMV4: - rmnet_map_v4_checksum_uplink_packet(skb, orig_dev); - break; - case RMNET_FLAGS_EGRESS_MAP_CKSUMV5: - rmnet_map_v5_checksum_uplink_packet(skb, orig_dev); - break; - default: - break; - } -} - -static void rmnet_map_move_headers(struct sk_buff *skb) -{ - struct iphdr *iph; - u16 ip_len; - u16 trans_len = 0; - u8 proto; - - /* This only applies to non-linear SKBs */ - if (!skb_is_nonlinear(skb)) - return; - - iph = (struct iphdr *)rmnet_map_data_ptr(skb); - if (iph->version == 4) { - ip_len = iph->ihl * 4; - proto = iph->protocol; - if (iph->frag_off & htons(IP_OFFSET)) - /* No transport header information */ - goto pull; - } else if (iph->version == 6) { - struct ipv6hdr *ip6h = (struct ipv6hdr *)iph; - __be16 frag_off; - u8 nexthdr = ip6h->nexthdr; - - ip_len = ipv6_skip_exthdr(skb, sizeof(*ip6h), &nexthdr, - &frag_off); - if (ip_len < 0) - return; - - proto = nexthdr; - } else { - return; - } - - if (proto == IPPROTO_TCP) { - struct tcphdr *tp = (struct tcphdr *)((u8 *)iph + ip_len); - - trans_len = tp->doff * 4; - } else if (proto == IPPROTO_UDP) { - trans_len = sizeof(struct udphdr); - } else if (proto == NEXTHDR_FRAGMENT) { - /* Non-first fragments don't have the fragment length added by - * ipv6_skip_exthdr() and sho up as proto NEXTHDR_FRAGMENT, so - * we account for the length here. - */ - ip_len += sizeof(struct frag_hdr); - } - -pull: - __pskb_pull_tail(skb, ip_len + trans_len); - skb_reset_network_header(skb); - if (trans_len) - skb_set_transport_header(skb, ip_len); -} - - -/* Process a QMAPv5 packet header */ -static int rmnet_map_process_next_hdr_packet(struct sk_buff *skb, - struct sk_buff_head *list, - u16 len) -{ - struct rmnet_priv *priv = netdev_priv(skb->dev); - int rc = 0; - - switch (rmnet_map_get_next_hdr_type(skb)) { - case RMNET_MAP_HEADER_TYPE_COALESCING: - priv->stats.coal.coal_rx++; - break; - case RMNET_MAP_HEADER_TYPE_CSUM_OFFLOAD: - if (rmnet_map_get_csum_valid(skb)) { - priv->stats.csum_ok++; - skb->ip_summed = CHECKSUM_UNNECESSARY; - } else { - priv->stats.csum_valid_unset++; - } - - /* Pull unnecessary headers and move the rest to the linear - * section of the skb. - */ - pskb_pull(skb, - (sizeof(struct rmnet_map_header) + - sizeof(struct rmnet_map_v5_csum_header))); - rmnet_map_move_headers(skb); - - /* Remove padding only for csum offload packets. - * Coalesced packets should never have padding. - */ - pskb_trim(skb, len); - __skb_queue_tail(list, skb); - break; - default: - rc = -EINVAL; - break; - } - - return rc; -} - -long rmnet_agg_time_limit __read_mostly = 1000000L; -long rmnet_agg_bypass_time __read_mostly = 10000000L; - -static int rmnet_map_tx_agg_skip(struct sk_buff *skb, int offset) -{ - u8 *packet_start = skb->data + offset; - int is_icmp = 0; - - if (skb->protocol == htons(ETH_P_IP)) { - struct iphdr *ip4h = (struct iphdr *)(packet_start); - - if (ip4h->protocol == IPPROTO_ICMP) - is_icmp = 1; - } else if (skb->protocol == htons(ETH_P_IPV6)) { - struct ipv6hdr *ip6h = (struct ipv6hdr *)(packet_start); - - if (ip6h->nexthdr == IPPROTO_ICMPV6) { - is_icmp = 1; - } else if (ip6h->nexthdr == NEXTHDR_FRAGMENT) { - struct frag_hdr *frag; - - frag = (struct frag_hdr *)(packet_start - + sizeof(struct ipv6hdr)); - if (frag->nexthdr == IPPROTO_ICMPV6) - is_icmp = 1; - } - } - - return is_icmp; -} - -static void rmnet_map_flush_tx_packet_work(struct work_struct *work) -{ - struct sk_buff *skb = NULL; - struct rmnet_port *port; - unsigned long flags; - - port = container_of(work, struct rmnet_port, agg_wq); - - spin_lock_irqsave(&port->agg_lock, flags); - if (likely(port->agg_state == -EINPROGRESS)) { - /* Buffer may have already been shipped out */ - if (likely(port->agg_skb)) { - skb = port->agg_skb; - port->agg_skb = NULL; - port->agg_count = 0; - memset(&port->agg_time, 0, sizeof(struct timespec)); - } - port->agg_state = 0; - } - - spin_unlock_irqrestore(&port->agg_lock, flags); - if (skb) - dev_queue_xmit(skb); -} - -static enum hrtimer_restart rmnet_map_flush_tx_packet_queue(struct hrtimer *t) -{ - struct rmnet_port *port; - - port = container_of(t, struct rmnet_port, hrtimer); - - schedule_work(&port->agg_wq); - return HRTIMER_NORESTART; -} - -static void rmnet_map_linearize_copy(struct sk_buff *dst, struct sk_buff *src) -{ - unsigned int linear = src->len - src->data_len, target = src->len; - unsigned char *src_buf; - struct sk_buff *skb; - - src_buf = src->data; - skb_put_data(dst, src_buf, linear); - target -= linear; - - skb = src; - - while (target) { - unsigned int i = 0, non_linear = 0; - - for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { - non_linear = skb_frag_size(&skb_shinfo(skb)->frags[i]); - src_buf = skb_frag_address(&skb_shinfo(skb)->frags[i]); - - skb_put_data(dst, src_buf, non_linear); - target -= non_linear; - } - - if (skb_shinfo(skb)->frag_list) { - skb = skb_shinfo(skb)->frag_list; - continue; - } - - if (skb->next) - skb = skb->next; - } -} - -static void rmnet_map_tx_aggregate(struct sk_buff *skb, struct rmnet_port *port) -{ - struct timespec diff, last; - int size, agg_count = 0; - struct sk_buff *agg_skb; - unsigned long flags; - -new_packet: - spin_lock_irqsave(&port->agg_lock, flags); - memcpy(&last, &port->agg_last, sizeof(struct timespec)); - getnstimeofday(&port->agg_last); - - if (!port->agg_skb) { - /* Check to see if we should agg first. If the traffic is very - * sparse, don't aggregate. We will need to tune this later - */ - diff = timespec_sub(port->agg_last, last); - size = port->egress_agg_params.agg_size - skb->len; - - if (diff.tv_sec > 0 || diff.tv_nsec > rmnet_agg_bypass_time || - size <= 0) { - spin_unlock_irqrestore(&port->agg_lock, flags); - skb->protocol = htons(ETH_P_MAP); - dev_queue_xmit(skb); - return; - } - - port->agg_skb = alloc_skb(port->egress_agg_params.agg_size, - GFP_ATOMIC); - if (!port->agg_skb) { - port->agg_skb = 0; - port->agg_count = 0; - memset(&port->agg_time, 0, sizeof(struct timespec)); - spin_unlock_irqrestore(&port->agg_lock, flags); - skb->protocol = htons(ETH_P_MAP); - dev_queue_xmit(skb); - return; - } - rmnet_map_linearize_copy(port->agg_skb, skb); - port->agg_skb->dev = skb->dev; - port->agg_skb->protocol = htons(ETH_P_MAP); - port->agg_count = 1; - getnstimeofday(&port->agg_time); - dev_kfree_skb_any(skb); - goto schedule; - } - diff = timespec_sub(port->agg_last, port->agg_time); - size = port->egress_agg_params.agg_size - port->agg_skb->len; - - if (skb->len > size || - port->agg_count >= port->egress_agg_params.agg_count || - diff.tv_sec > 0 || diff.tv_nsec > rmnet_agg_time_limit) { - agg_skb = port->agg_skb; - agg_count = port->agg_count; - port->agg_skb = 0; - port->agg_count = 0; - memset(&port->agg_time, 0, sizeof(struct timespec)); - port->agg_state = 0; - spin_unlock_irqrestore(&port->agg_lock, flags); - hrtimer_cancel(&port->hrtimer); - dev_queue_xmit(agg_skb); - goto new_packet; - } - - rmnet_map_linearize_copy(port->agg_skb, skb); - port->agg_count++; - dev_kfree_skb_any(skb); - -schedule: - if (port->agg_state != -EINPROGRESS) { - port->agg_state = -EINPROGRESS; - hrtimer_start(&port->hrtimer, - ns_to_ktime(port->egress_agg_params.agg_time), - HRTIMER_MODE_REL); - } - spin_unlock_irqrestore(&port->agg_lock, flags); -} - -static void rmnet_map_tx_aggregate_init(struct rmnet_port *port) -{ - hrtimer_init(&port->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); - port->hrtimer.function = rmnet_map_flush_tx_packet_queue; - port->egress_agg_params.agg_size = 8192; - port->egress_agg_params.agg_count = 20; - port->egress_agg_params.agg_time = 3000000; - spin_lock_init(&port->agg_lock); - - INIT_WORK(&port->agg_wq, rmnet_map_flush_tx_packet_work); -} - -static void rmnet_map_tx_aggregate_exit(struct rmnet_port *port) -{ - unsigned long flags; - - hrtimer_cancel(&port->hrtimer); - cancel_work_sync(&port->agg_wq); - - spin_lock_irqsave(&port->agg_lock, flags); - if (port->agg_state == -EINPROGRESS) { - if (port->agg_skb) { - kfree_skb(port->agg_skb); - port->agg_skb = NULL; - port->agg_count = 0; - memset(&port->agg_time, 0, sizeof(struct timespec)); - } - - port->agg_state = 0; - } - - spin_unlock_irqrestore(&port->agg_lock, flags); -} diff --git a/quectel_MHI/src/devices/rmnet/rmnet_private.h b/quectel_MHI/src/devices/rmnet/rmnet_private.h deleted file mode 100644 index d384b7b..0000000 --- a/quectel_MHI/src/devices/rmnet/rmnet_private.h +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright (c) 2013-2014, 2016-2019 The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef _RMNET_PRIVATE_H_ -#define _RMNET_PRIVATE_H_ - -#define RMNET_MAX_PACKET_SIZE 16384 -#define RMNET_DFLT_PACKET_SIZE 1500 -#define RMNET_NEEDED_HEADROOM 16 -#define RMNET_TX_QUEUE_LEN 1000 - -/* Constants */ -#define RMNET_EGRESS_FORMAT_AGGREGATION BIT(31) -#define RMNET_INGRESS_FORMAT_DL_MARKER_V1 BIT(30) -#define RMNET_INGRESS_FORMAT_DL_MARKER_V2 BIT(29) - -#define RMNET_INGRESS_FORMAT_DL_MARKER (RMNET_INGRESS_FORMAT_DL_MARKER_V1 |\ -RMNET_INGRESS_FORMAT_DL_MARKER_V2) - -/* Replace skb->dev to a virtual rmnet device and pass up the stack */ -#define RMNET_EPMODE_VND (1) -/* Pass the frame directly to another device with dev_queue_xmit() */ -#define RMNET_EPMODE_BRIDGE (2) - -#endif /* _RMNET_PRIVATE_H_ */ diff --git a/quectel_MHI/src/devices/rmnet/rmnet_trace.h b/quectel_MHI/src/devices/rmnet/rmnet_trace.h deleted file mode 100644 index d453fc5..0000000 --- a/quectel_MHI/src/devices/rmnet/rmnet_trace.h +++ /dev/null @@ -1,257 +0,0 @@ -/* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#undef TRACE_SYSTEM -#define TRACE_SYSTEM rmnet -#define TRACE_INCLUDE_FILE rmnet_trace - -#if !defined(_RMNET_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ) -#define _RMNET_TRACE_H_ - -#include -#include -#include - -/*****************************************************************************/ -/* Trace events for rmnet module */ -/*****************************************************************************/ -DECLARE_EVENT_CLASS - (rmnet_mod_template, - - TP_PROTO(u8 func, u8 evt, u32 uint1, u32 uint2, - u64 ulong1, u64 ulong2, void *ptr1, void *ptr2), - - TP_ARGS(func, evt, uint1, uint2, ulong1, ulong2, ptr1, ptr2), - - TP_STRUCT__entry( - __field(u8, func) - __field(u8, evt) - __field(u32, uint1) - __field(u32, uint2) - __field(u64, ulong1) - __field(u64, ulong2) - __field(void *, ptr1) - __field(void *, ptr2) - ), - - TP_fast_assign( - __entry->func = func; - __entry->evt = evt; - __entry->uint1 = uint1; - __entry->uint2 = uint2; - __entry->ulong1 = ulong1; - __entry->ulong2 = ulong2; - __entry->ptr1 = ptr1; - __entry->ptr2 = ptr2; - ), - -TP_printk("fun:%u ev:%u u1:%u u2:%u ul1:%llu ul2:%llu p1:0x%pK p2:0x%pK", - __entry->func, __entry->evt, - __entry->uint1, __entry->uint2, - __entry->ulong1, __entry->ulong2, - __entry->ptr1, __entry->ptr2) -) - -DEFINE_EVENT - (rmnet_mod_template, rmnet_low, - - TP_PROTO(u8 func, u8 evt, u32 uint1, u32 uint2, - u64 ulong1, u64 ulong2, void *ptr1, void *ptr2), - - TP_ARGS(func, evt, uint1, uint2, ulong1, ulong2, ptr1, ptr2) - -); - -DEFINE_EVENT - (rmnet_mod_template, rmnet_high, - - TP_PROTO(u8 func, u8 evt, u32 uint1, u32 uint2, - u64 ulong1, u64 ulong2, void *ptr1, void *ptr2), - - TP_ARGS(func, evt, uint1, uint2, ulong1, ulong2, ptr1, ptr2) - -); - -DEFINE_EVENT - (rmnet_mod_template, rmnet_err, - - TP_PROTO(u8 func, u8 evt, u32 uint1, u32 uint2, - u64 ulong1, u64 ulong2, void *ptr1, void *ptr2), - - TP_ARGS(func, evt, uint1, uint2, ulong1, ulong2, ptr1, ptr2) - -); - -/*****************************************************************************/ -/* Trace events for rmnet_perf module */ -/*****************************************************************************/ -DEFINE_EVENT - (rmnet_mod_template, rmnet_perf_low, - - TP_PROTO(u8 func, u8 evt, u32 uint1, u32 uint2, - u64 ulong1, u64 ulong2, void *ptr1, void *ptr2), - - TP_ARGS(func, evt, uint1, uint2, ulong1, ulong2, ptr1, ptr2) - -); - -DEFINE_EVENT - (rmnet_mod_template, rmnet_perf_high, - - TP_PROTO(u8 func, u8 evt, u32 uint1, u32 uint2, - u64 ulong1, u64 ulong2, void *ptr1, void *ptr2), - - TP_ARGS(func, evt, uint1, uint2, ulong1, ulong2, ptr1, ptr2) - -); - -DEFINE_EVENT - (rmnet_mod_template, rmnet_perf_err, - - TP_PROTO(u8 func, u8 evt, u32 uint1, u32 uint2, - u64 ulong1, u64 ulong2, void *ptr1, void *ptr2), - - TP_ARGS(func, evt, uint1, uint2, ulong1, ulong2, ptr1, ptr2) - -); - -/*****************************************************************************/ -/* Trace events for rmnet_shs module */ -/*****************************************************************************/ -DEFINE_EVENT - (rmnet_mod_template, rmnet_shs_low, - - TP_PROTO(u8 func, u8 evt, u32 uint1, u32 uint2, - u64 ulong1, u64 ulong2, void *ptr1, void *ptr2), - - TP_ARGS(func, evt, uint1, uint2, ulong1, ulong2, ptr1, ptr2) - -); - -DEFINE_EVENT - (rmnet_mod_template, rmnet_shs_high, - - TP_PROTO(u8 func, u8 evt, u32 uint1, u32 uint2, - u64 ulong1, u64 ulong2, void *ptr1, void *ptr2), - - TP_ARGS(func, evt, uint1, uint2, ulong1, ulong2, ptr1, ptr2) - -); - -DEFINE_EVENT - (rmnet_mod_template, rmnet_shs_err, - - TP_PROTO(u8 func, u8 evt, u32 uint1, u32 uint2, - u64 ulong1, u64 ulong2, void *ptr1, void *ptr2), - - TP_ARGS(func, evt, uint1, uint2, ulong1, ulong2, ptr1, ptr2) - -); - -DEFINE_EVENT - (rmnet_mod_template, rmnet_shs_wq_low, - - TP_PROTO(u8 func, u8 evt, u32 uint1, u32 uint2, - u64 ulong1, u64 ulong2, void *ptr1, void *ptr2), - - TP_ARGS(func, evt, uint1, uint2, ulong1, ulong2, ptr1, ptr2) - -); - -DEFINE_EVENT - (rmnet_mod_template, rmnet_shs_wq_high, - - TP_PROTO(u8 func, u8 evt, u32 uint1, u32 uint2, - u64 ulong1, u64 ulong2, void *ptr1, void *ptr2), - - TP_ARGS(func, evt, uint1, uint2, ulong1, ulong2, ptr1, ptr2) - -); - -DEFINE_EVENT - (rmnet_mod_template, rmnet_shs_wq_err, - - TP_PROTO(u8 func, u8 evt, u32 uint1, u32 uint2, - u64 ulong1, u64 ulong2, void *ptr1, void *ptr2), - - TP_ARGS(func, evt, uint1, uint2, ulong1, ulong2, ptr1, ptr2) - -); - -DECLARE_EVENT_CLASS - (rmnet_freq_template, - - TP_PROTO(u8 core, u32 newfreq), - - TP_ARGS(core, newfreq), - - TP_STRUCT__entry( - __field(u8, core) - __field(u32, newfreq) - ), - - TP_fast_assign( - __entry->core = core; - __entry->newfreq = newfreq; - - ), - -TP_printk("freq policy core:%u freq floor :%u", - __entry->core, __entry->newfreq) - -); - -DEFINE_EVENT - (rmnet_freq_template, rmnet_freq_boost, - - TP_PROTO(u8 core, u32 newfreq), - - TP_ARGS(core, newfreq) -); - -DEFINE_EVENT - (rmnet_freq_template, rmnet_freq_reset, - - TP_PROTO(u8 core, u32 newfreq), - - TP_ARGS(core, newfreq) -); - -TRACE_EVENT - (rmnet_freq_update, - - TP_PROTO(u8 core, u32 lowfreq, u32 highfreq), - - TP_ARGS(core, lowfreq, highfreq), - - TP_STRUCT__entry( - __field(u8, core) - __field(u32, lowfreq) - __field(u32, highfreq) - ), - - TP_fast_assign( - __entry->core = core; - __entry->lowfreq = lowfreq; - __entry->highfreq = highfreq; - - ), - -TP_printk("freq policy update core:%u policy freq floor :%u freq ceil :%u", - __entry->core, __entry->lowfreq, __entry->highfreq) -); -#endif /* _RMNET_TRACE_H_ */ - -/* This part must be outside protection */ -#undef TRACE_INCLUDE_PATH -#define TRACE_INCLUDE_PATH ../drivers/net/ethernet/qualcomm/rmnet -#include diff --git a/quectel_MHI/src/devices/rmnet/rmnet_vnd.c b/quectel_MHI/src/devices/rmnet/rmnet_vnd.c deleted file mode 100644 index 4ef645d..0000000 --- a/quectel_MHI/src/devices/rmnet/rmnet_vnd.c +++ /dev/null @@ -1,382 +0,0 @@ -/* Copyright (c) 2013-2019, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * - * RMNET Data virtual network driver - * - */ - -#include -#include -#include -#include -#include "rmnet_config.h" -#include "rmnet_handlers.h" -#include "rmnet_private.h" -#include "rmnet_map.h" -#include "rmnet_vnd.h" - -/* RX/TX Fixup */ - -static void rmnet_vnd_rx_fixup(struct net_device *dev, u32 skb_len) -{ - struct rmnet_priv *priv = netdev_priv(dev); - struct rmnet_pcpu_stats *pcpu_ptr; - - pcpu_ptr = this_cpu_ptr(priv->pcpu_stats); - - u64_stats_update_begin(&pcpu_ptr->syncp); - pcpu_ptr->stats.rx_pkts++; - pcpu_ptr->stats.rx_bytes += skb_len; - u64_stats_update_end(&pcpu_ptr->syncp); -} - -static void rmnet_vnd_tx_fixup(struct net_device *dev, u32 skb_len) -{ - struct rmnet_priv *priv = netdev_priv(dev); - struct rmnet_pcpu_stats *pcpu_ptr; - - pcpu_ptr = this_cpu_ptr(priv->pcpu_stats); - - u64_stats_update_begin(&pcpu_ptr->syncp); - pcpu_ptr->stats.tx_pkts++; - pcpu_ptr->stats.tx_bytes += skb_len; - u64_stats_update_end(&pcpu_ptr->syncp); -} - -/* Network Device Operations */ - -static netdev_tx_t rmnet_vnd_start_xmit(struct sk_buff *skb, - struct net_device *dev) -{ - struct rmnet_priv *priv; - - priv = netdev_priv(dev); - if (priv->real_dev) { - rmnet_egress_handler(skb); - } else { - this_cpu_inc(priv->pcpu_stats->stats.tx_drops); - kfree_skb(skb); - } - return NETDEV_TX_OK; -} - -static int rmnet_vnd_change_mtu(struct net_device *rmnet_dev, int new_mtu) -{ - if (new_mtu < 0 || new_mtu > RMNET_MAX_PACKET_SIZE) - return -EINVAL; - - rmnet_dev->mtu = new_mtu; - return 0; -} - -static int rmnet_vnd_get_iflink(const struct net_device *dev) -{ - struct rmnet_priv *priv = netdev_priv(dev); - - return priv->real_dev->ifindex; -} - -static int rmnet_vnd_init(struct net_device *dev) -{ - struct rmnet_priv *priv = netdev_priv(dev); - int err; - - priv->pcpu_stats = alloc_percpu(struct rmnet_pcpu_stats); - if (!priv->pcpu_stats) - return -ENOMEM; - - err = gro_cells_init(&priv->gro_cells, dev); - if (err) { - free_percpu(priv->pcpu_stats); - return err; - } - - return 0; -} - -static void rmnet_vnd_uninit(struct net_device *dev) -{ - struct rmnet_priv *priv = netdev_priv(dev); - - gro_cells_destroy(&priv->gro_cells); - free_percpu(priv->pcpu_stats); -} - -static struct rtnl_link_stats64* rmnet_get_stats64(struct net_device *dev, - struct rtnl_link_stats64 *s) -{ - struct rmnet_priv *priv = netdev_priv(dev); - struct rmnet_vnd_stats total_stats; - struct rmnet_pcpu_stats *pcpu_ptr; - unsigned int cpu, start; - - memset(&total_stats, 0, sizeof(struct rmnet_vnd_stats)); - - for_each_possible_cpu(cpu) { - pcpu_ptr = per_cpu_ptr(priv->pcpu_stats, cpu); - - do { - start = u64_stats_fetch_begin_irq(&pcpu_ptr->syncp); - total_stats.rx_pkts += pcpu_ptr->stats.rx_pkts; - total_stats.rx_bytes += pcpu_ptr->stats.rx_bytes; - total_stats.tx_pkts += pcpu_ptr->stats.tx_pkts; - total_stats.tx_bytes += pcpu_ptr->stats.tx_bytes; - } while (u64_stats_fetch_retry_irq(&pcpu_ptr->syncp, start)); - - total_stats.tx_drops += pcpu_ptr->stats.tx_drops; - } - - s->rx_packets = total_stats.rx_pkts; - s->rx_bytes = total_stats.rx_bytes; - s->tx_packets = total_stats.tx_pkts; - s->tx_bytes = total_stats.tx_bytes; - s->tx_dropped = total_stats.tx_drops; - - return s; -} - -static const struct net_device_ops rmnet_vnd_ops = { - .ndo_start_xmit = rmnet_vnd_start_xmit, - .ndo_change_mtu = rmnet_vnd_change_mtu, - .ndo_get_iflink = rmnet_vnd_get_iflink, - //.ndo_add_slave = rmnet_add_bridge, - //.ndo_del_slave = rmnet_del_bridge, - .ndo_init = rmnet_vnd_init, - .ndo_uninit = rmnet_vnd_uninit, - .ndo_get_stats64 = rmnet_get_stats64, -}; - -static const char rmnet_gstrings_stats[][ETH_GSTRING_LEN] = { - "Checksum ok", - "Checksum valid bit not set", - "Checksum validation failed", - "Checksum error bad buffer", - "Checksum error bad ip version", - "Checksum error bad transport", - "Checksum skipped on ip fragment", - "Checksum skipped", - "Checksum computed in software", - "Checksum computed in hardware", - "Coalescing packets received", - "Coalesced packets", - "Coalescing header NLO errors", - "Coalescing header pcount errors", - "Coalescing checksum errors", - "Coalescing packet reconstructs", - "Coalescing IP version invalid", - "Coalescing L4 header invalid", - "Coalescing close Non-coalescable", - "Coalescing close L3 mismatch", - "Coalescing close L4 mismatch", - "Coalescing close HW NLO limit", - "Coalescing close HW packet limit", - "Coalescing close HW byte limit", - "Coalescing close HW time limit", - "Coalescing close HW eviction", - "Coalescing close Coalescable", - "Coalescing packets over VEID0", - "Coalescing packets over VEID1", - "Coalescing packets over VEID2", - "Coalescing packets over VEID3", -}; - -static const char rmnet_port_gstrings_stats[][ETH_GSTRING_LEN] = { - "MAP Cmd last version", - "MAP Cmd last ep id", - "MAP Cmd last transaction id", - "DL header last seen sequence", - "DL header last seen bytes", - "DL header last seen packets", - "DL header last seen flows", - "DL header pkts received", - "DL header total bytes received", - "DL header total pkts received", - "DL trailer last seen sequence", - "DL trailer pkts received", -}; - -static void rmnet_get_strings(struct net_device *dev, u32 stringset, u8 *buf) -{ - switch (stringset) { - case ETH_SS_STATS: - memcpy(buf, &rmnet_gstrings_stats, - sizeof(rmnet_gstrings_stats)); - memcpy(buf + sizeof(rmnet_gstrings_stats), - &rmnet_port_gstrings_stats, - sizeof(rmnet_port_gstrings_stats)); - break; - } -} - -static int rmnet_get_sset_count(struct net_device *dev, int sset) -{ - switch (sset) { - case ETH_SS_STATS: - return ARRAY_SIZE(rmnet_gstrings_stats) + - ARRAY_SIZE(rmnet_port_gstrings_stats); - default: - return -EOPNOTSUPP; - } -} - -static void rmnet_get_ethtool_stats(struct net_device *dev, - struct ethtool_stats *stats, u64 *data) -{ - struct rmnet_priv *priv = netdev_priv(dev); - struct rmnet_priv_stats *st = &priv->stats; - struct rmnet_port_priv_stats *stp; - struct rmnet_port *port; - - port = rmnet_get_port(priv->real_dev); - - if (!data || !port) - return; - - stp = &port->stats; - - memcpy(data, st, ARRAY_SIZE(rmnet_gstrings_stats) * sizeof(u64)); - memcpy(data + ARRAY_SIZE(rmnet_gstrings_stats), stp, - ARRAY_SIZE(rmnet_port_gstrings_stats) * sizeof(u64)); -} - -static int rmnet_stats_reset(struct net_device *dev) -{ - struct rmnet_priv *priv = netdev_priv(dev); - struct rmnet_port_priv_stats *stp; - struct rmnet_port *port; - - port = rmnet_get_port(priv->real_dev); - if (!port) - return -EINVAL; - - stp = &port->stats; - - memset(stp, 0, sizeof(*stp)); - return 0; -} - -static const struct ethtool_ops rmnet_ethtool_ops = { - .get_ethtool_stats = rmnet_get_ethtool_stats, - .get_strings = rmnet_get_strings, - .get_sset_count = rmnet_get_sset_count, - .nway_reset = rmnet_stats_reset, -}; - -/* Called by kernel whenever a new rmnet device is created. Sets MTU, - * flags, ARP type, needed headroom, etc... - */ -void rmnet_vnd_setup(struct net_device *rmnet_dev) -{ - rmnet_dev->netdev_ops = &rmnet_vnd_ops; - rmnet_dev->mtu = RMNET_DFLT_PACKET_SIZE; - rmnet_dev->needed_headroom = RMNET_NEEDED_HEADROOM; - random_ether_addr(rmnet_dev->dev_addr); - rmnet_dev->tx_queue_len = RMNET_TX_QUEUE_LEN; - - /* Raw IP mode */ - rmnet_dev->header_ops = NULL; /* No header */ - rmnet_dev->type = ARPHRD_RAWIP; - rmnet_dev->hard_header_len = 0; - rmnet_dev->flags &= ~(IFF_BROADCAST | IFF_MULTICAST); - - //rmnet_dev->needs_free_netdev = true; - - rmnet_dev->hw_features = NETIF_F_RXCSUM; - rmnet_dev->hw_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; - //rmnet_dev->hw_features |= NETIF_F_SG; - //rmnet_dev->hw_features |= NETIF_F_GRO_HW; -} - -/* Exposed API */ - -static int rmnet_vnd_newlink(u8 id, struct net_device *rmnet_dev, - struct rmnet_port *port, - struct net_device *real_dev, - struct rmnet_endpoint *ep) -{ - struct rmnet_priv *priv = netdev_priv(rmnet_dev); - struct rmnet_nss_cb *nss_cb; - int rc; - - if (ep->egress_dev) - return -EINVAL; - - if (rmnet_get_endpoint(port, id)) - return -EBUSY; - - rmnet_dev->hw_features = NETIF_F_RXCSUM; - rmnet_dev->hw_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; - rmnet_dev->hw_features |= NETIF_F_SG; - - priv->real_dev = real_dev; - - rc = register_netdevice(rmnet_dev); - if (!rc) { - ep->egress_dev = rmnet_dev; - ep->mux_id = id; - port->nr_rmnet_devs++; - - //rmnet_dev->rtnl_link_ops = &rmnet_link_ops; - - priv->mux_id = id; - - netdev_dbg(rmnet_dev, "rmnet dev created\n"); - } - - nss_cb = rcu_dereference(rmnet_nss_callbacks); - if (nss_cb) { - rc = nss_cb->nss_create(rmnet_dev); - if (rc) { - /* Log, but don't fail the device creation */ - netdev_err(rmnet_dev, "Device will not use NSS path: %d\n", rc); - rc = 0; - } else { - netdev_dbg(rmnet_dev, "NSS context created\n"); - } - } - - return rc; -} - -static int rmnet_vnd_dellink(u8 id, struct rmnet_port *port, - struct rmnet_endpoint *ep) -{ - struct rmnet_nss_cb *nss_cb; - - if (id >= RMNET_MAX_LOGICAL_EP || !ep->egress_dev) - return -EINVAL; - - if (ep->egress_dev) { - nss_cb = rcu_dereference(rmnet_nss_callbacks); - if (nss_cb) - nss_cb->nss_free(ep->egress_dev); - } - ep->egress_dev = NULL; - port->nr_rmnet_devs--; - - return 0; -} - -static int rmnet_vnd_do_flow_control(struct net_device *rmnet_dev, int enable) -{ - netdev_dbg(rmnet_dev, "Setting VND TX queue state to %d\n", enable); - /* Although we expect similar number of enable/disable - * commands, optimize for the disable. That is more - * latency sensitive than enable - */ - if (unlikely(enable)) - netif_wake_queue(rmnet_dev); - else - netif_stop_queue(rmnet_dev); - - return 0; -} diff --git a/quectel_MHI/src/devices/rmnet/rmnet_vnd.h b/quectel_MHI/src/devices/rmnet/rmnet_vnd.h deleted file mode 100644 index f8a65a9..0000000 --- a/quectel_MHI/src/devices/rmnet/rmnet_vnd.h +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright (c) 2013-2019, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * RMNET Data Virtual Network Device APIs - * - */ - -#ifndef _RMNET_VND_H_ -#define _RMNET_VND_H_ - -static int rmnet_vnd_do_flow_control(struct net_device *dev, int enable); -static int rmnet_vnd_newlink(u8 id, struct net_device *rmnet_dev, - struct rmnet_port *port, - struct net_device *real_dev, - struct rmnet_endpoint *ep); -static int rmnet_vnd_dellink(u8 id, struct rmnet_port *port, - struct rmnet_endpoint *ep); -static void rmnet_vnd_rx_fixup(struct net_device *dev, u32 skb_len); -static void rmnet_vnd_tx_fixup(struct net_device *dev, u32 skb_len); -static void rmnet_vnd_setup(struct net_device *dev); -#endif /* _RMNET_VND_H_ */ diff --git a/quectel_MHI/src/devices/rmnet_handler.c b/quectel_MHI/src/devices/rmnet_handler.c deleted file mode 100644 index b100262..0000000 --- a/quectel_MHI/src/devices/rmnet_handler.c +++ /dev/null @@ -1,1129 +0,0 @@ -#if 0 - -#define RMNET_MAX_PACKET_SIZE 16384 -#define RMNET_DFLT_PACKET_SIZE 1500 -#define RMNET_NEEDED_HEADROOM 16 -#define RMNET_TX_QUEUE_LEN 1000 - -#define RMNET_MAX_LOGICAL_EP 255 -#define RMNET_MAP_DESC_HEADROOM 128 -#define RMNET_FRAG_DESCRIPTOR_POOL_SIZE 64 - -/* Pass the frame up the stack with no modifications to skb->dev */ -#define RMNET_EPMODE_NONE (0) -/* Replace skb->dev to a virtual rmnet device and pass up the stack */ -#define RMNET_EPMODE_VND (1) -/* Pass the frame directly to another device with dev_queue_xmit() */ -#define RMNET_EPMODE_BRIDGE (2) - -/* rmnet section */ - -#define RMNET_FLAGS_INGRESS_DEAGGREGATION (1U << 0) -#define RMNET_FLAGS_INGRESS_MAP_COMMANDS (1U << 1) -#define RMNET_FLAGS_INGRESS_MAP_CKSUMV4 (1U << 2) -#define RMNET_FLAGS_EGRESS_MAP_CKSUMV4 (1U << 3) -#define RMNET_FLAGS_INGRESS_COALESCE (1U << 4) -#define RMNET_FLAGS_INGRESS_MAP_CKSUMV5 (1U << 5) -#define RMNET_FLAGS_EGRESS_MAP_CKSUMV5 (1U << 6) - -enum rmnet_map_v5_header_type { - RMNET_MAP_HEADER_TYPE_UNKNOWN, - RMNET_MAP_HEADER_TYPE_COALESCING = 0x1, - RMNET_MAP_HEADER_TYPE_CSUM_OFFLOAD = 0x2, - RMNET_MAP_HEADER_TYPE_ENUM_LENGTH -}; - -/* Main QMAP header */ -struct rmnet_map_header { - u8 pad_len:6; - u8 next_hdr:1; - u8 cd_bit:1; - u8 mux_id; - __be16 pkt_len; -} __aligned(1); - -/* QMAP v5 headers */ -struct rmnet_map_v5_csum_header { - u8 next_hdr:1; - u8 header_type:7; - u8 hw_reserved:7; - u8 csum_valid_required:1; - __be16 reserved; -} __aligned(1); - -struct rmnet_map_v5_nl_pair { - __be16 pkt_len; - u8 csum_error_bitmap; - u8 num_packets; -} __aligned(1); - -/* NLO: Number-length object */ -#define RMNET_MAP_V5_MAX_NLOS (6) -#define RMNET_MAP_V5_MAX_PACKETS (48) - -struct rmnet_map_v5_coal_header { - u8 next_hdr:1; - u8 header_type:7; - u8 reserved1:4; - u8 num_nlos:3; - u8 csum_valid:1; - u8 close_type:4; - u8 close_value:4; - u8 reserved2:4; - u8 virtual_channel_id:4; - - struct rmnet_map_v5_nl_pair nl_pairs[RMNET_MAP_V5_MAX_NLOS]; -} __aligned(1); - -/* QMAP v4 headers */ -struct rmnet_map_dl_csum_trailer { - u8 reserved1; - u8 valid:1; - u8 reserved2:7; - u16 csum_start_offset; - u16 csum_length; - __be16 csum_value; -} __aligned(1); - -struct rmnet_frag_descriptor_pool { - struct list_head free_list; - u32 pool_size; -}; - -struct rmnet_frag_descriptor { - struct list_head list; - struct list_head sub_frags; - skb_frag_t frag; - u8 *hdr_ptr; - struct net_device *dev; - u32 hash; - __be32 tcp_seq; - __be16 ip_id; - u16 data_offset; - u16 gso_size; - u16 gso_segs; - u16 ip_len; - u16 trans_len; - u8 ip_proto; - u8 trans_proto; - u8 pkt_id; - u8 csum_valid:1, - hdrs_valid:1, - ip_id_set:1, - tcp_seq_set:1, - flush_shs:1, - reserved:3; -}; - -struct rmnet_endpoint { - u8 rmnet_mode; - u8 mux_id; - struct net_device *rmnet_dev; -}; - -/* One instance of this structure is instantiated for each real_dev associated - * with rmnet. - */ -struct rmnet_port { - struct net_device *dev; - u8 rmnet_mode; - u32 data_format; - u32 nr_rmnet_devs; - struct rmnet_endpoint muxed_ep[16]; - - /* Descriptor pool */ - spinlock_t desc_pool_lock; - struct rmnet_frag_descriptor_pool *frag_desc_pool; - struct sk_buff *chain_head; - struct sk_buff *chain_tail; -}; - -static struct sk_buff * add_qhdr_v5(struct sk_buff *skb, u8 mux_id) -{ - struct rmnet_map_header *map_header; - struct rmnet_map_v5_csum_header *ul_header; - u32 padding, map_datalen; - - map_datalen = skb->len; - padding = map_datalen%4; - if (padding) { - padding = 4 - padding; - if (skb_tailroom(skb) < padding) { - printk("skb_tailroom small!\n"); - padding = 0; - } - if (padding) - __skb_put(skb, padding); - } - - map_header = (struct rmnet_map_header *)skb_push(skb, (sizeof(struct rmnet_map_header) + sizeof(struct rmnet_map_v5_csum_header))); - - BUILD_BUG_ON((sizeof(struct rmnet_map_header) + sizeof(struct rmnet_map_v5_csum_header)) != 8); - - map_header->cd_bit = 0; - map_header->next_hdr = 1; - map_header->pad_len = padding; - map_header->mux_id = mux_id; - map_header->pkt_len = htons(map_datalen + padding); - - ul_header = (struct rmnet_map_v5_csum_header *)(map_header + 1); - memset(ul_header, 0, sizeof(*ul_header)); - ul_header->header_type = RMNET_MAP_HEADER_TYPE_CSUM_OFFLOAD; - - return skb; -} - -struct rmnet_endpoint *rmnet_get_endpoint(struct rmnet_port *port, u8 mux_id) -{ - return &port->muxed_ep[0]; -} - -static void -rmnet_deliver_skb(struct sk_buff *skb, struct rmnet_port *port) -{ - struct rmnet_nss_cb *nss_cb; - - //rmnet_vnd_rx_fixup(skb->dev, skb->len); - - /* Pass off the packet to NSS driver if we can */ - nss_cb = rcu_dereference(rmnet_nss_callbacks); - if (nss_cb) { - if (!port->chain_head) - port->chain_head = skb; - else - skb_shinfo(port->chain_tail)->frag_list = skb; - - port->chain_tail = skb; - return; - } - - skb_reset_transport_header(skb); - skb_reset_network_header(skb); - - skb->pkt_type = PACKET_HOST; - skb_set_mac_header(skb, 0); - - //if (port->data_format & RMNET_INGRESS_FORMAT_DL_MARKER) { - //} else { - //if (!rmnet_check_skb_can_gro(skb)) - // gro_cells_receive(&priv->gro_cells, skb); - //else - netif_receive_skb(skb); - //} -} - -static inline unsigned char *rmnet_map_data_ptr(struct sk_buff *skb) -{ - /* Nonlinear packets we receive are entirely within frag 0 */ - if (skb_is_nonlinear(skb) && skb->len == skb->data_len) - return skb_frag_address(skb_shinfo(skb)->frags); - - return skb->data; -} - -static inline void *rmnet_frag_data_ptr(struct rmnet_frag_descriptor *frag_desc) -{ - return skb_frag_address(&frag_desc->frag); -} - -static struct rmnet_frag_descriptor * -rmnet_get_frag_descriptor(struct rmnet_port *port) -{ - struct rmnet_frag_descriptor_pool *pool = port->frag_desc_pool; - struct rmnet_frag_descriptor *frag_desc; - - spin_lock(&port->desc_pool_lock); - if (!list_empty(&pool->free_list)) { - frag_desc = list_first_entry(&pool->free_list, - struct rmnet_frag_descriptor, - list); - list_del_init(&frag_desc->list); - } else { - frag_desc = kzalloc(sizeof(*frag_desc), GFP_ATOMIC); - if (!frag_desc) - goto out; - - INIT_LIST_HEAD(&frag_desc->list); - INIT_LIST_HEAD(&frag_desc->sub_frags); - pool->pool_size++; - } - -out: - spin_unlock(&port->desc_pool_lock); - return frag_desc; -} - -static void rmnet_recycle_frag_descriptor(struct rmnet_frag_descriptor *frag_desc, - struct rmnet_port *port) -{ - struct rmnet_frag_descriptor_pool *pool = port->frag_desc_pool; - struct page *page = skb_frag_page(&frag_desc->frag); - - list_del(&frag_desc->list); - if (page) - put_page(page); - - memset(frag_desc, 0, sizeof(*frag_desc)); - INIT_LIST_HEAD(&frag_desc->list); - INIT_LIST_HEAD(&frag_desc->sub_frags); - spin_lock(&port->desc_pool_lock); - list_add_tail(&frag_desc->list, &pool->free_list); - spin_unlock(&port->desc_pool_lock); -} - -static inline void rmnet_frag_fill(struct rmnet_frag_descriptor *frag_desc, - struct page *p, u32 page_offset, u32 len) -{ - get_page(p); - __skb_frag_set_page(&frag_desc->frag, p); - skb_frag_size_set(&frag_desc->frag, len); - frag_desc->frag.page_offset = page_offset; -} - -static inline void *rmnet_frag_pull(struct rmnet_frag_descriptor *frag_desc, - struct rmnet_port *port, - unsigned int size) -{ - if (size >= skb_frag_size(&frag_desc->frag)) { - pr_info("%s(): Pulling %u bytes from %u byte pkt. Dropping\n", - __func__, size, skb_frag_size(&frag_desc->frag)); - rmnet_recycle_frag_descriptor(frag_desc, port); - return NULL; - } - - frag_desc->frag.page_offset += size; - skb_frag_size_sub(&frag_desc->frag, size); - - return rmnet_frag_data_ptr(frag_desc); -} - -static inline void *rmnet_frag_trim(struct rmnet_frag_descriptor *frag_desc, - struct rmnet_port *port, - unsigned int size) -{ - if (!size) { - pr_info("%s(): Trimming %u byte pkt to 0. Dropping\n", - __func__, skb_frag_size(&frag_desc->frag)); - rmnet_recycle_frag_descriptor(frag_desc, port); - return NULL; - } - - if (size < skb_frag_size(&frag_desc->frag)) - skb_frag_size_set(&frag_desc->frag, size); - - return rmnet_frag_data_ptr(frag_desc); -} - -static inline u8 -rmnet_frag_get_next_hdr_type(struct rmnet_frag_descriptor *frag_desc) -{ - unsigned char *data = rmnet_frag_data_ptr(frag_desc); - - data += sizeof(struct rmnet_map_header); - return ((struct rmnet_map_v5_coal_header *)data)->header_type; -} - -static inline bool -rmnet_frag_get_csum_valid(struct rmnet_frag_descriptor *frag_desc) -{ - unsigned char *data = rmnet_frag_data_ptr(frag_desc); - - data += sizeof(struct rmnet_map_header); - return ((struct rmnet_map_v5_csum_header *)data)->csum_valid_required; -} - -static void rmnet_descriptor_add_frag(struct rmnet_port *port, struct list_head *list, - struct page *p, u32 page_offset, u32 len) -{ - struct rmnet_frag_descriptor *frag_desc; - - frag_desc = rmnet_get_frag_descriptor(port); - if (!frag_desc) - return; - - rmnet_frag_fill(frag_desc, p, page_offset, len); - list_add_tail(&frag_desc->list, list); -} - -static void rmnet_frag_deaggregate(skb_frag_t *frag, struct rmnet_port *port, - struct list_head *list) -{ - struct rmnet_map_header *maph; - u8 *data = skb_frag_address(frag); - u32 offset = 0; - u32 packet_len; - - while (offset < skb_frag_size(frag)) { - maph = (struct rmnet_map_header *)data; - packet_len = ntohs(maph->pkt_len); - - /* Some hardware can send us empty frames. Catch them */ - if (packet_len == 0) - return; - - packet_len += sizeof(*maph); - - if (port->data_format & RMNET_FLAGS_INGRESS_MAP_CKSUMV4) { - packet_len += sizeof(struct rmnet_map_dl_csum_trailer); - WARN_ON(1); - } else if (port->data_format & - (RMNET_FLAGS_INGRESS_MAP_CKSUMV5 | - RMNET_FLAGS_INGRESS_COALESCE) && !maph->cd_bit) { - u32 hsize = 0; - u8 type; - - type = ((struct rmnet_map_v5_coal_header *) - (data + sizeof(*maph)))->header_type; - switch (type) { - case RMNET_MAP_HEADER_TYPE_COALESCING: - hsize = sizeof(struct rmnet_map_v5_coal_header); - break; - case RMNET_MAP_HEADER_TYPE_CSUM_OFFLOAD: - hsize = sizeof(struct rmnet_map_v5_csum_header); - break; - } - - packet_len += hsize; - } - else { - qmap_hex_dump(__func__, data, 64); - WARN_ON(1); - } - - if ((int)skb_frag_size(frag) - (int)packet_len < 0) - return; - - rmnet_descriptor_add_frag(port, list, skb_frag_page(frag), - frag->page_offset + offset, - packet_len); - - offset += packet_len; - data += packet_len; - } -} - - -#define RMNET_IP_VERSION_4 0x40 -#define RMNET_IP_VERSION_6 0x60 - -/* Helper Functions */ - -static void rmnet_set_skb_proto(struct sk_buff *skb) -{ - switch (rmnet_map_data_ptr(skb)[0] & 0xF0) { - case RMNET_IP_VERSION_4: - skb->protocol = htons(ETH_P_IP); - break; - case RMNET_IP_VERSION_6: - skb->protocol = htons(ETH_P_IPV6); - break; - default: - skb->protocol = htons(ETH_P_MAP); - WARN_ON(1); - break; - } -} - -/* Allocate and populate an skb to contain the packet represented by the - * frag descriptor. - */ -static struct sk_buff *rmnet_alloc_skb(struct rmnet_frag_descriptor *frag_desc, - struct rmnet_port *port) -{ - struct sk_buff *head_skb, *current_skb, *skb; - struct skb_shared_info *shinfo; - struct rmnet_frag_descriptor *sub_frag, *tmp; - - /* Use the exact sizes if we know them (i.e. RSB/RSC, rmnet_perf) */ - if (frag_desc->hdrs_valid) { - u16 hdr_len = frag_desc->ip_len + frag_desc->trans_len; - - head_skb = alloc_skb(hdr_len + RMNET_MAP_DESC_HEADROOM, - GFP_ATOMIC); - if (!head_skb) - return NULL; - - skb_reserve(head_skb, RMNET_MAP_DESC_HEADROOM); - skb_put_data(head_skb, frag_desc->hdr_ptr, hdr_len); - skb_reset_network_header(head_skb); - - if (frag_desc->trans_len) - skb_set_transport_header(head_skb, frag_desc->ip_len); - - /* Packets that have no data portion don't need any frags */ - if (hdr_len == skb_frag_size(&frag_desc->frag)) - goto skip_frags; - - /* If the headers we added are the start of the page, - * we don't want to add them twice - */ - if (frag_desc->hdr_ptr == rmnet_frag_data_ptr(frag_desc)) { - if (!rmnet_frag_pull(frag_desc, port, hdr_len)) { - kfree_skb(head_skb); - return NULL; - } - } - } else { - /* Allocate enough space to avoid penalties in the stack - * from __pskb_pull_tail() - */ - head_skb = alloc_skb(256 + RMNET_MAP_DESC_HEADROOM, - GFP_ATOMIC); - if (!head_skb) - return NULL; - - skb_reserve(head_skb, RMNET_MAP_DESC_HEADROOM); - } - - /* Add main fragment */ - get_page(skb_frag_page(&frag_desc->frag)); - skb_add_rx_frag(head_skb, 0, skb_frag_page(&frag_desc->frag), - frag_desc->frag.page_offset, - skb_frag_size(&frag_desc->frag), - skb_frag_size(&frag_desc->frag)); - - shinfo = skb_shinfo(head_skb); - current_skb = head_skb; - - /* Add in any frags from rmnet_perf */ - list_for_each_entry_safe(sub_frag, tmp, &frag_desc->sub_frags, list) { - skb_frag_t *frag; - u32 frag_size; - - frag = &sub_frag->frag; - frag_size = skb_frag_size(frag); - -add_frag: - if (shinfo->nr_frags < MAX_SKB_FRAGS) { - get_page(skb_frag_page(frag)); - skb_add_rx_frag(current_skb, shinfo->nr_frags, - skb_frag_page(frag), frag->page_offset, - frag_size, frag_size); - if (current_skb != head_skb) { - head_skb->len += frag_size; - head_skb->data_len += frag_size; - } - } else { - /* Alloc a new skb and try again */ - skb = alloc_skb(0, GFP_ATOMIC); - if (!skb) - break; - - if (current_skb == head_skb) - shinfo->frag_list = skb; - else - current_skb->next = skb; - - current_skb = skb; - shinfo = skb_shinfo(current_skb); - goto add_frag; - } - - rmnet_recycle_frag_descriptor(sub_frag, port); - } - -skip_frags: - head_skb->dev = frag_desc->dev; - rmnet_set_skb_proto(head_skb); - - /* Handle any header metadata that needs to be updated after RSB/RSC - * segmentation - */ - if (frag_desc->ip_id_set) { - struct iphdr *iph; - - iph = (struct iphdr *)rmnet_map_data_ptr(head_skb); - csum_replace2(&iph->check, iph->id, frag_desc->ip_id); - iph->id = frag_desc->ip_id; - } - - if (frag_desc->tcp_seq_set) { - struct tcphdr *th; - - th = (struct tcphdr *) - (rmnet_map_data_ptr(head_skb) + frag_desc->ip_len); - th->seq = frag_desc->tcp_seq; - } - - /* Handle csum offloading */ - if (frag_desc->csum_valid && frag_desc->hdrs_valid) { - /* Set the partial checksum information */ - //rmnet_frag_partial_csum(head_skb, frag_desc); - WARN_ON(1); - } else if (frag_desc->csum_valid) { - /* Non-RSB/RSC/perf packet. The current checksum is fine */ - head_skb->ip_summed = CHECKSUM_UNNECESSARY; - } else if (frag_desc->hdrs_valid && - (frag_desc->trans_proto == IPPROTO_TCP || - frag_desc->trans_proto == IPPROTO_UDP)) { - /* Unfortunately, we have to fake a bad checksum here, since - * the original bad value is lost by the hardware. The only - * reliable way to do it is to calculate the actual checksum - * and corrupt it. - */ - __sum16 *check; - __wsum csum; - unsigned int offset = skb_transport_offset(head_skb); - __sum16 pseudo; - - WARN_ON(1); - /* Calculate pseudo header and update header fields */ - if (frag_desc->ip_proto == 4) { - struct iphdr *iph = ip_hdr(head_skb); - __be16 tot_len = htons(head_skb->len); - - csum_replace2(&iph->check, iph->tot_len, tot_len); - iph->tot_len = tot_len; - pseudo = ~csum_tcpudp_magic(iph->saddr, iph->daddr, - head_skb->len - - frag_desc->ip_len, - frag_desc->trans_proto, 0); - } else { - struct ipv6hdr *ip6h = ipv6_hdr(head_skb); - - ip6h->payload_len = htons(head_skb->len - - sizeof(*ip6h)); - pseudo = ~csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr, - head_skb->len - - frag_desc->ip_len, - frag_desc->trans_proto, 0); - } - - if (frag_desc->trans_proto == IPPROTO_TCP) { - check = &tcp_hdr(head_skb)->check; - } else { - udp_hdr(head_skb)->len = htons(head_skb->len - - frag_desc->ip_len); - check = &udp_hdr(head_skb)->check; - } - - *check = pseudo; - csum = skb_checksum(head_skb, offset, head_skb->len - offset, - 0); - /* Add 1 to corrupt. This cannot produce a final value of 0 - * since csum_fold() can't return a value of 0xFFFF - */ - *check = csum16_add(csum_fold(csum), htons(1)); - head_skb->ip_summed = CHECKSUM_NONE; - } - - /* Handle any rmnet_perf metadata */ - if (frag_desc->hash) { - head_skb->hash = frag_desc->hash; - head_skb->sw_hash = 1; - } - - if (frag_desc->flush_shs) - head_skb->cb[0] = 1; - - /* Handle coalesced packets */ - //if (frag_desc->gso_segs > 1) - // rmnet_frag_gso_stamp(head_skb, frag_desc); - - return head_skb; -} - -/* Deliver the packets contained within a frag descriptor */ -static void rmnet_frag_deliver(struct rmnet_frag_descriptor *frag_desc, - struct rmnet_port *port) -{ - struct sk_buff *skb; - - skb = rmnet_alloc_skb(frag_desc, port); - if (skb) - rmnet_deliver_skb(skb, port); - rmnet_recycle_frag_descriptor(frag_desc, port); -} - -/* Process a QMAPv5 packet header */ -static int rmnet_frag_process_next_hdr_packet(struct rmnet_frag_descriptor *frag_desc, - struct rmnet_port *port, - struct list_head *list, - u16 len) -{ - int rc = 0; - - switch (rmnet_frag_get_next_hdr_type(frag_desc)) { - case RMNET_MAP_HEADER_TYPE_COALESCING: - rc = -1; - WARN_ON(1); - break; - case RMNET_MAP_HEADER_TYPE_CSUM_OFFLOAD: - if (rmnet_frag_get_csum_valid(frag_desc)) { - frag_desc->csum_valid = true; - } else { - } - - if (!rmnet_frag_pull(frag_desc, port, - sizeof(struct rmnet_map_header) + - sizeof(struct rmnet_map_v5_csum_header))) { - rc = -EINVAL; - break; - } - - frag_desc->hdr_ptr = rmnet_frag_data_ptr(frag_desc); - - /* Remove padding only for csum offload packets. - * Coalesced packets should never have padding. - */ - if (!rmnet_frag_trim(frag_desc, port, len)) { - rc = -EINVAL; - break; - } - - list_del_init(&frag_desc->list); - list_add_tail(&frag_desc->list, list); - break; - default: - qmap_hex_dump(__func__, rmnet_frag_data_ptr(frag_desc), 64); - rc = -EINVAL; - break; - } - - return rc; -} - -static void -__rmnet_frag_ingress_handler(struct rmnet_frag_descriptor *frag_desc, - struct rmnet_port *port) -{ - struct rmnet_map_header *qmap; - struct rmnet_endpoint *ep; - struct rmnet_frag_descriptor *frag, *tmp; - LIST_HEAD(segs); - u16 len, pad; - u8 mux_id; - - qmap = (struct rmnet_map_header *)skb_frag_address(&frag_desc->frag); - mux_id = qmap->mux_id; - pad = qmap->pad_len; - len = ntohs(qmap->pkt_len) - pad; - - if (qmap->cd_bit) { - goto recycle; - } - - if (mux_id >= RMNET_MAX_LOGICAL_EP) - goto recycle; - - ep = rmnet_get_endpoint(port, mux_id); - if (!ep) - goto recycle; - - frag_desc->dev = ep->rmnet_dev; - - /* Handle QMAPv5 packet */ - if (qmap->next_hdr && - (port->data_format & (RMNET_FLAGS_INGRESS_COALESCE | - RMNET_FLAGS_INGRESS_MAP_CKSUMV5))) { - if (rmnet_frag_process_next_hdr_packet(frag_desc, port, &segs, - len)) - goto recycle; - } else { - /* We only have the main QMAP header to worry about */ - if (!rmnet_frag_pull(frag_desc, port, sizeof(*qmap))) - return; - - frag_desc->hdr_ptr = rmnet_frag_data_ptr(frag_desc); - - if (!rmnet_frag_trim(frag_desc, port, len)) - return; - - list_add_tail(&frag_desc->list, &segs); - } - - list_for_each_entry_safe(frag, tmp, &segs, list) { - list_del_init(&frag->list); - rmnet_frag_deliver(frag, port); - } - return; - -recycle: - rmnet_recycle_frag_descriptor(frag_desc, port); -} - -static void rmnet_frag_ingress_handler(struct sk_buff *skb, - struct rmnet_port *port) -{ - LIST_HEAD(desc_list); - int i = 0; - struct rmnet_nss_cb *nss_cb; - - /* Deaggregation and freeing of HW originating - * buffers is done within here - */ - while (skb) { - struct sk_buff *skb_frag; - - port->chain_head = NULL; - port->chain_tail = NULL; - - for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { - rmnet_frag_deaggregate(&skb_shinfo(skb)->frags[i], port, - &desc_list); - if (!list_empty(&desc_list)) { - struct rmnet_frag_descriptor *frag_desc, *tmp; - - list_for_each_entry_safe(frag_desc, tmp, - &desc_list, list) { - list_del_init(&frag_desc->list); - __rmnet_frag_ingress_handler(frag_desc, - port); - } - } - } - - nss_cb = rcu_dereference(rmnet_nss_callbacks); - if (nss_cb && port->chain_head) { - port->chain_head->cb[0] = 0; - netif_receive_skb(port->chain_head); - } - - skb_frag = skb_shinfo(skb)->frag_list; - skb_shinfo(skb)->frag_list = NULL; - consume_skb(skb); - skb = skb_frag; - } -} - -static void -rmnet_map_ingress_handler(struct sk_buff *skb, - struct rmnet_port *port) -{ - if (port->data_format & (RMNET_FLAGS_INGRESS_COALESCE | - RMNET_FLAGS_INGRESS_MAP_CKSUMV5)) { - if (skb_is_nonlinear(skb)) { - rmnet_frag_ingress_handler(skb, port); - return; - } - } - - WARN_ON(1); -} - -static rx_handler_result_t rmnet_rx_handler(struct sk_buff **pskb); -static int rmnet_is_real_dev_registered(const struct net_device *real_dev) -{ - return rcu_access_pointer(real_dev->rx_handler) == rmnet_rx_handler; -} - - -/* Needs either rcu_read_lock() or rtnl lock */ -struct rmnet_port *rmnet_get_port(struct net_device *real_dev) -{ - if (rmnet_is_real_dev_registered(real_dev)) - return rcu_dereference_rtnl(real_dev->rx_handler_data); - else - return NULL; -} - -static rx_handler_result_t rmnet_rx_priv_handler(struct sk_buff **pskb) -{ - struct sk_buff *skb = *pskb; - struct rmnet_nss_cb *nss_cb; - - if (!skb) - return RX_HANDLER_CONSUMED; - if (nss_debug) printk("%s skb=%p, len=%d, protocol=%x, hdr_len=%d\n", __func__, skb, skb->len, skb->protocol, skb->hdr_len); - - if (skb->pkt_type == PACKET_LOOPBACK) - return RX_HANDLER_PASS; - - /* Check this so that we dont loop around netif_receive_skb */ - if (skb->cb[0] == 1) { - skb->cb[0] = 0; - - skb->dev->stats.rx_packets++; - return RX_HANDLER_PASS; - } - - while (skb) { - struct sk_buff *skb_frag = skb_shinfo(skb)->frag_list; - - skb_shinfo(skb)->frag_list = NULL; - - nss_cb = rcu_dereference(rmnet_nss_callbacks); - if (nss_cb) - nss_cb->nss_tx(skb); - - skb = skb_frag; - } - - return RX_HANDLER_CONSUMED; -} - -/* Ingress / Egress Entry Points */ - -/* Processes packet as per ingress data format for receiving device. Logical - * endpoint is determined from packet inspection. Packet is then sent to the - * egress device listed in the logical endpoint configuration. - */ -static rx_handler_result_t rmnet_rx_handler(struct sk_buff **pskb) -{ - struct sk_buff *skb = *pskb; - struct rmnet_port *port; - struct net_device *dev; - - if (!skb) - goto done; - - if (nss_debug) printk("%s skb=%p, len=%d, protocol=%x, hdr_len=%d\n", __func__, skb, skb->len, skb->protocol, skb->hdr_len); - - if (skb->pkt_type == PACKET_LOOPBACK) - return RX_HANDLER_PASS; - - if (skb->protocol != htons(ETH_P_MAP)) { - WARN_ON(1); - return RX_HANDLER_PASS; - } - - dev = skb->dev; - port = rmnet_get_port(dev); - - if (port == NULL) - return RX_HANDLER_PASS; - - port->chain_head = NULL; - port->chain_tail = NULL; - - switch (port->rmnet_mode) { - case RMNET_EPMODE_VND: - rmnet_map_ingress_handler(skb, port); - break; - case RMNET_EPMODE_BRIDGE: - //rmnet_bridge_handler(skb, port->bridge_ep); - break; - } - -done: - return RX_HANDLER_CONSUMED; -} - -static void rmnet_descriptor_deinit(struct rmnet_port *port) -{ - struct rmnet_frag_descriptor_pool *pool; - struct rmnet_frag_descriptor *frag_desc, *tmp; - - pool = port->frag_desc_pool; - - list_for_each_entry_safe(frag_desc, tmp, &pool->free_list, list) { - kfree(frag_desc); - pool->pool_size--; - } - - kfree(pool); -} - -static int rmnet_descriptor_init(struct rmnet_port *port) -{ - struct rmnet_frag_descriptor_pool *pool; - int i; - - spin_lock_init(&port->desc_pool_lock); - pool = kzalloc(sizeof(*pool), GFP_ATOMIC); - if (!pool) - return -ENOMEM; - - INIT_LIST_HEAD(&pool->free_list); - port->frag_desc_pool = pool; - - for (i = 0; i < RMNET_FRAG_DESCRIPTOR_POOL_SIZE; i++) { - struct rmnet_frag_descriptor *frag_desc; - - frag_desc = kzalloc(sizeof(*frag_desc), GFP_ATOMIC); - if (!frag_desc) - return -ENOMEM; - - INIT_LIST_HEAD(&frag_desc->list); - INIT_LIST_HEAD(&frag_desc->sub_frags); - list_add_tail(&frag_desc->list, &pool->free_list); - pool->pool_size++; - } - - return 0; -} - -struct rmnet_priv { - //struct rmnet_endpoint local_ep; - struct net_device *real_dev; - u8 mux_id; -}; - -static netdev_tx_t rmnet_vnd_start_xmit(struct sk_buff *skb, - struct net_device *dev) -{ - struct rmnet_priv *priv; - - if (nss_debug) printk("%s skb=%p, len=%d, protocol=%x, hdr_len=%d\n", __func__, skb, skb->len, skb->protocol, skb->hdr_len); - - priv = netdev_priv(dev); - if (priv->real_dev) { - add_qhdr_v5(skb, priv->mux_id); - skb->protocol = htons(ETH_P_MAP); - skb->dev = priv->real_dev; - dev_queue_xmit(skb); - dev->stats.tx_packets++; - //rmnet_egress_handler(skb); - } else { - //this_cpu_inc(priv->pcpu_stats->stats.tx_drops); - kfree_skb(skb); - } - return NETDEV_TX_OK; -} - -static int rmnet_vnd_change_mtu(struct net_device *rmnet_dev, int new_mtu) -{ - if (new_mtu < 0 || new_mtu > RMNET_MAX_PACKET_SIZE) - return -EINVAL; - - rmnet_dev->mtu = new_mtu; - return 0; -} - -static const struct net_device_ops rmnet_vnd_ops = { - .ndo_start_xmit = rmnet_vnd_start_xmit, - .ndo_change_mtu = rmnet_vnd_change_mtu, - //.ndo_get_iflink = rmnet_vnd_get_iflink, - //.ndo_add_slave = rmnet_add_bridge, - //.ndo_del_slave = rmnet_del_bridge, - //.ndo_init = rmnet_vnd_init, - //.ndo_uninit = rmnet_vnd_uninit, - //.ndo_get_stats64 = rmnet_get_stats64, -}; - -static void rmnet_vnd_setup(struct net_device *rmnet_dev) -{ - rmnet_dev->netdev_ops = &rmnet_vnd_ops; - rmnet_dev->mtu = RMNET_DFLT_PACKET_SIZE; - rmnet_dev->needed_headroom = RMNET_NEEDED_HEADROOM; - random_ether_addr(rmnet_dev->dev_addr); - rmnet_dev->tx_queue_len = RMNET_TX_QUEUE_LEN; - - /* Raw IP mode */ - rmnet_dev->header_ops = NULL; /* No header */ - rmnet_dev->type = ARPHRD_RAWIP; - rmnet_dev->hard_header_len = 0; - rmnet_dev->flags &= ~(IFF_BROADCAST | IFF_MULTICAST); - - //rmnet_dev->needs_free_netdev = true; - - rmnet_dev->hw_features = NETIF_F_RXCSUM; - rmnet_dev->hw_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; - //rmnet_dev->hw_features |= NETIF_F_SG; - //rmnet_dev->hw_features |= NETIF_F_GRO_HW; -} -#else -#include -#include -#include -#include -#include -#include -#include -#include - -static uint nss_debug = 0; -module_param( nss_debug, uint, S_IRUGO | S_IWUSR); - -/* rmnet section */ - -#define RMNET_FLAGS_INGRESS_DEAGGREGATION (1U << 0) -#define RMNET_FLAGS_INGRESS_MAP_COMMANDS (1U << 1) -#define RMNET_FLAGS_INGRESS_MAP_CKSUMV4 (1U << 2) -#define RMNET_FLAGS_EGRESS_MAP_CKSUMV4 (1U << 3) -#define RMNET_FLAGS_INGRESS_COALESCE (1U << 4) -#define RMNET_FLAGS_INGRESS_MAP_CKSUMV5 (1U << 5) -#define RMNET_FLAGS_EGRESS_MAP_CKSUMV5 (1U << 6) - -#ifdef CONFIG_ARCH_IPQ807x -#define CONFIG_QCA_NSS_DRV -#endif -#ifdef CONFIG_QCA_NSS_DRV -#include "rmnet/rmnet_nss.c" -#else -#include "rmnet_nss.h" -#endif - -#include "rmnet/rmnet_vnd.c" -#include "rmnet/rmnet_map_command.c" -#include "rmnet/rmnet_map_data.c" -#include "rmnet/rmnet_descriptor.c" -#include "rmnet/rmnet_config.c" -#include "rmnet/rmnet_handlers.c" - -struct rmnet_nss_cb *rmnet_nss_callbacks __rcu __read_mostly; - -void rmnet_init(struct net_device *real_dev, u32 nr_rmnet_devs) -{ - struct rmnet_port *port; - struct rmnet_endpoint *ep; - struct net_device *rmnet_dev = NULL; - u32 nr = 0; - struct rmnet_nss_cb *nss_cb = rcu_dereference(rmnet_nss_callbacks); - - if (!nss_cb) { -#ifdef CONFIG_QCA_NSS_DRV - rmnet_nss_init(); -#endif - } - - rmnet_register_real_device(real_dev); - - port = rmnet_get_port_rtnl(real_dev); - - port->data_format = RMNET_FLAGS_INGRESS_DEAGGREGATION - | RMNET_FLAGS_INGRESS_MAP_CKSUMV5 | RMNET_FLAGS_EGRESS_MAP_CKSUMV5; - port->rmnet_mode = RMNET_EPMODE_VND; - - for (nr = 0; nr < nr_rmnet_devs; nr++) { - u8 mux_id = 0x81+nr; - - rmnet_dev = alloc_netdev(sizeof(struct rmnet_priv), - "rmnet_data%d", NET_NAME_PREDICTABLE, - rmnet_vnd_setup); - - ep = kzalloc(sizeof(*ep), GFP_ATOMIC); - - rmnet_vnd_newlink(mux_id, rmnet_dev, port, real_dev, ep); - netdev_rx_handler_register(rmnet_dev, rmnet_rx_priv_handler, NULL); - hlist_add_head_rcu(&ep->hlnode, &port->muxed_ep[mux_id]); - } - - port->nr_rmnet_devs = nr_rmnet_devs; -} - -void rmnet_deinit(struct net_device *real_dev, u32 nr_rmnet_devs) -{ - struct rmnet_port *port; - u32 nr = 0; - struct rmnet_nss_cb *nss_cb = rcu_dereference(rmnet_nss_callbacks); - - port = rmnet_get_port_rtnl(real_dev); - - if (!real_dev || !rmnet_is_real_dev_registered(real_dev)) - return; - - port = rmnet_get_port_rtnl(real_dev); - - for (nr = 0; nr < nr_rmnet_devs; nr++) { - struct rmnet_endpoint *ep; - u8 mux_id = 0x81+nr; - - ep = rmnet_get_endpoint(port, mux_id); - if (ep) { - hlist_del_init_rcu(&ep->hlnode); - rmnet_vnd_dellink(mux_id, port, ep); - synchronize_rcu(); - kfree(ep); - } - } - - rmnet_unregister_real_device(real_dev, port); - - if (nss_cb) { -#ifdef CONFIG_QCA_NSS_DRV - rmnet_nss_exit(); -#endif - } -} -#endif diff --git a/quectel_MHI/src/devices/rmnet_nss.c b/quectel_MHI/src/devices/rmnet_nss.c deleted file mode 100644 index e6e8414..0000000 --- a/quectel_MHI/src/devices/rmnet_nss.c +++ /dev/null @@ -1,424 +0,0 @@ -/* Copyright (c) 2019, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#define RMNET_NSS_HASH_BITS 8 -#define hash_add_ptr(table, node, key) \ - hlist_add_head(node, &table[hash_ptr(key, HASH_BITS(table))]) - -static DEFINE_HASHTABLE(rmnet_nss_ctx_hashtable, RMNET_NSS_HASH_BITS); - -struct rmnet_nss_ctx { - struct hlist_node hnode; - struct net_device *rmnet_dev; - struct nss_rmnet_rx_handle *nss_ctx; -}; - -enum __rmnet_nss_stat { - RMNET_NSS_RX_ETH, - RMNET_NSS_RX_FAIL, - RMNET_NSS_RX_NON_ETH, - RMNET_NSS_RX_BUSY, - RMNET_NSS_TX_NO_CTX, - RMNET_NSS_TX_SUCCESS, - RMNET_NSS_TX_FAIL, - RMNET_NSS_TX_NONLINEAR, - RMNET_NSS_TX_BAD_IP, - RMNET_NSS_EXCEPTIONS, - RMNET_NSS_EX_BAD_HDR, - RMNET_NSS_EX_BAD_IP, - RMNET_NSS_EX_SUCCESS, - RMNET_NSS_TX_BAD_FRAGS, - RMNET_NSS_TX_LINEARIZE_FAILS, - RMNET_NSS_TX_NON_ZERO_HEADLEN_FRAGS, - RMNET_NSS_TX_BUSY_LOOP, - RMNET_NSS_NUM_STATS, -}; - -static unsigned long rmnet_nss_stats[RMNET_NSS_NUM_STATS]; - -#define RMNET_NSS_STAT(name, counter, desc) \ - module_param_named(name, rmnet_nss_stats[counter], ulong, 0444); \ - MODULE_PARM_DESC(name, desc) - -RMNET_NSS_STAT(rmnet_nss_rx_ethernet, RMNET_NSS_RX_ETH, - "Number of Ethernet headers successfully removed"); -RMNET_NSS_STAT(rmnet_nss_rx_fail, RMNET_NSS_RX_FAIL, - "Number of Ethernet headers that could not be removed"); -RMNET_NSS_STAT(rmnet_nss_rx_non_ethernet, RMNET_NSS_RX_NON_ETH, - "Number of non-Ethernet packets received"); -RMNET_NSS_STAT(rmnet_nss_rx_busy, RMNET_NSS_RX_BUSY, - "Number of packets dropped decause rmnet_data device was busy"); -RMNET_NSS_STAT(rmnet_nss_tx_slow, RMNET_NSS_TX_NO_CTX, - "Number of packets sent over non-NSS-accelerated rmnet device"); -RMNET_NSS_STAT(rmnet_nss_tx_fast, RMNET_NSS_TX_SUCCESS, - "Number of packets sent over NSS-accelerated rmnet device"); -RMNET_NSS_STAT(rmnet_nss_tx_fail, RMNET_NSS_TX_FAIL, - "Number of packets that NSS could not transmit"); -RMNET_NSS_STAT(rmnet_nss_tx_nonlinear, RMNET_NSS_TX_NONLINEAR, - "Number of non linear sent over NSS-accelerated rmnet device"); -RMNET_NSS_STAT(rmnet_nss_tx_invalid_ip, RMNET_NSS_TX_BAD_IP, - "Number of ingress packets with invalid IP headers"); -RMNET_NSS_STAT(rmnet_nss_tx_invalid_frags, RMNET_NSS_TX_BAD_FRAGS, - "Number of ingress packets with invalid frag format"); -RMNET_NSS_STAT(rmnet_nss_tx_linearize_fail, RMNET_NSS_TX_LINEARIZE_FAILS, - "Number of ingress packets where linearize in tx fails"); -RMNET_NSS_STAT(rmnet_nss_tx_exceptions, RMNET_NSS_EXCEPTIONS, - "Number of times our DL exception handler was invoked"); -RMNET_NSS_STAT(rmnet_nss_exception_non_ethernet, RMNET_NSS_EX_BAD_HDR, - "Number of non-Ethernet exception packets"); -RMNET_NSS_STAT(rmnet_nss_exception_invalid_ip, RMNET_NSS_EX_BAD_IP, - "Number of exception packets with invalid IP headers"); -RMNET_NSS_STAT(rmnet_nss_exception_success, RMNET_NSS_EX_SUCCESS, - "Number of exception packets handled successfully"); -RMNET_NSS_STAT(rmnet_nss_tx_non_zero_headlen_frags, RMNET_NSS_TX_NON_ZERO_HEADLEN_FRAGS, - "Number of packets with non zero headlen"); -RMNET_NSS_STAT(rmnet_nss_tx_busy_loop, RMNET_NSS_TX_BUSY_LOOP, - "Number of times tx packets busy looped"); - -static void rmnet_nss_inc_stat(enum __rmnet_nss_stat stat) -{ - if (stat >= 0 && stat < RMNET_NSS_NUM_STATS) - rmnet_nss_stats[stat]++; -} - -static struct rmnet_nss_ctx *rmnet_nss_find_ctx(struct net_device *dev) -{ - struct rmnet_nss_ctx *ctx; - struct hlist_head *bucket; - u32 hash; - - hash = hash_ptr(dev, HASH_BITS(rmnet_nss_ctx_hashtable)); - bucket = &rmnet_nss_ctx_hashtable[hash]; - hlist_for_each_entry(ctx, bucket, hnode) { - if (ctx->rmnet_dev == dev) - return ctx; - } - - return NULL; -} - -static void rmnet_nss_free_ctx(struct rmnet_nss_ctx *ctx) -{ - if (ctx) { - hash_del(&ctx->hnode); - nss_rmnet_rx_xmit_callback_unregister(ctx->nss_ctx); - nss_rmnet_rx_destroy_sync(ctx->nss_ctx); - kfree(ctx); - } -} - -/* Pull off an ethernet header, if possible */ -static int rmnet_nss_ethhdr_pull(struct sk_buff *skb) -{ - if (!skb->protocol || skb->protocol == htons(ETH_P_802_3)) { - void *ret = skb_pull(skb, sizeof(struct ethhdr)); - - rmnet_nss_inc_stat((ret) ? RMNET_NSS_RX_ETH : - RMNET_NSS_RX_FAIL); - return !ret; - } - - rmnet_nss_inc_stat(RMNET_NSS_RX_NON_ETH); - return -1; -} - -/* Copy headers to linear section for non linear packets */ -static int rmnet_nss_adjust_header(struct sk_buff *skb) -{ - struct iphdr *iph; - skb_frag_t *frag; - int bytes = 0; - u8 transport; - - if (skb_shinfo(skb)->nr_frags != 1) { - rmnet_nss_inc_stat(RMNET_NSS_TX_BAD_FRAGS); - return -EINVAL; - } - - if (skb_headlen(skb)) { - rmnet_nss_inc_stat(RMNET_NSS_TX_NON_ZERO_HEADLEN_FRAGS); - return 0; - } - - frag = &skb_shinfo(skb)->frags[0]; - - iph = (struct iphdr *)(skb_frag_address(frag)); - - if (iph->version == 4) { - bytes = iph->ihl*4; - transport = iph->protocol; - } else if (iph->version == 6) { - struct ipv6hdr *ip6h = (struct ipv6hdr *)iph; - - bytes = sizeof(struct ipv6hdr); - /* Dont have to account for extension headers yet */ - transport = ip6h->nexthdr; - } else { - rmnet_nss_inc_stat(RMNET_NSS_TX_BAD_IP); - return -EINVAL; - } - - if (transport == IPPROTO_TCP) { - struct tcphdr *th; - - th = (struct tcphdr *)((u8 *)iph + bytes); - bytes += th->doff * 4; - } else if (transport == IPPROTO_UDP) { - bytes += sizeof(struct udphdr); - } else { - /* cant do anything else here unfortunately so linearize */ - if (skb_linearize(skb)) { - rmnet_nss_inc_stat(RMNET_NSS_TX_LINEARIZE_FAILS); - return -EINVAL; - } else { - return 0; - } - } - - if (bytes > skb_frag_size(frag)) { - rmnet_nss_inc_stat(RMNET_NSS_TX_BAD_FRAGS); - return -EINVAL; - } - - skb_push(skb, bytes); - memcpy(skb->data, iph, bytes); - - /* subtract to account for skb_push */ - skb->len -= bytes; - - frag->page_offset += bytes; - skb_frag_size_sub(frag, bytes); - - /* subtract to account for skb_frag_size_sub */ - skb->data_len -= bytes; - - return 0; -} - -/* Main downlink handler - * Looks up NSS contex associated with the device. If the context is found, - * we add a dummy ethernet header with the approriate protocol field set, - * the pass the packet off to NSS for hardware acceleration. - */ -int rmnet_nss_tx(struct sk_buff *skb) -{ - struct ethhdr *eth; - struct rmnet_nss_ctx *ctx; - struct net_device *dev = skb->dev; - nss_tx_status_t rc; - unsigned int len; - u8 version; - - if (skb_is_nonlinear(skb)) { - if (rmnet_nss_adjust_header(skb)) - goto fail; - else - rmnet_nss_inc_stat(RMNET_NSS_TX_NONLINEAR); - } - - version = ((struct iphdr *)skb->data)->version; - - ctx = rmnet_nss_find_ctx(dev); - if (!ctx) { - rmnet_nss_inc_stat(RMNET_NSS_TX_NO_CTX); - return -EINVAL; - } - - eth = (struct ethhdr *)skb_push(skb, sizeof(*eth)); - memset(ð->h_dest, 0, ETH_ALEN * 2); - if (version == 4) { - eth->h_proto = htons(ETH_P_IP); - } else if (version == 6) { - eth->h_proto = htons(ETH_P_IPV6); - } else { - rmnet_nss_inc_stat(RMNET_NSS_TX_BAD_IP); - goto fail; - } - - skb->protocol = htons(ETH_P_802_3); - /* Get length including ethhdr */ - len = skb->len; - -transmit: - rc = nss_rmnet_rx_tx_buf(ctx->nss_ctx, skb); - if (rc == NSS_TX_SUCCESS) { - /* Increment rmnet_data device stats. - * Don't call rmnet_data_vnd_rx_fixup() to do this, as - * there's no guarantee the skb pointer is still valid. - */ - dev->stats.rx_packets++; - dev->stats.rx_bytes += len; - rmnet_nss_inc_stat(RMNET_NSS_TX_SUCCESS); - return 0; - } else if (rc == NSS_TX_FAILURE_QUEUE) { - rmnet_nss_inc_stat(RMNET_NSS_TX_BUSY_LOOP); - goto transmit; - } - -fail: - rmnet_nss_inc_stat(RMNET_NSS_TX_FAIL); - kfree_skb(skb); - return 1; -} - -/* Called by NSS in the DL exception case. - * Since the packet cannot be sent over the accelerated path, we need to - * handle it. Remove the ethernet header and pass it onward to the stack - * if possible. - */ -void rmnet_nss_receive(struct net_device *dev, struct sk_buff *skb, - struct napi_struct *napi) -{ - rmnet_nss_inc_stat(RMNET_NSS_EXCEPTIONS); - - if (!skb) - return; - - if (rmnet_nss_ethhdr_pull(skb)) { - rmnet_nss_inc_stat(RMNET_NSS_EX_BAD_HDR); - goto drop; - } - - /* reset header pointers */ - skb_reset_transport_header(skb); - skb_reset_network_header(skb); - skb_reset_mac_header(skb); - - /* reset packet type */ - skb->pkt_type = PACKET_HOST; - - skb->dev = dev; - - /* reset protocol type */ - switch (skb->data[0] & 0xF0) { - case 0x40: - skb->protocol = htons(ETH_P_IP); - break; - case 0x60: - skb->protocol = htons(ETH_P_IPV6); - break; - default: - rmnet_nss_inc_stat(RMNET_NSS_EX_BAD_IP); - goto drop; - } - - rmnet_nss_inc_stat(RMNET_NSS_EX_SUCCESS); - - /* Set this so that we dont loop around netif_receive_skb */ - - skb->cb[0] = 1; - - netif_receive_skb(skb); - return; - -drop: - kfree_skb(skb); -} - -/* Called by NSS in the UL acceleration case. - * We are guaranteed to have an ethernet packet here from the NSS hardware, - * We need to pull the header off and invoke our ndo_start_xmit function - * to handle transmitting the packet to the network stack. - */ -void rmnet_nss_xmit(struct net_device *dev, struct sk_buff *skb) -{ - netdev_tx_t ret; - - skb_pull(skb, sizeof(struct ethhdr)); - rmnet_nss_inc_stat(RMNET_NSS_RX_ETH); - - /* NSS takes care of shaping, so bypassing Qdiscs like this is OK */ - ret = dev->netdev_ops->ndo_start_xmit(skb, dev); - if (unlikely(ret == NETDEV_TX_BUSY)) { - dev_kfree_skb_any(skb); - rmnet_nss_inc_stat(RMNET_NSS_RX_BUSY); - } -} - -/* Create and register an NSS context for an rmnet_data device */ -int rmnet_nss_create_vnd(struct net_device *dev) -{ - struct rmnet_nss_ctx *ctx; - - ctx = kzalloc(sizeof(*ctx), GFP_ATOMIC); - if (!ctx) - return -ENOMEM; - - ctx->rmnet_dev = dev; - ctx->nss_ctx = nss_rmnet_rx_create_sync_nexthop(dev, NSS_N2H_INTERFACE, - NSS_C2C_TX_INTERFACE); - if (!ctx->nss_ctx) { - kfree(ctx); - return -1; - } - - nss_rmnet_rx_register(ctx->nss_ctx, rmnet_nss_receive, dev); - nss_rmnet_rx_xmit_callback_register(ctx->nss_ctx, rmnet_nss_xmit); - hash_add_ptr(rmnet_nss_ctx_hashtable, &ctx->hnode, dev); - return 0; -} - -/* Unregister and destroy the NSS context for an rmnet_data device */ -int rmnet_nss_free_vnd(struct net_device *dev) -{ - struct rmnet_nss_ctx *ctx; - - ctx = rmnet_nss_find_ctx(dev); - rmnet_nss_free_ctx(ctx); - - return 0; -} - -static const struct rmnet_nss_cb rmnet_nss = { - .nss_create = rmnet_nss_create_vnd, - .nss_free = rmnet_nss_free_vnd, - .nss_tx = rmnet_nss_tx, -}; - -int __init rmnet_nss_init(void) -{ - pr_err("%s(): initializing rmnet_nss\n", __func__); - RCU_INIT_POINTER(rmnet_nss_callbacks, &rmnet_nss); - return 0; -} - -void __exit rmnet_nss_exit(void) -{ - struct hlist_node *tmp; - struct rmnet_nss_ctx *ctx; - int bkt; - - pr_err("%s(): exiting rmnet_nss\n", __func__); - RCU_INIT_POINTER(rmnet_nss_callbacks, NULL); - - /* Tear down all NSS contexts */ - hash_for_each_safe(rmnet_nss_ctx_hashtable, bkt, tmp, ctx, hnode) - rmnet_nss_free_ctx(ctx); -} - -#if 0 -MODULE_LICENSE("GPL v2"); -module_init(rmnet_nss_init); -module_exit(rmnet_nss_exit); -#endif diff --git a/quectel_MHI/src/log/AT_OVER_PCIE.txt b/quectel_MHI/src/log/AT_OVER_PCIE.txt deleted file mode 100644 index bc48504..0000000 --- a/quectel_MHI/src/log/AT_OVER_PCIE.txt +++ /dev/null @@ -1,31 +0,0 @@ -root@imx6qsabresd:~# busybox microcom /dev/mhi_DUN -[ 384.652992] [I][mhi_uci_open] Node open, ref counts 1 -[ 384.658144] [I][mhi_uci_open] Starting channel -[ 384.662612] [I][__mhi_prepare_channel] Entered: preparing channel:32 -[ 384.680397] [I][mhi_dump_tre] carl_ev evt_cmd_comp code=1 -[ 384.685890] [I][__mhi_prepare_channel] Chan:32 successfully moved to start state -[ 384.693312] [I][__mhi_prepare_channel] Entered: preparing channel:33 -[ 384.708692] [I][mhi_dump_tre] carl_ev evt_cmd_comp code=1 -[ 384.714324] [I][__mhi_prepare_channel] Chan:33 successfully moved to start state - -RDY - -+CFUN: 1 - -+CPIN: READY - -+QUSIM: 1 - -+QIND: SMS DONE - -+QIND: PB DONE -ati -Quectel -EM20 -Revision: EM20GR01A01M4G - -OK -at+cpin? -+CPIN: READY - -OK diff --git a/quectel_MHI/src/log/MBIM_OVER_PCIE.txt b/quectel_MHI/src/log/MBIM_OVER_PCIE.txt deleted file mode 100644 index 927a9b2..0000000 --- a/quectel_MHI/src/log/MBIM_OVER_PCIE.txt +++ /dev/null @@ -1,145 +0,0 @@ -root@OpenWrt:~# insmod pcie_mhi.ko mhi_mbim_enabled=1 -root@OpenWrt:~# dmesg | grep mhi -[ 65.587160] mhi_init Quectel_Linux_PCIE_MHI_Driver_V1.3.0.6 -[ 65.597089] mhi_pci_probe pci_dev->name = 0000:01:00.0, domain=0, bus=1, slot=0, vendor=17CB, device=0306 -[ 65.602250] mhi_q 0000:01:00.0: BAR 0: assigned [mem 0x20300000-0x20300fff 64bit] -[ 65.611690] mhi_q 0000:01:00.0: enabling device (0140 -> 0142) -[ 65.619307] [I][mhi_init_pci_dev] msi_required = 5, msi_allocated = 5, msi_irq = 63 -[ 65.619327] [I][mhi_power_up] dev_state:RESET -[ 65.619331] [I][mhi_async_power_up] Requested to power on -[ 65.619449] [I][mhi_alloc_coherent] size = 114688, dma_handle = 6fca0000 -[ 65.619462] [I][mhi_init_dev_ctxt] mhi_ctxt->ctrl_seg = c221e000 -[ 65.619731] [I][mhi_async_power_up] dev_state:RESET ee:AMSS -[ 65.619747] [I][mhi_pm_st_worker] Transition to state:READY -[ 65.619760] [I][mhi_pm_st_worker] INVALID_EE -> AMSS -[ 65.619764] [I][mhi_ready_state_transition] Waiting to enter READY state -[ 65.619885] [I][mhi_async_power_up] Power on setup success -[ 65.619897] [I][mhi_pci_probe] Return successful -[ 65.665114] [I][mhi_ready_state_transition] Device in READY State -[ 65.665125] [I][mhi_intvec_threaded_handlr] device ee:AMSS dev_state:READY, pm_state:POR -[ 65.665131] [I][mhi_intvec_threaded_handlr] device ee:AMSS dev_state:READY, INVALID_EE -[ 65.665133] [I][mhi_tryset_pm_state] Transition to pm state from:POR to:POR -[ 65.665137] [I][mhi_init_mmio] Initializing MMIO -[ 65.665142] [I][mhi_init_mmio] CHDBOFF:0x300 -[ 65.665151] [I][mhi_init_mmio] ERDBOFF:0x700 -[ 65.665156] [I][mhi_init_mmio] Programming all MMIO values. -[ 65.786283] [I][mhi_dump_tre] carl_ev evt_state_change mhistate=2 -[ 65.786289] [I][mhi_process_ctrl_ev_ring] MHI state change event to state:M0 -[ 65.786295] [I][mhi_pm_m0_transition] Entered With State:READY PM_STATE:POR -[ 65.786300] [I][mhi_tryset_pm_state] Transition to pm state from:POR to:M0 -[ 65.789734] [I][mhi_dump_tre] carl_ev evt_ee_state execenv=2 -[ 65.789739] [I][mhi_process_ctrl_ev_ring] MHI EE received event:AMSS -[ 65.789756] [I][mhi_pm_st_worker] Transition to state:MISSION MODE -[ 65.789767] [I][mhi_pm_st_worker] INVALID_EE -> AMSS -[ 65.789771] [I][mhi_pm_mission_mode_transition] Processing Mission Mode Transition -[ 65.789787] [I][mhi_init_timesync] No timesync capability found -[ 65.789791] [I][mhi_pm_mission_mode_transition] Adding new devices -[ 65.790570] [I][mhi_dtr_probe] Enter for DTR control channel -[ 65.790577] [I][__mhi_prepare_channel] Entered: preparing channel:18 -[ 65.797036] [I][mhi_dump_tre] carl_ev evt_cmd_comp code=1 -[ 65.797051] [I][__mhi_prepare_channel] Chan:18 successfully moved to start state -[ 65.797055] [I][__mhi_prepare_channel] Entered: preparing channel:19 -[ 65.802457] [I][mhi_dump_tre] carl_ev evt_cmd_comp code=1 -[ 65.802469] [I][__mhi_prepare_channel] Chan:19 successfully moved to start state -[ 65.802485] [I][mhi_dtr_probe] Exit with ret:0 -[ 65.802748] [I][mhi_netdev_enable_iface] Prepare the channels for transfer -[ 65.802772] [I][__mhi_prepare_channel] Entered: preparing channel:100 -[ 65.825279] [I][mhi_dump_tre] carl_ev evt_cmd_comp code=1 -[ 65.825293] [I][__mhi_prepare_channel] Chan:100 successfully moved to start state -[ 65.825297] [I][__mhi_prepare_channel] Entered: preparing channel:101 -[ 65.835565] [I][mhi_dump_tre] carl_ev evt_cmd_comp code=1 -[ 65.835578] [I][__mhi_prepare_channel] Chan:101 successfully moved to start state -[ 65.839141] [I][mhi_netdev_enable_iface] Exited. -[ 65.839875] rmnet_vnd_register_device(rmnet_mhi0.1)=0 -[ 65.843278] net rmnet_mhi0 rmnet_mhi0.1: NSS context created -[ 65.861808] [I][mhi_pm_mission_mode_transition] Exit with ret:0 -[ 68.625595] [I][__mhi_prepare_channel] Entered: preparing channel:12 -[ 68.634610] [I][mhi_dump_tre] carl_ev evt_cmd_comp code=1 -[ 68.634622] [I][__mhi_prepare_channel] Chan:12 successfully moved to start state -[ 68.634625] [I][__mhi_prepare_channel] Entered: preparing channel:13 -[ 68.644978] [I][mhi_dump_tre] carl_ev evt_cmd_comp code=1 -[ 68.644987] [I][__mhi_prepare_channel] Chan:13 successfully moved to start state -[ 69.170666] net rmnet_mhi0: link_state 0x0 -> 0x1 -[ 69.177035] [I][mhi_netdev_open] Opened net dev interface -[ 71.655431] [I][mhi_netdev_open] Opened net dev interface - -root@OpenWrt:~# ./quectel-CM & -[04-02_04:14:12:134] Quectel_QConnectManager_Linux_V1.6.0.5 -[04-02_04:14:12:134] Find /sys/bus/usb/devices/4-1 idVendor=0x2c7c idProduct=0x800, bus=0x004, dev=0x002 -[04-02_04:14:12:135] network interface '' or qmidev '' is not exist -[04-02_04:14:12:135] netcard driver = pcie_mhi, driver version = V1.3.0.6 -[04-02_04:14:12:135] Modem works in MBIM mode -[04-02_04:14:12:135] apn (null), user (null), passwd (null), auth 0 -[04-02_04:14:12:135] IP Proto MBIMContextIPTypeIPv4 -[04-02_04:14:12:154] mbim_read_thread is created -sh: can't create /sys/class/net/rmnet_mhi0/mbim/link_state: nonexistent directory -[04-02_04:14:12:156] system(echo 0 > /sys/class/net/rmnet_mhi0/mbim/link_state)=256 -[04-02_04:14:12:185] system(ip address flush dev rmnet_mhi0)=0 -[04-02_04:14:12:187] system(ip link set dev rmnet_mhi0 down)=0 -[04-02_04:14:12:188] mbim_open_device() -[04-02_04:14:12:605] mbim_device_caps_query() -[04-02_04:14:12:610] DeviceId: 869710030002905 -[04-02_04:14:12:610] HardwareInfo: 0 -[04-02_04:14:12:610] mbim_set_radio_state( 1 ) -[04-02_04:14:12:613] HwRadioState: 1, SwRadioState: 1 -[04-02_04:14:12:613] mbim_subscriber_status_query() -[04-02_04:14:12:620] SubscriberReadyState NotInitialized -> Initialized -[04-02_04:14:12:620] mbim_register_state_query() -[04-02_04:14:12:625] RegisterState Unknown -> Home -[04-02_04:14:12:625] mbim_packet_service_query() -[04-02_04:14:12:629] PacketServiceState Unknown -> Attached -[04-02_04:14:12:629] mbim_query_connect(sessionID=0) -[04-02_04:14:12:633] ActivationState Unknown -> Deactivated -[04-02_04:14:12:633] mbim_set_connect(onoff=1, sessionID=0) -[ 69.170666] net rmnet_mhi0: link_state 0x0 -> 0x1 -[04-02_04:14:12:680] ActivationState Deactivated -> Activated -[ 69.177035] [I][mhi_netdev_open] Opened net dev interface -[04-02_04:14:12:680] mbim_ip_config(sessionID=0) -[04-02_04:14:12:683] < SessionId = 0 -[04-02_04:14:12:683] < IPv4ConfigurationAvailable = 0xf -[04-02_04:14:12:683] < IPv6ConfigurationAvailable = 0x0 -[04-02_04:14:12:683] < IPv4AddressCount = 0x1 -[04-02_04:14:12:683] < IPv4AddressOffset = 0x3c -[04-02_04:14:12:683] < IPv6AddressCount = 0x0 -[04-02_04:14:12:683] < IPv6AddressOffset = 0x0 -[04-02_04:14:12:683] < IPv4 = 10.129.59.93/30 -[04-02_04:14:12:683] < gw = 10.129.59.94 -[04-02_04:14:12:683] < dns1 = 211.138.180.2 -[04-02_04:14:12:683] < dns2 = 211.138.180.3 -[04-02_04:14:12:683] < ipv4 mtu = 1500 -sh: can't create /sys/class/net/rmnet_mhi0/mbim/link_state: nonexistent directory -[04-02_04:14:12:684] system(echo 1 > /sys/class/net/rmnet_mhi0/mbim/link_state)=256 -[04-02_04:14:12:689] system(ip link set dev rmnet_mhi0 up)=0 -[04-02_04:14:12:692] system(ip -4 address flush dev rmnet_mhi0)=0 -[04-02_04:14:12:694] system(ip -4 address add 10.129.59.93/30 dev rmnet_mhi0)=0 -[04-02_04:14:12:697] system(ip -4 route add default via 10.129.59.94 dev rmnet_mhi0)=0 -[04-02_04:14:12:699] system(ip -4 link set dev rmnet_mhi0 mtu 1500)=0 - -root@OpenWrt:~# ifconfig rmnet_mhi0 -rmnet_mhi0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 - UP RUNNING NOARP MTU:1500 Metric:1 - RX packets:99379 errors:0 dropped:0 overruns:0 frame:0 - TX packets:176569 errors:0 dropped:0 overruns:0 carrier:0 - collisions:0 txqueuelen:1000 - RX bytes:1528181052 (1.4 GiB) TX bytes:62467192 (59.5 MiB) - -root@OpenWrt:~# ifconfig rmnet_mhi0.1 -rmnet_mhi0.1 Link encap:UNSPEC HWaddr 02-50-F4-00-00-00-00-00-00-00-00-00-00-00-00-00 - inet addr:10.129.59.93 Mask:255.255.255.252 - inet6 addr: fe80::50:f4ff:fe00:0/64 Scope:Link - UP RUNNING NOARP MTU:1500 Metric:1 - RX packets:1089360 errors:0 dropped:0 overruns:0 frame:0 - TX packets:176581 errors:0 dropped:0 overruns:0 carrier:0 - collisions:0 txqueuelen:1000 - RX bytes:1521449058 (1.4 GiB) TX bytes:57525792 (54.8 MiB) - -# adjust CPU load balancing -root@OpenWrt:~# echo 2 > /sys/class/net/rmnet_mhi0/queues/rx-0/rps_cpus -root@OpenWrt:~# echo 4 > /sys/class/net/rmnet_mhi0.1/queues/rx-0/rps_cpus -root@OpenWrt:~# echo 2000 > /proc/sys/net/core/netdev_max_backlog -root@OpenWrt:~# cat /sys/class/net/rmnet_mhi0/queues/rx-0/rps_cpus -2 -root@OpenWrt:~# cat /sys/class/net/rmnet_mhi0.1/queues/rx-0/rps_cpus -4 -root@OpenWrt:~# cat /proc/sys/net/core/netdev_max_backlog -2000 diff --git a/quectel_MHI/src/log/QMI_OVER_PCIE.txt b/quectel_MHI/src/log/QMI_OVER_PCIE.txt deleted file mode 100644 index 14a64f9..0000000 --- a/quectel_MHI/src/log/QMI_OVER_PCIE.txt +++ /dev/null @@ -1,134 +0,0 @@ -disable ccflags-y += -DCONFIG_MHI_NETDEV_MBIM in pcie_mhi/Makefile - -root@OpenWrt:~# insmod pcie_mhi.ko - -root@OpenWrt:~# dmesg | grep mhi -[ 138.483252] mhi_init Quectel_Linux_PCIE_MHI_Driver_V1.3.0.6 -[ 138.492350] mhi_pci_probe pci_dev->name = 0000:01:00.0, domain=0, bus=1, slot=0, vendor=17CB, device=0306 -[ 138.497564] mhi_q 0000:01:00.0: BAR 0: assigned [mem 0x20300000-0x20300fff 64bit] -[ 138.506952] mhi_q 0000:01:00.0: enabling device (0140 -> 0142) -[ 138.514562] [I][mhi_init_pci_dev] msi_required = 5, msi_allocated = 5, msi_irq = 63 -[ 138.514581] [I][mhi_power_up] dev_state:RESET -[ 138.514587] [I][mhi_async_power_up] Requested to power on -[ 138.514728] [I][mhi_alloc_coherent] size = 114688, dma_handle = 72160000 -[ 138.514734] [I][mhi_init_dev_ctxt] mhi_ctxt->ctrl_seg = c221f000 -[ 138.515030] [I][mhi_async_power_up] dev_state:RESET ee:AMSS -[ 138.515056] [I][mhi_pm_st_worker] Transition to state:READY -[ 138.515067] [I][mhi_pm_st_worker] INVALID_EE -> AMSS -[ 138.515073] [I][mhi_ready_state_transition] Waiting to enter READY state -[ 138.515210] [I][mhi_async_power_up] Power on setup success -[ 138.515227] [I][mhi_pci_probe] Return successful -[ 138.589013] [I][mhi_ready_state_transition] Device in READY State -[ 138.589029] [I][mhi_intvec_threaded_handlr] device ee:AMSS dev_state:READY, pm_state:POR -[ 138.589038] [I][mhi_intvec_threaded_handlr] device ee:AMSS dev_state:READY, INVALID_EE -[ 138.589041] [I][mhi_tryset_pm_state] Transition to pm state from:POR to:POR -[ 138.589046] [I][mhi_init_mmio] Initializing MMIO -[ 138.589050] [I][mhi_init_mmio] CHDBOFF:0x300 -[ 138.589060] [I][mhi_init_mmio] ERDBOFF:0x700 -[ 138.589065] [I][mhi_init_mmio] Programming all MMIO values. -[ 138.706124] [I][mhi_dump_tre] carl_ev evt_state_change mhistate=2 -[ 138.706132] [I][mhi_process_ctrl_ev_ring] MHI state change event to state:M0 -[ 138.706140] [I][mhi_pm_m0_transition] Entered With State:READY PM_STATE:POR -[ 138.706146] [I][mhi_tryset_pm_state] Transition to pm state from:POR to:M0 -[ 138.708699] [I][mhi_dump_tre] carl_ev evt_ee_state execenv=2 -[ 138.708706] [I][mhi_process_ctrl_ev_ring] MHI EE received event:AMSS -[ 138.708726] [I][mhi_pm_st_worker] Transition to state:MISSION MODE -[ 138.708736] [I][mhi_pm_st_worker] INVALID_EE -> AMSS -[ 138.708742] [I][mhi_pm_mission_mode_transition] Processing Mission Mode Transition -[ 138.708758] [I][mhi_init_timesync] No timesync capability found -[ 138.708764] [I][mhi_pm_mission_mode_transition] Adding new devices -[ 138.709785] [I][mhi_dtr_probe] Enter for DTR control channel -[ 138.709794] [I][__mhi_prepare_channel] Entered: preparing channel:18 -[ 138.715378] [I][mhi_dump_tre] carl_ev evt_cmd_comp code=1 -[ 138.715397] [I][__mhi_prepare_channel] Chan:18 successfully moved to start state -[ 138.715403] [I][__mhi_prepare_channel] Entered: preparing channel:19 -[ 138.720201] [I][mhi_dump_tre] carl_ev evt_cmd_comp code=1 -[ 138.720218] [I][__mhi_prepare_channel] Chan:19 successfully moved to start state -[ 138.720236] [I][mhi_dtr_probe] Exit with ret:0 -[ 138.720590] [I][mhi_netdev_enable_iface] Prepare the channels for transfer -[ 138.720630] [I][__mhi_prepare_channel] Entered: preparing channel:100 -[ 138.757230] [I][mhi_dump_tre] carl_ev evt_cmd_comp code=1 -[ 138.757253] [I][__mhi_prepare_channel] Chan:100 successfully moved to start state -[ 138.757259] [I][__mhi_prepare_channel] Entered: preparing channel:101 -[ 138.774352] [I][mhi_dump_tre] carl_ev evt_cmd_comp code=1 -[ 138.774370] [I][__mhi_prepare_channel] Chan:101 successfully moved to start state -[ 138.778137] [I][mhi_netdev_enable_iface] Exited. -[ 138.779018] rmnet_vnd_register_device(rmnet_mhi0.1)=0 -[ 138.782283] net rmnet_mhi0 rmnet_mhi0.1: NSS context created -[ 138.800865] [I][mhi_pm_mission_mode_transition] Exit with ret:0 - -root@OpenWrt:~# ./quectel-CM & -root@OpenWrt:~# [04-02_04:12:16:477] Quectel_QConnectManager_Linux_V1.6.0.5 -[04-02_04:12:16:477] Find /sys/bus/usb/devices/4-1 idVendor=0x2c7c idProduct=0x800, bus=0x004, dev=0x002 -[04-02_04:12:16:478] network interface '' or qmidev '' is not exist -[04-02_04:12:16:478] netcard driver = pcie_mhi, driver version = V1.3.0.6 -[04-02_04:12:16:479] qmap_mode = 1, qmap_version = 9, qmap_size = 16384, muxid = 0x81, qmap_netcard = rmnet_mhi0.1 -[04-02_04:12:16:479] Modem works in QMI mode -[04-02_04:12:16:505] cdc_wdm_fd = 7 -[04-02_04:12:17:506] QmiThreadSendQMITimeout pthread_cond_timeout_np timeout -[04-02_04:12:18:516] Get clientWDS = 19 -[04-02_04:12:18:520] Get clientDMS = 1 -[04-02_04:12:18:524] Get clientNAS = 3 -[04-02_04:12:18:527] Get clientUIM = 1 -[04-02_04:12:18:531] Get clientWDA = 1 -[04-02_04:12:18:535] requestBaseBandVersion RM500QGLAAR03A01M4G_BETA_20200107F 1 [Dec 30 2019 17:00:00] -[04-02_04:12:18:539] qmap_settings.rx_urb_size = 16384 -[04-02_04:12:18:539] qmap_settings.ul_data_aggregation_max_datagrams = 16 -[04-02_04:12:18:539] qmap_settings.ul_data_aggregation_max_size = 8192 -[04-02_04:12:18:539] qmap_settings.dl_minimum_padding = 0 -[04-02_04:12:18:550] requestSetLoopBackState(loopback_state=1, replication_factor=14) -[04-02_04:12:18:557] requestGetSIMStatus SIMStatus: SIM_ABSENT -[04-02_04:12:18:560] requestGetProfile[1] ///0 -[04-02_04:12:18:563] requestRegistrationState2 MCC: 0, MNC: 0, PS: Detached, DataCap: UNKNOW -[04-02_04:12:18:565] requestQueryDataCall IPv4ConnectionStatus: DISCONNECTED -[04-02_04:12:18:566] ifconfig rmnet_mhi0.1 down -[04-02_04:12:18:571] ifconfig rmnet_mhi0.1 0.0.0.0 -ifconfig: SIOCSIFFLAGS: Network is down -[04-02_04:12:18:575] SetLoopBackInd: loopback_state=1, replication_factor=14 -[04-02_04:12:18:591] requestSetupDataCall WdsConnectionIPv4Handle: 0xe40182a0 -[04-02_04:12:18:601] ifconfig rmnet_mhi0 up -[04-02_04:12:18:607] ifconfig rmnet_mhi0.1 up -[04-02_04:12:18:613] you are use OpenWrt? -[04-02_04:12:18:614] should not calling udhcpc manually? -[04-02_04:12:18:614] should modify /etc/config/network as below? -[04-02_04:12:18:614] config interface wan -[04-02_04:12:18:614] option ifname rmnet_mhi0.1 -[04-02_04:12:18:614] option proto dhcp -[04-02_04:12:18:614] should use "/sbin/ifstaus wan" to check rmnet_mhi0.1 's status? -[04-02_04:12:18:614] busybox udhcpc -f -n -q -t 5 -i rmnet_mhi0.1 -udhcpc: started, v1.28.3 -udhcpc: sending discover -udhcpc: sending select for 192.168.48.171 -udhcpc: lease of 192.168.48.171 obtained, lease time 7200 -[04-02_04:12:18:809] udhcpc: ifconfig rmnet_mhi0.1 192.168.48.171 netmask 255.255.255.248 broadcast + -[04-02_04:12:18:819] udhcpc: setting default routers: 192.168.48.172 - -root@OpenWrt:~# ifconfig rmnet_mhi0 -rmnet_mhi0 Link encap:Ethernet HWaddr 02:50:F4:00:00:00 - inet6 addr: fe80::50:f4ff:fe00:0/64 Scope:Link - UP RUNNING NOARP MTU:1500 Metric:1 - RX packets:2 errors:0 dropped:0 overruns:0 frame:0 - TX packets:2 errors:0 dropped:0 overruns:0 carrier:0 - collisions:0 txqueuelen:1000 - RX bytes:608 (608.0 B) TX bytes:672 (672.0 B) - -root@OpenWrt:~# ifconfig rmnet_mhi0.1 -rmnet_mhi0.1 Link encap:UNSPEC HWaddr 02-50-F4-00-00-00-00-00-00-00-00-00-00-00-00-00 - inet addr:192.168.48.171 Mask:255.255.255.248 - inet6 addr: fe80::50:f4ff:fe00:0/64 Scope:Link - UP RUNNING NOARP MTU:1500 Metric:1 - RX packets:2 errors:0 dropped:0 overruns:0 frame:0 - TX packets:2 errors:0 dropped:0 overruns:0 carrier:0 - collisions:0 txqueuelen:1000 - RX bytes:592 (592.0 B) TX bytes:656 (656.0 B) - -# adjust CPU load balancing -root@OpenWrt:~# echo 2 > /sys/class/net/rmnet_mhi0/queues/rx-0/rps_cpus -root@OpenWrt:~# echo 4 > /sys/class/net/rmnet_mhi0.1/queues/rx-0/rps_cpus -root@OpenWrt:~# echo 2000 > /proc/sys/net/core/netdev_max_backlog -root@OpenWrt:~# cat /sys/class/net/rmnet_mhi0/queues/rx-0/rps_cpus -2 -root@OpenWrt:~# cat /sys/class/net/rmnet_mhi0.1/queues/rx-0/rps_cpus -4 -root@OpenWrt:~# cat /proc/sys/net/core/netdev_max_backlog -2000 \ No newline at end of file diff --git a/quectel_MHI/src/log/QXDM_OVER_PCIE.txt b/quectel_MHI/src/log/QXDM_OVER_PCIE.txt deleted file mode 100644 index f7cff56..0000000 --- a/quectel_MHI/src/log/QXDM_OVER_PCIE.txt +++ /dev/null @@ -1,14 +0,0 @@ -root@imx6qsabresd:~# ./QLog -p /dev/mhi_DIAG -s log & -root@imx6qsabresd:~# [000.000]QLog Version: Quectel_QLog_Linux&Android_V1.2.4 -[ 298.597963] [I][mhi_uci_open] Node open, ref counts 1 -[ 298.605601] [I][mhi_uci_open] Starting channel -[ 298.612159] [I][__mhi_prepare_channel] Entered: preparing channel:4 -[ 298.629906] [I][mhi_dump_tre] carl_ev evt_cmd_comp code=1 -[ 298.635415] [I][__mhi_prepare_channel] Chan:4 successfully moved to start state -[ 298.642749] [I][__mhi_prepare_channel] Entered: preparing channel:5 -[ 298.658043] [I][mhi_dump_tre] carl_ev evt_cmd_comp code=1 -[ 298.663543] [I][__mhi_prepare_channel] Chan:5 successfully moved to start state -[000.075]open /dev/mhi_DIAG ttyfd = 3 -[000.075]Press CTRL+C to stop catch log. -[000.096]qlog_logfile_create log/20160920_145758_0000.qmdl logfd=4 -[005.268]recv: 0M 70K 490B in 5181 msec diff --git a/quectel_SRPD_PCIE/Makefile b/quectel_SRPD_PCIE/Makefile deleted file mode 100644 index 7e0f6b5..0000000 --- a/quectel_SRPD_PCIE/Makefile +++ /dev/null @@ -1,46 +0,0 @@ -# -# Copyright (C) 2015 OpenWrt.org -# -# This is free software, licensed under the GNU General Public License v2. -# See /LICENSE for more information. -# - -include $(TOPDIR)/rules.mk - -PKG_NAME:=sprd_pcie -PKG_VERSION:=1.6 -PKG_RELEASE:=1 - -include $(INCLUDE_DIR)/kernel.mk -include $(INCLUDE_DIR)/package.mk - -define KernelPackage/sprd_pcie - SUBMENU:=WWAN Support - TITLE:=Kernel pcie driver for SPRD device - FILES:=$(PKG_BUILD_DIR)/sprd_pcie.ko - AUTOLOAD:=$(call AutoLoad,41,sprd_pcie) -endef - -define KernelPackage/sprd_pcie/description - Kernel module for register a custom pcispd platform device. -endef - -MAKE_OPTS:= \ - ARCH="$(LINUX_KARCH)" \ - CROSS_COMPILE="$(TARGET_CROSS)" \ - CXXFLAGS="$(TARGET_CXXFLAGS)" \ - M="$(PKG_BUILD_DIR)" \ - $(EXTRA_KCONFIG) - -define Build/Prepare - mkdir -p $(PKG_BUILD_DIR) - $(CP) ./src/* $(PKG_BUILD_DIR)/ -endef - -define Build/Compile - $(MAKE) -C "$(LINUX_DIR)" \ - $(MAKE_OPTS) \ - modules -endef - -$(eval $(call KernelPackage,sprd_pcie)) diff --git a/quectel_SRPD_PCIE/src/Makefile b/quectel_SRPD_PCIE/src/Makefile deleted file mode 100644 index 8fc450f..0000000 --- a/quectel_SRPD_PCIE/src/Makefile +++ /dev/null @@ -1,33 +0,0 @@ -# -# Makefile for the sprd staging modem files -# -EXTRA_CFLAGS += -Wno-error -Wno-packed-bitfield-compat -ccflags-y += -DCONFIG_SPRD_PCIE_EP_DEVICE -DCONFIG_SPRD_SIPA -DCONFIG_SPRD_ETHERNET -obj-m += sprd_pcie.o -sprd_pcie-objs := pcie/sprd_pcie_ep_device.o pcie/pcie_host_resource.o pcie/sprd_pcie_quirks.o sipc/sipc.o sipc/sblock.o sipc/sbuf.o \ - sipc/sipc_debugfs.o sipc/smem.o sipc/smsg.o sipc/spipe.o sipc/spool.o power_manager/power_manager.o \ - sipa/sipa_core.o sipa/sipa_eth.o sipa/sipa_nic.o sipa/sipa_skb_send.o sipa/sipa_skb_recv.o sipa/sipa_dummy.o sipa/sipa_debugfs.o sipa/sipa_dele_cmn.o \ - sipa/sipa_phy_v0/sipa_fifo_irq_hal.o sipa/sipa_phy_v0/sipa_common_fifo_hal.o - -PWD := $(shell pwd) -ifeq ($(ARCH),) -ARCH := $(shell uname -m) -endif -ifeq ($(CROSS_COMPILE),) -CROSS_COMPILE := -endif -ifeq ($(KDIR),) -KDIR := /lib/modules/$(shell uname -r)/build -endif - -sprd_pcie: clean - $(MAKE) ARCH=${ARCH} CROSS_COMPILE=${CROSS_COMPILE} -C $(KDIR) M=$(PWD) modules - #cp sprd_pcie.ko /tftpboot/ - -clean: - $(MAKE) ARCH=${ARCH} CROSS_COMPILE=${CROSS_COMPILE} -C $(KDIR) M=$(PWD) clean - find . -name *.o.ur-safe | xargs rm -f - -install: sprd_pcie - sudo cp sprd_pcie.ko /lib/modules/${shell uname -r}/kernel/drivers/pci/ - sudo depmod diff --git a/quectel_SRPD_PCIE/src/include/mdm_ctrl.h b/quectel_SRPD_PCIE/src/include/mdm_ctrl.h deleted file mode 100644 index 677b837..0000000 --- a/quectel_SRPD_PCIE/src/include/mdm_ctrl.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef _MDM_CTRL_H -#define _MDM_CTRL_H -/* - * For mcd driver,it offer modem_ctrl_send_abnormal_to_ap - * function for others. It means you can use this function to notify ap, - * some errors has been catched,by this way,ap will triger this error - * and to do something for recovery. - */ - -#include - -enum { - MDM_CTRL_POWER_OFF = 0, - MDM_CTRL_POWER_ON, - MDM_CTRL_WARM_RESET, - MDM_CTRL_COLD_RESET, - MDM_WATCHDOG_RESET, - MDM_ASSERT, - MDM_PANIC, - MDM_CTRL_PCIE_RECOVERY, - MDM_POWER_OFF, - MDM_CTRL_SET_CFG -}; - -void modem_ctrl_send_abnormal_to_ap(int status); -void modem_ctrl_poweron_modem(int on); -void modem_ctrl_enable_cp_event(void); -int modem_ctrl_register_notifier(struct notifier_block *nb); -void modem_ctrl_unregister_notifier(struct notifier_block *nb); - -#endif diff --git a/quectel_SRPD_PCIE/src/include/pcie-rc-sprd.h b/quectel_SRPD_PCIE/src/include/pcie-rc-sprd.h deleted file mode 100644 index 4a42963..0000000 --- a/quectel_SRPD_PCIE/src/include/pcie-rc-sprd.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef _PCIE_RC_SPRD_H -#define _PCIE_RC_SPRD_H - -#include - -enum sprd_pcie_event { - SPRD_PCIE_EVENT_INVALID = 0, - SPRD_PCIE_EVENT_LINKDOWN = 0x1, - SPRD_PCIE_EVENT_LINKUP = 0x2, - SPRD_PCIE_EVENT_WAKEUP = 0x4, -}; - -struct sprd_pcie_register_event { - u32 events; - struct platform_device *pdev; - void (*callback)(enum sprd_pcie_event event, void *data); - void *data; -}; - -/* - * SPRD PCIe root complex (e.g. UD710 SoC) can't support PCI hotplug - * capability. Therefore, the standard hotplug driver can't be used. - * - * Whenever one endpoint is plugged or powered on, the EP driver must - * call sprd_pcie_configure_device() in order to add EP device to system - * and probe EP driver. If one endpoint is unplugged or powered off, - * the EP driver must call sprd_pcie_unconfigure_device() in order to - * remove all PCI devices on PCI bus. - * - * return 0 on success, otherwise return a negative number. - */ -/* dumy sprd api */ -static inline int sprd_pcie_configure_device(struct platform_device *pdev) { return 0; } -static inline int sprd_pcie_unconfigure_device(struct platform_device *pdev) { return 0; } -static inline void sprd_pcie_teardown_msi_irq(unsigned int irq) { } -static inline void sprd_pcie_dump_rc_regs(struct platform_device *pdev) { } -static inline int sprd_pcie_register_event(struct sprd_pcie_register_event *reg) { return 0; } -static inline int sprd_pcie_deregister_event(struct sprd_pcie_register_event *reg) { return 0; } - -#ifdef CONFIG_SPRD_PCIE_AER -void sprd_pcie_alloc_irq_vectors(struct pci_dev *dev, int *irqs, int services) { } -#else -static inline void sprd_pcie_alloc_irq_vectors(struct pci_dev *dev, int *irqs, - int services) -{ -} -#endif - -#endif diff --git a/quectel_SRPD_PCIE/src/include/sipa.h b/quectel_SRPD_PCIE/src/include/sipa.h deleted file mode 100644 index 9e4c664..0000000 --- a/quectel_SRPD_PCIE/src/include/sipa.h +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef _SIPA_H_ -#define _SIPA_H_ - -#include -#include -#include - -enum sipa_evt_type { - SIPA_RECEIVE, - SIPA_ENTER_FLOWCTRL, - SIPA_LEAVE_FLOWCTRL, - SIPA_ERROR, -}; - -typedef void (*sipa_notify_cb)(void *priv, enum sipa_evt_type evt, - unsigned int data); - -enum sipa_term_type { - SIPA_TERM_PCIE0 = 0x10, - SIPA_TERM_PCIE1 = 0x11, - SIPA_TERM_PCIE2 = 0x12, - SIPA_TERM_CP0 = 0x4, - SIPA_TERM_CP1 = 0x5, - SIPA_TERM_VCP = 0x6, - - SIPA_TERM_MAX = 0x20, /* max 5-bit register */ -}; - -enum sipa_nic_id { - SIPA_NIC_BB0, - SIPA_NIC_BB1, - SIPA_NIC_BB2, - SIPA_NIC_BB3, - SIPA_NIC_BB4, - SIPA_NIC_BB5, - SIPA_NIC_BB6, - SIPA_NIC_BB7, - SIPA_NIC_BB8, - SIPA_NIC_BB9, - SIPA_NIC_BB10, - SIPA_NIC_BB11, - SIPA_NIC_MAX, -}; - -struct sk_buff *sipa_recv_skb(int *netid, int index); -bool sipa_check_recv_tx_fifo_empty(void); -int sipa_nic_open(enum sipa_term_type src, int netid, - sipa_notify_cb cb, void *priv); -void sipa_nic_close(enum sipa_nic_id nic_id); -int sipa_nic_tx(enum sipa_nic_id nic_id, enum sipa_term_type dst, - int netid, struct sk_buff *skb); -int sipa_nic_rx(int *netid, struct sk_buff **out_skb, int index); -int sipa_nic_rx_has_data(enum sipa_nic_id nic_id); -int sipa_nic_trigger_flow_ctrl_work(enum sipa_nic_id nic_id, int err); - -u32 sipa_nic_get_filled_num(void); -void sipa_nic_restore_irq(void); -void sipa_nic_set_tx_fifo_rp(u32 rptr); -#endif diff --git a/quectel_SRPD_PCIE/src/include/sipc.h b/quectel_SRPD_PCIE/src/include/sipc.h deleted file mode 100644 index fe01b64..0000000 --- a/quectel_SRPD_PCIE/src/include/sipc.h +++ /dev/null @@ -1,1154 +0,0 @@ -/* - * Copyright (C) 2012-2019 Spreadtrum Communications Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef __SIPC_H -#define __SIPC_H - -#include - -/* ****************************************************************** */ -/* SMSG interfaces */ - -/* sipc processor ID definition */ -enum { - SIPC_ID_AP = 0, /* Application Processor */ - SIPC_ID_MINIAP, /* mini AP processor */ - SIPC_ID_CPW, /* WCDMA processor */ - SIPC_ID_WCN, /* Wireless Connectivity */ - SIPC_ID_GNSS, /* Gps processor(gnss) */ - SIPC_ID_PSCP, /* Protocol stack processor */ - SIPC_ID_PM_SYS, /* Power management processor */ - SIPC_ID_NR_PHY, /* New Radio PHY processor */ - SIPC_ID_V3_PHY, /* MODEM v3 PHY processor */ - SIPC_ID_NR, /* Max processor number */ -}; - -#define SIPC_ID_LTE SIPC_ID_PSCP - -/* share-mem ring buffer short message */ -struct smsg { - u8 channel; /* channel index */ - u8 type; /* msg type */ - u16 flag; /* msg flag */ - u32 value; /* msg value */ -}; - -/* smsg channel definition */ -enum { - SMSG_CH_CTRL = 0, /* some emergency control */ - SMSG_CH_COMM, /* general communication channel */ - SMSG_CH_IMSBR_DATA, /* ims bridge data channel */ - SMSG_CH_IMSBR_CTRL, /* ims bridge control channel */ - SMSG_CH_PIPE, /* general pipe channel */ - SMSG_CH_PLOG, /* pipe for debug log/dump */ - SMSG_CH_TTY, /* virtual serial for telephony */ - SMSG_CH_DATA0, /* 2G/3G wirleless data */ - SMSG_CH_DATA1, /* 2G/3G wirleless data */ - SMSG_CH_DATA2, /* 2G/3G wirleless data */ - SMSG_CH_VBC, /* audio conrol channel */ - SMSG_CH_PLAYBACK, /* audio playback channel */ - SMSG_CH_CAPTURE, /* audio capture channel */ - SMSG_CH_MONITOR_AUDIO, /* audio monitor channel */ - SMSG_CH_CTRL_VOIP, /* audio voip conrol channel */ - SMSG_CH_PLAYBACK_VOIP, /* audio voip playback channel */ - SMSG_CH_CAPTURE_VOIP, /* audio voip capture channel */ - SMSG_CH_MONITOR_VOIP, /* audio voip monitor channel */ - SMSG_CH_DATA3, /* 2G/3G wirleless data */ - SMSG_CH_DATA4, /* 2G/3G wirleless data */ - SMSG_CH_DATA5, /* 2G/3G wirleless data */ - SMSG_CH_DIAG, /* pipe for debug log/dump */ - SMSG_CH_PM_CTRL, /* power management control */ - SMSG_CH_DUAL_SIM_PLUG, /* dual sim plug channel */ - SMSG_CH_END /* will not allow add channel in here */ -}; - -/* smsg channel definition */ -enum { - /* 2G/3G wirleless data, channel 24~39 */ - SMSG_CH_DATA_BASE = 24, - SMSG_CH_DATA6 = SMSG_CH_DATA_BASE, - SMSG_CH_DATA7, - SMSG_CH_DATA8, - SMSG_CH_DATA9, - SMSG_CH_DATA10, - SMSG_CH_DATA11, - SMSG_CH_DATA12, - SMSG_CH_DATA13, - - /* general pipe channel, channel 40~59 */ - SMSG_CH_PIPE_BASE = 40, - SMSG_CH_NV = SMSG_CH_PIPE_BASE, - SMSG_CH_DVFS, - SMSG_CH_PIPE2, - SMSG_CH_PIPE3, - - /* pipe for debug log/dump channel 60~79 */ - SMSG_CH_PLOG_BASE = 60, - SMSG_CH_PLOG0 = SMSG_CH_PLOG_BASE, - SMSG_CH_PLOG1, - SMSG_CH_PLOG2, - SMSG_CH_PLOG3, - - /* virtual serial for telephony, channel 80~99*/ - SMSG_CH_TTY_BASE = 80, - SMSG_CH_TTY0 = SMSG_CH_TTY_BASE, - SMSG_CH_TTY1, - SMSG_CH_TTY2, - SMSG_CH_TTY3, - - /* some emergency control, channel 100~119 */ - SMSG_CH_CTRL_BASE = 100, - SMSG_CH_PMSYS_DBG = SMSG_CH_CTRL_BASE, - SMSG_CH_CTRL1, - SMSG_CH_CTRL2, - SMSG_CH_CTRL3, - - /* general communication, channel 120~129 */ - SMSG_CH_COMM_BASE = 120, - SMSG_CH_COMM_SIPA = SMSG_CH_COMM_BASE, - SMSG_CH_COMM1, - SMSG_CH_COMM2, - SMSG_CH_COMM3, - - /* audio channel, channel 130 ~149 */ - SMSG_CH_AUDIO_BASE = 130, - SMSG_CH_AGDSP_ACCESS = SMSG_CH_AUDIO_BASE,/* audio conrol channel */ - SMSG_CH_PLAYBACK_DEEP, - SMSG_CH_AUDIO2, - SMSG_CH_AUDIO3, - - /* VOIP channel, channel 150 ~169 */ - SMSG_CH_VOIP_BASE = 150, - SMSG_CH_VOIP0 = SMSG_CH_VOIP_BASE,/* audio voip conrol channel */ - SMSG_CH_VOIP_DEEP, /* audio voip playback channel */ - SMSG_CH_VOIP2, /* audio voip capture channel */ - SMSG_CH_VOIP3, /* audio voip monitor channel */ - - /* RPC server channel, channel 170~189 */ - SMSG_CH_RPC_BASE = 170, - SMSG_CH_RPC0 = SMSG_CH_RPC_BASE, - SMSG_CH_RPC1, - SMSG_CH_RPC2, - SMSG_CH_RPC3, - - /* RESERVE group 1, channel 190 ~209 */ - SMSG_CH_RESERVE1_BASE = 190, - - /* RESERVE group 2, channel 210 ~129 */ - SMSG_CH_RESERVE2_BASE = 210, - - /* RESERVE group 3, channel 230 ~244 */ - SMSG_CH_RESERVE3_BASE = 230, - - /* RESERVE group 4, channel 245 ~254 */ - SMSG_CH_RESERVE4_BASE = 245, - - /* total channel number 255, the max chanel number is 254*/ - SMSG_CH_NR = 255 -}; -#define INVALID_CHANEL_INDEX SMSG_CH_NR - -/* modem type */ -enum { - SOC_MODEM = 0, - PCIE_MODEM, -}; - -/* only be configed in sipc_config is valid channel */ -struct sipc_config { - u8 channel; - char *name; -}; - -static const struct sipc_config sipc_cfg[] = { - {SMSG_CH_CTRL, "com control"}, /* chanel 0 */ - {SMSG_CH_COMM, "com communication"}, /* chanel 1 */ - {SMSG_CH_PM_CTRL, "pm contrl"}, /* chanel 22 */ - {SMSG_CH_PMSYS_DBG, "pm debug contrl"}, /* chanel 100 */ - {SMSG_CH_DUAL_SIM_PLUG, "dual sim plug"}, /* chanel 23 */ - {SMSG_CH_PIPE, "pipe0"}, /* chanel 4 */ - {SMSG_CH_PLOG, "plog"}, /* chanel 5 */ - {SMSG_CH_DIAG, "diag"}, /* chanel 21 */ - {SMSG_CH_TTY, "stty chanel"}, /* chanel 6 */ - {SMSG_CH_DATA0, "seth0"}, /* chanel 7 */ - {SMSG_CH_DATA1, "seth1"}, /* chanel 8 */ - {SMSG_CH_DATA2, "seth2"}, /* chanel 9 */ - {SMSG_CH_DATA3, "seth3"}, /* chanel 18 */ - {SMSG_CH_DATA4, "seth4"}, /* chanel 19 */ - {SMSG_CH_DATA5, "seth5"}, /* chanel 20 */ - {SMSG_CH_DATA6, "seth6"}, /* chanel 24 */ - {SMSG_CH_DATA7, "seth7"}, /* chanel 25 */ - {SMSG_CH_DATA8, "seth8"}, /* chanel 26 */ - {SMSG_CH_DATA9, "seth9"}, /* chanel 27 */ - {SMSG_CH_DATA10, "seth10"}, /* chanel 28 */ - {SMSG_CH_DATA11, "seth11"}, /* chanel 29 */ - {SMSG_CH_DATA12, "seth12"}, /* chanel 30 */ - {SMSG_CH_DATA13, "seth13"}, /* chanel 31 */ - {SMSG_CH_VBC, "audio control"}, /* chanel 10 */ - {SMSG_CH_PLAYBACK, "audio playback"}, /* chanel 11 */ - {SMSG_CH_CAPTURE, "audio capture"}, /* chanel 12 */ - {SMSG_CH_MONITOR_AUDIO, "audio monitor"}, /* chanel 13 */ - {SMSG_CH_AGDSP_ACCESS, "agdsp access"}, /* chanel 13 */ - {SMSG_CH_CTRL_VOIP, "VOIP conrol"}, /* chanel 14 */ - {SMSG_CH_PLAYBACK_VOIP, "VOIP playback"}, /* chanel 15 */ - {SMSG_CH_CAPTURE_VOIP, "VOIP capture"}, /* chanel 16 */ - {SMSG_CH_MONITOR_VOIP, "VOIP monitor"}, /* chanel 17 */ - {SMSG_CH_PLAYBACK_DEEP, "audio playback deep"}, /*channel 131*/ - {SMSG_CH_IMSBR_DATA, "imsbr data"}, /* chanel 2 */ - {SMSG_CH_IMSBR_CTRL, "imsbr control"}, /* channel 3 */ - {SMSG_CH_VOIP_DEEP, "audio voip deep"}, /*channel 151*/ - {SMSG_CH_DVFS, "dvfs"}, /* channel 41 */ - {SMSG_CH_COMM_SIPA, "sipa"}, /* channel 120 */ - {SMSG_CH_NV, "nvsync"}, /* channel 40 */ -}; - -#define SMSG_VALID_CH_NR (sizeof(sipc_cfg)/sizeof(struct sipc_config)) - - -/* smsg type definition */ -enum { - SMSG_TYPE_NONE = 0, - SMSG_TYPE_OPEN, /* first msg to open a channel */ - SMSG_TYPE_CLOSE, /* last msg to close a channel */ - SMSG_TYPE_DATA, /* data, value=addr, no ack */ - SMSG_TYPE_EVENT, /* event with value, no ack */ - SMSG_TYPE_CMD, /* command, value=cmd */ - SMSG_TYPE_DONE, /* return of command */ - SMSG_TYPE_SMEM_ALLOC, /* allocate smem, flag=order */ - SMSG_TYPE_SMEM_FREE, /* free smem, flag=order, value=addr */ - SMSG_TYPE_SMEM_DONE, /* return of alloc/free smem */ - SMSG_TYPE_FUNC_CALL, /* RPC func, value=addr */ - SMSG_TYPE_FUNC_RETURN, /* return of RPC func */ - SMSG_TYPE_DIE, - SMSG_TYPE_DFS, - SMSG_TYPE_DFS_RSP, - SMSG_TYPE_ASS_TRG, - SMSG_TYPE_HIGH_OFFSET, /* client sipc get high offset from host */ - SMSG_TYPE_NR, /* total type number */ -}; - -/* flag for OPEN/CLOSE msg type */ -#define SMSG_OPEN_MAGIC 0xBEEE -#define SMSG_CLOSE_MAGIC 0xEDDD - -/** -* sipc_get_wakeup_flag -* after the wakeup flag be set, the fist smsg will be print -* @parameters: void -* @return: int -*/ -int sipc_get_wakeup_flag(void); - -/** -* sipc_set_wakeup_flag -* after the wakeup flag be set, the fist smsg will be print -* @parameters: void -* @return: no return value -*/ -void sipc_set_wakeup_flag(void); - -/** -* sipc_clear_wakeup_flag -* clear the wake up flag -* @parameters: void -* @return: no return value -*/ -void sipc_clear_wakeup_flag(void); - -/** - * smsg_ch_open -- open a channel for smsg - * - * @dst: dest processor ID - * @channel: channel ID - * @timeout: milliseconds, 0 means no wait, -1 means unlimited - * @return: 0 on success, <0 on failure - */ -int smsg_ch_open(u8 dst, u8 channel, int timeout); - -/** - * smsg_ch_close -- close a channel for smsg - * - * @dst: dest processor ID - * @channel: channel ID - * @timeout: milliseconds, 0 means no wait, -1 means unlimited - * @return: 0 on success, <0 on failure - */ -int smsg_ch_close(u8 dst, u8 channel, int timeout); - - /** - * smsg_senddie -- send a MSG_TYPE_DIE message to pubcp - * - * @dst: dest processor ID - * @return: 0 on success, <0 on failure - */ -int smsg_senddie(u8 dst); - -/** - * smsg_send -- send smsg - * - * @dst: dest processor ID - * @msg: smsg body to be sent - * @timeout: milliseconds, 0 means no wait, -1 means unlimited - * @return: 0 on success, <0 on failure - */ -int smsg_send(u8 dst, struct smsg *msg, int timeout); - -/** - * smsg_recv -- poll and recv smsg - * - * @dst: dest processor ID - * @msg: smsg body to be received, channel should be filled as input - * @timeout: milliseconds, 0 means no wait, -1 means unlimited - * @return: 0 on success, <0 on failure - */ -int smsg_recv(u8 dst, struct smsg *msg, int timeout); - -/** - * sipc_channel2index - * - * only be configed in sipc_config is valid channel - * @ch: channel number - * @return: channel index ,if return index is INVALID_CHANEL_INDEX , - * it indicate it is a invalid chanel - */ -u8 sipc_channel2index(u8 ch); - -int smsg_ch_wake_unlock(u8 dst, u8 channel); - -#if defined(CONFIG_DEBUG_FS) -void sipc_debug_putline(struct seq_file *m, char c, int n); -#endif - -/* quickly fill a smsg body */ -static inline void smsg_set(struct smsg *msg, u8 channel, - u8 type, u16 flag, u32 value) -{ - msg->channel = channel; - msg->type = type; - msg->flag = flag; - msg->value = value; -} - -/* ack an open msg for modem recovery */ -static inline void smsg_open_ack(u8 dst, u16 channel) -{ - struct smsg mopen; - - pr_info("%s: channel %d-%d!\n", __func__, dst, channel); - smsg_set(&mopen, channel, SMSG_TYPE_OPEN, SMSG_OPEN_MAGIC, 0); - smsg_send(dst, &mopen, -1); -} - -/* ack an close msg for modem recovery */ -static inline void smsg_close_ack(u8 dst, u16 channel) -{ - struct smsg mclose; - - pr_info("%s: channel %d-%d!\n", __func__, dst, channel); - smsg_set(&mclose, channel, SMSG_TYPE_CLOSE, SMSG_CLOSE_MAGIC, 0); - smsg_send(dst, &mclose, -1); -} - -/* ****************************************************************** */ -/* SMEM interfaces */ -/** - * smem_get_area -- get sipc smem - * - * @dst: dest processor ID - * @base: base pointer - * @size: size pointer - * @return: 0 success, < 0 failed - */ -int smem_get_area(u8 dst, u32 *base, u32 *size); - -/** - * smem_alloc -- allocate shared memory block - * - * @dst: dest processor ID - * @size: size to be allocated, page-aligned - * @return: phys addr or 0 if failed - */ -u32 smem_alloc(u8 dst, u32 size); - -/** - * smem_free -- free shared memory block - * - * @dst: dest processor ID - * @addr: smem phys addr to be freed - * @order: size to be freed - */ -void smem_free(u8 dst, u32 addr, u32 size); - -/** - * shmem_ram_unmap -- for sipc unmap ram address - * - * @mem: vir mem - */ -void shmem_ram_unmap(u8 dst, const void *mem); - -/** - * shmem_ram_vmap_nocache -- for sipc map ram address - * - * @start: start address - * @size: size to be allocated, page-aligned - * @return: phys addr or 0 if failed - */ -void *shmem_ram_vmap_nocache(u8 dst, phys_addr_t start, size_t size); - -/** - * shmem_ram_vmap_cache -- for sipc map ram address - * - * @start: start address - * @size: size to be allocated, page-aligned - * @return: phys addr or 0 if failed - */ -void *shmem_ram_vmap_cache(u8 dst, phys_addr_t start, size_t size); - -void smem_free(u8 dst, u32 addr, u32 size); - -/** - * modem_ram_unmap -- for modem unmap ram address - * - * @mem: vir mem - * @modem_type: soc modem, pcie modem - */ -void modem_ram_unmap(u32 modem_type, const void *mem); - -/** - * shmem_ram_vmap_nocache -- for modem map ram address - * - * @modem_type: soc modem, pcie modem - * @start: start address - * @size: size to be allocated, page-aligned - * @return: phys addr or 0 if failed - */ -void *modem_ram_vmap_nocache(u32 modem_type, phys_addr_t start, size_t size); - -/** - * modem_ram_vmap_cache -- for modem map ram address - * - * @modem_type: soc modem, pcie modem - * @start: start address - * @size: size to be allocated, page-aligned - * @return: phys addr or 0 if failed - */ -void *modem_ram_vmap_cache(u32 modem_type, phys_addr_t start, size_t size); -/** - * sbuf_set_no_need_wake_lock - * - * @dst: dest processor ID - * @bufnum: which buffer to be set - * @return: none - */ - -void sbuf_set_no_need_wake_lock(u8 dst, u8 channel, u32 bufnum); - -/** - * sbuf_create -- create pipe ring buffers on a channel - * - * @dst: dest processor ID - * @channel: channel ID - * @txbufsize: tx buffer size - * @rxbufsize: rx buffer size - * @bufnum: how many buffers to be created - * @return: 0 on success, <0 on failure - */ - -int sbuf_create(u8 dst, u8 channel, u32 bufnum, - u32 txbufsize, u32 rxbufsize); - -/** - * sbuf_destroy -- destroy the pipe ring buffers on a channel - * - * @dst: dest processor ID - * @channel: channel ID - * @return: 0 on success, <0 on failure - */ -void sbuf_destroy(u8 dst, u8 channel); -void sbuf_down(u8 dst, u8 channel); - -/** - * sbuf_write -- write data to a sbuf - * - * @dst: dest processor ID - * @channel: channel ID - * @bufid: buffer ID - * @buf: data to be written - * @len: data length - * @timeout: milliseconds, 0 means no wait, -1 means unlimited - * @return: written bytes on success, <0 on failure - */ -int sbuf_write(u8 dst, u8 channel, u32 bufid, - void *buf, u32 len, int timeout); - -/** - * sbuf_read -- write data to a sbuf - * - * @dst: dest processor ID - * @channel: channel ID - * @bufid: buffer ID - * @buf: data to be written - * @len: data length - * @timeout: milliseconds, 0 means no wait, -1 means unlimited - * @return: read bytes on success, <0 on failure - */ -int sbuf_read(u8 dst, u8 channel, u32 bufid, - void *buf, u32 len, int timeout); - -/** - * sbuf_poll_wait -- poll sbuf read/write, used in spipe driver - * - * @dst: dest processor ID - * @channel: channel ID - * @bufid: buffer ID - * @file: struct file handler - * @wait: poll table - * @return: POLLIN or POLLOUT - */ -int sbuf_poll_wait(u8 dst, u8 channel, u32 bufid, - struct file *file, poll_table *wait); - -/** - * sbuf_status -- get sbuf status - * - * @dst: dest processor ID - * @channel: channel ID - * @return: 0 when ready, <0 when broken - */ -int sbuf_status(u8 dst, u8 channel); - -#define SBUF_NOTIFY_READY 0x00 -#define SBUF_NOTIFY_READ 0x01 -#define SBUF_NOTIFY_WRITE 0x02 -/** - * sbuf_register_notifier -- register a callback that's called - * when a tx sbuf is available or a rx sbuf is received. - * non-blocked sbuf_read can be called. - * - * @dst: dest processor ID - * @channel: channel ID - * @bufid: buf ID - * @handler: a callback handler - * @event: NOTIFY_READ, NOTIFY_WRITE, or both - * @data: opaque data passed to the receiver - * @return: 0 on success, <0 on failure - */ -int sbuf_register_notifier(u8 dst, u8 channel, u32 bufid, - void (*handler)(int event, void *data), void *data); - - -int sipc_init(void); -void sipc_exit(void); - -int spipe_init(void); -void spipe_exit(void); -void spipe_device_down(void); -void spool_device_down(void); - -int spool_init(void); -void spool_exit(void); - -int modem_power_manager_init(void); -void modem_power_manager_exit(void); - -#if 0 -int modem_ctrl_init(void); -void modem_ctrl_exit(void); -#endif - -int sipc_init_debugfs(void); - -/* ****************************************************************** */ -/* SBLOCK interfaces */ - -/* sblock structure: addr is the uncached virtual address */ -struct sblock { - void *addr; - u32 length; -#ifdef CONFIG_SPRD_SIPC_ZERO_COPY_SIPX - u16 index; - u16 offset; -#endif -}; - -/** - * sblock_create -- create sblock manager on a channel - * - * @dst: dest processor ID - * @channel: channel ID - * @txblocknum: tx block number - * @txblocksize: tx block size - * @rxblocknum: rx block number - * @rxblocksize: rx block size - * @return: 0 on success, <0 on failure - */ -int sblock_create(u8 dst, u8 channel, - u32 txblocknum, u32 txblocksize, - u32 rxblocknum, u32 rxblocksize); - -/** - * sblock_create_ex -- merge sblock_create and block_register_notifier - * in one function - * - * @dst: dest processor ID - * @channel: channel ID - * @txblocknum: tx block number - * @txblocksize: tx block size - * @rxblocknum: rx block number - * @rxblocksize: rx block size - * @event: SBLOCK_NOTIFY_GET, SBLOCK_NOTIFY_RECV, or both - * @data: opaque data passed to the receiver - * @return: 0 on success, <0 on failure - */ -int sblock_create_ex(u8 dst, u8 channel, - u32 txblocknum, u32 txblocksize, - u32 rxblocknum, u32 rxblocksize, - void (*handler)(int event, void *data), void *data); - -/* sblock_pcfg_create -- create preconfigured SBLOCK channel. - * - * @dst: dest processor ID - * @channel: channel ID - * @tx_blk_num: tx block number - * @tx_blk_sz: tx block size - * @rx_blk_num: rx block number - * @rx_blk_sz: rx block size - * @return: 0 on success, <0 on failure - * - * The function only allocates the memory for the channel, and will not - * open the channel. The client shall open the channel using - * sblock_pcfg_open and close the channel using sblock_close. - */ -int sblock_pcfg_create(u8 dst, u8 channel, - u32 tx_blk_num, u32 tx_blk_sz, - u32 rx_blk_num, u32 rx_blk_sz); - -/* sblock_pcfg_open -- request to open preconfigured SBLOCK channel. - * - * @dst: dest processor ID - * @channel: channel ID - * @notifier: the event notification callback function. This function can - * not sleep. If this parameter is NULL, no event will be - * reported. - * @event: SBLOCK_NOTIFY_GET, SBLOCK_NOTIFY_RECV, or both - * @client: opaque data passed to the receiver - * @return: if the channel is established, return 0; if the open procedure - * is started and not finished, return SIPC_ERR_IN_PROGRESS; - * otherwise return a negative error code. - * - * The function starts the open procedure. If the open procedure is not - * finished when the function returns, the SBLOCK system will report - * the open result later through the notifier callback. - */ -int sblock_pcfg_open(uint8_t dest, uint8_t channel, - void (*notifier)(int event, void *client), - void *client); - -/* sblock_close -- request to close SBLOCK channel. - * - * @dst: dest processor ID - * @channel: channel ID - * @return: if the channel is closed, return 0; if the close procedure - * is started and not finished, return SIPC_ERR_IN_PROGRESS; - * otherwise return a negative error code. - * - * The function starts the close procedure. If the close procedure is not - * finished when the function returns, the SBLOCK system will report - * the close result later through the notification callback that the - * client set by sblock_pcfg_open. - */ -int sblock_close(uint8_t dest, uint8_t channel); - -/* sblock_get_smem_cp_addr - get the shared memory CP address. - * @dest: destination ID - * @channel: channel number - * @paddr: pointer to the variable to receive the address. - */ -int sblock_get_smem_cp_addr(uint8_t dest, uint8_t channel, - uint32_t *paddr); -/** - * sblock_destroy -- destroy sblock manager on a channel - * - * @dst: dest processor ID - * @channel: channel ID - */ -void sblock_destroy(u8 dst, u8 channel); -void sblock_down(u8 dst, u8 channel); - -#define SBLOCK_NOTIFY_GET 0x01 -#define SBLOCK_NOTIFY_RECV 0x02 -#define SBLOCK_NOTIFY_STATUS 0x04 -#define SBLOCK_NOTIFY_OPEN 0x08 -#define SBLOCK_NOTIFY_CLOSE 0x10 -#define SBLOCK_NOTIFY_OPEN_FAILED 0x20 - -/** - * sblock_register_notifier -- register a callback that's called - * when a tx sblock is available or a rx block is received. - * non-blocked sblock_get or sblock_receive can be called. - * - * @dst: dest processor ID - * @channel: channel ID - * @handler: a callback handler - * @event: SBLOCK_NOTIFY_GET, SBLOCK_NOTIFY_RECV, or both - * @data: opaque data passed to the receiver - * @return: 0 on success, <0 on failure - */ -int sblock_register_notifier(u8 dst, u8 channel, - void (*handler)(int event, void *data), void *data); - -/** - * sblock_get -- get a free sblock for sender - * - * @dst: dest processor ID - * @channel: channel ID - * @blk: return a gotten sblock pointer - * @timeout: milliseconds, 0 means no wait, -1 means unlimited - * @return: 0 on success, <0 on failure - */ -int sblock_get(u8 dst, u8 channel, struct sblock *blk, int timeout); - -/** - * sblock_send -- send a sblock with smsg, it should be from sblock_get - * - * @dst: dest processor ID - * @channel: channel ID - * @blk: the sblock to be sent - * @return: 0 on success, <0 on failure - */ -int sblock_send(u8 dst, u8 channel, struct sblock *blk); - -/** - * sblock_send_prepare -- send a sblock without smsg, - * it should be from sblock_get - * - * @dst: dest processor ID - * @channel: channel ID - * @blk: the sblock to be sent - * @return: 0 on success, <0 on failure - */ -int sblock_send_prepare(u8 dst, u8 channel, struct sblock *blk); - -/** - * sblock_send_finish -- trigger an smsg to notify that sblock has been sent - * - * @dst: dest processor ID - * @channel: channel ID - * @return: 0 on success, <0 on failure - */ -int sblock_send_finish(u8 dst, u8 channel); - -/** - * sblock_receive -- receive a sblock, it should be released after it's handled - * - * @dst: dest processor ID - * @channel: channel ID - * @blk: return a received sblock pointer - * @timeout: milliseconds, 0 means no wait, -1 means unlimited - * @return: 0 on success, <0 on failure - */ -int sblock_receive(u8 dst, u8 channel, - struct sblock *blk, int timeout); - -/** - * sblock_release -- release a sblock from reveiver - * - * @dst: dest processor ID - * @channel: channel ID - * @return: 0 on success, <0 on failure - */ -int sblock_release(u8 dst, u8 channel, struct sblock *blk); - -/** - * sblock_get_arrived_count -- get the count of sblock(s) arrived at - * AP (sblock_send on CP) but not received (sblock_receive on AP). - * - * @dst: dest processor ID - * @channel: channel ID - * @return: >=0 the count of blocks - */ -int sblock_get_arrived_count(u8 dst, u8 channel); - - - -/** - * sblock_get_free_count -- get the count of available sblock(s) resident in - * sblock pool on AP. - * - * @dst: dest processor ID - * @channel: channel ID - * @return: >=0 the count of blocks - */ -int sblock_get_free_count(u8 dst, u8 channel); - - -/** - * sblock_put -- put a free sblock for sender - * - * @dst: dest processor ID - * @channel: channel ID - * @blk: sblock pointer - * @return: void - */ -void sblock_put(u8 dst, u8 channel, struct sblock *blk); - -/** - * sblock_poll_wait -- poll sblock read/write - * - * @dst: dest processor ID - * @channel: channel ID - * @filp: strcut file handle - * @wait: poll table - * @return: POLLIN or POLLOUT - */ -unsigned int sblock_poll_wait(u8 dst, u8 channel, struct file *filp, poll_table *wait); - -/** - * sblock_query -- sblock query status - * - * @dst: dest processor ID - * @channel: channel ID - * @return: 0 on success, <0 on failure - */ -int sblock_query(u8 dst, u8 channel); - - -/* ****************************************************************** */ - -#define SIPX_ACK_BLK_LEN (100) - -/** - * sipx_chan_create -- create a sipx channel - * - * @dst: dest processor ID - * @channel: channel ID - * @return: 0 on success, <0 on failure - */ -int sipx_chan_create(u8 dst, u8 channel); - -/** - * sipx_chan_destroy -- destroy seblock manager on a channel - * - * @dst: dest processor ID - * @channel: channel ID - */ -int sipx_chan_destroy(u8 dst, u8 channel); - -/** - * sipx_get_ack_blk_len -- get sipx ack block max length - * - * @dst: dest processor ID - * @return: length - */ -u32 sipx_get_ack_blk_len(u8 dst); - -/** - * sipx_get -- get a free sblock for sender - * - * @dst: dest processor ID - * @channel: channel ID - * @blk: return a gotten sblock pointer - * @is_ack: if want to get block for ack packet - * @return: 0 on success, <0 on failure - */ -int sipx_get(u8 dst, u8 channel, struct sblock *blk, int is_ack); - -/** - * sipx_chan_register_notifier -- register a callback that's called - * when a tx sblock is available or a rx block is received. - * on-blocked sblock_get or sblock_receive can be called. - * - * @dst: dest processor ID - * @channel: channel ID - * @handler: a callback handler - * @event: SBLOCK_NOTIFY_GET, SBLOCK_NOTIFY_RECV, or both - * @data: opaque data passed to the receiver - * @return: 0 on success, <0 on failure - */ -int sipx_chan_register_notifier(u8 dst, u8 channel, - void (*handler)(int event, void *data), void *data); - -/** - * sipx_send -- send a sblock with smsg, it should be from seblock_get - * - * @dst: dest processor ID - * @channel: channel ID - * @blk: the sblock to be sent - * @return: 0 on success, <0 on failure - */ -int sipx_send(u8 dst, u8 channel, struct sblock *blk); - -/** - * sipx_flush -- trigger an smsg to notify that sblock has been sent - * - * @dst: dest processor ID - * @channel: channel ID - * @return: 0 on success, <0 on failure - */ -int sipx_flush(u8 dst, u8 channel); - -/** - * sipx_receive -- receive a sblock, it should be released after it's handled - * - * @dst: dest processor ID - * @channel: channel ID - * @blk: return a received sblock pointer - * @return: 0 on success, <0 on failure - */ -int sipx_receive(u8 dst, u8 channel, struct sblock *blk); - -/** - * sipx_release -- release a sblock from reveiver - * - * @dst: dest processor ID - * @channel: channel ID - * @return: 0 on success, <0 on failure - */ -int sipx_release(u8 dst, u8 channel, struct sblock *blk); - -/** - * sipx_get_arrived_count -- get the count of sblock(s) arrived at - * AP (sblock_send on CP) but not received (sblock_receive on AP). - * - * @dst: dest processor ID - * @channel: channel ID - * @return: >=0 the count of blocks - */ -int sipx_get_arrived_count(u8 dst, u8 channel); - -/** - * sipx_get_free_count -- get the count of available sblock(s) resident in - * normal pool on AP. - * - * @dst: dest processor ID - * @channel: channel ID - * @return: >=0 the count of blocks - */ -int sipx_get_free_count(u8 dst, u8 channel); - -/** - * sipx_put -- put a free sblock for sender - * - * @dst: dest processor ID - * @channel: channel ID - * @blk: sblock pointer - * @return: void - */ -int sipx_put(u8 dst, u8 channel, struct sblock *blk); - -/* ****************************************************************** */ - -#ifdef CONFIG_SPRD_SIPC_ZERO_COPY_SIPX - -#define SBLOCK_CREATE(dst, channel,\ - txblocknum, txblocksize, txpoolsize, \ - rxblocknum, rxblocksize, rxpoolsize) \ -sipx_chan_create(dst, channel) - - -#define SBLOCK_DESTROY(dst, channel) \ - sipx_chan_destroy(dst, channel) - -#define SBLOCK_GET(dst, channel, blk, ack, timeout) \ - sipx_get(dst, channel, blk, ack) - -#define SBLOCK_REGISTER_NOTIFIER(dst, channel, handler, data) \ - sipx_chan_register_notifier(dst, channel, handler, data) - -#define SBLOCK_SEND(dst, channel, blk) \ - sipx_send(dst, channel, blk) - -#define SBLOCK_SEND_PREPARE(dst, channel, blk) \ - sipx_send(dst, channel, blk) - -#define SBLOCK_SEND_FINISH(dst, channel)\ - sipx_flush(dst, channel) - -#define SBLOCK_RECEIVE(dst, channel, blk, timeout) \ - sipx_receive(dst, channel, blk) - -#define SBLOCK_RELEASE(dst, channel, blk) \ - sipx_release(dst, channel, blk) - -#define SBLOCK_GET_ARRIVED_COUNT(dst, channel) \ - sipx_get_arrived_count(dst, channel) - -#define SBLOCK_GET_FREE_COUNT(dst, channel) \ - sipx_get_free_count(dst, channel) - -#define SBLOCK_PUT(dst, channel, blk) \ - sipx_put(dst, channel, blk) - - -#else /* CONFIG_SPRD_SIPC_ZERO_COPY_SIPX */ - -#define SBLOCK_CREATE(dst, channel,\ - txblocknum, txblocksize, txpoolsize, \ - rxblocknum, rxblocksize, rxpoolsize) \ -sblock_create(dst, channel,\ - txblocknum, txblocksize,\ - rxblocknum, rxblocksize) - -#define SBLOCK_DESTROY(dst, channel) \ - sblock_destroy(dst, channel) - -#define SBLOCK_GET(dst, channel, blk, ack, timeout) \ - sblock_get(dst, channel, blk, timeout) - -#define SBLOCK_REGISTER_NOTIFIER(dst, channel, handler, data) \ - sblock_register_notifier(dst, channel, handler, data) - -#define SBLOCK_SEND(dst, channel, blk) \ - sblock_send(dst, channel, blk) - -#define SBLOCK_SEND_PREPARE(dst, channel, blk) \ - sblock_send_prepare(dst, channel, blk) - -#define SBLOCK_SEND_FINISH(dst, channel)\ - sblock_send_finish(dst, channel) - -#define SBLOCK_RECEIVE(dst, channel, blk, timeout) \ - sblock_receive(dst, channel, blk, timeout) - -#define SBLOCK_RELEASE(dst, channel, blk) \ - sblock_release(dst, channel, blk) - -#define SBLOCK_GET_ARRIVED_COUNT(dst, channel) \ - sblock_get_arrived_count(dst, channel) - -#define SBLOCK_GET_FREE_COUNT(dst, channel) \ - sblock_get_free_count(dst, channel) - -#define SBLOCK_PUT(dst, channel, blk) \ - sblock_put(dst, channel, blk) - -#endif /* CONFIG_SPRD_SIPC_ZERO_COPY_SIPX */ - -#ifdef CONFIG_ARM64 -/** - * unalign_copy_from_user -- unaligned data accesses to addresses - * marked as device will always trigger an exception, this fuction - * can avoid this exception - * - * @to: dest, normal memory - * @from: src, device memory and alignment access must be considered - * @n: bytes - * @return: bytes not copied - */ -static inline unsigned long unalign_copy_to_user(void __user *to, - const void *from, - unsigned long n) -{ - /* from is not 8 byte aligned and n is less than 16 bytes */ - if (((unsigned long)from & 7) && (n < 16)) { - while (n) { - if (copy_to_user(to++, from++, 1)) - break; - n--; - } - return n; - } - - return copy_to_user(to, from, n); -} - -/** - * unalign_copy_from_user -- unaligned data accesses to addresses - * marked as device will always trigger an exception, this fuction - * can avoid this exception - * - * @to: dest, device memory and alignment access must be considered - * @from: src, normal memory - * @n: bytes - * @return: bytes not copied - */ -static inline unsigned long unalign_copy_from_user(void *to, - const void __user *from, - unsigned long n) -{ - unsigned c1, c2, c3; - - /* to is 8 byte aligned and n is less than 16 bytes */ - c1 = !((unsigned long)to & 0x7) && (n < 16); - if (c1) - return copy_from_user(to, from, n); - - /* to and from are 8 byte aligned */ - c2 = !((unsigned long)to & 0x7) && !((unsigned long)from & 0x7); - if (c2) - return copy_from_user(to, from, n); - - /* to and from are the same offset and n is more than 15 bytes */ - c3 = !(((unsigned long)to ^ (unsigned long)from) & 0x7) && (n > 15); - if (c3) - return copy_from_user(to, from, n); - - while (n) { - if (copy_from_user(to++, from++, 1)) - break; - n--; - } - - return n; -} - -static inline void unalign_memcpy(void *to, const void *from, size_t n) -{ - if (((unsigned long)to & 7) == ((unsigned long)from & 7)) { - while (((unsigned long)from & 7) && n) { - *(char *)(to++) = *(char *)(from++); - n--; - } - memcpy(to, from, n); - } else if (((unsigned long)to & 3) == ((unsigned long)from & 3)) { - while (((unsigned long)from & 3) && n) { - *(char *)(to++) = *(char *)(from++); - n--; - } - while (n >= 4) { - *(u32 *)(to) = *(u32 *)(from); - to += 4; - from += 4; - n -= 4; - } - while (n) { - *(char *)(to++) = *(char *)(from++); - n--; - } - } else { - while (n) { - *(char *)(to++) = *(char *)(from++); - n--; - } - } -} -#else -static inline unsigned long unalign_copy_to_user(void __user *to, - const void *from, - unsigned long n) -{ - return copy_to_user(to, from, n); -} -static inline unsigned long unalign_copy_from_user(void *to, - const void __user *from, - unsigned long n) -{ - return copy_from_user(to, from, n); -} -static inline void *unalign_memcpy(void *to, const void *from, size_t n) -{ - return memcpy(to, from, n); -} -#endif - -#endif diff --git a/quectel_SRPD_PCIE/src/include/sipc_big_to_little.h b/quectel_SRPD_PCIE/src/include/sipc_big_to_little.h deleted file mode 100644 index d70e61b..0000000 --- a/quectel_SRPD_PCIE/src/include/sipc_big_to_little.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (C) 2019 Spreadtrum Communications Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef __SIPC_BIG_TO_LITTLE_H -#define __SIPC_BIG_TO_LITTLE_H -//#define CONFIG_SIPC_BIG_TO_LITTLE /* sipc little */ - -#define BL_READB(addr) \ - ({ unsigned char __v = (*(volatile unsigned char *) (addr)); __v; }) -#define BL_WRITEB(b,addr) (void)((*(volatile unsigned int *) (addr)) = (b)) - -#define BL_GETB(v) ((v)) -#define BL_SETB(v, b) ((v) = (b)) - - -#ifdef CONFIG_SIPC_BIG_TO_LITTLE -/* little 0x78563412 - 0x12 - 0x34 - 0x56 - 0x78 - read: - big: 0x12345678==>0x78563412 - write: 0x78563412 ===> 0x12345678*/ -#define BL_READW(addr) \ - ({ unsigned short __t = (*(volatile unsigned short *) (addr)); \ - unsigned short __v = ((__t & 0x00ff) << 8) + ((__t & 0xff00) >> 8); \ - __v; }) -#define BL_READL(addr) \ - ({ unsigned int __t = (*(volatile unsigned int *) (addr)); \ - unsigned int __v = ((__t & 0x000000ff) << 24) + ((__t & 0x0000ff00) << 8) + \ - ((__t & 0x00ff0000) >> 8) + ((__t & 0xff000000) >> 24); \ - __v; }) - -#define BL_WRITEW(b,addr) \ - ({ unsigned short __v = (((b) & 0x00ff) << 8) + (((b) & 0xff00) >> 8); \ - (*(volatile unsigned short *) (addr)) = __v; }) - -#define BL_WRITEL(b,addr) \ - ({ unsigned int __v = (((b) & 0x000000ff) << 24) + (((b) & 0xff00) >> 8) + \ - (((b) & 0x00ff0000) >> 8) + (((b) & 0xff000000) >> 24); \ - (*(volatile unsigned int *) (addr)) = __v; }) - -#define BL_GETL(v) \ -({unsigned int __v = (((v) & 0x000000ff) << 24) + (((v) & 0x0000ff00) << 8) + \ - (((v) & 0x00ff0000) >> 8) + (((v) & 0xff000000) >> 24); \ - __v; }) -#define BL_SETL(v, b) \ - ((v) = (((b) & 0x000000ff) << 24) + (((b) & 0x0000ff00) << 8) + \ - (((b) & 0x00ff0000) >> 8) + (((b) & 0xff000000) >> 24)) -#define BL_GETW(v) \ - ({unsigned int __v = (((v) & 0x00ff) << 8) + (((v) & 0xff00) >> 8); \ - __v; }) -#define BL_SETW(v, b) \ - ((v) = (((b) & 0x00ff) << 8) + (((b) & 0xff00) >> 8)) - -#else -#define BL_GETW(v) v -#define BL_GETL(v) v - -#define BL_SETW(v, b) ((v) = (b)) -#define BL_SETL(v, b) ((v) = (b)) - -#define BL_READW(addr) \ - ({ unsigned short __v = (*(volatile unsigned short *) (addr)); __v; }) -#define BL_READL(addr) \ - ({ unsigned int __v = (*(volatile unsigned int *) (addr)); __v; }) - -#define BL_WRITEW(b,addr) (void)((*(volatile unsigned short *) (addr)) = (b)) -#define BL_WRITEL(b,addr) (void)((*(volatile unsigned int *) (addr)) = (b)) - -#endif - -#endif - diff --git a/quectel_SRPD_PCIE/src/include/sprd_mpm.h b/quectel_SRPD_PCIE/src/include/sprd_mpm.h deleted file mode 100644 index f9ffe74..0000000 --- a/quectel_SRPD_PCIE/src/include/sprd_mpm.h +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Copyright (C) 2019 Spreadtrum Communications Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - - /* MPM: modem power manger - * PMS: power manage source which be used to request - * a modem power manage resource. - */ -#ifndef _SPRD_MPM_H -#define _SPRD_MPM_H -/* - * MPM modem powermanger source state define, - * if in idle state, we can release - * the related resources(such as pcie) of modem. - */ -enum { - SPRD_MPM_IDLE = 0, - SPRD_MPM_BUSY -}; - -/* - * @sprd_pms: the power manager source data struct, - * can usd it to request wake lock or request modem resource. - * - * @name: the name of a pms. - * @data: the point of MPM. - * @multitask: whether to support multitasking, default is false. - * false, the source can only be used in single task context. - * true, the source can be used multitask context. - * @awake: whether stay awake. - * @awake_cnt: total awake times. - * @pre_awake_cnt pre_awake_cnt. - * @active_cnt: the active counter of the pms. - * @expires: the timer expires value. - * @active_lock: use for protect the active_cnt member. - * @expires_lock: use for protect expires member. - * @entry: an entry of all pms list. - * @wake_timer: used for delay release wakelock. - */ -struct sprd_pms { - const char *name; - void *data; - bool multitask; - bool awake; - unsigned int awake_cnt; - unsigned int pre_awake_cnt; - unsigned int active_cnt; - unsigned long expires; - spinlock_t active_lock; - spinlock_t expires_lock; - struct list_head entry; - struct timer_list wake_timer; -}; - -/** - * sprd_mpm_create - create a modem powermanger source instacnce. - * - * @dst, which mpm (PSCP, SP, WCN, etc.) will be created. - * @later_idle, will release resource later (in ms). - */ -int sprd_mpm_create(unsigned int dst, - const char *name, - unsigned int later_idle); - -/** - * sprd_mpm_init_resource_ops - int resource ops for mpm. - * - * @wait_resource, used to wait request resource ready. - * @request_resource, used to request a resource - * @release_resource, used to release a resource - */ -int sprd_mpm_init_resource_ops(unsigned int dst, - int (*wait_resource)(unsigned int dst, - int timeout), - int (*request_resource)(unsigned int dst), - int (*release_resource)(unsigned int dst)); - -/** - * sprd_mpm_destroy - destroy a modem powermanger source instacnce. - * - * @dst, which mpm (PSCP, SP, WCN, etc.) will be destroyed. - */ -int sprd_mpm_destroy(unsigned int dst); - -/** - * sprd_pms_create - init a pms, - * a module which used it to request a modem power manage resource. - * All the pms interface are not safe in multi-thread or multi-cpu. - * if you want use in multi-thread, please use the pms_ext interface. - * - * @dst, the pms belong to which mpm. - * @name, the name of this pms. - * @pms, the point of this pms. - * @multitask: support multitask. - * - * Returns: NULL failed, > 0 succ. - */ -struct sprd_pms *sprd_pms_create(unsigned int dst, - const char *name, bool multitask); - -/** - * sprd_pms_destroy - destroy a pms. - * - * @pms, the point of this pms. - */ -void sprd_pms_destroy(struct sprd_pms *pms); - -/** - * sprd_pms_request_resource - request mpm resource - * - * @pms, the point of this pms. - * @timeout, in ms. - * - * Returns: - * 0 resource ready, - * < 0 resoure not ready, - * -%ERESTARTSYS if it was interrupted by a signal. - */ -int sprd_pms_request_resource(struct sprd_pms *pms, int timeout); - -/** - * sprd_pms_release_resource - release mpm resource. - * - * @pms, the point of this pms. - */ -void sprd_pms_release_resource(struct sprd_pms *pms); - -/** - * sprd_pms_request_wakelock - request wakelock - * - * @pms, the point of this pms. - */ -void sprd_pms_request_wakelock(struct sprd_pms *pms); - -/** - * sprd_pms_release_wakelock - release wakelock - * - * @pms, the point of this pms. - */ -void sprd_pms_release_wakelock(struct sprd_pms *pms); - -/** - * sprd_pms_request_wakelock_period - - * request wake lock, and will auto reaslse in msec ms. - * - * @pms, the point of this pms. - * @msec, will auto reaslse in msec ms - */ -void sprd_pms_request_wakelock_period(struct sprd_pms *pms, unsigned int msec); - -/** - * sprd_pms_release_wakelock_later - release wakelock later. - * - * @pms, the point of this pms. - * @msec, later time (in ms). - */ -void sprd_pms_release_wakelock_later(struct sprd_pms *pms, - unsigned int msec); - -/** - * sprd_pms_power_up - just powe up, not wait result. - * - * @pms, the point of this pms. - */ -void sprd_pms_power_up(struct sprd_pms *pms); - -/** - * sprd_pms_power_up - just power down,. - * - * @pms, the point of this pms. - * @immediately, whether immediately power down. - */ -void sprd_pms_power_down(struct sprd_pms *pms, bool immediately); - -#endif diff --git a/quectel_SRPD_PCIE/src/include/sprd_pcie_ep_device.h b/quectel_SRPD_PCIE/src/include/sprd_pcie_ep_device.h deleted file mode 100644 index 7b62456..0000000 --- a/quectel_SRPD_PCIE/src/include/sprd_pcie_ep_device.h +++ /dev/null @@ -1,99 +0,0 @@ -/** - * SPRD ep device driver in host side for Spreadtrum SoCs - * - * Copyright (C) 2019 Spreadtrum Co., Ltd. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 of - * the License as published by the Free Software Foundation. - * - * This program is used to control ep device driver in host side for - * Spreadtrum SoCs. - */ - -#ifndef __SPRD_PCIE_EP_DEVICE_H -#define __SPRD_PCIE_EP_DEVICE_H - -#include - -/* host receive msi irq */ -enum { - PCIE_MSI_SIPC_IRQ = 0, - PCIE_MSI_REQUEST_RES, - PCIE_MSI_EP_READY_FOR_RESCAN, - PCIE_MSI_RELEASE_RES, - PCIE_MSI_SCANNED_RESPOND, - PCIE_MSI_REMOVE_RESPOND, - PCIE_MSI_IPA, - PCIE_MSI_MAX_IRQ -}; - -/* host send doorbell irq */ -enum { - PCIE_DBELL_SIPC_IRQ = 0, - PCIE_DBEL_EP_SCANNED, - PCIE_DBEL_EP_REMOVING, - PCIE_DBEL_IRQ_MAX -}; - -enum { - PCIE_EP_MODEM = 0, - /* PCIE_EP_WCN, */ - PCIE_EP_NR -}; - -enum { - PCIE_EP_PROBE = 0, - PCIE_EP_REMOVE, - PCIE_EP_PROBE_BEFORE_SPLIT_BAR -}; - -#ifdef CONFIG_SPRD_SIPA -enum { - PCIE_IPA_TYPE_MEM = 0, - PCIE_IPA_TYPE_REG -}; -#endif - -#define MINI_REGION_SIZE 0x10000 /*64 K default */ - -int sprd_ep_dev_register_notify(int ep, - void (*notify)(int event, void *data), - void *data); -int sprd_ep_dev_unregister_notify(int ep); -int sprd_ep_dev_register_irq_handler(int ep, - int irq, - irq_handler_t handler, - void *data); -int sprd_ep_dev_unregister_irq_handler(int ep, int irq); -int sprd_ep_dev_register_irq_handler_ex(int ep, - int from_irq, - int to_irq, - irq_handler_t handler, - void *data); -int sprd_ep_dev_unregister_irq_handler_ex(int ep, - int from_irq, - int to_irq); -int sprd_ep_dev_set_irq_addr(int ep, void __iomem *irq_addr); -int sprd_ep_dev_raise_irq(int ep, int irq); -int sprd_ep_dev_clear_doolbell_irq(int ep, int irq); -int sprd_ep_dev_set_backup(int ep); -int sprd_ep_dev_clear_backup(int ep); - -void __iomem *sprd_ep_map_memory(int ep, - phys_addr_t cpu_addr, - size_t size); -void sprd_ep_unmap_memory(int ep, const void __iomem *bar_addr); -int sprd_ep_dev_pass_smem(int ep, u32 base, u32 size); -int sipa_module_init(struct device *dev); -void sipa_module_exit(void); -int sipa_eth_init(void); -void sipa_eth_exit(void); -int sipa_dummy_init(void); -void sipa_dummy_exit(void); - -#ifdef CONFIG_SPRD_SIPA -phys_addr_t sprd_ep_ipa_map(int type, phys_addr_t target_addr, size_t size); -int sprd_ep_ipa_unmap(int type, phys_addr_t cpu_addr); -#endif -#endif diff --git a/quectel_SRPD_PCIE/src/include/sprd_pcie_resource.h b/quectel_SRPD_PCIE/src/include/sprd_pcie_resource.h deleted file mode 100644 index 902de45..0000000 --- a/quectel_SRPD_PCIE/src/include/sprd_pcie_resource.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (C) 2019 Spreadtrum Communications Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - - /* mpms: modem powermanger source */ -#ifndef _SPRD_PCIE_RESOURCE_H -#define _SPRD_PCIE_RESOURCE_H - -#ifdef CONFIG_SPRD_PCIE_EP_DEVICE -#include -#endif - -#if 0 -//#undef pr_debug -//#define pr_debug pr_emerg - -#undef pr_info -#define pr_info pr_emerg - -#undef pr_err -#define pr_err pr_emerg - -#undef dev_dbg -#define dev_dbg dev_emerg - -#undef dev_info -#define dev_info dev_emerg - -#undef dev_err -#define dev_err dev_emerg -#endif - -#if defined(CONFIG_SPRD_PCIE_EP_DEVICE) || defined(CONFIG_PCIE_EPF_SPRD) -/* - * sprd_pcie_wait_resource - * Returns: - * 0 resource ready, - * < 0 resoure not ready, - * -%ERESTARTSYS if it was interrupted by a signal. - */ -int sprd_pcie_wait_resource(u32 dst, int timeout); - -int sprd_pcie_request_resource(u32 dst); -int sprd_pcie_release_resource(u32 dst); -int sprd_pcie_resource_trash(u32 dst); -bool sprd_pcie_is_defective_chip(void); -#else -/* dummy functions */ -static inline int sprd_pcie_wait_resource(u32 dst, int timeout) {return 0; } - -static inline int sprd_pcie_request_resource(u32 dst) {return 0; } -static inline int sprd_pcie_release_resource(u32 dst) {return 0; } -static inline int sprd_pcie_resource_trash(u32 dst) {return 0; } -static inline bool sprd_pcie_is_defective_chip(void) {return false; } -#endif - -#ifdef CONFIG_PCIE_EPF_SPRD -int sprd_pcie_resource_client_init(u32 dst, u32 ep_fun); -int sprd_register_pcie_resource_first_ready(u32 dst, - void (*notify)(void *p), - void *data); -#endif - -#ifdef CONFIG_SPRD_PCIE_EP_DEVICE -int sprd_pcie_resource_host_init(u32 dst, u32 ep_dev, - struct platform_device *pcie_dev); - -/* - * sprd_pcie_resource_reboot_ep - * reboot ep contains rescan ep device. - */ -void sprd_pcie_resource_reboot_ep(u32 dst); - -/* - * sprd_pcie_wait_load_resource - * In case of the open the feature CONFIG_PCIE_SPRD_SPLIT_BAR, - * It has 2 times pcie scan action in host side boot process. - * After the first scan, the ep only have 2 bar can be used for - * memory map, the pcie resource is not completely ready, - * but the host can load images for ep, so we add the special api - * sprd_pcie_wait_load_resource, this api will return after - * the first scan action. - * Returns: - * 0 resource ready, - * < 0 resoure not ready, - * -%ERESTARTSYS if it was interrupted by a signal. - */ -int sprd_pcie_wait_load_resource(u32 dst); - - -/* Because the ep bar can only be split by ep itself, - * After all modem images be loaded, notify pcie resource - * can rescan ep now. - */ -void sprd_pcie_resource_notify_load_done(u32 dst); -#endif /* CONFIG_SPRD_PCIE_EP_DEVICE */ - -#endif /* _SPRD_PCIE_RESOURCE_H */ diff --git a/quectel_SRPD_PCIE/src/mcd/Kconfig b/quectel_SRPD_PCIE/src/mcd/Kconfig deleted file mode 100644 index a7f3db5..0000000 --- a/quectel_SRPD_PCIE/src/mcd/Kconfig +++ /dev/null @@ -1,7 +0,0 @@ -config SPRD_MCD - tristate "SPRD modem power control module" - default n - help - mcd is a module for spreadtrum AP/CP communicaiton control driver, - it can control modem power on/off,triger modem event of assert,watchdog - reset,panic. diff --git a/quectel_SRPD_PCIE/src/mcd/Makefile b/quectel_SRPD_PCIE/src/mcd/Makefile deleted file mode 100644 index 78cb075..0000000 --- a/quectel_SRPD_PCIE/src/mcd/Makefile +++ /dev/null @@ -1 +0,0 @@ -obj-y += modem_ctrl.o diff --git a/quectel_SRPD_PCIE/src/mcd/modem_ctrl.c b/quectel_SRPD_PCIE/src/mcd/modem_ctrl.c deleted file mode 100644 index 720b923..0000000 --- a/quectel_SRPD_PCIE/src/mcd/modem_ctrl.c +++ /dev/null @@ -1,814 +0,0 @@ -/* - * Copyright (C) 2019 Spreadtrum Communications Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef CONFIG_PCIE_PM_NOTIFY -#include -#endif - -#include "../include/sprd_pcie_resource.h" -#include "../include/sipc.h" -#include "../include/mdm_ctrl.h" - -enum { - ROC1_SOC = 0, - ORCA_SOC -}; - -static char *const mdm_stat[] = { - "mdm_power_off", "mdm_power_on", "mdm_warm_reset", "mdm_cold_reset", - "mdm_watchdog_reset", "mdm_assert", "mdm_panic" -}; - -#define REBOOT_MODEM_DELAY 1000 -#define POWERREST_MODEM_DELAY 2000 -#define RESET_MODEM_DELAY 50 - -char cdev_name[] = "mdm_ctrl"; - -struct modem_ctrl_init_data { - char *name; - struct gpio_desc *gpio_poweron; /* Poweron */ - struct gpio_desc *gpio_reset; /* Reset modem */ - struct gpio_desc *gpio_preset; /* Pcie reset */ - struct gpio_desc *gpio_cpwatchdog; - struct gpio_desc *gpio_cpassert; - struct gpio_desc *gpio_cppanic; - struct gpio_desc *gpio_cppoweroff; - u32 irq_cpwatchdog; - u32 irq_cpassert; - u32 irq_cppanic; - u32 irq_cppoweroff; - u32 modem_status; - bool enable_cp_event; -}; - -struct modem_ctrl_device { - struct modem_ctrl_init_data *init; - int major; - int minor; - struct cdev cdev; - struct device *dev; - int soc_type; -}; - -static struct class *modem_ctrl_class; -static struct modem_ctrl_device *mcd_dev; - -/* modem control evnet notify */ -static ATOMIC_NOTIFIER_HEAD(modem_ctrl_chain); - -int modem_ctrl_register_notifier(struct notifier_block *nb) -{ - return atomic_notifier_chain_register(&modem_ctrl_chain, nb); -} -EXPORT_SYMBOL(modem_ctrl_register_notifier); - -void modem_ctrl_unregister_notifier(struct notifier_block *nb) -{ - atomic_notifier_chain_unregister(&modem_ctrl_chain, nb); -} -EXPORT_SYMBOL(modem_ctrl_unregister_notifier); - -static void send_event_msg(struct kobject *kobj) -{ - char *msg[3]; - char buff[100]; - char mbuff[100]; - - memset(mbuff, 0, sizeof(mbuff)); - if (!mcd_dev || !mcd_dev->init || !kobj) - return; - - snprintf(buff, sizeof(buff), "MODEM_STAT=%d", - mcd_dev->init->modem_status); - snprintf(mbuff, sizeof(mbuff), "MODEM_EVENT=%s", - mdm_stat[mcd_dev->init->modem_status]); - msg[0] = buff; - msg[1] = mbuff; - msg[2] = NULL; - kobject_uevent_env(kobj, KOBJ_CHANGE, msg); - dev_dbg(mcd_dev->dev, "send uevent to userspace\n"); -} - -static irqreturn_t cpwatchdogtriger_handler(int irq, void *dev_id) -{ - if (!mcd_dev || !mcd_dev->init || !mcd_dev->init->enable_cp_event) - return IRQ_NONE; - - mcd_dev->init->modem_status = MDM_WATCHDOG_RESET; - atomic_notifier_call_chain(&modem_ctrl_chain, MDM_WATCHDOG_RESET, NULL); - send_event_msg(&mcd_dev->dev->kobj); - return IRQ_HANDLED; -} - -static irqreturn_t cpasserttriger_handler(int irq, void *dev_id) -{ - if (!mcd_dev || !mcd_dev->init || !mcd_dev->init->enable_cp_event) - return IRQ_NONE; - - mcd_dev->init->modem_status = MDM_ASSERT; - atomic_notifier_call_chain(&modem_ctrl_chain, MDM_ASSERT, NULL); - send_event_msg(&mcd_dev->dev->kobj); - return IRQ_HANDLED; -} - -static irqreturn_t cppanictriger_handler(int irq, void *dev_id) -{ - if (!mcd_dev || !mcd_dev->init || !mcd_dev->init->enable_cp_event) - return IRQ_NONE; - - mcd_dev->init->modem_status = MDM_PANIC; - atomic_notifier_call_chain(&modem_ctrl_chain, MDM_PANIC, NULL); - send_event_msg(&mcd_dev->dev->kobj); - return IRQ_HANDLED; -} - -static irqreturn_t cppoweroff_handler(int irq, void *dev_id) -{ - if (!mcd_dev || !mcd_dev->init) - return IRQ_NONE; - /* To this reserve here for receve power off event from AP*/ - atomic_notifier_call_chain(&modem_ctrl_chain, - MDM_POWER_OFF, NULL); - kernel_power_off(); - return IRQ_HANDLED; -} - -static int request_gpio_to_irq(struct gpio_desc *cp_gpio, - struct modem_ctrl_device *mcd_dev) -{ - int ret = 0; - - if (!mcd_dev || !mcd_dev->init) - return -EINVAL; - - ret = gpiod_to_irq(cp_gpio); - if (ret < 0) { - dev_err(mcd_dev->dev, "requset irq %d failed\n", ret); - return ret; - } - dev_dbg(mcd_dev->dev, "gpio to irq %d\n", ret); - if (cp_gpio == mcd_dev->init->gpio_cpwatchdog) { - mcd_dev->init->irq_cpwatchdog = ret; - ret = devm_request_threaded_irq(mcd_dev->dev, - mcd_dev->init->irq_cpwatchdog, - NULL, cpwatchdogtriger_handler, - IRQF_ONESHOT | IRQF_TRIGGER_FALLING, - "cpwatchdog_irq", mcd_dev); - if (ret < 0) { - dev_err(mcd_dev->dev, "can not request irq for cp watchdog\n"); - return ret; - } - enable_irq_wake(mcd_dev->init->irq_cpwatchdog); - } else if (cp_gpio == mcd_dev->init->gpio_cpassert) { - mcd_dev->init->irq_cpassert = ret; - ret = devm_request_threaded_irq(mcd_dev->dev, - mcd_dev->init->irq_cpassert, - NULL, cpasserttriger_handler, - IRQF_ONESHOT | IRQF_TRIGGER_FALLING, - "cpassert_irq", mcd_dev); - if (ret < 0) { - dev_err(mcd_dev->dev, "can not request irq for cp assert\n"); - return ret; - } - enable_irq_wake(mcd_dev->init->irq_cpassert); - } else if (cp_gpio == mcd_dev->init->gpio_cppanic) { - mcd_dev->init->irq_cppanic = ret; - ret = devm_request_threaded_irq(mcd_dev->dev, - mcd_dev->init->irq_cppanic, - NULL, cppanictriger_handler, - IRQF_ONESHOT | IRQF_TRIGGER_FALLING, - "cppanic_irq", mcd_dev); - if (ret < 0) { - dev_err(mcd_dev->dev, - "can not request irq for panic\n"); - return ret; - } - enable_irq_wake(mcd_dev->init->irq_cppanic); - } else if (cp_gpio == mcd_dev->init->gpio_cppoweroff) { - mcd_dev->init->irq_cppoweroff = ret; - ret = devm_request_threaded_irq(mcd_dev->dev, - mcd_dev->init->irq_cppoweroff, - NULL, cppoweroff_handler, - IRQF_ONESHOT | IRQF_TRIGGER_LOW, - "cppoweroff_irq", mcd_dev); - if (ret < 0) { - dev_err(mcd_dev->dev, - "can not request irq for cppoweroff\n"); - return ret; - } - enable_irq_wake(mcd_dev->init->irq_cppoweroff); - } - return 0; -} - -static int modem_gpios_init(struct modem_ctrl_device *mcd_dev, int soc_type) -{ - int ret; - - if (!mcd_dev || !mcd_dev->init) - return -EINVAL; - if (soc_type == ROC1_SOC) { - gpiod_direction_input(mcd_dev->init->gpio_cpwatchdog); - gpiod_direction_input(mcd_dev->init->gpio_cpassert); - gpiod_direction_input(mcd_dev->init->gpio_cppanic); - - ret = request_gpio_to_irq(mcd_dev->init->gpio_cpwatchdog, - mcd_dev); - if (ret) - return ret; - ret = request_gpio_to_irq(mcd_dev->init->gpio_cpassert, - mcd_dev); - if (ret) - return ret; - ret = request_gpio_to_irq(mcd_dev->init->gpio_cppanic, - mcd_dev); - if (ret) - return ret; - - /* IRQF_TRIGGER_LOW, default must set to high */ - gpiod_set_value_cansleep(mcd_dev->init->gpio_cppoweroff, 1); - } else { - gpiod_direction_input(mcd_dev->init->gpio_cppoweroff); - ret = request_gpio_to_irq(mcd_dev->init->gpio_cppoweroff, - mcd_dev); - if (ret) - return ret; - - /* TRIGGER_FALLING, defaultmust set to high */ - gpiod_set_value_cansleep(mcd_dev->init->gpio_cpwatchdog, 1); - gpiod_set_value_cansleep(mcd_dev->init->gpio_cpassert, 1); - gpiod_set_value_cansleep(mcd_dev->init->gpio_cppanic, 1); - } - return 0; -} - -void modem_ctrl_enable_cp_event(void) -{ - if (mcd_dev && mcd_dev->init) - mcd_dev->init->enable_cp_event = true; -} -EXPORT_SYMBOL_GPL(modem_ctrl_enable_cp_event); - -void modem_ctrl_send_abnormal_to_ap(int status) -{ - struct gpio_desc *gpiodesc; - - if (!mcd_dev || !mcd_dev->init) - return; - if (mcd_dev->soc_type != ORCA_SOC) { - dev_err(mcd_dev->dev, "operation not be allowed for %d\n", - mcd_dev->soc_type); - return; - } - switch (status) { - case MDM_WATCHDOG_RESET: - gpiodesc = mcd_dev->init->gpio_cpwatchdog; - break; - case MDM_ASSERT: - gpiodesc = mcd_dev->init->gpio_cpassert; - break; - case MDM_PANIC: - gpiodesc = mcd_dev->init->gpio_cppanic; - break; - default: - dev_info(mcd_dev->dev, - "get status %d is not right for operation\n", status); - return; - } - mcd_dev->init->modem_status = status; - dev_info(mcd_dev->dev, - "operation unnormal status %d send to ap\n", - status); - if (!IS_ERR(gpiodesc)) - gpiod_set_value_cansleep(gpiodesc, 0); -} - -static void modem_ctrl_send_cmd_to_cp(int status) -{ - struct gpio_desc *gpiodesc = NULL; - - if (!mcd_dev || !mcd_dev->init) - return; - if (mcd_dev->soc_type != ROC1_SOC) { - dev_err(mcd_dev->dev, "operation not be allowed for %d\n", - mcd_dev->soc_type); - return; - } - if (status == MDM_POWER_OFF) - gpiodesc = mcd_dev->init->gpio_cppoweroff; - - mcd_dev->init->modem_status = status; - dev_info(mcd_dev->dev, - "operation cmd %d ms send to cp\n", - status); - if (!IS_ERR(gpiodesc)) { - gpiod_set_value_cansleep(gpiodesc, 0); - msleep(20); - gpiod_set_value_cansleep(gpiodesc, 20); - } -} - -static void modem_ctrl_notify_abnormal_status(int status) -{ - if (!mcd_dev || !mcd_dev->init) - return; - if (mcd_dev->soc_type != ORCA_SOC) { - dev_err(mcd_dev->dev, "operation not be allowed for %d\n", - mcd_dev->soc_type); - return; - } - if (status < MDM_WATCHDOG_RESET || status > MDM_PANIC) { - dev_err(mcd_dev->dev, - "operation not be allowed for status %d\n", status); - return; - } - modem_ctrl_send_abnormal_to_ap(status); -} - -void modem_ctrl_poweron_modem(int on) -{ - if (!mcd_dev || !mcd_dev->init) - return; - switch (on) { - case MDM_CTRL_POWER_ON: - if (!IS_ERR(mcd_dev->init->gpio_poweron)) { - atomic_notifier_call_chain(&modem_ctrl_chain, - MDM_CTRL_POWER_ON, NULL); - dev_info(mcd_dev->dev, "set modem_poweron: %d\n", on); - gpiod_set_value_cansleep(mcd_dev->init->gpio_poweron, - 1); - /* Base the spec modem boot flow that need to wait 1s */ - msleep(REBOOT_MODEM_DELAY); - mcd_dev->init->modem_status = MDM_CTRL_POWER_ON; - gpiod_set_value_cansleep(mcd_dev->init->gpio_poweron, - 0); - } - break; - case MDM_CTRL_POWER_OFF: - /* - *To do - */ - break; - case MDM_CTRL_SET_CFG: - /* - *To do - */ - break; - case MDM_CTRL_WARM_RESET: - if (!IS_ERR(mcd_dev->init->gpio_reset)) { - atomic_notifier_call_chain(&modem_ctrl_chain, - MDM_CTRL_WARM_RESET, NULL); - dev_dbg(mcd_dev->dev, "set warm reset: %d\n", on); - gpiod_set_value_cansleep(mcd_dev->init->gpio_reset, 1); - /* Base the spec modem that need to wait 50ms */ - msleep(RESET_MODEM_DELAY); - mcd_dev->init->modem_status = MDM_CTRL_WARM_RESET; - gpiod_set_value_cansleep(mcd_dev->init->gpio_reset, 0); - } - break; - case MDM_CTRL_COLD_RESET: - if (!IS_ERR(mcd_dev->init->gpio_poweron)) { - mcd_dev->init->enable_cp_event = false; - atomic_notifier_call_chain(&modem_ctrl_chain, - MDM_CTRL_COLD_RESET, NULL); - dev_info(mcd_dev->dev, "modem_power reset: %d\n", on); - gpiod_set_value_cansleep(mcd_dev->init->gpio_poweron, - 1); - /* Base the spec modem boot flow that need to wait 2s */ - msleep(POWERREST_MODEM_DELAY); - mcd_dev->init->modem_status = MDM_CTRL_COLD_RESET; - gpiod_set_value_cansleep(mcd_dev->init->gpio_poweron, - 0); - } - break; - case MDM_CTRL_PCIE_RECOVERY: -#ifdef CONFIG_PCIE_PM_NOTIFY - pcie_ep_pm_notify(PCIE_EP_POWER_OFF); - /* PCIE poweroff to poweron need 100ms*/ - msleep(100); - pcie_ep_pm_notify(PCIE_EP_POWER_ON); -#endif - break; - case MDM_POWER_OFF: - atomic_notifier_call_chain(&modem_ctrl_chain, - MDM_POWER_OFF, NULL); - modem_ctrl_send_cmd_to_cp(MDM_POWER_OFF); - break; - default: - dev_err(mcd_dev->dev, "cmd not support: %d\n", on); - } -} -EXPORT_SYMBOL_GPL(modem_ctrl_poweron_modem); - -#if defined(CONFIG_DEBUG_FS) -static int modem_ctrl_debug_show(struct seq_file *m, void *private) -{ - dev_dbg(mcd_dev->dev, "%s\n", __func__); - return 0; -} - -static int modem_ctrl_debug_open(struct inode *inode, struct file *file) -{ - return single_open(file, modem_ctrl_debug_show, inode->i_private); -} - -static const struct file_operations modem_ctrl_debug_fops = { - .open = modem_ctrl_debug_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -#endif /* CONFIG_DEBUG_FS */ - -static int modem_ctrl_open(struct inode *inode, struct file *filp) -{ - struct modem_ctrl_device *modem_ctrl; - - modem_ctrl = container_of(inode->i_cdev, - struct modem_ctrl_device, cdev); - filp->private_data = modem_ctrl; - dev_dbg(modem_ctrl->dev, "modem_ctrl: %s\n", __func__); - return 0; -} - -static int modem_ctrl_release(struct inode *inode, struct file *filp) -{ - struct modem_ctrl_device *modem_ctrl; - - modem_ctrl = container_of(inode->i_cdev, - struct modem_ctrl_device, cdev); - dev_dbg(modem_ctrl->dev, "modem_ctrl: %s\n", __func__); - - return 0; -} - -static ssize_t modem_ctrl_read(struct file *filp, - char __user *buf, - size_t count, - loff_t *ppos) -{ - char tmpbuf[30]; - int r; - struct modem_ctrl_device *mcd_dev = filp->private_data; - - if (!mcd_dev || !mcd_dev->init) - return -EINVAL; - - r = snprintf(tmpbuf, sizeof(tmpbuf), "%s\n", - mdm_stat[mcd_dev->init->modem_status]); - - return simple_read_from_buffer(buf, count, ppos, tmpbuf, r); -} - -static ssize_t modem_ctrl_write(struct file *filp, - const char __user *buf, - size_t count, loff_t *ppos) -{ - char sbuf[100]; - int ret; - u32 mcd_cmd; - struct modem_ctrl_device *mcd_dev = filp->private_data; - - if (!mcd_dev) - return -EINVAL; - - if (unalign_copy_from_user((void *)sbuf, buf, count)) { - dev_err(mcd_dev->dev, "copy buf %s error\n", buf); - return -EFAULT; - } - dev_dbg(mcd_dev->dev, "get info:%s", sbuf); - sbuf[count - 1] = '\0'; - ret = kstrtouint(sbuf, 10, &mcd_cmd); - if (ret) { - dev_err(mcd_dev->dev, "Invalid input!\n"); - return ret; - } - if (mcd_dev->soc_type == ROC1_SOC) { - if (mcd_cmd >= MDM_CTRL_POWER_OFF && - mcd_cmd <= MDM_CTRL_SET_CFG) - modem_ctrl_poweron_modem(mcd_cmd); - else - dev_info(mcd_dev->dev, "cmd not support!\n"); - } else { - modem_ctrl_notify_abnormal_status(mcd_cmd); - } - return count; -} - -static long modem_ctrl_ioctl(struct file *filp, unsigned int cmd, - unsigned long arg) -{ - - if (!mcd_dev || mcd_dev->soc_type == ORCA_SOC) - return -EINVAL; - switch (cmd) { - case MDM_CTRL_POWER_OFF: - modem_ctrl_poweron_modem(MDM_CTRL_POWER_OFF); - break; - case MDM_CTRL_POWER_ON: - modem_ctrl_poweron_modem(MDM_CTRL_POWER_ON); - break; - case MDM_CTRL_WARM_RESET: - modem_ctrl_poweron_modem(MDM_CTRL_WARM_RESET); - break; - case MDM_CTRL_COLD_RESET: - modem_ctrl_poweron_modem(MDM_CTRL_COLD_RESET); - break; - case MDM_CTRL_PCIE_RECOVERY: - modem_ctrl_poweron_modem(MDM_CTRL_PCIE_RECOVERY); - break; - case MDM_CTRL_SET_CFG: - break; - default: - return -EINVAL; - } - return 0; -} - -static const struct file_operations modem_ctrl_fops = { - .open = modem_ctrl_open, - .release = modem_ctrl_release, - .read = modem_ctrl_read, - .write = modem_ctrl_write, - .unlocked_ioctl = modem_ctrl_ioctl, - .owner = THIS_MODULE, - .llseek = default_llseek, -}; - -static int modem_ctrl_parse_modem_dt(struct modem_ctrl_init_data **init, - struct device *dev) -{ - struct modem_ctrl_init_data *pdata = NULL; - - pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); - if (!pdata) - return -ENOMEM; - pdata->name = cdev_name; - - /* Triger watchdog,assert,panic of orca */ - pdata->gpio_cpwatchdog = devm_gpiod_get(dev, - "cpwatchdog", - GPIOD_OUT_HIGH); - if (IS_ERR(pdata->gpio_cpwatchdog)) - return PTR_ERR(pdata->gpio_cpwatchdog); - - pdata->gpio_cpassert = devm_gpiod_get(dev, "cpassert", GPIOD_OUT_HIGH); - if (IS_ERR(pdata->gpio_cpassert)) - return PTR_ERR(pdata->gpio_cpassert); - - pdata->gpio_cppanic = devm_gpiod_get(dev, "cppanic", GPIOD_OUT_HIGH); - if (IS_ERR(pdata->gpio_cppanic)) - return PTR_ERR(pdata->gpio_cppanic); - - pdata->gpio_cppoweroff = devm_gpiod_get(dev, "cppoweroff", GPIOD_IN); - if (IS_ERR(pdata->gpio_cpassert)) - return PTR_ERR(pdata->gpio_cppoweroff); - - *init = pdata; - return 0; -} - -static int modem_ctrl_parse_dt(struct modem_ctrl_init_data **init, - struct device *dev) -{ - struct modem_ctrl_init_data *pdata; - - pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); - if (!pdata) - return -ENOMEM; - pdata->name = cdev_name; - pdata->gpio_poweron = devm_gpiod_get(dev, "poweron", GPIOD_OUT_LOW); - if (IS_ERR(pdata->gpio_poweron)) - return PTR_ERR(pdata->gpio_poweron); - - pdata->gpio_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); - if (IS_ERR(pdata->gpio_reset)) - return PTR_ERR(pdata->gpio_reset); - - /* Triger watchdog,assert,panic of orca */ - pdata->gpio_cpwatchdog = devm_gpiod_get(dev, "cpwatchdog", GPIOD_IN); - if (IS_ERR(pdata->gpio_cpwatchdog)) - return PTR_ERR(pdata->gpio_cpwatchdog); - - pdata->gpio_cpassert = devm_gpiod_get(dev, "cpassert", GPIOD_IN); - if (IS_ERR(pdata->gpio_cpassert)) - return PTR_ERR(pdata->gpio_cpassert); - - pdata->gpio_cppanic = devm_gpiod_get(dev, "cppanic", GPIOD_IN); - if (IS_ERR(pdata->gpio_cppanic)) - return PTR_ERR(pdata->gpio_cppanic); - - pdata->gpio_cppoweroff = devm_gpiod_get(dev, - "cppoweroff", GPIOD_OUT_HIGH); - if (IS_ERR(pdata->gpio_cpassert)) - return PTR_ERR(pdata->gpio_cppoweroff); - - pdata->modem_status = MDM_CTRL_POWER_OFF; - *init = pdata; - return 0; -} - -static inline void -modem_ctrl_destroy_pdata(struct modem_ctrl_init_data **init) -{ - struct modem_ctrl_init_data *pdata = *init; - - pdata = NULL; -} - -static int modem_ctrl_restart_handle(struct notifier_block *this, - unsigned long mode, void *cmd) -{ - if (!mcd_dev || mcd_dev->soc_type == ROC1_SOC) - return NOTIFY_DONE; - modem_ctrl_notify_abnormal_status(MDM_PANIC); - while (1) - ; - return NOTIFY_DONE; -} - -static struct notifier_block modem_ctrl_restart_handler = { - .notifier_call = modem_ctrl_restart_handle, - .priority = 150, -}; - -static int modem_ctrl_probe(struct platform_device *pdev) -{ - struct modem_ctrl_init_data *init = pdev->dev.platform_data; - struct modem_ctrl_device *modem_ctrl_dev; - dev_t devid; - int rval; - struct device *dev = &pdev->dev; - - modem_ctrl_dev = devm_kzalloc(dev, sizeof(*modem_ctrl_dev), GFP_KERNEL); - if (!modem_ctrl_dev) - return -ENOMEM; - mcd_dev = modem_ctrl_dev; - if (of_device_is_compatible(pdev->dev.of_node, "sprd,roc1-modem-ctrl")) - modem_ctrl_dev->soc_type = ROC1_SOC; - else - modem_ctrl_dev->soc_type = ORCA_SOC; - - if (modem_ctrl_dev->soc_type == ROC1_SOC) { - rval = modem_ctrl_parse_dt(&init, &pdev->dev); - if (rval) { - dev_err(dev, - "Failed to parse modem_ctrl device tree, ret=%d\n", - rval); - return rval; - } - } else { - rval = modem_ctrl_parse_modem_dt(&init, &pdev->dev); - if (rval) { - dev_err(dev, - "Failed to parse modem_ctrl device tree, ret=%d\n", - rval); - return rval; - } - } - - dev_dbg(dev, "after parse device tree, name=%s soctype=%d\n", - init->name, - modem_ctrl_dev->soc_type); - - rval = alloc_chrdev_region(&devid, 0, 1, init->name); - if (rval != 0) { - dev_err(dev, "Failed to alloc modem_ctrl chrdev\n"); - goto error3; - } - cdev_init(&modem_ctrl_dev->cdev, &modem_ctrl_fops); - rval = cdev_add(&modem_ctrl_dev->cdev, devid, 1); - if (rval != 0) { - dev_err(dev, "Failed to add modem_ctrl cdev\n"); - goto error2; - } - - modem_ctrl_dev->major = MAJOR(devid); - modem_ctrl_dev->minor = MINOR(devid); - modem_ctrl_dev->dev = device_create(modem_ctrl_class, NULL, - MKDEV(modem_ctrl_dev->major, - modem_ctrl_dev->minor), - NULL, "%s", init->name); - if (!modem_ctrl_dev->dev) { - dev_err(dev, "create dev failed\n"); - rval = -ENODEV; - goto error1; - } - modem_ctrl_dev->init = init; - platform_set_drvdata(pdev, modem_ctrl_dev); - rval = modem_gpios_init(modem_ctrl_dev, modem_ctrl_dev->soc_type); - if (rval) { - dev_err(dev, "request gpios error\n"); - goto error0; - } - - rval = register_restart_handler(&modem_ctrl_restart_handler); - if (rval) { - dev_err(dev, "cannot register restart handler err=%d\n", rval); - goto error0; - } - return 0; -error0: - device_destroy(modem_ctrl_class, - MKDEV(modem_ctrl_dev->major, - modem_ctrl_dev->minor)); -error1: - cdev_del(&modem_ctrl_dev->cdev); -error2: - unregister_chrdev_region(devid, 1); -error3: - modem_ctrl_destroy_pdata(&init); - return rval; -} - -static int modem_ctrl_remove(struct platform_device *pdev) -{ - struct modem_ctrl_device *modem_ctrl_dev = platform_get_drvdata(pdev); - - unregister_reboot_notifier(&modem_ctrl_restart_handler); - device_destroy(modem_ctrl_class, - MKDEV(modem_ctrl_dev->major, - modem_ctrl_dev->minor)); - cdev_del(&modem_ctrl_dev->cdev); - unregister_chrdev_region(MKDEV(modem_ctrl_dev->major, - modem_ctrl_dev->minor), 1); - modem_ctrl_destroy_pdata(&modem_ctrl_dev->init); - platform_set_drvdata(pdev, NULL); - return 0; -} - -static void modem_ctrl_shutdown(struct platform_device *pdev) -{ - if (mcd_dev->soc_type == ROC1_SOC) { - atomic_notifier_call_chain(&modem_ctrl_chain, - MDM_POWER_OFF, NULL); - /* - * sleep 50 ms for other module to do something - * before orca power down. - */ - msleep(50); - modem_ctrl_send_cmd_to_cp(MDM_POWER_OFF); - /* Sleep 500ms for cp to deal power down process otherwise - * cp will not power down clearly. - */ - msleep(500); - } -} - -static const struct of_device_id modem_ctrl_match_table[] = { - {.compatible = "sprd,roc1-modem-ctrl", }, - {.compatible = "sprd,orca-modem-ctrl", }, -}; - -static struct platform_driver modem_ctrl_driver = { - .driver = { - .name = "modem_ctrl", - .of_match_table = modem_ctrl_match_table, - }, - .probe = modem_ctrl_probe, - .remove = modem_ctrl_remove, - .shutdown = modem_ctrl_shutdown, -}; - -int modem_ctrl_init(void) -{ - modem_ctrl_class = class_create(THIS_MODULE, "modem_ctrl"); - if (IS_ERR(modem_ctrl_class)) - return PTR_ERR(modem_ctrl_class); - return platform_driver_register(&modem_ctrl_driver); -} -EXPORT_SYMBOL_GPL(modem_ctrl_init); - -void modem_ctrl_exit(void) -{ - class_destroy(modem_ctrl_class); - platform_driver_unregister(&modem_ctrl_driver); -} -EXPORT_SYMBOL_GPL(modem_ctrl_exit); diff --git a/quectel_SRPD_PCIE/src/pcie/Kconfig b/quectel_SRPD_PCIE/src/pcie/Kconfig deleted file mode 100644 index ac88510..0000000 --- a/quectel_SRPD_PCIE/src/pcie/Kconfig +++ /dev/null @@ -1,7 +0,0 @@ - -config SPRD_PCIE_EP_DEVICE - tristate "SPRD PCIE EP device" - default n - depends on PCI - help - SPRD pcie ep device driver in host side for Spreadtrum. \ No newline at end of file diff --git a/quectel_SRPD_PCIE/src/pcie/Makefile b/quectel_SRPD_PCIE/src/pcie/Makefile deleted file mode 100644 index 0f62c8a..0000000 --- a/quectel_SRPD_PCIE/src/pcie/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -ccflags-y += -DCONFIG_SPRD_PCIE_EP_DEVICE -DCONFIG_SPRD_SIPA -obj-y += sprd_pcie_ep_device.o -obj-y += pcie_host_resource.o -obj-y += sprd_pcie_quirks.o -obj-$(CONFIG_PCIE_EPF_SPRD) += pcie_client_resource.o -obj-$(CONFIG_SPRD_SIPA_RES) += pcie_sipa_res.o diff --git a/quectel_SRPD_PCIE/src/pcie/pcie_client_resource.c b/quectel_SRPD_PCIE/src/pcie/pcie_client_resource.c deleted file mode 100644 index 74e5d72..0000000 --- a/quectel_SRPD_PCIE/src/pcie/pcie_client_resource.c +++ /dev/null @@ -1,528 +0,0 @@ -/* - * Copyright (C) 2019 Spreadtrum Communications Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../include/sprd_pcie_resource.h" -#ifdef CONFIG_SPRD_SIPA_RES -#include "pcie_sipa_res.h" -#endif - -enum ep_msg { - RC_SCANNED_MSG = 0, - RC_REMOVING_MSG, - EPC_UNLINK_MSG, - EPC_LINKUP_MSG -}; - -enum pcie_ep_state { - SPRD_PCIE_WAIT_FIRST_READY = 0, - SPRD_PCIE_WAIT_SCANNED, - SPRD_PCIE_SCANNED, - SPRD_PCIE_WAIT_REMOVED, - SPRD_PCIE_REMOVED, - SPRD_PCIE_WAIT_POWER_OFF -}; - -struct sprd_pci_res_notify { - void (*notify)(void *p); - void *data; -}; - -struct sprd_pcie_res { - u32 dst; - u32 ep_fun; - enum pcie_ep_state state; - bool msi_later; - bool wakeup_later; - -#ifdef CONFIG_SPRD_SIPA_RES - void *sipa_res; -#endif - - /* - * in client(Orca), The PCIE module wll blocks the chip Deep, - * so we must get a wake lock when pcie work to avoid this situation: - * the system is deep, but the PCIE is still working. - */ - struct wakeup_source ws; - wait_queue_head_t wait_pcie_ready; - struct sprd_pci_res_notify first_ready_notify; -}; - -static struct sprd_pcie_res *g_pcie_res[SIPC_ID_NR]; - -/* the state machine of ep, init SPRD_PCIE_WAIT_FIRST_READY. - * SPRD_PCIE_WAIT_FIRST_READY (receive RC scanned) ==> SPRD_PCIE_SCANNED - * SPRD_PCIE_SCANNED (receive RC removing)==> SPRD_PCIE_WAIT_REMOVED - * SPRD_PCIE_WAIT_REMOVED(receive epc unlink)==>SPRD_PCIE_REMOVED - * SPRD_PCIE_REMOVED(receive epc linkup)==>SPRD_PCIE_WAIT_SCANNED - * SPRD_PCIE_WAIT_SCANNED(receive RC scanned)==>SPRD_PCIE_SCANNED - * SPRD_PCIE_WAIT_POWER_OFF can do nothing, just wait shutdown. - */ -static const char *change_msg[EPC_LINKUP_MSG + 1] = { - "rc scanned", - "rc removing", - "epc unlink", - "epc linkup" -}; - -static const char *state_msg[SPRD_PCIE_REMOVED + 1] = { - "wait first ready", - "wait sacanned", - "scanned", - "wait remove", - "removed" -}; - -static void pcie_resource_client_change_state(struct sprd_pcie_res *res, - enum ep_msg msg) -{ - u32 old_state = res->state; - - if (old_state == SPRD_PCIE_WAIT_POWER_OFF) - return; - - pr_debug("pcie res: change state msg=%s, old_state=%s.\n", - change_msg[msg], state_msg[old_state]); - - switch (msg) { - case RC_SCANNED_MSG: - if (old_state != SPRD_PCIE_WAIT_FIRST_READY - && old_state != SPRD_PCIE_WAIT_SCANNED) { - pr_err("pcie res: %s msg err, old state=%s", - change_msg[msg], state_msg[old_state]); - return; - } - res->state = SPRD_PCIE_SCANNED; - break; - - case RC_REMOVING_MSG: - if (old_state != SPRD_PCIE_SCANNED) { - pr_err("pcie res: %s msg err, old state=%s", - change_msg[msg], state_msg[old_state]); - return; - } - res->state = SPRD_PCIE_WAIT_REMOVED; - break; - - case EPC_UNLINK_MSG: - if (old_state != SPRD_PCIE_WAIT_REMOVED) { - if (old_state != SPRD_PCIE_WAIT_FIRST_READY) - pr_err("pcie res: %s msg err, old state=%s", - change_msg[msg], state_msg[old_state]); - return; - } - res->state = SPRD_PCIE_REMOVED; - break; - - case EPC_LINKUP_MSG: - if (old_state != SPRD_PCIE_REMOVED) { - if (old_state != SPRD_PCIE_WAIT_FIRST_READY) - pr_err("pcie res: %s msg err, old state=%s", - change_msg[msg], state_msg[old_state]); - return; - } - res->state = SPRD_PCIE_WAIT_SCANNED; - break; - } - - pr_info("pcie res: change state from %s to %s.\n", - state_msg[old_state], state_msg[res->state]); -} - -static void sprd_pcie_resource_first_ready_notify(struct sprd_pcie_res *res) -{ - void (*notify)(void *p); - - pr_info("pcie res: first ready.\n"); - -#ifdef CONFIG_SPRD_SIPA_RES - /* - * in client side, producer res id is SIPA_RM_RES_PROD_PCIE_EP, - * consumer res id is SIPA_RM_RES_CONS_WWAN_DL. - */ - res->sipa_res = pcie_sipa_res_create(res->dst, - SIPA_RM_RES_PROD_PCIE_EP, - SIPA_RM_RES_CONS_WWAN_DL); - if (!res->sipa_res) - pr_err("pcie res:create ipa res failed.\n"); -#endif - - notify = res->first_ready_notify.notify; - if (notify) - notify(res->first_ready_notify.data); -} - -static void pcie_resource_client_epf_notify(int event, void *private) -{ - struct sprd_pcie_res *res = (struct sprd_pcie_res *)private; - - if (res->state == SPRD_PCIE_WAIT_POWER_OFF) - return; - - switch (event) { - case SPRD_EPF_BIND: - pr_info("pcie res: epf be binded.\n"); - if (sprd_pcie_is_defective_chip()) - sprd_pci_epf_raise_irq(res->ep_fun, - PCIE_MSI_EP_READY_FOR_RESCAN); - break; - - case SPRD_EPF_UNBIND: - pr_info("pcie res: epf be unbinded.\n"); - break; - - case SPRD_EPF_REMOVE: - pr_info("pcie res: epf be removed.\n"); - break; - - case SPRD_EPF_LINK_UP: - /* get a wakelock */ - __pm_stay_awake(&res->ws); - - pr_info("pcie res: epf linkup.\n"); - pcie_resource_client_change_state(res, EPC_LINKUP_MSG); - - /* first ready notify */ - if (res->state == SPRD_PCIE_WAIT_FIRST_READY) - sprd_pcie_resource_first_ready_notify(res); - - break; - - case SPRD_EPF_UNLINK: - /* Here need this log to debug pcie scan and remove */ - pr_info("pcie res: epf unlink.\n"); - pcie_resource_client_change_state(res, EPC_UNLINK_MSG); - - /* if has wakeup pending, send wakeup to rc */ - if (res->wakeup_later) { - res->wakeup_later = false; - pr_info("pcie res: send wakeup to rc.\n"); - if (sprd_pci_epf_start(res->ep_fun)) - pr_err("pcie res: send wakeup to rc failed.\n"); - } - - /* relax a wakelock */ - __pm_relax(&res->ws); - break; - - default: - break; - } -} - -static irqreturn_t pcie_resource_client_irq_handler(int irq, void *private) -{ - struct sprd_pcie_res *res = (struct sprd_pcie_res *)private; - - if (res->state == SPRD_PCIE_WAIT_POWER_OFF) - return IRQ_HANDLED; - - if (irq == PCIE_DBEL_EP_SCANNED) { - pcie_resource_client_change_state(res, RC_SCANNED_MSG); - - /* wakeup all blocked thread */ - pr_info("pcie res: scanned, wakup all.\n"); - wake_up_interruptible_all(&res->wait_pcie_ready); - - /* if has msi pending, send msi to rc */ - if (res->msi_later) { - res->msi_later = false; - pr_info("pcie res: request msi to rc.\n"); - sprd_pci_epf_raise_irq(res->ep_fun, - PCIE_MSI_REQUEST_RES); - } - } else if (irq == PCIE_DBEL_EP_REMOVING) { - pr_info("pcie res: removing.\n"); - pcie_resource_client_change_state(res, RC_REMOVING_MSG); - } - - return IRQ_HANDLED; -} - -static int sprd_pcie_resource_client_mcd(struct notifier_block *nb, - unsigned long mode, void *cmd) -{ - struct sprd_pcie_res *res; - int i; - - pr_info("pcie res: mcd event mode=%ld.\n", mode); - - if (mode != MDM_POWER_OFF) - return NOTIFY_DONE; - - for (i = 0; i < SIPC_ID_NR; i++) { - res = g_pcie_res[i]; - if (res) - res->state = SPRD_PCIE_WAIT_POWER_OFF; - } - - return NOTIFY_DONE; -} - -static struct notifier_block mcd_notify = { - .notifier_call = sprd_pcie_resource_client_mcd, - .priority = 149, -}; - -int sprd_pcie_resource_client_init(u32 dst, u32 ep_fun) -{ - struct sprd_pcie_res *res; - - if (dst >= SIPC_ID_NR) - return -EINVAL; - - res = kzalloc(sizeof(*res), GFP_KERNEL); - if (!res) - return -ENOMEM; - - res->dst = dst; - res->state = SPRD_PCIE_WAIT_FIRST_READY; - res->ep_fun = ep_fun; - - wakeup_source_init(&res->ws, "pcie_res"); - - init_waitqueue_head(&res->wait_pcie_ready); - sprd_pci_epf_register_irq_handler_ex(res->ep_fun, - PCIE_DBEL_EP_SCANNED, - PCIE_DBEL_EP_REMOVING, - pcie_resource_client_irq_handler, - res); - sprd_pci_epf_register_notify(res->ep_fun, - pcie_resource_client_epf_notify, - res); - - modem_ctrl_register_notifier(&mcd_notify); - - g_pcie_res[dst] = res; - - return 0; -} - -int sprd_pcie_resource_trash(u32 dst) -{ - struct sprd_pcie_res *res; - - if (dst >= SIPC_ID_NR || !g_pcie_res[dst]) - return -EINVAL; - - res = g_pcie_res[dst]; - -#ifdef CONFIG_SPRD_SIPA_RES - if (res->sipa_res) - pcie_sipa_res_destroy(res->sipa_res); -#endif - - sprd_pci_epf_unregister_irq_handler_ex(res->ep_fun, - PCIE_DBEL_EP_SCANNED, - PCIE_DBEL_EP_REMOVING); - sprd_pci_epf_unregister_notify(res->ep_fun); - modem_ctrl_unregister_notifier(&mcd_notify); - - kfree(res); - g_pcie_res[dst] = NULL; - - return 0; -} - -int sprd_pcie_wait_resource(u32 dst, int timeout) -{ - struct sprd_pcie_res *res; - int ret, wait; - unsigned long delay; - - if (dst >= SIPC_ID_NR || !g_pcie_res[dst]) - return -EINVAL; - - res = g_pcie_res[dst]; - - /* pcie ready, return succ immediately */ - if (res->state == SPRD_PCIE_SCANNED) - return 0; - - if (timeout == 0) - return -ETIME; - - if (timeout < 0) { - wait = wait_event_interruptible( - res->wait_pcie_ready, - res->state == SPRD_PCIE_SCANNED - ); - ret = wait; - } else { - /* - * timeout must add 1s, - * because the pcie rescan may took some time. - */ - delay = msecs_to_jiffies(timeout + 1000); - wait = wait_event_interruptible_timeout(res->wait_pcie_ready, - res->state == - SPRD_PCIE_SCANNED, - delay); - if (wait == 0) - ret = -ETIME; - else if (wait > 0) - ret = 0; - else - ret = wait; - } - - if (ret < 0 && ret != -ERESTARTSYS) - pr_err("pcie res: wait resource, val=%d.\n", ret); - - return ret; -} - -int sprd_pcie_request_resource(u32 dst) -{ - struct sprd_pcie_res *res; - int ret = 0; - - if (dst >= SIPC_ID_NR || !g_pcie_res[dst]) - return -EINVAL; - - res = g_pcie_res[dst]; - - if (res->state == SPRD_PCIE_WAIT_POWER_OFF) - return -EINVAL; - - pr_debug("pcie res: request res, state=%d.\n", res->state); - - switch (res->state) { - case SPRD_PCIE_WAIT_FIRST_READY: - case SPRD_PCIE_WAIT_SCANNED: - pr_info("pcie res: later send request msi to rc.\n"); - res->msi_later = true; - break; - - case SPRD_PCIE_WAIT_REMOVED: - pr_info("pcie res: later send wakeup to rc.\n"); - res->wakeup_later = true; - break; - - case SPRD_PCIE_SCANNED: - /* - * if pcie state is SCANNED, just send - * PCIE_MSI_REQUEST_RES to the host. - * After host receive res msi interrupt, - * it will increase one vote in modem power manger. - */ - pr_info("pcie res: send request msi to rc.\n"); - ret = sprd_pci_epf_raise_irq(res->ep_fun, - PCIE_MSI_REQUEST_RES); - break; - - case SPRD_PCIE_REMOVED: - /* - * if pcie state is removed, poll wake_up singnal - * to host, and he host will rescan the pcie. - */ - pr_info("pcie res: send wakeup to rc.\n"); - if (sprd_pci_epf_start(res->ep_fun) == 0) - break; - - /* may receive ep reset, wait linkup and scanned */ - pr_info("pcie res: later send request msi to rc.\n"); - res->msi_later = true; - break; - - default: - pr_err("pcie res: request res err, state=%d.\n", - res->state); - ret = -EPERM; - break; - } - - return ret; -} - -int sprd_pcie_release_resource(u32 dst) -{ - struct sprd_pcie_res *res; - int ret = 0; - - if (dst >= SIPC_ID_NR || !g_pcie_res[dst]) - return -EINVAL; - - res = g_pcie_res[dst]; - - if (res->state == SPRD_PCIE_WAIT_POWER_OFF) - return -EINVAL; - - switch (res->state) { - case SPRD_PCIE_SCANNED: - /* - * if pcie state is SCANNED, send PCIE_MSI_RELEASE_RES - * to the host, else, do nothing. After host receive res msi - * interrupt, it will decrease one vote in modem power manger, - * and if modem power manger is idle, the host will remove - * the pcie. - */ - pr_info("pcie res: send release msi to rc.\n"); - ret = sprd_pci_epf_raise_irq(res->ep_fun, - PCIE_MSI_RELEASE_RES); - break; - - case SPRD_PCIE_WAIT_FIRST_READY: - /* if has msi pending, remove it */ - if (res->msi_later) - res->msi_later = false; - break; - - default: - pr_err("pcie res: release res state=%d.\n", res->state); - ret = -EPERM; - break; - } - - return ret; -} - -int sprd_register_pcie_resource_first_ready(u32 dst, - void (*notify)(void *p), void *data) -{ - struct sprd_pcie_res *res; - - if (dst >= SIPC_ID_NR || !g_pcie_res[dst]) - return -EINVAL; - - res = g_pcie_res[dst]; - - res->first_ready_notify.data = data; - res->first_ready_notify.notify = notify; - - return 0; -} - -bool sprd_pcie_is_defective_chip(void) -{ - static bool first_read = true, defective; - - if (first_read) { - first_read = false; - defective = sprd_kproperty_chipid("UD710-AB") == 0; - } - - return defective; -} diff --git a/quectel_SRPD_PCIE/src/pcie/pcie_host_resource.c b/quectel_SRPD_PCIE/src/pcie/pcie_host_resource.c deleted file mode 100644 index 5b75344..0000000 --- a/quectel_SRPD_PCIE/src/pcie/pcie_host_resource.c +++ /dev/null @@ -1,720 +0,0 @@ -/* - * Copyright (C) 2019 Spreadtrum Communications Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef CONFIG_SPRD_SIPA_RES -#include "pcie_sipa_res.h" -#endif - -#include "../include/pcie-rc-sprd.h" -#include "../include/sipc.h" -//#include "../include/mdm_ctrl.h" -#include "../include/sprd_pcie_ep_device.h" -#include "../include/sprd_mpm.h" -#include "../include/sprd_pcie_resource.h" - -#define PCIE_REMOVE_SCAN_GAP msecs_to_jiffies(200) -#define MAX_PMS_WAIT_TIME 5000 -#define MAX_PMS_DEFECTIVE_CHIP_FIRST_WAIT_TIME (55 * 1000) - -enum rc_state { - SPRD_PCIE_WAIT_FIRST_READY = 0, - SPRD_PCIE_WAIT_SCANNED, - SPRD_PCIE_SCANNED, - SPRD_PCIE_WAIT_REMOVED, - SPRD_PCIE_REMOVED, - SPRD_PCIE_SCANNED_2BAR, - SPRD_PCIE_WAIT_POWER_OFF -}; - -struct sprd_pcie_res { - u32 dst; - u32 ep_dev; - u32 state; - u32 scan_cnt; - u32 max_wait_time; - bool ep_power_on; - bool ep_dev_probe; - bool smem_send_to_ep; - unsigned long action_jiff; - - struct sprd_pms *pms; - char pms_name[20]; - - wait_queue_head_t wait_pcie_ready; - bool ep_ready_for_rescan; - wait_queue_head_t wait_load_ready; - wait_queue_head_t wait_first_rescan; - struct task_struct *thread; - -#ifdef CONFIG_SPRD_SIPA_RES - void *sipa_res; -#endif -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 4,18,0 )) - struct wakeup_source *ws; -#else - struct wakeup_source ws; -#endif - struct work_struct scan_work; - struct work_struct remove_work; - struct workqueue_struct *wq; - - struct platform_device *pcie_dev; - struct sprd_pcie_register_event reg_event; -}; - -static int sprd_pcie_resource_rescan(struct sprd_pcie_res *res); - -static struct sprd_pcie_res *g_pcie_res[SIPC_ID_NR]; - -static void sprd_pcie_resource_host_first_rescan_do(struct sprd_pcie_res *res) -{ - int ret = sprd_pcie_register_event(&res->reg_event); - - if (ret) - pr_err("pcie res: register pci ret=%d.\n", ret); - - /* power up for ep after the first scan. */ - res->ep_power_on = true; - sprd_pms_power_up(res->pms); - -#ifdef CONFIG_SPRD_SIPA_RES - /* - * in host side, producer res id is SIPA_RM_RES_PROD_PCIE3, - * consumer res id is SIPA_RM_RES_CONS_WWAN_UL. - */ - res->sipa_res = pcie_sipa_res_create(res->dst, - SIPA_RM_RES_PROD_PCIE3, - SIPA_RM_RES_CONS_WWAN_UL); - if (!res->sipa_res) - pr_err("pcie res:create ipa res failed.\n"); -#endif - -} - -static void sprd_pcie_resource_host_ep_notify(int event, void *data) -{ - struct sprd_pcie_res *res = (struct sprd_pcie_res *)data; - u32 base, size; - - /* wait power off, do nothing */ - if (res->state == SPRD_PCIE_WAIT_POWER_OFF) - return; - - switch (event) { - case PCIE_EP_PROBE: - /* set state to scanned */ - res->state = SPRD_PCIE_SCANNED; - res->scan_cnt++; - res->ep_dev_probe = true; - //modem_ctrl_enable_cp_event(); - - if (smem_get_area(SIPC_ID_MINIAP, &base, &size) == 0) - sprd_ep_dev_pass_smem(res->ep_dev, base, size); - - pr_info("pcie res: ep_notify, probed cnt=%d.\n", - res->scan_cnt); - - /* firsrt scan do somtehing */ - if (res->scan_cnt == 1) - sprd_pcie_resource_host_first_rescan_do(res); - - /* clear removed irq and notify ep scanned */ - sprd_ep_dev_clear_doolbell_irq(res->ep_dev, - PCIE_DBEL_EP_REMOVING); - sprd_ep_dev_raise_irq(res->ep_dev, PCIE_DBEL_EP_SCANNED); - - /* wakeup all blocked thread */ - wake_up_interruptible_all(&res->wait_pcie_ready); - break; - - case PCIE_EP_REMOVE: - pr_info("pcie res: ep_notify, removed.\n"); - res->state = SPRD_PCIE_REMOVED; - res->ep_dev_probe = false; - break; - - case PCIE_EP_PROBE_BEFORE_SPLIT_BAR: - res->state = SPRD_PCIE_SCANNED_2BAR; - res->ep_dev_probe = true; - pr_info("pcie res: probed before split bar.\n"); - if (!res->ep_ready_for_rescan) { - wake_up_interruptible_all(&res->wait_load_ready); - } else { - pr_info("pcie res: bar err, rescan.\n"); - sprd_pcie_resource_rescan(res); - } - break; - - default: - break; - } -} - -static irqreturn_t sprd_pcie_resource_host_irq_handler(int irq, void *private) -{ - struct sprd_pcie_res *res = (struct sprd_pcie_res *)private; - - if (irq == PCIE_MSI_REQUEST_RES) { - pr_info("pcie res: ep request res.\n"); - /* - * client modem power up, - * no need wake lock and no need wait resource. - */ - if (!res->ep_power_on) { - res->ep_power_on = true; - sprd_pms_power_up(res->pms); - } - - /* only after received ep request can backup the ep configs. */ - sprd_ep_dev_set_backup(res->ep_dev); - } else if (irq == PCIE_MSI_RELEASE_RES) { - pr_info("pcie res: ep release res.\n"); - /* - * client modem power down, - * no need wake lock. - */ - if (res->ep_power_on) { - res->ep_power_on = false; - sprd_pms_power_down(res->pms, false); - } - } else if (irq == PCIE_MSI_EP_READY_FOR_RESCAN) { - pr_info("pcie res: ep ready for rescan.\n"); - res->ep_ready_for_rescan = true; - wake_up_interruptible_all(&res->wait_first_rescan); - } - - return IRQ_HANDLED; -} - -static void sprd_pcie_resource_scan_fn(struct work_struct *work) -{ - unsigned long diff; - unsigned int delay; - int ret; - struct sprd_pcie_res *res = container_of(work, struct sprd_pcie_res, - scan_work); - - /* wait power off, do nothing */ - if (res->state == SPRD_PCIE_WAIT_POWER_OFF) - return; - - /* request wakelock */ - sprd_pms_request_wakelock(res->pms); - - diff = jiffies - res->action_jiff; - if (diff < PCIE_REMOVE_SCAN_GAP) { - /* must ensure that the scan starts after a period of remove. */ - delay = jiffies_to_msecs(PCIE_REMOVE_SCAN_GAP - diff); - msleep(delay); - } - - pr_info("pcie res: scan\n"); - - ret = sprd_pcie_configure_device(res->pcie_dev); - if (ret) - pr_err("pcie res: scan error = %d!\n", ret); - - /* record the last scan jiffies */ - res->action_jiff = jiffies; - - /* release wakelock */ - sprd_pms_release_wakelock(res->pms); -} - -static void sprd_pcie_resource_remove_fn(struct work_struct *work) -{ - unsigned long diff; - unsigned int delay; - int ret; - struct sprd_pcie_res *res = container_of(work, struct sprd_pcie_res, - remove_work); - /* request wakelock */ - sprd_pms_request_wakelock(res->pms); - - pr_info("pcie res: remove work!\n"); - - diff = jiffies - res->action_jiff; - if (diff < PCIE_REMOVE_SCAN_GAP) { - /* must ensure that the remove starts after a period of scan. */ - delay = jiffies_to_msecs(PCIE_REMOVE_SCAN_GAP - diff); - msleep(delay); - } - - /* - * in wait power off state, or ep device is not probing, - * can't access ep. - */ - if (res->state == SPRD_PCIE_WAIT_POWER_OFF || - !res->ep_dev_probe) { - /* release wakelock */ - sprd_pms_release_wakelock(res->pms); - return; - } - - /* notify ep removed, must before removed */ - sprd_ep_dev_clear_doolbell_irq(res->ep_dev, PCIE_DBEL_EP_SCANNED); - sprd_ep_dev_raise_irq(res->ep_dev, PCIE_DBEL_EP_REMOVING); - - /* waiting for the doorbell irq to ep */ - msleep(50); - - pr_info("pcie res: remove\n"); - - /* start removed ep*/ - ret = sprd_pcie_unconfigure_device(res->pcie_dev); - if (ret) - pr_err("pcie res: remove error = %d.\n!", ret); - - /* record the last remov jiffies */ - res->action_jiff = jiffies; - - /* release wakelock */ - sprd_pms_release_wakelock(res->pms); -} - -static void sprd_pcie_resource_start_scan(struct sprd_pcie_res *res) -{ - if (res->state == SPRD_PCIE_SCANNED || - res->state == SPRD_PCIE_WAIT_SCANNED) { - pr_info("pcie res: scanned, do nothing!\n"); - } else { - pr_info("pcie res: start scan!\n"); - queue_work(res->wq, &res->scan_work); - } -} - -static void sprd_pcie_resource_start_remove(struct sprd_pcie_res *res) -{ - /* wait power off, do nothing */ - if (res->state == SPRD_PCIE_WAIT_POWER_OFF) - return; - - if (res->state == SPRD_PCIE_SCANNED || - res->state == SPRD_PCIE_WAIT_FIRST_READY - || (res->state == SPRD_PCIE_SCANNED_2BAR) - ) { - res->state = SPRD_PCIE_WAIT_REMOVED; - pr_info("pcie res: start remove."); - queue_work(res->wq, &res->remove_work); - } else { - pr_err("pcie res: start remove, err=%d.", res->state); - } -} - -static void sprd_pcie_resource_event_process(enum sprd_pcie_event event, - void *data) -{ - struct sprd_pcie_res *res = data; - - if (event == SPRD_PCIE_EVENT_WAKEUP) { - pr_info("pcie res: wakeup by ep, event=%d.\n", event); - if (!res->ep_power_on) { - res->ep_power_on = true; - sprd_pms_power_up(res->pms); - } - } -} - -/* - * sprd_pcie_resource_rescan - * Because the ep bar can only be split by ep itself, - * After all modem images be loaded at the first time, - * the ep will run and split 2 64bit bar to 4 32bit bar. - * host must rescan the pcie ep device agian by this api, - * after receive ep driver ready for rescan msg and all - * modem images load done. - */ -static int sprd_pcie_resource_rescan(struct sprd_pcie_res *res) -{ - pr_info("pcie res: rescan.\n"); - - sprd_pcie_resource_start_remove(res); - sprd_pcie_resource_start_scan(res); - - return 0; -} - -static int sprd_pcie_resource_check_first_rescan(void *data) -{ - struct sprd_pcie_res *res = data; - int ret; - - pr_info("pcie res: check first rescan.\n"); - - while (!kthread_should_stop()) { - ret = wait_event_interruptible( - res->wait_first_rescan, - res->ep_ready_for_rescan); - if (!ret) { - pr_info("pcie res:first resacn ready.\n"); - sprd_pcie_resource_rescan(res); - break; - } - } - - /* After the first rescan, restore the normal wait time. */ - if (sprd_pcie_is_defective_chip()) - res->max_wait_time = MAX_PMS_WAIT_TIME; - - res->thread = NULL; - return 0; -} - -#if 0 -static int sprd_pcie_resource_host_mcd(struct notifier_block *nb, - unsigned long mode, void *cmd) -{ - struct sprd_pcie_res *res; - int i; - u32 state; - - pr_info("pcie res: mcd mode=%ld.\n", mode); - - switch (mode) { - case MDM_POWER_OFF: - state = SPRD_PCIE_WAIT_POWER_OFF; - break; - - default: - return NOTIFY_DONE; - } - - for (i = 0; i < SIPC_ID_NR; i++) { - res = g_pcie_res[i]; - - /* wait power off, do nothing */ - if (res->state == SPRD_PCIE_WAIT_POWER_OFF) - continue; - - if (res) { - res->state = state; - cancel_work_sync(&res->scan_work); - cancel_work_sync(&res->remove_work); - } - } - - return NOTIFY_DONE; -} - -static struct notifier_block mcd_notify = { - .notifier_call = sprd_pcie_resource_host_mcd, - .priority = 149, -}; -#endif - -/* Because the ep bar can only be split by ep itself, - * After all modem images be loaded, notify the pcie resource. - */ -void sprd_pcie_resource_notify_load_done(u32 dst) -{ - struct sprd_pcie_res *res; - - pr_info("pcie res: load done.\n"); - - if (dst >= SIPC_ID_NR || !g_pcie_res[dst]) - return; - - res = g_pcie_res[dst]; - - res->thread = kthread_create(sprd_pcie_resource_check_first_rescan, res, - "first rescan"); - if (IS_ERR(res->thread)) - pr_err("pcie res: Failed to create rescan thread.\n"); - else - wake_up_process(res->thread); -} - -int sprd_pcie_wait_load_resource(u32 dst) -{ - struct sprd_pcie_res *res; - - if (dst >= SIPC_ID_NR || !g_pcie_res[dst]) - return -EINVAL; - - res = g_pcie_res[dst]; - - /* can load image, return immediately */ - if (res->state == SPRD_PCIE_SCANNED || - res->state == SPRD_PCIE_SCANNED_2BAR) - return 0; - - return wait_event_interruptible( - res->wait_load_ready, - (res->state == SPRD_PCIE_SCANNED || - res->state == SPRD_PCIE_SCANNED_2BAR)); -} - -void sprd_pcie_resource_reboot_ep(u32 dst) -{ - struct sprd_pcie_res *res; - - pr_info("pcie res: reboot ep.\n"); - - if (dst >= SIPC_ID_NR || !g_pcie_res[dst]) - return; - - res = g_pcie_res[dst]; - - /* wait power off, do nothing */ - if (res->state == SPRD_PCIE_WAIT_POWER_OFF) - return; - - res->state = SPRD_PCIE_WAIT_FIRST_READY; - res->smem_send_to_ep = false; - res->ep_ready_for_rescan = false; - - /* The defective chip , the first wait time must be enough long. */ - if (sprd_pcie_is_defective_chip()) - res->max_wait_time = MAX_PMS_DEFECTIVE_CHIP_FIRST_WAIT_TIME; - else - res->max_wait_time = MAX_PMS_WAIT_TIME; - - /* after ep reboot, can't backup ep configs*/ - sprd_ep_dev_clear_backup(res->ep_dev); - - sprd_pcie_resource_start_remove(res); - //modem_ctrl_poweron_modem(MDM_CTRL_COLD_RESET); - sprd_pcie_resource_start_scan(res); -} - -int sprd_pcie_resource_host_init(u32 dst, u32 ep_dev, - struct platform_device *pcie_dev) -{ - struct sprd_pcie_res *res; - - if (dst >= SIPC_ID_NR) - return -EINVAL; - - res = kzalloc(sizeof(*res), GFP_KERNEL); - if (!res) - return -ENOMEM; - - res->wq = create_singlethread_workqueue("pcie_res"); - if (!res->wq) { - pr_err("pcie res:create wq failed.\n"); - kfree(res); - return -ENOMEM; - } - - init_waitqueue_head(&res->wait_load_ready); - init_waitqueue_head(&res->wait_first_rescan); - -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 4,18,0 )) - res->ws = wakeup_source_register(NULL, "pcie_res"); -#else - wakeup_source_init(&res->ws, "pcie_res"); -#endif - - res->dst = dst; - res->state = SPRD_PCIE_WAIT_FIRST_READY; - res->pcie_dev = pcie_dev; - - /* The defective chip , the first wait time must be enough long. */ - if (sprd_pcie_is_defective_chip()) - res->max_wait_time = MAX_PMS_DEFECTIVE_CHIP_FIRST_WAIT_TIME; - else - res->max_wait_time = MAX_PMS_WAIT_TIME; - - init_waitqueue_head(&res->wait_pcie_ready); - INIT_WORK(&res->scan_work, sprd_pcie_resource_scan_fn); - INIT_WORK(&res->remove_work, sprd_pcie_resource_remove_fn); - - sprintf(res->pms_name, "ep-request-%d", dst); - res->pms = sprd_pms_create(dst, res->pms_name, false); - if (!res->pms) - pr_err("pcie res:create pms failed.\n"); - - sprd_ep_dev_register_irq_handler_ex(res->ep_dev, - PCIE_MSI_REQUEST_RES, - PCIE_MSI_RELEASE_RES, - sprd_pcie_resource_host_irq_handler, res); - - sprd_ep_dev_register_notify(res->ep_dev, - sprd_pcie_resource_host_ep_notify, res); - - //modem_ctrl_register_notifier(&mcd_notify); - - /* init wake up event callback */ - res->reg_event.events = SPRD_PCIE_EVENT_WAKEUP; - res->reg_event.pdev = pcie_dev; - res->reg_event.callback = sprd_pcie_resource_event_process; - res->reg_event.data = res; - - g_pcie_res[dst] = res; - - return 0; -} - -int sprd_pcie_resource_trash(u32 dst) -{ - struct sprd_pcie_res *res; - - if (dst >= SIPC_ID_NR || !g_pcie_res[dst]) - return -EINVAL; - - res = g_pcie_res[dst]; - - if (!IS_ERR_OR_NULL(res->thread)) - kthread_stop(res->thread); - -#ifdef CONFIG_SPRD_SIPA_RES - if (res->sipa_res) - pcie_sipa_res_destroy(res->sipa_res); -#endif - - cancel_work_sync(&res->scan_work); - cancel_work_sync(&res->remove_work); - destroy_workqueue(res->wq); - - sprd_pcie_deregister_event(&res->reg_event); - - sprd_ep_dev_unregister_irq_handler_ex(res->ep_dev, - PCIE_MSI_REQUEST_RES, - PCIE_MSI_RELEASE_RES); - sprd_ep_dev_unregister_notify(res->ep_dev); - //modem_ctrl_unregister_notifier(&mcd_notify); - sprd_pms_destroy(res->pms); - - kfree(res); - g_pcie_res[dst] = NULL; - - return 0; -} - -int sprd_pcie_wait_resource(u32 dst, int timeout) -{ - struct sprd_pcie_res *res; - int ret, wait; - unsigned long delay; - - if (dst >= SIPC_ID_NR || !g_pcie_res[dst]) - return -EINVAL; - - res = g_pcie_res[dst]; - - /* pcie ready, return succ immediately. */ - if (res->state == SPRD_PCIE_SCANNED) - return 0; - - if (timeout == 0) - return -ETIME; - - /* - * In some case, orca may has an exception, And the pcie - * resource may never ready again. So we must set a - * maximum wait time for let user to know thereis an - * exception in pcie, and can return an error code to the user. - */ - if (timeout < 0 || timeout > res->max_wait_time) - timeout = res->max_wait_time; - - /* - * timeout must add 1s, - * because the pcie scan may took some time. - */ - delay = msecs_to_jiffies(timeout + 1000); - wait = wait_event_interruptible_timeout(res->wait_pcie_ready, - res->state == - SPRD_PCIE_SCANNED, - delay); - if (wait == 0) - ret = -ETIME; - else if (wait > 0) - ret = 0; - else - ret = wait; - - - if (ret < 0 && ret != -ERESTARTSYS) - pr_err("pcie res: wait resource, val=%d.\n", ret); - - return ret; -} - -int sprd_pcie_request_resource(u32 dst) -{ - struct sprd_pcie_res *res; - - if (dst >= SIPC_ID_NR || !g_pcie_res[dst]) - return -EINVAL; - - res = g_pcie_res[dst]; - - /* get a wakelock */ -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 4,18,0 )) - __pm_stay_awake(res->ws); -#else - __pm_stay_awake(&res->ws); -#endif - - pr_info("pcie res: request resource, state=%d.\n", res->state); - -#ifdef CONFIG_SPRD_PCIE - /* The first scan is start by pcie driver automatically. */ - if (res->state != SPRD_PCIE_WAIT_FIRST_READY) - sprd_pcie_resource_start_scan(res); -#endif - - return 0; -} - -int sprd_pcie_release_resource(u32 dst) -{ - struct sprd_pcie_res *res; - - if (dst >= SIPC_ID_NR || !g_pcie_res[dst]) - return -EINVAL; - - res = g_pcie_res[dst]; - - /* relax a wakelock */ -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 4,18,0 )) - __pm_relax(res->ws); -#else - __pm_relax(&res->ws); -#endif - -#ifdef CONFIG_SPRD_PCIE - pr_info("pcie res: release resource.\n"); - - sprd_pcie_resource_start_remove(res); -#endif - return 0; -} - -bool sprd_pcie_is_defective_chip(void) -{ -#ifndef CONFIG_SPRD_PCIE - return false; -#else - static bool first_read = true, defective; - - if (first_read) { - first_read = false; - defective = sprd_kproperty_chipid("UD710-AB") == 0; - } - - return defective; -#endif -} diff --git a/quectel_SRPD_PCIE/src/pcie/pcie_sipa_res.c b/quectel_SRPD_PCIE/src/pcie/pcie_sipa_res.c deleted file mode 100644 index dea3da3..0000000 --- a/quectel_SRPD_PCIE/src/pcie/pcie_sipa_res.c +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Copyright (C) 2018-2019 Unisoc Corporation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - */ -#include -#include -#include -#include - -#include "pcie_sipa_res.h" -#include "../include/sprd_pcie_resource.h" - -struct pcie_sipa_res_prod { - u8 dst; - enum sipa_rm_res_id prod_id; /* producer res id */ - enum sipa_rm_res_id cons_id; /* consumer res id */ - struct sprd_pms *pms; - char pms_name[20]; - struct work_struct wait_work; - struct delayed_work rm_work; -}; - -static void pcie_sipa_res_wait_res_work_fn(struct work_struct *work) -{ - int ret; - struct pcie_sipa_res_prod *res = container_of(work, - struct pcie_sipa_res_prod, - wait_work); - - ret = sprd_pcie_wait_resource(res->dst, -1); - - /* pcie not ready, just return. */ - if (ret) { - pr_err("pcie_sipa_res: wait res error = %d!\n", ret); - return; - } - - /* notify ipa module that pcie is ready. */ - sipa_rm_notify_completion(SIPA_RM_EVT_GRANTED, - res->prod_id); -} - -static int pcie_sipa_res_request_resource(void *data) -{ - int ret; - struct pcie_sipa_res_prod *res = data; - - pr_info("pcie_sipa_res: request resource.\n"); - - sprd_pms_power_up(res->pms); - - /* - * when the resource is not ready, the IPA module doesn't want be - * blocked in here until the pcie ready, the IPA owner designed - * a notification api sipa_rm_notify_completion to notify the - * IPA module that the resource requested by IPA is ready. - * The designated error value is -EINPROGRESS, so we must override the - * return value -ETIME to -EINPROGRESS. - */ - ret = sprd_pcie_wait_resource(res->dst, 0); - - if (ret == -ETIME) { - /* add a work to wait pcie ready */ - schedule_work(&res->wait_work); - ret = -EINPROGRESS; - } - - return ret; -} - -static int pcie_sipa_res_release_resource(void *data) -{ - struct pcie_sipa_res_prod *res = data; - - pr_info("pcie_sipa_res: release resource.\n"); - - sprd_pms_release_resource(res->pms); - - return 0; -} - -static void pcie_sipa_res_create_rm_work_fn(struct work_struct *work) -{ - int ret; - struct sipa_rm_create_params rm_params; - struct pcie_sipa_res_prod *res = container_of(to_delayed_work(work), - struct pcie_sipa_res_prod, - rm_work); - - rm_params.name = res->prod_id; - rm_params.floor_voltage = 0; - rm_params.reg_params.notify_cb = NULL; - rm_params.reg_params.user_data = res; - rm_params.request_resource = pcie_sipa_res_request_resource; - rm_params.release_resource = pcie_sipa_res_release_resource; - ret = sipa_rm_create_resource(&rm_params); - - /* defer to create rm */ - if (ret == -EPROBE_DEFER) { - schedule_delayed_work(&res->rm_work, msecs_to_jiffies(1000)); - return; - } - - /* add dependencys */ - ret = sipa_rm_add_dependency(res->cons_id, res->prod_id); - if (ret < 0 && ret != -EINPROGRESS) { - pr_err("pcie_sipa_res: add_dependency error = %d!\n", ret); - sipa_rm_delete_resource(res->prod_id); - sprd_pms_destroy(res->pms); - kfree(res); - } -} - -void *pcie_sipa_res_create(u8 dst, enum sipa_rm_res_id prod_id, - enum sipa_rm_res_id cons_id) -{ - int ret; - struct sipa_rm_create_params rm_params; - struct pcie_sipa_res_prod *res; - - res = kzalloc(sizeof(*res), GFP_KERNEL); - if (!res) - return NULL; - - /* init wait pcie res work */ - INIT_WORK(&res->wait_work, pcie_sipa_res_wait_res_work_fn); - INIT_DELAYED_WORK(&res->rm_work, pcie_sipa_res_create_rm_work_fn); - - /* create pms */ - strncpy(res->pms_name, "sipa", sizeof(res->pms_name)); - res->pms = sprd_pms_create(dst, res->pms_name, false); - if (!res->pms) { - pr_err("pcie_sipa_res: create pms failed!\n"); - kfree(res); - return NULL; - } - - res->dst = dst; - res->prod_id = prod_id; - res->cons_id = cons_id; - - /* create prod */ - rm_params.name = prod_id; - rm_params.floor_voltage = 0; - rm_params.reg_params.notify_cb = NULL; - rm_params.reg_params.user_data = res; - rm_params.request_resource = pcie_sipa_res_request_resource; - rm_params.release_resource = pcie_sipa_res_release_resource; - ret = sipa_rm_create_resource(&rm_params); - - /* defer to create rm */ - if (ret == -EPROBE_DEFER) { - schedule_delayed_work(&res->rm_work, msecs_to_jiffies(1000)); - return res; - } else if (ret) { - pr_err("pcie_sipa_res: create rm error = %d!\n", ret); - sprd_pms_destroy(res->pms); - kfree(res); - return NULL; - } - - /* add dependencys */ - ret = sipa_rm_add_dependency(cons_id, prod_id); - if (ret < 0 && ret != -EINPROGRESS) { - pr_err("pcie_sipa_res: add_dependency error = %d!\n", ret); - sipa_rm_delete_resource(prod_id); - sprd_pms_destroy(res->pms); - kfree(res); - return NULL; - } - - return res; -} - -void pcie_sipa_res_destroy(void *data) -{ - struct pcie_sipa_res_prod *res = data; - - cancel_work_sync(&res->wait_work); - cancel_delayed_work_sync(&res->rm_work); - - sprd_pms_destroy(res->pms); - sipa_rm_delete_dependency(res->cons_id, res->prod_id); - sipa_rm_delete_resource(res->prod_id); - kfree(res); -} - diff --git a/quectel_SRPD_PCIE/src/pcie/pcie_sipa_res.h b/quectel_SRPD_PCIE/src/pcie/pcie_sipa_res.h deleted file mode 100644 index 144bcc5..0000000 --- a/quectel_SRPD_PCIE/src/pcie/pcie_sipa_res.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2018-2019 Unisoc Corporation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - */ - -#ifndef PCIE_SIPA_RES_H -#define PCIE_SIPA_RES_H - -#include "../include/sipa.h" - -/* - * pcie_sipa_res_create - create pcie res for sipa module. - * @prod_id: which res is the producer. - * @cons_id: which res is the consumer. - * - * Returns: - * failed, return NULL, - * succ, return a void * pointer. - */ -void *pcie_sipa_res_create(u8 dst, enum sipa_rm_res_id prod_id, - enum sipa_rm_res_id cons_id); - -/* - * pcie_sipa_res_destroy -detroy pcie res for sipa module - * @res_id: the return point of call function pcie_sipa_res_create. - */ -void pcie_sipa_res_destroy(void *res); -#endif - diff --git a/quectel_SRPD_PCIE/src/pcie/sprd_pcie_ep_device.c b/quectel_SRPD_PCIE/src/pcie/sprd_pcie_ep_device.c deleted file mode 100644 index af6b922..0000000 --- a/quectel_SRPD_PCIE/src/pcie/sprd_pcie_ep_device.c +++ /dev/null @@ -1,1663 +0,0 @@ -/** - * SPRD ep device driver in host side for Spreadtrum SoCs - * - * Copyright (C) 2018 Spreadtrum Co., Ltd. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 of - * the License as published by the Free Software Foundation. - * - * This program is used to control ep device driver in host side for - * Spreadtrum SoCs. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "../include/pcie-rc-sprd.h" -#include "../include/sprd_pcie_ep_device.h" -#include "../include/sipc_big_to_little.h" -#include "../include/sprd_pcie_resource.h" -#include "../include/sipc.h" -#include "../include/sipa.h" -#include "../sipa/sipa_core.h" - -#define DRV_MODULE_NAME "sprd-pcie-ep-device" -#define CONFIG_SPRD_IPA_PCIE_WORKROUND - -enum dev_pci_barno { - BAR_0 = 0, - BAR_1, - BAR_2, - BAR_3, - BAR_4, - BAR_5, - BAR_CNT -}; - -#define MAX_SUPPORT_IRQ 32 -#define IPA_HW_IRQ_CNT 4 -#define IPA_HW_IRQ_BASE 16 -#define IPA_HW_IRQ_BASE_DEFECT 0 - -#define REQUEST_BASE_IRQ (IPA_HW_IRQ_BASE + IPA_HW_IRQ_CNT) -#define REQUEST_BASE_IRQ_DEFECT 16 - -#ifdef CONFIG_SPRD_IPA_PCIE_WORKROUND -/* the bar0 and the bar1 are used for ipa */ -#define IPA_MEM_BAR BAR_0 -#define IPA_REG_BAR BAR_1 -#define BAR_MIN BAR_2 -#else -#define BAR_MIN BAR_0 -#endif - -/* the bar4 and the bar5 are specail bars */ -#define BAR_MAX BAR_4 - -#define PCI_VENDOR_ID_SPRD 0x16c3 -#define PCI_DEVICE_ID_SPRD_ORCA 0xabcd -#define PCI_CLASS_ID_SPRD_ORCA 0x80d00 - -/* Parameters for the waiting for iATU enabled routine */ -#define LINK_WAIT_MAX_IATU_RETRIES 5 -#define LINK_WAIT_IATU_MIN 9000 -#define LINK_WAIT_IATU_MAX 10000 - -/* ep config bar bar4 , can config ep iatu reg and door bell reg */ -#define EP_CFG_BAR BAR_4 -#define DOOR_BELL_BASE 0x00000 -#define IATU_REG_BASE 0x10000 - -#define DOOR_BELL_ENABLE 0x10 -#define DOOR_BELL_STATUS 0x14 - -/* used 0x18 & 0x1c to save the smem base & size. */ -#define DOOR_BELL_SMEMBASE 0x18 -#define DOOR_BELL_SMEMSIZE 0x1C - -/* one bit can indicate one irq , if stauts[i] & enable[i] , irq = i */ -#define DOOR_BELL_IRQ_VALUE(irq) BIT((irq)) -#define DOOR_BELL_IRQ_CNT 32 -#define IATU_MAX_REGION 8 -#define PCIE_ATU_VIEWPORT 0x900 -#define PCIE_ATU_CR1 0x904 -#define PCIE_ATU_CR2 0x908 -#define PCIE_ATU_LOWER_BASE 0x90c -#define PCIE_ATU_UPPER_BASE 0x910 -#define PCIE_ATU_LIMIT 0x914 -#define PCIE_ATU_LOWER_TARGET 0x918 -#define PCIE_ATU_UPPER_TARGET 0x91c - -#define PCIE_ATU_REGION_INBOUND BIT(31) -#define PCIE_ATU_ENABLE BIT(31) -#define PCIE_ATU_BAR_MODE_ENABLE BIT(30) -#define PCIE_ATU_TYPE_MEM 0x0 - -#define PCIE_ATU_UNR_REGION_CTRL1 0x00 -#define PCIE_ATU_UNR_REGION_CTRL2 0x04 -#define PCIE_ATU_UNR_LOWER_BASE 0x08 -#define PCIE_ATU_UNR_UPPER_BASE 0x0c -#define PCIE_ATU_UNR_LIMIT 0x10 -#define PCIE_ATU_UNR_LOWER_TARGET 0x14 -#define PCIE_ATU_UNR_UPPER_TARGET 0x18 - -/* bar4 + 0x10000 has map to ep base + 0x18000 ((0x3 << 15)) */ -#define PCIE_ATU_IB_REGION(region) (((region) << 9) | (0x1 << 8)) -#define PCIE_ATU_OB_REGION(region) ((region) << 9) - -#define PCIE_SAVE_REGION_NUM (IATU_MAX_REGION * 2) -#define PCIE_SAVE_REG_NUM 8 - -#define PCIE_LEGACY_CLEAR_BASE 0x29000000 -#define PCIE_LEGACY_CLEAR_REG 0x2c -#define PCIE_LEGACY_CLEAR_MASK BIT(0) -#define BIT_SET_OFFSET 0x1000 -#define BIT_CLR_OFFSET 0x2000 - -struct sprd_ep_dev_notify { - void (*notify)(int event, void *data); - void *data; -}; - -struct sprd_pci_ep_dev { - struct pci_dev *pdev; - void __iomem *cfg_base; /* ep config bar base in rc */ - spinlock_t irq_lock; /* irq spinlock */ - spinlock_t bar_lock; /* bar spinlock */ - spinlock_t set_irq_lock; /* set irq spinlock */ - spinlock_t set_bar_lock; /* set bar spinlock */ - unsigned long bar_res; - - u32 base_irq; - u32 ipa_base_irq; - u32 bak_irq_status; - u8 iatu_unroll_enabled; - u8 ep; - u8 irq_cnt; - bool no_msi; - bool need_backup; - void __iomem *legacy_addr; - - struct resource *bar[BAR_CNT]; - void __iomem *bar_vir[BAR_MAX]; - void __iomem *cpu_vir[BAR_MAX]; - dma_addr_t src_addr[BAR_MAX]; - dma_addr_t target_addr[BAR_MAX]; - size_t map_size[BAR_MAX]; - int event; - struct work_struct notify_work; -}; - -struct sprd_pci_ep_dev_save { - bool save_succ; - unsigned long bar_res; - void __iomem *bar_vir[BAR_MAX]; - void __iomem *cpu_vir[BAR_MAX]; - dma_addr_t src_addr[BAR_MAX]; - dma_addr_t target_addr[BAR_MAX]; - size_t map_size[BAR_MAX]; - u32 doorbell_enable; - u32 doorbell_status; - void __iomem *cfg_base; - u32 save_reg[PCIE_SAVE_REGION_NUM][PCIE_SAVE_REG_NUM]; -}; - -#define VERSION_NUMBER "V1.1.6" -#define QUECTEL_SPRD_PCIE_VERSION "Quectel_Linux&Android_SPRD_PCIE_Driver_"VERSION_NUMBER - -static void __iomem *g_irq_addr[PCIE_EP_NR]; -static struct sprd_pci_ep_dev_save g_ep_save[PCIE_EP_NR]; -static struct sprd_pci_ep_dev *g_ep_dev[PCIE_EP_NR]; -static irq_handler_t ep_dev_handler[PCIE_EP_NR][PCIE_MSI_MAX_IRQ]; -static void *ep_dev_handler_data[PCIE_EP_NR][PCIE_MSI_MAX_IRQ]; -static struct sprd_ep_dev_notify g_ep_dev_notify[PCIE_EP_NR]; - -static int sprd_ep_dev_get_bar(int ep); -static int sprd_ep_dev_put_bar(int ep, int bar); -static int sprd_ep_dev_adjust_region(struct sprd_pci_ep_dev *ep_dev, - int bar, dma_addr_t *cpu_addr_ptr, - size_t *size_ptr, dma_addr_t *offset_ptr); -static int sprd_ep_dev_just_map_bar(struct sprd_pci_ep_dev *ep_dev, int bar, - dma_addr_t cpu_addr, size_t size); -static int sprd_ep_dev_just_unmap_bar(struct sprd_pci_ep_dev *ep_dev, int bar); -static void __iomem *sprd_ep_dev_map_bar(int ep, int bar, - dma_addr_t cpu_addr, - size_t size); -static int sprd_ep_dev_unmap_bar(int ep, int bar); -static void sprd_pci_ep_dev_backup(struct sprd_pci_ep_dev *ep_dev); - -static void sprd_pcie_iommu_init(struct device *dev) -{ - struct iommu_domain *domain = NULL; - unsigned long pg_size; - dma_addr_t start, end, addr; - u32 base, size; - int ret = 0; - - domain = iommu_get_domain_for_dev(dev); - if(!domain) { - dev_info(dev, "sprd_pcie_iommu_init domian null"); - return; - } - - pg_size = 1UL << __ffs(domain->pgsize_bitmap); - smem_get_area(SIPC_ID_MINIAP, &base, &size); - start = ALIGN(base, pg_size); - end = ALIGN(base + size, pg_size); - - for (addr = start; addr < end; addr += pg_size) { - phys_addr_t phys_addr; - - phys_addr = iommu_iova_to_phys(domain, addr); - if (phys_addr) { - dev_info(dev, "sprd_pcie_iommu_init iova:%d have been used", (u32)addr); - continue; - } - ret = iommu_map(domain, addr, addr, pg_size, IOMMU_READ | IOMMU_WRITE); - if (ret) { - dev_info(dev, "sprd_pcie_iommu_init iommu_map failed"); - return; - } - } -} - - - -#if (LINUX_VERSION_CODE < KERNEL_VERSION( 3,11,0 )) -int pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec) -{ - int nvec = maxvec; - int rc; - - if (maxvec < minvec) - return -ERANGE; - - do { - rc = pci_enable_msi_block(dev, nvec); - if (rc < 0) { - return rc; - } else if (rc > 0) { - if (rc < minvec) - return -ENOSPC; - nvec = rc; - } - } while (rc); - - return nvec; -} -#endif - -int sprd_ep_dev_register_notify(int ep, - void (*notify)(int event, void *data), - void *data) -{ - struct sprd_ep_dev_notify *dev_notify; - - if (ep >= PCIE_EP_NR) - return -EINVAL; - - dev_notify = &g_ep_dev_notify[ep]; - dev_notify->notify = notify; - dev_notify->data = data; - - return 0; -} -EXPORT_SYMBOL_GPL(sprd_ep_dev_register_notify); - -int sprd_ep_dev_unregister_notify(int ep) -{ - struct sprd_ep_dev_notify *notify; - - if (ep >= PCIE_EP_NR) - return -EINVAL; - - notify = &g_ep_dev_notify[ep]; - notify->notify = NULL; - notify->data = NULL; - - return 0; -} -EXPORT_SYMBOL_GPL(sprd_ep_dev_unregister_notify); - -int sprd_ep_dev_set_irq_addr(int ep, void __iomem *irq_addr) -{ - if (ep >= PCIE_EP_NR) - return -EINVAL; - - g_irq_addr[ep] = irq_addr; - - return 0; -} -EXPORT_SYMBOL_GPL(sprd_ep_dev_set_irq_addr); - -int sprd_ep_dev_register_irq_handler(int ep, int irq, - irq_handler_t handler, void *data) -{ - struct sprd_pci_ep_dev *ep_dev; - - if (ep >= PCIE_EP_NR || irq >= PCIE_MSI_MAX_IRQ) - return -EINVAL; - - ep_dev_handler[ep][irq] = handler; - ep_dev_handler_data[ep][irq] = data; - ep_dev = g_ep_dev[ep]; - - if (handler && ep_dev && - (BIT(irq) & ep_dev->bak_irq_status)) { - ep_dev->bak_irq_status &= ~BIT(irq); - handler(irq, data); - } - - return 0; -} -EXPORT_SYMBOL_GPL(sprd_ep_dev_register_irq_handler); - -int sprd_ep_dev_unregister_irq_handler(int ep, int irq) -{ - if (ep < PCIE_EP_NR && irq < PCIE_MSI_MAX_IRQ) { - ep_dev_handler[ep][irq] = NULL; - ep_dev_handler_data[ep][irq] = NULL; - return 0; - } - - return -EINVAL; -} -EXPORT_SYMBOL_GPL(sprd_ep_dev_unregister_irq_handler); - -int sprd_ep_dev_register_irq_handler_ex(int ep, - int from_irq, - int to_irq, - irq_handler_t handler, - void *data) -{ - int i, ret; - - for (i = from_irq; i < to_irq + 1; i++) { - ret = sprd_ep_dev_register_irq_handler(ep, - i, handler, data); - if (ret) - return ret; - } - - return 0; -} - -int sprd_ep_dev_unregister_irq_handler_ex(int ep, - int from_irq, - int to_irq) -{ - int i, ret; - - for (i = from_irq; i < to_irq + 1; i++) { - ret = sprd_ep_dev_unregister_irq_handler(ep, i); - if (ret) - return ret; - } - - return 0; -} - -void __iomem *sprd_ep_map_memory(int ep, - phys_addr_t cpu_addr, - size_t size) -{ - int bar; - void __iomem *bar_addr; - - bar = sprd_ep_dev_get_bar(ep); - if (bar < 0) { - pr_err("%s: get bar err = %d\n", __func__, bar); - return NULL; - } - - bar_addr = sprd_ep_dev_map_bar(ep, bar, cpu_addr, size); - if (!bar_addr) { - pr_err("%s: map bar = %d err!\n", __func__, bar); - sprd_ep_dev_put_bar(ep, bar); - return NULL; - } - - return bar_addr; -} -EXPORT_SYMBOL_GPL(sprd_ep_map_memory); - -void sprd_ep_unmap_memory(int ep, const void __iomem *bar_addr) -{ - int bar; - struct sprd_pci_ep_dev *ep_dev; - - if (ep >= PCIE_EP_NR || !g_ep_dev[ep]) - return; - - ep_dev = g_ep_dev[ep]; - - for (bar = 0; bar < BAR_MAX; bar++) { - if (bar_addr == ep_dev->cpu_vir[bar]) { - sprd_ep_dev_unmap_bar(ep, bar); - sprd_ep_dev_put_bar(ep, bar); - break; - } - } -} -EXPORT_SYMBOL_GPL(sprd_ep_unmap_memory); - -#ifdef CONFIG_SPRD_SIPA -phys_addr_t sprd_ep_ipa_map(int type, phys_addr_t target_addr, size_t size) -{ - int bar, ep = PCIE_EP_MODEM; - dma_addr_t offset; - struct sprd_pci_ep_dev *ep_dev; - struct pci_dev *pdev; - struct device *dev; - struct resource *res; - - ep_dev = g_ep_dev[ep]; - if (!ep_dev) - return 0; - - ep_dev = g_ep_dev[ep]; - pdev = ep_dev->pdev; - dev = &pdev->dev; -#ifdef CONFIG_SPRD_IPA_PCIE_WORKROUND - bar = type == PCIE_IPA_TYPE_MEM ? IPA_MEM_BAR : IPA_REG_BAR; -#else - bar = sprd_ep_dev_get_bar(ep); - if (bar < 0) { - dev_err(dev, "ep: ipa map, get bar err = %d\n", bar); - return 0; - } -#endif - res = &pdev->resource[bar]; - - dev_info(dev, "ep: ipa map type=%d, addr=0x%lx, size=0x%lx\n", - type, - (unsigned long)target_addr, - (unsigned long)size); - - /* 1st, adjust the map region */ - if (sprd_ep_dev_adjust_region(ep_dev, bar, &target_addr, - &size, &offset)) - return 0; - - /* than, map bar */ - if (sprd_ep_dev_just_map_bar(ep_dev, bar, target_addr, size)) - return 0; - - /* save for unmap */ - ep_dev->src_addr[bar] = res->start + offset; - ep_dev->target_addr[bar] = target_addr; - ep_dev->map_size[bar] = size; - - /* return the cpu phy address */ - return res->start + offset; -} - -int sprd_ep_ipa_unmap(int type, const phys_addr_t cpu_addr) -{ - int bar, ep = PCIE_EP_MODEM; - bool find_bar = false; - struct sprd_pci_ep_dev *ep_dev; - struct pci_dev *pdev; - struct resource *res; - - ep_dev = g_ep_dev[ep]; - if (!ep_dev) - return -EINVAL; - - pdev = ep_dev->pdev; - res = &pdev->resource[bar]; - - dev_info(&pdev->dev, "ep: ipa unmap cpu_addr=0x%lx\n", - (unsigned long)cpu_addr); - -#ifdef CONFIG_SPRD_IPA_PCIE_WORKROUND - bar = type == PCIE_IPA_TYPE_MEM ? IPA_MEM_BAR : IPA_REG_BAR; - if (ep_dev->src_addr[bar] == cpu_addr) - find_bar = true; -#else - for (bar = 0; bar < BAR_MAX; bar++) { - if (cpu_addr == ep_dev->src_addr[bar]) { - find_bar = true; - break; - } - } -#endif - - if (!find_bar) { - dev_err(&pdev->dev, "ep: ipa unmap can't find bar!"); - return -EINVAL; - } - - ep_dev->target_addr[bar] = 0; - ep_dev->target_addr[bar] = 0; - ep_dev->map_size[bar] = 0; - return sprd_ep_dev_just_unmap_bar(ep_dev, bar); -} -#endif - -int sprd_ep_dev_raise_irq(int ep, int irq) -{ - struct pci_dev *pdev; - struct device *dev; - struct sprd_pci_ep_dev *ep_dev; - void __iomem *base; - u32 value; - - if (ep >= PCIE_EP_NR || !g_ep_dev[ep]) - return -ENODEV; - - ep_dev = g_ep_dev[ep]; - pdev = ep_dev->pdev; - dev = &pdev->dev; - - dev_dbg(dev, "ep: raise, ep=%d, irq=%d\n", ep, irq); - - if (irq >= DOOR_BELL_IRQ_CNT) { - dev_err(&pdev->dev, "raise err, irq=%d\n", irq); - return -EINVAL; - } - - spin_lock(&ep_dev->set_irq_lock); - base = ep_dev->cfg_base + DOOR_BELL_BASE; - value = readl_relaxed(base + DOOR_BELL_STATUS); - writel_relaxed(value | DOOR_BELL_IRQ_VALUE(irq), - base + DOOR_BELL_STATUS); - spin_unlock(&ep_dev->set_irq_lock); - - return 0; -} -EXPORT_SYMBOL_GPL(sprd_ep_dev_raise_irq); - -int sprd_ep_dev_clear_doolbell_irq(int ep, int irq) -{ - struct pci_dev *pdev; - struct device *dev; - struct sprd_pci_ep_dev *ep_dev; - void __iomem *base; - u32 value; - - if (ep >= PCIE_EP_NR || !g_ep_dev[ep]) - return -ENODEV; - - ep_dev = g_ep_dev[ep]; - pdev = ep_dev->pdev; - dev = &pdev->dev; - - dev_dbg(dev, "ep: clear doorbell, ep=%d, irq=%d\n", ep, irq); - - if (irq >= DOOR_BELL_IRQ_CNT) - return -EINVAL; - - spin_lock(&ep_dev->set_irq_lock); - base = ep_dev->cfg_base + DOOR_BELL_BASE; - value = readl_relaxed(base + DOOR_BELL_STATUS); - if (value & DOOR_BELL_IRQ_VALUE(irq)) - writel_relaxed(value & (~DOOR_BELL_IRQ_VALUE(irq)), - base + DOOR_BELL_STATUS); - spin_unlock(&ep_dev->set_irq_lock); - - return 0; -} - -int sprd_ep_dev_set_backup(int ep) -{ - struct sprd_pci_ep_dev *ep_dev; - - if (ep >= PCIE_EP_NR || !g_ep_dev[ep]) - return -ENODEV; - - ep_dev = g_ep_dev[ep]; - ep_dev->need_backup = true; - - /* backup once immediately. */ - sprd_pci_ep_dev_backup(ep_dev); - - return 0; -} - -int sprd_ep_dev_clear_backup(int ep) -{ - struct sprd_pci_ep_dev *ep_dev; - - if (ep >= PCIE_EP_NR || !g_ep_dev[ep]) - return -ENODEV; - - ep_dev = g_ep_dev[ep]; - ep_dev->need_backup = false; - - return 0; -} - -int sprd_ep_dev_pass_smem(int ep, u32 base, u32 size) -{ - struct sprd_pci_ep_dev *ep_dev; - void __iomem *reg_base; - struct pci_dev *pdev; - struct device *dev; - - if (ep >= PCIE_EP_NR || !g_ep_dev[ep]) - return -ENODEV; - - ep_dev = g_ep_dev[ep]; - pdev = ep_dev->pdev; - dev = &pdev->dev; - dev_info(&pdev->dev, - "pass_smem, base=0x%x,size=0x%x\n", - base, size); - - reg_base = ep_dev->cfg_base + DOOR_BELL_BASE; - - writel_relaxed(base, reg_base + DOOR_BELL_SMEMBASE); - writel_relaxed(size, reg_base + DOOR_BELL_SMEMSIZE); - - return 0; -} - -static inline u32 sprd_pci_ep_iatu_readl(struct sprd_pci_ep_dev *ep_dev, - u32 offset) -{ - return readl_relaxed(ep_dev->cfg_base + IATU_REG_BASE + offset); -} - -static inline void sprd_pci_ep_iatu_writel(struct sprd_pci_ep_dev *ep_dev, - u32 offset, u32 value) -{ - writel_relaxed(value, ep_dev->cfg_base + IATU_REG_BASE + offset); -} - -static int sprd_ep_dev_get_bar(int ep) -{ - int bar; - int ret = -EBUSY; - struct sprd_pci_ep_dev *ep_dev; - - if (ep >= PCIE_EP_NR || !g_ep_dev[ep]) - return -ENODEV; - - ep_dev = g_ep_dev[ep]; - spin_lock(&ep_dev->bar_lock); - for (bar = BAR_MIN; bar < BAR_MAX; bar++) { - if (ep_dev->bar[bar] && !test_bit(bar, &ep_dev->bar_res)) { - set_bit(bar, &ep_dev->bar_res); - ret = bar; - break; - } - } - spin_unlock(&ep_dev->bar_lock); - - return ret; -} - -static int sprd_ep_dev_put_bar(int ep, int bar) -{ - int ret = -ENODEV; - struct sprd_pci_ep_dev *ep_dev; - - if (ep >= PCIE_EP_NR || !g_ep_dev[ep]) - return -ENODEV; - - ep_dev = g_ep_dev[ep]; - spin_lock(&ep_dev->bar_lock); - if (test_and_clear_bit(bar, &ep_dev->bar_res)) - ret = bar; - spin_unlock(&ep_dev->bar_lock); - - return ret; -} - -static int sprd_ep_dev_unr_set_bar(struct sprd_pci_ep_dev *ep_dev, - int bar, - dma_addr_t cpu_addr, size_t size) -{ - u32 retries, val; - struct pci_dev *pdev = ep_dev->pdev; - - spin_lock(&ep_dev->set_bar_lock); - - /* bar n use region n to map, map to bar match mode */ - sprd_pci_ep_iatu_writel(ep_dev, - PCIE_ATU_IB_REGION(bar) + - PCIE_ATU_UNR_LOWER_TARGET, - lower_32_bits(cpu_addr)); - sprd_pci_ep_iatu_writel(ep_dev, - PCIE_ATU_IB_REGION(bar) + - PCIE_ATU_UNR_UPPER_TARGET, - upper_32_bits(cpu_addr)); - - sprd_pci_ep_iatu_writel(ep_dev, - PCIE_ATU_IB_REGION(bar) + - PCIE_ATU_UNR_REGION_CTRL1, - PCIE_ATU_TYPE_MEM); - sprd_pci_ep_iatu_writel(ep_dev, - PCIE_ATU_IB_REGION(bar) + - PCIE_ATU_UNR_REGION_CTRL2, - PCIE_ATU_ENABLE | - PCIE_ATU_BAR_MODE_ENABLE | (bar << 8)); - - spin_unlock(&ep_dev->set_bar_lock); - - /* - * Make sure ATU enable takes effect before any subsequent config - * and I/O accesses. - */ - for (retries = 0; retries < LINK_WAIT_MAX_IATU_RETRIES; retries++) { - val = sprd_pci_ep_iatu_readl(ep_dev, - PCIE_ATU_IB_REGION(bar) + - PCIE_ATU_UNR_REGION_CTRL2); - if (val & PCIE_ATU_ENABLE) - return 0; - - dev_dbg(&pdev->dev, - "ep: unr set bar[%d], var = 0x%x\n", - bar, - val); - /* wait a moment for polling ep atu enable bit */ - usleep_range(LINK_WAIT_IATU_MIN, LINK_WAIT_IATU_MAX); - } - - return -EINVAL; -} - -static int sprd_ep_dev_unr_clear_bar(struct sprd_pci_ep_dev *ep_dev, int bar) -{ - struct pci_dev *pdev = ep_dev->pdev; - - dev_dbg(&pdev->dev, "ep: unr clear map bar=%d\n", bar); - - spin_lock(&ep_dev->set_bar_lock); - - sprd_pci_ep_iatu_writel(ep_dev, - PCIE_ATU_IB_REGION(bar) + - PCIE_ATU_UNR_REGION_CTRL2, - (u32)(~PCIE_ATU_ENABLE)); - spin_unlock(&ep_dev->set_bar_lock); - - return 0; -} - -static int sprd_ep_dev_adjust_region(struct sprd_pci_ep_dev *ep_dev, int bar, - dma_addr_t *cpu_addr_ptr, - size_t *size_ptr, - dma_addr_t *offset_ptr) -{ - dma_addr_t cpu_addr, base, offset; - resource_size_t bar_size, size; - struct pci_dev *pdev = ep_dev->pdev; - struct resource *res = &pdev->resource[bar]; - - size = (resource_size_t)*size_ptr; - cpu_addr = *cpu_addr_ptr; - bar_size = resource_size(res); - - /* size must align with page */ - size = PAGE_ALIGN(size); - - /* base must be divisible by bar size for bar match mode */ - base = cpu_addr / bar_size * bar_size; - offset = cpu_addr - base; - size += PAGE_ALIGN(offset); - - /* size must < bar size */ - if (size > bar_size) { - dev_err(&pdev->dev, - "bar[%d]:size=0x%lx > 0x%lx\n", - bar, - (unsigned long)size, - (unsigned long)bar_size); - return -EINVAL; - } - - dev_dbg(&pdev->dev, - "bar[%d]: base=0x%lx,size=0x%lx,offset=0x%lx\n", - bar, (unsigned long)base, - (unsigned long)size, - (unsigned long)offset); - - *size_ptr = (size_t)size; - *offset_ptr = offset; - *cpu_addr_ptr = base; - - return 0; -} - -static int sprd_ep_dev_just_map_bar(struct sprd_pci_ep_dev *ep_dev, int bar, - dma_addr_t cpu_addr, size_t size) -{ - u32 retries, val; - struct pci_dev *pdev; - struct device *dev; - - pdev = ep_dev->pdev; - dev = &pdev->dev; - - dev_dbg(dev, "ep: map bar=%d, addr=0x%lx, size=0x%lx\n", - bar, - (unsigned long)cpu_addr, - (unsigned long)size); - - if (ep_dev->iatu_unroll_enabled) - return sprd_ep_dev_unr_set_bar(ep_dev, bar, cpu_addr, size); - - spin_lock(&ep_dev->set_bar_lock); - - /* bar n use region n to map, map to bar match mode */ - sprd_pci_ep_iatu_writel(ep_dev, - PCIE_ATU_VIEWPORT, - PCIE_ATU_REGION_INBOUND | bar); - sprd_pci_ep_iatu_writel(ep_dev, PCIE_ATU_LOWER_TARGET, - lower_32_bits(cpu_addr)); - sprd_pci_ep_iatu_writel(ep_dev, PCIE_ATU_UPPER_TARGET, - upper_32_bits(cpu_addr)); - sprd_pci_ep_iatu_writel(ep_dev, - PCIE_ATU_CR1, - PCIE_ATU_TYPE_MEM); - sprd_pci_ep_iatu_writel(ep_dev, - PCIE_ATU_CR2, - PCIE_ATU_ENABLE | - PCIE_ATU_BAR_MODE_ENABLE | (bar << 8)); - - spin_unlock(&ep_dev->set_bar_lock); - - /* - * Make sure ATU enable takes effect - * before any subsequent config and I/O accesses. - */ - for (retries = 0; - retries < LINK_WAIT_MAX_IATU_RETRIES; - retries++) { - val = sprd_pci_ep_iatu_readl(ep_dev, PCIE_ATU_CR2); - if (val & PCIE_ATU_ENABLE) - return 0; - - /* wait a moment for polling ep atu enable bit */ - usleep_range(LINK_WAIT_IATU_MIN, LINK_WAIT_IATU_MAX); - } - - return -EINVAL; -} - -static int sprd_ep_dev_just_unmap_bar(struct sprd_pci_ep_dev *ep_dev, int bar) -{ - struct pci_dev *pdev; - struct device *dev; - - pdev = ep_dev->pdev; - dev = &pdev->dev; - - dev_dbg(dev, "ep: unmap bar = %d\n", bar); - - if (ep_dev->iatu_unroll_enabled) - return sprd_ep_dev_unr_clear_bar(ep_dev, bar); - - spin_lock(&ep_dev->set_bar_lock); - - sprd_pci_ep_iatu_writel(ep_dev, PCIE_ATU_VIEWPORT, - PCIE_ATU_REGION_INBOUND | bar); - sprd_pci_ep_iatu_writel(ep_dev, PCIE_ATU_CR2, - (u32)(~PCIE_ATU_ENABLE)); - - spin_unlock(&ep_dev->set_bar_lock); - - return 0; -} - -static void __iomem *sprd_ep_dev_map_bar(int ep, int bar, - dma_addr_t cpu_addr, size_t size) -{ - resource_size_t offset; - struct pci_dev *pdev; - struct device *dev; - struct sprd_pci_ep_dev *ep_dev; - void __iomem *bar_vir; - struct resource *res; - - if (ep >= PCIE_EP_NR || !g_ep_dev[ep]) - return NULL; - - ep_dev = g_ep_dev[ep]; - pdev = ep_dev->pdev; - dev = &pdev->dev; - - /* bar is be used */ - if (ep_dev->bar_vir[bar]) { - dev_err(dev, "ep: bar[%d] is used!", bar); - return NULL; - } - - /* 1st, adjust the map region */ - if (sprd_ep_dev_adjust_region(ep_dev, bar, &cpu_addr, &size, &offset)) - return NULL; - - /* than, ioremap, if map failed, no need to set bar */ - res = &pdev->resource[bar]; -#ifndef ioremap_nocache -#define ioremap_nocache ioremap -#endif - bar_vir = ioremap_nocache(res->start, size); - if (!bar_vir) { - dev_err(dev, "ep: map error, bar=%d, addr=0x%lx, size=0x%lx\n", - bar, - (unsigned long)cpu_addr, - (unsigned long)size); - return NULL; - } - - if (sprd_ep_dev_just_map_bar(ep_dev, bar, cpu_addr, size)) { - dev_err(dev, "ep: map bar =%d\n", bar); - iounmap(ep_dev->bar_vir[bar]); - return NULL; - } - - ep_dev->bar_vir[bar] = (void __iomem *)bar_vir; - ep_dev->cpu_vir[bar] = (void __iomem *)(bar_vir + offset); - ep_dev->src_addr[bar] = res->start + offset; - ep_dev->target_addr[bar] = cpu_addr; - ep_dev->map_size[bar] = size; - - return ep_dev->cpu_vir[bar]; -} - -static int sprd_ep_dev_unmap_bar(int ep, int bar) -{ - struct pci_dev *pdev; - struct device *dev; - struct sprd_pci_ep_dev *ep_dev; - - if (ep >= PCIE_EP_NR || !g_ep_dev[ep]) - return -ENODEV; - - ep_dev = g_ep_dev[ep]; - pdev = ep_dev->pdev; - dev = &pdev->dev; - - dev_info(dev, "ep: unmap bar = %d\n", bar); - - if (!ep_dev->bar_vir[bar]) - return -ENODEV; - - sprd_ep_dev_just_unmap_bar(ep_dev, bar); - - iounmap(ep_dev->bar_vir[bar]); - ep_dev->bar_vir[bar] = NULL; - ep_dev->cpu_vir[bar] = NULL; - ep_dev->src_addr[bar] = 0; - ep_dev->target_addr[bar] = 0; - ep_dev->map_size[bar] = 0; - - return 0; -} - -static void sprd_pci_ep_dev_clear_legacy_irq(struct sprd_pci_ep_dev *ep_dev) -{ - if (!ep_dev->legacy_addr) - return; - - writel_relaxed(PCIE_LEGACY_CLEAR_MASK, - ep_dev->legacy_addr + BIT_CLR_OFFSET + PCIE_LEGACY_CLEAR_REG); -} - -static irqreturn_t sprd_pci_ep_dev_irqhandler(int irq, void *dev_ptr) -{ - struct sprd_pci_ep_dev *ep_dev = dev_ptr; - struct pci_dev *pdev = ep_dev->pdev; - struct device *dev = &pdev->dev; - irq_handler_t handler; - u32 i, j, value; - int ipa_irq; - - if (ep_dev->no_msi) { - /* clear irq */ - sprd_pci_ep_dev_clear_legacy_irq(ep_dev); - - /* workaroud for IPA */ - handler = ep_dev_handler[ep_dev->ep][PCIE_MSI_IPA]; - if (handler) - handler(irq, ep_dev_handler_data[ep_dev->ep][PCIE_MSI_IPA]); - - - value = BL_READL(g_irq_addr[ep_dev->ep]); - dev_dbg(dev, "ep: irq handler. irq = 0x%x, base=%d\n", value, ep_dev->base_irq); - for (i = 0; i < 32; i++) { - if (value & BIT(i)) { - /* clear iqr bit*/ - value = BL_READL(g_irq_addr[ep_dev->ep]); - value &= ~(BIT(i)); - BL_WRITEL(value,g_irq_addr[ep_dev->ep]); - j = i - ep_dev->base_irq; - if (j >= PCIE_MSI_MAX_IRQ) - continue; - - handler = ep_dev_handler[ep_dev->ep][j]; - if (handler) - handler(irq, ep_dev_handler_data[ep_dev->ep][j]); - else - ep_dev->bak_irq_status |= BIT(j); - } - } - return IRQ_HANDLED; - } - - dev_dbg(dev, "ep: irq handler. irq = %d\n", irq); - /* for ipa hw irq. */ - ipa_irq = irq - (pdev->irq + ep_dev->ipa_base_irq); - if (ipa_irq >= 0 && ipa_irq < IPA_HW_IRQ_CNT) { - handler = ep_dev_handler[ep_dev->ep][PCIE_MSI_IPA]; - if (handler) - handler(ipa_irq, ep_dev_handler_data[ep_dev->ep][PCIE_MSI_IPA]); - else - ep_dev->bak_irq_status |= BIT(PCIE_MSI_IPA); - - return IRQ_HANDLED; - } - - - irq -= (pdev->irq + ep_dev->base_irq); - if (irq >= PCIE_MSI_MAX_IRQ || irq < 0) { - dev_err(dev, "ep: error, irq = %d", irq); - return IRQ_HANDLED; - } - - handler = ep_dev_handler[ep_dev->ep][irq]; - if (handler) - handler(irq, ep_dev_handler_data[ep_dev->ep][irq]); - else - ep_dev->bak_irq_status |= BIT(irq); - - return IRQ_HANDLED; -} - -static void sprd_pci_ep_save_reg(struct sprd_pci_ep_dev *ep_dev) -{ - int i, j; - u32 (*save_reg)[PCIE_SAVE_REG_NUM]; - static struct sprd_pci_ep_dev_save *ep_save; - - ep_save = &g_ep_save[ep_dev->ep]; - save_reg = ep_save->save_reg; - - for (i = 0; i < PCIE_SAVE_REGION_NUM; i += 2) { - for (j = 0; j < PCIE_SAVE_REG_NUM; j++) { - save_reg[i][j] = - sprd_pci_ep_iatu_readl(ep_dev, - PCIE_ATU_OB_REGION(i) + - j * sizeof(u32)); - save_reg[i + 1][j] = - sprd_pci_ep_iatu_readl(ep_dev, - PCIE_ATU_IB_REGION(i) + - j * sizeof(u32)); - } - } - - ep_save->doorbell_enable = sprd_pci_ep_iatu_readl(ep_dev, - DOOR_BELL_BASE + - DOOR_BELL_ENABLE); - ep_save->doorbell_status = sprd_pci_ep_iatu_readl(ep_dev, - DOOR_BELL_BASE + - DOOR_BELL_STATUS); - ep_save->cfg_base = ep_dev->cfg_base; - - ep_save->save_succ = true; -} - -static void sprd_pci_ep_dev_backup(struct sprd_pci_ep_dev *ep_dev) -{ - struct pci_dev *pdev = ep_dev->pdev; - struct device *dev = &pdev->dev; - struct sprd_pci_ep_dev_save *ep_save; - int i; - - ep_save = &g_ep_save[ep_dev->ep]; - - /* save some member */ - ep_save->bar_res = ep_dev->bar_res; - for (i = 0; i < BAR_MAX; i++) { - if (!ep_dev->src_addr[i]) - continue; - - dev_info(dev, "ep: backup bar=%d, addr=0x%lx, size=0x%lx\n", - i, - (unsigned long)ep_save->target_addr[i], - (unsigned long)ep_save->map_size[i]); - - ep_save->bar_vir[i] = ep_dev->bar_vir[i]; - ep_save->cpu_vir[i] = ep_dev->cpu_vir[i]; - ep_save->src_addr[i] = ep_dev->src_addr[i]; - ep_save->target_addr[i] = ep_dev->target_addr[i]; - ep_save->map_size[i] = ep_dev->map_size[i]; - } - - /* save ep reg */ - sprd_pci_ep_save_reg(ep_dev); -} - -static void sprd_pci_ep_dev_restore(struct sprd_pci_ep_dev *ep_dev) -{ - struct pci_dev *pdev = ep_dev->pdev; - struct device *dev = &pdev->dev; - struct sprd_pci_ep_dev_save *ep_save; - int i; - - ep_save = &g_ep_save[ep_dev->ep]; - - /* save some member */ - ep_dev->bar_res = ep_save->bar_res; - for (i = 0; i < BAR_MAX; i++) { - if (!ep_save->src_addr[i]) - continue; - - ep_dev->bar_vir[i] = ep_save->bar_vir[i]; - ep_dev->cpu_vir[i] = ep_save->cpu_vir[i]; - ep_dev->src_addr[i] = ep_save->src_addr[i]; - ep_dev->target_addr[i] = ep_save->target_addr[i]; - ep_dev->map_size[i] = ep_save->map_size[i]; - - dev_info(dev, "ep: restore bar=%d, addr=0x%lx, size=0x%lx\n", - i, - (unsigned long)ep_dev->target_addr[i], - (unsigned long)ep_dev->map_size[i]); - - if (sprd_ep_dev_just_map_bar(ep_dev, - i, - ep_dev->target_addr[i], - ep_dev->map_size[i])) - dev_err(dev, "ep: restore map err i = %d.\n", i); - } -} - -static void sprd_pci_ep_notify_fn(struct work_struct *work) -{ - struct sprd_ep_dev_notify *notify; - struct sprd_pci_ep_dev *ep_dev = container_of(work, - struct sprd_pci_ep_dev, - notify_work); - - notify = &g_ep_dev_notify[ep_dev->ep]; - if (notify->notify) - notify->notify(ep_dev->event, notify->data); -} - -static int sprd_pci_ep_dev_probe(struct pci_dev *pdev, - const struct pci_device_id *ent) -{ - int i, err, irq_cnt = 0; - u32 val; - enum dev_pci_barno bar; - struct device *dev = &pdev->dev; - struct sprd_pci_ep_dev *ep_dev; - struct resource *res; - - dev_info(dev, "ep: probe\n"); - - sprd_pcie_iommu_init(dev); - - ep_dev = devm_kzalloc(dev, sizeof(*ep_dev), GFP_KERNEL); - if (!ep_dev) - return -ENOMEM; - - ep_dev->pdev = pdev; - - if (ent->device == PCI_DEVICE_ID_SPRD_ORCA) - ep_dev->ep = PCIE_EP_MODEM; - else { - dev_err(dev, "ep: Cannot support ep device = 0x%x\n", - ent->device); - return -EINVAL; - } - - err = pci_enable_device(pdev); - if (err) { - dev_err(dev, "ep: Cannot enable PCI device\n"); - return err; - } - - err = pci_request_regions(pdev, DRV_MODULE_NAME); - if (err) { - dev_err(dev, "ep: Cannot obtain PCI resources\n"); - goto err_disable_pdev; - } - - pci_set_master(pdev); - -#ifdef PCI_IRQ_MSI - irq_cnt = pci_alloc_irq_vectors(pdev, - 1, - MAX_SUPPORT_IRQ, - PCI_IRQ_MSI); -#else - irq_cnt = pci_enable_msi_range(pdev, 1, MAX_SUPPORT_IRQ); -#endif - - if (sprd_pcie_is_defective_chip()) { - ep_dev->base_irq = REQUEST_BASE_IRQ_DEFECT; - ep_dev->ipa_base_irq = IPA_HW_IRQ_BASE_DEFECT; - } else { - ep_dev->base_irq = REQUEST_BASE_IRQ; - ep_dev->ipa_base_irq = IPA_HW_IRQ_BASE; - } - - for (bar = BAR_0; bar <= BAR_5; bar++) { - res = &pdev->resource[bar]; - dev_info(dev, "ep: BAR[%d] %pR\n", bar, res); - /* only save mem bar */ - if (resource_type(res) == IORESOURCE_MEM) - ep_dev->bar[bar] = res; - } - - ep_dev->cfg_base = pci_ioremap_bar(pdev, EP_CFG_BAR); - if (!ep_dev->cfg_base) { - dev_err(dev, "ep: failed to map cfg bar.\n"); - err = -ENOMEM; - goto err_disable_msi; - } - - /* clear all 32 bit door bell */ - writel_relaxed(0x0, - ep_dev->cfg_base + DOOR_BELL_BASE + DOOR_BELL_STATUS); - - pci_set_drvdata(pdev, ep_dev); - pci_read_config_dword(ep_dev->pdev, PCIE_ATU_VIEWPORT, &val); - /* - * this atu view port reg is 0xffffffff means that the ep device - * doesn't support atu view port, we need unroll iatu registers - */ - dev_info(dev, "ep: atu_view_port val = 0x%x", val); - ep_dev->iatu_unroll_enabled = val == 0xffffffff; - - /* default , PCIE_EP_PROBE */ - ep_dev->event = PCIE_EP_PROBE; - g_ep_dev[ep_dev->ep] = ep_dev; - - if (!ep_dev->bar[BAR_1] || !ep_dev->bar[BAR_3]) { - /* only 2 bar, set PCIE_EP_PROBE_BEFORE_SPLIT_BAR */ - ep_dev->event = PCIE_EP_PROBE_BEFORE_SPLIT_BAR; - dev_info(dev, "ep:bar not ready, wait the next probe!"); - } - - /* restore all the config */ - if (ep_dev->event == PCIE_EP_PROBE) - sprd_pci_ep_dev_restore(ep_dev); - - /* start notify work */ - INIT_WORK(&ep_dev->notify_work, sprd_pci_ep_notify_fn); - schedule_work(&ep_dev->notify_work); - - if (irq_cnt < MAX_SUPPORT_IRQ) { - err = irq_cnt < 0 ? irq_cnt : -EINVAL; - ep_dev->no_msi = true; - dev_info(dev, "ep: failed to get MSI, err=%d, irq=%d\n", err, pdev->irq); - - ep_dev->legacy_addr = sprd_ep_map_memory(ep_dev->ep, PCIE_LEGACY_CLEAR_BASE, 0x4000); - /* request legacy irq */ - err = devm_request_irq(dev, pdev->irq, sprd_pci_ep_dev_irqhandler, - IRQF_SHARED, DRV_MODULE_NAME, ep_dev); - if (err) - dev_warn(dev, - "ep: failed to request legacy %d\n", - pdev->irq); - - } else { - ep_dev->irq_cnt = irq_cnt; - dev_info(dev, "ep: request IRQ = %d, cnt =%d\n", - pdev->irq, - ep_dev->irq_cnt); - - /* request msi irq */ - for (i = ep_dev->base_irq; - i < ep_dev->base_irq + PCIE_MSI_MAX_IRQ; - i++) { - err = devm_request_irq(dev, pdev->irq + i, - sprd_pci_ep_dev_irqhandler, - IRQF_SHARED, DRV_MODULE_NAME, ep_dev); - if (err) - dev_warn(dev, - "ep: failed to request IRQ %d for MSI %d\n", - pdev->irq + i, i + 1); - } - - #ifdef CONFIG_SPRD_IPA_PCIE_WORKROUND - for (i = ep_dev->ipa_base_irq; - i < ep_dev->ipa_base_irq + IPA_HW_IRQ_CNT; - i++) { - err = devm_request_irq(dev, pdev->irq + i, - sprd_pci_ep_dev_irqhandler, - IRQF_SHARED, DRV_MODULE_NAME, - ep_dev); - if (!err) - sprd_pcie_teardown_msi_irq(pdev->irq + i); - } - #endif - } - -#ifndef SPRD_PCIE_USE_DTS - sipa_module_init(dev); - sipa_eth_init(); - sipa_dummy_init(); -#endif - - return 0; - -err_disable_msi: - pci_disable_msi(pdev); - pci_release_regions(pdev); - -err_disable_pdev: - pci_disable_device(pdev); - - return err; -} - -static void sprd_pci_ep_dev_remove(struct pci_dev *pdev) -{ - u32 i; - struct sprd_ep_dev_notify *notify; - struct sprd_pci_ep_dev *ep_dev = pci_get_drvdata(pdev); - struct sipa_core *ctrl = sipa_get_ctrl_pointer(); - dev_info(&pdev->dev, "ep: remove\n"); - ctrl->remote_ready = false; - spipe_device_down(); - spool_device_down(); - - cancel_work_sync(&ep_dev->notify_work); - - /* first notify PCIE_EP_REMOVE */ - notify = &g_ep_dev_notify[ep_dev->ep]; - if (notify->notify) - notify->notify(PCIE_EP_REMOVE, notify->data); - - /* back up some config before remove */ - if (ep_dev->need_backup) - sprd_pci_ep_dev_backup(ep_dev); - - if (ep_dev->no_msi) { - devm_free_irq(&pdev->dev, pdev->irq, ep_dev); - } else { - for (i = ep_dev->base_irq; i < ep_dev->base_irq + PCIE_MSI_MAX_IRQ; i++) - devm_free_irq(&pdev->dev, pdev->irq + i, ep_dev); - - #ifdef CONFIG_SPRD_IPA_PCIE_WORKROUND - for (i = ep_dev->ipa_base_irq; - i < ep_dev->ipa_base_irq + IPA_HW_IRQ_CNT; - i++) - devm_free_irq(&pdev->dev, pdev->irq + i, ep_dev); - #endif - } - - pci_disable_msi(pdev); - -#ifndef SPRD_PCIE_USE_DTS - sipa_dummy_exit(); - sipa_eth_exit(); - sipa_module_exit(); -#endif - - if (ep_dev->legacy_addr) { - sprd_ep_unmap_memory(ep_dev->ep, ep_dev->legacy_addr); - ep_dev->legacy_addr = NULL; - dev_info(&ep_dev->pdev->dev, "set ep_dev->legacy_addr = %lx\n", (long)ep_dev->legacy_addr); - } - - if (ep_dev->cfg_base) { - iounmap(ep_dev->cfg_base); - ep_dev->cfg_base = NULL; - } - - pci_release_regions(pdev); - pci_disable_device(pdev); - - g_ep_dev[ep_dev->ep] = NULL; - ep_dev->bar_res = 0; -} - -static const struct pci_device_id sprd_pci_ep_dev_tbl[] = { - { PCI_DEVICE(PCI_VENDOR_ID_SPRD, PCI_DEVICE_ID_SPRD_ORCA) }, - { } -}; -MODULE_DEVICE_TABLE(pci, sprd_pci_ep_dev_tbl); - -#ifdef CONFIG_PM_SLEEP -static int sprd_pci_ep_suspend(struct device *dev) -{ - struct pci_dev *pdev = to_pci_dev(dev); - int rc; - - dev_info(dev, "suspend\n"); - - /* Exec pci PCI_D3cold one time */ - if (pdev->current_state != PCI_D0) { - dev_info(dev, "done for pm %d\n", pdev->current_state); - return 0; - } - - /* - * TODO: The HAL will ask the shared memory layer whether D3 is allowed. - */ - - /* Save the PCI configuration space of a device before suspending. */ - rc = pci_save_state(pdev); - if (rc) { - dev_err(dev, "pci_save_state error=%d\n", rc); - return rc; - } - - /* Set the power state of a PCI device. - * Transition a device to a new power state, using the device's PCI PM - * registers. - */ - rc = pci_set_power_state(pdev, PCI_D3cold); - if (rc) { - dev_err(dev, "pci_set_power_state error=%d\n", rc); - return rc; - } - return 0; -} - -static int sprd_pci_ep_resume(struct device *dev) -{ - struct pci_dev *pdev = to_pci_dev(dev); - int rc; - - dev_info(dev, "resume\n"); - - /* Set the power state of a PCI device. */ - rc = pci_set_power_state(pdev, PCI_D0); - if (rc) { - dev_err(dev, "pci_set_power_state error=%d\n", rc); - return rc; - } - - /* Restore the saved state of a PCI device. */ - pci_restore_state(pdev); - - /* TODO: The HAL shall inform that the device is active. */ - return 0; -} -#endif /* CONFIG_PM_SLEEP */ - -static const struct dev_pm_ops sprd_pci_ep_pm = { - SET_SYSTEM_SLEEP_PM_OPS(sprd_pci_ep_suspend, - sprd_pci_ep_resume) -}; - -static struct pci_driver sprd_pci_ep_dev_driver = { - .name = DRV_MODULE_NAME, - .id_table = sprd_pci_ep_dev_tbl, - .probe = sprd_pci_ep_dev_probe, - .remove = sprd_pci_ep_dev_remove, - .driver = { - .pm = &sprd_pci_ep_pm, - } -}; -//module_pci_driver(sprd_pci_ep_dev_driver); - -#if defined(CONFIG_DEBUG_FS) -static void sprd_pci_ep_dev_save_show(struct seq_file *m, - struct sprd_pci_ep_dev_save *ep_save, - int ep) -{ - u32 i; - - seq_printf(m, "ep-save-%d configs:\n", ep); - seq_printf(m, "bar_res = 0x%lx\n", ep_save->bar_res); - - for (i = 0; i < BAR_MAX; i++) { - seq_printf(m, "src_addr[%d] = 0x%lx\n", - i, - (unsigned long)ep_save->src_addr[i]); - seq_printf(m, "target_addr[%d] = 0x%lx\n", - i, - (unsigned long)ep_save->target_addr[i]); - seq_printf(m, "map_size[%d] = 0x%lx\n", - i, - (unsigned long)ep_save->map_size[i]); - } -} - -static void sprd_pci_ep_dev_config_show(struct seq_file *m, - struct sprd_pci_ep_dev *ep_dev) -{ - u32 i; - void __iomem *base; - - seq_printf(m, "ep-%d configs:\n", ep_dev->ep); - - /* doorbell regs */ - seq_puts(m, "door bell regs:\n"); - base = ep_dev->cfg_base + DOOR_BELL_BASE; - - seq_printf(m, "irq_enable = 0x%08x\n irq_status = 0x%08x\n", - readl_relaxed(base + DOOR_BELL_ENABLE), - readl_relaxed(base + DOOR_BELL_STATUS)); - - /* iatu reg regs */ - seq_puts(m, "iatu regs reg:\n"); - for (i = 0; i < IATU_MAX_REGION * 2; i++) { - base = ep_dev->cfg_base + IATU_REG_BASE + i * 100; - seq_printf(m, "IATU[%d]:\n", i); - seq_printf(m, "0x%p: 0x%08x 0x%08x 0x%08x 0x%08x\n", - base, - readl_relaxed(base + 0x0), - readl_relaxed(base + 0x4), - readl_relaxed(base + 0x8), - readl_relaxed(base + 0xc)); - base += 0x10; - seq_printf(m, "0x%p: 0x%08x 0x%08x 0x%08x 0x%08x\n", - base, - readl_relaxed(base + 0x0), - readl_relaxed(base + 0x4), - readl_relaxed(base + 0x8), - readl_relaxed(base + 0x10)); - } -} - -static void sprd_pci_ep_dev_backup_show(struct seq_file *m, - struct sprd_pci_ep_dev_save *ep_save, - int ep) -{ - int i; - u32 (*save_reg)[PCIE_SAVE_REG_NUM]; - void __iomem *base; - - save_reg = ep_save->save_reg; - - seq_printf(m, "ep-%d backup configs:\n", ep); - - /* doorbell regs */ - seq_puts(m, "door bell regs:\n"); - seq_printf(m, "irq_enable = 0x%08x\n irq_status = 0x%08x\n", - ep_save->doorbell_enable, - ep_save->doorbell_status); - - /* iatu reg regs */ - seq_puts(m, "iatu regs reg:\n"); - for (i = 0; i < PCIE_SAVE_REGION_NUM; i++) { - seq_printf(m, "IATU[%d]:\n", i); - base = ep_save->cfg_base + IATU_REG_BASE + i * 100; - - seq_printf(m, "0x%p: 0x%08x 0x%08x 0x%08x 0x%08x\n", - base, - save_reg[i][0], - save_reg[i][1], - save_reg[i][2], - save_reg[i][3]); - base += 0x10; - seq_printf(m, "0x%p: 0x%08x 0x%08x 0x%08x 0x%08x\n", - base, - save_reg[i][4], - save_reg[i][5], - save_reg[i][6], - save_reg[i][7]); - } -} - -static int sprd_pci_ep_dev_show(struct seq_file *m, void *unused) -{ - u32 i; - struct sprd_pci_ep_dev *ep_dev; - struct sprd_pci_ep_dev_save *ep_save; - - for (i = 0; i < PCIE_EP_NR; i++) { - /* ep_save configus */ - ep_save = &g_ep_save[i]; - ep_dev = g_ep_dev[i]; - - if (!ep_dev && !ep_save->save_succ) - continue; - - if (ep_save) - sprd_pci_ep_dev_save_show(m, ep_save, i); - - if (ep_dev) - sprd_pci_ep_dev_config_show(m, ep_dev); - else - sprd_pci_ep_dev_backup_show(m, ep_save, i); - } - - return 0; -} - -static int sprd_pci_ep_dev_open(struct inode *inode, struct file *file) -{ - return single_open(file, sprd_pci_ep_dev_show, NULL); -} - -static const struct file_operations sprd_pci_ep_dev_fops = { - .owner = THIS_MODULE, - .open = sprd_pci_ep_dev_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static struct dentry *g_ep_debugfs_root; - -static int sprd_pci_ep_dev_init_debugfs(void) -{ - struct dentry *g_ep_debugfs_root = debugfs_create_dir("ep_dev", NULL); - - if (!g_ep_debugfs_root) - return -ENXIO; - - debugfs_create_file("ep", 0444, - g_ep_debugfs_root, - NULL, &sprd_pci_ep_dev_fops); - return 0; -} - -static void sprd_pci_ep_dev_remove_debugfs(void) -{ - debugfs_remove_recursive(g_ep_debugfs_root); -} -#endif - -static int __init sprd_pci_ep_dev_init(void) -{ - pr_info("%s %s\n", __func__, QUECTEL_SPRD_PCIE_VERSION); -#if defined(CONFIG_DEBUG_FS) - sprd_pci_ep_dev_init_debugfs(); - sipc_init_debugfs(); -#endif - sipc_init(); - spipe_init(); - spool_init(); - modem_power_manager_init(); - return pci_register_driver(&sprd_pci_ep_dev_driver); -} - -static void __exit sprd_pci_ep_dev_exit(void) -{ - spipe_exit(); - spool_exit(); - modem_power_manager_exit(); - pci_unregister_driver(&sprd_pci_ep_dev_driver); -#if defined(CONFIG_DEBUG_FS) - sprd_pci_ep_dev_remove_debugfs(); -#endif - sipc_exit(); -} - -module_init(sprd_pci_ep_dev_init); -module_exit(sprd_pci_ep_dev_exit); - - -MODULE_DESCRIPTION("SPRD PCI EP DEVICE HOST DRIVER"); -MODULE_AUTHOR("Wenping Zhou "); -MODULE_LICENSE("GPL v2"); -MODULE_VERSION(QUECTEL_SPRD_PCIE_VERSION); diff --git a/quectel_SRPD_PCIE/src/pcie/sprd_pcie_quirks.c b/quectel_SRPD_PCIE/src/pcie/sprd_pcie_quirks.c deleted file mode 100644 index d8e9853..0000000 --- a/quectel_SRPD_PCIE/src/pcie/sprd_pcie_quirks.c +++ /dev/null @@ -1,126 +0,0 @@ -/* - * This file contains work-arounds for many known PCI hardware - * bugs. Devices present only on certain architectures (host - * bridges et cetera) should be handled in arch-specific code. - * - * Note: any quirks for hotpluggable devices must _NOT_ be declared __init. - * - * Copyright (c) 1999 Martin Mares - * - * Init/reset quirks for USB host controllers should be in the - * USB quirks file, where their drivers can access reuse it. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#if (LINUX_VERSION_CODE < KERNEL_VERSION( 5,4,0 )) -#include -#endif -#include -#include -#include -#include -#include /* isa_dma_bridge_buggy */ - -#ifndef PCI_VENDOR_ID_SYNOPSYS -#define PCI_VENDOR_ID_SYNOPSYS 0x16c3 -#endif - - - /* - * It's possible that ep bar size is larger than rc allocated - * memory, so need to resize ep bar to small size. - * Original ep bar size:bar0:256MB, bar1:64kb, bar2:256MB, - * bar3: 64kb, bar4:256MB, bar5:64kb. - * resize to bar0:8MB, bar1:64kb, bar2:2MB, bar3: 64kb, - * bar4:2MB, bar5:64kb. - */ -#define SPRD_PCI_BAR0 0x10 -#define SPRD_BAR_NUM 0x6 -#define SPRD_PCI_MISC_CTRL1_OFF 0x8bc -#define SPRD_PCI_DBI_RO_WR_EN (0x1 << 0) -#define SPRD_PCI_RESIZABLE_BAR_EXTENDED_CAP_HEADER 0x260 -#define SPRD_PCI_RESIZABLE_BAR_EXTENDED_CAPID 0x15 -/* Resizable BAR Capability Register */ -#define SPRD_PCI_RESIZABLE_BAR0 0x264 -#define SPRD_PCI_RESIZABLE_BAR2 0x26c -#define SPRD_PCI_RESIZABLE_BAR4 0x274 -#define SPRD_BAR_SUPPORT_2MB (0x1 << 5) -#define SPRD_BAR_SUPPORT_4MB (0x1 << 6) -#define SPRD_BAR_SUPPORT_8MB (0x1 << 7) -/* Resizable BAR Control Register */ -#define SPRD_PCI_RESIZABLE_BAR0_CTL 0x268 -#define SPRD_PCI_RESIZABLE_BAR2_CTL 0x270 -#define SPRD_PCI_RESIZABLE_BAR4_CTL 0x278 -/* bit[13:8] is bar size */ -#define SPRD_PCI_RESIZABLE_BAR_SIZE_MASK 0x3F00 -#define SPRD_PCI_RESIZABLE_2MB (0x1 << 8) -#define SPRD_PCI_RESIZABLE_4MB (0x2 << 8) -#define SPRD_PCI_RESIZABLE_8MB (0x3 << 8) -#define SIZE(val) ((~(val & 0xFFFFFFF0)) + 1) - -static void quirk_sprd_pci_resizebar(struct pci_dev *dev) -{ - u32 val, i, backup; - - pci_read_config_dword(dev, - SPRD_PCI_RESIZABLE_BAR_EXTENDED_CAP_HEADER, &val); - if ((val & SPRD_PCI_RESIZABLE_BAR_EXTENDED_CAPID) != - SPRD_PCI_RESIZABLE_BAR_EXTENDED_CAPID) { - dev_info(&dev->dev, "%s: not support resize bar\n", __func__); - return; - } - - pci_read_config_dword(dev, SPRD_PCI_MISC_CTRL1_OFF, &val); - val |= SPRD_PCI_DBI_RO_WR_EN; - pci_write_config_dword(dev, SPRD_PCI_MISC_CTRL1_OFF, val); - - pci_read_config_dword(dev, SPRD_PCI_RESIZABLE_BAR0, &val); - pci_write_config_dword(dev, SPRD_PCI_RESIZABLE_BAR0, - val | SPRD_BAR_SUPPORT_4MB | - SPRD_BAR_SUPPORT_8MB); - pci_read_config_dword(dev, SPRD_PCI_RESIZABLE_BAR2, &val); - pci_write_config_dword(dev, SPRD_PCI_RESIZABLE_BAR2, - val | SPRD_BAR_SUPPORT_4MB | - SPRD_BAR_SUPPORT_8MB); - pci_read_config_dword(dev, SPRD_PCI_RESIZABLE_BAR4, &val); - pci_write_config_dword(dev, SPRD_PCI_RESIZABLE_BAR4, - val | SPRD_BAR_SUPPORT_4MB | - SPRD_BAR_SUPPORT_8MB); - - pci_read_config_dword(dev, SPRD_PCI_MISC_CTRL1_OFF, &val); - val &= ~SPRD_PCI_DBI_RO_WR_EN; - pci_write_config_dword(dev, SPRD_PCI_MISC_CTRL1_OFF, val); - - pci_read_config_dword(dev, SPRD_PCI_RESIZABLE_BAR0_CTL, &val); - pci_write_config_dword(dev, SPRD_PCI_RESIZABLE_BAR0_CTL, - (val & (~SPRD_PCI_RESIZABLE_BAR_SIZE_MASK)) | - SPRD_PCI_RESIZABLE_4MB); - pci_read_config_dword(dev, SPRD_PCI_RESIZABLE_BAR2_CTL, &val); - pci_write_config_dword(dev, SPRD_PCI_RESIZABLE_BAR2_CTL, - (val & (~SPRD_PCI_RESIZABLE_BAR_SIZE_MASK)) | - SPRD_PCI_RESIZABLE_4MB); - pci_read_config_dword(dev, SPRD_PCI_RESIZABLE_BAR4_CTL, &val); - pci_write_config_dword(dev, SPRD_PCI_RESIZABLE_BAR4_CTL, - (val & (~SPRD_PCI_RESIZABLE_BAR_SIZE_MASK)) | - SPRD_PCI_RESIZABLE_4MB); - - for (i = 0; i < SPRD_BAR_NUM; i++) { - pci_read_config_dword(dev, SPRD_PCI_BAR0 + i * 4, &backup); - pci_write_config_dword(dev, SPRD_PCI_BAR0 + i * 4, 0xFFFFFFFF); - pci_read_config_dword(dev, SPRD_PCI_BAR0 + i * 4, &val); - pci_write_config_dword(dev, SPRD_PCI_BAR0 + i * 4, backup); - - dev_info(&dev->dev, "%s: bar%d size 0x%x\n", - __func__, i, SIZE(val)); - } -} -DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SYNOPSYS, 0xabcd, quirk_sprd_pci_resizebar); \ No newline at end of file diff --git a/quectel_SRPD_PCIE/src/power_manager/Makefile b/quectel_SRPD_PCIE/src/power_manager/Makefile deleted file mode 100644 index 6d5c499..0000000 --- a/quectel_SRPD_PCIE/src/power_manager/Makefile +++ /dev/null @@ -1 +0,0 @@ -obj-y += power_manager.o diff --git a/quectel_SRPD_PCIE/src/power_manager/power_manager.c b/quectel_SRPD_PCIE/src/power_manager/power_manager.c deleted file mode 100644 index 077c31e..0000000 --- a/quectel_SRPD_PCIE/src/power_manager/power_manager.c +++ /dev/null @@ -1,964 +0,0 @@ -/* - * Copyright (C) 2019 Spreadtrum Communications Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../include/sprd_mpm.h" -#include "../include/sipc.h" -/* - * The data struct of modem power manager. - */ -struct sprd_mpm_data { -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 4,18,0 )) - struct wakeup_source *ws; -#else - struct wakeup_source ws; -#endif - struct list_head pms_list; - struct timer_list timer; - spinlock_t mpm_lock; - char name[20]; - const char *last_name; - unsigned int dst; - unsigned int up_cnt; - unsigned int awake_cnt; - unsigned int wakelock_cnt; - unsigned int mpm_state; - unsigned long expires; - unsigned int later_idle; - - /* resource ops functions */ - int (*wait_resource)(unsigned int dst, int timeout); - int (*request_resource)(unsigned int dst); - int (*release_resource)(unsigned int dst); - - struct work_struct release_res_work; - struct work_struct request_res_work; -}; - -/* - * Save all the instance of mpm in here. - */ -static struct sprd_mpm_data *g_sprd_mpm[SIPC_ID_NR]; - -/** - * sprd_mpm_print_awake - * print the wake up list to known who prevent system sleep. - */ -static void sprd_mpm_print_awake(struct sprd_mpm_data *mpm) -{ - struct sprd_pms *pms; - char *awake_info; - int len = 0, max_len = 512; - - awake_info = kmalloc(max_len, GFP_KERNEL); - if (!awake_info) - return; - - /* print pms list */ - list_for_each_entry(pms, &mpm->pms_list, entry) { - if (!pms->awake && pms->pre_awake_cnt == pms->awake_cnt) - continue; - - pms->pre_awake_cnt = pms->awake_cnt; - snprintf(awake_info + len, - max_len - len, - "%s is awake, awake_cnt = %d\n", - pms->name, - pms->awake_cnt); - len = strlen(awake_info); - } - - if (len) - pr_info("mpm: %s\n", awake_info); - - kfree(awake_info); -} - -/** - * sprd_mpm_pm_event - * monitor the PM_SUSPEND_PREPARE event. - */ -static int sprd_mpm_pm_event(struct notifier_block *notifier, - unsigned long pm_event, void *unused) -{ - unsigned int i; - struct sprd_mpm_data *cur; - - switch (pm_event) { - case PM_SUSPEND_PREPARE: - case PM_POST_SUSPEND: - /* check if has wake lock. */ - for (i = 0; i < SIPC_ID_NR; i++) { - if (!g_sprd_mpm[i]) - continue; - - cur = g_sprd_mpm[i]; - sprd_mpm_print_awake(cur); - } - break; - - default: - break; - } - - return NOTIFY_DONE; -} - -/* - * The pm event notify data, for the register pm notifier. - */ -static struct notifier_block sprd_mpm_notifier_block = { - .notifier_call = sprd_mpm_pm_event, -}; - -/** - * sprd_mpm_request_resource - * request resource. - */ -static void sprd_mpm_request_resource(struct sprd_mpm_data *mpm) -{ - if (mpm->request_resource) - schedule_work(&mpm->request_res_work); -} - -/** - * sprd_mpm_release_resource - * release resource. - */ -static void sprd_mpm_release_resource(struct sprd_mpm_data *mpm) -{ - if (mpm->release_resource) - schedule_work(&mpm->release_res_work); -} - -/** - * sprd_mpm_wait_resource -wait resource. - */ -static int sprd_mpm_wait_resource(struct sprd_mpm_data *mpm, int timeout) -{ - int ret = 0; - - if (mpm->wait_resource) { - ret = mpm->wait_resource(mpm->dst, timeout); - if (ret < 0 && ret != -ERESTARTSYS && timeout) - pr_err("mpm: %s wait resource, ret=%d, timeout=%d.\n", - mpm->name, ret, timeout); - } - - return ret; -} - -/** - * sprd_mpm_active - * set the state to busy. - */ -static void sprd_mpm_active(struct sprd_mpm_data *mpm) -{ - pr_debug("mpm: %s active, set state to busy.\n", mpm->name); - - mpm->mpm_state = SPRD_MPM_BUSY; - sprd_mpm_request_resource(mpm); -} - -/** - * sprd_mpm_deactive - * del the idle timer, - * set the state to idle. - */ -static void sprd_mpm_deactive(struct sprd_mpm_data *mpm) -{ - pr_debug("mpm: %s deactive, set state to idle.\n", mpm->name); - - mpm->mpm_state = SPRD_MPM_IDLE; - mpm->expires = 0; - sprd_mpm_release_resource(mpm); -} - -/** - * sprd_mpm_start_deactive - * start the deactive timer. - */ -static void sprd_mpm_start_deactive(struct sprd_mpm_data *mpm) -{ - pr_debug("mpm: %s start deactive.\n", mpm->name); - - mpm->expires = jiffies + msecs_to_jiffies(mpm->later_idle); - if (!mpm->expires) - mpm->expires = 1; - - mod_timer(&mpm->timer, mpm->expires); -} - -/** - * sprd_mpm_request_res_work_fn - * do release resource call in here. - */ -static void sprd_mpm_request_res_work_fn(struct work_struct *work) -{ - struct sprd_mpm_data *mpm = container_of(work, struct sprd_mpm_data, - request_res_work); - int ret; - - pr_debug("mpm: %s request res work.\n", mpm->name); - - ret = mpm->request_resource(mpm->dst); - if (ret) - pr_err("mpm: %s request res, ret = %d.\n", mpm->name, ret); -} - -/** - * sprd_mpm_release_res_work_fn - * do relase resource call in here - */ -static void sprd_mpm_release_res_work_fn(struct work_struct *work) -{ - struct sprd_mpm_data *mpm = container_of(work, struct sprd_mpm_data, - release_res_work); - int ret; - - pr_debug("mpm: %s releae res work.\n", mpm->name); - - ret = mpm->release_resource(mpm->dst); - if (ret) - pr_err("mpm: %s request res, ret = %d.\n", mpm->name, ret); -} - -/** - * sprd_mpm_deactive_timer_fn - * in a period of time (mpm->later_idle), - * have no modem resource request, - * we consider that it doesn't need modem resource, - * than set the state to idle. - */ -static void sprd_mpm_deactive_timer_fn( -#if (LINUX_VERSION_CODE <= KERNEL_VERSION( 4,10,0 )) - unsigned long data) -{ - struct sprd_mpm_data *mpm = (struct sprd_mpm_data *)data; -#else - struct timer_list *t) -{ - struct sprd_mpm_data *mpm = from_timer(mpm, t, timer); -#endif - - unsigned long flags; - - pr_debug("mpm: %s deactive timer.\n", mpm->name); - - spin_lock_irqsave(&mpm->mpm_lock, flags); - /* expires is 0, means the timer has been cancelled. */ - if (mpm->expires) - sprd_mpm_deactive(mpm); - spin_unlock_irqrestore(&mpm->mpm_lock, flags); -} - -/** - * sprd_pms_cancel_timer - * cancel the pms wakelock timer. - */ -static void sprd_pms_cancel_timer(struct sprd_pms *pms) -{ - unsigned long flags; - bool print = false; - - spin_lock_irqsave(&pms->expires_lock, flags); - if (pms->expires) { - print = true; - pms->expires = 0; - del_timer(&pms->wake_timer); - } - spin_unlock_irqrestore(&pms->expires_lock, flags); - - if (print) - pr_debug("pms: %s del timer.\n", pms->name); - -} - -/** - * sprd_mpm_cancel_timer - * cancel the deactive timer. - */ -static void sprd_mpm_cancel_timer(struct sprd_mpm_data *mpm) -{ - if (mpm->expires) { - pr_debug("mpm: %s del timer.\n", mpm->name); - - mpm->expires = 0; - del_timer(&mpm->timer); - } -} - -/** - * sprd_mpm_up - * modem power manger power up. - */ -static void sprd_mpm_up(struct sprd_mpm_data *mpm, const char *name) -{ - unsigned long flags; - - spin_lock_irqsave(&mpm->mpm_lock, flags); - - /* first cancel deactive timer */ - sprd_mpm_cancel_timer(mpm); - mpm->last_name = name; - - mpm->up_cnt++; - /* when up_cnt is change form 0 to 1, ready active pms. - * Although the cnt is 0, but later down, the state may is still busy, - * so here must see whether the mpm state is idle. - */ - if (mpm->up_cnt == 1 && - mpm->mpm_state == SPRD_MPM_IDLE) - sprd_mpm_active(mpm); - - spin_unlock_irqrestore(&mpm->mpm_lock, flags); - - pr_debug("mpm: %s up, up_cnt=%d.\n", mpm->name, mpm->up_cnt); -} - -/** - * sprd_mpm_down - * modem power manger power down. - */ -static void sprd_mpm_down(struct sprd_mpm_data *mpm, bool immediately) -{ - unsigned long flags; - - /* - * when up_cnt count is change form 1 to 0, - * start deactive pms. - */ - spin_lock_irqsave(&mpm->mpm_lock, flags); - mpm->up_cnt--; - if (!mpm->up_cnt) { - if (mpm->later_idle && !immediately) - sprd_mpm_start_deactive(mpm); - else - sprd_mpm_deactive(mpm); - } - spin_unlock_irqrestore(&mpm->mpm_lock, flags); - - pr_debug("mpm: %s down, up_cnt=%d.\n", mpm->name, mpm->up_cnt); -} - -/** - * sprd_mpm_stay_awake - * modem power manager stay awake. - */ -static void sprd_mpm_stay_awake(struct sprd_mpm_data *mpm) -{ - unsigned long flags; - - /* - * when wakelock_cnt is change form 0 to 1, - * get the system wake lock. - */ - spin_lock_irqsave(&mpm->mpm_lock, flags); - mpm->wakelock_cnt++; - if (mpm->wakelock_cnt == 1) { - mpm->awake_cnt++; -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 4,18,0 )) - __pm_stay_awake(mpm->ws); -#else - __pm_stay_awake(&mpm->ws); -#endif - } - spin_unlock_irqrestore(&mpm->mpm_lock, flags); - - pr_debug("mpm: %s wake, wake_cnt=%d\n", - mpm->name, mpm->wakelock_cnt); -} - -/** - * sprd_mpm_relax - * modem power manager relax wakelock. - */ -static void sprd_mpm_relax(struct sprd_mpm_data *mpm) -{ - unsigned long flags; - - /* - * when wakelock_cnt is change form 0 to 1, - * release the system wake lock. - */ - spin_lock_irqsave(&mpm->mpm_lock, flags); - mpm->wakelock_cnt--; - if (!mpm->wakelock_cnt) -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 4,18,0 )) - __pm_relax(mpm->ws); -#else - __pm_relax(&mpm->ws); -#endif - spin_unlock_irqrestore(&mpm->mpm_lock, flags); - - pr_debug("mpm: %s relax wake, wake_cnt=%d\n", - mpm->name, mpm->wakelock_cnt); -} - -/** - * sprd_pms_do_up_single - * do pms power up. - */ -static void sprd_pms_do_up_single(struct sprd_pms *pms) -{ - struct sprd_mpm_data *mpm = (struct sprd_mpm_data *)pms->data; - - /* - * when active_cnt is change form 0 to 1, mpm up. - */ - pms->active_cnt++; - if (pms->active_cnt == 1) - sprd_mpm_up(mpm, pms->name); - - pr_debug("pms: %s up, active_cnt=%d.\n", - pms->name, pms->active_cnt); -} - -/** - * sprd_pms_do_up_multi - * do pms power up. - */ -static void sprd_pms_do_up_multi(struct sprd_pms *pms) -{ - struct sprd_mpm_data *mpm = (struct sprd_mpm_data *)pms->data; - unsigned long flags; - bool active = false; - - /* - * when active_cnt is change form 0 to 1, mpm up. - */ - spin_lock_irqsave(&pms->active_lock, flags); - - pms->active_cnt++; - if (pms->active_cnt == 1) - active = true; - - spin_unlock_irqrestore(&pms->active_lock, flags); - - pr_debug("pms: %s up, active_cnt=%d.\n", - pms->name, pms->active_cnt); - - if (active) - sprd_mpm_up(mpm, pms->name); -} - -static void sprd_pms_do_up(struct sprd_pms *pms) -{ - if (pms->multitask) - sprd_pms_do_up_multi(pms); - else - sprd_pms_do_up_single(pms); -} - -/** - * sprd_pms_do_down_single - * do pms power down. - */ -static void sprd_pms_do_down_single(struct sprd_pms *pms, bool immediately) -{ - struct sprd_mpm_data *mpm = (struct sprd_mpm_data *)pms->data; - /* - * when active_cnt is change form 1 to 0, mpm down. - */ - if (pms->active_cnt > 0) { - pms->active_cnt--; - if (pms->active_cnt == 0) - sprd_mpm_down(mpm, immediately); - } - - pr_debug("pms: %s down, active_cnt=%d.\n", - pms->name, pms->active_cnt); -} - -/** - * sprd_pms_do_down - * do pms power down. - */ -static void sprd_pms_do_down_multi(struct sprd_pms *pms, bool immediately) -{ - struct sprd_mpm_data *mpm = (struct sprd_mpm_data *)pms->data; - unsigned long flags; - bool deactive = false; - - /* - * when active_cnt is change form 1 to 0, mpm down. - */ - spin_lock_irqsave(&pms->active_lock, flags); - - if (pms->active_cnt > 0) { - pms->active_cnt--; - if (pms->active_cnt == 0) - deactive = true; - } - - spin_unlock_irqrestore(&pms->active_lock, flags); - - pr_debug("pms: %s down, active_cnt=%d.\n", - pms->name, pms->active_cnt); - - if (deactive) - sprd_mpm_down(mpm, immediately); -} - -static void sprd_pms_do_down(struct sprd_pms *pms, bool immediately) -{ - if (pms->multitask) - sprd_pms_do_down_multi(pms, immediately); - else - sprd_pms_do_down_single(pms, immediately); -} - -/** - * sprd_pms_stay_awake - * power manger source stay awake. - */ -static void sprd_pms_stay_awake(struct sprd_pms *pms) -{ - struct sprd_mpm_data *mpm = (struct sprd_mpm_data *)pms->data; - - pr_debug("pms: %s stay awake.\n", pms->name); - - pms->awake_cnt++; - if (!pms->awake) { - pms->awake = true; - sprd_mpm_stay_awake(mpm); - } -} - -/** - * sprd_pms_relax - * power manger source release wakelock. - */ -static void sprd_pms_relax(struct sprd_pms *pms) -{ - struct sprd_mpm_data *mpm = (struct sprd_mpm_data *)pms->data; - - pr_debug("pms: %s relax awake.\n", pms->name); - - if (pms->awake) { - pms->awake = false; - sprd_mpm_relax(mpm); - } -} - -/** - * sprd_pms_relax_wakelock_timer - * the timer process function of pms delay release wakelock. - */ -static void sprd_pms_relax_wakelock_timer( -#if (LINUX_VERSION_CODE <= KERNEL_VERSION( 4,10,0 )) - unsigned long data) -{ - struct sprd_pms *pms = (struct sprd_pms *)data; -#else - struct timer_list *t) -{ - struct sprd_pms *pms = from_timer(pms, t, wake_timer); -#endif - - unsigned long flags; - bool relax = false; - - pr_debug("pms: %s timer down.\n", pms->name); - - spin_lock_irqsave(&pms->expires_lock, flags); - /* - * if jiffies < pms->expires, mpm called has been canceled, - * don't call sprd_pms_down. - */ - if (pms->expires && time_after_eq(jiffies, pms->expires)) { - pms->expires = 0; - relax = true; - } - spin_unlock_irqrestore(&pms->expires_lock, flags); - - if (relax) - sprd_pms_relax(pms); -} - -int sprd_mpm_create(unsigned int dst, const char *name, - unsigned int later_idle) -{ - struct sprd_mpm_data *mpm; - - if (dst >= SIPC_ID_NR) - return -EINVAL; - - mpm = kzalloc(sizeof(*mpm), GFP_KERNEL); - if (!mpm) - return -ENOMEM; - - snprintf(mpm->name, sizeof(mpm->name), "%s-mpm-%d", name, dst); - - mpm->dst = dst; - mpm->later_idle = later_idle; - - spin_lock_init(&mpm->mpm_lock); - INIT_LIST_HEAD(&mpm->pms_list); -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 4,18,0 )) - mpm->ws = wakeup_source_register(NULL, mpm->name); -#else - wakeup_source_init(&mpm->ws, mpm->name); -#endif - -#if (LINUX_VERSION_CODE <= KERNEL_VERSION( 4,10,0 )) - setup_timer(&mpm->timer, - sprd_mpm_deactive_timer_fn, - (unsigned long)mpm); -#else - timer_setup(&mpm->timer, - sprd_mpm_deactive_timer_fn, - 0); -#endif - - INIT_WORK(&mpm->request_res_work, sprd_mpm_request_res_work_fn); - INIT_WORK(&mpm->release_res_work, sprd_mpm_release_res_work_fn); - - g_sprd_mpm[dst] = mpm; - - return 0; -} - -int sprd_mpm_init_resource_ops(unsigned int dst, - int (*wait_resource)(unsigned int dst, - int timeout), - int (*request_resource)(unsigned int dst), - int (*release_resource)(unsigned int dst)) -{ - struct sprd_mpm_data *mpm; - - if (dst >= SIPC_ID_NR) - return -EINVAL; - - mpm = g_sprd_mpm[dst]; - if (!mpm) - return -ENODEV; - - mpm->wait_resource = wait_resource; - mpm->request_resource = request_resource; - mpm->release_resource = release_resource; - - return 0; -} - -int sprd_mpm_destroy(unsigned int dst) -{ - struct sprd_pms *pms, *temp; - struct sprd_mpm_data *mpm; - unsigned long flags; - - if (dst >= SIPC_ID_NR) - return -EINVAL; - - mpm = g_sprd_mpm[dst]; - if (!mpm) - return -ENODEV; - - sprd_mpm_cancel_timer(mpm); - cancel_work_sync(&mpm->request_res_work); - cancel_work_sync(&mpm->release_res_work); - - spin_lock_irqsave(&mpm->mpm_lock, flags); - list_for_each_entry_safe(pms, - temp, - &mpm->pms_list, - entry) { - sprd_pms_cancel_timer(pms); - list_del(&pms->entry); - } - spin_unlock_irqrestore(&mpm->mpm_lock, flags); - - kfree(mpm); - g_sprd_mpm[dst] = NULL; - - return 0; -} - -struct sprd_pms *sprd_pms_create(unsigned int dst, - const char *name, bool multitask) -{ - unsigned long flags; - struct sprd_pms *pms; - struct sprd_mpm_data *mpm; - - if (dst >= SIPC_ID_NR) - return NULL; - - mpm = g_sprd_mpm[dst]; - if (!mpm) { - pr_err("mpm: %s pms init failed, dst=%d.\n", name, dst); - return NULL; - } - - pms = kzalloc(sizeof(*pms), GFP_KERNEL); - if (!pms) - return NULL; - - pms->multitask = multitask; - pms->name = name; - pms->data = (void *)mpm; - - spin_lock_init(&pms->expires_lock); - spin_lock_init(&pms->active_lock); - -#if (LINUX_VERSION_CODE <= KERNEL_VERSION( 4,10,0 )) - setup_timer(&pms->wake_timer, - sprd_pms_relax_wakelock_timer, (unsigned long)pms); -#else - timer_setup(&pms->wake_timer, - sprd_pms_relax_wakelock_timer, 0); -#endif - - spin_lock_irqsave(&mpm->mpm_lock, flags); - list_add(&pms->entry, &mpm->pms_list); - spin_unlock_irqrestore(&mpm->mpm_lock, flags); - - return pms; -} - -void sprd_pms_destroy(struct sprd_pms *pms) -{ - unsigned long flags; - struct sprd_mpm_data *mpm; - - if (pms) { - sprd_pms_cancel_timer(pms); - mpm = (struct sprd_mpm_data *)pms->data; - spin_lock_irqsave(&mpm->mpm_lock, flags); - list_del(&pms->entry); - spin_unlock_irqrestore(&mpm->mpm_lock, flags); - kfree(pms); - } -} - -/** - * sprd_pms_request_resource - request mpm resource - * - * @pms, the point of this pms. - * @timeout, in ms. - * - * Returns: - * 0 resource ready, - * < 0 resoure not ready, - * -%ERESTARTSYS if it was interrupted by a signal. - */ -int sprd_pms_request_resource(struct sprd_pms *pms, int timeout) -{ - int ret; - struct sprd_mpm_data *mpm; - - if (!pms) - return -EINVAL; - - sprd_pms_do_up(pms); - - /* wait resource */ - mpm = (struct sprd_mpm_data *)pms->data; - ret = sprd_mpm_wait_resource(mpm, timeout); - if (ret) - sprd_pms_do_down(pms, false); - - return ret; -} - -/** - * sprd_pms_release_resource - release mpm resource. - * - * @pms, the point of this pms. - */ -void sprd_pms_release_resource(struct sprd_pms *pms) -{ - if (pms) - sprd_pms_do_down(pms, false); -} - -/** - * sprd_pms_request_wakelock - request wakelock - * - * @pms, the point of this pms. - */ -void sprd_pms_request_wakelock(struct sprd_pms *pms) -{ - if (pms) { - sprd_pms_cancel_timer(pms); - sprd_pms_stay_awake(pms); - } -} - -/** - * sprd_pms_release_wakelock - release wakelock - * - * @pms, the point of this pms. - */ -void sprd_pms_release_wakelock(struct sprd_pms *pms) -{ - if (pms) { - sprd_pms_cancel_timer(pms); - sprd_pms_relax(pms); - } -} - -/** - * sprd_pms_request_wakelock_period - - * request wake lock, and will auto reaslse in msec ms. - * - * @pms, the point of this pms. - * @msec, will auto reaslse in msec ms - */ -void sprd_pms_request_wakelock_period(struct sprd_pms *pms, unsigned int msec) -{ - sprd_pms_request_wakelock(pms); - sprd_pms_release_wakelock_later(pms, msec); -} - -/** - * sprd_pms_release_wakelock_later - release wakelock later. - * - * @pms, the point of this pms. - * @msec, later time (in ms). - */ -void sprd_pms_release_wakelock_later(struct sprd_pms *pms, - unsigned int msec) -{ - unsigned long expires; - unsigned long flags; - - if (pms) { - pr_debug("pms: %s release wakelock after %d ms.\n", - pms->name, msec); - - spin_lock_irqsave(&pms->expires_lock, flags); - expires = jiffies + msecs_to_jiffies(msec); - if (!expires) - expires = 1; - - /* always update the timer with new time */ - pms->expires = expires; - mod_timer(&pms->wake_timer, expires); - spin_unlock_irqrestore(&pms->expires_lock, flags); - } -} - -void sprd_pms_power_up(struct sprd_pms *pms) -{ - if (pms) - sprd_pms_do_up(pms); -} - -void sprd_pms_power_down(struct sprd_pms *pms, bool immediately) -{ - if (pms) - sprd_pms_do_down(pms, immediately); -} - -#if defined(CONFIG_DEBUG_FS) -static int sprd_mpm_stats_show(struct seq_file *m, void *unused) -{ - unsigned long flags; - struct sprd_pms *pms; - struct sprd_mpm_data *cur; - unsigned int i, ms; - - seq_puts(m, "---------------------------------------------\n"); - seq_puts(m, "All mpm list:\n"); - - for (i = 0; i < SIPC_ID_NR; i++) { - if (!g_sprd_mpm[i]) - continue; - - cur = g_sprd_mpm[i]; - seq_puts(m, "------------------------------------\n"); - seq_printf(m, "mpm = %s info:\n", cur->name); - seq_printf(m, "last up module = %s info:\n", - cur->last_name ? cur->last_name : "null"); - - if (cur->expires > 0) { - ms = jiffies_to_msecs(cur->expires - jiffies); - seq_printf(m, "left %d ms to idle\n", ms); - } - - seq_printf(m, "up_cnt=%d, state=%d.\n", - cur->up_cnt, cur->mpm_state); - seq_printf(m, "wakelock_cnt=%d, awake_cnt=%d\n", - cur->wakelock_cnt, cur->awake_cnt); - seq_puts(m, "------------------------------------\n"); - - seq_puts(m, "active pms list:\n"); - spin_lock_irqsave(&cur->mpm_lock, flags); - list_for_each_entry(pms, &cur->pms_list, entry) { - if (!pms->active_cnt && !pms->awake) - continue; - - seq_printf(m, " %s: active_cnt=%d, awake=%d\n", - pms->name, pms->active_cnt, pms->awake); - } - spin_unlock_irqrestore(&cur->mpm_lock, flags); - } - - seq_puts(m, "---------------------------------------------\n"); - - return 0; -} - -static int sprd_mpm_stats_open(struct inode *inode, struct file *file) -{ - return single_open(file, sprd_mpm_stats_show, NULL); -} - -static const struct file_operations sprd_mpm_stats_fops = { - .owner = THIS_MODULE, - .open = sprd_mpm_stats_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static int sprd_mpm_init_debugfs(void) -{ - struct dentry *root = debugfs_create_dir("mpm", NULL); - - if (!root) - return -ENXIO; - - debugfs_create_file("power_manage", 0444, - (struct dentry *)root, - NULL, &sprd_mpm_stats_fops); - return 0; -} -#endif - - -int modem_power_manager_init(void) -{ - register_pm_notifier(&sprd_mpm_notifier_block); - -#if defined(CONFIG_DEBUG_FS) - sprd_mpm_init_debugfs(); -#endif - - return 0; -} -EXPORT_SYMBOL(modem_power_manager_init); - -void modem_power_manager_exit(void) -{ - unregister_pm_notifier(&sprd_mpm_notifier_block); -} -EXPORT_SYMBOL(modem_power_manager_exit); diff --git a/quectel_SRPD_PCIE/src/pwake_function/ipq4019/pcie-qcom.c b/quectel_SRPD_PCIE/src/pwake_function/ipq4019/pcie-qcom.c deleted file mode 100644 index fcd0d30..0000000 --- a/quectel_SRPD_PCIE/src/pwake_function/ipq4019/pcie-qcom.c +++ /dev/null @@ -1,2237 +0,0 @@ -/* - * Copyright (c) 2014-2015, The Linux Foundation. All rights reserved. - * Copyright 2015 Linaro Limited. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "pcie-designware.h" - -#define PCIE20_PARF_SYS_CTRL 0x00 -#define ECAM_BLOCKER_EN_RANGE2 BIT(30) -#define MAC_PHY_POWERDOWN_IN_P2_D_MUX_EN BIT(29) -#define ECAM_REMOVE_OFFSET_EN BIT(27) -#define ECAM_BLOCKER_EN BIT(26) -#define MST_WAKEUP_EN BIT(13) -#define SLV_WAKEUP_EN BIT(12) -#define MSTR_ACLK_CGC_DIS BIT(10) -#define SLV_ACLK_CGC_DIS BIT(9) -#define CORE_CLK_CGC_DIS BIT(6) -#define AUX_PWR_DET BIT(4) -#define CORE_CLK_2AUX_CLK_MUX_DIS BIT(3) -#define L23_CLK_RMV_DIS BIT(2) -#define L1_CLK_RMV_DIS BIT(1) - -#define PCIE20_PARF_Q2A_FLUSH 0x1AC - -#define PCIE20_PARF_LTSSM 0x1B0 -#define LTSSM_EN (1 << 8) - -#define PCIE20_PARF_PHY_CTRL 0x40 -#define PHY_CTRL_PHY_TX0_TERM_OFFSET_MASK (0x1f << 16) -#define PHY_CTRL_PHY_TX0_TERM_OFFSET(x) (x << 16) - -#define PCIE20_PARF_PHY_REFCLK 0x4C -#define REF_SSP_EN BIT(16) -#define REF_USE_PAD BIT(12) - -#define PCIE20_PARF_DBI_BASE_ADDR 0x168 -#define PCIE20_PARF_SLV_ADDR_SPACE_SIZE 0x16c -#define PCIE20_PARF_AXI_MSTR_WR_ADDR_HALT 0x178 - -#define PARF_MHI_CLOCK_RESET_CTRL 0x174 -#define BYPASS BIT(4) -#define MSTR_AXI_CLK_EN BIT(1) -#define AHB_CLK_EN BIT(0) - -#define PARF_BLOCK_SLV_AXI_WR_BASE 0x360 -#define PARF_BLOCK_SLV_AXI_WR_LIMIT 0x368 -#define PARF_BLOCK_SLV_AXI_RD_BASE 0x370 -#define PARF_BLOCK_SLV_AXI_RD_LIMIT 0x378 -#define PARF_ECAM_BASE 0x380 -#define PARF_ECAM_OFFSET_REMOVAL_BASE 0x388 -#define PARF_ECAM_OFFSET_REMOVAL_LIMIT 0x390 -#define PARF_BLOCK_SLV_AXI_WR_BASE_2 0x398 -#define PARF_BLOCK_SLV_AXI_WR_LIMIT_2 0x3A0 -#define PARF_BLOCK_SLV_AXI_RD_BASE_2 0x3A8 -#define PARF_BLOCK_SLV_AXI_RD_LIMIT_2 0x3B0 -#define PARF_BDF_TO_SID_TABLE 0x2000 - -#define PCIE_PARF_DEVICE_TYPE 0x1000 -#define DEVICE_TYPE_RC 0x4 - -#define PCIE20_ELBI_SYS_CTRL 0x04 -#define PCIE20_ELBI_SYS_CTRL_LT_ENABLE BIT(0) -#define PCIE20_ELBI_SYS_STTS 0x08 -#define XMLH_LINK_UP 0x400 - -#define PCIE20_CAP 0x70 -#define PCIE20_CAP_LINKCTRLSTATUS (PCIE20_CAP + 0x10) - -#define PCIE20_AXI_MSTR_RESP_COMP_CTRL0 0x818 -#define PCIE20_AXI_MSTR_RESP_COMP_CTRL1 0x81c - -#define PCIE20_PLR_IATU_VIEWPORT 0x900 -#define PCIE20_PLR_IATU_REGION_OUTBOUND (0x0 << 31) -#define PCIE20_PLR_IATU_REGION_INDEX(x) (x << 0) - -#define PCIE20_PLR_IATU_CTRL1 0x904 -#define PCIE20_PLR_IATU_TYPE_CFG0 (0x4 << 0) -#define PCIE20_PLR_IATU_TYPE_MEM (0x0 << 0) - -#define PCIE20_PLR_IATU_CTRL2 0x908 -#define PCIE20_PLR_IATU_ENABLE BIT(31) - -#define PCIE20_PLR_IATU_LBAR 0x90C -#define PCIE20_PLR_IATU_UBAR 0x910 -#define PCIE20_PLR_IATU_LAR 0x914 -#define PCIE20_PLR_IATU_LTAR 0x918 -#define PCIE20_PLR_IATU_UTAR 0x91c - -#define MSM_PCIE_DEV_CFG_ADDR 0x01000000 -#define PCIE20_CAP_LINK_CAPABILITIES (PCIE20_CAP + 0xC) -#define PCIE20_CAP_LINK_1 (PCIE20_CAP + 0x14) -#define PCIE_CAP_LINK1_VAL 0x2fd7f - - -#define PCIE20_COMMAND_STATUS 0x04 -#define CMD_BME_VAL 0x4 -#define BUS_MASTER_EN 0x7 - -#define PCIE20_DEVICE_CONTROL2_STATUS2 0x98 -#define PCIE_CAP_CPL_TIMEOUT_DISABLE 0x10 - -#define PCIE30_GEN3_RELATED_OFF 0x890 -#define GEN3_EQUALIZATION_DISABLE BIT(16) -#define RXEQ_RGRDLESS_RXTS BIT(13) -#define GEN3_ZRXDC_NONCOMPL BIT(0) - -#define PCIE20_MISC_CONTROL_1_REG 0x8BC -#define DBI_RO_WR_EN 1 - -#define PERST_DELAY_US 1000 -/* PARF registers */ -#define PCIE20_PARF_PCS_DEEMPH 0x34 -#define PCS_DEEMPH_TX_DEEMPH_GEN1(x) (x << 16) -#define PCS_DEEMPH_TX_DEEMPH_GEN2_3_5DB(x) (x << 8) -#define PCS_DEEMPH_TX_DEEMPH_GEN2_6DB(x) (x << 0) - -#define PCIE20_PARF_PCS_SWING 0x38 -#define PCS_SWING_TX_SWING_FULL(x) (x << 8) -#define PCS_SWING_TX_SWING_LOW(x) (x << 0) - -#define PCIE20_PARF_CONFIG_BITS 0x50 -#define PHY_RX0_EQ(x) (x << 24) - -#define PCIE20_LNK_CONTROL2_LINK_STATUS2 0xA0 -#define PCIE_CAP_CURR_DEEMPHASIS BIT(16) -#define SPEED_GEN1 0x1 -#define SPEED_GEN2 0x2 -#define SPEED_GEN3 0x3 -#define PCIE_CAP_TARGET_LINK_SPEED_MASK __mask(3, 0) - -#define __set(v, a, b) (((v) << (b)) & GENMASK(a, b)) -#define __mask(a, b) (((1 << ((a) + 1)) - 1) & ~((1 << (b)) - 1)) -#define PCIE20_DEV_CAS 0x78 -#define PCIE20_MRRS_MASK __mask(14, 12) -#define PCIE20_MRRS(x) __set(x, 14, 12) -#define PCIE20_MPS_MASK __mask(7, 5) -#define PCIE20_MPS(x) __set(x, 7, 5) - -#define AXI_CLK_RATE 200000000 -#define RCHNG_CLK_RATE 100000000 - -#define PCIE20_v3_PARF_SLV_ADDR_SPACE_SIZE 0x358 -#define SLV_ADDR_SPACE_SZ 0x10000000 - -#define PCIE_V2_PARF_SIZE 0x2000 - -#define PCIE20_INT_ALL_STATUS 0x224 -#define PCIE20_INT_ALL_CLEAR 0x228 -#define PCIE20_INT_ALL_MASK 0x22c -#define PCIE_LINK_UP 0x2000 -#define PCIE_LINK_DOWN 0x2 - -#define PCIE_ATU_CR1_OUTBOUND_6_GEN3 0xC00 -#define PCIE_ATU_CR2_OUTBOUND_6_GEN3 0xC04 -#define PCIE_ATU_LOWER_BASE_OUTBOUND_6_GEN3 0xC08 -#define PCIE_ATU_UPPER_BASE_OUTBOUND_6_GEN3 0xC0C -#define PCIE_ATU_LIMIT_OUTBOUND_6_GEN3 0xC10 -#define PCIE_ATU_LOWER_TARGET_OUTBOUND_6_GEN3 0xC14 -#define PCIE_ATU_UPPER_TARGET_OUTBOUND_6_GEN3 0xC18 - -#define PCIE_ATU_CR1_OUTBOUND_7_GEN3 0xE00 -#define PCIE_ATU_CR2_OUTBOUND_7_GEN3 0xE04 -#define PCIE_ATU_LOWER_BASE_OUTBOUND_7_GEN3 0xE08 -#define PCIE_ATU_UPPER_BASE_OUTBOUND_7_GEN3 0xE0C -#define PCIE_ATU_LIMIT_OUTBOUND_7_GEN3 0xE10 -#define PCIE_ATU_LOWER_TARGET_OUTBOUND_7_GEN3 0xE14 -#define PCIE_ATU_UPPER_TARGET_OUTBOUND_7_GEN3 0xE18 - -#define PCIE_ASPM_MASK 0x3 -#define PCIE_ASPM_POS 10 - -struct qcom_pcie_resources_v0 { - struct clk *iface_clk; - struct clk *core_clk; - struct clk *phy_clk; - struct clk *aux_clk; - struct clk *ref_clk; - struct reset_control *pci_reset; - struct reset_control *axi_reset; - struct reset_control *ahb_reset; - struct reset_control *por_reset; - struct reset_control *phy_reset; - struct reset_control *ext_reset; - struct regulator *vdda; - struct regulator *vdda_phy; - struct regulator *vdda_refclk; - uint8_t phy_tx0_term_offset; -}; - -struct qcom_pcie_resources_v1 { - struct clk *iface; - struct clk *aux; - struct clk *master_bus; - struct clk *slave_bus; - struct reset_control *core; - struct regulator *vdda; -}; - -struct qcom_pcie_resources_v2 { - struct clk *ahb_clk; - struct clk *axi_m_clk; - struct clk *axi_s_clk; - struct reset_control *axi_m_reset; - struct reset_control *axi_s_reset; - struct reset_control *pipe_reset; - struct reset_control *axi_m_vmid_reset; - struct reset_control *axi_s_xpu_reset; - struct reset_control *parf_reset; - struct reset_control *phy_reset; - struct reset_control *axi_m_sticky_reset; - struct reset_control *pipe_sticky_reset; - struct reset_control *pwr_reset; - struct reset_control *ahb_reset; - struct reset_control *phy_ahb_reset; - struct regulator *vdda; - struct regulator *vdda_phy; - struct regulator *vdda_refclk; -}; - -struct qcom_pcie_resources_v3 { - struct clk *sys_noc_clk; - struct clk *axi_m_clk; - struct clk *axi_s_clk; - struct clk *ahb_clk; - struct clk *aux_clk; - struct clk *axi_bridge_clk; - struct clk *rchng_clk; - struct reset_control *axi_m_reset; - struct reset_control *axi_s_reset; - struct reset_control *pipe_reset; - struct reset_control *axi_m_sticky_reset; - struct reset_control *axi_s_sticky_reset; - struct reset_control *ahb_reset; - struct reset_control *sticky_reset; - struct reset_control *sleep_reset; - - struct regulator *vdda; - struct regulator *vdda_phy; - struct regulator *vdda_refclk; -}; - -union qcom_pcie_resources { - struct qcom_pcie_resources_v0 v0; - struct qcom_pcie_resources_v1 v1; - struct qcom_pcie_resources_v2 v2; - struct qcom_pcie_resources_v3 v3; -}; - -struct qcom_pcie; - -struct qcom_pcie_ops { - int (*get_resources)(struct qcom_pcie *pcie); - int (*init)(struct qcom_pcie *pcie); - void (*deinit)(struct qcom_pcie *pcie); -}; - -struct qcom_pcie { - struct pcie_port pp; - struct device *dev; - union qcom_pcie_resources res; - void __iomem *parf; - void __iomem *dbi; - void __iomem *elbi; - void __iomem *dm_iatu; - struct phy *phy; - struct gpio_desc *reset; - struct qcom_pcie_ops *ops; - struct work_struct handle_wake_work; - struct work_struct handle_e911_work; - uint32_t force_gen1; - uint32_t force_gen2; - u32 is_emulation; - u32 compliance; - u32 use_delay; - u32 link_retries_count; - u32 slot_id; - u32 cap_active_state_link_pm; - u32 is_gen3; - int global_irq; - int wake_irq; - int link_down_irq; - int link_up_irq; - int mdm2ap_e911_irq; - bool enumerated; - uint32_t rc_idx; - struct qcom_pcie_register_event *event_reg; - struct notifier_block pci_reboot_notifier; -}; - -#define to_qcom_pcie(x) container_of(x, struct qcom_pcie, pp) - -#define MAX_RC_NUM 3 -static struct qcom_pcie *qcom_pcie_dev[MAX_RC_NUM]; -struct gpio_desc *mdm2ap_e911; - -static inline void -writel_masked(void __iomem *addr, u32 clear_mask, u32 set_mask) -{ - u32 val = readl(addr); - - val &= ~clear_mask; - val |= set_mask; - writel(val, addr); -} - -static void qcom_ep_reset_assert(struct qcom_pcie *pcie) -{ - gpiod_set_value(pcie->reset, 1); - usleep_range(PERST_DELAY_US, PERST_DELAY_US + 500); -} - -static void qcom_ep_reset_deassert(struct qcom_pcie *pcie) -{ - msleep(100); - gpiod_set_value(pcie->reset, 0); - usleep_range(PERST_DELAY_US, PERST_DELAY_US + 500); -} - -static irqreturn_t qcom_pcie_msi_irq_handler(int irq, void *arg) -{ - struct pcie_port *pp = arg; - - return dw_handle_msi_irq(pp); -} - -static int qcom_pcie_establish_link(struct qcom_pcie *pcie) -{ - u32 val; - - if (dw_pcie_link_up(&pcie->pp)) - return 0; - - /* enable link training */ - val = readl(pcie->elbi + PCIE20_ELBI_SYS_CTRL); - val |= PCIE20_ELBI_SYS_CTRL_LT_ENABLE; - writel(val, pcie->elbi + PCIE20_ELBI_SYS_CTRL); - - return dw_pcie_wait_for_link(&pcie->pp); -} - -static void qcom_pcie_notify_client(struct qcom_pcie *dev, - enum qcom_pcie_event event) -{ - if (dev->event_reg && dev->event_reg->callback && - (dev->event_reg->events & event)) { - struct qcom_pcie_notify *notify = &dev->event_reg->notify; - notify->event = event; - notify->user = dev->event_reg->user; - pr_info("PCIe: callback RC%d for event %d.\n", - dev->rc_idx, event); - dev->event_reg->callback(notify); - - } else { - pr_info( - "PCIe: Client of RC%d does not have registered for event %d.\n", - dev->rc_idx, event); - } -} - -static irqreturn_t handle_link_down_irq(int irq, void *data) -{ - struct qcom_pcie *qcom_pcie = data; - - pr_info("PCIe: link_down IRQ for RC=%d\n", qcom_pcie->rc_idx); - - qcom_pcie_notify_client(qcom_pcie, QCOM_PCIE_EVENT_LINKDOWN); - return IRQ_HANDLED; -} - -static irqreturn_t handle_link_up_irq(int irq, void *data) -{ - struct qcom_pcie *qcom_pcie = data; - - pr_info("PCIe: link_up IRQ for RC=%d\n", qcom_pcie->rc_idx); - - return IRQ_HANDLED; -} - -/* PCIe wake-irq handler */ -static void handle_wake_func(struct work_struct *work) -{ - int ret; - struct qcom_pcie *pcie = container_of(work, struct qcom_pcie, - handle_wake_work); - struct pcie_port *pp = &pcie->pp; - - pci_lock_rescan_remove(); - if (pcie->enumerated) { - pr_info("PCIe: RC%d has been already enumerated\n", pcie->rc_idx); - pci_unlock_rescan_remove(); - return; - } - - if (!gpiod_get_value(mdm2ap_e911)) { - ret = dw_pcie_host_init_pm(pp); - - if (ret) - pr_err("PCIe: failed to enable RC%d upon wake request from the device\n", - pcie->rc_idx); - else { - pcie->enumerated = true; - pr_info("PCIe: enumerated RC%d successfully upon wake request from the device\n", - pcie->rc_idx); - } - } - - pci_unlock_rescan_remove(); -} - -static irqreturn_t qcom_pcie_wake_irq_handler(int irq, void *data) -{ - struct qcom_pcie *pcie = data; - - schedule_work(&pcie->handle_wake_work); - - return IRQ_HANDLED; -} - -/* PCIe global int handler */ -static irqreturn_t qcom_pcie_global_irq_handler(int irq, void *data) -{ - u32 status = 0; - unsigned long val, val_status, val_mask; - irqreturn_t ret = IRQ_HANDLED; - struct qcom_pcie *pcie = data; - - val_status = readl_relaxed(pcie->parf + PCIE20_INT_ALL_STATUS); - val_mask = readl_relaxed(pcie->parf + PCIE20_INT_ALL_MASK); - status = val_status & val_mask; - - /* Clear PARF status register */ - val = readl_relaxed(pcie->parf + PCIE20_INT_ALL_CLEAR) | status; - writel_relaxed(val, pcie->parf + PCIE20_INT_ALL_CLEAR); - /* ensure data is written to hw register */ - wmb(); - - if (status & PCIE_LINK_DOWN) - pr_info("PCIe: link_up IRQ for RC=%d\n", pcie->rc_idx); - if (status & PCIE_LINK_UP) - pr_info("PCIe: link_down IRQ for RC=%d\n", pcie->rc_idx); - - return ret; -} - -static void qcom_pcie_prog_viewport_cfg0(struct qcom_pcie *pcie, u32 busdev) -{ - struct pcie_port *pp = &pcie->pp; - - /* - * program and enable address translation region 0 (device config - * address space); region type config; - * axi config address range to device config address range - */ - writel(PCIE20_PLR_IATU_REGION_OUTBOUND | - PCIE20_PLR_IATU_REGION_INDEX(0), - pcie->dbi + PCIE20_PLR_IATU_VIEWPORT); - - writel(PCIE20_PLR_IATU_TYPE_CFG0, pcie->dbi + PCIE20_PLR_IATU_CTRL1); - writel(PCIE20_PLR_IATU_ENABLE, pcie->dbi + PCIE20_PLR_IATU_CTRL2); - writel(pp->cfg0_base, pcie->dbi + PCIE20_PLR_IATU_LBAR); - writel((pp->cfg0_base >> 32), pcie->dbi + PCIE20_PLR_IATU_UBAR); - writel((pp->cfg0_base + pp->cfg0_size - 1), - pcie->dbi + PCIE20_PLR_IATU_LAR); - writel(busdev, pcie->dbi + PCIE20_PLR_IATU_LTAR); - writel(0, pcie->dbi + PCIE20_PLR_IATU_UTAR); -} - -static void qcom_pcie_prog_viewport_mem2_outbound(struct qcom_pcie *pcie) -{ - struct pcie_port *pp = &pcie->pp; - - /* - * program and enable address translation region 2 (device resource - * address space); region type memory; - * axi device bar address range to device bar address range - */ - writel(PCIE20_PLR_IATU_REGION_OUTBOUND | - PCIE20_PLR_IATU_REGION_INDEX(2), - pcie->dbi + PCIE20_PLR_IATU_VIEWPORT); - - writel(PCIE20_PLR_IATU_TYPE_MEM, pcie->dbi + PCIE20_PLR_IATU_CTRL1); - writel(PCIE20_PLR_IATU_ENABLE, pcie->dbi + PCIE20_PLR_IATU_CTRL2); - writel(pp->mem_base, pcie->dbi + PCIE20_PLR_IATU_LBAR); - writel((pp->mem_base >> 32), pcie->dbi + PCIE20_PLR_IATU_UBAR); - writel(pp->mem_base + pp->mem_size - 1, - pcie->dbi + PCIE20_PLR_IATU_LAR); - writel(pp->mem_bus_addr, pcie->dbi + PCIE20_PLR_IATU_LTAR); - writel(upper_32_bits(pp->mem_bus_addr), - pcie->dbi + PCIE20_PLR_IATU_UTAR); - - /* 256B PCIE buffer setting */ - writel(0x1, pcie->dbi + PCIE20_AXI_MSTR_RESP_COMP_CTRL0); - writel(0x1, pcie->dbi + PCIE20_AXI_MSTR_RESP_COMP_CTRL1); -} - -static int qcom_pcie_get_resources_v0(struct qcom_pcie *pcie) -{ - struct qcom_pcie_resources_v0 *res = &pcie->res.v0; - struct device *dev = pcie->dev; - - res->vdda = devm_regulator_get(dev, "vdda"); - if (IS_ERR(res->vdda)) - return PTR_ERR(res->vdda); - - res->vdda_phy = devm_regulator_get(dev, "vdda_phy"); - if (IS_ERR(res->vdda_phy)) - return PTR_ERR(res->vdda_phy); - - res->vdda_refclk = devm_regulator_get(dev, "vdda_refclk"); - if (IS_ERR(res->vdda_refclk)) - return PTR_ERR(res->vdda_refclk); - - res->iface_clk = devm_clk_get(dev, "iface"); - if (IS_ERR(res->iface_clk)) - return PTR_ERR(res->iface_clk); - - res->core_clk = devm_clk_get(dev, "core"); - if (IS_ERR(res->core_clk)) - return PTR_ERR(res->core_clk); - - res->phy_clk = devm_clk_get(dev, "phy"); - if (IS_ERR(res->phy_clk)) - return PTR_ERR(res->phy_clk); - - res->aux_clk = devm_clk_get(dev, "aux"); - if (IS_ERR(res->aux_clk)) - return PTR_ERR(res->aux_clk); - - res->ref_clk = devm_clk_get(dev, "ref"); - if (IS_ERR(res->ref_clk)) - return PTR_ERR(res->ref_clk); - - res->pci_reset = devm_reset_control_get(dev, "pci"); - if (IS_ERR(res->pci_reset)) - return PTR_ERR(res->pci_reset); - - res->axi_reset = devm_reset_control_get(dev, "axi"); - if (IS_ERR(res->axi_reset)) - return PTR_ERR(res->axi_reset); - - res->ahb_reset = devm_reset_control_get(dev, "ahb"); - if (IS_ERR(res->ahb_reset)) - return PTR_ERR(res->ahb_reset); - - res->por_reset = devm_reset_control_get(dev, "por"); - if (IS_ERR(res->por_reset)) - return PTR_ERR(res->por_reset); - - res->phy_reset = devm_reset_control_get(dev, "phy"); - if (IS_ERR(res->phy_reset)) - return PTR_ERR(res->phy_reset); - - res->ext_reset = devm_reset_control_get(dev, "ext"); - if (IS_ERR(res->ext_reset)) - return PTR_ERR(res->ext_reset); - - if (of_property_read_u8(dev->of_node, "phy-tx0-term-offset", - &res->phy_tx0_term_offset)) - res->phy_tx0_term_offset = 0; - - return 0; -} - -static int qcom_pcie_get_resources_v1(struct qcom_pcie *pcie) -{ - struct qcom_pcie_resources_v1 *res = &pcie->res.v1; - struct device *dev = pcie->dev; - - res->vdda = devm_regulator_get(dev, "vdda"); - if (IS_ERR(res->vdda)) - return PTR_ERR(res->vdda); - - res->iface = devm_clk_get(dev, "iface"); - if (IS_ERR(res->iface)) - return PTR_ERR(res->iface); - - res->aux = devm_clk_get(dev, "aux"); - if (IS_ERR(res->aux)) - return PTR_ERR(res->aux); - - res->master_bus = devm_clk_get(dev, "master_bus"); - if (IS_ERR(res->master_bus)) - return PTR_ERR(res->master_bus); - - res->slave_bus = devm_clk_get(dev, "slave_bus"); - if (IS_ERR(res->slave_bus)) - return PTR_ERR(res->slave_bus); - - res->core = devm_reset_control_get(dev, "core"); - if (IS_ERR(res->core)) - return PTR_ERR(res->core); - - return 0; -} - -static int qcom_pcie_get_resources_v2(struct qcom_pcie *pcie) -{ - struct qcom_pcie_resources_v2 *res = &pcie->res.v2; - struct device *dev = pcie->dev; - - res->vdda = devm_regulator_get(dev, "vdda"); - if (IS_ERR(res->vdda)) - return PTR_ERR(res->vdda); - - res->vdda_phy = devm_regulator_get(dev, "vdda_phy"); - if (IS_ERR(res->vdda_phy)) - return PTR_ERR(res->vdda_phy); - - res->vdda_refclk = devm_regulator_get(dev, "vdda_refclk"); - if (IS_ERR(res->vdda_refclk)) - return PTR_ERR(res->vdda_refclk); - - res->ahb_clk = devm_clk_get(dev, "ahb"); - if (IS_ERR(res->ahb_clk)) - return PTR_ERR(res->ahb_clk); - - res->axi_m_clk = devm_clk_get(dev, "axi_m"); - if (IS_ERR(res->axi_m_clk)) - return PTR_ERR(res->axi_m_clk); - - res->axi_s_clk = devm_clk_get(dev, "axi_s"); - if (IS_ERR(res->axi_s_clk)) - return PTR_ERR(res->axi_s_clk); - - res->axi_m_reset = devm_reset_control_get(dev, "axi_m"); - if (IS_ERR(res->axi_m_reset)) - return PTR_ERR(res->axi_m_reset); - - res->axi_s_reset = devm_reset_control_get(dev, "axi_s"); - if (IS_ERR(res->axi_s_reset)) - return PTR_ERR(res->axi_s_reset); - - res->pipe_reset = devm_reset_control_get(dev, "pipe"); - if (IS_ERR(res->pipe_reset)) - return PTR_ERR(res->pipe_reset); - - res->axi_m_vmid_reset = devm_reset_control_get(dev, "axi_m_vmid"); - if (IS_ERR(res->axi_m_vmid_reset)) - return PTR_ERR(res->axi_m_vmid_reset); - - res->axi_s_xpu_reset = devm_reset_control_get(dev, "axi_s_xpu"); - if (IS_ERR(res->axi_s_xpu_reset)) - return PTR_ERR(res->axi_s_xpu_reset); - - res->parf_reset = devm_reset_control_get(dev, "parf"); - if (IS_ERR(res->parf_reset)) - return PTR_ERR(res->parf_reset); - - res->phy_reset = devm_reset_control_get(dev, "phy"); - if (IS_ERR(res->phy_reset)) - return PTR_ERR(res->phy_reset); - - res->axi_m_sticky_reset = devm_reset_control_get(dev, "axi_m_sticky"); - if (IS_ERR(res->axi_m_sticky_reset)) - return PTR_ERR(res->axi_m_sticky_reset); - - res->pipe_sticky_reset = devm_reset_control_get(dev, "pipe_sticky"); - if (IS_ERR(res->pipe_sticky_reset)) - return PTR_ERR(res->pipe_sticky_reset); - - res->pwr_reset = devm_reset_control_get(dev, "pwr"); - if (IS_ERR(res->pwr_reset)) - return PTR_ERR(res->pwr_reset); - - res->ahb_reset = devm_reset_control_get(dev, "ahb"); - if (IS_ERR(res->ahb_reset)) - return PTR_ERR(res->ahb_reset); - - res->phy_ahb_reset = devm_reset_control_get(dev, "phy_ahb"); - if (IS_ERR(res->phy_ahb_reset)) - return PTR_ERR(res->phy_ahb_reset); - - return 0; -} - - -static int qcom_pcie_get_resources_v3(struct qcom_pcie *pcie) -{ - struct qcom_pcie_resources_v3 *res = &pcie->res.v3; - struct device *dev = pcie->dev; - - res->vdda = devm_regulator_get(dev, "vdda"); - if (IS_ERR(res->vdda)) - return PTR_ERR(res->vdda); - - res->vdda_phy = devm_regulator_get(dev, "vdda_phy"); - if (IS_ERR(res->vdda_phy)) - return PTR_ERR(res->vdda_phy); - - res->vdda_refclk = devm_regulator_get(dev, "vdda_refclk"); - if (IS_ERR(res->vdda_refclk)) - return PTR_ERR(res->vdda_refclk); - - res->sys_noc_clk = devm_clk_get(dev, "sys_noc"); - if (IS_ERR(res->sys_noc_clk)) - return PTR_ERR(res->sys_noc_clk); - - res->axi_m_clk = devm_clk_get(dev, "axi_m"); - if (IS_ERR(res->axi_m_clk)) - return PTR_ERR(res->axi_m_clk); - - res->axi_s_clk = devm_clk_get(dev, "axi_s"); - if (IS_ERR(res->axi_s_clk)) - return PTR_ERR(res->axi_s_clk); - - res->ahb_clk = devm_clk_get(dev, "ahb"); - if (IS_ERR(res->ahb_clk)) - return PTR_ERR(res->ahb_clk); - - res->aux_clk = devm_clk_get(dev, "aux"); - if (IS_ERR(res->aux_clk)) - return PTR_ERR(res->aux_clk); - - if (pcie->is_gen3) { - res->axi_bridge_clk = devm_clk_get(dev, "axi_bridge"); - if (IS_ERR(res->axi_bridge_clk)) - return PTR_ERR(res->axi_bridge_clk); - - res->rchng_clk = devm_clk_get(dev, "rchng"); - if (IS_ERR(res->rchng_clk)) - res->rchng_clk = NULL; - } - - res->axi_m_reset = devm_reset_control_get(dev, "axi_m"); - if (IS_ERR(res->axi_m_reset)) - return PTR_ERR(res->axi_m_reset); - - res->axi_s_reset = devm_reset_control_get(dev, "axi_s"); - if (IS_ERR(res->axi_s_reset)) - return PTR_ERR(res->axi_s_reset); - - res->pipe_reset = devm_reset_control_get(dev, "pipe"); - if (IS_ERR(res->pipe_reset)) - return PTR_ERR(res->pipe_reset); - - res->axi_m_sticky_reset = devm_reset_control_get(dev, "axi_m_sticky"); - if (IS_ERR(res->axi_m_sticky_reset)) - return PTR_ERR(res->axi_m_sticky_reset); - - if (pcie->is_gen3) { - res->axi_s_sticky_reset = devm_reset_control_get(dev, "axi_s_sticky"); - if (IS_ERR(res->axi_s_sticky_reset)) - return PTR_ERR(res->axi_s_sticky_reset); - } - res->sticky_reset = devm_reset_control_get(dev, "sticky"); - if (IS_ERR(res->sticky_reset)) - return PTR_ERR(res->sticky_reset); - - res->ahb_reset = devm_reset_control_get(dev, "ahb"); - if (IS_ERR(res->ahb_reset)) - return PTR_ERR(res->ahb_reset); - - res->sleep_reset = devm_reset_control_get(dev, "sleep"); - if (IS_ERR(res->sleep_reset)) - return PTR_ERR(res->sleep_reset); - - return 0; -} - -static void qcom_pcie_deinit_v0(struct qcom_pcie *pcie) -{ - struct qcom_pcie_resources_v0 *res = &pcie->res.v0; - - clk_disable_unprepare(res->phy_clk); - reset_control_assert(res->phy_reset); - reset_control_assert(res->axi_reset); - reset_control_assert(res->ahb_reset); - reset_control_assert(res->por_reset); - reset_control_assert(res->pci_reset); - reset_control_assert(res->ext_reset); - clk_disable_unprepare(res->iface_clk); - clk_disable_unprepare(res->core_clk); - clk_disable_unprepare(res->aux_clk); - clk_disable_unprepare(res->ref_clk); - regulator_disable(res->vdda); - regulator_disable(res->vdda_phy); - regulator_disable(res->vdda_refclk); -} - -static int qcom_pcie_init_v0(struct qcom_pcie *pcie) -{ - struct qcom_pcie_resources_v0 *res = &pcie->res.v0; - struct device *dev = pcie->dev; - int ret; - - ret = reset_control_assert(res->ahb_reset); - if (ret) { - dev_err(dev, "cannot assert ahb reset\n"); - return ret; - } - - ret = regulator_enable(res->vdda); - if (ret) { - dev_err(dev, "cannot enable vdda regulator\n"); - return ret; - } - - ret = regulator_enable(res->vdda_refclk); - if (ret) { - dev_err(dev, "cannot enable vdda_refclk regulator\n"); - goto err_refclk; - } - - ret = regulator_enable(res->vdda_phy); - if (ret) { - dev_err(dev, "cannot enable vdda_phy regulator\n"); - goto err_vdda_phy; - } - - ret = reset_control_deassert(res->ext_reset); - if (ret) { - dev_err(dev, "cannot assert ext reset\n"); - goto err_reset_ext; - } - - ret = clk_prepare_enable(res->iface_clk); - if (ret) { - dev_err(dev, "cannot prepare/enable iface clock\n"); - goto err_iface; - } - - ret = clk_prepare_enable(res->core_clk); - if (ret) { - dev_err(dev, "cannot prepare/enable core clock\n"); - goto err_clk_core; - } - - ret = clk_prepare_enable(res->aux_clk); - if (ret) { - dev_err(dev, "cannot prepare/enable aux clock\n"); - goto err_clk_aux; - } - - ret = clk_prepare_enable(res->ref_clk); - if (ret) { - dev_err(dev, "cannot prepare/enable ref clock\n"); - goto err_clk_ref; - } - - ret = reset_control_deassert(res->ahb_reset); - if (ret) { - dev_err(dev, "cannot deassert ahb reset\n"); - goto err_deassert_ahb; - } - - writel_masked(pcie->parf + PCIE20_PARF_PHY_CTRL, BIT(0), 0); - - /* Set Tx termination offset */ - writel_masked(pcie->parf + PCIE20_PARF_PHY_CTRL, - PHY_CTRL_PHY_TX0_TERM_OFFSET_MASK, - PHY_CTRL_PHY_TX0_TERM_OFFSET(res->phy_tx0_term_offset)); - - /* PARF programming */ - writel(PCS_DEEMPH_TX_DEEMPH_GEN1(0x18) | - PCS_DEEMPH_TX_DEEMPH_GEN2_3_5DB(0x18) | - PCS_DEEMPH_TX_DEEMPH_GEN2_6DB(0x22), - pcie->parf + PCIE20_PARF_PCS_DEEMPH); - writel(PCS_SWING_TX_SWING_FULL(0x78) | - PCS_SWING_TX_SWING_LOW(0x78), - pcie->parf + PCIE20_PARF_PCS_SWING); - writel(PHY_RX0_EQ(0x4), pcie->parf + PCIE20_PARF_CONFIG_BITS); - - /* Enable reference clock */ - writel_masked(pcie->parf + PCIE20_PARF_PHY_REFCLK, - REF_USE_PAD, REF_SSP_EN); - - - ret = reset_control_deassert(res->phy_reset); - if (ret) { - dev_err(dev, "cannot deassert phy reset\n"); - return ret; - } - - ret = reset_control_deassert(res->pci_reset); - if (ret) { - dev_err(dev, "cannot deassert pci reset\n"); - return ret; - } - - ret = reset_control_deassert(res->por_reset); - if (ret) { - dev_err(dev, "cannot deassert por reset\n"); - return ret; - } - - ret = reset_control_deassert(res->axi_reset); - if (ret) { - dev_err(dev, "cannot deassert axi reset\n"); - return ret; - } - - ret = clk_prepare_enable(res->phy_clk); - if (ret) { - dev_err(dev, "cannot prepare/enable phy clock\n"); - goto err_deassert_ahb; - } - - /* wait for clock acquisition */ - usleep_range(1000, 1500); - if (pcie->force_gen1) { - writel_relaxed(((readl_relaxed( - pcie->dbi + PCIE20_LNK_CONTROL2_LINK_STATUS2) - & (~PCIE_CAP_TARGET_LINK_SPEED_MASK)) | SPEED_GEN1), - pcie->dbi + PCIE20_LNK_CONTROL2_LINK_STATUS2); - } - - qcom_pcie_prog_viewport_cfg0(pcie, MSM_PCIE_DEV_CFG_ADDR); - qcom_pcie_prog_viewport_mem2_outbound(pcie); - - return 0; - -err_deassert_ahb: - clk_disable_unprepare(res->ref_clk); -err_clk_ref: - clk_disable_unprepare(res->aux_clk); -err_clk_aux: - clk_disable_unprepare(res->core_clk); -err_clk_core: - clk_disable_unprepare(res->iface_clk); -err_iface: - reset_control_assert(res->ext_reset); -err_reset_ext: - regulator_disable(res->vdda_phy); -err_vdda_phy: - regulator_disable(res->vdda_refclk); -err_refclk: - regulator_disable(res->vdda); - - return ret; -} - -static void qcom_pcie_deinit_v1(struct qcom_pcie *pcie) -{ - struct qcom_pcie_resources_v1 *res = &pcie->res.v1; - - reset_control_assert(res->core); - clk_disable_unprepare(res->slave_bus); - clk_disable_unprepare(res->master_bus); - clk_disable_unprepare(res->iface); - clk_disable_unprepare(res->aux); - regulator_disable(res->vdda); -} - -static int qcom_pcie_init_v1(struct qcom_pcie *pcie) -{ - struct qcom_pcie_resources_v1 *res = &pcie->res.v1; - struct device *dev = pcie->dev; - int ret; - - ret = reset_control_deassert(res->core); - if (ret) { - dev_err(dev, "cannot deassert core reset\n"); - return ret; - } - - ret = clk_prepare_enable(res->aux); - if (ret) { - dev_err(dev, "cannot prepare/enable aux clock\n"); - goto err_res; - } - - ret = clk_prepare_enable(res->iface); - if (ret) { - dev_err(dev, "cannot prepare/enable iface clock\n"); - goto err_aux; - } - - ret = clk_prepare_enable(res->master_bus); - if (ret) { - dev_err(dev, "cannot prepare/enable master_bus clock\n"); - goto err_iface; - } - - ret = clk_prepare_enable(res->slave_bus); - if (ret) { - dev_err(dev, "cannot prepare/enable slave_bus clock\n"); - goto err_master; - } - - ret = regulator_enable(res->vdda); - if (ret) { - dev_err(dev, "cannot enable vdda regulator\n"); - goto err_slave; - } - - /* change DBI base address */ - writel(0, pcie->parf + PCIE20_PARF_DBI_BASE_ADDR); - - if (IS_ENABLED(CONFIG_PCI_MSI)) { - u32 val = readl(pcie->parf + PCIE20_PARF_AXI_MSTR_WR_ADDR_HALT); - - val |= BIT(31); - writel(val, pcie->parf + PCIE20_PARF_AXI_MSTR_WR_ADDR_HALT); - } - - return 0; -err_slave: - clk_disable_unprepare(res->slave_bus); -err_master: - clk_disable_unprepare(res->master_bus); -err_iface: - clk_disable_unprepare(res->iface); -err_aux: - clk_disable_unprepare(res->aux); -err_res: - reset_control_assert(res->core); - - return ret; -} - -static void qcom_pcie_deinit_v2(struct qcom_pcie *pcie) -{ - struct qcom_pcie_resources_v2 *res = &pcie->res.v2; - - /* Assert pcie_pipe_ares */ - reset_control_assert(res->axi_m_reset); - reset_control_assert(res->axi_s_reset); - usleep_range(10000, 12000); /* wait 12ms */ - - reset_control_assert(res->pipe_reset); - reset_control_assert(res->pipe_sticky_reset); - reset_control_assert(res->phy_reset); - reset_control_assert(res->phy_ahb_reset); - usleep_range(10000, 12000); /* wait 12ms */ - - reset_control_assert(res->axi_m_sticky_reset); - reset_control_assert(res->pwr_reset); - reset_control_assert(res->ahb_reset); - usleep_range(10000, 12000); /* wait 12ms */ - - clk_disable_unprepare(res->ahb_clk); - clk_disable_unprepare(res->axi_m_clk); - clk_disable_unprepare(res->axi_s_clk); - regulator_disable(res->vdda); - regulator_disable(res->vdda_phy); - regulator_disable(res->vdda_refclk); -} - -static int qcom_pcie_enable_resources_v2(struct qcom_pcie *pcie) -{ - struct qcom_pcie_resources_v2 *res = &pcie->res.v2; - struct device *dev = pcie->dev; - int ret; - - ret = regulator_enable(res->vdda); - if (ret) { - dev_err(dev, "cannot enable vdda regulator\n"); - return ret; - } - - ret = regulator_enable(res->vdda_refclk); - if (ret) { - dev_err(dev, "cannot enable vdda_refclk regulator\n"); - goto err_refclk; - } - - ret = regulator_enable(res->vdda_phy); - if (ret) { - dev_err(dev, "cannot enable vdda_phy regulator\n"); - goto err_vdda_phy; - } - - ret = clk_prepare_enable(res->ahb_clk); - if (ret) { - dev_err(dev, "cannot prepare/enable iface clock\n"); - goto err_ahb; - } - - ret = clk_prepare_enable(res->axi_m_clk); - if (ret) { - dev_err(dev, "cannot prepare/enable core clock\n"); - goto err_clk_axi_m; - } - - ret = clk_prepare_enable(res->axi_s_clk); - if (ret) { - dev_err(dev, "cannot prepare/enable phy clock\n"); - goto err_clk_axi_s; - } - - udelay(1); - - return 0; - -err_clk_axi_s: - clk_disable_unprepare(res->axi_m_clk); -err_clk_axi_m: - clk_disable_unprepare(res->ahb_clk); -err_ahb: - regulator_disable(res->vdda_phy); -err_vdda_phy: - regulator_disable(res->vdda_refclk); -err_refclk: - regulator_disable(res->vdda); - return ret; -} - -static void qcom_pcie_v2_reset(struct qcom_pcie *pcie) -{ - struct qcom_pcie_resources_v2 *res = &pcie->res.v2; - /* Assert pcie_pipe_ares */ - reset_control_assert(res->axi_m_reset); - reset_control_assert(res->axi_s_reset); - usleep_range(10000, 12000); /* wait 12ms */ - - reset_control_assert(res->pipe_reset); - reset_control_assert(res->pipe_sticky_reset); - reset_control_assert(res->phy_reset); - reset_control_assert(res->phy_ahb_reset); - usleep_range(10000, 12000); /* wait 12ms */ - - reset_control_assert(res->axi_m_sticky_reset); - reset_control_assert(res->pwr_reset); - reset_control_assert(res->ahb_reset); - usleep_range(10000, 12000); /* wait 12ms */ - - reset_control_deassert(res->phy_ahb_reset); - reset_control_deassert(res->phy_reset); - reset_control_deassert(res->pipe_reset); - reset_control_deassert(res->pipe_sticky_reset); - usleep_range(10000, 12000); /* wait 12ms */ - - reset_control_deassert(res->axi_m_reset); - reset_control_deassert(res->axi_m_sticky_reset); - reset_control_deassert(res->axi_s_reset); - reset_control_deassert(res->pwr_reset); - reset_control_deassert(res->ahb_reset); - usleep_range(10000, 12000); /* wait 12ms */ - wmb(); /* ensure data is written to hw register */ -} - -static int qcom_pcie_init_v2(struct qcom_pcie *pcie) -{ - int ret; - - qcom_pcie_v2_reset(pcie); - qcom_ep_reset_assert(pcie); - - ret = qcom_pcie_enable_resources_v2(pcie); - if (ret) - return ret; - - writel_masked(pcie->parf + PCIE20_PARF_PHY_CTRL, BIT(0), 0); - - writel(0, pcie->parf + PCIE20_PARF_DBI_BASE_ADDR); - - writel(MST_WAKEUP_EN | SLV_WAKEUP_EN | MSTR_ACLK_CGC_DIS - | SLV_ACLK_CGC_DIS | CORE_CLK_CGC_DIS | - AUX_PWR_DET | L23_CLK_RMV_DIS | L1_CLK_RMV_DIS, - pcie->parf + PCIE20_PARF_SYS_CTRL); - writel(0, pcie->parf + PCIE20_PARF_Q2A_FLUSH); - writel(CMD_BME_VAL, pcie->dbi + PCIE20_COMMAND_STATUS); - writel(DBI_RO_WR_EN, pcie->dbi + PCIE20_MISC_CONTROL_1_REG); - writel(PCIE_CAP_LINK1_VAL, pcie->dbi + PCIE20_CAP_LINK_1); - - writel_masked(pcie->dbi + PCIE20_CAP_LINK_CAPABILITIES, - BIT(10) | BIT(11), 0); - writel(PCIE_CAP_CPL_TIMEOUT_DISABLE, pcie->dbi + - PCIE20_DEVICE_CONTROL2_STATUS2); - writel(LTSSM_EN, pcie->parf + PCIE20_PARF_LTSSM); - - return 0; -} - -static void qcom_pcie_deinit_v3(struct qcom_pcie *pcie) -{ - struct qcom_pcie_resources_v3 *res = &pcie->res.v3; - - clk_disable_unprepare(res->axi_m_clk); - clk_disable_unprepare(res->axi_s_clk); - clk_disable_unprepare(res->ahb_clk); - clk_disable_unprepare(res->aux_clk); - clk_disable_unprepare(res->sys_noc_clk); - regulator_disable(res->vdda); - regulator_disable(res->vdda_phy); - regulator_disable(res->vdda_refclk); -} - -static void qcom_pcie_v3_reset(struct qcom_pcie *pcie) -{ - struct qcom_pcie_resources_v3 *res = &pcie->res.v3; - /* Assert pcie_pipe_ares */ - reset_control_assert(res->pipe_reset); - reset_control_assert(res->sleep_reset); - reset_control_assert(res->sticky_reset); - reset_control_assert(res->axi_m_reset); - reset_control_assert(res->axi_s_reset); - reset_control_assert(res->ahb_reset); - reset_control_assert(res->axi_m_sticky_reset); - if (pcie->is_gen3) - reset_control_assert(res->axi_s_sticky_reset); - usleep_range(10000, 12000); /* wait 12ms */ - - reset_control_deassert(res->pipe_reset); - reset_control_deassert(res->sleep_reset); - reset_control_deassert(res->sticky_reset); - reset_control_deassert(res->axi_m_reset); - reset_control_deassert(res->axi_s_reset); - reset_control_deassert(res->ahb_reset); - reset_control_deassert(res->axi_m_sticky_reset); - if (pcie->is_gen3) - reset_control_deassert(res->axi_s_sticky_reset); - usleep_range(10000, 12000); /* wait 12ms */ - wmb(); /* ensure data is written to hw register */ -} - -static int qcom_pcie_enable_resources_v3(struct qcom_pcie *pcie) -{ - struct qcom_pcie_resources_v3 *res = &pcie->res.v3; - struct device *dev = pcie->dev; - int ret; - - ret = regulator_enable(res->vdda); - if (ret) { - dev_err(dev, "cannot enable vdda regulator\n"); - return ret; - } - - ret = regulator_enable(res->vdda_refclk); - if (ret) { - dev_err(dev, "cannot enable vdda_refclk regulator\n"); - goto err_refclk; - } - - ret = regulator_enable(res->vdda_phy); - if (ret) { - dev_err(dev, "cannot enable vdda_phy regulator\n"); - goto err_vdda_phy; - } - - ret = clk_prepare_enable(res->sys_noc_clk); - if (ret) { - dev_err(dev, "cannot prepare/enable core clock\n"); - goto err_clk_sys_noc; - } - - ret = clk_prepare_enable(res->axi_m_clk); - if (ret) { - dev_err(dev, "cannot prepare/enable core clock\n"); - goto err_clk_axi_m; - } - - ret = clk_set_rate(res->axi_m_clk, AXI_CLK_RATE); - if (ret) { - dev_err(dev, "MClk rate set failed (%d)\n", ret); - goto err_clk_axi_m; - } - - ret = clk_prepare_enable(res->axi_s_clk); - if (ret) { - dev_err(dev, "cannot prepare/enable axi slave clock\n"); - goto err_clk_axi_s; - } - - ret = clk_set_rate(res->axi_s_clk, AXI_CLK_RATE); - if (ret) { - dev_err(dev, "MClk rate set failed (%d)\n", ret); - goto err_clk_axi_s; - } - - ret = clk_prepare_enable(res->ahb_clk); - if (ret) { - dev_err(dev, "cannot prepare/enable ahb clock\n"); - goto err_clk_ahb; - } - - ret = clk_prepare_enable(res->aux_clk); - if (ret) { - dev_err(dev, "cannot prepare/enable aux clock\n"); - goto err_clk_aux; - } - - if (pcie->is_gen3) { - ret = clk_prepare_enable(res->axi_bridge_clk); - if (ret) { - dev_err(dev, "cannot prepare/enable axi_bridge clock\n"); - goto err_clk_axi_bridge; - } - - if (res->rchng_clk) { - ret = clk_prepare_enable(res->rchng_clk); - if (ret) { - dev_err(dev, "cannot prepare/enable rchng_clk clock\n"); - goto err_clk_rchng; - } - - ret = clk_set_rate(res->rchng_clk, RCHNG_CLK_RATE); - if (ret) { - dev_err(dev, "rchng_clk rate set failed (%d)\n", - ret); - goto err_clk_rchng; - } - } - } - - - udelay(1); - - return 0; - -err_clk_rchng: - clk_disable_unprepare(res->axi_bridge_clk); -err_clk_axi_bridge: - clk_disable_unprepare(res->aux_clk); -err_clk_aux: - clk_disable_unprepare(res->ahb_clk); -err_clk_ahb: - clk_disable_unprepare(res->axi_s_clk); -err_clk_axi_s: - clk_disable_unprepare(res->axi_m_clk); -err_clk_axi_m: - clk_disable_unprepare(res->sys_noc_clk); -err_clk_sys_noc: - regulator_disable(res->vdda_phy); -err_vdda_phy: - regulator_disable(res->vdda_refclk); -err_refclk: - regulator_disable(res->vdda); - return ret; -} - - -static int qcom_pcie_init_v3(struct qcom_pcie *pcie) -{ - int ret, i; - - qcom_pcie_v3_reset(pcie); - if (!pcie->is_emulation) - qcom_ep_reset_assert(pcie); - - ret = qcom_pcie_enable_resources_v3(pcie); - if (ret) - return ret; - - writel(SLV_ADDR_SPACE_SZ, pcie->parf + PCIE20_v3_PARF_SLV_ADDR_SPACE_SIZE); - - ret = phy_power_on(pcie->phy); - if (ret) - return ret; - - writel_masked(pcie->parf + PCIE20_PARF_PHY_CTRL, BIT(0), 0); - - writel(0, pcie->parf + PCIE20_PARF_DBI_BASE_ADDR); - - if (pcie->is_gen3) { - writel(DEVICE_TYPE_RC, pcie->parf + PCIE_PARF_DEVICE_TYPE); - writel(BYPASS | MSTR_AXI_CLK_EN | AHB_CLK_EN, - pcie->parf + PARF_MHI_CLOCK_RESET_CTRL); - writel(RXEQ_RGRDLESS_RXTS | - GEN3_ZRXDC_NONCOMPL, pcie->dbi + PCIE30_GEN3_RELATED_OFF); - } - - writel(MST_WAKEUP_EN | SLV_WAKEUP_EN | MSTR_ACLK_CGC_DIS - | SLV_ACLK_CGC_DIS | CORE_CLK_CGC_DIS | - AUX_PWR_DET | L23_CLK_RMV_DIS | L1_CLK_RMV_DIS, - pcie->parf + PCIE20_PARF_SYS_CTRL); - - writel(0, pcie->parf + PCIE20_PARF_Q2A_FLUSH); - if (pcie->is_gen3) - writel(BUS_MASTER_EN, pcie->dbi + PCIE20_COMMAND_STATUS); - else - writel(CMD_BME_VAL, pcie->dbi + PCIE20_COMMAND_STATUS); - writel(DBI_RO_WR_EN, pcie->dbi + PCIE20_MISC_CONTROL_1_REG); - writel(PCIE_CAP_LINK1_VAL, pcie->dbi + PCIE20_CAP_LINK_1); - - /* Configure PCIe link capabilities for ASPM */ - writel_masked(pcie->dbi + PCIE20_CAP_LINK_CAPABILITIES, - PCIE_ASPM_MASK << PCIE_ASPM_POS, - (pcie->cap_active_state_link_pm & PCIE_ASPM_MASK) << PCIE_ASPM_POS); - - writel(PCIE_CAP_CPL_TIMEOUT_DISABLE, pcie->dbi + - PCIE20_DEVICE_CONTROL2_STATUS2); - - if (pcie->is_gen3 && !pcie->force_gen2) - writel_relaxed(PCIE_CAP_CURR_DEEMPHASIS | SPEED_GEN3, - pcie->dbi + PCIE20_LNK_CONTROL2_LINK_STATUS2); - else if (pcie->force_gen2) - writel_relaxed(PCIE_CAP_CURR_DEEMPHASIS | SPEED_GEN2, - pcie->dbi + PCIE20_LNK_CONTROL2_LINK_STATUS2); - - if (pcie->force_gen1) { - writel_relaxed(((readl_relaxed( - pcie->dbi + PCIE20_LNK_CONTROL2_LINK_STATUS2) - & (~PCIE_CAP_TARGET_LINK_SPEED_MASK)) | SPEED_GEN1), - pcie->dbi + PCIE20_LNK_CONTROL2_LINK_STATUS2); - } - - writel(LTSSM_EN, pcie->parf + PCIE20_PARF_LTSSM); - if (pcie->is_emulation) - qcom_ep_reset_deassert(pcie); - - if (pcie->is_gen3) { - for (i = 0; i < 255; i++) - writel(0x0, pcie->parf + PARF_BDF_TO_SID_TABLE + (4 * i)); - writel( 0x4, pcie->dm_iatu + PCIE_ATU_CR1_OUTBOUND_6_GEN3); - writel( 0x90000000, pcie->dm_iatu + PCIE_ATU_CR2_OUTBOUND_6_GEN3); - writel( 0x0, pcie->dm_iatu + PCIE_ATU_LOWER_BASE_OUTBOUND_6_GEN3); - writel( 0x0, pcie->dm_iatu + PCIE_ATU_UPPER_BASE_OUTBOUND_6_GEN3); - writel( 0x00107FFFF, pcie->dm_iatu + PCIE_ATU_LIMIT_OUTBOUND_6_GEN3); - writel( 0x0, pcie->dm_iatu + PCIE_ATU_LOWER_TARGET_OUTBOUND_6_GEN3); - writel( 0x0, pcie->dm_iatu + PCIE_ATU_UPPER_TARGET_OUTBOUND_6_GEN3); - writel( 0x5, pcie->dm_iatu + PCIE_ATU_CR1_OUTBOUND_7_GEN3); - writel( 0x90000000, pcie->dm_iatu + PCIE_ATU_CR2_OUTBOUND_7_GEN3); - writel( 0x200000, pcie->dm_iatu + PCIE_ATU_LOWER_BASE_OUTBOUND_7_GEN3); - writel( 0x0, pcie->dm_iatu+ PCIE_ATU_UPPER_BASE_OUTBOUND_7_GEN3); - writel( 0x7FFFFF, pcie->dm_iatu + PCIE_ATU_LIMIT_OUTBOUND_7_GEN3); - writel( 0x0, pcie->dm_iatu + PCIE_ATU_LOWER_TARGET_OUTBOUND_7_GEN3); - writel( 0x0, pcie->dm_iatu + PCIE_ATU_UPPER_TARGET_OUTBOUND_7_GEN3); - } - - phy_power_off(pcie->phy); - return 0; -} - -static int qcom_pcie_link_up(struct pcie_port *pp) -{ - struct qcom_pcie *pcie = to_qcom_pcie(pp); - u32 val; - - val = readl_relaxed(pcie->elbi + PCIE20_ELBI_SYS_STTS); - if (val & XMLH_LINK_UP) - return 1; - return 0; -} - -static int qcom_pcie_host_init(struct pcie_port *pp) -{ - struct qcom_pcie *pcie = to_qcom_pcie(pp); - int ret; - - if (gpiod_get_value(mdm2ap_e911)) - return -EBUSY; - - if (!pcie->is_emulation) - qcom_ep_reset_assert(pcie); - - ret = pcie->ops->init(pcie); - if (ret) - goto err_deinit; - - ret = phy_power_on(pcie->phy); - if (ret) - goto err_deinit; - - if (IS_ENABLED(CONFIG_PCI_MSI)) { - if (!pp->msi_gicm_addr) - dw_pcie_msi_init(pp); - } - - if (!pcie->is_emulation) - qcom_ep_reset_deassert(pcie); - - ret = qcom_pcie_establish_link(pcie); - if (ret) - goto err; - - return 0; - -err: - if (pcie->compliance == 1) - return 0; - - if (!pcie->is_emulation) - qcom_ep_reset_assert(pcie); - - phy_power_off(pcie->phy); - -err_deinit: - if (pcie->compliance == 1) - return 0; - - pcie->ops->deinit(pcie); - return ret; -} - -static int qcom_pcie_rd_own_conf(struct pcie_port *pp, int where, int size, - u32 *val) -{ - /* the device class is not reported correctly from the register */ - if (where == PCI_CLASS_REVISION && size == 4) { - *val = readl(pp->dbi_base + PCI_CLASS_REVISION); - *val &= 0xff; /* keep revision id */ - *val |= PCI_CLASS_BRIDGE_PCI << 16; - return PCIBIOS_SUCCESSFUL; - } - - return dw_pcie_cfg_read(pp->dbi_base + where, size, val); -} - -static struct pcie_host_ops qcom_pcie_dw_ops = { - .link_up = qcom_pcie_link_up, - .host_init = qcom_pcie_host_init, - .rd_own_conf = qcom_pcie_rd_own_conf, -}; - -static const struct qcom_pcie_ops ops_v0 = { - .get_resources = qcom_pcie_get_resources_v0, - .init = qcom_pcie_init_v0, - .deinit = qcom_pcie_deinit_v0, -}; - -static const struct qcom_pcie_ops ops_v1 = { - .get_resources = qcom_pcie_get_resources_v1, - .init = qcom_pcie_init_v1, - .deinit = qcom_pcie_deinit_v1, -}; - -static const struct qcom_pcie_ops ops_v2 = { - .get_resources = qcom_pcie_get_resources_v2, - .init = qcom_pcie_init_v2, - .deinit = qcom_pcie_deinit_v2, -}; - -static const struct qcom_pcie_ops ops_v3 = { - .get_resources = qcom_pcie_get_resources_v3, - .init = qcom_pcie_init_v3, - .deinit = qcom_pcie_deinit_v3, -}; - -static void qcom_slot_remove(int val) -{ - - struct pcie_port *pp; - pci_lock_rescan_remove(); - - if ((val >= 0) && (val < MAX_RC_NUM)) { - if (qcom_pcie_dev[val]) { - if (!qcom_pcie_dev[val]->enumerated) { - pr_notice("\nPCIe: RC%d already removed", val); - } else { - pr_notice("---> Removing %d", val); - pp = &qcom_pcie_dev[val]->pp; - pci_stop_root_bus(pp->pci_bus); - pci_remove_root_bus(pp->pci_bus); - if (!qcom_pcie_dev[val]->is_emulation) - qcom_ep_reset_assert(qcom_pcie_dev[val]); - phy_power_off(qcom_pcie_dev[val]->phy); - qcom_pcie_dev[val]->ops->deinit(qcom_pcie_dev[val]); - pp->pci_bus = NULL; - qcom_pcie_dev[val]->enumerated = false; - pr_notice(" ... done<---\n"); - } - } - } - pci_unlock_rescan_remove(); -} - -static void qcom_slot_rescan(int val) -{ - - int ret; - struct pcie_port *pp; - pci_lock_rescan_remove(); - - if ((val >= 0) && (val < MAX_RC_NUM)) { - if (qcom_pcie_dev[val]) { - if (qcom_pcie_dev[val]->enumerated) { - pr_notice("PCIe: RC%d already enumerated", val); - } else { - pp = &qcom_pcie_dev[val]->pp; - ret = dw_pcie_host_init_pm(pp); - if (!ret) - qcom_pcie_dev[val]->enumerated = true; - } - } - } - pci_unlock_rescan_remove(); - -} - -int qcom_pcie_rescan(void) -{ - int i, ret; - struct pcie_port *pp; - - for (i = 0; i < MAX_RC_NUM; i++) { - /* reset and enumerate the pcie devices */ - if (qcom_pcie_dev[i]) { - pr_notice("---> Initializing %d\n", i); - if (qcom_pcie_dev[i]->enumerated) - continue; - - pp = &qcom_pcie_dev[i]->pp; - ret = dw_pcie_host_init_pm(pp); - if (!ret) - qcom_pcie_dev[i]->enumerated = true; - pr_notice(" ... done<---\n"); - } - } - return 0; -} - -void qcom_pcie_remove_bus(void) -{ - int i; - - for (i = 0; i < MAX_RC_NUM; i++) { - if (qcom_pcie_dev[i]) { - struct pcie_port *pp; - struct qcom_pcie *pcie; - - pr_notice("---> Removing %d\n", i); - - pcie = qcom_pcie_dev[i]; - if (!pcie->enumerated) - continue; - - pp = &qcom_pcie_dev[i]->pp; - pci_stop_root_bus(pp->pci_bus); - pci_remove_root_bus(pp->pci_bus); - - if (!pcie->is_emulation) - qcom_ep_reset_assert(pcie); - phy_power_off(pcie->phy); - - qcom_pcie_dev[i]->ops->deinit(qcom_pcie_dev[i]); - pp->pci_bus = NULL; - pcie->enumerated = false; - pr_notice(" ... done<---\n"); - } - } -} - -static void handle_e911_func(struct work_struct *work) -{ - - int slot_id; - struct qcom_pcie *pcie = container_of(work, struct qcom_pcie, - handle_e911_work); - slot_id = pcie->slot_id; - - if (gpiod_get_value(mdm2ap_e911)) - qcom_slot_remove(slot_id); - else - qcom_slot_rescan(slot_id); -} - -static irqreturn_t handle_mdm2ap_e911_irq(int irq, void *data) -{ - struct qcom_pcie *pcie = data; - - schedule_work(&pcie->handle_e911_work); - - return IRQ_HANDLED; -} - -static ssize_t qcom_bus_rescan_store(struct bus_type *bus, const char *buf, - size_t count) -{ - unsigned long val; - - if (kstrtoul(buf, 0, &val) < 0) - return -EINVAL; - - if (gpiod_get_value(mdm2ap_e911)) - return -EBUSY; - - if (val) { - pci_lock_rescan_remove(); - qcom_pcie_rescan(); - pci_unlock_rescan_remove(); - } - return count; -} -static BUS_ATTR(rcrescan, (S_IWUSR|S_IWGRP), NULL, qcom_bus_rescan_store); - -static ssize_t qcom_bus_remove_store(struct bus_type *bus, const char *buf, - size_t count) -{ - unsigned long val; - - if (kstrtoul(buf, 0, &val) < 0) - return -EINVAL; - - if (val) { - pci_lock_rescan_remove(); - qcom_pcie_remove_bus(); - pci_unlock_rescan_remove(); - } - return count; -} -static BUS_ATTR(rcremove, (S_IWUSR|S_IWGRP), NULL, qcom_bus_remove_store); - -static ssize_t qcom_slot_rescan_store(struct bus_type *bus, const char *buf, - size_t count) -{ - unsigned long val; - - if (kstrtoul(buf, 0, &val) < 0) - return -EINVAL; - - qcom_slot_rescan(val); - - return count; -} -static BUS_ATTR(slot_rescan, (S_IWUSR|S_IWGRP), NULL, qcom_slot_rescan_store); - -static ssize_t qcom_slot_remove_store(struct bus_type *bus, const char *buf, - size_t count) -{ - unsigned long val; - - if (kstrtoul(buf, 0, &val) < 0) - return -EINVAL; - - qcom_slot_remove(val); - - return count; -} -static BUS_ATTR(slot_remove, (S_IWUSR|S_IWGRP), NULL, qcom_slot_remove_store); - -int qcom_pcie_register_event(struct qcom_pcie_register_event *reg) -{ - int ret = 0; - struct pci_dev *pci_dev; - struct pcie_port *pp; - struct qcom_pcie *qcom_pcie; - - if (!reg) { - pr_err("PCIe: Event registration is NULL\n"); - return -ENODEV; - } - - if (!reg->user) { - pr_err("PCIe: User of event registration is NULL\n"); - return -ENODEV; - } - pci_dev = (struct pci_dev *)reg->user; - pp = pci_dev->bus->sysdata; - qcom_pcie = to_qcom_pcie(pp); - - if (qcom_pcie) { - qcom_pcie->event_reg = reg; - pr_info("Event 0x%x is registered for RC %d\n", reg->events, - qcom_pcie->rc_idx); - } else { - pr_err("PCIe: did not find RC for pci endpoint device %p\n", - reg->user); - ret = -ENODEV; - } - - return ret; -} -EXPORT_SYMBOL(qcom_pcie_register_event); - -int qcom_pcie_deregister_event(struct qcom_pcie_register_event *reg) -{ - int ret = 0; - struct pci_dev *pci_dev; - struct pcie_port *pp; - struct qcom_pcie *qcom_pcie; - - if (!reg) { - pr_err("PCIe: Event deregistration is NULL\n"); - return -ENODEV; - } - - if (!reg->user) { - pr_err("PCIe: User of event deregistration is NULL\n"); - return -ENODEV; - } - pci_dev = (struct pci_dev *)reg->user; - pp = pci_dev->bus->sysdata; - qcom_pcie = to_qcom_pcie(pp); - - if (qcom_pcie) { - qcom_pcie->event_reg = NULL; - pr_info("Event is deregistered for RC %d\n", - qcom_pcie->rc_idx); - } else { - pr_err("PCIe: did not find RC for pci endpoint device %p\n", - reg->user); - ret = -ENODEV; - } - - return ret; -} -EXPORT_SYMBOL(qcom_pcie_deregister_event); - -static int pci_reboot_handler(struct notifier_block *this, - unsigned long event, void *ptr) -{ - pci_lock_rescan_remove(); - qcom_pcie_remove_bus(); - pci_unlock_rescan_remove(); - - return 0; -} - -static int qcom_pcie_probe(struct platform_device *pdev) -{ - struct device *dev = &pdev->dev; - struct resource *res; - struct qcom_pcie *pcie; - struct pcie_port *pp; - int ret; - uint32_t force_gen1 = 0; - uint32_t force_gen2 = 0; - struct device_node *np = pdev->dev.of_node; - u32 is_emulation = 0; - u32 use_delay = 0; - u32 link_retries_count = 0; - u32 slot_id = -1; - u32 compliance = 0; - static int rc_idx; - int i; - char irq_name[20]; - u32 soc_version_major; - int index = 0; - - pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL); - if (!pcie) - return -ENOMEM; - - pcie->ops = (struct qcom_pcie_ops *)of_device_get_match_data(dev); - pcie->dev = dev; - - of_property_read_u32(np, "compliance", &compliance); - pcie->compliance = compliance; - - of_property_read_u32(np, "is_emulation", &is_emulation); - pcie->is_emulation = is_emulation; - - of_property_read_u32(np, "use_delay", &use_delay); - pcie->use_delay = use_delay; - - of_property_read_u32(np, "link_retries_count", &link_retries_count); - pcie->link_retries_count = link_retries_count; - - of_property_read_u32(np, "slot_id", &slot_id); - pcie->slot_id = slot_id; - - of_property_read_u32(np, "pcie-cap-active-state-link-pm", - &pcie->cap_active_state_link_pm); - - pcie->reset = devm_gpiod_get_optional(dev, "perst", GPIOD_OUT_HIGH); - if (IS_ERR(pcie->reset)) - return PTR_ERR(pcie->reset); - - of_property_read_u32(np, "force_gen1", &force_gen1); - pcie->force_gen1 = force_gen1; - - of_property_read_u32(np, "force_gen2", &force_gen2); - pcie->force_gen2 = force_gen2; - - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dbi"); - pcie->dbi = devm_ioremap_resource(dev, res); - if (IS_ERR(pcie->dbi)) - return PTR_ERR(pcie->dbi); - - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "elbi"); - pcie->elbi = devm_ioremap_resource(dev, res); - if (IS_ERR(pcie->elbi)) - return PTR_ERR(pcie->elbi); - - pcie->is_gen3 = 0; - if (of_device_is_compatible(pdev->dev.of_node, "qcom,pcie-ipq807x")) { - soc_version_major = read_ipq_soc_version_major(); - BUG_ON(soc_version_major <= 0); - index = of_property_match_string(dev->of_node, "phy-names", - "pciephy"); - if (index < 0) { - if (soc_version_major == 1) { - pcie->phy = devm_phy_optional_get(dev, "pciephy-gen2"); - if (IS_ERR(pcie->phy)) - return PTR_ERR(pcie->phy); - pcie->is_gen3 = 0; - } else if (soc_version_major == 2) { - pcie->phy = devm_phy_optional_get(dev, "pciephy-gen3"); - if (IS_ERR(pcie->phy)) - return PTR_ERR(pcie->phy); - pcie->is_gen3 = 1; - } else { - dev_err(dev, "missing phy-names\n"); - return index; - } - } else { - pcie->phy = devm_phy_optional_get(dev, "pciephy"); - if (IS_ERR(pcie->phy)) - return PTR_ERR(pcie->phy); - pcie->is_gen3 = 0; - } - } else if (of_device_is_compatible(pdev->dev.of_node, "qcom,pcie-ipq6018")) { - if (!pcie->is_emulation) { - pcie->phy = devm_phy_optional_get(dev, "pciephy"); - if (IS_ERR(pcie->phy)) - return PTR_ERR(pcie->phy); - } - pcie->is_gen3 = 1; - } else if (of_device_is_compatible(pdev->dev.of_node, - "qcom,pcie-ipq5018")) { - if (!pcie->is_emulation) { - pcie->phy = devm_phy_optional_get(dev, "pciephy"); - if (IS_ERR(pcie->phy)) - return PTR_ERR(pcie->phy); - } - pcie->is_gen3 = 1; - } - - if (pcie->is_gen3) { - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dm_iatu"); - pcie->dm_iatu = devm_ioremap_resource(dev, res); - if (IS_ERR(pcie->dm_iatu)) - return PTR_ERR(pcie->dm_iatu); - - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "parf"); - if (res) - res->end += PCIE_V2_PARF_SIZE; - pcie->parf = devm_ioremap_resource(dev, res); - if (IS_ERR(pcie->parf)) - return PTR_ERR(pcie->parf); - } else { - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "parf"); - pcie->parf = devm_ioremap_resource(dev, res); - if (IS_ERR(pcie->parf)) - return PTR_ERR(pcie->parf); - } - - ret = pcie->ops->get_resources(pcie); - if (ret) - return ret; - - pp = &pcie->pp; - pp->dev = dev; - pp->dbi_base = pcie->dbi; - pp->dm_iatu = pcie->dm_iatu; - pp->is_gen3 = pcie->is_gen3; - pp->use_delay = pcie->use_delay; - pp->link_retries_count = pcie->link_retries_count; - pp->root_bus_nr = -1; - pp->ops = &qcom_pcie_dw_ops; - - pcie->mdm2ap_e911_irq = platform_get_irq_byname(pdev, - "mdm2ap_e911"); - if (pcie->mdm2ap_e911_irq >= 0) { - mdm2ap_e911 = devm_gpiod_get_optional(&pdev->dev, "e911", - GPIOD_IN); - - if (IS_ERR(mdm2ap_e911)) { - pr_err("requesting for e911 gpio failed %ld\n", - PTR_ERR(mdm2ap_e911)); - return PTR_ERR(mdm2ap_e911); - } - - INIT_WORK(&pcie->handle_e911_work, handle_e911_func); - - ret = devm_request_irq(&pdev->dev, pcie->mdm2ap_e911_irq, - handle_mdm2ap_e911_irq, - IRQ_TYPE_EDGE_BOTH, "mdm2ap_e911", - pcie); - - if (ret) { - dev_err(&pdev->dev, "Unable to request mdm2ap_e911 irq\n"); - return ret; - } - - pcie->pci_reboot_notifier.notifier_call = pci_reboot_handler; - ret = register_reboot_notifier(&pcie->pci_reboot_notifier); - if (ret) { - pr_warn("%s: Failed to register notifier (%d)\n", - __func__, ret); - return ret; - } - } - - pcie->link_down_irq = platform_get_irq_byname(pdev, - "int_link_down"); - if (pcie->link_down_irq >= 0) { - ret = devm_request_irq(&pdev->dev, pcie->link_down_irq, - handle_link_down_irq, - IRQF_TRIGGER_RISING, "pci_link_down", - pcie); - } - - pcie->link_up_irq = platform_get_irq_byname(pdev, "int_link_up"); - if (pcie->link_up_irq >= 0) { - ret = devm_request_irq(&pdev->dev, pcie->link_up_irq, - handle_link_up_irq, - IRQF_TRIGGER_RISING, "pci_link_up", - pcie); - } - - pcie->global_irq = platform_get_irq_byname(pdev, "global"); - if (pcie->global_irq >= 0) { - ret = devm_request_irq(&pdev->dev, pcie->global_irq, - qcom_pcie_global_irq_handler, - IRQF_TRIGGER_RISING, "qcom-pcie-global", pcie); - if (ret) { - dev_err(&pdev->dev, "cannot request global irq\n"); - return ret; - } - } - - pp->msi_gicm_addr = 0; - pp->msi_gicm_base = 0; - of_property_read_u32(np, "qcom,msi-gicm-addr", &pp->msi_gicm_addr); - of_property_read_u32(np, "qcom,msi-gicm-base", &pp->msi_gicm_base); - - if (IS_ENABLED(CONFIG_PCI_MSI)) { - pp->msi_irq = platform_get_irq_byname(pdev, "msi"); - if (pp->msi_irq < 0) - return pp->msi_irq; - - ret = devm_request_irq(dev, pp->msi_irq, - qcom_pcie_msi_irq_handler, - IRQF_SHARED, "qcom-pcie-msi", pp); - if (ret) { - dev_err(dev, "cannot request msi irq\n"); - return ret; - } - for (i = 0; i < MAX_MSI_IRQS; i++) { - snprintf(irq_name, sizeof(irq_name), "msi_%d", i); - pp->msi[i] = platform_get_irq_byname(pdev, irq_name); - if (pp->msi[i] < 0) - break; - } - } - - ret = phy_init(pcie->phy); - if (ret) - return ret; - - pcie->wake_irq = platform_get_irq_byname(pdev, "wake_gpio"); - - ret = dw_pcie_host_init(pp); - - if (ret) { - if (pcie->wake_irq < 0) { - dev_err(dev, "cannot initialize host\n"); - return ret; - } - pr_info("PCIe: RC%d is not enabled during bootup;it will be enumerated upon client request\n", - rc_idx); - } else { - pcie->enumerated = true; - pr_info("PCIe: RC%d enabled during bootup\n", rc_idx); - } - - if (pcie->wake_irq >= 0) { - INIT_WORK(&pcie->handle_wake_work, handle_wake_func); - - ret = devm_request_irq(&pdev->dev, pcie->wake_irq, - qcom_pcie_wake_irq_handler, - IRQF_TRIGGER_FALLING, "qcom-pcie-wake", pcie); - if (ret) { - dev_err(&pdev->dev, "Unable to request wake irq\n"); - return ret; - } - } - - /* - ####ipq-4019, add pcie_wake control - static irqreturn_t quectel_pcie_wake_irq(int irq, void *data) - { - return IRQ_WAKE_THREAD; - } - - static irqreturn_t quectel_pcie_wake_thread_irq(int irq, void *data) - { - struct qcom_pcie *pcie = data; - int val = gpiod_get_value(pcie->quectel_pwake); - struct dw_pcie *pci = ep->pci; - - pr_info("pwake val: %d\n", val); - if (val){ - //up: rescan - pci_lock_rescan_remove(); - qcom_pcie_rescan(); - pci_unlock_rescan_remove(); - }else{ - //down: remove - pci_lock_rescan_remove(); - qcom_pcie_remove_bus(); - pci_unlock_rescan_remove(); - } - return IRQ_HANDLED; - } - - pcie->quectel_pwake = devm_gpiod_get_index(dev, "pcie-wake", 0, GPIOD_IN); - if (IS_ERR(pcie->quectel_pwake)) { - dev_err(&pdev->dev, "Please set pcie-wake gpio in DTS\n"); - return PTR_ERR(pcie->quectel_pwake); - } - - pcie->quectel_pwake_irq = gpiod_to_irq(pcie->quectel_pwake); - - ret = devm_request_threaded_irq(&pdev->dev, pcie->quectel_pwake_irq, - quectel_pcie_wake_irq, - quectel_pcie_wake_thread_irq, - IRQF_TRIGGER_RISING | - IRQF_TRIGGER_FALLING | IRQF_NO_SUSPEND, - "quectel-pcie-wake", pcie); - - enable_irq_wake(pcie->quectel_pcie_wake); - */ - - platform_set_drvdata(pdev, pcie); - - if (!rc_idx) { - ret = bus_create_file(&pci_bus_type, &bus_attr_rcrescan); - if (ret != 0) { - dev_err(&pdev->dev, - "Failed to create sysfs rcrescan file\n"); - return ret; - } - - ret = bus_create_file(&pci_bus_type, &bus_attr_rcremove); - if (ret != 0) { - dev_err(&pdev->dev, - "Failed to create sysfs rcremove file\n"); - return ret; - } - } - - /* create sysfs files to support slot rescan and remove*/ - if (!rc_idx) { - ret = bus_create_file(&pci_bus_type, &bus_attr_slot_rescan); - if (ret != 0) { - dev_err(&pdev->dev, - "Failed to create sysfs rcrescan file\n"); - return ret; - } - - ret = bus_create_file(&pci_bus_type, &bus_attr_slot_remove); - if (ret != 0) { - dev_err(&pdev->dev, - "Failed to create sysfs rcremove file\n"); - return ret; - } - } - - pcie->rc_idx = rc_idx; - qcom_pcie_dev[rc_idx++] = pcie; - - return 0; -} - -static int qcom_pcie_remove(struct platform_device *pdev) -{ - struct qcom_pcie *pcie = platform_get_drvdata(pdev); - - if (!pcie->is_emulation) - qcom_ep_reset_assert(pcie); - - phy_power_off(pcie->phy); - phy_exit(pcie->phy); - pcie->ops->deinit(pcie); - - return 0; -} - -static void qcom_pcie_fixup_final(struct pci_dev *dev) -{ - int cap, err; - u16 ctl, reg_val; - - cap = pci_pcie_cap(dev); - if (!cap) - return; - - err = pci_read_config_word(dev, cap + PCI_EXP_DEVCTL, &ctl); - - if (err) - return; - - reg_val = ctl; - - if (((reg_val & PCIE20_MRRS_MASK) >> 12) > 1) - reg_val = (reg_val & ~(PCIE20_MRRS_MASK)) | PCIE20_MRRS(0x1); - - if (((ctl & PCIE20_MPS_MASK) >> 5) > 1) - reg_val = (reg_val & ~(PCIE20_MPS_MASK)) | PCIE20_MPS(0x1); - - err = pci_write_config_word(dev, cap + PCI_EXP_DEVCTL, reg_val); - - if (err) - pr_err("pcie config write failed %d\n", err); -} -DECLARE_PCI_FIXUP_FINAL(PCI_ANY_ID, PCI_ANY_ID, qcom_pcie_fixup_final); - -static const struct of_device_id qcom_pcie_match[] = { - { .compatible = "qcom,pcie-ipq8064", .data = &ops_v0 }, - { .compatible = "qcom,pcie-apq8064", .data = &ops_v0 }, - { .compatible = "qcom,pcie-apq8084", .data = &ops_v1 }, - { .compatible = "qcom,pcie-ipq4019", .data = &ops_v2 }, - { .compatible = "qcom,pcie-ipq807x", .data = &ops_v3 }, - { .compatible = "qcom,pcie-ipq6018", .data = &ops_v3 }, - { .compatible = "qcom,pcie-ipq5018", .data = &ops_v3 }, - { } -}; -MODULE_DEVICE_TABLE(of, qcom_pcie_match); - -static struct platform_driver qcom_pcie_driver = { - .probe = qcom_pcie_probe, - .remove = qcom_pcie_remove, - .driver = { - .name = "qcom-pcie", - .of_match_table = qcom_pcie_match, - }, -}; - -module_platform_driver(qcom_pcie_driver); - -MODULE_AUTHOR("Stanimir Varbanov "); -MODULE_DESCRIPTION("Qualcomm PCIe root complex driver"); -MODULE_LICENSE("GPL v2"); diff --git a/quectel_SRPD_PCIE/src/sipa/Kconfig b/quectel_SRPD_PCIE/src/sipa/Kconfig deleted file mode 100644 index f648033..0000000 --- a/quectel_SRPD_PCIE/src/sipa/Kconfig +++ /dev/null @@ -1,9 +0,0 @@ -menu "SIPA modules" - -config SPRD_SIPA - bool "sipa ipa" - default n - help - sipa is a module for spreadtrum ip packet accelator driver. - -endmenu diff --git a/quectel_SRPD_PCIE/src/sipa/Makefile b/quectel_SRPD_PCIE/src/sipa/Makefile deleted file mode 100644 index 1d5101b..0000000 --- a/quectel_SRPD_PCIE/src/sipa/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -EXTRA_CFLAGS += -Wno-error -Wno-packed-bitfield-compat -ccflags-y += -DCONFIG_SPRD_SIPA -obj-y += sipa_core.o sipa_skb_send.o sipa_skb_recv.o \ - sipa_nic.o sipa_debugfs.o sipa_dele_cmn.o \ - sipa_eth.o sipa_dummy.o -obj-y += sipa_phy_v0/ diff --git a/quectel_SRPD_PCIE/src/sipa/sipa_core.c b/quectel_SRPD_PCIE/src/sipa/sipa_core.c deleted file mode 100644 index bcde7e5..0000000 --- a/quectel_SRPD_PCIE/src/sipa/sipa_core.c +++ /dev/null @@ -1,333 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note. - * - * UNISOC 'virt sipa' driver - * - * Qingsheng.Li - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License v2 as published by - * the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../include/sipa.h" -#include "../include/sprd_pcie_ep_device.h" -#include "../include/sipc.h" -#include "sipa_core.h" - -#define DRV_NAME "virt_sipa" - -struct sipa_core *sipa_ctrl; - -struct sipa_core *sipa_get_ctrl_pointer(void) -{ - return sipa_ctrl; -} -EXPORT_SYMBOL(sipa_get_ctrl_pointer); - -static void sipa_notify_sender_flow_ctrl(struct work_struct *work) -{ - struct sipa_core *sipa_ctrl = container_of(work, struct sipa_core, - flow_ctrl_work); - - if (sipa_ctrl->sender && sipa_ctrl->sender->free_notify_net) - wake_up(&sipa_ctrl->sender->free_waitq); -} - -static int sipa_init_cmn_fifo(struct sipa_core *ipa, - enum sipa_cmn_fifo_index id) -{ - size_t size; - dma_addr_t dma_addr; - struct sipa_cmn_fifo_cfg_tag *cmn_fifo; - - cmn_fifo = &ipa->cmn_fifo_cfg[id]; - cmn_fifo->fifo_id = id; - cmn_fifo->dst = SIPA_TERM_VCP; - cmn_fifo->cur = SIPA_TERM_PCIE0; - size = cmn_fifo->tx_fifo.depth * - sizeof(struct sipa_node_description_tag); - cmn_fifo->tx_fifo.virtual_addr = dma_alloc_coherent(ipa->pci_dev, size, - &dma_addr, - GFP_KERNEL); - if (!cmn_fifo->tx_fifo.virtual_addr) - return -ENOMEM; - cmn_fifo->tx_fifo.dma_ptr = dma_addr; - memset(cmn_fifo->tx_fifo.virtual_addr, 0, size); - pr_info("comfifo%d tx_fifo addr-0x%lx\n", id, (long unsigned int)cmn_fifo->tx_fifo.virtual_addr); - - cmn_fifo->tx_fifo.fifo_base_addr_l = lower_32_bits(dma_addr); - cmn_fifo->tx_fifo.fifo_base_addr_h = 0x2; - - size = cmn_fifo->rx_fifo.depth * - sizeof(struct sipa_node_description_tag); - cmn_fifo->rx_fifo.virtual_addr = dma_alloc_coherent(ipa->pci_dev, size, - &dma_addr, - GFP_KERNEL); - if (!cmn_fifo->rx_fifo.virtual_addr) - return -ENOMEM; - cmn_fifo->rx_fifo.dma_ptr = dma_addr; - memset(cmn_fifo->rx_fifo.virtual_addr, 0, size); - pr_info("comfifo%d rx_fifo addr-0x%lx\n", id, (long unsigned int)cmn_fifo->rx_fifo.virtual_addr); - - cmn_fifo->rx_fifo.fifo_base_addr_l = lower_32_bits(dma_addr); - cmn_fifo->rx_fifo.fifo_base_addr_h = 0x2; - - return 0; -} - -static void sipa_free_cmn_fifo(struct sipa_core *ipa, enum sipa_cmn_fifo_index id) -{ - size_t size; - struct sipa_cmn_fifo_cfg_tag *cmn_fifo; - - cmn_fifo = &ipa->cmn_fifo_cfg[id]; - size = cmn_fifo->tx_fifo.depth * sizeof(struct sipa_node_description_tag); - dma_free_coherent(ipa->dev, size, cmn_fifo->tx_fifo.virtual_addr, cmn_fifo->tx_fifo.dma_ptr); - size = cmn_fifo->rx_fifo.depth * sizeof(struct sipa_node_description_tag); - dma_free_coherent(ipa->dev, size, cmn_fifo->rx_fifo.virtual_addr, cmn_fifo->rx_fifo.dma_ptr); -} - -static void sipa_init_ep(struct sipa_core *ipa) -{ - struct sipa_endpoint *ep = &ipa->ep; - - ep->send_fifo = &ipa->cmn_fifo_cfg[SIPA_FIFO_PCIE_UL]; - ep->recv_fifo = &ipa->cmn_fifo_cfg[SIPA_FIFO_PCIE_DL]; -} - -#ifdef SPRD_PCIE_USE_DTS -static int sipa_parse_dts_configuration(struct platform_device *pdev, - struct sipa_core *ipa) -{ - int ret; - struct sipa_cmn_fifo_cfg_tag *cmn_fifo; - - ipa->reg_res = platform_get_resource_byname(pdev, - IORESOURCE_MEM, "ipa-base"); - if (!ipa->reg_res) { - dev_err(&pdev->dev, "get ipa-base res fail\n"); - return -EINVAL; - } - - cmn_fifo = &ipa->cmn_fifo_cfg[SIPA_FIFO_PCIE_DL]; - ret = of_property_read_u32(pdev->dev.of_node, "pcie-dl-tx-fifo-depth", - &cmn_fifo->tx_fifo.depth); - if (ret) { - dev_err(&pdev->dev, - "get pcie-dl-tx-fifo-depth ret = %d\n", ret); - return ret; - } - - ret = of_property_read_u32(pdev->dev.of_node, "pcie-dl-rx-fifo-depth", - &cmn_fifo->rx_fifo.depth); - if (ret) { - dev_err(&pdev->dev, - "get pcie-dl-rx-fifo-depth ret = %d\n", ret); - return ret; - } - - cmn_fifo = &ipa->cmn_fifo_cfg[SIPA_FIFO_PCIE_UL]; - ret = of_property_read_u32(pdev->dev.of_node, "pcie-ul-tx-fifo-depth", - &cmn_fifo->tx_fifo.depth); - if (ret) { - dev_err(&pdev->dev, - "get pcie-ul-tx-fifo-depth ret = %d\n", ret); - return ret; - } - - ret = of_property_read_u32(pdev->dev.of_node, "pcie-ul-rx-fifo-depth", - &cmn_fifo->rx_fifo.depth); - if (ret) { - dev_err(&pdev->dev, - "get pcie-ul-rx-fifo-depth ret = %d\n", ret); - return ret; - } - - return 0; -} -#else -static struct resource ipa_res = { - .start = 0x2e000000, - .end = 0x2e000000 + 0x2000 -1, - .flags = IORESOURCE_MEM, -}; - -static int sipa_parse_dts_configuration(struct platform_device *pdev, - struct sipa_core *ipa) -{ - struct sipa_cmn_fifo_cfg_tag *cmn_fifo; - ipa->reg_res = &ipa_res; - cmn_fifo = &ipa->cmn_fifo_cfg[SIPA_FIFO_PCIE_DL]; - cmn_fifo->tx_fifo.depth = 4096; - cmn_fifo->rx_fifo.depth = 4096; - cmn_fifo = &ipa->cmn_fifo_cfg[SIPA_FIFO_PCIE_UL]; - cmn_fifo->tx_fifo.depth = 4096; - cmn_fifo->rx_fifo.depth = 4096; - return 0; -} -#endif - -static int sipa_plat_drv_probe(struct platform_device *pdev) -{ - int ret; - struct sipa_core *ipa; - struct device *dev = &pdev->dev; - struct device *pci_dev; - - pci_dev = (struct device *)dev_get_drvdata(dev); - if(!pci_dev) - return -1; - - ipa = devm_kzalloc(dev, sizeof(*ipa), GFP_KERNEL); - if (!ipa) - return -ENOMEM; - - sipa_ctrl = ipa; - ipa->dev = dev; - ipa->pci_dev = pci_dev; - ipa->pcie_mem_offset = SIPA_PCIE_MEM_OFFSET; - dev_set_drvdata(dev, ipa); - ret = sipa_parse_dts_configuration(pdev, ipa); - if (ret) - return ret; - - ret = sipa_init_cmn_fifo(ipa, SIPA_FIFO_PCIE_DL); - if (ret) - return ret; - - ret = sipa_init_cmn_fifo(ipa, SIPA_FIFO_PCIE_UL); - if (ret) - return ret; - - sipa_init_ep(ipa); - - sipa_fifo_ops_init(&ipa->hal_ops); - INIT_WORK(&ipa->flow_ctrl_work, sipa_notify_sender_flow_ctrl); - - create_sipa_skb_receiver(&ipa->ep, &ipa->receiver); - create_sipa_skb_sender(&ipa->ep, &ipa->sender); - device_init_wakeup(dev, true); - - sipa_create_smsg_channel(ipa); - - sprd_ep_dev_register_irq_handler(PCIE_EP_MODEM, PCIE_MSI_IPA, - (irq_handler_t)sipa_int_callback_func, - (void *)ipa); - sipa_init_debugfs(ipa); - - return 0; -} - -extern void destroy_sipa_skb_receiver(struct sipa_skb_receiver *receiver); -extern void destroy_sipa_skb_sender(struct sipa_skb_sender *sender); - -static int sipa_plat_drv_remove(struct platform_device *pdev) -{ - struct sipa_core *ipa; - - ipa = dev_get_drvdata(&pdev->dev); - smsg_ch_close(SIPC_ID_MINIAP, SMSG_CH_COMM_SIPA, 1000); - if(ipa->smsg_thread){ - kthread_stop(ipa->smsg_thread); - ipa->smsg_thread = NULL; - } - destroy_sipa_skb_sender(ipa->sender); - destroy_sipa_skb_receiver(ipa->receiver); - cancel_work_sync(&ipa->flow_ctrl_work); - mdelay(1000); - sipa_free_cmn_fifo(ipa, SIPA_FIFO_PCIE_UL); - sipa_free_cmn_fifo(ipa, SIPA_FIFO_PCIE_DL); - if (!IS_ERR_OR_NULL(ipa->dentry)) - debugfs_remove_recursive(ipa->dentry); - devm_kfree(&pdev->dev, ipa); - platform_set_drvdata(pdev, NULL); - return 0; -} - -#ifdef SPRD_PCIE_USE_DTS -static const struct of_device_id sipa_plat_drv_match[] = { - { .compatible = "sprd,virt-sipa"}, -}; -#endif - -static struct platform_driver sipa_plat_drv = { - .probe = sipa_plat_drv_probe, - .remove = sipa_plat_drv_remove, - .driver = { - .name = DRV_NAME, - .owner = THIS_MODULE, -#ifdef SPRD_PCIE_USE_DTS - .of_match_table = sipa_plat_drv_match, -#endif - }, -}; - -#ifndef SPRD_PCIE_USE_DTS -static struct platform_device *sipa_plat_dev; -static int sipa_core_platform_device_reigster(struct device *dev) -{ - int retval = -ENOMEM; - - sipa_plat_dev = platform_device_alloc("virt_sipa", -1); - if (!sipa_plat_dev) - return retval; - - sipa_plat_dev->dev.dma_mask = dev->dma_mask; - sipa_plat_dev->dev.coherent_dma_mask = dev->coherent_dma_mask; - sipa_plat_dev->dev.archdata = dev->archdata; - dev_set_drvdata(&sipa_plat_dev->dev, dev); - retval = platform_device_add(sipa_plat_dev); - if (retval < 0) - platform_device_put(sipa_plat_dev); - - return retval; -} -#endif - -int sipa_module_init(struct device *dev) -{ -#ifndef SPRD_PCIE_USE_DTS - sipa_core_platform_device_reigster(dev); -#endif - return platform_driver_register(&sipa_plat_drv); -} -EXPORT_SYMBOL(sipa_module_init); - -void sipa_module_exit(void) -{ - platform_driver_unregister(&sipa_plat_drv); -#ifndef SPRD_PCIE_USE_DTS - platform_device_unregister(sipa_plat_dev); - #endif -} -EXPORT_SYMBOL(sipa_module_exit); diff --git a/quectel_SRPD_PCIE/src/sipa/sipa_core.h b/quectel_SRPD_PCIE/src/sipa/sipa_core.h deleted file mode 100644 index f67853b..0000000 --- a/quectel_SRPD_PCIE/src/sipa/sipa_core.h +++ /dev/null @@ -1,519 +0,0 @@ -/* - * SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef _SIPA_CORE_H_ -#define _SIPA_CORE_H_ - -#include -#include -#include -#include -#include -#include -#include - -enum sipa_cmn_fifo_index { - SIPA_FIFO_PCIE_DL, - SIPA_FIFO_PCIE_UL, - SIPA_FIFO_MAX, -}; - -enum sipa_irq_evt_type { - SIPA_IRQ_TX_FIFO_THRESHOLD_SW = BIT(22), - SIPA_IRQ_EXIT_FLOW_CTRL = BIT(20), - SIPA_IRQ_ENTER_FLOW_CTRL = BIT(19), - SIPA_IRQ_TXFIFO_FULL_INT = BIT(18), - SIPA_IRQ_TXFIFO_OVERFLOW = BIT(17), - SIPA_IRQ_ERRORCODE_IN_TX_FIFO = BIT(16), - SIPA_IRQ_INTR_BIT = BIT(15), - SIPA_IRQ_THRESHOLD = BIT(14), - SIPA_IRQ_DELAY_TIMER = BIT(13), - SIPA_IRQ_DROP_PACKT_OCCUR = BIT(12), - - SIPA_IRQ_ERROR = 0x0, -}; - -#define SIPA_FIFO_THRESHOLD_IRQ_EN BIT(1) -#define SIPA_FIFO_DELAY_TIMER_IRQ_EN BIT(0) - -#define SIPA_PCIE_MEM_OFFSET 0x200000000ULL - -enum sipa_nic_status_e { - NIC_OPEN, - NIC_CLOSE -}; - -#define SIPA_RECV_EVT (SIPA_IRQ_INTR_BIT | SIPA_IRQ_THRESHOLD | \ - SIPA_IRQ_DELAY_TIMER | SIPA_IRQ_TX_FIFO_THRESHOLD_SW) - -#define SIPA_RECV_WARN_EVT (SIPA_IRQ_TXFIFO_FULL_INT | SIPA_IRQ_TXFIFO_OVERFLOW) - -#define SMSG_FLG_DELE_REQUEST 0x1 -#define SMSG_FLG_DELE_RELEASE 0x2 - -typedef void (*sipa_irq_notify_cb)(void *priv, - enum sipa_irq_evt_type evt, - u32 data); - -struct sipa_node_description_tag { - /*soft need to set*/ - u64 address : 40; - /*soft need to set*/ - u32 length : 20; - /*soft need to set*/ - u16 offset : 12; - /*soft need to set*/ - u8 net_id; - /*soft need to set*/ - u8 src : 5; - /*soft need to set*/ - u8 dst : 5; - u8 prio : 3; - u8 bear_id : 7; - /*soft need to set*/ - u8 intr : 1; - /*soft need to set*/ - u8 indx : 1; - u8 err_code : 4; - u32 reserved : 22; -} __attribute__((__packed__)); - -struct sipa_cmn_fifo_params { - u32 tx_intr_delay_us; - u32 tx_intr_threshold; - bool flowctrl_in_tx_full; - u32 flow_ctrl_cfg; - u32 flow_ctrl_irq_mode; - u32 tx_enter_flowctrl_watermark; - u32 tx_leave_flowctrl_watermark; - u32 rx_enter_flowctrl_watermark; - u32 rx_leave_flowctrl_watermark; - - u32 data_ptr_cnt; - u32 buf_size; - dma_addr_t data_ptr; -}; - -struct sipa_skb_dma_addr_node { - struct sk_buff *skb; - u64 dma_addr; - struct list_head list; -}; - -struct sipa_cmn_fifo_tag { - u32 depth; - u32 wr; - u32 rd; - - u32 fifo_base_addr_l; - u32 fifo_base_addr_h; - - void *virtual_addr; - dma_addr_t dma_ptr; -}; - -struct sipa_cmn_fifo_cfg_tag { - const char *fifo_name; - - void *priv; - - enum sipa_cmn_fifo_index fifo_id; - - bool state; - u32 dst; - u32 cur; - - void __iomem *fifo_reg_base; - - struct sipa_cmn_fifo_tag rx_fifo; - struct sipa_cmn_fifo_tag tx_fifo; - - u32 enter_flow_ctrl_cnt; - u32 exit_flow_ctrl_cnt; - - sipa_irq_notify_cb irq_cb; -}; - -struct sipa_endpoint { - /* Centered on CPU/PAM */ - struct sipa_cmn_fifo_cfg_tag *send_fifo; - struct sipa_cmn_fifo_cfg_tag *recv_fifo; - - struct sipa_cmn_fifo_params send_fifo_param; - struct sipa_cmn_fifo_params recv_fifo_param; - - bool inited; - bool connected; - bool suspended; -}; - -struct sipa_nic { - enum sipa_nic_id nic_id; - struct sipa_endpoint *send_ep; - struct sk_buff_head rx_skb_q; - int need_notify; - u32 src_mask; - int netid; - struct list_head list; - sipa_notify_cb cb; - void *cb_priv; - atomic_t status; - bool flow_ctrl_status; - bool continue_notify; - bool rm_flow_ctrl; -}; - -struct sipa_skb_array { - struct sipa_skb_dma_addr_node *array; - u32 rp; - u32 wp; - u32 depth; -}; - -struct sipa_skb_sender { - struct device *dev; - - struct sipa_endpoint *ep; - - atomic_t left_cnt; - /* To be used for add/remove nic device */ - spinlock_t nic_lock; - /* To be used for send skb process */ - spinlock_t send_lock; - spinlock_t exit_lock; - struct list_head nic_list; - struct list_head sending_list; - struct list_head pair_free_list; - struct sipa_skb_dma_addr_node *pair_cache; - - bool free_notify_net; - bool ep_cover_net; - bool send_notify_net; - - wait_queue_head_t free_waitq; - - struct task_struct *free_thread; - struct task_struct *send_thread; - - bool init_flag; - u32 no_mem_cnt; - u32 no_free_cnt; - u32 enter_flow_ctrl_cnt; - u32 exit_flow_ctrl_cnt; - u32 run; -}; - -struct sipa_skb_receiver { - struct sipa_endpoint *ep; - u32 rsvd; - struct sipa_skb_array recv_array; - wait_queue_head_t recv_waitq; - wait_queue_head_t fill_recv_waitq; - spinlock_t lock; - spinlock_t exit_lock; - u32 nic_cnt; - atomic_t need_fill_cnt; - struct sipa_nic *nic_array[SIPA_NIC_MAX]; - - struct task_struct *fill_thread; - - u32 tx_danger_cnt; - u32 rx_danger_cnt; - u32 run; -}; - -struct sipa_fifo_hal_ops { - int (*open)(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, void *cookie); - int (*close)(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base); - int (*set_rx_depth)(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, u32 depth); - int (*set_tx_depth)(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, u32 depth); - u32 (*get_rx_depth)(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base); - int (*hal_set_tx_depth)(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - u32 depth); - u32 (*get_tx_depth)(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base); - int (*set_intr_drop_packet)(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - u32 enable, sipa_irq_notify_cb cb); - int (*set_intr_error_code)(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - u32 enable, sipa_irq_notify_cb cb); - int (*set_intr_timeout)(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - u32 enable, u32 time, sipa_irq_notify_cb cb); - int (*set_hw_intr_timeout)(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - u32 enable, u32 time, sipa_irq_notify_cb cb); - int (*set_intr_threshold)(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - u32 enable, u32 cnt, sipa_irq_notify_cb cb); - int (*set_hw_intr_thres)(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - u32 enable, u32 cnt, sipa_irq_notify_cb cb); - int (*set_src_dst_term)(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - u32 src, u32 dst); - int (*enable_local_flowctrl_intr)(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag * - cfg_base, u32 enable, u32 irq_mode, - sipa_irq_notify_cb cb); - int (*enable_remote_flowctrl_intr)(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag * - cfg_base, u32 work_mode, - u32 tx_entry_watermark, - u32 tx_exit_watermark, - u32 rx_entry_watermark, - u32 rx_exit_watermark); - int (*set_interrupt_intr)(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - u32 enable, sipa_irq_notify_cb cb); - int (*set_intr_txfifo_overflow)(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - u32 enable, sipa_irq_notify_cb cb); - int (*set_intr_txfifo_full)(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - u32 enable, sipa_irq_notify_cb cb); - int (*put_node_to_rx_fifo)(struct device *dev, - enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - struct sipa_node_description_tag *node, - u32 force_intr, u32 num); - u32 (*get_left_cnt)(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base); - u32 (*recv_node_from_tx_fifo)(struct device *dev, - enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - u32 num); - void (*get_rx_ptr)(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - u32 *wr, u32 *rd); - void (*get_tx_ptr)(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - u32 *wr, u32 *rd); - void (*get_filled_depth)(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - u32 *rx_filled, u32 *tx_filled); - u32 (*get_tx_full_status)(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base); - u32 (*get_tx_empty_status)(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base); - u32 (*get_rx_full_status)(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base); - u32 (*get_rx_empty_status)(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base); - bool (*set_rx_fifo_wptr)(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - u32 wptr); - bool (*set_tx_fifo_wptr)(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - u32 wptr); - int (*set_rx_tx_fifo_ptr)(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - u32 rx_rd, u32 rx_wr, u32 tx_rd, u32 tx_wr); - int (*ctrl_receive)(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - bool stop); - struct sipa_node_description_tag * - (*get_tx_fifo_rp)(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - u32 index); - struct sipa_node_description_tag * - (*get_rx_fifo_wr)(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - u32 index); - int (*set_tx_fifo_rp)(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - u32 tx_rd); - int (*set_rx_fifo_wr)(struct device *dev, enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - u32 num); - int (*set_intr_eb)(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - bool eb, u32 type); - void (*clr_tout_th_intr)(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base); -}; - -struct sipa_core { - const char *name; - - struct device *dev; - struct device *pci_dev; - struct dentry *dentry; - struct sipa_endpoint ep; - - struct sipa_cmn_fifo_cfg_tag cmn_fifo_cfg[SIPA_FIFO_MAX]; - - struct work_struct flow_ctrl_work; - - /* ipa low power*/ - bool remote_ready; - - struct resource *reg_res; - phys_addr_t reg_mapped; - void __iomem *virt_reg_addr; - /* IPA NIC interface */ - struct sipa_nic *nic[SIPA_NIC_MAX]; - - /* sender & receiver */ - struct sipa_skb_sender *sender; - struct sipa_skb_receiver *receiver; - - atomic_t recv_cnt; - u64 pcie_mem_offset; - - struct sipa_fifo_hal_ops hal_ops; - - struct task_struct *smsg_thread; - - struct dentry *debugfs_root; - const void *debugfs_data; -}; - -void sipa_fifo_ops_init(struct sipa_fifo_hal_ops *ops); -struct sipa_core *sipa_get_ctrl_pointer(void); - -void sipa_receiver_add_nic(struct sipa_skb_receiver *receiver, - struct sipa_nic *nic); -void sipa_receiver_open_cmn_fifo(struct sipa_skb_receiver *receiver); - -void sipa_sender_open_cmn_fifo(struct sipa_skb_sender *sender); -int create_sipa_skb_sender(struct sipa_endpoint *ep, - struct sipa_skb_sender **sender_pp); -void destroy_sipa_skb_sender(struct sipa_skb_sender *sender); -void sipa_skb_sender_add_nic(struct sipa_skb_sender *sender, - struct sipa_nic *nic); -void sipa_skb_sender_remove_nic(struct sipa_skb_sender *sender, - struct sipa_nic *nic); -int sipa_skb_sender_send_data(struct sipa_skb_sender *sender, - struct sk_buff *skb, - enum sipa_term_type dst, - u8 netid); -int create_sipa_skb_receiver(struct sipa_endpoint *ep, - struct sipa_skb_receiver **receiver_pp); - -void sipa_nic_notify_evt(struct sipa_nic *nic, enum sipa_evt_type evt); -void sipa_nic_try_notify_recv(struct sipa_nic *nic); -void sipa_nic_push_skb(struct sipa_nic *nic, struct sk_buff *skb); -void sipa_nic_check_flow_ctrl(void); - -int sipa_create_smsg_channel(struct sipa_core *ipa); - -int sipa_init_debugfs(struct sipa_core *ipa); - -int sipa_int_callback_func(int evt, void *cookie); - -#if defined (__BIG_ENDIAN_BITFIELD) -static inline int sipa_get_node_desc(u8 *node_addr, - struct sipa_node_description_tag *node) -{ - if (!node_addr || !node) - return -EINVAL; - - node->address = node_addr[0] + ((u32)node_addr[1] << 8) + - ((u32)node_addr[2] << 16) + ((u32)node_addr[3] << 24) + - ((u64)node_addr[4] << 32); -#if 0 - node->length = node_addr[5] + ((u32)node_addr[6] << 8) + - ((u32)(node_addr[7] & 0xf) << 16); - node->offset = ((node_addr[7] & 0xf0) >> 4) + - ((u16)node_addr[8] << 4); -#endif - node->net_id = node_addr[9]; - node->src = node_addr[10] & 0x1f; -#if 0 - node->dst = ((node_addr[11] & 0x3) << 3) + - ((node_addr[10] & 0xe0) >> 5); -#endif - node->err_code = ((node_addr[12] & 0xc0) >> 6) + - ((node_addr[13] & 0x03) << 2); -#if 0 - node->prio = (node_addr[11] & 0x1c) >> 2; - node->bear_id = ((node_addr[11] & 0xe0) >> 5) + - ((node_addr[12] & 0xf) << 3); - node->intr = !!(node_addr[12] & BIT(4)); - node->indx = !!(node_addr[12] & BIT(5)); - node->reserved = ((node_addr[13] & 0xfc) >> 2) + - ((u32)node_addr[14] << 6) + ((u32)node_addr[15] << 14); -#endif - smp_rmb(); - - return 0; -} - -static inline int sipa_set_node_desc(u8 *dst_addr, u8 *src_addr) -{ - if (!dst_addr || !src_addr) - return -EINVAL; - - /* address */ - dst_addr[0] = src_addr[4]; - dst_addr[1] = src_addr[3]; - dst_addr[2] = src_addr[2]; - dst_addr[3] = src_addr[1]; - dst_addr[4] = src_addr[0]; - - /* length */ - dst_addr[5] = (src_addr[7] >> 4) + ((src_addr[6] & 0x0f) << 4); - dst_addr[6] = (src_addr[6] >> 4) + ((src_addr[5] & 0x0f) << 4); - dst_addr[7] = src_addr[5] >> 4; - - /* offset */ - dst_addr[7] += ((src_addr[8] & 0x0f) << 4); - dst_addr[8] = (src_addr[7] << 4) + (src_addr[8] >> 4); - - /* netid */ - dst_addr[9] = src_addr[9]; - - /* src */ - dst_addr[10] = ((src_addr[10] & 0xf8) >> 3); - - /* dst */ - dst_addr[10] += - ((src_addr[11] >> 6) + ((src_addr[10] & 0x01) << 2)) << 5; - dst_addr[11] = (src_addr[10] & 0x6) >> 1; - - /* prio */ - dst_addr[11] += ((src_addr[11] & 0x38) >> 1); - - /* bear_id */ - dst_addr[11] += ((src_addr[12] & 0x70) << 1); - dst_addr[12] = ((src_addr[11] & 0x7) << 1) + (src_addr[12] >> 7); - - /* intx */ - dst_addr[12] += ((src_addr[12] & 0x8) << 1); - - /* indx */ - dst_addr[12] += ((src_addr[12] & 0x4) << 3); - - /* err code */ - dst_addr[12] += (src_addr[13] & 0xc0); - dst_addr[13] = src_addr[12] & 0x3; - - /* reserved */ - dst_addr[13] += src_addr[15] << 2; - dst_addr[14] = (src_addr[15] & 0x3) + (src_addr[14] << 2); - dst_addr[15] = ((src_addr[13] & 0x3f) << 2) + - ((src_addr[14] & 0xc0) >> 6); - smp_wmb(); - - return 0; -} -#endif -#endif diff --git a/quectel_SRPD_PCIE/src/sipa/sipa_debugfs.c b/quectel_SRPD_PCIE/src/sipa/sipa_debugfs.c deleted file mode 100644 index 13dba60..0000000 --- a/quectel_SRPD_PCIE/src/sipa/sipa_debugfs.c +++ /dev/null @@ -1,590 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../include/sipa.h" -#include "sipa_core.h" - -static u32 debug_cmd[5], data_buf[5]; -static struct sipa_node_description_tag ipa_node; - -static int sipa_params_debug_show(struct seq_file *s, void *unused) -{ - int i; - u32 tmp; - struct sipa_core *ipa = (struct sipa_core *)s->private; - struct sipa_cmn_fifo_cfg_tag *fifo_cfg; - - seq_printf(s, "dma_mask = 0x%llx coherent_dma_mask = 0x%llx\n", - (u64)*ipa->pci_dev->dma_mask, (u64)ipa->pci_dev->coherent_dma_mask); - seq_printf(s, "remote ready = %d reg_mapped = 0x%llx virt_reg_addr = 0x%p\n", - ipa->remote_ready, (long long unsigned int)ipa->reg_mapped, ipa->virt_reg_addr); - seq_printf(s, "ipa reg start = 0x%llx size = 0x%llx pcie_mem_offset = %llx\n", - (long long unsigned int)ipa->reg_res->start, (long long unsigned int)resource_size(ipa->reg_res), - (long long unsigned int)ipa->pcie_mem_offset); - for (i = 0; i < SIPA_NIC_MAX; i++) { - if (!ipa->nic[i]) - continue; - - seq_printf(s, "open = %d src_mask = 0x%x netid = %d flow_ctrl_status = %d", - atomic_read(&ipa->nic[i]->status), ipa->nic[i]->src_mask, - ipa->nic[i]->netid, ipa->nic[i]->flow_ctrl_status); - seq_printf(s, " qlen = %d need_notify = %d continue_notify = %d\n", - ipa->nic[i]->rx_skb_q.qlen, ipa->nic[i]->need_notify, - ipa->nic[i]->continue_notify); - } - - seq_printf(s, "sender no_mem_cnt = %d no_free_cnt = %d left_cnt = %d\n", - ipa->sender->no_mem_cnt, ipa->sender->no_free_cnt, - atomic_read(&ipa->sender->left_cnt)); - seq_printf(s, "sender enter_flow_ctrl_cnt=%d, exit_flow_ctrl_cnt=%d, free_notify_net=%d, ep_cover_net=%d\n", - ipa->sender->enter_flow_ctrl_cnt, ipa->sender->exit_flow_ctrl_cnt, - ipa->sender->free_notify_net, ipa->sender->ep_cover_net); - seq_printf(s, "receiver need_fill_cnt = %d", - atomic_read(&ipa->receiver->need_fill_cnt)); - seq_printf(s, " tx_danger_cnt = %d rx_danger_cnt = %d\n", - ipa->receiver->tx_danger_cnt, ipa->receiver->rx_danger_cnt); - - fifo_cfg = &ipa->cmn_fifo_cfg[SIPA_FIFO_PCIE_DL]; - seq_printf(s, "[PCIE_DL]state = %d fifo_reg_base = %p\n", - fifo_cfg->state, fifo_cfg->fifo_reg_base); - seq_printf(s, "[PCIE_DL]rx fifo depth = 0x%x wr = 0x%x rd = 0x%x\n", - fifo_cfg->rx_fifo.depth, - fifo_cfg->rx_fifo.wr, - fifo_cfg->rx_fifo.rd); - seq_printf(s, "[PCIE_DL]rx_fifo fifo_addrl = 0x%x fifo_addrh = 0x%x\n", - fifo_cfg->rx_fifo.fifo_base_addr_l, - fifo_cfg->rx_fifo.fifo_base_addr_h); - seq_printf(s, "[PCIE_DL]rx fifo virt addr = %p\n", - fifo_cfg->rx_fifo.virtual_addr); - seq_printf(s, "[PCIE_DL]tx fifo depth = 0x%x wr = 0x%x rd = 0x%x\n", - fifo_cfg->tx_fifo.depth, fifo_cfg->tx_fifo.wr, - fifo_cfg->tx_fifo.rd); - seq_printf(s, "[PCIE_DL]tx_fifo fifo_addrl = 0x%x fifo_addrh = 0x%x\n", - fifo_cfg->tx_fifo.fifo_base_addr_l, - fifo_cfg->tx_fifo.fifo_base_addr_h); - seq_printf(s, "[PCIE_DL]tx fifo virt addr = %p\n", - fifo_cfg->tx_fifo.virtual_addr); - fifo_cfg = &ipa->cmn_fifo_cfg[SIPA_FIFO_PCIE_UL]; - seq_printf(s, "[PCIE_UL]state = %d fifo_reg_base = %p\n", - fifo_cfg->state, fifo_cfg->fifo_reg_base); - seq_printf(s, "[PCIE_UL]rx fifo depth = 0x%x wr = 0x%x rd = 0x%x\n", - fifo_cfg->rx_fifo.depth, - fifo_cfg->rx_fifo.wr, - fifo_cfg->rx_fifo.rd); - seq_printf(s, "[PCIE_UL]rx_fifo fifo_addrl = 0x%x fifo_addrh = 0x%x\n", - fifo_cfg->rx_fifo.fifo_base_addr_l, - fifo_cfg->rx_fifo.fifo_base_addr_h); - seq_printf(s, "[PCIE_UL]rx fifo virt addr = %p\n", - fifo_cfg->rx_fifo.virtual_addr); - seq_printf(s, "[PCIE_UL]tx fifo depth = 0x%x wr = 0x%x rd = 0x%x\n", - fifo_cfg->tx_fifo.depth, fifo_cfg->tx_fifo.wr, - fifo_cfg->tx_fifo.rd); - seq_printf(s, "[PCIE_UL]tx_fifo fifo_addrl = 0x%x fifo_addrh = 0x%x\n", - fifo_cfg->tx_fifo.fifo_base_addr_l, - fifo_cfg->tx_fifo.fifo_base_addr_h); - seq_printf(s, "[PCIE_UL]tx fifo virt addr = %p\n", - fifo_cfg->tx_fifo.virtual_addr); - - //ep: IPA_COMMON_TX_FIFO_DEPTH 0x0Cl - tmp = readl_relaxed(ipa->virt_reg_addr + 0xc00 + 0x0C); - seq_printf(s, "neil: read IPA_COMMON_TX_FIFO_DEPTH, value = %x\n", (tmp >> 16)); - - //ep: IPA_COMMON_TX_FIFO_WR 0x10l - tmp = readl_relaxed(ipa->virt_reg_addr + 0xc00 + 0x10); - seq_printf(s, "neil: read IPA_COMMON_TX_FIFO_WR, value = %x\n", (tmp >> 16)); - - //ep: IPA_COMMON_TX_FIFO_RD 0x14l - tmp = readl_relaxed(ipa->virt_reg_addr + 0xc00 + 0x14); - seq_printf(s, "neil: read IPA_COMMON_TX_FIFO_RD, value = %x\n", (tmp >> 16)); - return 0; -} - -static int sipa_params_debug_open(struct inode *inode, - struct file *file) -{ - return single_open(file, sipa_params_debug_show, - inode->i_private); -} - -static ssize_t sipa_endian_debug_write(struct file *f, const char __user *buf, - size_t size, loff_t *l) -{ - ssize_t len; - u32 debug_cmd[24], data_buf[24]; - - len = min(size, sizeof(data_buf) - 1); - if (copy_from_user((char *)data_buf, buf, len)) - return -EFAULT; - - len = sscanf((char *)data_buf, "%x %x %x %x %x %x %x %x %x %x %x %x\n", - &debug_cmd[0], &debug_cmd[1], &debug_cmd[2], - &debug_cmd[3], &debug_cmd[4], &debug_cmd[5], - &debug_cmd[6], &debug_cmd[7], &debug_cmd[8], - &debug_cmd[9], &debug_cmd[10], &debug_cmd[11]); - - ipa_node.address = debug_cmd[0]; - ipa_node.length = debug_cmd[1]; - ipa_node.offset = debug_cmd[2]; - ipa_node.net_id = debug_cmd[3]; - ipa_node.src = debug_cmd[4]; - ipa_node.dst = debug_cmd[5]; - ipa_node.prio = debug_cmd[6]; - ipa_node.bear_id = debug_cmd[7]; - ipa_node.intr = debug_cmd[8]; - ipa_node.indx = debug_cmd[9]; - ipa_node.err_code = debug_cmd[10]; - ipa_node.reserved = debug_cmd[11]; - - return size; -} - -static int sipa_endian_debug_show(struct seq_file *s, void *unused) -{ - int i; - u8 *byte; - - seq_printf(s, "address = 0x%llx length = 0x%x offset = 0x%x net_id = 0x%x\n", - (u64)ipa_node.address, ipa_node.length, ipa_node.offset, - ipa_node.net_id); - seq_printf(s, "src = 0x%x dst = 0x%x prio = 0x%x bear_id = 0x%x\n", - ipa_node.src, ipa_node.dst, ipa_node.prio, ipa_node.bear_id); - seq_printf(s, "intr = 0x%x indx = 0x%x err_code = 0x%x reserved = 0x%x\n", - ipa_node.intr, ipa_node.indx, - ipa_node.err_code, ipa_node.reserved); - - byte = (u8 *)&ipa_node; - for (i = 0; i < sizeof(ipa_node); i++) - seq_printf(s, "0x%x ", *(byte + i)); - - seq_puts(s, "\n"); - - return 0; -} - -static const struct file_operations sipa_params_fops = { - .open = sipa_params_debug_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static int sipa_endian_debug_open(struct inode *inode, - struct file *file) -{ - return single_open(file, sipa_endian_debug_show, - inode->i_private); -} - -static const struct file_operations sipa_endian_fops = { - .open = sipa_endian_debug_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, - .write = sipa_endian_debug_write, -}; - -static ssize_t sipa_get_node_debug_write(struct file *f, const char __user *buf, - size_t size, loff_t *l) -{ - int i; - ssize_t len; - u8 debug_cmd[16], data_buf[128]; - - len = min(size, sizeof(data_buf) - 1); - if (copy_from_user((char *)data_buf, buf, len)) - return -EFAULT; - - len = sscanf((char *)data_buf, "%4hhx %4hhx %4hhx %4hhx %4hhx %4hhx %4hhx %4hhx %4hhx %4hhx %4hhx %4hhx %4hhx %4hhx %4hhx %4hhx\n", - &debug_cmd[0], &debug_cmd[1], &debug_cmd[2], - &debug_cmd[3], &debug_cmd[4], &debug_cmd[5], - &debug_cmd[6], &debug_cmd[7], &debug_cmd[8], - &debug_cmd[9], &debug_cmd[10], &debug_cmd[11], - &debug_cmd[12], &debug_cmd[13], &debug_cmd[14], - &debug_cmd[15]); - - for (i = 0; i < 16; i++) - pr_err("0x%x ", debug_cmd[i]); - pr_err("\n"); - -#if defined (__BIG_ENDIAN_BITFIELD) - sipa_get_node_desc(debug_cmd, &ipa_node); -#else - ipa_node.address = debug_cmd[4] + ((u32)debug_cmd[3] << 8) + - ((u32)debug_cmd[2] << 16) + ((u32)debug_cmd[1] << 24) + - ((u64)debug_cmd[0] << 32); - ipa_node.net_id = debug_cmd[9]; - ipa_node.src = debug_cmd[10] & 0x1f; - ipa_node.err_code = ((debug_cmd[13] & 0xc0) >> 6) + - ((debug_cmd[12] & 0x03) << 2); -#endif - return size; -} - -static int sipa_get_node_debug_show(struct seq_file *s, void *unused) -{ - int i; - u8 *byte; - - seq_printf(s, "address = 0x%llx length = 0x%x offset = 0x%x net_id = 0x%x\n", - (u64)ipa_node.address, ipa_node.length, ipa_node.offset, - ipa_node.net_id); - seq_printf(s, "src = 0x%x dst = 0x%x prio = 0x%x bear_id = 0x%x\n", - ipa_node.src, ipa_node.dst, ipa_node.prio, ipa_node.bear_id); - seq_printf(s, "intr = 0x%x indx = 0x%x err_code = 0x%x reserved = 0x%x\n", - ipa_node.intr, ipa_node.indx, - ipa_node.err_code, ipa_node.reserved); - - byte = (u8 *)&ipa_node; - for (i = 0; i < sizeof(ipa_node); i++) - seq_printf(s, "0x%x ", *(byte + i)); - - seq_puts(s, "\n"); - - return 0; -} - -static int sipa_get_node_debug_open(struct inode *inode, - struct file *file) -{ - return single_open(file, sipa_get_node_debug_show, - inode->i_private); -} - -static const struct file_operations sipa_get_node_fops = { - .open = sipa_get_node_debug_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, - .write = sipa_get_node_debug_write, -}; - -static ssize_t sipa_set_node_debug_write(struct file *f, const char __user *buf, - size_t size, loff_t *l) -{ - ssize_t len; - u32 debug_cmd[24], data_buf[24]; - - len = min(size, sizeof(data_buf) - 1); - if (copy_from_user((char *)data_buf, buf, len)) - return -EFAULT; - - len = sscanf((char *)data_buf, "%x %x %x %x %x %x %x %x %x %x %x %x\n", - &debug_cmd[0], &debug_cmd[1], &debug_cmd[2], - &debug_cmd[3], &debug_cmd[4], &debug_cmd[5], - &debug_cmd[6], &debug_cmd[7], &debug_cmd[8], - &debug_cmd[9], &debug_cmd[10], &debug_cmd[11]); - - ipa_node.address = debug_cmd[0]; - ipa_node.length = debug_cmd[1]; - ipa_node.offset = debug_cmd[2]; - ipa_node.net_id = debug_cmd[3]; - ipa_node.src = debug_cmd[4]; - ipa_node.dst = debug_cmd[5]; - ipa_node.prio = debug_cmd[6]; - ipa_node.bear_id = debug_cmd[7]; - ipa_node.intr = debug_cmd[8]; - ipa_node.indx = debug_cmd[9]; - ipa_node.err_code = debug_cmd[10]; - ipa_node.reserved = debug_cmd[11]; - - return size; -} - -static int sipa_set_node_debug_show(struct seq_file *s, void *unused) -{ -#if defined (__BIG_ENDIAN_BITFIELD) - int i; - u8 node_buf[16]; -#endif - - seq_printf(s, "address = 0x%llx length = 0x%x offset = 0x%x net_id = 0x%x\n", - (u64)ipa_node.address, ipa_node.length, ipa_node.offset, - ipa_node.net_id); - seq_printf(s, "src = 0x%x dst = 0x%x prio = 0x%x bear_id = 0x%x\n", - ipa_node.src, ipa_node.dst, ipa_node.prio, ipa_node.bear_id); - seq_printf(s, "intr = 0x%x indx = 0x%x err_code = 0x%x reserved = 0x%x\n", - ipa_node.intr, ipa_node.indx, - ipa_node.err_code, ipa_node.reserved); - -#if defined (__BIG_ENDIAN_BITFIELD) - sipa_set_node_desc(node_buf, (u8 *)&ipa_node); - for (i = 0; i < sizeof(node_buf); i++) - seq_printf(s, "0x%x ", node_buf[i]); -#endif - - seq_puts(s, "\n"); - - return 0; -} - -static int sipa_set_node_debug_open(struct inode *inode, - struct file *file) -{ - return single_open(file, sipa_set_node_debug_show, - inode->i_private); -} - -static const struct file_operations sipa_set_node_fops = { - .open = sipa_set_node_debug_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, - .write = sipa_set_node_debug_write, -}; - -static ssize_t sipa_reg_debug_write(struct file *f, const char __user *buf, - size_t size, loff_t *l) -{ - ssize_t len; - struct sipa_core *ipa = f->f_inode->i_private; - - len = min(size, sizeof(data_buf) - 1); - if (copy_from_user((char *)data_buf, buf, len)) - return -EFAULT; - - len = sscanf((char *)data_buf, "%x %x %x %x %x\n", - &debug_cmd[0], &debug_cmd[1], &debug_cmd[2], - &debug_cmd[3], &debug_cmd[4]); - if (debug_cmd[2]) - writel_relaxed(debug_cmd[1], ipa->virt_reg_addr + debug_cmd[0]); - - return size; -} - -static int sipa_reg_debug_show(struct seq_file *s, void *unused) -{ - u32 tx_filled, rx_filled; - u32 tx_wr, tx_rd, rx_wr, rx_rd; - struct sipa_core *ipa = (struct sipa_core *)s->private; - - seq_printf(s, "0x%x\n", - readl_relaxed(ipa->virt_reg_addr + debug_cmd[0])); - - seq_printf(s, "pcie dl tx fifo empty = %d full = %d rx fifo empty = %d full = %d\n", - ipa->hal_ops.get_tx_empty_status(SIPA_FIFO_PCIE_DL, - ipa->cmn_fifo_cfg), - ipa->hal_ops.get_tx_full_status(SIPA_FIFO_PCIE_DL, - ipa->cmn_fifo_cfg), - ipa->hal_ops.get_rx_empty_status(SIPA_FIFO_PCIE_DL, - ipa->cmn_fifo_cfg), - ipa->hal_ops.get_rx_full_status(SIPA_FIFO_PCIE_DL, - ipa->cmn_fifo_cfg)); - seq_printf(s, "pcie ul tx fifo empty = %d full = %d rx fifo empty = %d full = %d\n", - ipa->hal_ops.get_tx_empty_status(SIPA_FIFO_PCIE_UL, - ipa->cmn_fifo_cfg), - ipa->hal_ops.get_tx_full_status(SIPA_FIFO_PCIE_UL, - ipa->cmn_fifo_cfg), - ipa->hal_ops.get_rx_empty_status(SIPA_FIFO_PCIE_UL, - ipa->cmn_fifo_cfg), - ipa->hal_ops.get_rx_full_status(SIPA_FIFO_PCIE_UL, - ipa->cmn_fifo_cfg)); - ipa->hal_ops.get_filled_depth(SIPA_FIFO_PCIE_DL, ipa->cmn_fifo_cfg, - &rx_filled, &tx_filled); - seq_printf(s, "pcie dl tx filled = 0x%x rx filled = 0x%x\n", - tx_filled, rx_filled); - ipa->hal_ops.get_filled_depth(SIPA_FIFO_PCIE_UL, ipa->cmn_fifo_cfg, - &rx_filled, &tx_filled); - seq_printf(s, "pcie ul tx filled = 0x%x rx filled = 0x%x\n", - tx_filled, rx_filled); - - ipa->hal_ops.get_rx_ptr(SIPA_FIFO_PCIE_UL, ipa->cmn_fifo_cfg, &rx_wr, &rx_rd); - ipa->hal_ops.get_tx_ptr(SIPA_FIFO_PCIE_UL, ipa->cmn_fifo_cfg, &tx_wr, &tx_rd); - seq_printf(s, "pcie ul rx_wr = 0x%x, rx_rd = 0x%x, tx_wr = 0x%x, tx_rd = 0x%x\n", - rx_wr, rx_rd, tx_wr, tx_rd); - - ipa->hal_ops.get_rx_ptr(SIPA_FIFO_PCIE_DL, ipa->cmn_fifo_cfg, &rx_wr, &rx_rd); - ipa->hal_ops.get_tx_ptr(SIPA_FIFO_PCIE_DL, ipa->cmn_fifo_cfg, &tx_wr, &tx_rd); - seq_printf(s, "pcie dl rx_wr = 0x%x, rx_rd = 0x%x, tx_wr = 0x%x, tx_rd = 0x%x\n", - rx_wr, rx_rd, tx_wr, tx_rd); - - sipa_int_callback_func(0, NULL); - - return 0; -} - -static int sipa_reg_debug_open(struct inode *inode, - struct file *file) -{ - return single_open(file, sipa_reg_debug_show, - inode->i_private); -} - -static const struct file_operations sipa_reg_debug_fops = { - .open = sipa_reg_debug_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, - .write = sipa_reg_debug_write, -}; - -static int sipa_send_test_show(struct seq_file *s, void *unused) -{ - struct sk_buff *skb = NULL; - struct sipa_core *ipa = (struct sipa_core *)s->private; - - if (!skb) { - skb = __dev_alloc_skb(256, GFP_KERNEL | GFP_NOWAIT); - if (!skb) { - dev_err(ipa->dev, "failed to alloc skb!\n"); - return 0; - } - skb_put(skb, 128); - memset(skb->data, 0xE7, skb->len); - - sipa_skb_sender_send_data(ipa->sender, skb, 0x19, 0); - } - - return 0; -} - -static int sipa_send_test_open(struct inode *inode, struct file *file) -{ - return single_open(file, sipa_send_test_show, inode->i_private); -} - -static const struct file_operations sipa_send_test_fops = { - .open = sipa_send_test_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static ssize_t sipa_nic_debug_write(struct file *f, const char __user *buf, - size_t size, loff_t *l) -{ - ssize_t len; - u8 debug_cmd[24], data_buf[24]; - - len = min(size, sizeof(data_buf) - 1); - if (copy_from_user((char *)data_buf, buf, len)) - return -EFAULT; - - len = sscanf((char *)data_buf, "%4hhx %4hhx\n", - &debug_cmd[0], &debug_cmd[1]); - if (debug_cmd[1]) - sipa_nic_open(debug_cmd[0], 0, NULL, NULL); - else - sipa_nic_close(debug_cmd[0]); - - return size; -} - -static int sipa_nic_debug_show(struct seq_file *s, void *unused) -{ - //struct sk_buff *skb = NULL; - struct sipa_core *ipa = (struct sipa_core *)s->private; - struct sipa_cmn_fifo_cfg_tag *pcie_dl = &ipa->cmn_fifo_cfg[SIPA_FIFO_PCIE_DL]; - //struct sipa_cmn_fifo_cfg_tag *pcie_ul = &ipa->cmn_fifo_cfg[SIPA_FIFO_PCIE_UL]; - //struct sipa_cmn_fifo_tag *dl_tx_fifo = &pcie_dl->tx_fifo; - struct sipa_cmn_fifo_tag *dl_rx_fifo = &pcie_dl->rx_fifo; - //struct sipa_cmn_fifo_tag *ul_tx_fifo = &pcie_ul->tx_fifo; - //struct sipa_cmn_fifo_tag *ul_rx_fifo = &pcie_ul->rx_fifo; - struct sipa_node_description_tag *node; - int i = 0; - - pr_info("dl rx_fifo addr: 0x%lx wp-%d rp-%d\n", (long unsigned int)dl_rx_fifo->virtual_addr, - dl_rx_fifo->wr, dl_rx_fifo->rd); - node = (struct sipa_node_description_tag *)dl_rx_fifo->virtual_addr; - for (i = 0; i < dl_rx_fifo->depth; i++, node++) { - pr_info("node addr 0x%lx\n", (long unsigned int)node); - pr_info("node info i-%d, addr-0x%llx len-%u off-%u netid-%u src-%u dst-%u pro-%u bearid-%u intr-%u indx-%u err-%u resd-%u\n", - i, (long long unsigned int)node->address, node->length, node->offset, node->net_id, - node->src, node->dst, node->prio, node->bear_id, node->intr, - node->indx, node->err_code, node->reserved); - } - - - return 0; -} - -static int sipa_nic_debug_open(struct inode *inode, struct file *file) -{ - return single_open(file, sipa_nic_debug_show, inode->i_private); -} - -static const struct file_operations sipa_nic_debug_fops = { - .open = sipa_nic_debug_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, - .write = sipa_nic_debug_write, -}; - -int sipa_init_debugfs(struct sipa_core *ipa) -{ - struct dentry *root; - struct dentry *file; - - root = debugfs_create_dir(dev_name(ipa->dev), NULL); - if (!root) { - dev_err(ipa->dev, "sipa create debugfs fail\n"); - return -ENOMEM; - } - - file = debugfs_create_file("params", 0444, root, ipa, - &sipa_params_fops); - if (!file) { - dev_err(ipa->dev, "sipa create params file debugfs fail\n"); - debugfs_remove_recursive(root); - return -ENOMEM; - } - - file = debugfs_create_file("endian", 0444, root, ipa, - &sipa_endian_fops); - if (!file) { - dev_err(ipa->dev, "sipa create endian file debugfs fail\n"); - debugfs_remove_recursive(root); - return -ENOMEM; - } - - file = debugfs_create_file("get_node", 0444, root, ipa, - &sipa_get_node_fops); - if (!file) { - dev_err(ipa->dev, "sipa create endian file debugfs fail\n"); - debugfs_remove_recursive(root); - return -ENOMEM; - } - - file = debugfs_create_file("set_node", 0444, root, ipa, - &sipa_set_node_fops); - if (!file) { - dev_err(ipa->dev, "sipa create set node file debugfs fail\n"); - debugfs_remove_recursive(root); - return -ENOMEM; - } - - file = debugfs_create_file("reg", 0444, root, ipa, - &sipa_reg_debug_fops); - if (!file) { - dev_err(ipa->dev, "sipa create reg debug file debugfs fail\n"); - debugfs_remove_recursive(root); - return -ENOMEM; - } - - file = debugfs_create_file("send_test", 0444, root, ipa, - &sipa_send_test_fops); - if (!file) { - dev_err(ipa->dev, "sipa create send_test debug file debugfs fail\n"); - debugfs_remove_recursive(root); - return -ENOMEM; - } - - file = debugfs_create_file("nic", 0444, root, ipa, - &sipa_nic_debug_fops); - if (!file) { - dev_err(ipa->dev, "sipa create nic debug file debugfs fail\n"); - debugfs_remove_recursive(root); - return -ENOMEM; - } - ipa->dentry = root; - - return 0; -} -EXPORT_SYMBOL(sipa_init_debugfs); diff --git a/quectel_SRPD_PCIE/src/sipa/sipa_dele_cmn.c b/quectel_SRPD_PCIE/src/sipa/sipa_dele_cmn.c deleted file mode 100644 index e90895b..0000000 --- a/quectel_SRPD_PCIE/src/sipa/sipa_dele_cmn.c +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright (C) 2018-2019 Unisoc Corporation - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../include/sipa.h" -#include "../include/sipc.h" -#include "../include/sprd_pcie_ep_device.h" -#include "sipa_core.h" - -#define SIPA_PCIE_DL_CMN_FIFO_REG_OFFSET 0x980 -#define SIPA_PCIE_UL_CMN_FIFO_REG_OFFSET 0x200 - -static int sipa_dele_start_req_work(void) -{ - struct smsg msg; - - msg.channel = SMSG_CH_COMM_SIPA; - msg.type = SMSG_TYPE_CMD; - msg.flag = SMSG_FLG_DELE_REQUEST; - msg.value = 0; - - return smsg_send(SIPC_ID_MINIAP, &msg, -1); -} - -static int sipa_init_cmn_fifo_reg_addr(struct sipa_core *ipa) -{ - ipa->reg_mapped = sprd_ep_ipa_map(PCIE_IPA_TYPE_REG, - ipa->reg_res->start, - resource_size(ipa->reg_res)); -#ifndef devm_ioremap_nocache -#define devm_ioremap_nocache devm_ioremap -#endif - ipa->virt_reg_addr = devm_ioremap_nocache(ipa->dev, - (resource_size_t)ipa->reg_mapped, - (resource_size_t)(resource_size(ipa->reg_res))); - if (!ipa->virt_reg_addr) { - dev_err(ipa->dev, "ipa reg base remap fail\n"); - return -ENOMEM; - } - - ipa->cmn_fifo_cfg[SIPA_FIFO_PCIE_DL].fifo_reg_base = - ipa->virt_reg_addr + SIPA_PCIE_DL_CMN_FIFO_REG_OFFSET; - ipa->cmn_fifo_cfg[SIPA_FIFO_PCIE_UL].fifo_reg_base = - ipa->virt_reg_addr + SIPA_PCIE_UL_CMN_FIFO_REG_OFFSET; - - return 0; -} - -static int conn_thread(void *data) -{ - struct smsg mrecv; - int ret, timeout = 500; - struct sipa_core *ipa = data; - - /* since the channel open may hang, we call it in the thread context */ - ret = smsg_ch_open(SIPC_ID_MINIAP, SMSG_CH_COMM_SIPA, -1); - if (ret != 0) { - dev_err(ipa->dev, "sipa_delegator failed to open dst %d channel %d\n", - SIPC_ID_MINIAP, SMSG_CH_COMM_SIPA); - /* assign NULL to thread poniter as failed to open channel */ - return ret; - } - - while (sipa_dele_start_req_work() && timeout--) - usleep_range(5000, 10000); - - /* start listen the smsg events */ - while (!kthread_should_stop()) { - /* monitor seblock recv smsg */ - smsg_set(&mrecv, SMSG_CH_COMM_SIPA, 0, 0, 0); - ret = smsg_recv(SIPC_ID_MINIAP, &mrecv, -1); - if (ret == -EIO || ret == -ENODEV) { - /* channel state is FREE */ - usleep_range(5000, 10000); - continue; - } - - dev_dbg(ipa->dev, "sipa type=%d, flag=0x%x, value=0x%08x\n", - mrecv.type, mrecv.flag, mrecv.value); - - switch (mrecv.type) { - case SMSG_TYPE_OPEN: - /* just ack open */ - smsg_open_ack(SIPC_ID_AP, SMSG_CH_COMM_SIPA); - break; - case SMSG_TYPE_CLOSE: - /* handle channel close */ - smsg_close_ack(SIPC_ID_AP, SMSG_CH_COMM_SIPA); - break; - case SMSG_TYPE_CMD: - /* handle commads */ - break; - case SMSG_TYPE_DONE: - sipa_init_cmn_fifo_reg_addr(ipa); - dev_info(ipa->dev, "remote ipa ready reg_mapped = 0x%llx\n", (long long unsigned int)ipa->reg_mapped); - sipa_receiver_open_cmn_fifo(ipa->receiver); - sipa_sender_open_cmn_fifo(ipa->sender); - sipa_nic_check_flow_ctrl(); - ipa->remote_ready = true; - /* handle cmd done */ - break; - case SMSG_TYPE_EVENT: - /* handle events */ - break; - default: - ret = 1; - break; - }; - - if (ret) { - dev_info(ipa->dev, "unknown msg in conn_thrd: %d, %d, %d\n", - mrecv.type, mrecv.flag, mrecv.value); - ret = 0; - } - } - - return ret; -} - -int sipa_create_smsg_channel(struct sipa_core *ipa) -{ - /* create channel thread for this seblock channel */ - ipa->smsg_thread = kthread_create(conn_thread, ipa, "sipa-dele"); - if (IS_ERR(ipa->smsg_thread)) { - dev_err(ipa->dev, "Failed to create monitor smsg kthread\n"); - return PTR_ERR(ipa->smsg_thread); - } - - wake_up_process(ipa->smsg_thread); - - return 0; -} -EXPORT_SYMBOL(sipa_create_smsg_channel); diff --git a/quectel_SRPD_PCIE/src/sipa/sipa_dummy.c b/quectel_SRPD_PCIE/src/sipa/sipa_dummy.c deleted file mode 100644 index 6d3c8f9..0000000 --- a/quectel_SRPD_PCIE/src/sipa/sipa_dummy.c +++ /dev/null @@ -1,583 +0,0 @@ -/* - * Copyright (C) 2020 Spreadtrum Communications Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#define pr_fmt(fmt) "sipa_dummy: " fmt - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "sipa_eth.h" -#include "sipa_core.h" -#include "../include/sipa.h" - - -/* Device status */ -#define DEV_ON 1 -#define DEV_OFF 0 - -#define SIPA_DUMMY_NAPI_WEIGHT 64 - -extern struct sipa_eth_netid_device * dev_list[]; -static struct net_device *dummy_dev; -static struct dentry *dummy_root; -static int sipa_dummy_debugfs_mknod(void *data); - -#ifndef CONFIG_SPRD_ETHERNET -static int sipa_arp_reply(struct net_device *net, struct sk_buff *skb) { - struct arphdr *parp; - u8 *arpptr, *sha; - u8 sip[4], tip[4]; - struct sk_buff *reply = NULL; - - parp = arp_hdr(skb); - - if (parp->ar_hrd == htons(ARPHRD_ETHER) && parp->ar_pro == htons(ETH_P_IP) - && parp->ar_op == htons(ARPOP_REQUEST) && parp->ar_hln == 6 && parp->ar_pln == 4) { - arpptr = (u8 *)parp + sizeof(struct arphdr); - sha = arpptr; - arpptr += net->addr_len; /* sha */ - memcpy(sip, arpptr, sizeof(sip)); - arpptr += sizeof(sip); - arpptr += net->addr_len; /* tha */ - memcpy(tip, arpptr, sizeof(tip)); - - pr_info("%s sip = %d.%d.%d.%d, tip=%d.%d.%d.%d\n", netdev_name(net), sip[0], sip[1], sip[2], sip[3], tip[0], tip[1], tip[2], tip[3]); - reply = arp_create(ARPOP_REPLY, ETH_P_ARP, *((__be32 *)sip), skb->dev, *((__be32 *)tip), sha, net->dev_addr, sha); - if (reply) { - dev_queue_xmit(reply); - } - return 1; - } - - return 0; -} - -static void sipa_get_modem_mac(struct sk_buff *skb, struct SIPA_ETH *sipa_eth) -{ - struct ethhdr *ehdr; - struct iphdr *iph; - struct udphdr *udph; - struct sipa_eth_init_data *pdata = sipa_eth->pdata; - - ehdr = (struct ethhdr *)(skb->data - ETH_HLEN); - iph = ip_hdr(skb); - udph = (struct udphdr *)(skb->data + iph->ihl*4); - - if (ehdr->h_proto == htons(ETH_P_ARP)) { - sipa_arp_reply(skb->dev, skb); - return; - } - - //printk("%s skb=%p, h_proto=%x, protocol=%x, saddr=%x, daddr=%x dest=%x\n", __func__, skb, ehdr->h_proto, iph->protocol, iph->saddr, iph->daddr, udph->dest); - if (ehdr->h_proto == htons(ETH_P_IP) && iph->protocol == IPPROTO_UDP && iph->saddr != 0x00000000 && iph->daddr == 0xFFFFFFFF) { - if (udph->dest == htons(68)) //DHCP offer/ACK - { - memcpy(pdata->modem_mac, ehdr->h_source, ETH_ALEN); - pr_info("Modem Mac Address: %02x:%02x:%02x:%02x:%02x:%02x\n", - pdata->modem_mac[0], pdata->modem_mac[1], pdata->modem_mac[2], pdata->modem_mac[3], pdata->modem_mac[4], pdata->modem_mac[5]); - } - } -} -#endif - -/* Term type 0x6 means we are in direct mode, currently. - * we will recv pkt with a dummy mac header, which will - * cause us fail to get skb->pkt_type and skb->protocol. - */ -static void sipa_dummy_prepare_skb(struct sk_buff *skb) -{ - struct iphdr *iph; - struct ipv6hdr *ipv6h; - struct net_device *dev; - unsigned int real_len = 0, payload_len = 0; - bool ip_arp = true; - - dev = skb->dev; - - skb->protocol = eth_type_trans(skb, dev); - skb_reset_network_header(skb); - - switch (ntohs(skb->protocol)) { - case ETH_P_IP: - iph = ip_hdr(skb); - real_len = ntohs(iph->tot_len); - break; - case ETH_P_IPV6: - ipv6h = ipv6_hdr(skb); - payload_len = ntohs(ipv6h->payload_len); - real_len = payload_len + sizeof(struct ipv6hdr); - break; - case ETH_P_ARP: - real_len = arp_hdr_len(dev); - break; - default: - ip_arp = false; - break; - } - - if (ip_arp) - skb_trim(skb, real_len); - - /* TODO chechsum ... */ - skb->ip_summed = CHECKSUM_NONE; - skb->pkt_type = PACKET_HOST; -} - -/* Term type 0x6 means we are in direct mode, currently. - * we will recv pkt with a dummy mac header, which will - * cause us fail to get skb->pkt_type and skb->protocol. - */ -static void sipa_dummy_direct_mode_prepare_skb(struct sk_buff *skb) -{ - struct iphdr *iph; - struct ipv6hdr *ipv6h; - unsigned int real_len = 0, payload_len = 0; - - skb_pull_inline(skb, ETH_HLEN); - skb_reset_network_header(skb); - iph = ip_hdr(skb); - if (iph->version == 4) { - skb->protocol = htons(ETH_P_IP); - iph = ip_hdr(skb); - real_len = ntohs(iph->tot_len); - skb_trim(skb, real_len); - } else if(iph->version == 6){ - skb->protocol = htons(ETH_P_IPV6); - ipv6h = ipv6_hdr(skb); - payload_len = ntohs(ipv6h->payload_len); - real_len = payload_len + sizeof(struct ipv6hdr); - skb_trim(skb, real_len); - } else { - pr_err("unrecognized ip version %d\n", iph->version); - } - - skb->ip_summed = CHECKSUM_NONE; - skb->pkt_type = PACKET_HOST; -} - -static int sipa_dummy_rx(struct SIPA_DUMMY *sipa_dummy, int budget) -{ - struct sk_buff *skb; - struct sipa_eth_netid_device *netid_dev_info; - struct SIPA_ETH *sipa_eth; - int real_netid = 0; - int skb_cnt = 0; - int ret; - - if (!sipa_dummy) { - pr_err("no sipa_dummy device\n"); - return -EINVAL; - } - - atomic_set(&sipa_dummy->rx_evt, 0); - while (skb_cnt < budget) { - ret = sipa_nic_rx(&real_netid, &skb, skb_cnt); - - if (ret) { - switch (ret) { - case -ENODEV: - pr_err("sipa fail to find dev\n"); - sipa_dummy->stats.rx_errors++; - sipa_dummy->netdev->stats.rx_errors++; - break; - case -ENODATA: - pr_err("sipa no data\n"); - atomic_set(&sipa_dummy->rx_busy, 0); - break; - } - break; - } - - skb_cnt++; - sipa_dummy->stats.rx_packets++; - sipa_dummy->stats.rx_bytes += skb->len; - if (real_netid < 0) { - pr_err("sipa invaild netid"); - break; - } - /* - * We should determine the real device before we do eth_types_tran, - */ - if (real_netid < 0 || real_netid >= SIPA_DUMMY_IFACE_NUM) { - pr_err("illegal real_netid %d\n", real_netid); - dev_kfree_skb_any(skb); - break; - } - netid_dev_info = dev_list[real_netid]; - if (!netid_dev_info || netid_dev_info->state == DEV_OFF) { - pr_info("netid= %d net is not DEV_ON\n", real_netid); - dev_kfree_skb_any(skb); - break; - } - - skb->dev = netid_dev_info->ndev; - sipa_eth = netdev_priv(skb->dev); - sipa_eth->stats.rx_packets++; - sipa_eth->stats.rx_bytes += skb->len; - if (sipa_eth->pdata->term_type == 0x6) { - sipa_dummy_direct_mode_prepare_skb(skb); - } else { - sipa_dummy_prepare_skb(skb); -#ifndef CONFIG_SPRD_ETHERNET - sipa_get_modem_mac(skb, sipa_eth); -#endif - } - napi_gro_receive(&sipa_dummy->napi, skb); - } - - return skb_cnt; -} - -static int sipa_dummy_rx_poll_handler(struct napi_struct *napi, int budget) -{ - int pkts = 0, num, tmp = 0; - - struct SIPA_DUMMY *sipa_dummy = container_of(napi, struct SIPA_DUMMY, napi); - -READ_AGAIN: - num = sipa_nic_get_filled_num(); - if (!num) - goto check; - if (num > budget) - num = budget; - - pkts = sipa_dummy_rx(sipa_dummy, num); - if (pkts > 0) - sipa_nic_set_tx_fifo_rp(pkts); - tmp += pkts; - - budget -= pkts; - if (!budget) - goto out; - -check: - if (!sipa_check_recv_tx_fifo_empty() || - atomic_read(&sipa_dummy->rx_evt)) { - atomic_set(&sipa_dummy->rx_evt, 0); - goto READ_AGAIN; - } - - atomic_set(&sipa_dummy->rx_busy, 0); - napi_complete(napi); - sipa_nic_restore_irq(); - if (atomic_read(&sipa_dummy->rx_evt) || - atomic_read(&sipa_dummy->rx_busy) || - !sipa_check_recv_tx_fifo_empty()) { - atomic_set(&sipa_dummy->rx_evt, 0); - napi_schedule(&sipa_dummy->napi); - } - -out: - return tmp; -} - -static void sipa_dummy_rx_handler (void *priv) -{ - struct SIPA_DUMMY *sipa_dummy = (struct SIPA_DUMMY *)priv; - - if (!sipa_dummy) { - pr_err("data is NULL\n"); - return; - } - - if (!atomic_cmpxchg(&sipa_dummy->rx_busy, 0, 1)) { - atomic_set(&sipa_dummy->rx_evt, 0); - napi_schedule(&sipa_dummy->napi); - } -} - -/* for sipa to invoke */ -void sipa_dummy_recv_trigger(void) -{ - struct SIPA_DUMMY *sipa_dummy; - - if (!dummy_dev) - return; - - sipa_dummy = netdev_priv(dummy_dev); - - atomic_set(&sipa_dummy->rx_evt, 1); - sipa_dummy_rx_handler(sipa_dummy); -} - -static int sipa_dummy_start_xmit(struct sk_buff *skb, struct net_device *dev) -{ - struct SIPA_DUMMY *sipa_dummy = netdev_priv(dev); - - /* update netdev statistics */ - sipa_dummy->stats.tx_packets++; - sipa_dummy->stats.tx_bytes += skb->len; - - dev_kfree_skb(skb); - return NETDEV_TX_OK; -} - -/* Open interface */ -static int sipa_dummy_open(struct net_device *dev) -{ - struct SIPA_DUMMY *sipa_dummy = netdev_priv(dev); - struct sipa_core *ctrl = sipa_get_ctrl_pointer(); - - if (!ctrl) { - return -EINVAL; - } - - if(!ctrl->remote_ready) - return -EINVAL; - - pr_info("dummy open\n"); - if (!netif_carrier_ok(sipa_dummy->netdev)) { - netif_carrier_on(sipa_dummy->netdev); - } - - netif_start_queue(dev); - //napi_enable(&sipa_dummy->napi); - - napi_schedule(&sipa_dummy->napi); - return 0; -} - -/* Close interface */ -static int sipa_dummy_close(struct net_device *dev) -{ - //struct SIPA_DUMMY *sipa_dummy = netdev_priv(dev); - pr_info("close dummy!\n"); - - //napi_disable(&sipa_dummy->napi); - netif_stop_queue(dev); - netif_carrier_off(dev); - - return 0; -} - -static struct net_device_stats *sipa_dummy_get_stats(struct net_device *dev) -{ - struct SIPA_DUMMY *sipa_dummy = netdev_priv(dev); - - return &sipa_dummy->stats; -} - -static const struct net_device_ops sipa_dummy_ops = { - .ndo_open = sipa_dummy_open, - .ndo_stop = sipa_dummy_close, - .ndo_start_xmit = sipa_dummy_start_xmit, - .ndo_get_stats = sipa_dummy_get_stats, -}; - -static void s_setup(struct net_device *dev) -{ - ether_setup(dev); -} - -static int sipa_dummy_probe(struct platform_device *pdev) -{ - struct SIPA_DUMMY *sipa_dummy; - struct net_device *netdev; - int ret; - -#ifdef NET_NAME_PREDICTABLE - netdev = alloc_netdev( - sizeof(struct SIPA_DUMMY), - "sipa_dummy0", - NET_NAME_PREDICTABLE, - s_setup); -#else - netdev = alloc_netdev( - sizeof(struct SIPA_DUMMY), - "sipa_dummy0", - s_setup); -#endif - - if (!netdev) { - pr_err("alloc_netdev() failed.\n"); - return -ENOMEM; - } - - dummy_dev = netdev; - netdev->type = ARPHRD_ETHER; - sipa_dummy = netdev_priv(netdev); - sipa_dummy->netdev = netdev; - netdev->netdev_ops = &sipa_dummy_ops; - netdev->watchdog_timeo = 1 * HZ; - netdev->irq = 0; - netdev->dma = 0; - netdev->features &= ~(NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | NETIF_F_HW_CSUM); - random_ether_addr(netdev->dev_addr); - - netif_napi_add(netdev, - &sipa_dummy->napi, - sipa_dummy_rx_poll_handler, - SIPA_DUMMY_NAPI_WEIGHT); - - /* Register new Ethernet interface */ - ret = register_netdev(netdev); - if (ret) { - pr_err("register_netdev() failed (%d)\n", ret); - netif_napi_del(&sipa_dummy->napi); - free_netdev(netdev); - return ret; - } - - /* Set link as disconnected */ - netif_carrier_off(netdev); - platform_set_drvdata(pdev, sipa_dummy); - sipa_dummy_debugfs_mknod((void *)sipa_dummy); - napi_enable(&sipa_dummy->napi); - return 0; -} - -/* Cleanup Ethernet device driver. */ -static int sipa_dummy_remove(struct platform_device *pdev) -{ - struct SIPA_DUMMY *sipa_dummy= platform_get_drvdata(pdev); - netif_stop_queue(sipa_dummy->netdev); - napi_disable(&sipa_dummy->napi); - netif_napi_del(&sipa_dummy->napi); - unregister_netdev(sipa_dummy->netdev); - free_netdev(sipa_dummy->netdev); - platform_set_drvdata(pdev, NULL); - if (!IS_ERR_OR_NULL(dummy_root)) - debugfs_remove_recursive(dummy_root); - - return 0; -} - -#ifdef SPRD_PCIE_USE_DTS -static const struct of_device_id sipa_dummy_match_table[] = { - { .compatible = "sprd,sipa_dummy"}, - { } -}; -#endif - -static struct platform_driver sipa_dummy_driver = { - .probe = sipa_dummy_probe, - .remove = sipa_dummy_remove, - .driver = { - .owner = THIS_MODULE, - .name = "sipa_dummy", -#ifdef SPRD_PCIE_USE_DTS - .of_match_table = sipa_dummy_match_table -#endif - } -}; - -#ifndef SPRD_PCIE_USE_DTS -static struct platform_device *sipa_dummy_device; - -static int sipa_dummy_platform_device_reigster(void) -{ - int retval = -ENOMEM; - - sipa_dummy_device = platform_device_alloc("sipa_dummy", -1); - if (!sipa_dummy_device) - return retval; - - retval = platform_device_add(sipa_dummy_device); - if (retval < 0) - platform_device_put(sipa_dummy_device); - - return retval; -} -#endif - - -static int sipa_dummy_debug_show(struct seq_file *m, void *v) -{ - struct SIPA_DUMMY *sipa_dummy = (struct SIPA_DUMMY *)(m->private); - - if (!sipa_dummy) { - pr_err("invalid data, sipa_dummy is NULL\n"); - return -EINVAL; - } - - seq_puts(m, "*************************************************\n"); - seq_printf(m, "DEVICE: %s rx_busy=%d rx_evt=%d\n", - sipa_dummy->netdev->name, atomic_read(&sipa_dummy->rx_busy), - atomic_read(&sipa_dummy->rx_evt)); - seq_puts(m, "*************************************************\n"); - - return 0; -} - -static int sipa_dummy_debug_open(struct inode *inode, struct file *file) -{ - return single_open(file, sipa_dummy_debug_show, inode->i_private); -} - -static const struct file_operations sipa_dummy_debug_fops = { - .open = sipa_dummy_debug_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static int sipa_dummy_debugfs_mknod(void *data) -{ - if (!dummy_root) { - pr_err("dummy dir is NULL\n"); - return -ENXIO; - } - debugfs_create_file("stats", - 0444, - dummy_root, - data, - &sipa_dummy_debug_fops); - - return 0; -} - -static void __init sipa_dummy_debugfs_init(void) -{ - dummy_root = debugfs_create_dir("sipa_dummy", NULL); - if (!dummy_root) - pr_err("failed to create sipa_dummy debugfs dir\n"); -} - -int sipa_dummy_init(void) -{ - sipa_dummy_debugfs_init(); -#ifndef SPRD_PCIE_USE_DTS - sipa_dummy_platform_device_reigster(); -#endif - return platform_driver_register(&sipa_dummy_driver); -} -EXPORT_SYMBOL(sipa_dummy_init); - -void sipa_dummy_exit(void) -{ - platform_driver_unregister(&sipa_dummy_driver); -#ifndef SPRD_PCIE_USE_DTS - platform_device_unregister(sipa_dummy_device); -#endif -} -EXPORT_SYMBOL(sipa_dummy_exit); diff --git a/quectel_SRPD_PCIE/src/sipa/sipa_eth.c b/quectel_SRPD_PCIE/src/sipa/sipa_eth.c deleted file mode 100644 index c790725..0000000 --- a/quectel_SRPD_PCIE/src/sipa/sipa_eth.c +++ /dev/null @@ -1,1087 +0,0 @@ -/* - * Copyright (C) 2019 Spreadtrum Communications Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#define pr_fmt(fmt) "sipa_eth: " fmt - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "sipa_eth.h" -#include "../include/sipa.h" - -#ifndef ARPHRD_RAWIP -#define ARPHRD_RAWIP ARPHRD_NONE -#endif - -#ifdef CONFIG_PINCTRL_IPQ807x -//#define CONFIG_QCA_NSS_DRV -#endif - -#if 1//def CONFIG_QCA_NSS_DRV -#define _RMNET_NSS_H_ -#define _RMENT_NSS_H_ -struct rmnet_nss_cb { - int (*nss_create)(struct net_device *dev); - int (*nss_free)(struct net_device *dev); - int (*nss_tx)(struct sk_buff *skb); -}; -static struct rmnet_nss_cb *rmnet_nss_callbacks __rcu __read_mostly; -#ifdef CONFIG_QCA_NSS_DRV -static uint __read_mostly qca_nss_enabled = 1; -module_param( qca_nss_enabled, uint, S_IRUGO); -#define rmnet_nss_dereference(nss_cb) do { \ - rcu_read_lock(); \ - nss_cb = rcu_dereference(rmnet_nss_callbacks); \ - rcu_read_unlock(); \ -} while(0) -#else -#define rmnet_nss_dereference(nss_cb) do { nss_cb = NULL; } while(0) -#endif -#endif - -/* Device status */ -#define DEV_ON 1 -#define DEV_OFF 0 - -#define SIPA_ETH_NAPI_WEIGHT 64 -#define SIPA_ETH_IFACE_PREF "seth" -#define SIPA_ETH_VPCIE_PREF "pcie" -#define SIPA_ETH_VPCIE_IDX 8 - -#define SIPA_DUMMY_IFACE_NUM 4 - -static struct dentry *root; -static int sipa_eth_debugfs_mknod(void *root, void *data); -static void sipa_eth_poll_rx_handler (void *priv); -static u64 gro_enable; - -struct sipa_eth_netid_device * dev_list[SIPA_DUMMY_IFACE_NUM]; - - -static const unsigned char dhcp_dst_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - -//static const u8 default_modem_addr[ETH_ALEN] = {0x02, 0x50, 0xf3}; -//static const u8 default_dev_addr[ETH_ALEN] = {0x02, 0x50, 0xf4}; - -static inline void sipa_eth_dt_stats_init(struct sipa_eth_dtrans_stats *stats) -{ - memset(stats, 0, sizeof(*stats)); -} - -static inline void sipa_eth_rx_stats_update( - struct sipa_eth_dtrans_stats *stats, u32 len) -{ - stats->rx_sum += len; - stats->rx_cnt++; -} - -static inline void sipa_eth_tx_stats_update( - struct sipa_eth_dtrans_stats *stats, u32 len) -{ - stats->tx_sum += len; - stats->tx_cnt++; -} - -static void sipa_eth_prepare_skb(struct SIPA_ETH *sipa_eth, struct sk_buff *skb) -{ - struct iphdr *iph; - struct ipv6hdr *ipv6h; - struct net_device *dev; - unsigned int real_len = 0, payload_len = 0; - bool ip_arp = true; - - dev = sipa_eth->netdev; - - skb->protocol = eth_type_trans(skb, dev); - skb_reset_network_header(skb); - - switch (ntohs(skb->protocol)) { - case ETH_P_IP: - iph = ip_hdr(skb); - real_len = ntohs(iph->tot_len); - break; - case ETH_P_IPV6: - ipv6h = ipv6_hdr(skb); - payload_len = ntohs(ipv6h->payload_len); - real_len = payload_len + sizeof(struct ipv6hdr); - break; - case ETH_P_ARP: - real_len = arp_hdr_len(dev); - break; - default: - ip_arp = false; - break; - } - - if (ip_arp) - skb_trim(skb, real_len); - - /* TODO chechsum ... */ - skb->ip_summed = CHECKSUM_NONE; - skb->dev = dev; -} - -static int sipa_eth_rx(struct SIPA_ETH *sipa_eth, int budget) -{ - struct sk_buff *skb; - struct net_device *dev; - struct sipa_eth_dtrans_stats *dt_stats; - int netid; - int skb_cnt = 0; - int ret; - - dt_stats = &sipa_eth->dt_stats; - - if (!sipa_eth) { - pr_err("no sipa_eth device\n"); - return -EINVAL; - } - - dev = sipa_eth->netdev; - atomic_set(&sipa_eth->rx_evt, 0); - while (skb_cnt < budget) { - ret = sipa_nic_rx(&netid, &skb, skb_cnt); - if (ret) { - switch (ret) { - case -ENODEV: - pr_err("fail to find dev"); - sipa_eth->stats.rx_errors++; - dt_stats->rx_fail++; - dev->stats.rx_errors++; - break; - case -ENODATA: - atomic_set(&sipa_eth->rx_busy, 0); - break; - } - break; - } - - if (!skb) { - pr_err("recv skb is null\n"); - return -EINVAL; - } - - sipa_eth_prepare_skb(sipa_eth, skb); - - sipa_eth->stats.rx_packets++; - sipa_eth->stats.rx_bytes += skb->len; - sipa_eth_rx_stats_update(dt_stats, skb->len); - napi_gro_receive(&sipa_eth->napi, skb); - //netif_receive_skb(skb); - skb_cnt++; - } - - return skb_cnt; -} - -static int sipa_eth_rx_poll_handler(struct napi_struct *napi, int budget) -{ - struct SIPA_ETH *sipa_eth = container_of(napi, struct SIPA_ETH, napi); - int tmp = 0, pkts; - - /* If the number of pkt is more than weight(64), - * we cannot read them all with a single poll. - * When the return value of poll func equals to weight(64), - * napi structure invokes the poll func one more time by - * __raise_softirq_irqoff.(See napi_poll for details) - * So do not do napi_complete in that case. - */ -READ_AGAIN: - /* For example: - * pkts = 60, tmp = 60, budget = 4 - * if rx_evt is true, we goto READ_AGAIN, - * pkts = 4, tmp = 64, budget = 0, - * then we goto out, return 64 to napi, - * In that case, we force napi to do polling again. - */ - pkts = sipa_eth_rx(sipa_eth, budget); - tmp += pkts; - budget -= pkts; - /* - * If budget is 0 here, means we has not finished reading yet, - * so we should return a weight-number(64) to napi to ask it - * do another polling. - */ - if (!budget) - goto out; - - /* Due to a cuncurrency issue, we have to do napi_complete - * cautiously. If a socket is in the process of napi polling, - * a SIPA_RECEIVE is arriving to trigger another socket to do receiving, - * we must record it because it will be blocked by rx_busy - * at the first beginning. - * Since this SIPA_RECEIVE notification is a one-shot behaviour - * in sipa_nic. if we chose to ignore this event, we may lose - * the chance to receive forever. - */ - if (atomic_read(&sipa_eth->rx_evt)) - goto READ_AGAIN; - - /* If the number of budget is more than 0, it means the pkts - * we received is smaller than napi weight(64). - * Then we are okay to do napi_complete. - */ - if (budget) { - napi_complete(napi); - /* Test in a lab, ten threads of TCP streams, - * TPUT reaches to 1Gbps, another edge case occurs, - * rx_busy might be 0, and rx_evt might be 1, - * after we do napi_complete. - * So do rx_handler manually to prevent - * sipa_eth from stopping receiving pkts. - */ - if (atomic_read(&sipa_eth->rx_evt) || - atomic_read(&sipa_eth->rx_busy)) { - pr_debug("rx evt recv after napi complete"); - atomic_set(&sipa_eth->rx_evt, 0); - napi_schedule(&sipa_eth->napi); - } - } - -out: - return tmp; -} - -/* Attention, The whole RX is deprecated, we use sipa_dummy to rx. */ -static void sipa_eth_poll_rx_handler (void *priv) -{ - struct SIPA_ETH *sipa_eth = (struct SIPA_ETH *)priv; - - if (!sipa_eth) { - pr_err("data is NULL\n"); - return; - } - - if (!atomic_cmpxchg(&sipa_eth->rx_busy, 0, 1)) { - atomic_set(&sipa_eth->rx_evt, 0); - napi_schedule(&sipa_eth->napi); - /* Trigger a NET_RX_SOFTIRQ softirq directly, - * or there will be a delay - */ - //raise_softirq(NET_RX_SOFTIRQ); - } -} - -static void sipa_eth_flowctrl_handler(void *priv, int flowctrl) -{ - struct SIPA_ETH *sipa_eth = (struct SIPA_ETH *)priv; - struct net_device *dev = sipa_eth->netdev; - - if (flowctrl) { - netif_stop_queue(dev); - } else if (netif_queue_stopped(dev)) { - netif_wake_queue(dev); - } -} - -static void sipa_eth_notify_cb(void *priv, enum sipa_evt_type evt, - unsigned int data) -{ - struct SIPA_ETH *sipa_eth = (struct SIPA_ETH *)priv; - - switch (evt) { - case SIPA_RECEIVE: - atomic_set(&sipa_eth->rx_evt, 1); - sipa_eth_poll_rx_handler(priv); - break; - case SIPA_LEAVE_FLOWCTRL: - pr_info("SIPA LEAVE FLOWCTRL\n"); - sipa_eth_flowctrl_handler(priv, 0); - break; - case SIPA_ENTER_FLOWCTRL: - pr_info("SIPA ENTER FLOWCTRL\n"); - sipa_eth_flowctrl_handler(priv, 1); - break; - default: - break; - } -} - -static int sipa_eth_start_xmit(struct sk_buff *skb, struct net_device *dev) -{ - struct SIPA_ETH *sipa_eth = netdev_priv(dev); - struct sipa_eth_init_data *pdata = sipa_eth->pdata; - struct sipa_eth_dtrans_stats *dt_stats; - int ret = 0, dhcp = 0; - int netid; - - dt_stats = &sipa_eth->dt_stats; - if (sipa_eth->state != DEV_ON) { - pr_err("called when %s is down\n", dev->name); - dt_stats->tx_fail++; - netif_carrier_off(dev); - dev_kfree_skb_any(skb); - return NETDEV_TX_OK; - } - - netid = pdata->netid; - - - if (dev->type != ARPHRD_ETHER) { - switch (skb->data[0] & 0xf0) { - case 0x40: - { - struct iphdr *ip4h = (struct iphdr *)(&skb->data[0]); - if (ip4h->protocol == IPPROTO_UDP && ip4h->saddr == 0x00000000 && ip4h->daddr == 0xFFFFFFFF) { - dhcp = 1; - } - skb->protocol = htons(ETH_P_IP); - } - break; - case 0x60: - skb->protocol = htons(ETH_P_IPV6); - break; - default: - if(skb->protocol != htons(ETH_P_ARP)) { - pr_err("unknow skb->protocol %02x\n", skb->data[0]); - goto err; - } - skb->protocol = htons(ETH_P_ARP); - arp_hdr(skb)->ar_hrd = htons(ARPHRD_ETHER); - break; - - } - skb_push(skb, ETH_HLEN); - skb_reset_mac_header(skb); - - memcpy(eth_hdr(skb)->h_source, dev->dev_addr, ETH_ALEN); - if(dhcp) - memcpy(eth_hdr(skb)->h_dest, dhcp_dst_addr, ETH_ALEN); - else - memcpy(eth_hdr(skb)->h_dest, pdata->modem_mac, ETH_ALEN); - eth_hdr(skb)->h_proto = skb->protocol; - } - - ret = sipa_nic_tx(sipa_eth->nic_id, pdata->term_type, netid, skb); - if (unlikely(ret != 0)) { - if (ret == -EAGAIN) { - /* - * resume skb, otherwise - * we may pull this skb ETH_HLEN-bytes twice - */ - if (!pdata->mac_h) - skb_push(skb, ETH_HLEN); - dt_stats->tx_fail++; - sipa_eth->stats.tx_errors++; - /* - if (ret == -EAGAIN) { - netif_stop_queue(dev); - sipa_nic_trigger_flow_ctrl_work(sipa_eth->nic_id, ret); - } - */ - return NETDEV_TX_BUSY; - } - pr_err("fail to send skb, dev 0x%p eth 0x%p nic_id %d, ret %d\n", - dev, sipa_eth, sipa_eth->nic_id, ret); - goto err; - } - - /* update netdev statistics */ - sipa_eth->stats.tx_packets++; - sipa_eth->stats.tx_bytes += skb->len; - sipa_eth_tx_stats_update(dt_stats, skb->len); - - return NETDEV_TX_OK; - -err: - sipa_eth->netdev->stats.tx_dropped++; - dev_kfree_skb_any(skb); - return NETDEV_TX_OK; -} - -static int sipa_eth_change_dev_list_state(struct SIPA_ETH *sipa_eth, int state) { - struct sipa_eth_netid_device *netid_dev_info; - int netid = sipa_eth->pdata->netid; - - if (strncmp(sipa_eth->netdev->name, - SIPA_ETH_VPCIE_PREF, - strlen(SIPA_ETH_VPCIE_PREF))) - return 0; - - if (netid < 0 || netid >= SIPA_DUMMY_IFACE_NUM) { - pr_info("illegal netid %d\n", netid); - return -EINVAL; - } - - netid_dev_info = dev_list[netid]; - netid_dev_info->state = state; - - pr_info("set %s netid %d %s for dummy\n", - sipa_eth->netdev->name, netid, state ? "DEV_ON" : "DEV_OFF"); - return 0; -} - -/* Open interface */ -static int sipa_eth_open(struct net_device *dev) -{ - struct SIPA_ETH *sipa_eth = netdev_priv(dev); - struct sipa_eth_init_data *pdata = sipa_eth->pdata; - int ret = 0; - - pr_info("dev 0x%p eth 0x%p open %s netid %d term %d mac_h %d\n", - dev, sipa_eth, dev->name, pdata->netid, pdata->term_type, - pdata->mac_h); - ret = sipa_nic_open( - pdata->term_type, - pdata->netid, - sipa_eth_notify_cb, - (void *)sipa_eth); - - if (ret < 0) - return -EINVAL; - - sipa_eth->nic_id = ret; - sipa_eth->state = DEV_ON; - sipa_eth_dt_stats_init(&sipa_eth->dt_stats); - memset(&sipa_eth->stats, 0, sizeof(sipa_eth->stats)); - - if (!netif_carrier_ok(sipa_eth->netdev)) { - pr_info("set netif_carrier_on\n"); - netif_carrier_on(sipa_eth->netdev); - } - - atomic_set(&sipa_eth->rx_busy, 0); - sipa_eth_change_dev_list_state(sipa_eth, DEV_ON); - netif_start_queue(dev); - napi_enable(&sipa_eth->napi); - - return 0; -} - -/* Close interface */ -static int sipa_eth_close(struct net_device *dev) -{ - struct SIPA_ETH *sipa_eth = netdev_priv(dev); - pr_info("close %s!\n", dev->name); - - sipa_nic_close(sipa_eth->nic_id); - sipa_eth->state = DEV_OFF; - - napi_disable(&sipa_eth->napi); - netif_stop_queue(dev); - - sipa_eth_change_dev_list_state(sipa_eth, DEV_OFF); - return 0; -} - -static struct net_device_stats *sipa_eth_get_stats(struct net_device *dev) -{ - struct SIPA_ETH *sipa_eth = netdev_priv(dev); - - return &sipa_eth->stats; -} - -/* - * For example, if an application starts a tcp connection, - * it finally invokes tcp_connect func to send out a TCP SYN. - * In a func tcp_init_nondata_skb, the skb->ip_summed is set - * to CHECKSUM_PARTIAL. Because only the pesuode header is - * calculated and stored. It expects that the netdevice - * to calculate the checksum for TCP header&TCP paylod and store - * the final checksum into tcphdr->check. - * Then __dev_queue_xmit -> validate_xmit_skb, it check the features - * of this current network card, if it with - * NETIF_F_IP_CSUM/NETIF_F_IPV6_CSUM/NETIF_F_HW_CSUM, - * skb_checksum_help func will be invoked for this calculation. - * - * So we have to implement ndo_features_check func, since we - * have any ability to calculate a checksum for a pkt. - */ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION( 3,11,0 )) -netdev_features_t sipa_eth_features_check(struct sk_buff *skb, struct net_device *dev, - netdev_features_t features) -{ - features &= ~(NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | NETIF_F_HW_CSUM); - - return features; -} -#endif - -static const struct net_device_ops sipa_eth_ops = { - .ndo_open = sipa_eth_open, - .ndo_stop = sipa_eth_close, - .ndo_start_xmit = sipa_eth_start_xmit, - .ndo_get_stats = sipa_eth_get_stats, -#if (LINUX_VERSION_CODE >= KERNEL_VERSION( 3,11,0 )) - .ndo_features_check = sipa_eth_features_check, -#endif -}; - -#if (LINUX_VERSION_CODE >= KERNEL_VERSION( 3,11,0 )) -static int sipa_eth_parse_dt( - struct sipa_eth_init_data **init, - struct device *dev) -{ - struct sipa_eth_init_data *pdata = NULL; - struct device_node *np = dev->of_node; - int ret; - u32 udata, id; - s32 sdata; - - if (!np) - pr_err("dev of_node np is null\n"); - - pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); - if (!pdata) - return -ENOMEM; - - id = of_alias_get_id(np, "eth"); - switch (id) { - case 0 ... 7: - snprintf(pdata->name, IFNAMSIZ, "%s%d", - SIPA_ETH_IFACE_PREF, id); - break; - case 8 ... 11: - snprintf(pdata->name, IFNAMSIZ, "%s%d", - SIPA_ETH_VPCIE_PREF, id - SIPA_ETH_VPCIE_IDX); - break; - default: - pr_err("wrong alias id from dts, id %d\n", id); - return -EINVAL; - } - - ret = of_property_read_u32(np, "sprd,netid", &sdata); - if (ret) { - pr_err("read sprd,netid ret %d\n", ret); - return ret; - } - /* dts reflect */ - pdata->netid = sdata - 1; - - ret = of_property_read_u32(np, "sprd,term-type", &udata); - if (ret) { - pr_err("read sprd,term-type ret %d\n", ret); - return ret; - } - - pdata->term_type = udata; - - pdata->mac_h = of_property_read_bool(np, "sprd,mac-header"); - - *init = pdata; - pr_debug("after dt parse, name %s netid %d term-type %d mac_h %d\n", - pdata->name, pdata->netid, pdata->term_type, pdata->mac_h); - return 0; -} -#endif - -static void s_setup(struct net_device *dev) -{ -#ifndef CONFIG_SPRD_ETHERNET - ether_setup(dev); - dev->needed_headroom = 16; - - /* Raw IP mode */ - dev->header_ops = NULL; /* No header */ - dev->type = ARPHRD_RAWIP; - dev->hard_header_len = 0; - dev->flags |= IFF_NOARP | IFF_PROMISC; - dev->flags &= ~(IFF_BROADCAST | IFF_MULTICAST); - dev->addr_len = ETH_ALEN; - eth_hw_addr_random(dev); -#else - ether_setup(dev); - dev->flags |= IFF_PROMISC; -#endif -} - -static ssize_t sipa_eth_get_direct_mode(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct net_device *netdev = to_net_dev(dev); - struct SIPA_ETH *sipa_eth = netdev_priv(netdev); - - - if (sipa_eth->pdata->term_type == 0x0) - return sprintf(buf, "\n %s in mode: normal\n", sipa_eth->netdev->name); - else if (sipa_eth->pdata->term_type == 0x6) - return sprintf(buf, "\n %s in mode: direct\n", sipa_eth->netdev->name); - else - return sprintf(buf, "\n %s in mode: illegal\n", sipa_eth->netdev->name); -} - -static ssize_t sipa_eth_set_direct_mode(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - struct net_device *netdev = to_net_dev(dev); - struct SIPA_ETH *sipa_eth = netdev_priv(netdev); - - if (!strncmp(buf, "normal", count - 1)) { - sipa_eth->pdata->term_type = 0x0; - } else if (!strncmp(buf, "direct", count - 1)) { -#ifndef CONFIG_SPRD_ETHERNET - sipa_eth->pdata->term_type = 0x6; -#else - pr_info("mode only can be set as normal when CONFIG_SPRD_ETHERNET is enabled!\n"); - return -EINVAL; -#endif - } else { - return -EINVAL; - } - - return count; -} - -static DEVICE_ATTR(mode, 0664, sipa_eth_get_direct_mode, sipa_eth_set_direct_mode); - -static struct attribute *sipa_eth_attributes[] = { - &dev_attr_mode.attr, - NULL, -}; - -static struct attribute_group sipa_eth_attribute_group = { - .attrs = sipa_eth_attributes, -}; - -static rx_handler_result_t sipa_eth_rx_handler(struct sk_buff **pskb) -{ - struct sk_buff *skb = *pskb; - struct rmnet_nss_cb *nss_cb; - - if (!skb) - return RX_HANDLER_CONSUMED; - - //printk("%s skb=%p, len=%d, protocol=%x, hdr_len=%d\n", __func__, skb, skb->len, skb->protocol, skb->hdr_len); - - /* Check this so that we dont loop around netif_receive_skb */ - - if (skb->cb[0] == 1) { - skb->cb[0] = 0; - - return RX_HANDLER_PASS; - } - - rmnet_nss_dereference(nss_cb); - if (nss_cb) { - nss_cb->nss_tx(skb); - return RX_HANDLER_CONSUMED; - } - - return RX_HANDLER_PASS; -} - -static int sipa_eth_probe(struct platform_device *pdev) -{ - struct sipa_eth_netid_device *netid_dev_info = NULL; - struct sipa_eth_init_data *pdata = pdev->dev.platform_data; - struct net_device *netdev; - struct SIPA_ETH *sipa_eth; - char ifname[IFNAMSIZ]; - struct rmnet_nss_cb *nss_cb; - int ret; - -#if (LINUX_VERSION_CODE >= KERNEL_VERSION( 3,11,0 )) - if (pdev->dev.of_node && !pdata) { - ret = sipa_eth_parse_dt(&pdata, &pdev->dev); - if (ret) { - pr_err("failed to parse device tree, ret=%d\n", ret); - return ret; - } - pdev->dev.platform_data = pdata; - } -#endif - - rmnet_nss_dereference(nss_cb); - strlcpy(ifname, pdata->name, IFNAMSIZ); -#ifdef NET_NAME_PREDICTABLE - netdev = alloc_netdev( - sizeof(struct SIPA_ETH), - ifname, - NET_NAME_PREDICTABLE, - s_setup); -#else - netdev = alloc_netdev( - sizeof(struct SIPA_ETH), - ifname, - s_setup); -#endif - - if (!netdev) { - pr_err("alloc_netdev() failed.\n"); - return -ENOMEM; - } - - sipa_eth = netdev_priv(netdev); - sipa_eth_dt_stats_init(&sipa_eth->dt_stats); - sipa_eth->netdev = netdev; - sipa_eth->pdata = pdata; - atomic_set(&sipa_eth->rx_busy, 0); - atomic_set(&sipa_eth->rx_evt, 0); - netdev->netdev_ops = &sipa_eth_ops; - netdev->watchdog_timeo = 1 * HZ; - netdev->irq = 0; - netdev->dma = 0; - netdev->features &= ~(NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | NETIF_F_HW_CSUM); - random_ether_addr(netdev->dev_addr); - netdev->sysfs_groups[0] = &sipa_eth_attribute_group; - - netif_napi_add(netdev, - &sipa_eth->napi, - sipa_eth_rx_poll_handler, - SIPA_ETH_NAPI_WEIGHT); - - /* Register new Ethernet interface */ - ret = register_netdev(netdev); - if (ret) { - pr_err("register_netdev() failed (%d)\n", ret); - netif_napi_del(&sipa_eth->napi); - free_netdev(netdev); - return ret; - } - - sipa_eth->state = DEV_OFF; - /* Set link as disconnected */ - netif_carrier_off(netdev); - platform_set_drvdata(pdev, sipa_eth); - sipa_eth_debugfs_mknod(root, (void *)sipa_eth); - - if (!strncmp(netdev->name, SIPA_ETH_VPCIE_PREF, strlen(SIPA_ETH_VPCIE_PREF))) { - netid_dev_info = kzalloc(sizeof(*netid_dev_info), GFP_ATOMIC); - if (!netid_dev_info) - return -ENOMEM; - - if (nss_cb) { - int rc = nss_cb->nss_create(netdev); - if (rc) { - /* Log, but don't fail the device creation */ - netdev_err(netdev, "Device will not use NSS path: %d\n", rc); - } else { - netdev_info(netdev, "NSS context created\n"); - rtnl_lock(); - netdev_rx_handler_register(netdev, sipa_eth_rx_handler, NULL); - rtnl_unlock(); - } - } - - netid_dev_info->ndev = netdev; - netid_dev_info->napi = sipa_eth->napi; - netid_dev_info->state = DEV_OFF; - netid_dev_info->netid = pdata->netid; - dev_list[pdata->netid] = netid_dev_info; - } - //sysfs_create_group(&pdev->dev.kobj, &sipa_eth_attribute_group); - return 0; -} - -/* Cleanup Ethernet device driver. */ -static int sipa_eth_remove(struct platform_device *pdev) -{ - struct SIPA_ETH *sipa_eth = platform_get_drvdata(pdev); - struct rmnet_nss_cb *nss_cb; - rx_handler_func_t *rx_handler; - struct sipa_eth_init_data *pdata = pdev->dev.platform_data; - - - rmnet_nss_dereference(nss_cb); - rcu_read_lock(); - rx_handler = rcu_dereference(sipa_eth->netdev->rx_handler); - rcu_read_unlock(); - if (nss_cb && rx_handler == sipa_eth_rx_handler) { - rtnl_lock(); - netdev_rx_handler_unregister(sipa_eth->netdev); - rtnl_unlock(); - nss_cb->nss_free(sipa_eth->netdev); - } - - netif_napi_del(&sipa_eth->napi); - unregister_netdev(sipa_eth->netdev); - - if(dev_list[pdata->netid]) { - kfree(dev_list[pdata->netid]); - dev_list[pdata->netid] = NULL; - } - - if (!IS_ERR_OR_NULL(sipa_eth->subroot)) - debugfs_remove_recursive(sipa_eth->subroot); - free_netdev(sipa_eth->netdev); - return 0; -} - -#ifdef SPRD_PCIE_USE_DTS -static const struct of_device_id sipa_eth_match_table[] = { - { .compatible = "sprd,sipa_eth"}, - { } -}; -#endif - -static struct platform_driver sipa_eth_driver = { - .probe = sipa_eth_probe, - .remove = sipa_eth_remove, - .driver = { - .owner = THIS_MODULE, - .name = SIPA_ETH_IFACE_PREF, -#ifdef SPRD_PCIE_USE_DTS - .of_match_table = sipa_eth_match_table -#endif - } -}; - -#ifndef SPRD_PCIE_USE_DTS -static struct platform_device *sipa_eth_pdev[SIPA_ETH_NUM]; -static struct sipa_eth_init_data *sipa_eth_data[SIPA_ETH_NUM]; - -static int sipa_eth_platform_device_reigster(void) -{ - int retval = -ENOMEM; - int i; - - for(i = 0; i < SIPA_ETH_NUM; i++) { - sipa_eth_pdev[i] = platform_device_alloc(SIPA_ETH_IFACE_PREF, i); - if (!sipa_eth_pdev[i]) { - i--; - while (i >= 0) - platform_device_put(sipa_eth_pdev[i--]); - return retval; - } - } - - for (i = 0; i < SIPA_ETH_NUM; i++) { - sipa_eth_data[i] = kzalloc(sizeof(struct sipa_eth_init_data), GFP_KERNEL); - if (!sipa_eth_data[i]) { - retval = -ENOMEM; - goto err_add_pdata; - } - - snprintf(sipa_eth_data[i]->name, IFNAMSIZ, "%s%d", - SIPA_ETH_VPCIE_PREF, i); -#ifndef CONFIG_SPRD_ETHERNET - sipa_eth_data[i]->term_type = 0x6; -#else - sipa_eth_data[i]->term_type = 0x0; -#endif - sipa_eth_data[i]->netid = i; - sipa_eth_data[i]->mac_h = true; - - retval = platform_device_add_data(sipa_eth_pdev[i], sipa_eth_data[i], - sizeof(struct sipa_eth_init_data)); - if (retval) - goto err_add_pdata; - } - - for (i = 0; i < SIPA_ETH_NUM; i++) { - retval = platform_device_add(sipa_eth_pdev[i]); - if (retval < 0) { - i--; - while (i >= 0) - platform_device_del(sipa_eth_pdev[i]); - goto err_add_pdata; - } - } - - return retval; -err_add_pdata: - for (i = 0; i < SIPA_ETH_NUM; i++) { - if(sipa_eth_data[i]) - kfree(sipa_eth_data[i]); - } - for (i = 0; i < SIPA_ETH_NUM; i++) - platform_device_put(sipa_eth_pdev[i]); - return retval; -} - -static void sipa_eth_platform_device_unreigster(void) -{ - int i; - - for (i = 0; i < SIPA_ETH_NUM; i++) { - struct sipa_eth_init_data *init_data; - - init_data = dev_get_platdata(&sipa_eth_pdev[i]->dev); - platform_device_unregister(sipa_eth_pdev[i]); - } - - if (!IS_ERR_OR_NULL(root)) - debugfs_remove_recursive(root); - -} -#endif - -static int sipa_eth_debug_show(struct seq_file *m, void *v) -{ - struct SIPA_ETH *sipa_eth = (struct SIPA_ETH *)(m->private); - struct sipa_eth_dtrans_stats *stats; - struct sipa_eth_init_data *pdata; - int i; - - if (!sipa_eth) { - pr_err("invalid data, sipa_eth is NULL\n"); - return -EINVAL; - } - pdata = sipa_eth->pdata; - stats = &sipa_eth->dt_stats; - - seq_puts(m, "*************************************************\n"); - seq_printf(m, "DEVICE: %s, term_type %d, netid %d, state %s mac_h %d\n", - pdata->name, pdata->term_type, pdata->netid, - sipa_eth->state == DEV_ON ? "UP" : "DOWN", pdata->mac_h); - seq_puts(m, "\nRX statistics:\n"); - seq_printf(m, "rx_sum=%u, rx_cnt=%u\n", - stats->rx_sum, - stats->rx_cnt); - seq_printf(m, "rx_fail=%u\n", - stats->rx_fail); - - seq_printf(m, "rx_busy=%d\n", atomic_read(&sipa_eth->rx_busy)); - seq_printf(m, "rx_evt=%d\n", atomic_read(&sipa_eth->rx_evt)); - - seq_puts(m, "\nTX statistics:\n"); - seq_printf(m, "tx_sum=%u, tx_cnt=%u\n", - stats->tx_sum, - stats->tx_cnt); - seq_printf(m, "tx_fail=%u\n", - stats->tx_fail); - - for (i = 0; i < SIPA_DUMMY_IFACE_NUM; i++) { - if(dev_list[i] == NULL) { - break; - } - seq_printf(m, "dev %s, netid %d state %d\n", - dev_list[i]->ndev->name, dev_list[i]->netid, dev_list[i]->state); - } - - seq_puts(m, "*************************************************\n"); - - return 0; -} - -static int sipa_eth_debug_open(struct inode *inode, struct file *file) -{ - return single_open(file, sipa_eth_debug_show, inode->i_private); -} - -static const struct file_operations sipa_eth_debug_fops = { - .open = sipa_eth_debug_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static int debugfs_gro_enable_get(void *data, u64 *val) -{ - *val = *(u64 *)data; - return 0; -} - -static int debugfs_gro_enable_set(void *data, u64 val) -{ - *(u64 *)data = val; - return 0; -} - -DEFINE_SIMPLE_ATTRIBUTE(fops_gro_enable, - debugfs_gro_enable_get, - debugfs_gro_enable_set, - "%llu\n"); - -static int sipa_eth_debugfs_mknod(void *root, void *data) -{ - struct SIPA_ETH *sipa_eth = (struct SIPA_ETH *)data; - struct dentry *subroot; - - if (!sipa_eth) - return -ENODEV; - - if (!root) - return -ENXIO; - subroot = debugfs_create_dir(sipa_eth->netdev->name, (struct dentry *)root); - if (!subroot) - return -ENOMEM; - - sipa_eth->subroot = subroot; - debugfs_create_file("stats", - 0444, - subroot, - data, - &sipa_eth_debug_fops); - - debugfs_create_file("gro_enable", - 0600, - (struct dentry *)root, - &gro_enable, - &fops_gro_enable); - - return 0; -} - -static void __init sipa_eth_debugfs_init(void) -{ - root = debugfs_create_dir(SIPA_ETH_IFACE_PREF, NULL); - if (!root) - pr_err("failed to create sipa_eth debugfs dir\n"); -} - -#ifdef CONFIG_QCA_NSS_DRV -/* - EXTRA_CFLAGS="-I$(STAGING_DIR)/usr/include/qca-nss-drv $(EXTRA_CFLAGS)" - qsdk/qca/src/data-kernel/drivers/rmnet-nss/rmnet_nss.c -*/ -#include "rmnet_nss.c" -#endif - -int sipa_eth_init(void) -{ - sipa_eth_debugfs_init(); - - RCU_INIT_POINTER(rmnet_nss_callbacks, NULL); -#ifdef CONFIG_QCA_NSS_DRV - if (qca_nss_enabled) - rmnet_nss_init(); -#endif - -#ifndef SPRD_PCIE_USE_DTS - sipa_eth_platform_device_reigster(); -#endif - return platform_driver_register(&sipa_eth_driver); -} -EXPORT_SYMBOL(sipa_eth_init); - -void sipa_eth_exit(void) -{ - int i; -#ifdef CONFIG_QCA_NSS_DRV - if (qca_nss_enabled) - rmnet_nss_exit(); -#endif - platform_driver_unregister(&sipa_eth_driver); -#ifndef SPRD_PCIE_USE_DTS - sipa_eth_platform_device_unreigster(); -#endif - for (i = 0; i < SIPA_ETH_NUM; i++) { - if(sipa_eth_data[i]){ - kfree(sipa_eth_data[i]); - } - } -} -EXPORT_SYMBOL(sipa_eth_exit); diff --git a/quectel_SRPD_PCIE/src/sipa/sipa_eth.h b/quectel_SRPD_PCIE/src/sipa/sipa_eth.h deleted file mode 100644 index 0519225..0000000 --- a/quectel_SRPD_PCIE/src/sipa/sipa_eth.h +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef _SIPA_ETH_H_ -#define _SIPA_ETH_H_ - -#include "../include/sipa.h" -#include - -#define SIPA_ETH_NUM 2 -#define SIPA_DUMMY_IFACE_NUM 4 - -/* Struct of data transfer statistics */ -struct sipa_eth_dtrans_stats { - u32 rx_sum; - u32 rx_cnt; - u32 rx_fail; - - u32 tx_sum; - u32 tx_cnt; - u32 tx_fail; -}; - -/* Device instance data. */ -struct SIPA_ETH { - int state; - atomic_t rx_busy; - atomic_t rx_evt; - struct net_device *netdev;/* Linux net device */ - enum sipa_nic_id nic_id; - struct napi_struct napi;/* Napi instance */ - /* Record data_transfer statistics */ - struct sipa_eth_dtrans_stats dt_stats; - struct net_device_stats stats;/* Net statistics */ - struct sipa_eth_init_data *pdata;/* Platform data */ - struct dentry *subroot; -}; - -struct sipa_eth_init_data { - char name[IFNAMSIZ]; - unsigned char modem_mac[ETH_ALEN]; - u32 term_type; - s32 netid; - bool mac_h; -}; - -struct sipa_eth_netid_device { - int state; - int netid; - struct net_device *ndev; - struct napi_struct napi;/* Napi instance */ - /* Record data_transfer statistics */ - struct net_device_stats stats;/* Net statistics */ -}; - -/* Device instance data. */ -struct SIPA_DUMMY { - atomic_t rx_busy; - atomic_t rx_evt; - struct net_device *netdev;/* Linux net device */ - struct napi_struct napi;/* Napi instance */ - struct net_device_stats stats;/* Net statistics */ -}; - -void sipa_dummy_recv_trigger(void); - -#endif - diff --git a/quectel_SRPD_PCIE/src/sipa/sipa_nic.c b/quectel_SRPD_PCIE/src/sipa/sipa_nic.c deleted file mode 100644 index 6a69b0d..0000000 --- a/quectel_SRPD_PCIE/src/sipa/sipa_nic.c +++ /dev/null @@ -1,332 +0,0 @@ -/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 and - * only version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "../include/sipa.h" -#include "sipa_core.h" - -#define SIPA_CP_SRC ((1 << SIPA_TERM_CP0) | \ - (1 << SIPA_TERM_CP1) | (1 << SIPA_TERM_VCP) | \ - (1 << 0x19) | (1 << 0x18)) - -struct sipa_nic_statics_info { - u32 src_mask; - int netid; -}; - -static struct sipa_nic_statics_info s_spia_nic_statics[SIPA_NIC_MAX] = { - { - .src_mask = SIPA_CP_SRC, - .netid = 0, - }, - { - .src_mask = SIPA_CP_SRC, - .netid = 1, - }, - { - .src_mask = SIPA_CP_SRC, - .netid = 2, - }, - { - .src_mask = SIPA_CP_SRC, - .netid = 3, - }, - { - .src_mask = SIPA_CP_SRC, - .netid = 4, - }, - { - .src_mask = SIPA_CP_SRC, - .netid = 5, - }, - { - .src_mask = SIPA_CP_SRC, - .netid = 6, - }, - { - .src_mask = SIPA_CP_SRC, - .netid = 7, - }, - { - .src_mask = SIPA_CP_SRC, - .netid = 8, - }, - { - .src_mask = SIPA_CP_SRC, - .netid = 9, - }, -}; - -int sipa_nic_open(enum sipa_term_type src, int netid, - sipa_notify_cb cb, void *priv) -{ - struct sipa_nic *nic = NULL; - struct sk_buff *skb; - enum sipa_nic_id nic_id = SIPA_NIC_MAX; - struct sipa_core *ctrl = sipa_get_ctrl_pointer(); - - if (!ctrl) { - return -EINVAL; - } - - if(!ctrl->remote_ready) - return -EINVAL; - - nic_id = netid; - dev_info(ctrl->dev, "open nic_id = %d\n", nic_id); - if (nic_id == SIPA_NIC_MAX) - return -EINVAL; - - if (ctrl->nic[nic_id]) { - nic = ctrl->nic[nic_id]; - if (atomic_read(&nic->status) == NIC_OPEN) - return -EBUSY; - while ((skb = skb_dequeue(&nic->rx_skb_q)) != NULL) - dev_kfree_skb_any(skb); - } else { - nic = kzalloc(sizeof(*nic), GFP_KERNEL); - if (!nic) - return -ENOMEM; - ctrl->nic[nic_id] = nic; - skb_queue_head_init(&nic->rx_skb_q); - } - - atomic_set(&nic->status, NIC_OPEN); - nic->nic_id = nic_id; - nic->send_ep = &ctrl->ep; - nic->need_notify = 0; - nic->src_mask = s_spia_nic_statics[nic_id].src_mask; - nic->netid = netid; - nic->cb = cb; - nic->cb_priv = priv; - nic->continue_notify = true; - - /* every receiver may receive cp packets */ - //sipa_receiver_add_nic(ctrl->receiver, nic); - sipa_skb_sender_add_nic(ctrl->sender, nic); - - return nic_id; -} -EXPORT_SYMBOL(sipa_nic_open); - -void sipa_nic_close(enum sipa_nic_id nic_id) -{ - struct sipa_nic *nic = NULL; - struct sk_buff *skb; - struct sipa_core *ctrl = sipa_get_ctrl_pointer(); - - if (!ctrl) { - dev_err(ctrl->dev, "sipa driver may not register\n"); - return; - } - - if (nic_id == SIPA_NIC_MAX || !ctrl->nic[nic_id]) - return; - - nic = ctrl->nic[nic_id]; - nic->continue_notify = false; - atomic_set(&nic->status, NIC_CLOSE); - /* free all pending skbs */ - while ((skb = skb_dequeue(&nic->rx_skb_q)) != NULL) - dev_kfree_skb_any(skb); - - sipa_skb_sender_remove_nic(ctrl->sender, nic); - dev_info(ctrl->dev, "close nic_id = %d\n", nic_id); -} -EXPORT_SYMBOL(sipa_nic_close); - -void sipa_nic_notify_evt(struct sipa_nic *nic, enum sipa_evt_type evt) -{ - struct sipa_core *ipa = sipa_get_ctrl_pointer(); - if (!ipa->remote_ready) { - return; - } - - if (nic->cb) - nic->cb(nic->cb_priv, evt, 0); -} -EXPORT_SYMBOL(sipa_nic_notify_evt); - -void sipa_nic_check_flow_ctrl(void) -{ - int i; - struct sipa_nic *nic; - struct sipa_core *ipa = sipa_get_ctrl_pointer(); - - for (i = 0; i < SIPA_NIC_MAX; i++) { - nic = ipa->nic[i]; - if (nic && nic->rm_flow_ctrl) { - nic->rm_flow_ctrl = false; - nic->cb(nic->cb_priv, SIPA_LEAVE_FLOWCTRL, 0); - } - } -} -EXPORT_SYMBOL(sipa_nic_check_flow_ctrl); - -void sipa_nic_try_notify_recv(struct sipa_nic *nic) -{ - if (atomic_read(&nic->status) == NIC_CLOSE) - return; - - if (nic->cb) - nic->cb(nic->cb_priv, SIPA_RECEIVE, 0); -} -EXPORT_SYMBOL(sipa_nic_try_notify_recv); - -void sipa_nic_push_skb(struct sipa_nic *nic, struct sk_buff *skb) -{ - struct sipa_core *ctrl = sipa_get_ctrl_pointer(); - - atomic_inc(&ctrl->recv_cnt); - skb_queue_tail(&nic->rx_skb_q, skb); - if (nic->rx_skb_q.qlen == 1 || nic->continue_notify) - nic->need_notify = 1; -} -EXPORT_SYMBOL(sipa_nic_push_skb); - -int sipa_nic_tx(enum sipa_nic_id nic_id, enum sipa_term_type dst, - int netid, struct sk_buff *skb) -{ - int ret; - struct sipa_core *ctrl = sipa_get_ctrl_pointer(); - - if (!ctrl || !ctrl->sender) { - dev_err(ctrl->dev, "sipa driver may not register\n"); - return -EINVAL; - } - - if (!ctrl->remote_ready) { - ctrl->nic[nic_id]->rm_flow_ctrl = true; -// dev_err(ctrl->dev, "remote ipa not ready\n"); - return -EINPROGRESS; - } - - ret = sipa_skb_sender_send_data(ctrl->sender, skb, dst, netid); -// if (ret == -EAGAIN) -// ctrl->nic[nic_id]->flow_ctrl_status = true; - - return ret; -} -EXPORT_SYMBOL(sipa_nic_tx); - -int sipa_nic_rx(int *netid, struct sk_buff **out_skb, int index) -{ - struct sk_buff *skb; - - skb = sipa_recv_skb(netid, index); - *out_skb = skb; - - return (skb) ? 0 : -ENODATA; -} -EXPORT_SYMBOL(sipa_nic_rx); - -int sipa_nic_rx_has_data(enum sipa_nic_id nic_id) -{ - struct sipa_nic *nic; - struct sipa_core *ctrl = sipa_get_ctrl_pointer(); - - if (!ctrl) { - pr_err("sipa driver may not register\n"); - return -EINVAL; - } - if (!ctrl->nic[nic_id] || - atomic_read(&ctrl->nic[nic_id]->status) == NIC_CLOSE) - return 0; - - nic = ctrl->nic[nic_id]; - - return (!!nic->rx_skb_q.qlen); -} -EXPORT_SYMBOL(sipa_nic_rx_has_data); - -int sipa_nic_trigger_flow_ctrl_work(enum sipa_nic_id nic_id, int err) -{ - struct sipa_core *ctrl = sipa_get_ctrl_pointer(); - - if (!ctrl) { - pr_err("sipa driver may not register\n"); - return -EINVAL; - } - - if (!ctrl->sender) - return -ENODEV; - - switch (err) { - case -EAGAIN: - //ctrl->sender->free_notify_net = true; - schedule_work(&ctrl->flow_ctrl_work); - break; - default: - dev_warn(ctrl->dev, - "don't have this flow ctrl err type\n"); - break; - } - - return 0; -} -EXPORT_SYMBOL(sipa_nic_trigger_flow_ctrl_work); - -u32 sipa_nic_get_filled_num(void) -{ - struct sipa_core *ctrl = sipa_get_ctrl_pointer(); - enum sipa_cmn_fifo_index id = ctrl->receiver->ep->recv_fifo->fifo_id; - - if (!ctrl->remote_ready) { - dev_err(ctrl->dev, "remote sipa not ready %d\n", - ctrl->remote_ready); - return 0; - } - - return ctrl->hal_ops.recv_node_from_tx_fifo(ctrl->dev, id, - ctrl->cmn_fifo_cfg, -1); -} -EXPORT_SYMBOL(sipa_nic_get_filled_num); - -void sipa_nic_restore_irq(void) -{ - struct sipa_core *ctrl = sipa_get_ctrl_pointer(); - enum sipa_cmn_fifo_index id = ctrl->receiver->ep->recv_fifo->fifo_id; - - if (!ctrl->remote_ready) { - dev_err(ctrl->dev, "remote sipa not ready %d\n", - ctrl->remote_ready); - return; - } - - ctrl->hal_ops.clr_tout_th_intr(id, ctrl->cmn_fifo_cfg); - ctrl->hal_ops.set_intr_eb(id, ctrl->cmn_fifo_cfg, true, - SIPA_FIFO_THRESHOLD_IRQ_EN | - SIPA_FIFO_DELAY_TIMER_IRQ_EN); -} -EXPORT_SYMBOL(sipa_nic_restore_irq); - -void sipa_nic_set_tx_fifo_rp(u32 rptr) -{ - struct sipa_core *ctrl = sipa_get_ctrl_pointer(); - enum sipa_cmn_fifo_index id = ctrl->receiver->ep->recv_fifo->fifo_id; - - if (!ctrl->remote_ready) { - dev_err(ctrl->dev, "remote sipa not ready %d\n", - ctrl->remote_ready); - return; - } - - ctrl->hal_ops.set_tx_fifo_rp(id, ctrl->cmn_fifo_cfg, rptr); -} -EXPORT_SYMBOL(sipa_nic_set_tx_fifo_rp); diff --git a/quectel_SRPD_PCIE/src/sipa/sipa_phy_v0/Makefile b/quectel_SRPD_PCIE/src/sipa/sipa_phy_v0/Makefile deleted file mode 100644 index dd44ed6..0000000 --- a/quectel_SRPD_PCIE/src/sipa/sipa_phy_v0/Makefile +++ /dev/null @@ -1 +0,0 @@ -obj-y += sipa_common_fifo_hal.o sipa_fifo_irq_hal.o diff --git a/quectel_SRPD_PCIE/src/sipa/sipa_phy_v0/sipa_common_fifo_hal.c b/quectel_SRPD_PCIE/src/sipa/sipa_phy_v0/sipa_common_fifo_hal.c deleted file mode 100644 index 5121968..0000000 --- a/quectel_SRPD_PCIE/src/sipa/sipa_phy_v0/sipa_common_fifo_hal.c +++ /dev/null @@ -1,1234 +0,0 @@ -#include -#include - -#include "../../include/sipa.h" -#include "../sipa_core.h" -#include "sipa_fifo_phy.h" - -#define PTR_MASK(depth) (depth | (depth - 1)) - -static inline int -ipa_put_pkt_to_cache_rx_fifo(struct device *dev, - struct sipa_cmn_fifo_cfg_tag *fifo_cfg, - struct sipa_node_description_tag *desc, - u32 num) -{ - dma_addr_t dma_addr; - u32 tmp = 0, tmp1 = 0, ret = 0, index = 0, left_cnt = 0; - ssize_t node_size = sizeof(struct sipa_node_description_tag); - struct sipa_node_description_tag *node = - (struct sipa_node_description_tag *) - fifo_cfg->rx_fifo.virtual_addr; - - dma_addr = fifo_cfg->rx_fifo.fifo_base_addr_l; - - left_cnt = fifo_cfg->rx_fifo.depth - - ipa_phy_get_rx_fifo_filled_depth(fifo_cfg->fifo_reg_base); - - if (!left_cnt) - return -ENOSPC; - - if (left_cnt < num) - num = left_cnt; - - index = fifo_cfg->rx_fifo.wr & (fifo_cfg->rx_fifo.depth - 1); - if (index + num <= fifo_cfg->rx_fifo.depth) { - memcpy(node + index, desc, node_size * num); - } else { - tmp = fifo_cfg->rx_fifo.depth - index; - memcpy(node + index, desc, tmp * node_size); - tmp1 = num - tmp; - memcpy(node, desc + tmp, tmp1 * node_size); - } - - fifo_cfg->rx_fifo.wr = (fifo_cfg->rx_fifo.wr + num) & - PTR_MASK(fifo_cfg->rx_fifo.depth); - smp_wmb(); - ret = ipa_phy_update_rx_fifo_wptr(fifo_cfg->fifo_reg_base, - fifo_cfg->rx_fifo.wr); - - if (!ret) - pr_err("sipa_phy_update_rx_fifo_rptr fail\n"); - - return num; -} - -static inline u32 -ipa_recv_pkts_from_tx_fifo(struct device *dev, - struct sipa_cmn_fifo_cfg_tag *fifo_cfg, - u32 num) -{ - return ipa_phy_get_tx_fifo_filled_depth(fifo_cfg->fifo_reg_base); -} - -static int ipa_common_fifo_hal_open(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - void *cookie) -{ - struct sipa_cmn_fifo_cfg_tag *ipa_term_fifo = NULL; - - if (likely(id < SIPA_FIFO_MAX)) { - ipa_term_fifo = cfg_base + id; - } else { - pr_err("sipa don't have this id %d\n", id); - return -EINVAL; - } - - if (ipa_term_fifo->state) { - pr_err("sipa fifo_id = %d has already opened state = %d\n", - ipa_term_fifo->fifo_id, ipa_term_fifo->state); - return -EBUSY; - } - - ipa_phy_set_rx_fifo_total_depth(ipa_term_fifo->fifo_reg_base, - ipa_term_fifo->rx_fifo.depth); - ipa_phy_set_rx_fifo_addr(ipa_term_fifo->fifo_reg_base, - ipa_term_fifo->rx_fifo.fifo_base_addr_l, - ipa_term_fifo->rx_fifo.fifo_base_addr_h); - - ipa_phy_set_tx_fifo_total_depth(ipa_term_fifo->fifo_reg_base, - ipa_term_fifo->tx_fifo.depth); - ipa_phy_set_tx_fifo_addr(ipa_term_fifo->fifo_reg_base, - ipa_term_fifo->tx_fifo.fifo_base_addr_l, - ipa_term_fifo->tx_fifo.fifo_base_addr_h); - - ipa_phy_set_cur_term_num(ipa_term_fifo->fifo_reg_base, - ipa_term_fifo->cur); - ipa_phy_set_dst_term_num(ipa_term_fifo->fifo_reg_base, - ipa_term_fifo->dst); - - ipa_phy_update_rx_fifo_rptr(ipa_term_fifo->fifo_reg_base, 0); - ipa_phy_update_rx_fifo_wptr(ipa_term_fifo->fifo_reg_base, 0); - ipa_phy_update_tx_fifo_rptr(ipa_term_fifo->fifo_reg_base, 0); - ipa_phy_update_tx_fifo_wptr(ipa_term_fifo->fifo_reg_base, 0); - ipa_phy_clear_stop_receive(ipa_term_fifo->fifo_reg_base); - - ipa_term_fifo->rx_fifo.rd = 0; - ipa_term_fifo->rx_fifo.wr = 0; - ipa_term_fifo->tx_fifo.rd = 0; - ipa_term_fifo->tx_fifo.wr = 0; - - ipa_term_fifo->fifo_name = cookie; - ipa_term_fifo->state = true; - - return 0; -} - -static int ipa_common_fifo_hal_close(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base) -{ - struct sipa_cmn_fifo_cfg_tag *ipa_term_fifo; - - if (likely(id < SIPA_FIFO_MAX)) { - ipa_term_fifo = cfg_base + id; - } else { - pr_err("sipa don't have this id %d\n", id); - return -EINVAL; - } - - ipa_phy_set_rx_fifo_total_depth(ipa_term_fifo->fifo_reg_base, 0); - ipa_phy_set_tx_fifo_total_depth(ipa_term_fifo->fifo_reg_base, 0); - - ipa_phy_update_rx_fifo_rptr(ipa_term_fifo->fifo_reg_base, 0); - ipa_phy_update_rx_fifo_wptr(ipa_term_fifo->fifo_reg_base, 0); - ipa_phy_update_tx_fifo_rptr(ipa_term_fifo->fifo_reg_base, 0); - ipa_phy_update_tx_fifo_wptr(ipa_term_fifo->fifo_reg_base, 0); - - ipa_term_fifo->rx_fifo.rd = 0; - ipa_term_fifo->rx_fifo.wr = 0; - ipa_term_fifo->tx_fifo.rd = 0; - ipa_term_fifo->tx_fifo.wr = 0; - - ipa_term_fifo->state = 0; - - return 0; -} - -static int -ipa_common_fifo_hal_set_rx_depth(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - u32 depth) -{ - struct sipa_cmn_fifo_cfg_tag *ipa_term_fifo; - - if (likely(id < SIPA_FIFO_MAX)) { - ipa_term_fifo = cfg_base + id; - } else { - pr_err("sipa don't have this id %d\n", id); - return -EINVAL; - } - - return ipa_phy_set_rx_fifo_total_depth(ipa_term_fifo->fifo_reg_base, - depth); -} - -static u32 -ipa_common_fifo_hal_get_rx_depth(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base) -{ - struct sipa_cmn_fifo_cfg_tag *ipa_term_fifo; - - if (likely(id < SIPA_FIFO_MAX)) { - ipa_term_fifo = cfg_base + id; - } else { - pr_err("sipa don't have this id %d\n", id); - return 0; - } - - return ipa_phy_get_rx_fifo_total_depth(ipa_term_fifo->fifo_reg_base); -} - -static int -ipa_common_fifo_hal_set_tx_depth(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - u32 depth) -{ - struct sipa_cmn_fifo_cfg_tag *ipa_term_fifo; - - if (likely(id < SIPA_FIFO_MAX)) { - ipa_term_fifo = cfg_base + id; - } else { - pr_err("sipa don't have this id %d\n", id); - return 0; - } - - return ipa_phy_set_tx_fifo_total_depth(ipa_term_fifo->fifo_reg_base, - depth); -} - -static u32 -ipa_common_fifo_hal_get_tx_depth(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base) -{ - struct sipa_cmn_fifo_cfg_tag *ipa_term_fifo; - - if (likely(id < SIPA_FIFO_MAX)) { - ipa_term_fifo = cfg_base + id; - } else { - pr_err("sipa don't have this id %d\n", id); - return 0; - } - - return ipa_phy_get_tx_fifo_total_depth(ipa_term_fifo->fifo_reg_base); -} - -static int -ipa_common_fifo_hal_set_intr_drop_packet(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - u32 enable, sipa_irq_notify_cb cb) -{ - struct sipa_cmn_fifo_cfg_tag *ipa_term_fifo; - - if (likely(id < SIPA_FIFO_MAX)) { - ipa_term_fifo = cfg_base + id; - } else { - pr_err("sipa don't have this id %d\n", id); - return -EINVAL; - } - - if (enable) - return ipa_phy_enable_int_bit(ipa_term_fifo->fifo_reg_base, - IPA_DROP_PACKET_OCCUR_INT_EN); - else - return ipa_phy_disable_int_bit(ipa_term_fifo->fifo_reg_base, - IPA_DROP_PACKET_OCCUR_INT_EN); -} - -static int -ipa_common_fifo_hal_set_intr_error_code(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - u32 enable, sipa_irq_notify_cb cb) -{ - struct sipa_cmn_fifo_cfg_tag *ipa_term_fifo; - - if (likely(id < SIPA_FIFO_MAX)) { - ipa_term_fifo = cfg_base + id; - } else { - pr_err("sipa don't have this id %d\n", id); - return -EINVAL; - } - - if (enable) - return ipa_phy_enable_int_bit(ipa_term_fifo->fifo_reg_base, - IPA_ERRORCODE_IN_TX_FIFO_EN); - else - return ipa_phy_disable_int_bit(ipa_term_fifo->fifo_reg_base, - IPA_ERRORCODE_IN_TX_FIFO_EN); -} - -static int -ipa_common_fifo_hal_set_intr_timeout(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - u32 enable, u32 time, - sipa_irq_notify_cb cb) -{ - int ret; - struct sipa_cmn_fifo_cfg_tag *ipa_term_fifo; - - if (likely(id < SIPA_FIFO_MAX)) { - ipa_term_fifo = cfg_base + id; - } else { - pr_err("sipa don't have this id %d\n", id); - return -EINVAL; - } - - if (enable) { - ret = ipa_phy_set_tx_fifo_interrupt_delay_timer( - ipa_term_fifo->fifo_reg_base, - time); - if (ret) - ret = ipa_phy_enable_int_bit( - ipa_term_fifo->fifo_reg_base, - IPA_TXFIFO_INT_DELAY_TIMER_SW_EN); - else - pr_err("fifo(%d) set timeout threshold fail\n", id); - } else { - ret = ipa_phy_disable_int_bit(ipa_term_fifo->fifo_reg_base, - IPA_TXFIFO_INT_DELAY_TIMER_SW_EN); - } - - return ret; -} - -static int -ipa_common_fifo_hal_set_hw_intr_timeout(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - u32 enable, u32 time, - sipa_irq_notify_cb cb) -{ - int ret; - struct sipa_cmn_fifo_cfg_tag *ipa_term_fifo; - - if (likely(id < SIPA_FIFO_MAX)) { - ipa_term_fifo = cfg_base + id; - } else { - pr_err("don't have this id %d\n", id); - return -EINVAL; - } - - if (enable) { - ret = ipa_phy_set_tx_fifo_interrupt_delay_timer( - ipa_term_fifo->fifo_reg_base, time); - if (!ret) - ret = ipa_phy_enable_int_bit( - ipa_term_fifo->fifo_reg_base, - IPA_TX_FIFO_DELAY_TIMER_EN); - else - pr_err("fifo(%d) set timeout threshold fail\n", id); - } else { - ret = ipa_phy_disable_int_bit(ipa_term_fifo->fifo_reg_base, - IPA_TX_FIFO_DELAY_TIMER_EN); - } - - return ret; -} - -static int -ipa_common_fifo_hal_set_intr_threshold(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - u32 enable, u32 cnt, - sipa_irq_notify_cb cb) -{ - int ret; - struct sipa_cmn_fifo_cfg_tag *ipa_term_fifo; - - if (likely(id < SIPA_FIFO_MAX)) { - ipa_term_fifo = cfg_base + id; - } else { - pr_err("don't have this id %d\n", id); - return -EINVAL; - } - - if (enable) { - ret = ipa_phy_set_tx_fifo_interrupt_threshold( - ipa_term_fifo->fifo_reg_base, cnt); - if (!ret) { - ret = ipa_phy_enable_int_bit( - ipa_term_fifo->fifo_reg_base, - IPA_TXFIFO_INT_THRESHOLD_ONESHOT_EN); - } else { - pr_err("fifo(%d) set threshold fail\n", id); - } - } else { - ret = - ipa_phy_disable_int_bit(ipa_term_fifo->fifo_reg_base, - IPA_TXFIFO_INT_THRESHOLD_ONESHOT_EN); - } - - return ret; -} - -static int -ipa_common_fifo_hal_set_hw_intr_thres(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - u32 enable, u32 cnt, - sipa_irq_notify_cb cb) -{ - int ret; - struct sipa_cmn_fifo_cfg_tag *ipa_term_fifo; - - if (likely(id < SIPA_FIFO_MAX)) { - ipa_term_fifo = cfg_base + id; - } else { - pr_err("don't have this id %d\n", id); - return -EINVAL; - } - - if (enable) { - ret = ipa_phy_set_tx_fifo_interrupt_threshold( - ipa_term_fifo->fifo_reg_base, cnt); - if (!ret) - ret = ipa_phy_enable_int_bit( - ipa_term_fifo->fifo_reg_base, - IPA_TX_FIFO_THRESHOLD_EN); - else - pr_err("fifo(%d) set threshold fail\n", id); - } else { - ret = ipa_phy_disable_int_bit(ipa_term_fifo->fifo_reg_base, - IPA_TX_FIFO_THRESHOLD_EN); - } - - return ret; -} - -static int -ipa_common_fifo_hal_set_src_dst_term(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - u32 src, u32 dst) -{ - int ret; - struct sipa_cmn_fifo_cfg_tag *ipa_term_fifo; - - if (likely(id < SIPA_FIFO_MAX)) { - ipa_term_fifo = cfg_base + id; - } else { - pr_err("don't have this id %d\n", id); - return -EINVAL; - } - - ret = ipa_phy_set_cur_term_num(ipa_term_fifo->fifo_reg_base, src); - if (ret) { - pr_err("fifo %d set cur failed\n", id); - return ret; - } - - ret = ipa_phy_set_dst_term_num(ipa_term_fifo->fifo_reg_base, dst); - if (ret) { - pr_err("fifo %d set dst failed\n", id); - return ret; - } - - return 0; -} - -static int -ipa_common_fifo_hal_enable_local_flowctrl_intr(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag * - cfg_base, u32 enable, - u32 irq_mode, - sipa_irq_notify_cb cb) -{ - int ret; - u32 irq; - struct sipa_cmn_fifo_cfg_tag *ipa_term_fifo; - - if (likely(id < SIPA_FIFO_MAX)) { - ipa_term_fifo = cfg_base + id; - } else { - pr_err("don't have this id %d\n", id); - return -EINVAL; - } - - switch (irq_mode) { - case 0: - irq = IPA_RX_FIFO_INT_EXIT_FLOW_CTRL_EN; - break; - case 1: - irq = IPA_RX_FIFO_INT_ENTER_FLOW_CTRL_EN; - break; - case 2: - irq = IPA_RX_FIFO_INT_EXIT_FLOW_CTRL_EN | - IPA_RX_FIFO_INT_ENTER_FLOW_CTRL_EN; - break; - default: - pr_err("don't have this %d irq type\n", irq_mode); - return -EINVAL; - } - - if (enable) { - ret = ipa_phy_enable_int_bit(ipa_term_fifo->fifo_reg_base, irq); - if (ret) { - pr_err("fifo_id = %d irq_mode = %d set failed\n", - id, irq); - return ret; - } - } else { - ret = ipa_phy_disable_int_bit(ipa_term_fifo->fifo_reg_base, - irq); - } - - return ret; -} - -static int -ipa_common_fifo_hal_enable_remote_flowctrl_intr(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag * - cfg_base, u32 work_mode, - u32 tx_entry_watermark, - u32 tx_exit_watermark, - u32 rx_entry_watermark, - u32 rx_exit_watermark) -{ - int ret; - struct sipa_cmn_fifo_cfg_tag *ipa_term_fifo; - - if (likely(id < SIPA_FIFO_MAX)) { - ipa_term_fifo = cfg_base + id; - } else { - pr_err("don't have this id %d\n", id); - return -EINVAL; - } - - ret = ipa_phy_set_tx_fifo_exit_flow_ctrl_watermark( - ipa_term_fifo->fifo_reg_base, tx_exit_watermark); - if (unlikely(!ret)) { - pr_err("fifo_id = %d tx_exit_watermark(0x%x) failed\n", - id, tx_exit_watermark); - return ret; - } - - ret = ipa_phy_set_tx_fifo_entry_flow_ctrl_watermark( - ipa_term_fifo->fifo_reg_base, tx_entry_watermark); - if (unlikely(!ret)) { - pr_err("fifo_id = %d tx_entry_watermark(0x%x) failed\n", - id, tx_entry_watermark); - return ret; - } - - ret = ipa_phy_set_rx_fifo_exit_flow_ctrl_watermark( - ipa_term_fifo->fifo_reg_base, rx_exit_watermark); - if (unlikely(!ret)) { - pr_err("fifo_id = %d rx_exit_watermark(0x%x) failed\n", - id, rx_exit_watermark); - return ret; - } - - ret = ipa_phy_set_rx_fifo_entry_flow_ctrl_watermark( - ipa_term_fifo->fifo_reg_base, rx_entry_watermark); - if (unlikely(!ret)) { - pr_err("fifo_id = %d rx_entry_watermark(0x%x) failed\n", - id, rx_entry_watermark); - return ret; - } - - ret = ipa_phy_set_flow_ctrl_config(ipa_term_fifo->fifo_reg_base, - work_mode); - - return ret; -} - -static int -ipa_common_fifo_hal_set_interrupt_intr(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - u32 enable, - sipa_irq_notify_cb cb) -{ - int ret; - struct sipa_cmn_fifo_cfg_tag *ipa_term_fifo; - - if (likely(id < SIPA_FIFO_MAX)) { - ipa_term_fifo = cfg_base + id; - } else { - pr_err("don't have this id %d\n", id); - return -EINVAL; - } - - if (enable) { - ret = ipa_phy_enable_int_bit(ipa_term_fifo->fifo_reg_base, - IPA_TX_FIFO_INTR_SW_BIT_EN); - } else { - ret = ipa_phy_disable_int_bit(ipa_term_fifo->fifo_reg_base, - IPA_TX_FIFO_INTR_SW_BIT_EN); - } - - return ret; -} - -static int -ipa_common_fifo_hal_set_intr_txfifo_overflow(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag * - cfg_base, u32 enable, - sipa_irq_notify_cb cb) -{ - int ret; - struct sipa_cmn_fifo_cfg_tag *ipa_term_fifo; - - if (likely(id < SIPA_FIFO_MAX)) { - ipa_term_fifo = cfg_base + id; - } else { - pr_err("don't have this id %d\n", id); - return -EINVAL; - } - - if (enable) { - ret = ipa_phy_enable_int_bit(ipa_term_fifo->fifo_reg_base, - IPA_TXFIFO_OVERFLOW_EN); - } else { - ret = ipa_phy_disable_int_bit(ipa_term_fifo->fifo_reg_base, - IPA_TXFIFO_OVERFLOW_EN); - } - - return ret; -} - -static int -ipa_common_fifo_hal_set_intr_txfifo_full(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - u32 enable, sipa_irq_notify_cb cb) -{ - int ret; - struct sipa_cmn_fifo_cfg_tag *ipa_term_fifo; - - if (likely(id < SIPA_FIFO_MAX)) { - ipa_term_fifo = cfg_base + id; - } else { - pr_err("don't have this id %d\n", id); - return -EINVAL; - } - - if (enable) { - ret = ipa_phy_enable_int_bit(ipa_term_fifo->fifo_reg_base, - IPA_TXFIFO_FULL_INT_EN); - } else { - ret = ipa_phy_disable_int_bit(ipa_term_fifo->fifo_reg_base, - IPA_TXFIFO_FULL_INT_EN); - } - - return ret; -} - -/** - * Description: Receive Node from tx fifo. - * Input: - * @id: The FIFO id that need to be operated. - * @pkt: The node that need to be stored address. - * @num: The num of receive. - * OUTPUT: - * @The num that has be received from tx fifo successful. - * Note: - */ -static int -ipa_common_fifo_hal_put_node_to_rx_fifo(struct device *dev, - enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - struct sipa_node_description_tag *node, - u32 force_intr, u32 num) -{ - struct sipa_cmn_fifo_cfg_tag *ipa_term_fifo; - - if (likely(id < SIPA_FIFO_MAX)) { - ipa_term_fifo = cfg_base + id; - } else { - pr_err("don't have this id %d\n", id); - return -EINVAL; - } - - return ipa_put_pkt_to_cache_rx_fifo(dev, ipa_term_fifo, - node, num); -} - -static u32 -ipa_common_fifo_hal_get_left_cnt(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base) -{ - u32 left_cnt; - struct sipa_cmn_fifo_cfg_tag *ipa_term_fifo = NULL; - - if (likely(id < SIPA_FIFO_MAX)) { - ipa_term_fifo = cfg_base + id; - } else { - pr_err("don't have this id %d\n", id); - return 0; - } - - left_cnt = - ipa_phy_get_tx_fifo_total_depth(ipa_term_fifo->fifo_reg_base) - - ipa_phy_get_tx_fifo_filled_depth(ipa_term_fifo->fifo_reg_base); - - return left_cnt; -} - -/* - * Description: Send Node to rx fifo. - * Input: - * id: The FIFO id that need to be operated. - * pkt: The node address that need send to rx fifo. - * num: The number of need to send. - * OUTPUT: - * The number that has get from tx fifo successful. - * Note: - */ -static u32 -ipa_common_fifo_hal_recv_node_from_tx_fifo(struct device *dev, - enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag * - cfg_base, u32 num) -{ - struct sipa_cmn_fifo_cfg_tag *ipa_term_fifo; - - if (likely(id < SIPA_FIFO_MAX)) { - ipa_term_fifo = cfg_base + id; - } else { - pr_err("don't have this id %d\n", id); - return 0; - } - - return ipa_recv_pkts_from_tx_fifo(dev, ipa_term_fifo, num); -} - -static void -ipa_common_fifo_hal_get_rx_ptr(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - u32 *wr, u32 *rd) -{ - struct sipa_cmn_fifo_cfg_tag *ipa_term_fifo; - - if (likely(id < SIPA_FIFO_MAX)) { - ipa_term_fifo = cfg_base + id; - } else { - pr_err("don't have this id %d\n", id); - return; - } - - if (rd) - *rd = ipa_phy_get_rx_fifo_rptr(ipa_term_fifo->fifo_reg_base); - if (wr) - *wr = ipa_phy_get_rx_fifo_wptr(ipa_term_fifo->fifo_reg_base); -} - -static void -ipa_common_fifo_hal_get_tx_ptr(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - u32 *wr, u32 *rd) -{ - struct sipa_cmn_fifo_cfg_tag *ipa_term_fifo; - - if (likely(id < SIPA_FIFO_MAX)) { - ipa_term_fifo = cfg_base + id; - } else { - pr_err("don't have this id %d\n", id); - return; - } - - if (rd) - *rd = ipa_phy_get_tx_fifo_rptr(ipa_term_fifo->fifo_reg_base); - if (wr) - *wr = ipa_phy_get_tx_fifo_wptr(ipa_term_fifo->fifo_reg_base); -} - -static void -ipa_common_fifo_hal_get_filled_depth(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - u32 *rx_filled, u32 *tx_filled) -{ - struct sipa_cmn_fifo_cfg_tag *ipa_term_fifo; - void __iomem *reg_base; - - if (likely(id < SIPA_FIFO_MAX)) { - ipa_term_fifo = cfg_base + id; - } else { - pr_err("don't have this id %d\n", id); - return; - } - - reg_base = ipa_term_fifo->fifo_reg_base; - if (tx_filled) - *tx_filled = ipa_phy_get_tx_fifo_filled_depth(reg_base); - if (rx_filled) - *rx_filled = ipa_phy_get_rx_fifo_filled_depth(reg_base); -} - -static u32 -ipa_common_fifo_hal_get_tx_full_status(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base) -{ - struct sipa_cmn_fifo_cfg_tag *ipa_term_fifo; - - if (likely(id < SIPA_FIFO_MAX)) { - ipa_term_fifo = cfg_base + id; - } else { - pr_err("don't have this id %d\n", id); - return 0; - } - - return ipa_phy_get_tx_fifo_full_status(ipa_term_fifo->fifo_reg_base); -} - -static u32 -ipa_common_fifo_hal_get_tx_empty_status(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base) -{ - struct sipa_cmn_fifo_cfg_tag *ipa_term_fifo; - - if (likely(id < SIPA_FIFO_MAX)) { - ipa_term_fifo = cfg_base + id; - } else { - pr_err("don't have this id %d\n", id); - return 0; - } - - return ipa_phy_get_tx_fifo_empty_status(ipa_term_fifo->fifo_reg_base); -} - -static u32 -ipa_common_fifo_hal_get_rx_full_status(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base) -{ - struct sipa_cmn_fifo_cfg_tag *ipa_term_fifo; - - if (likely(id < SIPA_FIFO_MAX)) { - ipa_term_fifo = cfg_base + id; - } else { - pr_err("don't have this id %d\n", id); - return 0; - } - - return ipa_phy_get_rx_fifo_full_status(ipa_term_fifo->fifo_reg_base); -} - -static u32 -ipa_common_fifo_hal_get_rx_empty_status(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base) -{ - struct sipa_cmn_fifo_cfg_tag *ipa_term_fifo; - - if (likely(id < SIPA_FIFO_MAX)) { - ipa_term_fifo = cfg_base + id; - } else { - pr_err("don't have this id %d\n", id); - return 0; - } - - return ipa_phy_get_rx_fifo_empty_status(ipa_term_fifo->fifo_reg_base); -} - -static bool -ipa_common_fifo_hal_set_rx_fifo_wptr(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - u32 wptr) -{ - u32 ret; - u32 rx_wptr; - struct sipa_cmn_fifo_cfg_tag *ipa_term_fifo; - - if (likely(id < SIPA_FIFO_MAX)) { - ipa_term_fifo = cfg_base + id; - } else { - pr_err("don't have this id %d\n", id); - return false; - } - - rx_wptr = ipa_phy_get_rx_fifo_wptr(ipa_term_fifo->fifo_reg_base); - - if (wptr != rx_wptr) { - wptr = wptr & PTR_MASK(ipa_term_fifo->rx_fifo.depth); - ipa_term_fifo->rx_fifo.wr = wptr; - ret = ipa_phy_update_rx_fifo_wptr(ipa_term_fifo->fifo_reg_base, - wptr); - if (!ret) { - pr_err("fifo id = %d update rx fifo wptr = 0x%x failed !!!", - id, wptr); - return false; - } - } - - return true; -} - -static bool -ipa_common_fifo_hal_set_tx_fifo_wptr(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - u32 wptr) -{ - u32 ret; - u32 tx_wptr; - struct sipa_cmn_fifo_cfg_tag *ipa_term_fifo; - - if (likely(id < SIPA_FIFO_MAX)) { - ipa_term_fifo = cfg_base + id; - } else { - pr_err("don't have this id %d\n", id); - return false; - } - - tx_wptr = ipa_phy_get_tx_fifo_wptr(ipa_term_fifo->fifo_reg_base); - - if (wptr != tx_wptr) { - wptr = wptr & PTR_MASK(ipa_term_fifo->rx_fifo.depth); - ipa_term_fifo->tx_fifo.wr = wptr; - ret = ipa_phy_update_tx_fifo_wptr(ipa_term_fifo->fifo_reg_base, - wptr); - if (!ret) { - pr_err("fifo id = %d update tx fifo wptr = 0x%x failed !!!", - id, wptr); - return false; - } - } - - return true; -} - -static int -ipa_common_fifo_hal_set_rx_tx_fifo_ptr(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - u32 rx_rd, u32 rx_wr, - u32 tx_rd, u32 tx_wr) -{ - int ret = 0, ret1 = 0; - u32 rx_rptr = 0, rx_wptr = 0; - u32 tx_rptr = 0, tx_wptr = 0; - struct sipa_cmn_fifo_cfg_tag *ipa_term_fifo; - - if (likely(id < SIPA_FIFO_MAX)) { - ipa_term_fifo = cfg_base + id; - } else { - pr_err("don't have this id %d\n", id); - return -EINVAL; - } - - tx_wptr = ipa_phy_get_tx_fifo_wptr(ipa_term_fifo->fifo_reg_base); - tx_rptr = ipa_phy_get_tx_fifo_rptr(ipa_term_fifo->fifo_reg_base); - rx_wptr = ipa_phy_get_rx_fifo_wptr(ipa_term_fifo->fifo_reg_base); - rx_rptr = ipa_phy_get_rx_fifo_rptr(ipa_term_fifo->fifo_reg_base); - - if (rx_rd != rx_rptr) { - rx_rd = rx_rd & PTR_MASK(ipa_term_fifo->rx_fifo.depth); - ipa_term_fifo->rx_fifo.rd = rx_rd; - ret = ipa_phy_update_rx_fifo_rptr(ipa_term_fifo->fifo_reg_base, - rx_rd); - if (!ret) { - ret1 = -EIO; - pr_err("update rx fifo rptr = 0x%x failed !!!", rx_rd); - } - } - - if (rx_wr != rx_wptr) { - rx_wr = rx_wr & PTR_MASK(ipa_term_fifo->rx_fifo.depth); - ipa_term_fifo->rx_fifo.wr = rx_wr; - ret = ipa_phy_update_rx_fifo_wptr(ipa_term_fifo->fifo_reg_base, - rx_wr); - if (!ret) { - ret1 = -EIO; - pr_err("update rx fifo wptr = 0x%x failed !!!", rx_wr); - } - } - - if (tx_rd != tx_rptr) { - tx_rd = tx_rd & PTR_MASK(ipa_term_fifo->rx_fifo.depth); - ipa_term_fifo->tx_fifo.rd = tx_rd; - ret = ipa_phy_update_tx_fifo_rptr(ipa_term_fifo->fifo_reg_base, - tx_rd); - if (!ret) { - ret1 = -EIO; - pr_err("update tx fifo rptr = 0x%x failed !!!", tx_rd); - } - } - - if (tx_wr != tx_wptr) { - tx_wr = tx_wr & PTR_MASK(ipa_term_fifo->rx_fifo.depth); - ipa_term_fifo->tx_fifo.wr = tx_wr; - ret = ipa_phy_update_tx_fifo_wptr(ipa_term_fifo->fifo_reg_base, - tx_wr); - if (!ret) { - ret1 = -EIO; - pr_err("update tx fifo wptr = 0x%x failed !!!", tx_wr); - } - } - - return ret1; -} - -static int -ipa_common_fifo_hal_ctrl_receive(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - bool stop) -{ - struct sipa_cmn_fifo_cfg_tag *ipa_term_fifo; - - if (likely(id < SIPA_FIFO_MAX)) { - ipa_term_fifo = cfg_base + id; - } else { - pr_err("don't have this id %d\n", id); - return -EINVAL; - } - - if (stop) - return ipa_phy_stop_receive(ipa_term_fifo->fifo_reg_base); - else - return ipa_phy_clear_stop_receive(ipa_term_fifo->fifo_reg_base); -} - -static struct sipa_node_description_tag * -ipa_common_fifo_hal_get_tx_fifo_rp(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - u32 index) -{ - u32 tmp; - struct sipa_cmn_fifo_cfg_tag *fifo_cfg; - struct sipa_node_description_tag *node; - - if (unlikely(id >= SIPA_FIFO_MAX)) - return NULL; - - fifo_cfg = cfg_base + id; - node = (struct sipa_node_description_tag *) - fifo_cfg->tx_fifo.virtual_addr; - - if (unlikely(!node)) - return NULL; - - tmp = (fifo_cfg->tx_fifo.rd + index) & (fifo_cfg->tx_fifo.depth - 1); - - return node + tmp; -} - -static struct sipa_node_description_tag * -ipa_common_fifo_hal_get_rx_fifo_wr(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - u32 index) -{ - u32 tmp; - struct sipa_cmn_fifo_cfg_tag *fifo_cfg; - struct sipa_node_description_tag *node; - - if (unlikely(id >= SIPA_FIFO_MAX)) - return NULL; - - fifo_cfg = cfg_base + id; - node = (struct sipa_node_description_tag *) - fifo_cfg->rx_fifo.virtual_addr; - - if (unlikely(!node)) - return NULL; - - if (index >= fifo_cfg->rx_fifo.depth) - return NULL; - - tmp = (fifo_cfg->rx_fifo.wr + index) & (fifo_cfg->rx_fifo.depth - 1); - - return node + tmp; -} - -static int ipa_common_fifo_hal_set_tx_fifo_rp(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag * - cfg_base, u32 tx_rd) -{ - int ret; - struct sipa_cmn_fifo_cfg_tag *fifo_cfg; - - if (unlikely(id >= SIPA_FIFO_MAX)) - return -EINVAL; - - fifo_cfg = cfg_base + id; - fifo_cfg->tx_fifo.rd = (fifo_cfg->tx_fifo.rd + tx_rd) & - PTR_MASK(fifo_cfg->tx_fifo.depth); - ret = ipa_phy_update_tx_fifo_rptr(fifo_cfg->fifo_reg_base, - fifo_cfg->tx_fifo.rd); - - if (ret) { - pr_err("update tx fifo rptr fail !!!\n"); - return -EINVAL; - } - - return 0; -} - -static int ipa_common_fifo_hal_set_rx_fifo_wr(struct device *dev, - enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag * - cfg_base, u32 num) -{ - int ret; - dma_addr_t dma_addr; - struct sipa_cmn_fifo_cfg_tag *fifo_cfg; - u32 tmp = 0, tmp1 = 0, index = 0, left_cnt = 0; - ssize_t node_size = sizeof(struct sipa_node_description_tag); - - if (unlikely(id >= SIPA_FIFO_MAX)) - return -EINVAL; - - fifo_cfg = cfg_base + id; - dma_addr = fifo_cfg->rx_fifo.fifo_base_addr_l; - - left_cnt = fifo_cfg->rx_fifo.depth - - ipa_phy_get_rx_fifo_filled_depth(fifo_cfg->fifo_reg_base); - - if (!left_cnt) - return -ENOSPC; - - if (left_cnt < num) - num = left_cnt; - - index = fifo_cfg->rx_fifo.wr & (fifo_cfg->rx_fifo.depth - 1); - if (index + num <= fifo_cfg->rx_fifo.depth) { - dma_sync_single_for_device(dev, dma_addr + index * node_size, - node_size * num, DMA_TO_DEVICE); - } else { - tmp = fifo_cfg->rx_fifo.depth - index; - dma_sync_single_for_device(dev, dma_addr + index * node_size, - node_size * tmp, DMA_TO_DEVICE); - tmp1 = num - tmp; - dma_sync_single_for_device(dev, dma_addr, - node_size * tmp1, DMA_TO_DEVICE); - } - - fifo_cfg->rx_fifo.wr = (fifo_cfg->rx_fifo.wr + num) & - PTR_MASK(fifo_cfg->rx_fifo.depth); - ret = ipa_phy_update_rx_fifo_wptr(fifo_cfg->fifo_reg_base, - fifo_cfg->rx_fifo.wr); - - if (ret) { - pr_err("update rx fifo rptr fail !!!\n"); - return -EIO; - } - - return 0; -} - -static int ipa_common_fifo_set_intr_eb(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *cfg_base, - bool eb, u32 type) -{ - struct sipa_cmn_fifo_cfg_tag *fifo_cfg; - - if (unlikely(id >= SIPA_FIFO_MAX)) - return -EINVAL; - - fifo_cfg = cfg_base + id; - - if (eb) - return ipa_phy_enable_int_bit(fifo_cfg->fifo_reg_base, type); - else - return ipa_phy_disable_int_bit(fifo_cfg->fifo_reg_base, type); -} - -static void ipa_common_fifo_clr_tout_th_intr(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag * - cfg_base) -{ - struct sipa_cmn_fifo_cfg_tag *fifo_cfg; - - if (unlikely(id >= SIPA_FIFO_MAX)) - return; - - fifo_cfg = cfg_base + id; - - ipa_phy_clear_int(fifo_cfg->fifo_reg_base, - IPA_TX_FIFO_TIMER_CLR_BIT | - IPA_TX_FIFO_THRESHOLD_CLR_BIT); -} - -void sipa_fifo_ops_init(struct sipa_fifo_hal_ops *ops) -{ - ops->open = ipa_common_fifo_hal_open; - - ops->close = ipa_common_fifo_hal_close; - - ops->enable_remote_flowctrl_intr = - ipa_common_fifo_hal_enable_remote_flowctrl_intr; - - ops->enable_local_flowctrl_intr = - ipa_common_fifo_hal_enable_local_flowctrl_intr; - - ops->get_left_cnt = ipa_common_fifo_hal_get_left_cnt; - - ops->put_node_to_rx_fifo = - ipa_common_fifo_hal_put_node_to_rx_fifo; - - ops->recv_node_from_tx_fifo = - ipa_common_fifo_hal_recv_node_from_tx_fifo; - - ops->set_intr_drop_packet = - ipa_common_fifo_hal_set_intr_drop_packet; - - ops->set_intr_error_code = - ipa_common_fifo_hal_set_intr_error_code; - - ops->set_intr_threshold = - ipa_common_fifo_hal_set_intr_threshold; - - ops->set_intr_timeout = - ipa_common_fifo_hal_set_intr_timeout; - - ops->set_hw_intr_thres = - ipa_common_fifo_hal_set_hw_intr_thres; - - ops->set_hw_intr_timeout = - ipa_common_fifo_hal_set_hw_intr_timeout; - - ops->set_interrupt_intr = - ipa_common_fifo_hal_set_interrupt_intr; - - ops->set_intr_txfifo_full = - ipa_common_fifo_hal_set_intr_txfifo_full; - - ops->set_intr_txfifo_overflow = - ipa_common_fifo_hal_set_intr_txfifo_overflow; - - ops->set_rx_depth = - ipa_common_fifo_hal_set_rx_depth; - - ops->set_tx_depth = - ipa_common_fifo_hal_set_tx_depth; - - ops->get_rx_depth = - ipa_common_fifo_hal_get_rx_depth; - - ops->get_tx_depth = - ipa_common_fifo_hal_get_tx_depth; - - ops->get_tx_ptr = - ipa_common_fifo_hal_get_tx_ptr; - - ops->get_rx_ptr = - ipa_common_fifo_hal_get_rx_ptr; - - ops->get_filled_depth = - ipa_common_fifo_hal_get_filled_depth; - - ops->get_tx_empty_status = - ipa_common_fifo_hal_get_tx_empty_status; - - ops->get_tx_full_status = - ipa_common_fifo_hal_get_tx_full_status; - - ops->get_rx_empty_status = - ipa_common_fifo_hal_get_rx_empty_status; - - ops->get_rx_full_status = - ipa_common_fifo_hal_get_rx_full_status; - - ops->set_rx_tx_fifo_ptr = - ipa_common_fifo_hal_set_rx_tx_fifo_ptr; - - ops->set_tx_fifo_wptr = - ipa_common_fifo_hal_set_tx_fifo_wptr; - - ops->set_rx_fifo_wptr = - ipa_common_fifo_hal_set_rx_fifo_wptr; - - ops->set_src_dst_term = - ipa_common_fifo_hal_set_src_dst_term; - - ops->ctrl_receive = - ipa_common_fifo_hal_ctrl_receive; - - ops->set_tx_fifo_rp = ipa_common_fifo_hal_set_tx_fifo_rp; - ops->get_tx_fifo_rp = ipa_common_fifo_hal_get_tx_fifo_rp; - ops->get_rx_fifo_wr = ipa_common_fifo_hal_get_rx_fifo_wr; - ops->set_rx_fifo_wr = ipa_common_fifo_hal_set_rx_fifo_wr; - - ops->set_intr_eb = ipa_common_fifo_set_intr_eb; - ops->clr_tout_th_intr = ipa_common_fifo_clr_tout_th_intr; -} -EXPORT_SYMBOL(sipa_fifo_ops_init); diff --git a/quectel_SRPD_PCIE/src/sipa/sipa_phy_v0/sipa_fifo_irq_hal.c b/quectel_SRPD_PCIE/src/sipa/sipa_phy_v0/sipa_fifo_irq_hal.c deleted file mode 100644 index 36fa1dc..0000000 --- a/quectel_SRPD_PCIE/src/sipa/sipa_phy_v0/sipa_fifo_irq_hal.c +++ /dev/null @@ -1,74 +0,0 @@ -#include "../../include/sipa.h" - -#include "../sipa_core.h" -#include "sipa_fifo_phy.h" - -static void ipa_fifo_traverse_int_bit(enum sipa_cmn_fifo_index id, - struct sipa_cmn_fifo_cfg_tag *ipa_cfg) -{ - void __iomem *fifo_base; - u32 clr_sts = 0; - u32 int_status = 0; - - fifo_base = ipa_cfg->fifo_reg_base; - int_status = ipa_phy_get_fifo_all_int_sts(fifo_base); - - if (!(int_status & IPA_INT_STS_GROUP)) - return; - - if (int_status & IPA_INT_EXIT_FLOW_CTRL_STS) { - ipa_cfg->exit_flow_ctrl_cnt++; - clr_sts |= IPA_EXIT_FLOW_CONTROL_CLR_BIT; - } - - if (int_status & IPA_INT_ERRORCODE_IN_TX_FIFO_STS) - clr_sts |= IPA_ERROR_CODE_INTR_CLR_BIT; - - if (int_status & IPA_INT_ENTER_FLOW_CTRL_STS) { - ipa_cfg->enter_flow_ctrl_cnt++; - clr_sts |= IPA_ENTRY_FLOW_CONTROL_CLR_BIT; - } - - if (int_status & IPA_INT_INTR_BIT_STS) - clr_sts |= IPA_TX_FIFO_INTR_CLR_BIT; - - if (int_status & IPA_INT_THRESHOLD_STS || - int_status & IPA_INT_DELAY_TIMER_STS) { - ipa_phy_disable_int_bit(ipa_cfg->fifo_reg_base, - IPA_TX_FIFO_THRESHOLD_EN | - IPA_TX_FIFO_DELAY_TIMER_EN); - clr_sts |= IPA_TX_FIFO_THRESHOLD_CLR_BIT | - IPA_TX_FIFO_TIMER_CLR_BIT; - } - - if (int_status & IPA_INT_DROP_PACKT_OCCUR) - clr_sts |= IPA_DROP_PACKET_INTR_CLR_BIT; - - if (int_status & IPA_INT_TXFIFO_OVERFLOW_STS) - clr_sts |= IPA_TX_FIFO_OVERFLOW_CLR_BIT; - - if (int_status & IPA_INT_TXFIFO_FULL_INT_STS) - clr_sts |= IPA_TX_FIFO_FULL_INT_CLR_BIT; - - if (ipa_cfg->irq_cb) - ipa_cfg->irq_cb(ipa_cfg->priv, int_status, id); - else - pr_err("Don't register this fifo(%d) irq callback\n", id); - - ipa_phy_clear_int(ipa_cfg->fifo_reg_base, clr_sts); -} - -int sipa_int_callback_func(int evt, void *cookie) -{ - struct sipa_core *ipa = sipa_get_ctrl_pointer(); - - if (ipa->remote_ready) { - ipa_fifo_traverse_int_bit(SIPA_FIFO_PCIE_DL, - &ipa->cmn_fifo_cfg[SIPA_FIFO_PCIE_DL]); - ipa_fifo_traverse_int_bit(SIPA_FIFO_PCIE_UL, - &ipa->cmn_fifo_cfg[SIPA_FIFO_PCIE_UL]); - } - - return 0; -} -EXPORT_SYMBOL(sipa_int_callback_func); diff --git a/quectel_SRPD_PCIE/src/sipa/sipa_phy_v0/sipa_fifo_phy.h b/quectel_SRPD_PCIE/src/sipa/sipa_phy_v0/sipa_fifo_phy.h deleted file mode 100644 index d578585..0000000 --- a/quectel_SRPD_PCIE/src/sipa/sipa_phy_v0/sipa_fifo_phy.h +++ /dev/null @@ -1,1413 +0,0 @@ -#ifndef _IPA_CP0_FIFO_PHY_H_ -#define _IPA_CP0_FIFO_PHY_H_ - -#include - -/* Common fifo reg */ -#define IPA_COMMON_RX_FIFO_DEPTH 0x00UL -#define IPA_COMMON_RX_FIFO_WR 0x04UL -#define IPA_COMMON_RX_FIFO_RD 0x08UL -#define IPA_COMMON_TX_FIFO_DEPTH 0x0CUL -#define IPA_COMMON_TX_FIFO_WR 0x10UL -#define IPA_COMMON_TX_FIFO_RD 0x14UL -#define IPA_COMMON_RX_FIFO_ADDRL 0x18UL -#define IPA_COMMON_RX_FIFO_ADDRH 0x1CUL -#define IPA_COMMON_TX_FIFO_ADDRL 0x20UL -#define IPA_COMMON_TX_FIFO_ADDRH 0x24UL -#define IPA_PERFETCH_FIFO_CTL 0x28UL -#define IPA_INT_GEN_CTL_TX_FIFO_VALUE 0x2CUL -#define IPA_INT_GEN_CTL_EN 0x30UL -#define IPA_DROP_PACKET_CNT 0x34UL -#define IPA_FLOW_CTRL_CONFIG 0x38UL -#define IPA_TX_FIFO_FLOW_CTRL 0x3CUL -#define IPA_RX_FIFO_FLOW_CTRL 0x40UL -#define IPA_RX_FIFO_FULL_NEG_PULSE_NUM 0x44UL -#define IPA_INT_GEN_CTL_CLR 0x48UL -#define IPA_INTR_RX_FIFO_FULL_ADDR_HIGH 0x4CUL -#define IPA_INTR_MEM_WR_ADDR_LOW 0x50UL -#define IPA_RXFIFO_FULL_MEM_WR_ADDR_LOW 0x54UL -#define IPA_INTR_MEM_WR_PATTERN 0x58UL -#define IPA_RX_FIFO_FULL_MEM_WR_PATTERN 0x5CUL -#define IPA_TX_FIFO_WR_INIT 0x60UL -#define IPA_COMMON_RX_FIFO_AXI_STS 0x64UL -#define IPA_ERRCODE_INT_ADDR_LOW 0x68UL -#define IPA_ERRCODE_INT_PATTERN 0x6CUL - -/* Fifo interrupt enable bit */ -#define IPA_TXFIFO_INT_THRESHOLD_ONESHOT_EN BIT(11) -#define IPA_TXFIFO_INT_THRESHOLD_SW_EN BIT(10) -#define IPA_TXFIFO_INT_DELAY_TIMER_SW_EN BIT(9) -#define IPA_TXFIFO_FULL_INT_EN BIT(8) -#define IPA_TXFIFO_OVERFLOW_EN BIT(7) -#define IPA_ERRORCODE_IN_TX_FIFO_EN BIT(6) -#define IPA_DROP_PACKET_OCCUR_INT_EN BIT(5) -#define IPA_RX_FIFO_INT_EXIT_FLOW_CTRL_EN BIT(4) -#define IPA_RX_FIFO_INT_ENTER_FLOW_CTRL_EN BIT(3) -#define IPA_TX_FIFO_INTR_SW_BIT_EN BIT(2) -#define IPA_TX_FIFO_THRESHOLD_EN BIT(1) -#define IPA_TX_FIFO_DELAY_TIMER_EN BIT(0) -#define IPA_INT_EN_BIT_GROUP 0x00000FFFUL - -/* Fifo interrupt status bit */ -#define IPA_INT_TX_FIFO_THRESHOLD_SW_STS BIT(22) -#define IPA_INT_EXIT_FLOW_CTRL_STS BIT(20) -#define IPA_INT_ENTER_FLOW_CTRL_STS BIT(19) -#define IPA_INT_TXFIFO_FULL_INT_STS BIT(18) -#define IPA_INT_TXFIFO_OVERFLOW_STS BIT(17) -#define IPA_INT_ERRORCODE_IN_TX_FIFO_STS BIT(16) -#define IPA_INT_INTR_BIT_STS BIT(15) -#define IPA_INT_THRESHOLD_STS BIT(14) -#define IPA_INT_DELAY_TIMER_STS BIT(13) -#define IPA_INT_DROP_PACKT_OCCUR BIT(12) -#define IPA_INT_STS_GROUP 0x5FF000UL - -/* Fifo interrupt clear bit */ -#define IPA_TX_FIFO_TIMER_CLR_BIT BIT(0) -#define IPA_TX_FIFO_THRESHOLD_CLR_BIT BIT(1) -#define IPA_TX_FIFO_INTR_CLR_BIT BIT(2) -#define IPA_ENTRY_FLOW_CONTROL_CLR_BIT BIT(3) -#define IPA_EXIT_FLOW_CONTROL_CLR_BIT BIT(4) -#define IPA_DROP_PACKET_INTR_CLR_BIT BIT(5) -#define IPA_ERROR_CODE_INTR_CLR_BIT BIT(6) -#define IPA_TX_FIFO_OVERFLOW_CLR_BIT BIT(7) -#define IPA_TX_FIFO_FULL_INT_CLR_BIT BIT(8) -#define IPA_INT_STS_CLR_GROUP 0x000001FFUL - -#define NODE_DESCRIPTION_SIZE 128UL - -/** - * Description: set rx fifo total depth. - * Input: - * @fifo_base: Need to set total depth of the fifo, - * the base address of the FIFO. - * @depth: the size of depth. - * return: - * 0: set successfully. - * non-zero: set failed. - * Note: - */ -static inline int ipa_phy_set_rx_fifo_total_depth(void __iomem *fifo_base, - u32 depth) -{ - u32 tmp; - - if (depth > 0xFFFF) - return -EINVAL; - - tmp = readl_relaxed(fifo_base + IPA_COMMON_RX_FIFO_DEPTH); - tmp &= 0x0000FFFFUL; - tmp |= (depth << 16); - writel_relaxed(tmp, fifo_base + IPA_COMMON_RX_FIFO_DEPTH); - tmp = readl_relaxed(fifo_base + IPA_COMMON_RX_FIFO_DEPTH); - if ((tmp & 0xFFFF0000UL) == tmp) - return 0; - else - return -EINVAL; -} - -/** - * Description: get rx fifo total depth. - * Input: - * @fifo_base: Need to get total depth of the fifo, the base address of the - * FIFO. - * return: The size of toal depth. - * Note: - */ -static inline u32 ipa_phy_get_rx_fifo_total_depth(void __iomem *fifo_base) -{ - u32 tmp; - - tmp = readl_relaxed(fifo_base + IPA_COMMON_RX_FIFO_DEPTH); - - return (tmp >> 16) & 0x0000FFFFUL; -} - -/** - * Description: get rx fifo filled depth. - * Input: - * @fifo_base: Need to get filled depth of the FIFO, the base address of the - * FIFO. - * return: - * TRUE: The size of rx filled depth - * Note: - */ -static inline u32 ipa_phy_get_rx_fifo_filled_depth(void __iomem *fifo_base) -{ - u32 tmp; - - tmp = readl_relaxed(fifo_base + IPA_COMMON_RX_FIFO_DEPTH); - - return tmp & 0x0000FFFFUL; -} - -/** - * Description: get rx fifo full status. - * Input: - * @fifo_base: Need to get rx fifo full status of the FIFO, the base address - * of the FIFO. - * return: - * 1: rx fifo full. - * 0: rx fifo not full. - * Note: - */ -static inline u32 ipa_phy_get_rx_fifo_full_status(void __iomem *fifo_base) -{ - u32 tmp; - - tmp = readl_relaxed(fifo_base + IPA_COMMON_RX_FIFO_WR); - - return tmp & 0x1UL; -} - -/** - * Description: update rx fifo write pointer. - * Input: - * @fifo_base: Need to update rx fifo write pointer of the FIFO, the base - * address of the FIFO. - * return: - * 0: update rx fifo write pointer successfully, - * non-zero: update rx fifo write pointer failed. - * Note: - */ -static inline int ipa_phy_update_rx_fifo_wptr(void __iomem *fifo_base, - u32 wptr) -{ - u32 tmp = 0; - void __iomem *fifo_reg_addr; - - fifo_reg_addr = fifo_base + IPA_COMMON_RX_FIFO_WR; - - if (wptr > 0xFFFFUL) - return -EINVAL; - - tmp = readl_relaxed(fifo_reg_addr); - tmp &= 0x0000FFFFUL; - tmp |= (wptr << 16); - writel_relaxed(tmp, fifo_reg_addr); - - tmp = readl_relaxed(fifo_reg_addr); - if ((tmp >> 16) == wptr) - return 0; - else - return -EIO; -} - -/** - * Description: get rx fifo write pointer. - * Input: - * @fifo_base: Need to get rx fifo write pointer of the FIFO, the base - * address of the FIFO. - * return: - * The write pointer of rx fifo. - * Note: - */ -static inline u32 ipa_phy_get_rx_fifo_wptr(void __iomem *fifo_base) -{ - u32 tmp; - - tmp = readl_relaxed(fifo_base + IPA_COMMON_RX_FIFO_WR); - - return (tmp >> 16); -} - -/** - * Description: update rx fifo read pointer. - * Input: - * @fifo_base: Need to update rx fifo read pointer of the FIFO, the base - * address of the FIFO. - * return: - * 0: update rx fifo read pointer successfully, - * non-zero: update rx fifo read pointer failed. - * Note: - */ -static inline int ipa_phy_update_rx_fifo_rptr(void __iomem *fifo_base, - u32 rptr) -{ - u32 tmp = 0; - void __iomem *fifo_reg_addr; - - fifo_reg_addr = fifo_base + IPA_COMMON_RX_FIFO_RD; - - if (rptr > 0xFFFFUL) - return -EINVAL; - - tmp = readl_relaxed(fifo_reg_addr); - tmp &= 0x0000FFFFUL; - tmp |= (rptr << 16); - writel_relaxed(tmp, fifo_reg_addr); - - tmp = readl_relaxed(fifo_reg_addr); - - if ((tmp >> 16) == rptr) - return 0; - else - return -EIO; -} - -/** - * Description: get rx fifo read pointer. - * Input: - * @fifo_base: Need to get rx fifo read pointer of the FIFO, the base - * address of the FIFO. - * return: - * The read pointer of rx fifo. - * Note: - */ -static inline u32 ipa_phy_get_rx_fifo_rptr(void __iomem *fifo_base) -{ - u32 tmp; - - tmp = readl_relaxed(fifo_base + IPA_COMMON_RX_FIFO_RD); - - return (tmp >> 16); -} - -/** - * Description: get rx fifo empty status. - * Input: - * @fifo_base: Need to get rx fifo empty status of the FIFO, the base - * address of the FIFO. - * return: - * The empty status of rx fifo. - * Note: - */ -static inline u32 ipa_phy_get_rx_fifo_empty_status(void __iomem *fifo_base) -{ - u32 tmp; - - tmp = readl_relaxed(fifo_base + IPA_COMMON_RX_FIFO_RD); - - return tmp & 0x1UL; -} - -/** - * Description: set tx fifo total depth. - * Input: - * @fifo_base: Need to set tx fifo empty status of the FIFO, the base - * address of the FIFO. - * return: - * 0: set tx fifo total depth successfully. - * non-zero: set tx fifo total_depth failed. - * Note: - */ -static inline int ipa_phy_set_tx_fifo_total_depth(void __iomem *fifo_base, - u32 depth) -{ - u32 tmp; - void __iomem *fifo_reg_addr; - - fifo_reg_addr = fifo_base + IPA_COMMON_TX_FIFO_DEPTH; - - if (depth > 0xFFFFUL) - return -EINVAL; - - tmp = readl_relaxed(fifo_reg_addr); - tmp &= 0x0000FFFFUL; - tmp |= (depth << 16); - writel_relaxed(tmp, fifo_reg_addr); - - tmp = readl_relaxed(fifo_reg_addr); - if ((tmp >> 16) == depth) - return 0; - else - return -EIO; -} - -/** - * Description: get tx fifo total depth. - * Input: - * @fifo_base: Need to get tx fifo empty status of the FIFO, the base - * address of the FIFO. - * return: - * The total depth of tx fifo. - * Note: - */ -static inline u32 ipa_phy_get_tx_fifo_total_depth(void __iomem *fifo_base) -{ - u32 tmp; - - tmp = readl_relaxed(fifo_base + IPA_COMMON_TX_FIFO_DEPTH); - - return ((tmp >> 16) & 0x0000FFFF); -} - -/** - * Description: get tx fifo filled depth. - * Input: - * @fifo_base: Need to get tx fifo filled depth of the FIFO, the base - * address of the FIFO. - * return: - * The tx fifo filled depth. - * Note: - */ -static inline u32 ipa_phy_get_tx_fifo_filled_depth(void __iomem *fifo_base) -{ - u32 tmp; - - tmp = readl_relaxed(fifo_base + IPA_COMMON_TX_FIFO_DEPTH); - - return (tmp & 0x0000FFFFUL); -} - -/** - * Description: get tx fifo full status. - * Input: - * @fifo_base: Need to get tx fifo full status of the FIFO, the base - * address of the FIFO. - * return: - * The full status of tx fifo. - * Note: - */ -static inline u32 ipa_phy_get_tx_fifo_full_status(void __iomem *fifo_base) -{ - u32 tmp; - - tmp = readl_relaxed(fifo_base + IPA_COMMON_TX_FIFO_WR); - - return (tmp & 0x1UL); -} - -/** - * Description: get tx fifo empty status. - * Input: - * @fifo_base: Need to get tx fifo empty status of the FIFO, the base - * address of the FIFO. - * return: - * The empty status of tx fifo. - * Note: - */ -static inline u32 ipa_phy_get_tx_fifo_empty_status(void __iomem *fifo_base) -{ - u32 tmp; - - tmp = readl_relaxed(fifo_base + IPA_COMMON_TX_FIFO_RD); - - return (tmp & 0x1UL); -} - -/** - * Description: update tx fifo write pointer. - * Input: - * @fifo_base: Need to update tx fifo write pointer of the FIFO, the base - * address of the FIFO. - * return: - * 0: update tx fifo write pointer successfully. - * non-zero: update tx fifo write pointer failed. - * Note: - */ -static inline int ipa_phy_update_tx_fifo_wptr(void __iomem *fifo_base, - u32 wptr) -{ - u32 tmp; - void __iomem *fifo_reg_addr; - - fifo_reg_addr = fifo_base + IPA_TX_FIFO_WR_INIT; - - if (wptr > 0xFFFFUL) - return -EINVAL; - - tmp = readl_relaxed(fifo_reg_addr); - tmp &= 0x0000FFFFUL; - tmp |= (wptr << 16); - writel_relaxed(tmp, fifo_reg_addr); - - tmp = readl_relaxed(fifo_reg_addr); - tmp |= 0x2; - writel_relaxed(tmp, fifo_reg_addr); - - tmp = readl_relaxed(fifo_reg_addr); - tmp &= 0xFFFFFFFDUL; - writel_relaxed(tmp, fifo_reg_addr); - - tmp = readl_relaxed(fifo_reg_addr); - - if ((tmp >> 16) == wptr) - return 0; - else - return -EIO; -} - -/** - * Description: get tx fifo write pointer. - * Input: - * @fifo_base: Need to get tx fifo write pointer of the FIFO, the base - * address of the FIFO. - * return: - * The write pointer of tx fifo. - * Note: - */ -static inline u32 ipa_phy_get_tx_fifo_wptr(void __iomem *fifo_base) -{ - u32 tmp; - - tmp = readl_relaxed(fifo_base + IPA_COMMON_TX_FIFO_WR); - - return (tmp >> 16); -} - -/** - * Description: update tx fifo read pointer. - * Input: - * @fifo_base: Need to update tx fifo read pointer of the FIFO, the base - * address of the FIFO. - * return: - * 0: update tx fifo read pointer successfully. - * non-zero: update tx fifo read pointer failed. - * Note: - */ -static inline int ipa_phy_update_tx_fifo_rptr(void __iomem *fifo_base, - u32 rptr) -{ - u32 tmp; - void __iomem *fifo_reg_addr; - - fifo_reg_addr = fifo_base + IPA_COMMON_TX_FIFO_RD; - - if (rptr > 0xFFFFUL) - return -EINVAL; - - tmp = readl_relaxed(fifo_reg_addr); - tmp &= 0x0000FFFF; - tmp |= (rptr << 16); - writel_relaxed(tmp, fifo_reg_addr); - - tmp = readl_relaxed(fifo_reg_addr); - - if ((tmp >> 16) == rptr) - return 0; - else - return -EIO; -} - -/** - * Description: get tx fifo write pointer. - * Input: - * @fifo_base: Need to get tx fifo write pointer of the FIFO, the base - * address of the FIFO. - * return: - * The write pointer of rx fifo. - * Note: - */ -static inline u32 ipa_phy_get_tx_fifo_rptr(void __iomem *fifo_base) -{ - u32 tmp; - - tmp = readl_relaxed(fifo_base + IPA_COMMON_TX_FIFO_RD); - - return (tmp >> 16); -} - -/** - * Description: set rx fifo address of iram. - * Input: - * @fifo_base: Need to set rx fifo address of the FIFO, the base - * address of the FIFO. - * @addr_l: low 32 bit. - * @addr_h: high 8 bit. - * return: - * 0: update rx fifo address of iram successfully. - * non-zero: update rx fifo address of iram failed. - * Note: - */ -static inline int ipa_phy_set_rx_fifo_addr(void __iomem *fifo_base, - u32 addr_l, u32 addr_h) -{ - u32 tmp_l, tmp_h; - - writel_relaxed(addr_l, fifo_base + IPA_COMMON_RX_FIFO_ADDRL); - writel_relaxed(addr_h, fifo_base + IPA_COMMON_RX_FIFO_ADDRH); - - tmp_l = readl_relaxed(fifo_base + IPA_COMMON_RX_FIFO_ADDRL); - tmp_h = readl_relaxed(fifo_base + IPA_COMMON_RX_FIFO_ADDRH); - - if ((tmp_l == addr_l) && (tmp_h == addr_h)) - return 0; - else - return -EIO; -} - -/** - * Description: get rx fifo address of iram. - * Input: - * @fifo_base: Need to get rx fifo address of the FIFO, the base - * address of the FIFO. - * @addr_l: low 32 bit. - * @addr_h: high 8 bit. - * return: - * void. - * Note: - */ -static inline void ipa_phy_get_rx_fifo_addr(void __iomem *fifo_base, - u32 *addr_l, u32 *addr_h) -{ - *addr_l = readl_relaxed(fifo_base + IPA_COMMON_RX_FIFO_ADDRL); - *addr_h = readl_relaxed(fifo_base + IPA_COMMON_RX_FIFO_ADDRH); -} - -/** - * Description: set tx fifo address of iram. - * Input: - * @fifo_base: Need to set tx fifo address of the FIFO, the base - * address of the FIFO. - * @addr_l: low 32 bit. - * @addr_h: high 8 bit. - * return: - * 0: update tx fifo address of iram successfully. - * non-zero: update tx fifo address of iram failed. - * Note: - */ -static inline int ipa_phy_set_tx_fifo_addr(void __iomem *fifo_base, - u32 addr_l, u32 addr_h) -{ - u32 tmp_l, tmp_h; - - writel_relaxed(addr_l, fifo_base + IPA_COMMON_TX_FIFO_ADDRL); - writel_relaxed(addr_h, fifo_base + IPA_COMMON_TX_FIFO_ADDRH); - - tmp_l = readl_relaxed(fifo_base + IPA_COMMON_TX_FIFO_ADDRL); - tmp_h = readl_relaxed(fifo_base + IPA_COMMON_TX_FIFO_ADDRH); - - if ((tmp_l == addr_l) && (tmp_h == addr_h)) - return 0; - else - return -EIO; -} - -/** - * Description: get tx fifo address of iram. - * Input: - * @fifo_base: Need to get tx fifo address of the FIFO, the base - * address of the FIFO. - * @addr_l: low 32 bit. - * @addr_h: high 8 bit. - * return: - * void. - * Note: - */ -static inline void ipa_phy_get_tx_fifo_addr(void __iomem *fifo_base, - u32 *addr_l, u32 *addr_h) -{ - *addr_l = readl_relaxed(fifo_base + IPA_COMMON_TX_FIFO_ADDRL); - *addr_h = readl_relaxed(fifo_base + IPA_COMMON_TX_FIFO_ADDRH); -} - -/** - * Description: Enable interrupt bit. - * Input: - * @fifo_base: Need to enable interrupr bit of the FIFO, the base - * address of the FIFO. - * @int_bit: The interrupt bit that need to enable. - * return: - * 0: Enable successfully. - * non-zero: Enable successfully. - * Note: - */ -static inline int ipa_phy_enable_int_bit(void __iomem *fifo_base, - u32 int_bit) -{ - u32 tmp; - void __iomem *fifo_reg_addr; - - fifo_reg_addr = fifo_base + IPA_INT_GEN_CTL_EN; - - tmp = readl_relaxed(fifo_reg_addr); - tmp |= int_bit; - writel_relaxed(tmp, fifo_reg_addr); - - tmp = readl_relaxed(fifo_reg_addr); - - if ((tmp & int_bit) == int_bit) - return 0; - else - return -EIO; -} - -/** - * Description: Disable interrupt bit. - * Input: - * @fifo_base: Need to Disable interrupr bit of the FIFO, the base - * address of the FIFO. - * @int_bit: The interrupt bit that need to disable. - * return: - * 0: Disable successfully. - * non-zero: Disable failed. - * Note: - */ -static inline int ipa_phy_disable_int_bit(void __iomem *fifo_base, - u32 int_bit) -{ - u32 tmp = 0; - void __iomem *fifo_reg_addr; - - fifo_reg_addr = fifo_base + IPA_INT_GEN_CTL_EN; - - tmp = readl_relaxed(fifo_reg_addr); - tmp &= (~int_bit); - writel_relaxed(tmp, fifo_reg_addr); - - tmp = readl_relaxed(fifo_reg_addr); - tmp &= int_bit; - - if (tmp) { - pr_err("Disable interrupt bit = 0x%x set failed!\n", - int_bit); - return -EIO; - } - - return 0; -} - -static inline u32 ipa_phy_get_all_intr_enable_status(void __iomem *fifo_base) -{ - u32 tmp = 0; - void __iomem *fifo_reg_addr; - - fifo_reg_addr = fifo_base + IPA_INT_GEN_CTL_EN; - - tmp = readl_relaxed(fifo_reg_addr); - - tmp &= IPA_INT_EN_BIT_GROUP; - - return tmp; -} - -/** - * Description: Get specified interrupt bit status. - * Input: - * @fifo_base: Need to get interrupt bit of the FIFO, the base - * address of the FIFO. - * @int_bit: The specified interrupt bit that need to get. - * return: - * 0: interrupt bit enable. - * non-zero: interrupt bit disable. - * Note: - */ -static inline int ipa_phy_get_fifo_int_sts(void __iomem *fifo_base, u32 sts) -{ - u32 tmp; - - tmp = readl_relaxed(fifo_base + IPA_INT_GEN_CTL_EN); - - if (tmp & sts) - return 0; - else - return -EIO; -} - -/** - * Description: Get interrupt group status. - * Input: - * @fifo_base: Need to get interrupt group status of the FIFO, the base - * address of the FIFO. - * return: - * Interrupt group status. - * Note: - */ -static inline u32 ipa_phy_get_fifo_all_int_sts(void __iomem *fifo_base) -{ - u32 tmp; - - tmp = readl_relaxed(fifo_base + IPA_INT_GEN_CTL_EN); - - return (tmp & IPA_INT_STS_GROUP); -} - -/** - * Description: Clear interrupt flag, need to write 1, then write 0. - * Input: - * @fifo_base: Need to clear interrupt flag of the FIFO, the base - * address of the FIFO. - * return: - * void. - * Note: - */ -static inline void ipa_phy_clear_int(void __iomem *fifo_base, u32 clr_bit) -{ - writel_relaxed(clr_bit, fifo_base + IPA_INT_GEN_CTL_CLR); -} - -/** - * Description: Get drop packet count. - * Input: - * @fifo_base: Need to get drop packet count of the FIFO, the base - * address of the FIFO. - * return: - * Drop packet count. - * Note: - */ -static inline u32 ipa_phy_get_drop_packet_cnt(void __iomem *fifo_base) -{ - u32 tmp; - - tmp = readl_relaxed(fifo_base + IPA_DROP_PACKET_CNT); - - return tmp; -} - -/** - * Description: Get tx fifo threshold interrupt. - * Input: - * @fifo_base: Need to get threshold interrupt of the FIFO, the base - * address of the FIFO. - * OUTPUT: - * threshold value. - * Note: - */ -static inline u32 ipa_phy_get_tx_fifo_interrupt_threshold(void __iomem - *fifo_base) -{ - u32 tmp; - - tmp = readl_relaxed(fifo_base + IPA_INT_GEN_CTL_TX_FIFO_VALUE); - - return (tmp >> 16); -} - -/** - * Description: Set tx fifo interrupt threshold of value. - * Input: - * @fifo_base: Need to get threshold interrupt value of the FIFO, the base - * address of the FIFO. - * return: - * TRUE: set successfully. - * FALSE: set failed. - * Note: - */ -static inline int -ipa_phy_set_tx_fifo_interrupt_threshold(void __iomem *fifo_base, u32 threshold) -{ - u32 tmp = 0; - void __iomem *fifo_reg_addr; - - fifo_reg_addr = fifo_base + IPA_INT_GEN_CTL_TX_FIFO_VALUE; - - if (threshold > 0xFFFFUL) - return -EINVAL; - - tmp = readl_relaxed(fifo_reg_addr); - tmp &= 0x0000FFFFUL; - tmp |= (threshold << 16); - writel_relaxed(tmp, fifo_reg_addr); - tmp = readl_relaxed(fifo_reg_addr); - - if ((tmp >> 16) == threshold) - return 0; - else - return -EIO; -} - -/** - * Description: Get tx fifo interrupt of delay timer value. - * Input: - * @fifo_base: Need to get delay timer interrupt of the FIFO, the base - * address of the FIFO. - * OUTPUT: - * delay timer value. - * Note: - */ -static inline u32 -ipa_phy_get_tx_fifo_interrupt_delay_timer(void __iomem *fifo_base) -{ - u32 tmp; - - tmp = readl_relaxed(fifo_base + IPA_INT_GEN_CTL_TX_FIFO_VALUE); - - return (tmp & 0x0000FFFFUL); -} - -/** - * Description: Set tx fifo interrupt of delay timer value. - * Input: - * @fifo_base: Need to set delay timer interrupt of the FIFO, the base - * address of the FIFO. - * @threshold: The overflow value that need to set. - * return: - * 0: Set successfully. - * non-zero: set failed. - * Note: - */ -static inline int -ipa_phy_set_tx_fifo_interrupt_delay_timer(void __iomem *fifo_base, - u32 threshold) -{ - u32 tmp = 0; - void __iomem *fifo_reg_addr; - - fifo_reg_addr = fifo_base + IPA_INT_GEN_CTL_TX_FIFO_VALUE; - - if (threshold > 0xFFFFUL) - return -EINVAL; - - tmp = readl_relaxed(fifo_reg_addr); - tmp &= 0xFFFF0000UL; - tmp |= threshold; - writel_relaxed(tmp, fifo_reg_addr); - tmp = readl_relaxed(fifo_reg_addr); - - if ((tmp & 0x0000FFFF) == threshold) - return 0; - else - return -EIO; -} - -/** - * Description: Get current term number. - * Input: - * @fifo_base: Need to get current term number of the FIFO, the base - * address of the FIFO. - * return: - * Current term number. - * Note: - */ -static inline u32 ipa_phy_get_cur_term_num(void __iomem *fifo_base) -{ - u32 tmp; - - tmp = readl_relaxed(fifo_base + IPA_PERFETCH_FIFO_CTL); - - return ((tmp & 0x0003E000UL) >> 13); -} - -/** - * Description: Set current term number. - * Input: - * @fifo_base: Need to set current term number of the FIFO, the base - * address of the FIFO. - * return: - * 0: Set successfully. - * non-zero: Set failed. - * Note: - */ -static inline int ipa_phy_set_cur_term_num(void __iomem *fifo_base, - u32 num) -{ - u32 tmp = 0; - void __iomem *fifo_reg_addr; - - fifo_reg_addr = fifo_base + IPA_PERFETCH_FIFO_CTL; - - if (num > 0x1FUL) - return -EINVAL; - - tmp = readl_relaxed(fifo_reg_addr); - tmp &= 0xFFFC1FFFUL; - tmp |= (num << 13); - writel_relaxed(tmp, fifo_reg_addr); - - tmp = readl_relaxed(fifo_reg_addr); - if (((tmp & 0x0003E000) >> 13) == num) - return 0; - else - return -EIO; -} - -/** - * Description: Get dst term number. - * Input: - * @fifo_base: Need to get dst term number of the FIFO, the base - * address of the FIFO. - * return: - * Dst term number. - * Note: - */ -static inline u32 ipa_phy_get_dst_term_num(void __iomem *fifo_base) -{ - u32 tmp; - - tmp = readl_relaxed(fifo_base + IPA_PERFETCH_FIFO_CTL); - - return ((tmp & 0x00001F00UL) >> 8); -} - -/** - * Description: Set dst term number. - * Input: - * @fifo_base: Need to set dst term number of the FIFO, the base - * address of the FIFO. - * return: - * 0: Set successfully. - * non-zero: Set failed. - * Note: - */ -static inline int ipa_phy_set_dst_term_num(void __iomem *fifo_base, - u32 num) -{ - u32 tmp = 0; - void __iomem *fifo_reg_addr; - - fifo_reg_addr = fifo_base + IPA_PERFETCH_FIFO_CTL; - if (num > 0x1FUL) - return -EINVAL; - - tmp = readl_relaxed(fifo_reg_addr); - tmp &= 0xFFFFE0FFUL; - tmp |= (num << 8); - writel_relaxed(tmp, fifo_reg_addr); - - tmp = readl_relaxed(fifo_reg_addr); - if (((tmp & 0x00001F00UL) >> 8) == num) - return 0; - else - return -EIO; -} - -/** - * Description: Get prefetch fifo priority. - * Input: - * @fifo_base: Need to get prefetch fifo priority of the FIFO, the base - * address of the FIFO. - * return: - * Prefetch fifo priority. - * Note: - */ -static inline u32 ipa_phy_get_prefetch_fifo_priority(void __iomem *fifo_base) -{ - u32 tmp; - - tmp = readl_relaxed(fifo_base + IPA_PERFETCH_FIFO_CTL); - - return ((tmp & 0x000000F0UL) >> 4); -} - -/** - * Description: Set prefetch fifo priority. - * Input: - * @fifo_base: Need to set prefetch fifo priority of the FIFO, the base - * address of the FIFO. - * return: - * 0: Set successfully. - * non-zero: Set failed. - * Note: - */ -static inline int ipa_phy_set_prefetch_fifo_priority(void __iomem *fifo_base, - u32 pri) -{ - u32 tmp = 0; - void __iomem *fifo_reg_base; - - fifo_reg_base = fifo_base + IPA_PERFETCH_FIFO_CTL; - - if (pri > 0xFUL) - return -EINVAL; - - tmp = readl_relaxed(fifo_reg_base); - tmp &= 0xFFFFFF0FUL; - tmp |= (pri << 4); - writel_relaxed(tmp, fifo_reg_base); - - tmp = readl_relaxed(fifo_reg_base); - if (((tmp & 0x000000F0UL) >> 4) == pri) - return 0; - else - return -EIO; -} - -/** - * Description: Get prefetch threshold. - * Input: - * @fifo_base: Need to get prefetch threshold of the FIFO, the base - * address of the FIFO. - * return: - * Prefetch threshold. - * Note: - */ -static inline u32 ipa_phy_get_prefetch_threshold(void __iomem *fifo_base) -{ - u32 tmp; - - tmp = readl_relaxed(fifo_base + IPA_PERFETCH_FIFO_CTL); - - return (tmp & 0xFUL); -} - -/** - * Description: Set prefetch threshold. - * Input: - * @fifo_base: Need to get threshold of the FIFO, the base - * address of the FIFO. - * return: - * 0: Set successfully. - * non-zero: Set failed. - * Note: - */ -static inline int ipa_phy_set_prefetch_threshold(void __iomem *fifo_base, - u32 threshold) -{ - u32 tmp = 0; - void __iomem *fifo_reg_addr; - - fifo_reg_addr = fifo_base + IPA_PERFETCH_FIFO_CTL; - - if (threshold > 0xFUL) - return -EINVAL; - - tmp = readl_relaxed(fifo_reg_addr); - tmp &= 0xFFFFFFF0UL; - tmp |= threshold; - writel_relaxed(tmp, fifo_reg_addr); - - tmp = readl_relaxed(fifo_reg_addr); - if ((tmp & 0xFUL) == threshold) - return 0; - else - return -EIO; -} - -/** - * Description: Set stop receive bit. - * Input: - * @fifo_base: Need to set stop receive bit of the FIFO, the base - * address of the FIFO. - * return: - * 0: Set successfully. - * non-zero: Set failed. - * Note: - */ -static inline int ipa_phy_stop_receive(void __iomem *fifo_base) -{ - u32 tmp; - void __iomem *fifo_reg_addr; - - fifo_reg_addr = fifo_base + IPA_FLOW_CTRL_CONFIG; - - tmp = readl_relaxed(fifo_reg_addr); - tmp |= 0x8; - writel_relaxed(tmp, fifo_reg_addr); - - tmp = readl_relaxed(fifo_reg_addr); - if (tmp & 0x8) - return 0; - else - return -EIO; -} - -/** - * Description: Clear stop receive bit. - * Input: - * @fifo_base: Need to clear stop receive bit of the FIFO, the base - * address of the FIFO. - * return: - * 0: clear successfully. - * non-zero: clear failed. - * Note: - */ -static inline int ipa_phy_clear_stop_receive(void __iomem *fifo_base) -{ - u32 tmp; - void __iomem *fifo_reg_addr; - - fifo_reg_addr = fifo_base + IPA_FLOW_CTRL_CONFIG; - - tmp = readl_relaxed(fifo_reg_addr); - tmp &= 0xFFFFFFF7; - writel_relaxed(tmp, fifo_reg_addr); - tmp = readl_relaxed(fifo_reg_addr); - - if (!(tmp & 0x8)) - return 0; - else - return -EIO; -} - -/** - * Description: recover fifo work. - * Input: - * @fifo_base: Need to be recovered of the FIFO, the base - * address of the FIFO. - * return: - * 0: Recover successfully. - * non-zero: Recover failed. - * Note: - */ -static inline int ipa_phy_flow_ctrl_recover(void __iomem *fifo_base) -{ - u32 tmp; - void __iomem *fifo_reg_addr; - - fifo_reg_addr = fifo_base + IPA_FLOW_CTRL_CONFIG; - - tmp = readl_relaxed(fifo_reg_addr); - tmp |= 0x4UL; - writel_relaxed(tmp, fifo_reg_addr); - - tmp = readl_relaxed(fifo_reg_addr); - if (tmp & 0x4UL) { - tmp &= 0xFFFFFFFBUL; - writel_relaxed(tmp, fifo_reg_addr); - - tmp = readl_relaxed(fifo_reg_addr); - if (!(tmp & 0x4UL)) - return 0; - else - return -EIO; - } else { - return -EINVAL; - } -} - -/** - * Description: Set flow ctrl mode. - * Input: - * @fifo_base: Need to set flow ctrl mode of the FIFO, the base - * address of the FIFO. - * return: - * 0: Set successfully. - * non-zero: Set failed. - * Note: - */ -static inline int ipa_phy_set_flow_ctrl_config(void __iomem *fifo_base, - u32 config) -{ - u32 tmp; - void __iomem *fifo_reg_addr; - - fifo_reg_addr = fifo_base + IPA_FLOW_CTRL_CONFIG; - - tmp = readl_relaxed(fifo_reg_addr); - tmp &= 0xFFFFFFFC; - tmp |= config; - writel_relaxed(tmp, fifo_reg_addr); - - tmp = readl_relaxed(fifo_reg_addr); - if ((tmp & 0x00000003) == config) - return 0; - else - return -EIO; -} - -/** - * Description: Get flow ctrl mode. - * Input: - * @fifo_base: Need to get flow ctrl mode of the FIFO, the base - * address of the FIFO. - * return: - * Flow ctrl config - * Note: - */ -static inline u32 ipa_phy_get_flow_ctrl_config(void __iomem *fifo_base) -{ - u32 tmp; - - tmp = readl_relaxed(fifo_base + IPA_FLOW_CTRL_CONFIG); - - return (tmp & 0x00000003); -} - -/** - * Description: Set tx fifo exit flow ctrl watermark. - * Input: - * @fifo_base: Need to be set of the FIFO, the base - * address of the FIFO. - * @watermark: The need to be set. - * return: - * 0: Set successfully. - * non-zero: Set failed. - * Note: - */ -static inline int -ipa_phy_set_tx_fifo_exit_flow_ctrl_watermark(void __iomem *fifo_base, - u32 watermark) -{ - u32 tmp; - void __iomem *fifo_reg_addr; - - fifo_reg_addr = fifo_base + IPA_TX_FIFO_FLOW_CTRL; - - tmp = readl_relaxed(fifo_reg_addr); - tmp &= 0x0000FFFFUL; - tmp |= (watermark << 16); - writel_relaxed(tmp, fifo_reg_addr); - - tmp = readl_relaxed(fifo_reg_addr); - if ((tmp >> 16) == watermark) - return 0; - else - return -EIO; -} - -/** - * Description: Get tx fifo exit flow ctrl watermark. - * Input: - * @fifo_base: Need to be get of the FIFO, the base - * address of the FIFO. - * return: - * Tx fifo exit watermark. - * Note: - */ -static inline u32 -ipa_phy_get_tx_fifo_exit_flow_ctrl_watermark(void __iomem *fifo_base) -{ - u32 tmp; - - tmp = readl_relaxed(fifo_base + IPA_TX_FIFO_FLOW_CTRL); - - return (tmp >> 16); -} - -/** - * Description: Set tx fifo entry flow ctrl watermark. - * Input: - * @fifo_base: Need to be set of the FIFO, the base - * address of the FIFO. - * @watermark: The need to be set. - * return: - * 0: Set successfully. - * non-zero: Set failed. - * Note: - */ -static inline int -ipa_phy_set_tx_fifo_entry_flow_ctrl_watermark(void __iomem *fifo_base, - u32 watermark) -{ - u32 tmp; - void __iomem *fifo_reg_addr; - - fifo_reg_addr = fifo_base + IPA_TX_FIFO_FLOW_CTRL; - - tmp = readl_relaxed(fifo_reg_addr); - tmp &= 0xFFFF0000UL; - tmp |= watermark; - writel_relaxed(tmp, fifo_reg_addr); - tmp = readl_relaxed(fifo_reg_addr); - - if ((tmp & 0x0000FFFFUL) == watermark) - return 0; - else - return -EIO; -} - -/** - * Description: Get tx fifo entry flow ctrl watermark. - * Input: - * @fifo_base: Need to be get of the FIFO, the base - * address of the FIFO. - * return: - * @The value of tx fifo entry watermark. - * Note: - */ -static inline u32 -ipa_phy_get_tx_fifo_entry_flow_ctrl_watermark(void __iomem *fifo_base) -{ - u32 tmp; - - tmp = readl_relaxed(fifo_base + IPA_TX_FIFO_FLOW_CTRL); - - return (tmp & 0x0000FFFF); -} - -/** - * Description: Set rx fifo exit flow ctrl watermark. - * Input: - * @fifo_base: Need to be set of the FIFO, the base - * address of the FIFO. - * @watermark: The value of rx fifo exit watermark. - * return: - * 0: Set successfully. - * non-zero: Set failed. - * Note: - */ -static inline int -ipa_phy_set_rx_fifo_exit_flow_ctrl_watermark(void __iomem *fifo_base, - u32 watermark) -{ - u32 tmp; - void __iomem *fifo_reg_addr; - - fifo_reg_addr = fifo_base + IPA_RX_FIFO_FLOW_CTRL; - - tmp = readl_relaxed(fifo_reg_addr); - tmp &= 0x0000FFFFUL; - tmp |= (watermark << 16); - writel_relaxed(tmp, fifo_reg_addr); - tmp = readl_relaxed(fifo_reg_addr); - - if ((tmp >> 16) == watermark) - return 0; - else - return -EIO; -} - -/** - * Description: Get rx fifo exit flow ctrl watermark. - * Input: - * @fifo_base: Need to be get of the FIFO, the base - * address of the FIFO. - * return: - * The value of rx fifo exit watermark. - * Note: - */ -static inline u32 -ipa_phy_get_rx_fifo_exit_flow_ctrl_watermark(void __iomem *fifo_base) -{ - u32 tmp; - - tmp = readl_relaxed(fifo_base + IPA_RX_FIFO_FLOW_CTRL); - - return (tmp >> 16); -} - -/** - * Description: Set rx fifo entry flow ctrl watermark. - * Input: - * @fifo_base: Need to be set of the FIFO, the base - * address of the FIFO. - * @watermark: The value of rx fifo entry watermark. - * return: - * TRUE: Set successfully. - * FALSE: Set failed. - * Note: - */ -static inline int -ipa_phy_set_rx_fifo_entry_flow_ctrl_watermark(void __iomem *fifo_base, - u32 watermark) -{ - u32 tmp; - void __iomem *fifo_reg_addr; - - fifo_reg_addr = fifo_base + IPA_RX_FIFO_FLOW_CTRL; - tmp = readl_relaxed(fifo_reg_addr); - tmp &= 0xFFFF0000UL; - tmp |= watermark; - writel_relaxed(tmp, fifo_reg_addr); - tmp = readl_relaxed(fifo_reg_addr); - - if ((tmp & 0x0000FFFFUL) == watermark) - return 0; - else - return -EIO; -} - -/** - * Description: Get rx fifo entry flow ctrl watermark. - * Input: - * @fifo_base: Need to be get of the FIFO, the base - * address of the FIFO. - * return: - * The value of rx fifo entry watermark. - * Note: - */ -static inline u32 -ipa_phy_get_rx_fifo_entry_flow_ctrl_watermark(void __iomem *fifo_base) -{ - u32 tmp; - - tmp = readl_relaxed(fifo_base + IPA_RX_FIFO_FLOW_CTRL); - - return (tmp & 0x0000FFFF); -} - -/** - * Description: Get rx_axi_read_cmd_sts - * return: - * rx_axi_read_cmd_sts. - * Note: - */ -static inline u32 ipa_phy_get_rx_fifo_axi_sts(void __iomem *fifo_base) -{ - u32 tmp; - - tmp = readl_relaxed(fifo_base + IPA_COMMON_RX_FIFO_AXI_STS); - - return (tmp & 0x00000003); -} -#endif diff --git a/quectel_SRPD_PCIE/src/sipa/sipa_skb_recv.c b/quectel_SRPD_PCIE/src/sipa/sipa_skb_recv.c deleted file mode 100644 index 63c60b9..0000000 --- a/quectel_SRPD_PCIE/src/sipa/sipa_skb_recv.c +++ /dev/null @@ -1,674 +0,0 @@ -/* - * Copyright (C) 2020 Unisoc Communications Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 4,4,60 )) -#include -#include -#endif - - -#include "../include/sipa.h" -#include "sipa_core.h" -#include "sipa_eth.h" - -#define SIPA_RECV_BUF_LEN 1600 -#define SIPA_RECV_RSVD_LEN 128 - -static int put_recv_array_node(struct sipa_skb_array *p, - struct sk_buff *skb, u64 *dma_addr) -{ - u32 pos; - - if ((p->wp - p->rp) < p->depth) { - pos = p->wp & (p->depth - 1); - p->array[pos].skb = skb; - p->array[pos].dma_addr = *dma_addr; - /* - * Ensure that we put the item to the fifo before - * we update the fifo wp. - */ - smp_wmb(); - p->wp++; - return 0; - } else { - return -1; - } -} - -static int get_recv_array_node(struct sipa_skb_array *p, - struct sk_buff **skb, u64 *dma_addr) -{ - u32 pos; - - if (p->rp != p->wp) { - pos = p->rp & (p->depth -1); - *skb = p->array[pos].skb; - *dma_addr = p->array[pos].dma_addr; - /* - * Ensure that we remove the item from the fifo before - * we update the fifo rp. - */ - smp_wmb(); - p->rp++; - return 0; - } else { - return -1; - } -} - -static int create_recv_array(struct sipa_skb_array *p, u32 depth) -{ - p->array = kzalloc(sizeof(*p->array) * depth, - GFP_KERNEL); - if (!p->array) - return -ENOMEM; - p->rp = 0; - p->wp = 0; - p->depth = depth; - - return 0; -} - -static void destroy_recv_array(struct sipa_skb_array *p) -{ - kfree(p->array); - - p->array = NULL; - p->rp = 0; - p->wp = 0; - p->depth = 0; -} - -static struct sk_buff *alloc_recv_skb(u32 req_len, u8 rsvd) -{ - struct sk_buff *skb; - u32 hr; - struct sipa_core *ctrl = sipa_get_ctrl_pointer(); - - skb = __dev_alloc_skb(req_len + rsvd, GFP_KERNEL | GFP_NOWAIT); - if (!skb) { - dev_err(ctrl->dev, "failed to alloc skb!\n"); - return NULL; - } - - /* save skb ptr to skb->data */ - hr = skb_headroom(skb); - if (hr < rsvd) - skb_reserve(skb, rsvd - hr); - - return skb; -} - -static void sipa_prepare_free_node_init(struct sipa_skb_receiver *receiver, - u32 cnt) -{ - struct sk_buff *skb; - u32 tmp, fail_cnt = 0; - int i; - u32 success_cnt = 0; - u64 dma_addr; - struct sipa_node_description_tag *node; -#if defined (__BIG_ENDIAN_BITFIELD) - struct sipa_node_description_tag node_tmp; -#endif - struct sipa_core *ctrl = sipa_get_ctrl_pointer(); - struct sipa_cmn_fifo_cfg_tag *cmn = receiver->ep->recv_fifo; - - for (i = 0; i < cnt; i++) { - skb = alloc_recv_skb(SIPA_RECV_BUF_LEN, receiver->rsvd); - if (!skb) { - fail_cnt++; - break; - } - - tmp = skb_headroom(skb); - if (unlikely(tmp > SIPA_RECV_RSVD_LEN)) { - tmp -= SIPA_RECV_RSVD_LEN; - skb_put(skb, SIPA_RECV_BUF_LEN - tmp); - skb_push(skb, tmp); - } else { - skb_put(skb, SIPA_RECV_BUF_LEN); - } - - dma_addr = (u64)dma_map_single(ctrl->pci_dev, - skb->head, - SIPA_RECV_BUF_LEN + - skb_headroom(skb), - DMA_FROM_DEVICE); - if (dma_mapping_error(ctrl->pci_dev, (dma_addr_t)dma_addr)) { - dev_kfree_skb_any(skb); - dev_err(ctrl->dev, - "prepare free node dma map err\n"); - fail_cnt++; - break; - } - - node = ctrl->hal_ops.get_rx_fifo_wr(cmn->fifo_id, - ctrl->cmn_fifo_cfg, - i); - if (!node) { - dma_unmap_single(ctrl->pci_dev, dma_addr, - SIPA_RECV_BUF_LEN + - skb_headroom(skb), - DMA_FROM_DEVICE); - dev_kfree_skb_any(skb); - dev_err(ctrl->dev, - "get node fail index = %d\n", i); - fail_cnt++; - break; - } - - dma_addr += ctrl->pcie_mem_offset; -#if defined (__BIG_ENDIAN_BITFIELD) - memset(&node_tmp, 0, sizeof(node_tmp)); - node_tmp.address = dma_addr; - node_tmp.length = skb->len; - node_tmp.offset = skb_headroom(skb); - node_tmp.dst = ctrl->ep.recv_fifo->dst; - node_tmp.src = ctrl->ep.recv_fifo->cur; - node_tmp.intr = 0; - node_tmp.net_id = 0; - node_tmp.err_code = 0; - sipa_set_node_desc((u8 *)node, (u8 *)&node_tmp); -#else - node->address = dma_addr; - node->length = skb->len; - node->offset = skb_headroom(skb); - node->dst = ctrl->ep.recv_fifo->dst; - node->src = ctrl->ep.recv_fifo->cur; - node->intr = 0; - node->net_id = 0; - node->err_code = 0; -#endif - if (dma_addr == 0 || node->address == 0) - pr_info("cnt = %d, i = %d, dma_addr 0x%llx, node->address 0x%llx\n", - cnt, i, dma_addr, (long long unsigned int)node->address); - put_recv_array_node(&receiver->recv_array, skb, &dma_addr); - success_cnt++; - } - if (fail_cnt) - dev_err(ctrl->dev, - "fail_cnt = %d success_cnt = %d\n", - fail_cnt, success_cnt); -} - -static void fill_free_fifo(struct sipa_skb_receiver *receiver, u32 cnt) -{ - struct sk_buff *skb; - u32 tmp, fail_cnt = 0; - int i; - u32 success_cnt = 0, depth; - u64 dma_addr; - struct sipa_node_description_tag *node; -#if defined (__BIG_ENDIAN_BITFIELD) - struct sipa_node_description_tag node_tmp; -#endif - struct sipa_core *ctrl = sipa_get_ctrl_pointer(); - struct sipa_cmn_fifo_cfg_tag *cmn = receiver->ep->recv_fifo; - - depth = cmn->rx_fifo.depth; - if (cnt > (depth - depth / 4)) { -// dev_warn(ctrl->dev, "free node is not enough,need fill %d\n", cnt); - receiver->rx_danger_cnt++; - } - - for (i = 0; i < cnt; i++) { - skb = alloc_recv_skb(SIPA_RECV_BUF_LEN, receiver->rsvd); - if (!skb) { - fail_cnt++; - break; - } - - tmp = skb_headroom(skb); - if (unlikely(tmp > SIPA_RECV_RSVD_LEN)) { - tmp -= SIPA_RECV_RSVD_LEN; - skb_put(skb, SIPA_RECV_BUF_LEN - tmp); - skb_push(skb, tmp); - } else { - skb_put(skb, SIPA_RECV_BUF_LEN); - } - - dma_addr = (u64)dma_map_single(ctrl->pci_dev, - skb->head, - SIPA_RECV_BUF_LEN + - skb_headroom(skb), - DMA_FROM_DEVICE); - if (dma_mapping_error(ctrl->pci_dev, (dma_addr_t)dma_addr)) { - dev_kfree_skb_any(skb); - dev_err(ctrl->dev, - "prepare free node dma map err\n"); - fail_cnt++; - break; - } - node = ctrl->hal_ops.get_rx_fifo_wr(cmn->fifo_id, - ctrl->cmn_fifo_cfg, - i); - if (!node) { - dma_unmap_single(ctrl->pci_dev, dma_addr, - SIPA_RECV_BUF_LEN + - skb_headroom(skb), - DMA_FROM_DEVICE); - dev_kfree_skb_any(skb); - dev_err(ctrl->dev, - "get node fail index = %d\n", i); - fail_cnt++; - break; - } - - dma_addr += ctrl->pcie_mem_offset; -#if defined (__BIG_ENDIAN_BITFIELD) - memset(&node_tmp, 0, sizeof(node_tmp)); - node_tmp.address = dma_addr; - node_tmp.length = skb->len; - node_tmp.offset = skb_headroom(skb); - node_tmp.dst = ctrl->ep.recv_fifo->dst; - node_tmp.src = ctrl->ep.recv_fifo->cur; - node_tmp.intr = 0; - node_tmp.net_id = 0; - node_tmp.err_code = 0; - sipa_set_node_desc((u8 *)node, (u8 *)&node_tmp); -#else - node->address = dma_addr; - node->length = skb->len; - node->offset = skb_headroom(skb); - node->dst = ctrl->ep.recv_fifo->dst; - node->src = ctrl->ep.recv_fifo->cur; - node->intr = 0; - node->net_id = 0; - node->err_code = 0; -#endif - - put_recv_array_node(&receiver->recv_array, skb, &dma_addr); - success_cnt++; - } - - if (success_cnt) { - ctrl->hal_ops.set_rx_fifo_wr(ctrl->pci_dev, - cmn->fifo_id, - ctrl->cmn_fifo_cfg, - success_cnt); - if (atomic_read(&receiver->need_fill_cnt) > 0) - atomic_sub(success_cnt, - &receiver->need_fill_cnt); - } - - if (fail_cnt) - dev_err(ctrl->dev, - "fill free fifo fail_cnt = %d\n", fail_cnt); -} - -static void sipa_fill_free_node(struct sipa_skb_receiver *receiver, u32 cnt) -{ - struct sipa_core *ctrl = sipa_get_ctrl_pointer(); - - ctrl->hal_ops.set_rx_fifo_wr(ctrl->pci_dev, - receiver->ep->recv_fifo->fifo_id, - ctrl->cmn_fifo_cfg, cnt); - - if (atomic_read(&receiver->need_fill_cnt) > 0) - dev_info(ctrl->dev, - "a very serious problem, mem cover may appear\n"); - - atomic_set(&receiver->need_fill_cnt, 0); -} - -static void sipa_receiver_notify_cb(void *priv, enum sipa_irq_evt_type evt, - unsigned long data) -{ - struct sipa_core *ctrl = sipa_get_ctrl_pointer(); - struct sipa_skb_receiver *receiver = (struct sipa_skb_receiver *)priv; - - if (evt & SIPA_RECV_WARN_EVT) { - dev_dbg(ctrl->dev, - "sipa maybe poor resources evt = 0x%x\n", evt); - receiver->tx_danger_cnt++; - } - - sipa_dummy_recv_trigger(); -} - -static void sipa_free_recv_skb(struct sipa_skb_receiver *receiver) -{ - u64 addr = 0; - struct sk_buff *recv_skb = NULL; - while(!get_recv_array_node(&receiver->recv_array, &recv_skb, &addr)) - { - dev_kfree_skb_any(recv_skb); - } -} - -struct sk_buff *sipa_recv_skb(int *netid, int index) -{ - int ret = -1; - u32 retry_cnt = 10; - u64 addr = 0; - struct sk_buff *recv_skb = NULL; -#if defined (__BIG_ENDIAN_BITFIELD) - struct sipa_node_description_tag node; -#else - struct sipa_node_description_tag *node; -#endif - struct sipa_core *ctrl = sipa_get_ctrl_pointer(); - struct sipa_skb_receiver *receiver = ctrl->receiver; - enum sipa_cmn_fifo_index id = receiver->ep->recv_fifo->fifo_id; - - ret = get_recv_array_node(&receiver->recv_array, - &recv_skb, &addr); -read_again: -#if defined (__BIG_ENDIAN_BITFIELD) - sipa_get_node_desc((u8 *)ctrl->hal_ops.get_tx_fifo_rp(id, - ctrl->cmn_fifo_cfg, index), &node); -#else - node = ctrl->hal_ops.get_tx_fifo_rp(id, ctrl->cmn_fifo_cfg, index); -#endif - -#if defined (__BIG_ENDIAN_BITFIELD) - if (!node.address) { -#else - if (!node->address) { -#endif - if (retry_cnt--) { - udelay(1); - goto read_again; - } - -#if defined (__BIG_ENDIAN_BITFIELD) - dev_err(ctrl->dev, "phy addr is null = %llx\n", - (u64)node.address); -#else - dev_err(ctrl->dev, "phy addr is null = %llx\n", - (u64)node->address); -#endif - if(!ret) { - dma_unmap_single(ctrl->pci_dev, (dma_addr_t)(addr - ctrl->pcie_mem_offset), - SIPA_RECV_BUF_LEN + skb_headroom(recv_skb), - DMA_FROM_DEVICE); - dev_kfree_skb_any(recv_skb); - atomic_add(1, &receiver->need_fill_cnt); - ctrl->hal_ops.set_tx_fifo_rp(id, ctrl->cmn_fifo_cfg, 1); - dev_err(ctrl->dev, - "recv addr is null, but recv_array addr:0x%llx\n", - addr); - } - return NULL; - } - - retry_cnt = 10; -check_again: - if (ret) { -#if defined (__BIG_ENDIAN_BITFIELD) - dev_err(ctrl->dev, - "recv addr:0x%llx, but recv_array is empty\n", - (u64)node.address); -#else - dev_err(ctrl->dev, - "recv addr:0x%llx, but recv_array is empty\n", - (u64)node->address); -#endif - return NULL; -#if defined (__BIG_ENDIAN_BITFIELD) - } else if (addr != node.address && retry_cnt) { -#else - } else if (addr != node->address && retry_cnt) { -#endif - retry_cnt--; - udelay(1); -#if defined (__BIG_ENDIAN_BITFIELD) - sipa_get_node_desc((u8 *)ctrl->hal_ops.get_tx_fifo_rp(id, - ctrl->cmn_fifo_cfg, index), &node); -#endif - goto check_again; -#if defined (__BIG_ENDIAN_BITFIELD) - } else if (addr != node.address && !retry_cnt) { -#else - } else if (addr != node->address && !retry_cnt) { -#endif - dma_unmap_single(ctrl->pci_dev, (dma_addr_t)(addr - ctrl->pcie_mem_offset), - SIPA_RECV_BUF_LEN + skb_headroom(recv_skb), - DMA_FROM_DEVICE); - dev_kfree_skb_any(recv_skb); - atomic_add(1, &receiver->need_fill_cnt); - dev_err(ctrl->dev, - "recv addr:0x%llx, but recv_array addr:0x%llx not equal\n", -#if defined (__BIG_ENDIAN_BITFIELD) - (u64)node.address, addr); -#else - (u64)node->address, addr); -#endif - ctrl->hal_ops.set_tx_fifo_rp(id, ctrl->cmn_fifo_cfg, 1); - return NULL; - } - dma_unmap_single(ctrl->pci_dev, (dma_addr_t)(addr - ctrl->pcie_mem_offset), - SIPA_RECV_BUF_LEN + skb_headroom(recv_skb), - DMA_FROM_DEVICE); - - atomic_add(1, &receiver->need_fill_cnt); - if (atomic_read(&receiver->need_fill_cnt) > 0x30) - wake_up(&receiver->fill_recv_waitq); - -#if defined (__BIG_ENDIAN_BITFIELD) - *netid = node.net_id; -#else - *netid = node->net_id; -#endif - return recv_skb; -} -EXPORT_SYMBOL(sipa_recv_skb); - -static int fill_recv_thread(void *data) -{ - int ret; - struct sipa_skb_receiver *receiver = (struct sipa_skb_receiver *)data; - struct sched_param param = {.sched_priority = 92}; - unsigned long flags; - - sched_setscheduler(current, SCHED_RR, ¶m); - - while (!kthread_should_stop()) { - ret = wait_event_interruptible(receiver->fill_recv_waitq, - (atomic_read(&receiver->need_fill_cnt) > 0) || receiver->run == 0); - spin_lock_irqsave(&receiver->exit_lock, flags); - if(receiver->run == 0) { - spin_unlock_irqrestore(&receiver->exit_lock, flags); - break; - } - spin_unlock_irqrestore(&receiver->exit_lock, flags); - if (!ret) - fill_free_fifo(receiver, atomic_read(&receiver->need_fill_cnt)); - } - - sipa_free_recv_skb(receiver); - if (receiver->recv_array.array) - destroy_recv_array(&receiver->recv_array); - - kfree(receiver); - return 0; -} - -bool sipa_check_recv_tx_fifo_empty(void) -{ - struct sipa_core *ctrl = sipa_get_ctrl_pointer(); - enum sipa_cmn_fifo_index id = ctrl->receiver->ep->recv_fifo->fifo_id; - - if (!ctrl->remote_ready) - return true; - - return ctrl->hal_ops.get_tx_empty_status(id, ctrl->cmn_fifo_cfg); -} -EXPORT_SYMBOL(sipa_check_recv_tx_fifo_empty); - -void sipa_receiver_open_cmn_fifo(struct sipa_skb_receiver *receiver) -{ - struct sipa_core *ctrl = sipa_get_ctrl_pointer(); - struct sipa_cmn_fifo_cfg_tag *fifo_cfg = receiver->ep->recv_fifo; - - if (unlikely(!ctrl || !receiver)) { - pr_err("ctrl %p receiver %p not ready\n", ctrl, receiver); - return; - } - - ctrl->hal_ops.open(fifo_cfg->fifo_id, ctrl->cmn_fifo_cfg, NULL); - sipa_fill_free_node(receiver, fifo_cfg->rx_fifo.depth); - - ctrl->hal_ops.set_hw_intr_thres(fifo_cfg->fifo_id, - ctrl->cmn_fifo_cfg, - true, 64, NULL); - /* timeout = 1 / ipa_sys_clk * 1024 * value */ - ctrl->hal_ops.set_hw_intr_timeout(fifo_cfg->fifo_id, - ctrl->cmn_fifo_cfg, - true, 0x32, NULL); - -// ctrl->hal_ops.set_intr_txfifo_full(fifo_cfg->fifo_id, -// ctrl->cmn_fifo_cfg, -// true, NULL); -} -EXPORT_SYMBOL(sipa_receiver_open_cmn_fifo); - -static void sipa_receiver_init(struct sipa_skb_receiver *receiver, u32 rsvd) -{ - u32 depth; - struct sipa_core *ctrl = sipa_get_ctrl_pointer(); - enum sipa_cmn_fifo_index fifo_id = receiver->ep->recv_fifo->fifo_id; - - dev_info(ctrl->dev, - "fifo_id = %d rx_fifo depth = 0x%x\n", - receiver->ep->recv_fifo->fifo_id, - receiver->ep->recv_fifo->rx_fifo.depth); - - ctrl->cmn_fifo_cfg[fifo_id].irq_cb = - (sipa_irq_notify_cb)sipa_receiver_notify_cb; - ctrl->cmn_fifo_cfg[fifo_id].priv = receiver; - - /* reserve space for dma flushing cache issue */ - receiver->rsvd = rsvd; - depth = receiver->ep->recv_fifo->rx_fifo.depth; - - sipa_prepare_free_node_init(receiver, depth); -} - -void sipa_receiver_add_nic(struct sipa_skb_receiver *receiver, - struct sipa_nic *nic) -{ - int i; - unsigned long flags; - - for (i = 0; i < receiver->nic_cnt; i++) - if (receiver->nic_array[i] == nic) - return; - spin_lock_irqsave(&receiver->lock, flags); - if (receiver->nic_cnt < SIPA_NIC_MAX) - receiver->nic_array[receiver->nic_cnt++] = nic; - spin_unlock_irqrestore(&receiver->lock, flags); -} -EXPORT_SYMBOL(sipa_receiver_add_nic); - -void sipa_reinit_recv_array(struct sipa_skb_receiver *receiver) -{ - if (!receiver) { - pr_err("sipa receiver is null\n"); - return; - } - - if (!receiver->recv_array.array) { - pr_err("sipa p->array is null\n"); - return; - } - - receiver->recv_array.rp = 0; - receiver->recv_array.wp = receiver->recv_array.depth; -} - -int create_sipa_skb_receiver(struct sipa_endpoint *ep, - struct sipa_skb_receiver **receiver_pp) -{ - int ret; - struct sipa_skb_receiver *receiver = NULL; - struct sipa_core *ctrl = sipa_get_ctrl_pointer(); - - receiver = kzalloc(sizeof(*receiver), GFP_KERNEL); - if (!receiver) - return -ENOMEM; - - receiver->ep = ep; - receiver->rsvd = SIPA_RECV_RSVD_LEN; - - atomic_set(&receiver->need_fill_cnt, 0); - - ret = create_recv_array(&receiver->recv_array, - receiver->ep->recv_fifo->rx_fifo.depth); - if (ret) { - dev_err(ctrl->dev, - "create_sipa_sipa_receiver: recv_array kzalloc err.\n"); - kfree(receiver); - return -ENOMEM; - } - - spin_lock_init(&receiver->lock); - spin_lock_init(&receiver->exit_lock); - init_waitqueue_head(&receiver->fill_recv_waitq); - - sipa_receiver_init(receiver, SIPA_RECV_RSVD_LEN); - receiver->run = 1; - receiver->fill_thread = kthread_create(fill_recv_thread, receiver, - "sipa-fill"); - if (IS_ERR(receiver->fill_thread)) { - dev_err(ctrl->dev, "Failed to create kthread: ipa-fill\n"); - ret = PTR_ERR(receiver->fill_thread); - kfree(receiver->recv_array.array); - kfree(receiver); - return ret; - } - - wake_up_process(receiver->fill_thread); - - *receiver_pp = receiver; - return 0; -} -EXPORT_SYMBOL(create_sipa_skb_receiver); - -void destroy_sipa_skb_receiver(struct sipa_skb_receiver *receiver) -{ - unsigned long flags; - - spin_lock_irqsave(&receiver->exit_lock, flags); - receiver->run = 0; - wake_up_interruptible_all(&receiver->fill_recv_waitq); - spin_unlock_irqrestore(&receiver->exit_lock, flags); -} -EXPORT_SYMBOL(destroy_sipa_skb_receiver); diff --git a/quectel_SRPD_PCIE/src/sipa/sipa_skb_send.c b/quectel_SRPD_PCIE/src/sipa/sipa_skb_send.c deleted file mode 100644 index f70bd16..0000000 --- a/quectel_SRPD_PCIE/src/sipa/sipa_skb_send.c +++ /dev/null @@ -1,556 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 4,4,60 )) -#include -#include -#endif - - -#include "sipa_phy_v0/sipa_fifo_phy.h" -#include "../include/sipa.h" -#include "sipa_core.h" -#include "sipa_eth.h" - -#define SIPA_RECEIVER_BUF_LEN 1600 - -static void sipa_inform_evt_to_nics(struct sipa_skb_sender *sender, - enum sipa_evt_type evt) -{ - - struct sipa_nic *nic; - unsigned long flags; - spin_lock_irqsave(&sender->nic_lock, flags); - - if(SIPA_LEAVE_FLOWCTRL == evt){ - if(sender->free_notify_net == true){ - pr_info("%s, not leave flowctl, free_notify_net is true\n", __func__); - return; - } - - if(sender->ep_cover_net == true){ - pr_info("%s, not leave flowctl, ep_cover_net is true\n", __func__); - return; - } - - pr_info("%s, leave flowctl\n", __func__); - list_for_each_entry(nic, &sender->nic_list, list) { - if (nic->flow_ctrl_status == true) { - nic->flow_ctrl_status = false; - sipa_nic_notify_evt(nic, evt); - } - } - }else{ - pr_info("%s, enter flowctl\n", __func__); - list_for_each_entry(nic, &sender->nic_list, list) { - if (nic->flow_ctrl_status == false) { - nic->flow_ctrl_status = true; - sipa_nic_notify_evt(nic, evt); - } - } - } - - spin_unlock_irqrestore(&sender->nic_lock, flags); -} - -static void sipa_sender_notify_cb(void *priv, enum sipa_irq_evt_type evt, - unsigned long data) -{ - unsigned long flags; - struct sipa_skb_sender *sender = (struct sipa_skb_sender *)priv; - struct sipa_core *ctrl = sipa_get_ctrl_pointer(); - - if (evt & SIPA_RECV_WARN_EVT) { - dev_err(ctrl->dev, - "sipa overflow on ep\n"); - sender->no_free_cnt++; - } - - if (evt & SIPA_IRQ_ENTER_FLOW_CTRL) { - spin_lock_irqsave(&sender->send_lock, flags); - pr_info("sipa_sender_notify_cb set ep_cover_net true!!!!!\n"); - sender->enter_flow_ctrl_cnt++; - sender->ep_cover_net = true; - sipa_inform_evt_to_nics(sender, SIPA_ENTER_FLOWCTRL); - spin_unlock_irqrestore(&sender->send_lock, flags); - } - - if (evt & SIPA_IRQ_EXIT_FLOW_CTRL) { - spin_lock_irqsave(&sender->send_lock, flags); - sender->exit_flow_ctrl_cnt++; - sender->ep_cover_net = false; - sipa_inform_evt_to_nics(sender, SIPA_LEAVE_FLOWCTRL); - spin_unlock_irqrestore(&sender->send_lock, flags); - } - wake_up(&sender->free_waitq); -} - -static void sipa_free_sent_items(struct sipa_skb_sender *sender) -{ - bool status = false; - unsigned long flags; - u32 i, num, success_cnt = 0, retry_cnt = 10, failed_cnt = 0; - struct sipa_skb_dma_addr_node *iter, *_iter; -#if defined (__BIG_ENDIAN_BITFIELD) - struct sipa_node_description_tag node; -#else - struct sipa_node_description_tag *node; -#endif - struct sipa_core *ctrl = sipa_get_ctrl_pointer(); - enum sipa_cmn_fifo_index id = sender->ep->send_fifo->fifo_id; - u32 tx_wr, tx_rd, rx_wr, rx_rd; - int exit_flow = 0; - struct sipa_cmn_fifo_cfg_tag *fifo_cfg; - void __iomem *fifo_base; - u32 clr_sts = 0; - u32 int_status = 0; - u32 read_count = 0; - - num = ctrl->hal_ops.recv_node_from_tx_fifo(ctrl->dev, id, - ctrl->cmn_fifo_cfg, -1); - for (i = 0; i < num; i++) { - retry_cnt = 10; -#if defined (__BIG_ENDIAN_BITFIELD) - sipa_get_node_desc((u8 *)ctrl->hal_ops.get_tx_fifo_rp(id, - ctrl->cmn_fifo_cfg, i), &node); -#else - node = ctrl->hal_ops.get_tx_fifo_rp(id, ctrl->cmn_fifo_cfg, i); -#endif - -#if defined (__BIG_ENDIAN_BITFIELD) - if (node.err_code) - dev_err(ctrl->dev, "have node transfer err = %d\n", - node.err_code); -#else - if (node->err_code) - dev_err(ctrl->dev, "have node transfer err = %d\n", - node->err_code); -#endif - -check_again: - spin_lock_irqsave(&sender->send_lock, flags); - if (list_empty(&sender->sending_list)) { - ctrl->hal_ops.get_rx_ptr(SIPA_FIFO_PCIE_UL, ctrl->cmn_fifo_cfg, &rx_wr, &rx_rd); - ctrl->hal_ops.get_tx_ptr(SIPA_FIFO_PCIE_UL, ctrl->cmn_fifo_cfg, &tx_wr, &tx_rd); - dev_err(ctrl->dev, "fifo id %d: send list is empty, old tx_wr=%x tx_rd=%x, rx_wr=%x, rx_rd=%x, left_cnt=%d\n", - sender->ep->send_fifo->fifo_id, tx_wr, tx_rd, rx_wr, rx_rd, atomic_read(&sender->left_cnt)); - - spin_unlock_irqrestore(&sender->send_lock, flags); - goto sipa_free_end; - } - - list_for_each_entry_safe(iter, _iter, &sender->sending_list, list) { -#if defined (__BIG_ENDIAN_BITFIELD) - if (iter->dma_addr == node.address) { -#else - if (iter->dma_addr == node->address) { -#endif - list_del(&iter->list); - list_add_tail(&iter->list, - &sender->pair_free_list); - status = true; - break; - } - } - spin_unlock_irqrestore(&sender->send_lock, flags); - - if (status) { - dma_unmap_single(ctrl->pci_dev, - (dma_addr_t)(iter->dma_addr - ctrl->pcie_mem_offset), - iter->skb->len + - skb_headroom(iter->skb), - DMA_TO_DEVICE); - - dev_kfree_skb_any(iter->skb); - success_cnt++; - status = false; - } else { - if (retry_cnt--) { -#if defined (__BIG_ENDIAN_BITFIELD) - sipa_get_node_desc((u8 *)ctrl->hal_ops.get_tx_fifo_rp(id, - ctrl->cmn_fifo_cfg, i), &node); -#endif - //dev_err(ctrl->dev, "free send skb warning, retry_cnt = %d\n", retry_cnt); - goto check_again; - } - failed_cnt++; - } - } - if(failed_cnt >0){ - dev_err(ctrl->dev, "can't find matching nodes num=%d\n", failed_cnt); - } - - ctrl->hal_ops.set_tx_fifo_rp(id, ctrl->cmn_fifo_cfg, i); - atomic_add(success_cnt, &sender->left_cnt); - if (num != success_cnt) - dev_err(ctrl->dev, "recv num = %d release num = %d\n", num, success_cnt); - -sipa_free_end: - if (sender->free_notify_net && atomic_read(&sender->left_cnt) > sender->ep->send_fifo->rx_fifo.depth / 4) { - sender->free_notify_net = false; - exit_flow = 1; - } - - if(sender->ep_cover_net == true){ - fifo_cfg = ctrl->cmn_fifo_cfg + sender->ep->send_fifo->fifo_id; - fifo_base = fifo_cfg->fifo_reg_base; - - int_status = ipa_phy_get_fifo_all_int_sts(fifo_base); - - if (int_status & IPA_INT_EXIT_FLOW_CTRL_STS) { - exit_flow = 1; - sender->ep_cover_net = false; - clr_sts |= IPA_EXIT_FLOW_CONTROL_CLR_BIT; - ipa_phy_clear_int(fifo_base, clr_sts); - pr_info("%s, exit flow control\n", __func__); - }else{ - pr_info("%s, still in flow control\n", __func__); - } - } - - if(exit_flow == 1){ - spin_lock_irqsave(&sender->send_lock, flags); - sipa_inform_evt_to_nics(sender, SIPA_LEAVE_FLOWCTRL); - spin_unlock_irqrestore(&sender->send_lock, flags); - } -} - -static bool sipa_sender_ck_unfree(struct sipa_skb_sender *sender) -{ - struct sipa_core *ctrl = sipa_get_ctrl_pointer(); - enum sipa_cmn_fifo_index id = sender->ep->send_fifo->fifo_id; - if (!ctrl->remote_ready) { - printk("%s: need wait remote_ready!\n", __func__); - return false; - } - - if (ctrl->hal_ops.get_tx_empty_status(id, ctrl->cmn_fifo_cfg)) { - ctrl->hal_ops.clr_tout_th_intr(id, ctrl->cmn_fifo_cfg); - ctrl->hal_ops.set_intr_eb(id, ctrl->cmn_fifo_cfg, true, - SIPA_FIFO_THRESHOLD_IRQ_EN | - SIPA_FIFO_DELAY_TIMER_IRQ_EN); - return false; - } else { - return true; - } -} - -static void sipa_free_send_skb(struct sipa_skb_sender *sender) -{ - struct sipa_skb_dma_addr_node *iter, *_iter; - struct sipa_core *ctrl = sipa_get_ctrl_pointer(); - unsigned long flags; - - spin_lock_irqsave(&sender->send_lock, flags); - if (list_empty(&sender->sending_list)) { - dev_err(ctrl->dev, "fifo id %d: send list is empty\n", sender->ep->send_fifo->fifo_id); - spin_unlock_irqrestore(&sender->send_lock, flags); - return; - } - - list_for_each_entry_safe(iter, _iter, &sender->sending_list, list) { - list_del(&iter->list); - list_add_tail(&iter->list, &sender->pair_free_list); - dma_unmap_single(ctrl->pci_dev, (dma_addr_t)(iter->dma_addr - ctrl->pcie_mem_offset), - iter->skb->len + skb_headroom(iter->skb), DMA_TO_DEVICE); - dev_kfree_skb_any(iter->skb); - } - spin_unlock_irqrestore(&sender->send_lock, flags); -} - -static int sipa_free_thread(void *data) -{ - struct sipa_skb_sender *sender = (struct sipa_skb_sender *)data; - struct sched_param param = {.sched_priority = 90}; - struct sipa_core *ctrl = sipa_get_ctrl_pointer(); - enum sipa_cmn_fifo_index id = sender->ep->send_fifo->fifo_id; - unsigned long flags; - struct sipa_nic *iter, *_iter; - sched_setscheduler(current, SCHED_RR, ¶m); - - while (!kthread_should_stop()) { - wait_event_interruptible(sender->free_waitq, - sender->free_notify_net || sender->run == 0 || sender->ep_cover_net || - sipa_sender_ck_unfree(sender)); - - spin_lock_irqsave(&sender->exit_lock, flags); - if(sender->run == 0) { - spin_unlock_irqrestore(&sender->exit_lock, flags); - break; - } - spin_unlock_irqrestore(&sender->exit_lock, flags); - sipa_free_sent_items(sender); - - if (!ctrl->hal_ops.get_tx_empty_status(id, ctrl->cmn_fifo_cfg)) { - usleep_range(100, 200); - //pr_info("%s, not empty\n", __func__); - } - } - - sipa_free_send_skb(sender); - kfree(sender->pair_cache); - - list_for_each_entry_safe(iter, _iter, &sender->nic_list, list) { - list_del(&iter->list); - kfree(iter); - } - - kfree(sender); - - return 0; -} - -void sipa_sender_open_cmn_fifo(struct sipa_skb_sender *sender) -{ - struct sipa_core *ctrl = sipa_get_ctrl_pointer(); - struct sipa_cmn_fifo_cfg_tag *fifo_cfg = sender->ep->send_fifo; - - if (unlikely(!ctrl || !sender)) { - pr_err("ctrl %p sender %p not ready\n", ctrl, sender); - return; - } - - fifo_cfg->irq_cb = (sipa_irq_notify_cb)sipa_sender_notify_cb; - fifo_cfg->priv = sender; - ctrl->hal_ops.open(fifo_cfg->fifo_id, ctrl->cmn_fifo_cfg, NULL); - - ctrl->hal_ops.set_hw_intr_thres(fifo_cfg->fifo_id, - ctrl->cmn_fifo_cfg, true, - 128, NULL); - ctrl->hal_ops.set_hw_intr_timeout(fifo_cfg->fifo_id, ctrl->cmn_fifo_cfg, - true, 0x64, NULL); - - ctrl->hal_ops.set_intr_txfifo_full(fifo_cfg->fifo_id, - ctrl->cmn_fifo_cfg, true, NULL); -} -EXPORT_SYMBOL(sipa_sender_open_cmn_fifo); - -int create_sipa_skb_sender(struct sipa_endpoint *ep, - struct sipa_skb_sender **sender_pp) -{ - int i, ret; - struct sipa_skb_sender *sender = NULL; - struct sipa_core *ctrl = sipa_get_ctrl_pointer(); - - dev_info(ctrl->dev, "sender create start\n"); - sender = kzalloc(sizeof(*sender), GFP_KERNEL); - if (!sender) { - dev_err(ctrl->dev, "alloc sender failed\n"); - return -ENOMEM; - } - - sender->pair_cache = kcalloc(ep->send_fifo->rx_fifo.depth, - sizeof(struct sipa_skb_dma_addr_node), - GFP_KERNEL); - if (!sender->pair_cache) { - dev_err(ctrl->dev, "alloc sender->pair_cache fail\n"); - kfree(sender); - return -ENOMEM; - } - - INIT_LIST_HEAD(&sender->nic_list); - INIT_LIST_HEAD(&sender->sending_list); - INIT_LIST_HEAD(&sender->pair_free_list); - spin_lock_init(&sender->nic_lock); - spin_lock_init(&sender->send_lock); - spin_lock_init(&sender->exit_lock); - for (i = 0; i < ep->send_fifo->rx_fifo.depth; i++) - list_add_tail(&((sender->pair_cache + i)->list), - &sender->pair_free_list); - - sender->ep = ep; - - atomic_set(&sender->left_cnt, ep->send_fifo->rx_fifo.depth / 4 * 3); - - init_waitqueue_head(&sender->free_waitq); - sender->run = 1; - sender->free_thread = kthread_create(sipa_free_thread, sender, - "sipa-free"); - if (IS_ERR(sender->free_thread)) { - dev_err(ctrl->dev, "Failed to create kthread: ipa-free\n"); - ret = PTR_ERR(sender->free_thread); - kfree(sender->pair_cache); - kfree(sender); - return ret; - } - - *sender_pp = sender; - wake_up_process(sender->free_thread); - return 0; -} -EXPORT_SYMBOL(create_sipa_skb_sender); - -void destroy_sipa_skb_sender(struct sipa_skb_sender *sender) -{ - unsigned long flags; - - spin_lock_irqsave(&sender->exit_lock, flags); - sender->run = 0; - wake_up_interruptible_all(&sender->free_waitq); - spin_unlock_irqrestore(&sender->exit_lock, flags); -} -EXPORT_SYMBOL(destroy_sipa_skb_sender); - -void sipa_skb_sender_add_nic(struct sipa_skb_sender *sender, - struct sipa_nic *nic) -{ - unsigned long flags; - - spin_lock_irqsave(&sender->nic_lock, flags); - list_add_tail(&nic->list, &sender->nic_list); - spin_unlock_irqrestore(&sender->nic_lock, flags); -} -EXPORT_SYMBOL(sipa_skb_sender_add_nic); - -void sipa_skb_sender_remove_nic(struct sipa_skb_sender *sender, - struct sipa_nic *nic) -{ - unsigned long flags; - - spin_lock_irqsave(&sender->nic_lock, flags); - list_del(&nic->list); - spin_unlock_irqrestore(&sender->nic_lock, flags); -} -EXPORT_SYMBOL(sipa_skb_sender_remove_nic); - -int sipa_skb_sender_send_data(struct sipa_skb_sender *sender, - struct sk_buff *skb, - enum sipa_term_type dst, - u8 netid) -{ - unsigned long flags; - u64 dma_addr; - struct sipa_skb_dma_addr_node *node; -#if defined (__BIG_ENDIAN_BITFIELD) - struct sipa_node_description_tag des; -#else - struct sipa_node_description_tag *des; -#endif - struct sipa_core *ctrl = sipa_get_ctrl_pointer(); - struct sipa_cmn_fifo_cfg_tag *fifo_cfg; - void __iomem *fifo_base; - u32 clr_sts = 0; - u32 int_status = 0; - - spin_lock_irqsave(&sender->send_lock, flags); - - if (sender->ep_cover_net == true){ - pr_info("%s, ep_cover_net is true, so return EAGAIN\n", __func__); - spin_unlock_irqrestore(&sender->send_lock, flags); - wake_up(&sender->free_waitq); - return -EAGAIN; - }else{ - fifo_cfg = ctrl->cmn_fifo_cfg + sender->ep->send_fifo->fifo_id; - fifo_base = fifo_cfg->fifo_reg_base; - int_status = ipa_phy_get_fifo_all_int_sts(fifo_base); - if(int_status == 0x5FF000){ - pr_err("%s: check sts failed, maybe ep is down\n", __func__); - spin_unlock_irqrestore(&sender->send_lock, flags); - return -EINPROGRESS; - } - - if (int_status & IPA_INT_ENTER_FLOW_CTRL_STS) { - pr_info("sipa_skb_sender_send_data set ep_cover_net true!!!!!\n"); - sender->ep_cover_net = true; - sender->enter_flow_ctrl_cnt++; - clr_sts |= IPA_ENTRY_FLOW_CONTROL_CLR_BIT; - ipa_phy_clear_int(fifo_base, clr_sts); - sipa_inform_evt_to_nics(sender, SIPA_ENTER_FLOWCTRL); - spin_unlock_irqrestore(&sender->send_lock, flags); - wake_up(&sender->free_waitq); - return -EAGAIN; - } - } - - if (sender->free_notify_net == true){ - pr_info("%s: free_notify_net is true, so return EAGAIN\n", __func__); - spin_unlock_irqrestore(&sender->send_lock, flags); - wake_up(&sender->free_waitq); - return -EAGAIN; - } - - if (!atomic_read(&sender->left_cnt)) { - sender->no_free_cnt++; - sender->free_notify_net = true; - sipa_inform_evt_to_nics(sender, SIPA_ENTER_FLOWCTRL); - spin_unlock_irqrestore(&sender->send_lock, flags); - wake_up(&sender->free_waitq); - return -EAGAIN; - } - - dma_addr = (u64)dma_map_single(ctrl->pci_dev, skb->head, - skb->len + skb_headroom(skb), - DMA_TO_DEVICE); - - if (unlikely(dma_mapping_error(ctrl->pci_dev, (dma_addr_t)dma_addr))) { - sender->free_notify_net = true; - sipa_inform_evt_to_nics(sender, SIPA_ENTER_FLOWCTRL); - spin_unlock_irqrestore(&sender->send_lock, flags); - wake_up(&sender->free_waitq); - return -EAGAIN; - } - - dma_addr += ctrl->pcie_mem_offset; -#if defined (__BIG_ENDIAN_BITFIELD) - memset(&des, 0, sizeof(des)); - des.address = dma_addr; - des.length = skb->len; - des.offset = skb_headroom(skb); - des.net_id = netid; - des.dst = dst; - des.src = sender->ep->send_fifo->cur; - des.err_code = 0; - des.intr = 0; - sipa_set_node_desc((u8 *)ctrl->hal_ops.get_rx_fifo_wr(sender->ep->send_fifo->fifo_id, - ctrl->cmn_fifo_cfg, 0), (u8 *)&des); -#else - des = ctrl->hal_ops.get_rx_fifo_wr(sender->ep->send_fifo->fifo_id, - ctrl->cmn_fifo_cfg, 0); - des->address = dma_addr; - des->length = skb->len; - des->offset = skb_headroom(skb); - des->net_id = netid; - des->dst = dst; - des->src = sender->ep->send_fifo->cur; - des->err_code = 0; - des->intr = 0; -#endif - node = list_first_entry(&sender->pair_free_list, - struct sipa_skb_dma_addr_node, - list); - node->skb = skb; - node->dma_addr = dma_addr; - list_del(&node->list); - list_add_tail(&node->list, &sender->sending_list); - ctrl->hal_ops.set_rx_fifo_wr(ctrl->pci_dev, - sender->ep->send_fifo->fifo_id, - ctrl->cmn_fifo_cfg, 1); - atomic_dec(&sender->left_cnt); - spin_unlock_irqrestore(&sender->send_lock, flags); - - return 0; -} -EXPORT_SYMBOL(sipa_skb_sender_send_data); diff --git a/quectel_SRPD_PCIE/src/sipc/Kconfig b/quectel_SRPD_PCIE/src/sipc/Kconfig deleted file mode 100644 index 9fe1419..0000000 --- a/quectel_SRPD_PCIE/src/sipc/Kconfig +++ /dev/null @@ -1,26 +0,0 @@ -menu "SIPC modules" - -config SPRD_SIPC - bool "Sprd IPC" - default n - select GENERIC_ALLOCATOR - help - SIPC is a module for spreadtrum AP/CP communicaiton system. - -config SPRD_SIPC_SPIPE - bool "SPRD pipe driver based on SBUF" - default n - depends on SPRD_SIPC - help - This driver is a pipe driver base on SBUF, which create - general pipes between AP & CP. - -config SPRD_SIPC_SPOOL - bool "SPRD pool driver based on SBLOCK" - default n - depends on SPRD_SIPC - help - This driver is a pool driver base on SBLOCK, which create - general pools between AP & CP. - -endmenu diff --git a/quectel_SRPD_PCIE/src/sipc/Makefile b/quectel_SRPD_PCIE/src/sipc/Makefile deleted file mode 100644 index caed73a..0000000 --- a/quectel_SRPD_PCIE/src/sipc/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -ccflags-y += -DCONFIG_SPRD_PCIE_EP_DEVICE -DCONFIG_SPRD_SIPA - -obj-y += sipc.o smsg.o smem.o sbuf.o sblock.o sipc_debugfs.o -obj-y += spipe.o -obj-y += spool.o - diff --git a/quectel_SRPD_PCIE/src/sipc/sblock.c b/quectel_SRPD_PCIE/src/sipc/sblock.c deleted file mode 100644 index 730f531..0000000 --- a/quectel_SRPD_PCIE/src/sipc/sblock.c +++ /dev/null @@ -1,1911 +0,0 @@ -/* - * Copyright (C) 2019 Spreadtrum Communications Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 4,4,60 )) -#include -#include -#endif - -#include "../include/sipc.h" -#include "sipc_priv.h" -#include "sblock.h" - -static struct sblock_mgr *sblocks[SIPC_ID_NR][SMSG_VALID_CH_NR]; - -/* put one block pack to the pool */ -void sblock_put(u8 dst, u8 channel, struct sblock *blk) -{ - struct sblock_mgr *sblock; - struct sblock_ring *ring; - unsigned long flags; - int txpos; - int index; - u8 ch_index; - struct sblock_ring_header_op *poolhd_op; - - ch_index = sipc_channel2index(channel); - if (ch_index == INVALID_CHANEL_INDEX) { - pr_err("%s:channel %d invalid!\n", __func__, channel); - return; - } - - sblock = sblocks[dst][ch_index]; - if (!sblock) - return; - - ring = sblock->ring; - poolhd_op = &(ring->header_op.poolhd_op); - - spin_lock_irqsave(&ring->p_txlock, flags); - txpos = sblock_get_ringpos(*(poolhd_op->tx_rd_p) - 1, - poolhd_op->tx_count); - ring->p_txblks[txpos].addr = blk->addr - - sblock->smem_virt + - sblock->stored_smem_addr; - ring->p_txblks[txpos].length = poolhd_op->tx_size; - *(poolhd_op->tx_rd_p) = *(poolhd_op->tx_rd_p) - 1; - if ((int)(*(poolhd_op->tx_wt_p) - *(poolhd_op->tx_rd_p)) == 1) - wake_up_interruptible_all(&(ring->getwait)); - index = sblock_get_index((blk->addr - ring->txblk_virt), - sblock->txblksz); - ring->txrecord[index] = SBLOCK_BLK_STATE_DONE; - - spin_unlock_irqrestore(&ring->p_txlock, flags); - - /* set write mask. */ - spin_lock_irqsave(&ring->poll_lock, flags); - ring->poll_mask |= POLLOUT | POLLWRNORM; - spin_unlock_irqrestore(&ring->poll_lock, flags); - - /* request in sblock_get, release here */ - sipc_smem_release_resource(ring->tx_pms, dst); -} -EXPORT_SYMBOL_GPL(sblock_put); - -static bool sblock_has_data(struct sblock_mgr *sblock, bool tx) -{ - struct sblock_ring_header_op *poolhd_op; - struct sblock_ring_header_op *ringhd_op; - struct sblock_ring *ring = sblock->ring; - bool has_data; - unsigned long flags; - - /* if it is local share memory, - * check the read and write point directly. - */ - if (smsg_ipcs[sblock->dst]->smem_type == SMEM_LOCAL) { - if (tx) { - poolhd_op = &ring->header_op.poolhd_op; - return *(poolhd_op->tx_rd_p) != *(poolhd_op->tx_wt_p); - } - - ringhd_op = &ring->header_op.ringhd_op; - return *(ringhd_op->rx_wt_p) != *(ringhd_op->rx_rd_p); - } - - /* - * if it is remote share memmory read the poll_mask, this situation - * requires that the poll_mask must be accurate enough. - */ - spin_lock_irqsave(&ring->poll_lock, flags); - if (tx) - has_data = ring->poll_mask & (POLLOUT | POLLWRNORM); - else - has_data = ring->poll_mask & (POLLIN | POLLRDNORM); - spin_unlock_irqrestore(&ring->poll_lock, flags); - - return has_data; -} - -/* clean rings and recover pools */ -static int sblock_recover(u8 dst, u8 channel) -{ - struct sblock_mgr *sblock; - struct sblock_ring *ring = NULL; - struct sblock_ring_header_op *poolhd_op; - struct sblock_ring_header_op *ringhd_op; - unsigned long pflags, qflags; - int i, j, rval; - u8 ch_index; - - ch_index = sipc_channel2index(channel); - if (ch_index == INVALID_CHANEL_INDEX) { - pr_err("%s:channel %d invalid!\n", __func__, channel); - return -EINVAL; - } - - sblock = sblocks[dst][ch_index]; - if (!sblock) - return -ENODEV; - - ring = sblock->ring; - poolhd_op = &(ring->header_op.poolhd_op); - ringhd_op = &(ring->header_op.ringhd_op); - - sblock->state = SBLOCK_STATE_IDLE; - wake_up_interruptible_all(&ring->getwait); - wake_up_interruptible_all(&ring->recvwait); - - /* must request resource before read or write share memory */ - rval = sipc_smem_request_resource(ring->rx_pms, dst, -1); - if (rval < 0) - return rval; - - spin_lock_irqsave(&ring->r_txlock, pflags); - /* clean txblks ring */ - *(ringhd_op->tx_wt_p) = *(ringhd_op->tx_rd_p); - - spin_lock_irqsave(&ring->p_txlock, qflags); - /* recover txblks pool */ - *(poolhd_op->tx_rd_p) = *(poolhd_op->tx_wt_p); - for (i = 0, j = 0; i < poolhd_op->tx_count; i++) { - if (ring->txrecord[i] == SBLOCK_BLK_STATE_DONE) { - ring->p_txblks[j].addr = i * sblock->txblksz + - poolhd_op->tx_addr; - ring->p_txblks[j].length = sblock->txblksz; - *(poolhd_op->tx_wt_p) = *(poolhd_op->tx_wt_p) + 1; - j++; - } - } - spin_unlock_irqrestore(&ring->p_txlock, qflags); - spin_unlock_irqrestore(&ring->r_txlock, pflags); - - spin_lock_irqsave(&ring->r_rxlock, pflags); - /* clean rxblks ring */ - *(ringhd_op->rx_rd_p) = *(ringhd_op->rx_wt_p); - - spin_lock_irqsave(&ring->p_rxlock, qflags); - /* recover rxblks pool */ - *(poolhd_op->rx_wt_p) = *(poolhd_op->rx_rd_p); - for (i = 0, j = 0; i < poolhd_op->rx_count; i++) { - if (ring->rxrecord[i] == SBLOCK_BLK_STATE_DONE) { - ring->p_rxblks[j].addr = i * sblock->rxblksz + - poolhd_op->rx_addr; - ring->p_rxblks[j].length = sblock->rxblksz; - *(poolhd_op->rx_wt_p) = *(poolhd_op->rx_wt_p) + 1; - j++; - } - } - spin_unlock_irqrestore(&ring->p_rxlock, qflags); - spin_unlock_irqrestore(&ring->r_rxlock, pflags); - - /* restore write mask. */ - spin_lock_irqsave(&ring->poll_lock, qflags); - ring->poll_mask |= POLLOUT | POLLWRNORM; - spin_unlock_irqrestore(&ring->poll_lock, qflags); - - /* release resource */ - sipc_smem_release_resource(ring->rx_pms, dst); - - return 0; -} - -static int sblock_host_init(struct smsg_ipc *sipc, struct sblock_mgr *sblock, - u32 txblocknum, u32 txblocksize, - u32 rxblocknum, u32 rxblocksize) -{ - volatile struct sblock_ring_header *ringhd; - volatile struct sblock_ring_header *poolhd; - struct sblock_ring_header_op *ringhd_op; - struct sblock_ring_header_op *poolhd_op; - - u32 hsize; - int i, rval = -ENOMEM; - phys_addr_t offset = 0; - u8 dst = sblock->dst; - - txblocksize = ALIGN(txblocksize, SBLOCK_ALIGN_BYTES); - rxblocksize = ALIGN(rxblocksize, SBLOCK_ALIGN_BYTES); - sblock->txblksz = txblocksize; - sblock->rxblksz = rxblocksize; - sblock->txblknum = txblocknum; - sblock->rxblknum = rxblocknum; - - pr_debug("%s: channel %d-%d, txblocksize=%#x, rxblocksize=%#x!\n", - __func__, - sblock->dst, - sblock->channel, - txblocksize, - rxblocksize); - - pr_debug("%s: channel %d-%d, txblocknum=%#x, rxblocknum=%#x!\n", - __func__, - sblock->dst, - sblock->channel, - txblocknum, - rxblocknum); - - /* allocate smem */ - hsize = sizeof(struct sblock_header); - /* for header*/ - sblock->smem_size = hsize + - /* for blks */ - txblocknum * txblocksize + rxblocknum * rxblocksize + - /* for ring */ - (txblocknum + rxblocknum) * sizeof(struct sblock_blks) + - /* for pool */ - (txblocknum + rxblocknum) * sizeof(struct sblock_blks); - - sblock->smem_addr = smem_alloc(dst, sblock->smem_size); - if (!sblock->smem_addr) { - pr_err("%s: channel %d-%d, Failed to alloc smem for sblock\n", - __func__, - sblock->dst, - sblock->channel); - return -ENOMEM; - } - - pr_debug("%s: channel %d-%d, smem_addr=%#lx, smem_size=%#x!\n", - __func__, - sblock->dst, - sblock->channel, - (unsigned long)(sblock->smem_addr + offset), - sblock->smem_size); - - sblock->dst_smem_addr = sblock->smem_addr - - sipc->smem_base + sipc->dst_smem_base; - - /* in host mode, it is client physial address. */ - sblock->stored_smem_addr = sblock->dst_smem_addr; - -#ifdef CONFIG_PHYS_ADDR_T_64BIT - offset = sipc->high_offset; - offset = offset << 32; -#endif - pr_debug("%s: channel %d-%d, offset = 0x%lx!\n", - __func__, - sblock->dst, - sblock->channel, - (unsigned long)offset); - sblock->smem_virt = shmem_ram_vmap_nocache(dst, - sblock->smem_addr + offset, - sblock->smem_size); - if (!sblock->smem_virt) { - pr_err("%s: channel %d-%d, Failed to map smem for sblock\n", - __func__, - sblock->dst, - sblock->channel); - goto sblock_host_smem_free; - } - - /* alloc ring */ - sblock->ring->txrecord = kcalloc(txblocknum, sizeof(int), GFP_KERNEL); - if (!sblock->ring->txrecord) - goto sblock_host_unmap; - - sblock->ring->rxrecord = kcalloc(rxblocknum, sizeof(int), GFP_KERNEL); - if (!sblock->ring->rxrecord) - goto sblock_host_tx_free; - - /* must request resource before read or write share memory */ - rval = sipc_smem_request_resource(sipc->sipc_pms, sipc->dst, -1); - if (rval < 0) - goto sblock_host_rx_free; - - /* initialize header */ - ringhd = (volatile struct sblock_ring_header *)(sblock->smem_virt); - ringhd->txblk_addr = sblock->stored_smem_addr + hsize; - ringhd->txblk_count = txblocknum; - ringhd->txblk_size = txblocksize; - ringhd->txblk_rdptr = 0; - ringhd->txblk_wrptr = 0; - ringhd->txblk_blks = ringhd->txblk_addr + - txblocknum * txblocksize + rxblocknum * rxblocksize; - ringhd->rxblk_addr = ringhd->txblk_addr + txblocknum * txblocksize; - ringhd->rxblk_count = rxblocknum; - ringhd->rxblk_size = rxblocksize; - ringhd->rxblk_rdptr = 0; - ringhd->rxblk_wrptr = 0; - ringhd->rxblk_blks = ringhd->txblk_blks + - txblocknum * sizeof(struct sblock_blks); - - poolhd = ringhd + 1; - poolhd->txblk_addr = sblock->stored_smem_addr + hsize; - poolhd->txblk_count = txblocknum; - poolhd->txblk_size = txblocksize; - poolhd->txblk_rdptr = 0; - poolhd->txblk_wrptr = 0; - poolhd->txblk_blks = ringhd->rxblk_blks + - rxblocknum * sizeof(struct sblock_blks); - poolhd->rxblk_addr = ringhd->txblk_addr + txblocknum * txblocksize; - poolhd->rxblk_count = rxblocknum; - poolhd->rxblk_size = rxblocksize; - poolhd->rxblk_rdptr = 0; - poolhd->rxblk_wrptr = 0; - poolhd->rxblk_blks = poolhd->txblk_blks + - txblocknum * sizeof(struct sblock_blks); - - pr_debug("%s: channel %d-%d, int ring!\n", - __func__, - sblock->dst, - sblock->channel); - - /* initialize ring */ - sblock->ring->header = sblock->smem_virt; - sblock->ring->txblk_virt = sblock->smem_virt + - (ringhd->txblk_addr - sblock->stored_smem_addr); - sblock->ring->r_txblks = sblock->smem_virt + - (ringhd->txblk_blks - sblock->stored_smem_addr); - sblock->ring->rxblk_virt = sblock->smem_virt + - (ringhd->rxblk_addr - sblock->stored_smem_addr); - sblock->ring->r_rxblks = sblock->smem_virt + - (ringhd->rxblk_blks - sblock->stored_smem_addr); - sblock->ring->p_txblks = sblock->smem_virt + - (poolhd->txblk_blks - sblock->stored_smem_addr); - sblock->ring->p_rxblks = sblock->smem_virt + - (poolhd->rxblk_blks - sblock->stored_smem_addr); - - for (i = 0; i < txblocknum; i++) { - sblock->ring->p_txblks[i].addr = poolhd->txblk_addr + - i * txblocksize; - sblock->ring->p_txblks[i].length = txblocksize; - sblock->ring->txrecord[i] = SBLOCK_BLK_STATE_DONE; - poolhd->txblk_wrptr++; - } - for (i = 0; i < rxblocknum; i++) { - sblock->ring->p_rxblks[i].addr = poolhd->rxblk_addr + - i * rxblocksize; - sblock->ring->p_rxblks[i].length = rxblocksize; - sblock->ring->rxrecord[i] = SBLOCK_BLK_STATE_DONE; - poolhd->rxblk_wrptr++; - } - - /* init, set write mask. */ - sblock->ring->poll_mask = POLLOUT | POLLWRNORM; - - /* init header op */ - ringhd_op = &((sblock->ring->header_op).ringhd_op); - ringhd_op->tx_rd_p = &ringhd->txblk_rdptr; - ringhd_op->tx_wt_p = &ringhd->txblk_wrptr; - ringhd_op->rx_rd_p = &ringhd->rxblk_rdptr; - ringhd_op->rx_wt_p = &ringhd->rxblk_wrptr; - ringhd_op->tx_addr = ringhd->txblk_addr; - ringhd_op->tx_count = ringhd->txblk_count; - ringhd_op->tx_size = ringhd->txblk_size; - ringhd_op->tx_blks = ringhd->txblk_blks; - ringhd_op->rx_addr = ringhd->rxblk_addr; - ringhd_op->rx_count = ringhd->rxblk_count; - ringhd_op->rx_size = ringhd->rxblk_size; - ringhd_op->rx_blks = ringhd->rxblk_blks; - poolhd_op = &((sblock->ring->header_op).poolhd_op); - poolhd_op->tx_rd_p = &poolhd->txblk_rdptr; - poolhd_op->tx_wt_p = &poolhd->txblk_wrptr; - poolhd_op->rx_rd_p = &poolhd->rxblk_rdptr; - poolhd_op->rx_wt_p = &poolhd->rxblk_wrptr; - poolhd_op->tx_addr = poolhd->txblk_addr; - poolhd_op->tx_count = poolhd->txblk_count; - poolhd_op->tx_size = poolhd->txblk_size; - poolhd_op->tx_blks = poolhd->txblk_blks; - poolhd_op->rx_addr = poolhd->rxblk_addr; - poolhd_op->rx_count = poolhd->rxblk_count; - poolhd_op->rx_size = poolhd->rxblk_size; - poolhd_op->rx_blks = poolhd->rxblk_blks; - - /* release resource */ - sipc_smem_release_resource(sipc->sipc_pms, sipc->dst); - - return 0; - -sblock_host_rx_free: - kfree(sblock->ring->rxrecord); -sblock_host_tx_free: - kfree(sblock->ring->txrecord); -sblock_host_unmap: - shmem_ram_unmap(dst, sblock->smem_virt); -sblock_host_smem_free: - smem_free(dst, sblock->smem_addr, sblock->smem_size); - - pr_err("%s: channel %d-%d, failed, ENOMEM!\n", - __func__, - sblock->dst, - sblock->channel); - - return rval; -} - -static int sblock_client_init(struct smsg_ipc *sipc, struct sblock_mgr *sblock) -{ - volatile struct sblock_ring_header *ringhd; - volatile struct sblock_ring_header *poolhd; - struct sblock_ring_header_op *ringhd_op; - struct sblock_ring_header_op *poolhd_op; - u32 hsize; - u8 dst = sblock->dst; - phys_addr_t offset = 0; - u32 txblocknum, txblocksize, rxblocknum, rxblocksize; - int rval = -ENOMEM; - -#ifdef CONFIG_PHYS_ADDR_T_64BIT - offset = sipc->high_offset; - offset = offset << 32; - pr_debug("%s: channel %d-%d, offset = 0x%llx!\n", - __func__, - sblock->dst, - sblock->channel, - offset); -#endif - - /* get blcok num and block size */ - hsize = sizeof(struct sblock_header); - sblock->smem_virt = shmem_ram_vmap_nocache(dst, - sblock->smem_addr + offset, - hsize); - if (!sblock->smem_virt) { - pr_err("%s: channel %d-%d, Failed to map smem for sblock\n", - __func__, - sblock->dst, - sblock->channel); - return -ENOMEM; - } - ringhd = (volatile struct sblock_ring_header *)(sblock->smem_virt); - /* client mode, tx <==> rx */ - txblocknum = ringhd->rxblk_count; - txblocksize = ringhd->rxblk_size; - rxblocknum = ringhd->txblk_count; - rxblocksize = ringhd->txblk_size; - - sblock->txblksz = txblocksize; - sblock->rxblksz = rxblocksize; - sblock->txblknum = txblocknum; - sblock->rxblknum = rxblocknum; - shmem_ram_unmap(dst, sblock->smem_virt); - - pr_debug("%s: channel %d-%d, txblocksize=%#x, rxblocksize=%#x!\n", - __func__, - sblock->dst, - sblock->channel, - txblocksize, - rxblocksize); - - pr_debug("%s: channel %d-%d, txblocknum=%#x, rxblocknum=%#x!\n", - __func__, - sblock->dst, - sblock->channel, - txblocknum, - rxblocknum); - - /* allocate smem */ - /* for header*/ - sblock->smem_size = hsize + - /* for blks */ - txblocknum * txblocksize + rxblocknum * rxblocksize + - /* for ring */ - (txblocknum + rxblocknum) * sizeof(struct sblock_blks) + - /* for pool */ - (txblocknum + rxblocknum) * sizeof(struct sblock_blks); - - sblock->smem_addr_debug = smem_alloc(dst, sblock->smem_size); - if (!sblock->smem_addr_debug) { - pr_err("%s: channel %d-%d, Failed to allocate smem\n", - __func__, - sblock->dst, - sblock->channel); - return -ENOMEM; - } - - pr_debug("%s: channel %d-%d, smem_addr=%#lx, smem_size=%#x!\n", - __func__, - sblock->dst, - sblock->channel, - (unsigned long)(sblock->smem_addr + offset), - sblock->smem_size); - - /* in client mode, it is own physial address. */ - sblock->stored_smem_addr = sblock->smem_addr; - - /* get smem virtual address */ - sblock->smem_virt = shmem_ram_vmap_nocache(dst, - sblock->smem_addr + offset, - sblock->smem_size); - if (!sblock->smem_virt) { - pr_err("%s: channel %d-%d, Failed to map smem for sblock!\n", - __func__, - sblock->dst, - sblock->channel); - goto sblock_client_smem_free; - } - - /* initialize ring and header */ - sblock->ring->txrecord = kcalloc(txblocknum, sizeof(int), GFP_KERNEL); - if (!sblock->ring->txrecord) - goto sblock_client_unmap; - - sblock->ring->rxrecord = kcalloc(rxblocknum, sizeof(int), GFP_KERNEL); - if (!sblock->ring->rxrecord) - goto sblock_client_tx_free; - - ringhd = (volatile struct sblock_ring_header *)(sblock->smem_virt); - poolhd = ringhd + 1; - - /* must request resource before read or write share memory */ - rval = sipc_smem_request_resource(sipc->sipc_pms, sipc->dst, -1); - if (rval < 0) - goto sblock_client_tx_free; - - /* client mode, tx <==> rx */ - sblock->ring->header = sblock->smem_virt; - sblock->ring->txblk_virt = sblock->smem_virt + - (ringhd->rxblk_addr - sblock->stored_smem_addr); - sblock->ring->rxblk_virt = sblock->smem_virt + - (ringhd->txblk_addr - sblock->stored_smem_addr); - sblock->ring->r_txblks = sblock->smem_virt + - (ringhd->rxblk_blks - sblock->stored_smem_addr); - sblock->ring->r_rxblks = sblock->smem_virt + - (ringhd->txblk_blks - sblock->stored_smem_addr); - sblock->ring->p_txblks = sblock->smem_virt + - (poolhd->rxblk_blks - sblock->stored_smem_addr); - sblock->ring->p_rxblks = sblock->smem_virt + - (poolhd->txblk_blks - sblock->stored_smem_addr); - - /* init header op, tx <==> rx */ - ringhd_op = &((sblock->ring->header_op).ringhd_op); - ringhd_op->tx_rd_p = &ringhd->rxblk_rdptr; - ringhd_op->tx_wt_p = &ringhd->rxblk_wrptr; - ringhd_op->rx_rd_p = &ringhd->txblk_rdptr; - ringhd_op->rx_wt_p = &ringhd->txblk_wrptr; - ringhd_op->tx_addr = ringhd->rxblk_addr; - ringhd_op->tx_count = ringhd->rxblk_count; - ringhd_op->tx_size = ringhd->rxblk_size; - ringhd_op->tx_blks = ringhd->rxblk_blks; - ringhd_op->rx_addr = ringhd->txblk_addr; - ringhd_op->rx_count = ringhd->txblk_count; - ringhd_op->rx_size = ringhd->txblk_size; - ringhd_op->rx_blks = ringhd->txblk_blks; - poolhd_op = &((sblock->ring->header_op).poolhd_op); - poolhd_op->tx_rd_p = &poolhd->rxblk_rdptr; - poolhd_op->tx_wt_p = &poolhd->rxblk_wrptr; - poolhd_op->rx_rd_p = &poolhd->txblk_rdptr; - poolhd_op->rx_wt_p = &poolhd->txblk_wrptr; - poolhd_op->tx_addr = poolhd->rxblk_addr; - poolhd_op->tx_count = poolhd->rxblk_count; - poolhd_op->tx_size = poolhd->rxblk_size; - poolhd_op->tx_blks = poolhd->rxblk_blks; - poolhd_op->rx_addr = poolhd->txblk_addr; - poolhd_op->rx_count = poolhd->txblk_count; - poolhd_op->rx_size = poolhd->txblk_size; - poolhd_op->rx_blks = poolhd->txblk_blks; - - /* release resource */ - sipc_smem_release_resource(sipc->sipc_pms, sipc->dst); - - return 0; - -sblock_client_tx_free: - kfree(sblock->ring->txrecord); -sblock_client_unmap: - shmem_ram_unmap(dst, sblock->smem_virt); -sblock_client_smem_free: - smem_free(dst, sblock->smem_addr_debug, sblock->smem_size); - - return rval; -} - -static int sblock_thread(void *data) -{ - struct sblock_mgr *sblock = data; - struct smsg mcmd, mrecv; - unsigned long flags; - int rval; - int recovery = 0; - struct smsg_ipc *sipc; - struct sblock_ring *ring; - - /* since the channel open may hang, we call it in the sblock thread */ - rval = smsg_ch_open(sblock->dst, sblock->channel, -1); - if (rval != 0) { - pr_err("Failed to open channel %d\n", - sblock->channel); - - if (sblock->pre_cfg && sblock->handler) { - sblock->handler(SBLOCK_NOTIFY_OPEN_FAILED, - sblock->data); - } - - return rval; - } - - if (sblock->pre_cfg) { - sblock->state = SBLOCK_STATE_READY; - recovery = 1; - if (sblock->handler) - sblock->handler(SBLOCK_NOTIFY_OPEN, sblock->data); - } - - /* if client, send SMSG_CMD_SBLOCK_INIT, wait SMSG_DONE_SBLOCK_INIT */ - sipc = smsg_ipcs[sblock->dst]; - if (sipc->client) { - smsg_set(&mcmd, sblock->channel, SMSG_TYPE_CMD, - SMSG_CMD_SBLOCK_INIT, 0); - smsg_send(sblock->dst, &mcmd, -1); - do { - smsg_set(&mrecv, sblock->channel, 0, 0, 0); - rval = smsg_recv(sblock->dst, &mrecv, -1); - if (rval != 0) { - sblock->thread = NULL; - return rval; - } - } while (mrecv.type != SMSG_TYPE_DONE || - mrecv.flag != SMSG_DONE_SBLOCK_INIT); - sblock->smem_addr = mrecv.value; - pr_info("%s: channel %d-%d, done_sblock_init, address=0x%x!\n", - __func__, - sblock->dst, - sblock->channel, - sblock->smem_addr); - if (sblock_client_init(sipc, sblock)) { - sblock->thread = NULL; - return 0; - } - sblock->state = SBLOCK_STATE_READY; - if (sblock->handler) - sblock->handler(SBLOCK_NOTIFY_OPEN, - sblock->data); - } - - /* handle the sblock events */ - while (!kthread_should_stop()) { - /* monitor sblock recv smsg */ - smsg_set(&mrecv, sblock->channel, 0, 0, 0); - rval = smsg_recv(sblock->dst, &mrecv, -1); - if (rval == -EIO || rval == -ENODEV) { - /* channel state is FREE */ - msleep(20); - continue; - } - - pr_debug("sblock thread recv msg: dst=%d, channel=%d, type=%d, flag=0x%04x, value=0x%08x\n", - sblock->dst, sblock->channel, - mrecv.type, mrecv.flag, mrecv.value); - - switch (mrecv.type) { - case SMSG_TYPE_OPEN: - pr_info("%s: channel %d-%d,revc open!\n", - __func__, - sblock->dst, - sblock->channel); - /* handle channel recovery */ - if (recovery) { - if (sblock->handler) - sblock->handler(SBLOCK_NOTIFY_CLOSE, - sblock->data); - sblock_recover(sblock->dst, sblock->channel); - } - smsg_open_ack(sblock->dst, sblock->channel); - if (sblock->pre_cfg) - sblock->state = SBLOCK_STATE_READY; - break; - case SMSG_TYPE_CLOSE: - /* handle channel recovery */ - smsg_close_ack(sblock->dst, sblock->channel); - if (sblock->handler) - sblock->handler(SBLOCK_NOTIFY_CLOSE, - sblock->data); - sblock->state = SBLOCK_STATE_IDLE; - break; - case SMSG_TYPE_CMD: - if (!sblock->pre_cfg) { - /* respond cmd done for sblock init */ - WARN_ON(mrecv.flag != SMSG_CMD_SBLOCK_INIT); - smsg_set(&mcmd, - sblock->channel, - SMSG_TYPE_DONE, - SMSG_DONE_SBLOCK_INIT, - sblock->dst_smem_addr); - smsg_send(sblock->dst, &mcmd, -1); - sblock->state = SBLOCK_STATE_READY; - recovery = 1; - pr_info("%s: channel %d-%d, SMSG_CMD_SBLOCK_INIT, dst address = 0x%x!\n", - __func__, - sblock->dst, - sblock->channel, - sblock->dst_smem_addr); - - if (sblock->handler) - sblock->handler(SBLOCK_NOTIFY_OPEN, - sblock->data); - } - break; - case SMSG_TYPE_EVENT: - /* handle sblock send/release events */ - switch (mrecv.flag) { - case SMSG_EVENT_SBLOCK_SEND: - ring = sblock->ring; - /* set read mask. */ - spin_lock_irqsave(&ring->poll_lock, flags); - ring->poll_mask |= POLLIN | POLLRDNORM; - spin_unlock_irqrestore(&ring->poll_lock, flags); - wake_up_interruptible_all(&sblock->ring->recvwait); - if (sblock->handler) - sblock->handler(SBLOCK_NOTIFY_RECV, - sblock->data); - break; - case SMSG_EVENT_SBLOCK_RELEASE: - ring = sblock->ring; - /* set write mask. */ - spin_lock_irqsave(&ring->poll_lock, flags); - ring->poll_mask |= POLLOUT | POLLWRNORM; - spin_unlock_irqrestore(&ring->poll_lock, flags); - wake_up_interruptible_all(&sblock->ring->getwait); - if (sblock->handler) - sblock->handler(SBLOCK_NOTIFY_GET, - sblock->data); - break; - default: - rval = 1; - break; - } - break; - default: - rval = 1; - break; - }; - - if (rval) { - pr_info("non-handled sblock msg: %d-%d, %d, %d, %d\n", - sblock->dst, sblock->channel, - mrecv.type, mrecv.flag, mrecv.value); - rval = 0; - } - } - - pr_info("sblock %d-%d thread stop", - sblock->dst, sblock->channel); - return rval; -} - -static void sblock_pms_init(uint8_t dst, uint8_t ch, struct sblock_ring *ring) -{ - sprintf(ring->tx_pms_name, "sblock-%d-%d-tx", dst, ch); - ring->tx_pms = sprd_pms_create(dst, ring->tx_pms_name, true); - if (!ring->tx_pms) - pr_warn("create pms %s failed!\n", ring->tx_pms_name); - - sprintf(ring->rx_pms_name, "sblock-%d-%d-rx", dst, ch); - ring->rx_pms = sprd_pms_create(dst, ring->rx_pms_name, true); - if (!ring->rx_pms) - pr_warn("create pms %s failed!\n", ring->rx_pms_name); -} - -static void sblock_pms_destroy(struct sblock_ring *ring) -{ - sprd_pms_destroy(ring->tx_pms); - sprd_pms_destroy(ring->rx_pms); - ring->tx_pms = NULL; - ring->rx_pms = NULL; -} - -static int sblock_mgr_create(uint8_t dst, - uint8_t channel, - int pre_cfg, - uint32_t tx_blk_num, uint32_t tx_blk_sz, - uint32_t rx_blk_num, uint32_t rx_blk_sz, - struct sblock_mgr **sb_mgr) -{ - struct sblock_mgr *sblock = NULL; - struct smsg_ipc *sipc = smsg_ipcs[dst]; - int ret; - - pr_debug("%s: dst=%d channel=%d\n", __func__, dst, channel); - - if (!sipc) - return -EINVAL; - - sblock = kzalloc(sizeof(struct sblock_mgr), GFP_KERNEL); - if (!sblock) - return -ENOMEM; - - sblock->ring = kzalloc(sizeof(struct sblock_ring), GFP_KERNEL); - if (!sblock->ring) { - kfree(sblock); - return -ENOMEM; - } - - sblock->dst = dst; - sblock->channel = channel; - sblock->pre_cfg = pre_cfg; - sblock->state = SBLOCK_STATE_IDLE; - - if (!sipc->client) { - ret = sblock_host_init(sipc, sblock, - tx_blk_num, tx_blk_sz, - rx_blk_num, rx_blk_sz); - if (ret) { - kfree(sblock->ring); - kfree(sblock); - return ret; - } - } - - sblock_pms_init(dst, channel, sblock->ring); - init_waitqueue_head(&sblock->ring->getwait); - init_waitqueue_head(&sblock->ring->recvwait); - spin_lock_init(&sblock->ring->r_txlock); - spin_lock_init(&sblock->ring->r_rxlock); - spin_lock_init(&sblock->ring->p_txlock); - spin_lock_init(&sblock->ring->p_rxlock); - spin_lock_init(&sblock->ring->poll_lock); - - *sb_mgr = sblock; - - return 0; -} - -int sblock_create_ex(u8 dst, u8 channel, - u32 txblocknum, u32 txblocksize, - u32 rxblocknum, u32 rxblocksize, - void (*handler)(int event, void *data), void *data) -{ - struct sblock_mgr *sblock = NULL; - int result; - u8 ch_index; - struct smsg_ipc *sipc; - struct sched_param param = {.sched_priority = 11}; - - ch_index = sipc_channel2index(channel); - if (ch_index == INVALID_CHANEL_INDEX) { - pr_err("%s:channel %d invalid!\n", __func__, channel); - return -EINVAL; - } - - if (dst >= SIPC_ID_NR) { - pr_err("%s: dst = %d is invalid\n", __func__, dst); - return -EINVAL; - } - - pr_debug("%s: dst=%d channel=%d\n", __func__, dst, channel); - - result = sblock_mgr_create(dst, channel, 0, - txblocknum, txblocksize, - rxblocknum, rxblocksize, - &sblock); - if (!result) { - sblock->thread = kthread_create(sblock_thread, sblock, - "sblock-%d-%d", dst, channel); - if (IS_ERR(sblock->thread)) { - pr_err("Failed to create kthread: sblock-%d-%d\n", - dst, channel); - sipc = smsg_ipcs[sblock->dst]; - if (!sipc->client) { - shmem_ram_unmap(dst, sblock->smem_virt); - smem_free(dst, - sblock->smem_addr, - sblock->smem_size); - kfree(sblock->ring->txrecord); - kfree(sblock->ring->rxrecord); - } - kfree(sblock->ring); - result = PTR_ERR(sblock->thread); - kfree(sblock); - return result; - } - - /* Prevent the thread task_struct from being destroyed. */ - get_task_struct(sblock->thread); - - sblocks[dst][ch_index] = sblock; - if ((handler != NULL) && (data != NULL)) { - result = sblock_register_notifier(dst, channel, - handler, data); - if (result < 0) { - sblock_destroy(dst, channel); - return result; - } - } - /*set the thread as a real time thread, and its priority is 11*/ - sched_setscheduler(sblock->thread, SCHED_RR, ¶m); - wake_up_process(sblock->thread); - } - - pr_debug("%s: sblock-%d-%d create over, result = %d\n", - __func__, dst, channel, result); - - return result; -} -EXPORT_SYMBOL_GPL(sblock_create_ex); - -int sblock_create(u8 dst, u8 channel, - u32 txblocknum, u32 txblocksize, - u32 rxblocknum, u32 rxblocksize) -{ - return sblock_create_ex(dst, channel, txblocknum, txblocksize, - rxblocknum, rxblocksize, NULL, NULL); -} -EXPORT_SYMBOL_GPL(sblock_create); - -int sblock_pcfg_create(u8 dst, u8 channel, - u32 tx_blk_num, u32 tx_blk_sz, - u32 rx_blk_num, u32 rx_blk_sz) -{ - struct sblock_mgr *sblock = NULL; - int result; - u8 ch_index; - - ch_index = sipc_channel2index(channel); - if (ch_index == INVALID_CHANEL_INDEX) { - pr_err("%s:channel %d invalid!\n", __func__, channel); - return -EINVAL; - } - if (dst >= SIPC_ID_NR) { - pr_err("sblock_create_ex: dst = %d is invalid\n", dst); - return -EINVAL; - } - - pr_debug("%s: dst=%d channel=%d\n", __func__, dst, channel); - - result = sblock_mgr_create(dst, - channel, - 1, - tx_blk_num, tx_blk_sz, - rx_blk_num, rx_blk_sz, - &sblock); - if (!result) { - struct sched_param param = {.sched_priority = 11}; - - sblock->thread = kthread_create(sblock_thread, sblock, - "sblock-%d-%d", dst, channel); - if (IS_ERR(sblock->thread)) { - struct smsg_ipc *sipc; - - pr_err("Failed to create kthread: sblock-%d-%d\n", - dst, channel); - sipc = smsg_ipcs[sblock->dst]; - if (!sipc->client) { - shmem_ram_unmap(dst, sblock->smem_virt); - smem_free(dst, - sblock->smem_addr, - sblock->smem_size); - kfree(sblock->ring->txrecord); - kfree(sblock->ring->rxrecord); - } - kfree(sblock->ring); - result = PTR_ERR(sblock->thread); - kfree(sblock); - return result; - } - - /* Prevent the thread task_struct from being destroyed. */ - get_task_struct(sblock->thread); - - sblocks[dst][ch_index] = sblock; - /* - * Set the thread as a real time thread, and its priority - * is 11. - */ - sched_setscheduler(sblock->thread, SCHED_RR, ¶m); - wake_up_process(sblock->thread); - } - - return result; -} -EXPORT_SYMBOL_GPL(sblock_pcfg_create); - -void sblock_down(u8 dst, u8 channel) -{ - struct sblock_mgr *sblock; - u8 ch_index; - int i; - ch_index = sipc_channel2index(channel); - if (ch_index == INVALID_CHANEL_INDEX) { - pr_err("%s:channel %d invalid!\n", __func__, channel); - return; - } - - sblock = sblocks[dst][ch_index]; - if (sblock == NULL) - return; - - sblock->state = SBLOCK_STATE_IDLE; - if (sblock->ring) { - wake_up_interruptible_all(&sblock->ring->recvwait); - wake_up_interruptible_all(&sblock->ring->getwait); - } - pr_info("%s: channel=%d sblock down success\n", __func__, channel); - -} -EXPORT_SYMBOL_GPL(sblock_down); - -void sblock_destroy(u8 dst, u8 channel) -{ - struct sblock_mgr *sblock; - u8 ch_index; - struct smsg_ipc *sipc; - - ch_index = sipc_channel2index(channel); - if (ch_index == INVALID_CHANEL_INDEX) { - pr_err("%s:channel %d invalid!\n", __func__, channel); - return; - } - - sblock = sblocks[dst][ch_index]; - if (sblock == NULL) - return; - - sblock->state = SBLOCK_STATE_IDLE; - smsg_ch_close(dst, channel, -1); - - /* stop sblock thread if it's created successfully and still alive */ - if (!IS_ERR_OR_NULL(sblock->thread)) { - kthread_stop(sblock->thread); - put_task_struct(sblock->thread); - sblock->thread = NULL; - } - - if (sblock->ring) { - sblock_pms_destroy(sblock->ring); - wake_up_interruptible_all(&sblock->ring->recvwait); - wake_up_interruptible_all(&sblock->ring->getwait); - /* kfree(NULL) is safe */ - /* if (sblock->ring->txrecord) */ - kfree(sblock->ring->txrecord); - /* if (sblock->ring->rxrecord) */ - kfree(sblock->ring->rxrecord); - kfree(sblock->ring); - } - if (sblock->smem_virt) - shmem_ram_unmap(dst, sblock->smem_virt); - - sipc = smsg_ipcs[dst]; - if (sipc->client) - smem_free(dst, sblock->smem_addr_debug, sblock->smem_size); - else - smem_free(dst, sblock->smem_addr, sblock->smem_size); - kfree(sblock); - - sblocks[dst][ch_index] = NULL; -} -EXPORT_SYMBOL_GPL(sblock_destroy); - -int sblock_pcfg_open(uint8_t dest, uint8_t channel, - void (*notifier)(int event, void *client), - void *client) -{ - struct sblock_mgr *sblock; - uint8_t idx; - int ret; - struct sched_param param = {.sched_priority = 11}; - - pr_debug("%s: dst=%d channel=%d\n", __func__, dest, channel); - - if (!notifier) - return -EINVAL; - - idx = sipc_channel2index(channel); - if (idx == INVALID_CHANEL_INDEX) { - pr_err("%s: invalid channel %d!\n", __func__, channel); - return -ENODEV; - } - - sblock = sblocks[dest][idx]; - if (!sblock) - return -ENODEV; - - if (!sblock->pre_cfg) - return -EINVAL; - - if (sblock->thread) { - pr_err("%s: SBLOCK %u/%u already open", - __func__, - (unsigned int)sblock->dst, - (unsigned int)sblock->channel); - return -EPROTO; - } - - ret = 0; - sblock->thread = kthread_create(sblock_thread, sblock, - "sblock-%d-%d", dest, channel); - if (IS_ERR(sblock->thread)) { - pr_err("%s: create thread error\n", __func__); - sblock->thread = NULL; - ret = -EBUSY; - } else { - /* Prevent the thread task_struct from being destroyed. */ - get_task_struct(sblock->thread); - - sblock->handler = notifier; - sblock->data = client; - /*set the thread as a real time thread, and its priority is 11*/ - sched_setscheduler(sblock->thread, SCHED_RR, ¶m); - wake_up_process(sblock->thread); - } - - return ret; -} -EXPORT_SYMBOL_GPL(sblock_pcfg_open); - -int sblock_close(uint8_t dest, uint8_t channel) -{ - return -ENOTSUPP; -} -EXPORT_SYMBOL_GPL(sblock_close); - -int sblock_register_notifier(u8 dst, u8 channel, - void (*handler)(int event, void *data), - void *data) -{ - struct sblock_mgr *sblock; - u8 ch_index; - - ch_index = sipc_channel2index(channel); - if (ch_index == INVALID_CHANEL_INDEX) { - pr_err("%s:channel %d invalid!\n", __func__, channel); - return -EINVAL; - } - - sblock = sblocks[dst][ch_index]; - - if (!sblock) { - pr_err("%s:sblock-%d-%d not ready!\n", __func__, dst, channel); - return -ENODEV; - } -#ifndef CONFIG_SPRD_SIPC_WCN - if (sblock->handler) { - pr_err("sblock handler already registered\n"); - return -EBUSY; - } -#endif - sblock->handler = handler; - sblock->data = data; - - return 0; -} -EXPORT_SYMBOL_GPL(sblock_register_notifier); - -int sblock_get_smem_cp_addr(uint8_t dest, uint8_t channel, - uint32_t *paddr) -{ - struct sblock_mgr *sblock; - uint8_t idx; - - if (!paddr) - return -EINVAL; - - idx = sipc_channel2index(channel); - if (idx == INVALID_CHANEL_INDEX) { - pr_err("%s: invalid channel %d!\n", __func__, channel); - return -ENODEV; - } - - sblock = sblocks[dest][idx]; - if (!sblock) - return -ENODEV; - - *paddr = sblock->dst_smem_addr; - - return 0; -} -EXPORT_SYMBOL_GPL(sblock_get_smem_cp_addr); - -int sblock_get(u8 dst, u8 channel, struct sblock *blk, int timeout) -{ - struct sblock_mgr *sblock; - struct sblock_ring *ring; - struct sblock_ring_header_op *poolhd_op; - - int txpos, index; - int rval = 0; - unsigned long flags; - u8 ch_index; - bool no_data; - - ch_index = sipc_channel2index(channel); - if (ch_index == INVALID_CHANEL_INDEX) { - pr_err("%s:channel %d invalid!\n", __func__, channel); - return -EINVAL; - } - - sblock = sblocks[dst][ch_index]; - - if (!sblock || sblock->state != SBLOCK_STATE_READY) { - pr_err("%s:sblock-%d-%d not ready!\n", __func__, dst, channel); - return sblock ? -EIO : -ENODEV; - } - - ring = sblock->ring; - poolhd_op = &(ring->header_op.poolhd_op); - - /* must request resource before read or write share memory */ - rval = sipc_smem_request_resource(ring->tx_pms, dst, timeout); - if (rval < 0) - return rval; - - spin_lock_irqsave(&ring->poll_lock, flags); - no_data = *(poolhd_op->tx_rd_p) == *(poolhd_op->tx_wt_p); - /* update write mask */ - if (no_data) - ring->poll_mask &= ~(POLLOUT | POLLWRNORM); - else - ring->poll_mask |= POLLOUT | POLLWRNORM; - spin_unlock_irqrestore(&ring->poll_lock, flags); - - /* release resource */ - sipc_smem_release_resource(ring->tx_pms, dst); - - if (no_data) { - if (timeout == 0) { - /* no wait */ - pr_err("%s: %d-%d is empty!\n", __func__, dst, channel); - rval = -ENODATA; - } else if (timeout < 0) { - /* wait forever */ - rval = wait_event_interruptible(ring->getwait, - sblock_has_data(sblock, true) || - sblock->state == SBLOCK_STATE_IDLE); - if (rval < 0) - pr_debug("%s: wait interrupted!\n", __func__); - - if (sblock->state == SBLOCK_STATE_IDLE) { - pr_err("%s: state is idle!\n", __func__); - rval = -EIO; - } - } else { - /* wait timeout */ - rval = wait_event_interruptible_timeout(ring->getwait, - sblock_has_data(sblock, true) || - sblock == SBLOCK_STATE_IDLE, - timeout); - if (rval < 0) { - pr_debug("%s: wait interrupted!\n", __func__); - } else if (rval == 0) { - pr_info("%s: wait timeout!\n", __func__); - rval = -ETIME; - } - - if (sblock->state == SBLOCK_STATE_IDLE) { - pr_info("%s: state is idle!\n", __func__); - rval = -EIO; - } - } - } - - if (rval < 0) - return rval; - - /* must request resource before read or write share memory */ - rval = sipc_smem_request_resource(ring->tx_pms, dst, timeout); - if (rval < 0) - return rval; - - /* multi-gotter may cause got failure */ - spin_lock_irqsave(&ring->p_txlock, flags); - if (*(poolhd_op->tx_rd_p) != *(poolhd_op->tx_wt_p) && - sblock->state == SBLOCK_STATE_READY) { - txpos = sblock_get_ringpos(*(poolhd_op->tx_rd_p), - poolhd_op->tx_count); - blk->addr = sblock->smem_virt + - (ring->p_txblks[txpos].addr - - sblock->stored_smem_addr); - blk->length = poolhd_op->tx_size; - *(poolhd_op->tx_rd_p) = *(poolhd_op->tx_rd_p) + 1; - index = sblock_get_index((blk->addr - ring->txblk_virt), - sblock->txblksz); - ring->txrecord[index] = SBLOCK_BLK_STATE_PENDING; - } else { - /* release resource */ - sipc_smem_release_resource(ring->tx_pms, dst); - rval = sblock->state == SBLOCK_STATE_READY ? -EAGAIN : -EIO; - } - spin_unlock_irqrestore(&ring->p_txlock, flags); - - spin_lock_irqsave(&ring->poll_lock, flags); - /* update write mask */ - if (*(poolhd_op->tx_wt_p) == *(poolhd_op->tx_rd_p)) - ring->poll_mask &= ~(POLLOUT | POLLWRNORM); - else - ring->poll_mask |= POLLOUT | POLLWRNORM; - spin_unlock_irqrestore(&ring->poll_lock, flags); - - return rval; -} -EXPORT_SYMBOL_GPL(sblock_get); - -static int sblock_send_ex(u8 dst, u8 channel, - struct sblock *blk, bool yell) -{ - struct sblock_mgr *sblock; - struct sblock_ring *ring; - struct sblock_ring_header_op *ringhd_op; - struct smsg mevt; - int txpos, index; - int rval = 0; - unsigned long flags; - u8 ch_index; - bool send_event = false; - - ch_index = sipc_channel2index(channel); - if (ch_index == INVALID_CHANEL_INDEX) { - pr_err("%s:channel %d invalid!\n", __func__, channel); - return -EINVAL; - } - - sblock = sblocks[dst][ch_index]; - - if (!sblock || sblock->state != SBLOCK_STATE_READY) { - pr_err("%s:sblock-%d-%d not ready!\n", __func__, dst, channel); - return sblock ? -EIO : -ENODEV; - } - - pr_debug("sblock_send: dst=%d, channel=%d, addr=%p, len=%d\n", - dst, channel, blk->addr, blk->length); - - ring = sblock->ring; - ringhd_op = &(ring->header_op.ringhd_op); - - spin_lock_irqsave(&ring->r_txlock, flags); - - txpos = sblock_get_ringpos(*(ringhd_op->tx_wt_p), ringhd_op->tx_count); - ring->r_txblks[txpos].addr = blk->addr - - sblock->smem_virt + - sblock->stored_smem_addr; - ring->r_txblks[txpos].length = blk->length; - pr_debug("sblock_send: channel=%d, wrptr=%d, txpos=%d, addr=%x\n", - channel, *(ringhd_op->tx_wt_p), - txpos, ring->r_txblks[txpos].addr); - *(ringhd_op->tx_wt_p) = *(ringhd_op->tx_wt_p) + 1; - - if (sblock->state == SBLOCK_STATE_READY) { - if (yell) { - send_event = true; - } else if (!ring->yell) { - if ((int)(*(ringhd_op->tx_wt_p) - - *(ringhd_op->tx_rd_p)) == 1) - ring->yell = 1; - } - } - index = sblock_get_index((blk->addr - ring->txblk_virt), - sblock->txblksz); - ring->txrecord[index] = SBLOCK_BLK_STATE_DONE; - - spin_unlock_irqrestore(&ring->r_txlock, flags); - - /* request in sblock_get, release here */ - sipc_smem_release_resource(ring->tx_pms, dst); - - /* - * smsg_send may caused schedule, - * can't be called in spinlock protected context. - */ - if (send_event) { - smsg_set(&mevt, channel, - SMSG_TYPE_EVENT, - SMSG_EVENT_SBLOCK_SEND, - 0); - rval = smsg_send(dst, &mevt, -1); - } - - return rval; -} - -int sblock_send(u8 dst, u8 channel, struct sblock *blk) -{ - return sblock_send_ex(dst, channel, blk, true); -} -EXPORT_SYMBOL_GPL(sblock_send); - -int sblock_send_prepare(u8 dst, u8 channel, struct sblock *blk) -{ - return sblock_send_ex(dst, channel, blk, false); -} -EXPORT_SYMBOL_GPL(sblock_send_prepare); - -int sblock_send_finish(u8 dst, u8 channel) -{ - struct sblock_mgr *sblock; - struct sblock_ring *ring; - struct sblock_ring_header_op *ringhd_op; - struct smsg mevt; - int rval = 0; - u8 ch_index; - - ch_index = sipc_channel2index(channel); - if (ch_index == INVALID_CHANEL_INDEX) { - pr_err("%s:channel %d invalid!\n", __func__, channel); - return -EINVAL; - } - - sblock = sblocks[dst][ch_index]; - if (!sblock || sblock->state != SBLOCK_STATE_READY) { - pr_err("%s:sblock-%d-%d not ready!\n", __func__, dst, channel); - return sblock ? -EIO : -ENODEV; - } - - ring = sblock->ring; - ringhd_op = &(ring->header_op.ringhd_op); - - /* must wait resource before read or write share memory */ - rval = sipc_smem_request_resource(ring->tx_pms, dst, -1); - if (rval) - return rval; - - if (*(ringhd_op->tx_wt_p) != *(ringhd_op->tx_rd_p)) { - smsg_set(&mevt, channel, - SMSG_TYPE_EVENT, - SMSG_EVENT_SBLOCK_SEND, 0); - rval = smsg_send(dst, &mevt, -1); - } - /* release resource */ - sipc_smem_release_resource(ring->tx_pms, dst); - - return rval; -} -EXPORT_SYMBOL_GPL(sblock_send_finish); - -int sblock_receive(u8 dst, u8 channel, - struct sblock *blk, int timeout) -{ - struct sblock_mgr *sblock; - struct sblock_ring *ring; - struct sblock_ring_header_op *ringhd_op; - int rxpos, index, rval = 0; - unsigned long flags; - u8 ch_index; - bool no_data; - - ch_index = sipc_channel2index(channel); - if (ch_index == INVALID_CHANEL_INDEX) { - pr_err("%s:channel %d invalid!\n", __func__, channel); - return -EINVAL; - } - - sblock = sblocks[dst][ch_index]; - - if (!sblock || sblock->state != SBLOCK_STATE_READY) { - pr_err("%s:sblock-%d-%d not ready!\n", __func__, dst, channel); - return sblock ? -EIO : -ENODEV; - } - - pr_debug("%s: dst=%d, channel=%d, timeout=%d\n", - __func__, dst, channel, timeout); - - ring = sblock->ring; - ringhd_op = &(ring->header_op.ringhd_op); - - /* must request resource before read or write share memory */ - rval = sipc_smem_request_resource(ring->rx_pms, dst, timeout); - if (rval < 0) - return rval; - - pr_debug("%s: channel=%d, wrptr=%d, rdptr=%d", - __func__, channel, - *(ringhd_op->rx_wt_p), - *(ringhd_op->rx_rd_p)); - - spin_lock_irqsave(&ring->poll_lock, flags); - no_data = *(ringhd_op->rx_wt_p) == *(ringhd_op->rx_rd_p); - /* update read mask */ - if (no_data) - ring->poll_mask &= ~(POLLIN | POLLRDNORM); - else - ring->poll_mask |= POLLIN | POLLRDNORM; - spin_unlock_irqrestore(&ring->poll_lock, flags); - - /* release resource */ - sipc_smem_release_resource(ring->rx_pms, dst); - - if (no_data) { - if (timeout == 0) { - /* no wait */ - pr_debug("%s: %d-%d is empty!\n", - __func__, dst, channel); - rval = -ENODATA; - } else if (timeout < 0) { - /* wait forever */ - rval = wait_event_interruptible(ring->recvwait, - sblock_has_data(sblock, false)); - if (rval < 0) - pr_info("%s: wait interrupted!\n", __func__); - - if (sblock->state == SBLOCK_STATE_IDLE) { - pr_info("%s: state is idle!\n", __func__); - rval = -EIO; - } - - } else { - /* wait timeout */ - rval = wait_event_interruptible_timeout(ring->recvwait, - sblock_has_data(sblock, false), - timeout); - if (rval < 0) { - pr_info("%s: wait interrupted!\n", __func__); - } else if (rval == 0) { - pr_info("%s: wait timeout!\n", __func__); - rval = -ETIME; - } - - if (sblock->state == SBLOCK_STATE_IDLE) { - pr_info("%s: state is idle!\n", __func__); - rval = -EIO; - } - } - } - - if (rval < 0) - return rval; - - /* must request resource before read or write share memory */ - rval = sipc_smem_request_resource(ring->rx_pms, dst, timeout); - if (rval < 0) - return rval; - - /* multi-receiver may cause recv failure */ - spin_lock_irqsave(&ring->r_rxlock, flags); - - if (*(ringhd_op->rx_wt_p) != *(ringhd_op->rx_rd_p) && - sblock->state == SBLOCK_STATE_READY) { - rxpos = sblock_get_ringpos(*(ringhd_op->rx_rd_p), - ringhd_op->rx_count); - blk->addr = ring->r_rxblks[rxpos].addr - - sblock->stored_smem_addr + - sblock->smem_virt; - blk->length = ring->r_rxblks[rxpos].length; - *(ringhd_op->rx_rd_p) = *(ringhd_op->rx_rd_p) + 1; - pr_debug("%s: channel=%d, rxpos=%d, addr=%p, len=%d\n", - __func__, channel, rxpos, blk->addr, blk->length); - index = sblock_get_index((blk->addr - ring->rxblk_virt), - sblock->rxblksz); - ring->rxrecord[index] = SBLOCK_BLK_STATE_PENDING; - } else { - /* release resource */ - sipc_smem_release_resource(ring->rx_pms, dst); - rval = sblock->state == SBLOCK_STATE_READY ? -EAGAIN : -EIO; - } - spin_unlock_irqrestore(&ring->r_rxlock, flags); - - spin_lock_irqsave(&ring->poll_lock, flags); - /* update read mask */ - if (*(ringhd_op->rx_wt_p) == *(ringhd_op->rx_rd_p)) - ring->poll_mask &= ~(POLLIN | POLLRDNORM); - else - ring->poll_mask |= POLLIN | POLLRDNORM; - spin_unlock_irqrestore(&ring->poll_lock, flags); - - return rval; -} -EXPORT_SYMBOL_GPL(sblock_receive); - -int sblock_get_arrived_count(u8 dst, u8 channel) -{ - struct sblock_mgr *sblock; - struct sblock_ring *ring; - struct sblock_ring_header_op *ringhd_op; - int blk_count = 0; - unsigned long flags; - u8 ch_index; - int rval; - - ch_index = sipc_channel2index(channel); - if (ch_index == INVALID_CHANEL_INDEX) { - pr_err("%s:channel %d invalid!\n", __func__, channel); - return -EINVAL; - } - - sblock = sblocks[dst][ch_index]; - if (!sblock || sblock->state != SBLOCK_STATE_READY) { - pr_err("%s:sblock-%d-%d not ready!\n", __func__, dst, channel); - return -ENODEV; - } - - ring = sblock->ring; - ringhd_op = &(ring->header_op.ringhd_op); - - /* must request resource before read or write share memory */ - rval = sipc_smem_request_resource(ring->rx_pms, dst, -1); - if (rval < 0) - return rval; - - spin_lock_irqsave(&ring->r_rxlock, flags); - blk_count = (int)(*(ringhd_op->rx_wt_p) - *(ringhd_op->rx_rd_p)); - spin_unlock_irqrestore(&ring->r_rxlock, flags); - /* release resource */ - sipc_smem_release_resource(ring->rx_pms, dst); - - return blk_count; - -} -EXPORT_SYMBOL_GPL(sblock_get_arrived_count); - -int sblock_get_free_count(u8 dst, u8 channel) -{ - struct sblock_mgr *sblock; - struct sblock_ring *ring; - struct sblock_ring_header_op *poolhd_op; - int blk_count = 0, rval; - unsigned long flags; - u8 ch_index; - - ch_index = sipc_channel2index(channel); - if (ch_index == INVALID_CHANEL_INDEX) { - pr_err("%s:channel %d invalid!\n", __func__, channel); - return -EINVAL; - } - - sblock = sblocks[dst][ch_index]; - if (!sblock || sblock->state != SBLOCK_STATE_READY) { - pr_err("%s:sblock-%d-%d not ready!\n", __func__, dst, channel); - return -ENODEV; - } - - ring = sblock->ring; - poolhd_op = &(ring->header_op.poolhd_op); - - /* must request resource before read or write share memory */ - rval = sipc_smem_request_resource(ring->tx_pms, dst, -1); - if (rval < 0) - return rval; - - spin_lock_irqsave(&ring->p_txlock, flags); - blk_count = (int)(*(poolhd_op->tx_wt_p) - *(poolhd_op->tx_rd_p)); - spin_unlock_irqrestore(&ring->p_txlock, flags); - /* release resource */ - sipc_smem_release_resource(ring->tx_pms, dst); - - return blk_count; -} -EXPORT_SYMBOL_GPL(sblock_get_free_count); - -int sblock_release(u8 dst, u8 channel, struct sblock *blk) -{ - struct sblock_mgr *sblock; - struct sblock_ring *ring; - struct sblock_ring_header_op *poolhd_op; - struct smsg mevt; - unsigned long flags; - int rxpos; - int index; - u8 ch_index; - bool send_event = false; - - ch_index = sipc_channel2index(channel); - if (ch_index == INVALID_CHANEL_INDEX) { - pr_err("%s:channel %d invalid!\n", __func__, channel); - return -EINVAL; - } - - sblock = sblocks[dst][ch_index]; - if (!sblock || sblock->state != SBLOCK_STATE_READY) { - pr_err("%s:sblock-%d-%d not ready!\n", __func__, dst, channel); - return -ENODEV; - } - - pr_debug("%s: dst=%d, channel=%d, addr=%p, len=%d\n", - __func__, dst, channel, blk->addr, blk->length); - - ring = sblock->ring; - poolhd_op = &(ring->header_op.poolhd_op); - - spin_lock_irqsave(&ring->p_rxlock, flags); - rxpos = sblock_get_ringpos(*(poolhd_op->rx_wt_p), poolhd_op->rx_count); - ring->p_rxblks[rxpos].addr = blk->addr - - sblock->smem_virt + - sblock->stored_smem_addr; - ring->p_rxblks[rxpos].length = poolhd_op->rx_size; - *(poolhd_op->rx_wt_p) = *(poolhd_op->rx_wt_p) + 1; - pr_debug("%s: addr=%x\n", __func__, ring->p_rxblks[rxpos].addr); - - if ((int)(*(poolhd_op->rx_wt_p) - *(poolhd_op->rx_rd_p)) == 1 && - sblock->state == SBLOCK_STATE_READY) { - /* send smsg to notify the peer side */ - send_event = true; - } - - index = sblock_get_index((blk->addr - ring->rxblk_virt), - sblock->rxblksz); - ring->rxrecord[index] = SBLOCK_BLK_STATE_DONE; - - spin_unlock_irqrestore(&ring->p_rxlock, flags); - - /* request in sblock_receive, release here */ - sipc_smem_release_resource(ring->rx_pms, dst); - - /* - * smsg_send may caused schedule, - * can't be called in spinlock protected context. - */ - if (send_event) { - smsg_set(&mevt, channel, - SMSG_TYPE_EVENT, - SMSG_EVENT_SBLOCK_RELEASE, - 0); - smsg_send(dst, &mevt, -1); - } - - return 0; -} -EXPORT_SYMBOL_GPL(sblock_release); - -unsigned int sblock_poll_wait(u8 dst, u8 channel, - struct file *filp, poll_table *wait) -{ - struct sblock_mgr *sblock; - struct sblock_ring *ring; - struct sblock_ring_header_op *poolhd_op; - struct sblock_ring_header_op *ringhd_op; - unsigned int mask = 0; - u8 ch_index; - - ch_index = sipc_channel2index(channel); - if (ch_index == INVALID_CHANEL_INDEX) { - pr_err("%s:channel %d invalid!\n", __func__, channel); - return mask; - } - sblock = sblocks[dst][ch_index]; - - if (!sblock) - return mask; - ring = sblock->ring; - poolhd_op = &(ring->header_op.poolhd_op); - ringhd_op = &(ring->header_op.ringhd_op); - - if (sblock->state != SBLOCK_STATE_READY) { - pr_debug("%s:sblock-%d-%d not ready to poll !\n", - __func__, dst, channel); - return mask; - } - poll_wait(filp, &ring->recvwait, wait); - poll_wait(filp, &ring->getwait, wait); - - if (sblock_has_data(sblock, true)) - mask |= POLLOUT | POLLWRNORM; - - if (sblock_has_data(sblock, false)) - mask |= POLLIN | POLLRDNORM; - - return mask; -} -EXPORT_SYMBOL_GPL(sblock_poll_wait); - -int sblock_query(u8 dst, u8 channel) -{ - struct sblock_mgr *sblock = NULL; - u8 ch_index; - - ch_index = sipc_channel2index(channel); - if (ch_index == INVALID_CHANEL_INDEX) { - pr_err("%s:channel %d invalid!\n", __func__, channel); - return -EINVAL; - } - - sblock = sblocks[dst][ch_index]; - if (!sblock) - return -ENODEV; - if (sblock->state != SBLOCK_STATE_READY) { - pr_debug("%s:sblock-%d-%d not ready!\n", __func__, dst, channel); - return -EINVAL; - } - return 0; -} -EXPORT_SYMBOL_GPL(sblock_query); - -#if defined(CONFIG_DEBUG_FS) -static int sblock_debug_show(struct seq_file *m, void *private) -{ - struct smsg_ipc *sipc = NULL; - struct sblock_mgr *sblock; - struct sblock_ring *ring; - struct sblock_ring_header_op *poolhd_op; - struct sblock_ring_header_op *ringhd_op; - int i, j; - - for (i = 0; i < SIPC_ID_NR; i++) { - sipc = smsg_ipcs[i]; - if (!sipc) - continue; - - /* must request resource before read or write share memory */ - if (sipc_smem_request_resource(sipc->sipc_pms, - sipc->dst, 1000) < 0) - continue; - - for (j = 0; j < SMSG_VALID_CH_NR; j++) { - sblock = sblocks[i][j]; - if (!sblock) - continue; - - sipc_debug_putline(m, '*', 170); - seq_printf(m, "sblock dst %d, channel: %3d, state: %d, smem_virt: 0x%lx, smem_addr: 0x%0x, dst_smem_addr: 0x%0x, smem_size: 0x%0x, txblksz: %d, rxblksz: %d\n", - sblock->dst, - sblock->channel, - sblock->state, - (unsigned long)sblock->smem_virt, - sblock->smem_addr, - sblock->dst_smem_addr, - sblock->smem_size, - sblock->txblksz, - sblock->rxblksz); - - /* - * in precfg channel, the ring pinter can be null - * before the the block manger has been created - * and ring->header pointer can also be null - * before the block handshake with host, - * so must add null pointer protect here. - */ - ring = sblock->ring; - if (!ring || !ring->header) - continue; - - poolhd_op = &(ring->header_op.poolhd_op); - ringhd_op = &(ring->header_op.ringhd_op); - seq_printf(m, "sblock ring: txblk_virt :0x%lx, rxblk_virt :0x%lx, poll_mask=0x%x\n", - (unsigned long)ring->txblk_virt, - (unsigned long)ring->rxblk_virt, - ring->poll_mask); - seq_printf(m, "sblock ring header: rxblk_addr :0x%0x, rxblk_rdptr :0x%0x, rxblk_wrptr :0x%0x, rxblk_size :%d, rxblk_count :%d, rxblk_blks: 0x%0x\n", - ringhd_op->rx_addr, *(ringhd_op->rx_rd_p), - *(ringhd_op->rx_wt_p), ringhd_op->rx_size, - ringhd_op->rx_count, ringhd_op->rx_blks); - seq_printf(m, "sblock ring header: txblk_addr :0x%0x, txblk_rdptr :0x%0x, txblk_wrptr :0x%0x, txblk_size :%d, txblk_count :%d, txblk_blks: 0x%0x\n", - ringhd_op->tx_addr, *(ringhd_op->tx_rd_p), - *(ringhd_op->tx_wt_p), ringhd_op->tx_size, - ringhd_op->tx_count, ringhd_op->tx_blks); - seq_printf(m, "sblock pool header: rxblk_addr :0x%0x, rxblk_rdptr :0x%0x, rxblk_wrptr :0x%0x, rxblk_size :%d, rxpool_count :%d, rxblk_blks: 0x%0x\n", - poolhd_op->rx_addr, *(poolhd_op->rx_rd_p), - *(poolhd_op->rx_wt_p), poolhd_op->rx_size, - poolhd_op->rx_count, poolhd_op->rx_blks); - seq_printf(m, "sblock pool header: txblk_addr :0x%0x, txblk_rdptr :0x%0x, txblk_wrptr :0x%0x, txblk_size :%d, txpool_count :%d, txblk_blks: 0x%0x\n", - poolhd_op->tx_addr, *(poolhd_op->tx_rd_p), - *(poolhd_op->tx_wt_p), poolhd_op->tx_size, - poolhd_op->tx_count, poolhd_op->tx_blks); - } - /* release resource */ - sipc_smem_release_resource(sipc->sipc_pms, sipc->dst); - } - - return 0; -} - -static int sblock_debug_open(struct inode *inode, struct file *file) -{ - return single_open(file, sblock_debug_show, inode->i_private); -} - -static const struct file_operations sblock_debug_fops = { - .open = sblock_debug_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -int sblock_init_debugfs(void *root) -{ - if (!root) - return -ENXIO; - debugfs_create_file("sblock", 0444, - (struct dentry *)root, - NULL, &sblock_debug_fops); - return 0; -} -EXPORT_SYMBOL_GPL(sblock_init_debugfs); - -#endif /* CONFIG_DEBUG_FS */ - - -MODULE_AUTHOR("Chen Gaopeng"); -MODULE_DESCRIPTION("SIPC/SBLOCK driver"); -MODULE_LICENSE("GPL v2"); diff --git a/quectel_SRPD_PCIE/src/sipc/sblock.h b/quectel_SRPD_PCIE/src/sipc/sblock.h deleted file mode 100644 index 13d67af..0000000 --- a/quectel_SRPD_PCIE/src/sipc/sblock.h +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright (C) 2019 Spreadtrum Communications Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef __SBLOCK_H -#define __SBLOCK_H - -/* flag for CMD/DONE msg type */ -#define SMSG_CMD_SBLOCK_INIT 0x1 -#define SMSG_DONE_SBLOCK_INIT 0x2 - -/* flag for EVENT msg type */ -#define SMSG_EVENT_SBLOCK_SEND 0x1 -#define SMSG_EVENT_SBLOCK_RELEASE 0x2 - -#define SBLOCK_STATE_IDLE 0 -#define SBLOCK_STATE_READY 1 - -#define SBLOCK_BLK_STATE_DONE 0 -#define SBLOCK_BLK_STATE_PENDING 1 - -struct sblock_blks { - u32 addr; /*phy address*/ - u32 length; -}; - -/* ring block header */ -struct sblock_ring_header { - /* get|send-block info */ - u32 txblk_addr; /* tx blocks start addr */ - u32 txblk_count; /* tx blocks num */ - u32 txblk_size; /* one tx block size */ - u32 txblk_blks; /* tx_ring or tx_pool start addr */ - u32 txblk_rdptr; /* tx_ring or tx_pool read point */ - u32 txblk_wrptr; /* tx_ring or tx_pool write point */ - - /* release|recv-block info */ - u32 rxblk_addr; - u32 rxblk_count; - u32 rxblk_size; - u32 rxblk_blks; - u32 rxblk_rdptr; - u32 rxblk_wrptr; -}; - -struct sblock_header { - struct sblock_ring_header ring; - struct sblock_ring_header pool; -}; - -struct sblock_ring_header_op { - /* - * this points point to share memory - * for update rdptr and wtptr on share memory - */ - volatile u32 *tx_rd_p; - volatile u32 *tx_wt_p; - volatile u32 *rx_rd_p; - volatile u32 *rx_wt_p; - - /* - * this member copy from share memory, - * because this contents will not change on share memory - */ - u32 tx_addr; /* txblk_addr */ - u32 tx_count; /* txblk_count */ - u32 tx_size; /* txblk_size */ - u32 tx_blks; /* txblk_blks */ - u32 rx_addr; - u32 rx_count; - u32 rx_size; - u32 rx_blks; -}; - -struct sblock_header_op { - struct sblock_ring_header_op ringhd_op; - struct sblock_ring_header_op poolhd_op; -}; - -struct sblock_ring { - struct sblock_header *header; - struct sblock_header_op header_op; - - struct sprd_pms *tx_pms; - struct sprd_pms *rx_pms; - char tx_pms_name[20]; - char rx_pms_name[20]; - - void *txblk_virt; /* virt of header->txblk_addr */ - void *rxblk_virt; /* virt of header->rxblk_addr */ - - /* virt of header->ring->txblk_blks */ - struct sblock_blks *r_txblks; - /* virt of header->ring->rxblk_blks */ - struct sblock_blks *r_rxblks; - /* virt of header->pool->txblk_blks */ - struct sblock_blks *p_txblks; - /* virt of header->pool->rxblk_blks */ - struct sblock_blks *p_rxblks; - - unsigned int poll_mask; - /* protect the poll_mask menber */ - spinlock_t poll_lock; - - int *txrecord; /* record the state of every txblk */ - int *rxrecord; /* record the state of every rxblk */ - int yell; /* need to notify cp */ - spinlock_t r_txlock; /* send */ - spinlock_t r_rxlock; /* recv */ - spinlock_t p_txlock; /* get */ - spinlock_t p_rxlock; /* release */ - - wait_queue_head_t getwait; - wait_queue_head_t recvwait; -}; - -struct sblock_mgr { - u8 dst; - u8 channel; - int pre_cfg; /*support in host mode only */ - u32 state; - - void *smem_virt; - u32 smem_addr; - u32 smem_addr_debug; - u32 smem_size; - u32 dst_smem_addr; - - /* - * this address stored in share memory, - * be used to calculte the block virt address. - * in host mode, it is client physial address(dst_smem_addr), - * in client mode, it is own physial address(smem_addr). - */ - u32 stored_smem_addr; - - u32 txblksz; - u32 rxblksz; - u32 txblknum; - u32 rxblknum; - - struct sblock_ring *ring; - struct task_struct *thread; - - void (*handler)(int event, void *data); - void *data; -}; - -#ifdef CONFIG_64BIT -#define SBLOCK_ALIGN_BYTES (8) -#else -#define SBLOCK_ALIGN_BYTES (4) -#endif - -static inline u32 sblock_get_index(u32 x, u32 y) -{ - return (x / y); -} - -static inline u32 sblock_get_ringpos(u32 x, u32 y) -{ - return is_power_of_2(y) ? (x & (y - 1)) : (x % y); -} -#endif diff --git a/quectel_SRPD_PCIE/src/sipc/sbuf.c b/quectel_SRPD_PCIE/src/sipc/sbuf.c deleted file mode 100644 index 2a50b72..0000000 --- a/quectel_SRPD_PCIE/src/sipc/sbuf.c +++ /dev/null @@ -1,1755 +0,0 @@ -/* - * Copyright (C) 2019 Spreadtrum Communications Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#if (LINUX_VERSION_CODE > KERNEL_VERSION( 4,4,60 )) -#include -#include -#endif - -#include "../include/sipc.h" -#include "sipc_priv.h" -#include "sbuf.h" - -#if defined(CONFIG_DEBUG_FS) -#include "sipc_debugfs.h" -#endif - -#define VOLA_SBUF_SMEM volatile struct sbuf_smem_header -#define VOLA_SBUF_RING volatile struct sbuf_ring_header - -struct name_node { - struct list_head list; - char comm[TASK_COMM_LEN]; - pid_t pid; - u8 latest; -}; - -union sbuf_buf { - void *buf; - void __user *ubuf; -}; - -enum task_type { - TASK_RXWAIT = 0, - TASK_TXWAIT, - TASK_SELECT -}; - -static struct sbuf_mgr *sbufs[SIPC_ID_NR][SMSG_VALID_CH_NR]; - -static bool sbuf_has_data(struct sbuf_ring *ring, u8 dst, bool tx) -{ - struct sbuf_ring_header_op *hd_op = &ring->header_op; - bool has_data; - unsigned long flags; - - /* - * if it is local share memory, - * check the read and write point directly. - */ - if (smsg_ipcs[dst]->smem_type == SMEM_LOCAL) { - if (tx) - return (int)(BL_READL(hd_op->tx_wt_p) - BL_READL(hd_op->tx_rd_p)) < - hd_op->tx_size; - - return BL_READL(hd_op->rx_wt_p) != BL_READL(hd_op->rx_rd_p); - } - - /* - * if it is remote share memmory read the poll_mask, - * this situation requires that the poll_mask must be accurate enough. - */ - spin_lock_irqsave(&ring->poll_lock, flags); - if (tx) - has_data = ring->poll_mask & (POLLOUT | POLLWRNORM); - else - has_data = ring->poll_mask & (POLLIN | POLLRDNORM); - spin_unlock_irqrestore(&ring->poll_lock, flags); - - return has_data; -} - -static bool sbuf_is_task_pointer(const void *ptr) -{ - struct task_struct *task; - struct thread_info *thread_info; - - task = (struct task_struct *)ptr; - if (IS_ERR_OR_NULL(task) || !virt_addr_valid(task)) - return false; - -#ifndef CONFIG_THREAD_INFO_IN_TASK - /* in this case thread_info is in the same addres with stack thread_union*/ - if (IS_ERR_OR_NULL(task->stack) || !virt_addr_valid(task->stack)) - return false; -#endif - - thread_info = task_thread_info(task); - - if (IS_ERR_OR_NULL(thread_info) || !virt_addr_valid(thread_info)) - return false; - - return true; -} - -static struct task_struct *sbuf_wait_get_task( -#if (LINUX_VERSION_CODE <= KERNEL_VERSION( 4,10,0 )) - wait_queue_t *pos, -#else - wait_queue_entry_t *pos, -#endif - u32 *b_select) -{ - struct task_struct *task; - struct poll_wqueues *table; - - if (!pos->private) - return NULL; - - /* if the private is put into wait list by sbuf_read, the struct of - * pos->private is struct task_struct - * if the private is put into list by sbuf_poll, the struct of - * pos->private is struct poll_wqueues - */ - - /* firstly, try struct poll_wqueues */ - table = (struct poll_wqueues *)pos->private; - task = table->polling_task; - if (sbuf_is_task_pointer(task)) { - *b_select = 1; - return task; - } - - /* firstly, try convert it with the struct task_struct */ - task = (struct task_struct *)pos->private; - - if (sbuf_is_task_pointer(task)) { - *b_select = 0; - return task; - } - - return NULL; -} - -#if defined(SIPC_DEBUG_SBUF_RDWT_OWNER) -static void sbuf_record_rdwt_owner(struct sbuf_ring *ring, int b_rx) -{ - int b_add; - int cnt = 0; - struct name_node *pos = NULL; - struct name_node *temp = NULL; - struct list_head *owner_list; - unsigned long flags; - - b_add = 1; - owner_list = b_rx ? (&ring->rx_list) : (&ring->tx_list); - - spin_lock_irqsave(&ring->rxwait.lock, flags); - list_for_each_entry(pos, owner_list, list) { - cnt++; - if (pos->pid == current->pid) { - b_add = 0; - pos->latest = 1; - continue; - } - if (pos->latest) - pos->latest = 0; - } - spin_unlock_irqrestore(&ring->rxwait.lock, flags); - - if (b_add) { - /* delete head next */ - if (cnt == MAX_RECORD_CNT) { - temp = list_first_entry(owner_list, - struct name_node, list); - list_del(&temp->list); - kfree(temp); - } - - pos = kzalloc(sizeof(*pos), GFP_KERNEL); - if (pos) { - memcpy(pos->comm, current->comm, TASK_COMM_LEN); - pos->pid = current->pid; - pos->latest = 1; - spin_lock_irqsave(&ring->rxwait.lock, flags); - list_add_tail(&pos->list, owner_list); - spin_unlock_irqrestore(&ring->rxwait.lock, flags); - } - } -} - -static void sbuf_destroy_rdwt_owner(struct sbuf_ring *ring) -{ - struct name_node *pos, *temp; - unsigned long flags; - - spin_lock_irqsave(&ring->rxwait.lock, flags); - /* free task node */ - list_for_each_entry_safe(pos, - temp, - &ring->rx_list, - list) { - list_del(&pos->list); - kfree(pos); - } - - list_for_each_entry_safe(pos, - temp, - &ring->tx_list, - list) { - list_del(&pos->list); - kfree(pos); - } - spin_unlock_irqrestore(&ring->rxwait.lock, flags); -} -#endif - -static void sbuf_skip_old_data(struct sbuf_mgr *sbuf) -{ - struct sbuf_ring *ring = NULL; - struct sbuf_ring_header_op *hd_op = NULL; - u32 i, v; - unsigned long flags; - - ring = &sbuf->rings[0]; - /* must reques resource before read or write share memory */ - if (sipc_smem_request_resource(ring->rx_pms, sbuf->dst, -1) < 0) - return; - - for (i = 0; i < sbuf->ringnr; i++) { - ring = &sbuf->rings[i]; - hd_op = &ring->header_op; - - /* clean sbuf tx ring , sbuf tx ring no need to clear */ - /* *(hd_op->tx_wt_p) = *(hd_op->tx_rd_p); */ - /* clean sbuf rx ring */ - v = BL_READL(hd_op->rx_wt_p); - BL_WRITEL(v, hd_op->rx_rd_p); - /* restore write mask. */ - spin_lock_irqsave(&ring->poll_lock, flags); - ring->poll_mask = POLLOUT | POLLWRNORM; - spin_unlock_irqrestore(&ring->poll_lock, flags); - } - ring = &sbuf->rings[0]; - /* release resource */ - sipc_smem_release_resource(ring->rx_pms, sbuf->dst); -} - -static void sbuf_pms_init(struct sbuf_ring *ring, - uint8_t dst, uint8_t ch, int index) -{ - ring->need_wake_lock = true; - sprintf(ring->tx_pms_name, "sbuf-%d-%d-%d-tx", dst, ch, index); - ring->tx_pms = sprd_pms_create(dst, ring->tx_pms_name, false); - if (!ring->tx_pms) - pr_warn("create pms %s failed!\n", ring->tx_pms_name); - - sprintf(ring->rx_pms_name, "sbuf-%d-%d-%d-rx", dst, ch, index); - ring->rx_pms = sprd_pms_create(dst, ring->rx_pms_name, false); - if (!ring->rx_pms) - pr_warn("create pms %s failed!\n", ring->rx_pms_name); -} - -static void sbuf_comm_init(struct sbuf_mgr *sbuf) -{ - u32 bufnum = sbuf->ringnr; - int i; - struct sbuf_ring *ring; - - for (i = 0; i < bufnum; i++) { - ring = &sbuf->rings[i]; - init_waitqueue_head(&ring->txwait); - init_waitqueue_head(&ring->rxwait); -#if defined(SIPC_DEBUG_SBUF_RDWT_OWNER) - INIT_LIST_HEAD(&ring->tx_list); - INIT_LIST_HEAD(&ring->rx_list); -#endif - mutex_init(&ring->txlock); - mutex_init(&ring->rxlock); - spin_lock_init(&ring->poll_lock); - spin_lock_init(&ring->rxwait.lock); - - /* init, set write mask. */ - ring->poll_mask = POLLOUT | POLLWRNORM; - sbuf_pms_init(ring, sbuf->dst, sbuf->channel, i); - } -} - -static int sbuf_host_init(struct smsg_ipc *sipc, struct sbuf_mgr *sbuf, - u32 bufnum, u32 txbufsize, u32 rxbufsize) -{ - VOLA_SBUF_SMEM *smem; - VOLA_SBUF_RING *ringhd; - struct sbuf_ring_header_op *hd_op; - int hsize, i, rval; - phys_addr_t offset = 0; - u8 dst = sbuf->dst; - struct sbuf_ring *ring; - u32 txbuf_addr; - - sbuf->ringnr = bufnum; - - /* allocate smem */ - hsize = sizeof(struct sbuf_smem_header) + - sizeof(struct sbuf_ring_header) * bufnum; - sbuf->smem_size = hsize + (txbufsize + rxbufsize) * bufnum; - sbuf->smem_addr = smem_alloc(dst, sbuf->smem_size); - if (!sbuf->smem_addr) { - pr_err("%s: channel %d-%d, Failed to allocate smem for sbuf\n", - __func__, sbuf->dst, sbuf->channel); - return -ENOMEM; - } - sbuf->dst_smem_addr = sbuf->smem_addr - sipc->smem_base + - sipc->dst_smem_base; - - pr_debug("%s: channel %d-%d, smem_addr=0x%x, smem_size=0x%x, dst_smem_addr=0x%x\n", - __func__, - sbuf->dst, - sbuf->channel, - sbuf->smem_addr, - sbuf->smem_size, - sbuf->dst_smem_addr); - -#ifdef CONFIG_PHYS_ADDR_T_64BIT - offset = sipc->high_offset; - offset = offset << 32; -#endif - - pr_info("%s: channel %d-%d, offset = 0x%lx!\n", - __func__, sbuf->dst, sbuf->channel, (unsigned long)offset); - sbuf->smem_virt = shmem_ram_vmap_nocache(dst, - sbuf->smem_addr + offset, - sbuf->smem_size); - if (!sbuf->smem_virt) { - pr_err("%s: channel %d-%d, Failed to map smem for sbuf\n", - __func__, sbuf->dst, sbuf->channel); - smem_free(dst, sbuf->smem_addr, sbuf->smem_size); - return -EFAULT; - } - - /* allocate rings description */ - sbuf->rings = kcalloc(bufnum, sizeof(struct sbuf_ring), GFP_KERNEL); - if (!sbuf->rings) { - smem_free(dst, sbuf->smem_addr, sbuf->smem_size); - shmem_ram_unmap(dst, sbuf->smem_virt); - return -ENOMEM; - } - - /* must request resource before read or write share memory */ - rval = sipc_smem_request_resource(sipc->sipc_pms, sipc->dst, -1); - if (rval < 0) { - smem_free(dst, sbuf->smem_addr, sbuf->smem_size); - shmem_ram_unmap(dst, sbuf->smem_virt); - kfree(sbuf->rings); - return rval; - } - - /* initialize all ring bufs */ - smem = (VOLA_SBUF_SMEM *)sbuf->smem_virt; - BL_SETL(smem->ringnr, bufnum); - for (i = 0; i < bufnum; i++) { - ringhd = (VOLA_SBUF_RING *)&smem->headers[i]; - txbuf_addr = sbuf->dst_smem_addr + hsize + - (txbufsize + rxbufsize) * i; - BL_SETL(ringhd->txbuf_addr, txbuf_addr); - BL_SETL(ringhd->txbuf_size, txbufsize); - BL_SETL(ringhd->txbuf_rdptr, 0); - BL_SETL(ringhd->txbuf_wrptr, 0); - BL_SETL(ringhd->rxbuf_addr, txbuf_addr + txbufsize); - BL_SETL(ringhd->rxbuf_size, rxbufsize); - BL_SETL(ringhd->rxbuf_rdptr, 0); - BL_SETL(ringhd->rxbuf_wrptr, 0); - - ring = &sbuf->rings[i]; - ring->header = ringhd; - ring->txbuf_virt = sbuf->smem_virt + hsize + - (txbufsize + rxbufsize) * i; - ring->rxbuf_virt = ring->txbuf_virt + txbufsize; - /* init header op */ - hd_op = &ring->header_op; - hd_op->rx_rd_p = &ringhd->rxbuf_rdptr; - hd_op->rx_wt_p = &ringhd->rxbuf_wrptr; - hd_op->rx_size = ringhd->rxbuf_size; - hd_op->tx_rd_p = &ringhd->txbuf_rdptr; - hd_op->tx_wt_p = &ringhd->txbuf_wrptr; - hd_op->tx_size = ringhd->txbuf_size; - } - - /* release resource */ - sipc_smem_release_resource(sipc->sipc_pms, sipc->dst); - - sbuf_comm_init(sbuf); - - return 0; -} - -static int sbuf_client_init(struct smsg_ipc *sipc, struct sbuf_mgr *sbuf) -{ - VOLA_SBUF_SMEM *smem; - VOLA_SBUF_RING *ringhd; - struct sbuf_ring_header_op *hd_op; - struct sbuf_ring *ring; - int hsize, i, rval; - u32 txbufsize, rxbufsize; - phys_addr_t offset = 0; - u32 bufnum; - u8 dst = sbuf->dst; - -#ifdef CONFIG_PHYS_ADDR_T_64BIT - offset = sipc->high_offset; - offset = offset << 32; - pr_info("%s: channel %d-%d, offset = 0x%llx!\n", - __func__, sbuf->dst, sbuf->channel, offset); -#endif - - /* get bufnum and bufsize */ - hsize = sizeof(struct sbuf_smem_header) + - sizeof(struct sbuf_ring_header) * 1; - sbuf->smem_virt = shmem_ram_vmap_nocache(dst, - sbuf->smem_addr + offset, - hsize); - if (!sbuf->smem_virt) { - pr_err("%s: channel %d-%d, Failed to map smem for sbuf head\n", - __func__, sbuf->dst, sbuf->channel); - return -EFAULT; - } - smem = (VOLA_SBUF_SMEM *)sbuf->smem_virt; - sbuf->ringnr = smem->ringnr; - bufnum = sbuf->ringnr; - ringhd = (VOLA_SBUF_RING *)&smem->headers[0]; - txbufsize = BL_GETL(ringhd->rxbuf_size); - rxbufsize = BL_GETL(ringhd->txbuf_size); - hsize = sizeof(struct sbuf_smem_header) + - sizeof(struct sbuf_ring_header) * bufnum; - sbuf->smem_size = hsize + (txbufsize + rxbufsize) * bufnum; - pr_debug("%s: channel %d-%d, txbufsize = 0x%x, rxbufsize = 0x%x!\n", - __func__, sbuf->dst, sbuf->channel, txbufsize, rxbufsize); - pr_debug("%s: channel %d-%d, smem_size = 0x%x, ringnr = %d!\n", - __func__, sbuf->dst, sbuf->channel, sbuf->smem_size, bufnum); - shmem_ram_unmap(dst, sbuf->smem_virt); - - /* alloc debug smem */ - sbuf->smem_addr_debug = smem_alloc(dst, sbuf->smem_size); - if (!sbuf->smem_addr_debug) { - pr_err("%s: channel %d-%d,Failed to allocate debug smem for sbuf\n", - __func__, sbuf->dst, sbuf->channel); - return -ENOMEM; - } - - /* get smem virtual address */ - sbuf->smem_virt = shmem_ram_vmap_nocache(dst, - sbuf->smem_addr + offset, - sbuf->smem_size); - if (!sbuf->smem_virt) { - pr_err("%s: channel %d-%d,Failed to map smem for sbuf\n", - __func__, sbuf->dst, sbuf->channel); - smem_free(dst, sbuf->smem_addr_debug, sbuf->smem_size); - return -EFAULT; - } - - /* allocate rings description */ - sbuf->rings = kcalloc(bufnum, sizeof(struct sbuf_ring), GFP_KERNEL); - if (!sbuf->rings) { - smem_free(dst, sbuf->smem_addr_debug, sbuf->smem_size); - shmem_ram_unmap(dst, sbuf->smem_virt); - return -ENOMEM; - } - pr_info("%s: channel %d-%d, ringns = 0x%p!\n", - __func__, sbuf->dst, sbuf->channel, sbuf->rings); - - /* must request resource before read or write share memory */ - rval = sipc_smem_request_resource(sipc->sipc_pms, sipc->dst, -1); - if (rval < 0) { - smem_free(dst, sbuf->smem_addr, sbuf->smem_size); - shmem_ram_unmap(dst, sbuf->smem_virt); - kfree(sbuf->rings); - return rval; - } - - /* initialize all ring bufs */ - smem = (VOLA_SBUF_SMEM *)sbuf->smem_virt; - for (i = 0; i < bufnum; i++) { - ringhd = (VOLA_SBUF_RING *)&smem->headers[i]; - ring = &sbuf->rings[i]; - ring->header = ringhd; - /* host txbuf_addr */ - ring->rxbuf_virt = sbuf->smem_virt + hsize + - (txbufsize + rxbufsize) * i; - /* host rxbuf_addr */ - ring->txbuf_virt = ring->rxbuf_virt + rxbufsize; - /* init header op , client mode, rx <==> tx */ - hd_op = &ring->header_op; - hd_op->rx_rd_p = &ringhd->txbuf_rdptr; - hd_op->rx_wt_p = &ringhd->txbuf_wrptr; - hd_op->rx_size = ringhd->txbuf_size; - hd_op->tx_rd_p = &ringhd->rxbuf_rdptr; - hd_op->tx_wt_p = &ringhd->rxbuf_wrptr; - hd_op->tx_size = ringhd->rxbuf_size; - } - - /* release resource */ - sipc_smem_release_resource(sipc->sipc_pms, sipc->dst); - - sbuf_comm_init(sbuf); - - return 0; -} - -static int sbuf_thread(void *data) -{ - struct sbuf_mgr *sbuf = data; - struct sbuf_ring *ring; - struct smsg mcmd, mrecv; - int rval, bufid; - struct smsg_ipc *sipc; - unsigned long flags; - - /* since the channel open may hang, we call it in the sbuf thread */ - rval = smsg_ch_open(sbuf->dst, sbuf->channel, -1); - if (rval != 0) { - pr_err("Failed to open channel %d\n", sbuf->channel); - /* assign NULL to thread poniter as failed to open channel */ - sbuf->thread = NULL; - return rval; - } - - /* if client, send SMSG_CMD_SBUF_INIT, wait sbuf SMSG_DONE_SBUF_INIT */ - sipc = smsg_ipcs[sbuf->dst]; - if (sipc->client) { - smsg_set(&mcmd, sbuf->channel, SMSG_TYPE_CMD, - SMSG_CMD_SBUF_INIT, 0); - smsg_send(sbuf->dst, &mcmd, -1); - do { - smsg_set(&mrecv, sbuf->channel, 0, 0, 0); - rval = smsg_recv(sbuf->dst, &mrecv, -1); - if (rval != 0) { - sbuf->thread = NULL; - return rval; - } - } while (mrecv.type != SMSG_TYPE_DONE || - mrecv.flag != SMSG_DONE_SBUF_INIT); - sbuf->smem_addr = mrecv.value; - pr_info("%s: channel %d-%d, done_sbuf_init, address = 0x%x!\n", - __func__, sbuf->dst, sbuf->channel, sbuf->smem_addr); - if (sbuf_client_init(sipc, sbuf)) { - sbuf->thread = NULL; - return 0; - } - sbuf->state = SBUF_STATE_READY; - } - - /* sbuf init done, handle the ring rx events */ - while (!kthread_should_stop()) { - /* monitor sbuf rdptr/wrptr update smsg */ - smsg_set(&mrecv, sbuf->channel, 0, 0, 0); - rval = smsg_recv(sbuf->dst, &mrecv, -1); - if (rval == -EIO) { - /* channel state is free */ - msleep(20); - continue; - } - - pr_debug("sbuf thread recv msg: dst=%d, channel=%d, type=%d, flag=0x%04x, value=0x%08x\n", - sbuf->dst, - sbuf->channel, - mrecv.type, - mrecv.flag, - mrecv.value); - - switch (mrecv.type) { - case SMSG_TYPE_OPEN: - pr_info("%s: channel %d-%d, state=%d, recv open msg!\n", - __func__, sbuf->dst, - sbuf->channel, sbuf->state); - if (sipc->client) - break; - - /* if channel state is already reay, reopen it - * (such as modem reset), we must skip the old - * buf data , than give open ack and reset state - * to idle - */ - if (sbuf->state == SBUF_STATE_READY) { - sbuf_skip_old_data(sbuf); - sbuf->state = SBUF_STATE_IDLE; - } - /* handle channel open */ - smsg_open_ack(sbuf->dst, sbuf->channel); - break; - case SMSG_TYPE_CLOSE: - /* handle channel close */ - sbuf_skip_old_data(sbuf); - smsg_close_ack(sbuf->dst, sbuf->channel); - sbuf->state = SBUF_STATE_IDLE; - break; - case SMSG_TYPE_CMD: - pr_info("%s: channel %d-%d state = %d, recv cmd msg, flag = %d!\n", - __func__, sbuf->dst, sbuf->channel, - sbuf->state, mrecv.flag); - if (sipc->client) - break; - - /* respond cmd done for sbuf init only state is idle */ - if (sbuf->state == SBUF_STATE_IDLE && - mrecv.flag == SMSG_CMD_SBUF_INIT) { - smsg_set(&mcmd, - sbuf->channel, - SMSG_TYPE_DONE, - SMSG_DONE_SBUF_INIT, - sbuf->dst_smem_addr); - smsg_send(sbuf->dst, &mcmd, -1); - sbuf->state = SBUF_STATE_READY; - for (bufid = 0; bufid < sbuf->ringnr; bufid++) { - ring = &sbuf->rings[bufid]; - if (ring->handler) - ring->handler(SBUF_NOTIFY_READY, - ring->data); - } - } - break; - case SMSG_TYPE_EVENT: - bufid = mrecv.value; - WARN_ON(bufid >= sbuf->ringnr); - ring = &sbuf->rings[bufid]; - switch (mrecv.flag) { - case SMSG_EVENT_SBUF_RDPTR: - if (ring->need_wake_lock) - sprd_pms_request_wakelock_period(ring->tx_pms, - 500); - /* set write mask. */ - spin_lock_irqsave(&ring->poll_lock, flags); - ring->poll_mask |= POLLOUT | POLLWRNORM; - spin_unlock_irqrestore(&ring->poll_lock, flags); - wake_up_interruptible_all(&ring->txwait); - if (ring->handler) - ring->handler(SBUF_NOTIFY_WRITE, - ring->data); - break; - case SMSG_EVENT_SBUF_WRPTR: - /* set read mask. */ - spin_lock_irqsave(&ring->poll_lock, flags); - ring->poll_mask |= POLLIN | POLLRDNORM; - spin_unlock_irqrestore(&ring->poll_lock, flags); - - if (ring->need_wake_lock) - sprd_pms_request_wakelock_period(ring->rx_pms, - 500); - wake_up_interruptible_all(&ring->rxwait); - if (ring->handler) - ring->handler(SBUF_NOTIFY_READ, - ring->data); - break; - default: - rval = 1; - break; - } - break; - default: - rval = 1; - break; - }; - - if (rval) { - pr_info("non-handled sbuf msg: %d-%d, %d, %d, %d\n", - sbuf->dst, - sbuf->channel, - mrecv.type, - mrecv.flag, - mrecv.value); - rval = 0; - } - /* unlock sipc channel wake lock */ - smsg_ch_wake_unlock(sbuf->dst, sbuf->channel); - } - - return 0; -} - - -int sbuf_create(u8 dst, u8 channel, u32 bufnum, u32 txbufsize, u32 rxbufsize) -{ - struct sbuf_mgr *sbuf; - u8 ch_index; - int ret; - struct smsg_ipc *sipc = NULL; - struct sched_param param = {.sched_priority = 10}; - - sipc = smsg_ipcs[dst]; - ch_index = sipc_channel2index(channel); - if (ch_index == INVALID_CHANEL_INDEX) { - pr_err("%s:channel %d invalid!\n", __func__, channel); - return -EINVAL; - } - - pr_debug("%s dst=%d, chanel=%d, bufnum=%d, txbufsize=0x%x, rxbufsize=0x%x\n", - __func__, - dst, - channel, - bufnum, - txbufsize, - rxbufsize); - - if (dst >= SIPC_ID_NR || !sipc) { - pr_err("%s: dst = %d is invalid\n", __func__, dst); - return -EINVAL; - } - - sbuf = kzalloc(sizeof(*sbuf), GFP_KERNEL); - if (!sbuf) - return -ENOMEM; - - sbuf->state = SBUF_STATE_IDLE; - sbuf->dst = dst; - sbuf->channel = channel; - - /* The dst smem type is pcie, need force send smsg in sbuf_write. */ - if (sipc->type == SIPC_BASE_PCIE && sipc->smem_type == SMEM_LOCAL) - sbuf->force_send = true; - - if (!sipc->client) { - ret = sbuf_host_init(sipc, sbuf, bufnum, txbufsize, rxbufsize); - if (ret) { - kfree(sbuf); - return ret; - } - } - - sbuf->thread = kthread_create(sbuf_thread, sbuf, - "sbuf-%d-%d", dst, channel); - if (IS_ERR(sbuf->thread)) { - pr_err("Failed to create kthread: sbuf-%d-%d\n", dst, channel); - if (!sipc->client) { - kfree(sbuf->rings); - shmem_ram_unmap(dst, sbuf->smem_virt); - smem_free(dst, sbuf->smem_addr, sbuf->smem_size); - } - ret = PTR_ERR(sbuf->thread); - kfree(sbuf); - return ret; - } - - sbufs[dst][ch_index] = sbuf; - - /*set the thread as a real time thread, and its priority is 10*/ - sched_setscheduler(sbuf->thread, SCHED_FIFO, ¶m); - wake_up_process(sbuf->thread); - - return 0; -} -EXPORT_SYMBOL_GPL(sbuf_create); - -void sbuf_set_no_need_wake_lock(u8 dst, u8 channel, u32 bufnum) -{ - u8 ch_index; - struct sbuf_mgr *sbuf; - struct sbuf_ring *ring = NULL; - - ch_index = sipc_channel2index(channel); - if (ch_index == INVALID_CHANEL_INDEX) { - pr_err("%s:channel %d invalid!\n", __func__, channel); - return; - } - - sbuf = sbufs[dst][ch_index]; - if (!sbuf || sbuf->ringnr <= bufnum) - return; - - ring = &sbuf->rings[bufnum]; - ring->need_wake_lock = false; -} -EXPORT_SYMBOL_GPL(sbuf_set_no_need_wake_lock); - - -void sbuf_down(u8 dst, u8 channel) -{ - struct sbuf_mgr *sbuf; - u8 ch_index; - int i; - ch_index = sipc_channel2index(channel); - if (ch_index == INVALID_CHANEL_INDEX) { - pr_err("%s:channel %d invalid!\n", __func__, channel); - return; - } - - sbuf = sbufs[dst][ch_index]; - if (!sbuf) - return; - sbuf->state = SBUF_STATE_IDLE; - if (sbuf->rings) { - for (i = 0; i < sbuf->ringnr; i++) { - wake_up_interruptible_all(&sbuf->rings[i].txwait); - wake_up_interruptible_all(&sbuf->rings[i].rxwait); - } - } - pr_info("%s: channel=%d sbuf down success\n", __func__, channel); -} - -void sbuf_destroy(u8 dst, u8 channel) -{ - struct sbuf_mgr *sbuf; - int i; - u8 ch_index; - struct smsg_ipc *sipc; - - ch_index = sipc_channel2index(channel); - if (ch_index == INVALID_CHANEL_INDEX) { - pr_err("%s:channel %d invalid!\n", __func__, channel); - return; - } - - sbuf = sbufs[dst][ch_index]; - if (!sbuf) - return; - - sbuf->state = SBUF_STATE_IDLE; - smsg_ch_close(dst, channel, -1); - - /* stop sbuf thread if it's created successfully and still alive */ - if (!IS_ERR_OR_NULL(sbuf->thread)) - kthread_stop(sbuf->thread); - - if (sbuf->rings) { - for (i = 0; i < sbuf->ringnr; i++) { - wake_up_interruptible_all(&sbuf->rings[i].txwait); - wake_up_interruptible_all(&sbuf->rings[i].rxwait); -#if defined(SIPC_DEBUG_SBUF_RDWT_OWNER) - sbuf_destroy_rdwt_owner(&sbuf->rings[i]); -#endif - sprd_pms_destroy(sbuf->rings[i].tx_pms); - sprd_pms_destroy(sbuf->rings[i].rx_pms); - } - kfree(sbuf->rings); - } - - if (sbuf->smem_virt) - shmem_ram_unmap(dst, sbuf->smem_virt); - - sipc = smsg_ipcs[dst]; - if (sipc->client) - smem_free(dst, sbuf->smem_addr_debug, sbuf->smem_size); - else - smem_free(dst, sbuf->smem_addr, sbuf->smem_size); - - kfree(sbuf); - - sbufs[dst][ch_index] = NULL; -} -EXPORT_SYMBOL_GPL(sbuf_destroy); - -int sbuf_write(u8 dst, u8 channel, u32 bufid, - void *buf, u32 len, int timeout) -{ - struct sbuf_mgr *sbuf; - struct sbuf_ring *ring = NULL; - struct sbuf_ring_header_op *hd_op; - struct smsg mevt; - void *txpos; - int rval, left, tail, txsize; - u8 ch_index; - union sbuf_buf u_buf; - bool no_data; - unsigned long flags; - u32 v; - - u_buf.buf = buf; - ch_index = sipc_channel2index(channel); - if (ch_index == INVALID_CHANEL_INDEX) { - pr_err("%s:channel %d invalid!\n", __func__, channel); - return -EINVAL; - } - - sbuf = sbufs[dst][ch_index]; - if (!sbuf) - return -ENODEV; - ring = &sbuf->rings[bufid]; - hd_op = &ring->header_op; - if (sbuf->state != SBUF_STATE_READY) { - pr_info("sbuf-%d-%d not ready to write!\n", - dst, channel); - return -ENODEV; - } - - pr_debug("%s: dst=%d, channel=%d, bufid=%d, len=%d, timeout=%d\n", - __func__, - dst, - channel, - bufid, - len, - timeout); - - rval = 0; - left = len; - - if (timeout) { - mutex_lock_interruptible(&ring->txlock); - } else { - if (!mutex_trylock(&ring->txlock)) { - pr_debug("sbuf_read busy, dst=%d, channel=%d, bufid=%d\n", - dst, channel, bufid); - return -EBUSY; - } - } - -#if defined(SIPC_DEBUG_SBUF_RDWT_OWNER) - sbuf_record_rdwt_owner(ring, 0); -#endif - - /* must request resource before read or write share memory */ - rval = sipc_smem_request_resource(ring->tx_pms, sbuf->dst, -1); - if (rval < 0) { - mutex_unlock(&ring->txlock); - return rval; - } - - pr_debug("%s: channel=%d, wrptr=%d, rdptr=%d\n", - __func__, - channel, - BL_READL(hd_op->tx_wt_p), - BL_READL(hd_op->tx_rd_p)); - no_data = ((int)(BL_READL(hd_op->tx_wt_p) - BL_READL(hd_op->tx_rd_p)) >= - hd_op->tx_size); - - /* update write mask */ - spin_lock_irqsave(&ring->poll_lock, flags); - if (no_data) - ring->poll_mask &= ~(POLLOUT | POLLWRNORM); - else - ring->poll_mask |= POLLOUT | POLLWRNORM; - spin_unlock_irqrestore(&ring->poll_lock, flags); - - /* release resource */ - sipc_smem_release_resource(ring->tx_pms, sbuf->dst); - - if (no_data) { - if (timeout == 0) { - pr_info("%s: %d-%d ring %d txbuf is full!\n", - __func__, dst, channel, bufid); - rval = -EBUSY; - } else if (timeout < 0) { - /* wait forever */ - rval = wait_event_interruptible( - ring->txwait, - sbuf_has_data(ring, dst, true) || - sbuf->state == SBUF_STATE_IDLE); - if (rval < 0) - pr_debug("%s: wait interrupted!\n", __func__); - - if (sbuf->state == SBUF_STATE_IDLE) { - pr_err("%s: sbuf state is idle!\n", __func__); - rval = -EIO; - } - } else { - /* wait timeout */ - rval = wait_event_interruptible_timeout( - ring->txwait, - sbuf_has_data(ring, dst, true) || - sbuf->state == SBUF_STATE_IDLE, - timeout); - if (rval < 0) { - pr_debug("%s: wait interrupted!\n", __func__); - } else if (rval == 0) { - pr_info("%s: wait timeout!\n", __func__); - rval = -ETIME; - } - - if (sbuf->state == SBUF_STATE_IDLE) { - pr_err("%s: sbuf state is idle!\n", __func__); - rval = -EIO; - } - } - } - - if (rval < 0) { - mutex_unlock(&ring->txlock); - return rval; - } - - /* must request resource before read or write share memory */ - rval = sipc_smem_request_resource(ring->tx_pms, sbuf->dst, -1); - if (rval < 0) { - mutex_unlock(&ring->txlock); - return rval; - } - - while (left && (int)(BL_READL(hd_op->tx_wt_p) - BL_READL(hd_op->tx_rd_p)) < - hd_op->tx_size && sbuf->state == SBUF_STATE_READY) { - /* calc txpos & txsize */ - txpos = ring->txbuf_virt + - BL_READL(hd_op->tx_wt_p) % hd_op->tx_size; - txsize = hd_op->tx_size - - (int)(BL_READL(hd_op->tx_wt_p) - BL_READL(hd_op->tx_rd_p)); - txsize = min(txsize, left); - - tail = txpos + txsize - (ring->txbuf_virt + hd_op->tx_size); - if (tail > 0) { - /* ring buffer is rounded */ - if ((uintptr_t)u_buf.buf > TASK_SIZE) { - unalign_memcpy(txpos, u_buf.buf, txsize - tail); - unalign_memcpy(ring->txbuf_virt, - u_buf.buf + txsize - tail, tail); - } else { - if (unalign_copy_from_user( - txpos, - u_buf.ubuf, - txsize - tail) || - unalign_copy_from_user( - ring->txbuf_virt, - u_buf.ubuf + txsize - tail, - tail)) { - pr_err("%s:failed to copy from user!\n", - __func__); - rval = -EFAULT; - break; - } - } - } else { - if ((uintptr_t)u_buf.buf > TASK_SIZE) { - unalign_memcpy(txpos, u_buf.buf, txsize); - } else { - /* handle the user space address */ - if (unalign_copy_from_user( - txpos, - u_buf.ubuf, - txsize)) { - pr_err("%s:failed to copy from user!\n", - __func__); - rval = -EFAULT; - break; - } - } - } - - pr_debug("%s: channel=%d, txpos=%p, txsize=%d\n", - __func__, channel, txpos, txsize); - - /* update tx wrptr */ - v = BL_READL(hd_op->tx_wt_p) + txsize; - BL_WRITEL(v, hd_op->tx_wt_p); - /* - * force send be true or tx ringbuf is empty, - * need to notify peer side - */ - if (sbuf->force_send || - BL_READL(hd_op->tx_wt_p) - BL_READL(hd_op->tx_rd_p) == txsize) { - smsg_set(&mevt, channel, - SMSG_TYPE_EVENT, - SMSG_EVENT_SBUF_WRPTR, - bufid); - smsg_send(dst, &mevt, -1); - } - - left -= txsize; - u_buf.buf += txsize; - } - - /* update write mask */ - spin_lock_irqsave(&ring->poll_lock, flags); - if ((int)(BL_READL(hd_op->tx_wt_p) - BL_READL(hd_op->tx_rd_p)) >= - hd_op->tx_size) - ring->poll_mask &= ~(POLLOUT | POLLWRNORM); - else - ring->poll_mask |= POLLOUT | POLLWRNORM; - spin_unlock_irqrestore(&ring->poll_lock, flags); - - /* release resource */ - sipc_smem_release_resource(ring->tx_pms, sbuf->dst); - if (ring->need_wake_lock) - sprd_pms_release_wakelock_later(ring->tx_pms, 20); - - mutex_unlock(&ring->txlock); - - pr_debug("%s: done, channel=%d, len=%d\n", - __func__, channel, len - left); - - if (len == left) - return rval; - else - return (len - left); -} -EXPORT_SYMBOL_GPL(sbuf_write); - -int sbuf_read(u8 dst, u8 channel, u32 bufid, - void *buf, u32 len, int timeout) -{ - struct sbuf_mgr *sbuf; - struct sbuf_ring *ring = NULL; - struct sbuf_ring_header_op *hd_op; - struct smsg mevt; - void *rxpos; - int rval, left, tail, rxsize; - u8 ch_index; - union sbuf_buf u_buf; - bool no_data; - unsigned long flags; - u32 v; - - u_buf.buf = buf; - ch_index = sipc_channel2index(channel); - if (ch_index == INVALID_CHANEL_INDEX) { - pr_err("%s:channel %d invalid!\n", __func__, channel); - return -EINVAL; - } - sbuf = sbufs[dst][ch_index]; - if (!sbuf) - return -ENODEV; - ring = &sbuf->rings[bufid]; - hd_op = &ring->header_op; - - if (sbuf->state != SBUF_STATE_READY) { - pr_debug("sbuf-%d-%d not ready to read!\n", dst, channel); - return -ENODEV; - } - - pr_debug("%s:dst=%d, channel=%d, bufid=%d, len=%d, timeout=%d\n", - __func__, dst, channel, bufid, len, timeout); - - rval = 0; - left = len; - - if (timeout) { - mutex_lock_interruptible(&ring->rxlock); - } else { - if (!mutex_trylock(&ring->rxlock)) { - pr_debug("%s: busy!,dst=%d, channel=%d, bufid=%d\n", - __func__, dst, channel, bufid); - return -EBUSY; - } - } - -#if defined(SIPC_DEBUG_SBUF_RDWT_OWNER) - sbuf_record_rdwt_owner(ring, 1); -#endif - - /* must request resource before read or write share memory */ - rval = sipc_smem_request_resource(ring->rx_pms, sbuf->dst, -1); - if (rval < 0) { - mutex_unlock(&ring->rxlock); - return rval; - } - - pr_debug("%s: channel=%d, wrptr=%d, rdptr=%d\n", - __func__, - channel, - BL_READL(hd_op->rx_wt_p), - BL_READL(hd_op->rx_rd_p)); - no_data = (BL_READL(hd_op->rx_wt_p) == BL_READL(hd_op->rx_rd_p)); - /* update read mask */ - spin_lock_irqsave(&ring->poll_lock, flags); - if (no_data) - ring->poll_mask &= ~(POLLIN | POLLRDNORM); - else - ring->poll_mask |= POLLIN | POLLRDNORM; - spin_unlock_irqrestore(&ring->poll_lock, flags); - - /* release resource */ - sipc_smem_release_resource(ring->rx_pms, sbuf->dst); - - if (no_data) { - if (timeout == 0) { - /* no wait */ - pr_debug("%s: %d-%d ring %d rxbuf is empty!\n", - __func__, dst, channel, bufid); - rval = -ENODATA; - } else if (timeout < 0) { - /* wait forever */ - rval = wait_event_interruptible( - ring->rxwait, - sbuf_has_data(ring, dst, false) || - sbuf->state == SBUF_STATE_IDLE); - if (rval < 0) - pr_debug("%s: wait interrupted!\n", __func__); - - if (sbuf->state == SBUF_STATE_IDLE) { - pr_err("%s: sbuf state is idle!\n", __func__); - rval = -EIO; - } - } else { - /* wait timeout */ - rval = wait_event_interruptible_timeout( - ring->rxwait, - sbuf_has_data(ring, dst, false) || - sbuf->state == SBUF_STATE_IDLE, timeout); - if (rval < 0) { - pr_debug("%s: wait interrupted!\n", __func__); - } else if (rval == 0) { - pr_info("%s: wait timeout!\n", __func__); - rval = -ETIME; - } - - if (sbuf->state == SBUF_STATE_IDLE) { - pr_err("%s: state is idle!\n", __func__); - rval = -EIO; - } - } - } - - if (rval < 0) { - mutex_unlock(&ring->rxlock); - return rval; - } - - /* must request resource before read or write share memory */ - rval = sipc_smem_request_resource(ring->rx_pms, sbuf->dst, -1); - if (rval < 0) { - mutex_unlock(&ring->rxlock); - return rval; - } - - while (left && - (BL_READL(hd_op->rx_wt_p) != BL_READL(hd_op->rx_rd_p)) && - sbuf->state == SBUF_STATE_READY) { - /* calc rxpos & rxsize */ - rxpos = ring->rxbuf_virt + - BL_READL(hd_op->rx_rd_p) % hd_op->rx_size; - rxsize = (int)(BL_READL(hd_op->rx_wt_p) - BL_READL(hd_op->rx_rd_p)); - /* check overrun */ - if (rxsize > hd_op->rx_size) - pr_err("%s: bufid = %d, channel= %d rxsize=0x%x, rdptr=%d, wrptr=%d", - __func__, - bufid, - channel, - rxsize, - BL_READL(hd_op->rx_wt_p), - BL_READL(hd_op->rx_rd_p)); - - rxsize = min(rxsize, left); - - pr_debug("%s: channel=%d, buf=%p, rxpos=%p, rxsize=%d\n", - __func__, channel, u_buf.buf, rxpos, rxsize); - - tail = rxpos + rxsize - (ring->rxbuf_virt + hd_op->rx_size); - - if (tail > 0) { - /* ring buffer is rounded */ - if ((uintptr_t)u_buf.buf > TASK_SIZE) { - unalign_memcpy(u_buf.buf, rxpos, rxsize - tail); - unalign_memcpy(u_buf.buf + rxsize - tail, - ring->rxbuf_virt, tail); - } else { - /* handle the user space address */ - if (unalign_copy_to_user(u_buf.ubuf, - rxpos, - rxsize - tail) || - unalign_copy_to_user(u_buf.ubuf - + rxsize - tail, - ring->rxbuf_virt, - tail)) { - pr_err("%s: failed to copy to user!\n", - __func__); - rval = -EFAULT; - break; - } - } - } else { - if ((uintptr_t)u_buf.buf > TASK_SIZE) { - unalign_memcpy(u_buf.buf, rxpos, rxsize); - } else { - /* handle the user space address */ - if (unalign_copy_to_user(u_buf.ubuf, - rxpos, rxsize)) { - pr_err("%s: failed to copy to user!\n", - __func__); - rval = -EFAULT; - break; - } - } - } - - /* update rx rdptr */ - v = BL_READL(hd_op->rx_rd_p) + rxsize; - BL_WRITEL(v, hd_op->rx_rd_p); - /* rx ringbuf is full ,so need to notify peer side */ - if (BL_READL(hd_op->rx_wt_p) - BL_READL(hd_op->rx_rd_p) == - hd_op->rx_size - rxsize) { - smsg_set(&mevt, channel, - SMSG_TYPE_EVENT, - SMSG_EVENT_SBUF_RDPTR, - bufid); - smsg_send(dst, &mevt, -1); - } - - left -= rxsize; - u_buf.buf += rxsize; - } - - /* update read mask */ - spin_lock_irqsave(&ring->poll_lock, flags); - if (BL_READL(hd_op->rx_wt_p) == BL_READL(hd_op->rx_rd_p)) - ring->poll_mask &= ~(POLLIN | POLLRDNORM); - else - ring->poll_mask |= POLLIN | POLLRDNORM; - spin_unlock_irqrestore(&ring->poll_lock, flags); - - /* release resource */ - sipc_smem_release_resource(ring->rx_pms, sbuf->dst); - if (ring->need_wake_lock) - sprd_pms_release_wakelock_later(ring->rx_pms, 20); - - mutex_unlock(&ring->rxlock); - - pr_debug("%s: done, channel=%d, len=%d", __func__, channel, len - left); - - if (len == left) - return rval; - else - return (len - left); -} -EXPORT_SYMBOL_GPL(sbuf_read); - -int sbuf_poll_wait(u8 dst, u8 channel, u32 bufid, - struct file *filp, poll_table *wait) -{ - struct sbuf_mgr *sbuf; - struct sbuf_ring *ring = NULL; - struct sbuf_ring_header_op *hd_op; - unsigned int mask = 0; - u8 ch_index; - - ch_index = sipc_channel2index(channel); - if (ch_index == INVALID_CHANEL_INDEX) { - pr_err("%s:channel %d invalid!\n", __func__, channel); - return mask; - } - sbuf = sbufs[dst][ch_index]; - if (!sbuf) - return mask; - ring = &sbuf->rings[bufid]; - hd_op = &ring->header_op; - if (sbuf->state != SBUF_STATE_READY) { - pr_err("sbuf-%d-%d not ready to poll !\n", dst, channel); - return mask; - } - - poll_wait(filp, &ring->txwait, wait); - poll_wait(filp, &ring->rxwait, wait); - - - if (sbuf_has_data(ring, dst, true)) - mask |= POLLOUT | POLLWRNORM; - - if (sbuf_has_data(ring, dst, false)) - mask |= POLLIN | POLLRDNORM; - - return mask; -} -EXPORT_SYMBOL_GPL(sbuf_poll_wait); - -int sbuf_status(u8 dst, u8 channel) -{ - struct sbuf_mgr *sbuf; - u8 ch_index; - - ch_index = sipc_channel2index(channel); - if (ch_index == INVALID_CHANEL_INDEX) { - pr_err("%s:channel %d invalid!\n", __func__, channel); - return -EINVAL; - } - sbuf = sbufs[dst][ch_index]; - - if (!sbuf) - return -ENODEV; - if (sbuf->state != SBUF_STATE_READY) - return -ENODEV; - - return 0; -} -EXPORT_SYMBOL_GPL(sbuf_status); - -int sbuf_register_notifier(u8 dst, u8 channel, u32 bufid, - void (*handler)(int event, void *data), void *data) -{ - struct sbuf_mgr *sbuf; - struct sbuf_ring *ring = NULL; - u8 ch_index; - - ch_index = sipc_channel2index(channel); - if (ch_index == INVALID_CHANEL_INDEX) { - pr_err("%s:channel %d invalid!\n", __func__, channel); - return -EINVAL; - } - sbuf = sbufs[dst][ch_index]; - if (!sbuf) - return -ENODEV; - ring = &sbuf->rings[bufid]; - ring->handler = handler; - ring->data = data; - - if (sbuf->state == SBUF_STATE_READY) - handler(SBUF_NOTIFY_READ, data); - - return 0; -} -EXPORT_SYMBOL_GPL(sbuf_register_notifier); - -void sbuf_get_status(u8 dst, char *status_info, int size) -{ - struct sbuf_mgr *sbuf = NULL; - struct sbuf_ring *ring = NULL; - struct sbuf_ring_header_op *hd_op; - -#if (LINUX_VERSION_CODE <= KERNEL_VERSION( 4,10,0 )) - wait_queue_t *pos; -#else - wait_queue_entry_t *pos; -#endif - struct task_struct *task; - unsigned long flags; - int i, n, len, cnt; - u32 b_select; - char *phead; -#if defined(SIPC_DEBUG_SBUF_RDWT_OWNER) - struct name_node *node = NULL; -#endif - - len = strlen(status_info); - if (!status_info || size < 0 || dst >= SIPC_ID_NR) - return; - - for (i = 0; i < SMSG_VALID_CH_NR; i++) { - sbuf = sbufs[dst][i]; - if (!sbuf) - continue; - - ring = &sbuf->rings[0]; - /* must request resource before read or write share memory */ - if (sipc_smem_request_resource(ring->rx_pms, dst, 1000) < 0) - continue; - - for (n = 0; n < sbuf->ringnr && len < size; n++) { - ring = &sbuf->rings[n]; - hd_op = &ring->header_op; - - if ((BL_READL(hd_op->rx_wt_p) - BL_READL(hd_op->rx_rd_p)) - < hd_op->rx_size) - continue; - - snprintf(status_info + len, - size - len, - "ch-%d-ring-%d is full.\n", - sbuf->channel, - n); - len = strlen(status_info); - - /* show all rxwait task */ - spin_lock_irqsave(&ring->rxwait.lock, flags); - cnt = 0; - - list_for_each_entry(pos, -#if (LINUX_VERSION_CODE <= KERNEL_VERSION( 4,10,0 )) - &ring->rxwait.task_list, - task_list -#else - &ring->rxwait.head, - entry -#endif - ) { - task = sbuf_wait_get_task(pos, &b_select); - if (!task) - continue; - - if (b_select) - phead = "rxwait task"; - else - phead = "select task"; - - snprintf( - status_info + len, - size - len, - "%s %d: %s, state=0x%lx, pid=%d.\n", - phead, - cnt, task->comm, - task->state, task->pid); - cnt++; - len = strlen(status_info); - } - spin_unlock_irqrestore(&ring->rxwait.lock, flags); - - /* only show the latest ever read task */ -#if defined(SIPC_DEBUG_SBUF_RDWT_OWNER) - spin_lock_irqsave(&ring->rxwait.lock, flags); - list_for_each_entry(node, &ring->rx_list, list) { - if (node->latest) { - snprintf( - status_info + len, - size - len, - "read task: %s, pid = %d.\n", - node->comm, - node->pid); - break; - } - } - spin_unlock_irqrestore(&ring->rxwait.lock, flags); -#endif - } - ring = &sbuf->rings[0]; - /* release resource */ - sipc_smem_release_resource(ring->rx_pms, sbuf->dst); - } -} -EXPORT_SYMBOL_GPL(sbuf_get_status); - -#if defined(CONFIG_DEBUG_FS) -static void sbuf_debug_task_show(struct seq_file *m, - struct sbuf_mgr *sbuf, int task_type) -{ - int n, cnt; - u32 b_select; - unsigned long flags; - struct sbuf_ring *ring = NULL; - wait_queue_head_t *phead; - char *buf; -#if (LINUX_VERSION_CODE <= KERNEL_VERSION( 4,10,0 )) - wait_queue_t *pos; -#else - wait_queue_entry_t *pos; -#endif - struct task_struct *task; - - for (n = 0; n < sbuf->ringnr; n++) { - ring = &sbuf->rings[n]; - cnt = 0; - - if (task_type == TASK_RXWAIT) { - phead = &ring->rxwait; - buf = "rxwait task"; - } else if (task_type == TASK_TXWAIT) { - phead = &ring->txwait; - buf = "txwait task"; - } else { - phead = &ring->rxwait; - buf = "select task"; - } - - spin_lock_irqsave(&phead->lock, flags); - - list_for_each_entry(pos, -#if (LINUX_VERSION_CODE <= KERNEL_VERSION( 4,10,0 )) - &phead->task_list, task_list -#else - &phead->head, entry -#endif - ){ - task = sbuf_wait_get_task(pos, &b_select); - if (!task) - continue; - - if (b_select && (task_type != TASK_SELECT)) - continue; - - seq_printf(m, " ring[%2d]: %s %d ", - n, - buf, - cnt); - seq_printf(m, ": %s, state = 0x%lx, pid = %d\n", - task->comm, - task->state, - task->pid); - cnt++; - } - spin_unlock_irqrestore( - &phead->lock, - flags); - } -} - -#if defined(SIPC_DEBUG_SBUF_RDWT_OWNER) -static void sbuf_debug_list_show(struct seq_file *m, - struct sbuf_mgr *sbuf, int b_rx) -{ - int n, cnt; - struct sbuf_ring *ring = NULL; - struct list_head *plist; - char *buf; - struct name_node *node = NULL; - unsigned long flags; - - /* list all sbuf task list */ - for (n = 0; n < sbuf->ringnr; n++) { - ring = &sbuf->rings[n]; - cnt = 0; - - if (b_rx) { - plist = &ring->rx_list; - buf = "read task"; - } else { - plist = &ring->tx_list; - buf = "write task"; - } - - spin_lock_irqsave(&ring->rxwait.lock, flags); - list_for_each_entry(node, plist, list) { - seq_printf(m, " ring[%2d]: %s %d : %s, pid = %d, latest = %d\n", - n, - buf, - cnt, - node->comm, - node->pid, - node->latest); - cnt++; - } - spin_unlock_irqrestore(&ring->rxwait.lock, flags); - } -} -#endif - -static int sbuf_debug_show(struct seq_file *m, void *private) -{ - struct sbuf_mgr *sbuf = NULL; - struct sbuf_ring *ring = NULL; - struct sbuf_ring_header_op *hd_op; - int i, j, n, cnt; - struct smsg_ipc *sipc = NULL; - - for (i = 0; i < SIPC_ID_NR; i++) { - sipc = smsg_ipcs[i]; - if (!sipc) - continue; - - /* must request resource before read or write share memory */ - if (sipc_smem_request_resource(sipc->sipc_pms, - sipc->dst, 1000) < 0) - continue; - - sipc_debug_putline(m, '*', 120); - seq_printf(m, "dst: 0x%0x, sipc: %s:\n", i, sipc->name); - sipc_debug_putline(m, '*', 120); - - for (j = 0; j < SMSG_VALID_CH_NR; j++) { - sbuf = sbufs[i][j]; - if (!sbuf) - continue; - /* list a sbuf channel */ - sipc_debug_putline(m, '-', 100); - seq_printf(m, "sbuf_%d_%03d, state: %d, force: %d", - sbuf->dst, - sbuf->channel, - sbuf->state, - sbuf->force_send); - seq_printf(m, "virt: 0x%lx, phy: 0x%0x, map: 0x%x", - (unsigned long)sbuf->smem_virt, - sbuf->smem_addr, - sbuf->dst_smem_addr); - seq_printf(m, " size: 0x%0x, ringnr: %d\n", - sbuf->smem_size, - sbuf->ringnr); - sipc_debug_putline(m, '-', 100); - - /* list all sbuf ring info list in a chanel */ - sipc_debug_putline(m, '-', 80); - seq_puts(m, " 1. all sbuf ring info list:\n"); - for (n = 0; n < sbuf->ringnr; n++) { - ring = &sbuf->rings[n]; - hd_op = &ring->header_op; - if (BL_READL(hd_op->tx_wt_p) == 0 && - BL_READL(hd_op->rx_wt_p) == 0) - continue; - - seq_printf(m, " rx ring[%2d]: addr: 0x%0x, mask: 0x%x", - n, ring->header->rxbuf_addr, - ring->poll_mask); - seq_printf(m, "rp: 0x%0x, wp: 0x%0x, size: 0x%0x\n", - BL_READL(hd_op->rx_rd_p), - BL_READL(hd_op->rx_wt_p), - hd_op->rx_size); - - seq_printf(m, " tx ring[%2d]: addr: 0x%0x, ", - n, ring->header->txbuf_addr); - seq_printf(m, "rp: 0x%0x, wp: 0x%0x, size: 0x%0x\n", - BL_READL(hd_op->tx_rd_p), - BL_READL(hd_op->tx_wt_p), - hd_op->tx_size); - } - - /* list all sbuf rxwait/txwait in a chanel */; - sipc_debug_putline(m, '-', 80); - seq_puts(m, " 2. all waittask list:\n"); - sbuf_debug_task_show(m, sbuf, TASK_RXWAIT); - sbuf_debug_task_show(m, sbuf, TASK_TXWAIT); - sbuf_debug_task_show(m, sbuf, TASK_SELECT); - -#ifdef SIPC_DEBUG_SBUF_RDWT_OWNER - /* list all sbuf ever read task list in a chanel */; - sipc_debug_putline(m, '-', 80); - seq_puts(m, " 3. all ever rdwt list:\n"); - sbuf_debug_list_show(m, sbuf, 1); - sbuf_debug_list_show(m, sbuf, 0); -#endif - - /* list all rx full ring list in a chanel */ - cnt = 0; - for (n = 0; n < sbuf->ringnr; n++) { - ring = &sbuf->rings[n]; - hd_op = &ring->header_op; - if ((BL_READL(hd_op->rx_wt_p) - BL_READL(hd_op->rx_rd_p)) - == hd_op->rx_size) { - if (cnt == 0) { - sipc_debug_putline(m, '-', 80); - seq_puts(m, " x. all rx full ring list:\n"); - } - cnt++; - seq_printf(m, " ring[%2d]\n", n); - } - } - } - /* release resource */ - sipc_smem_release_resource(sipc->sipc_pms, sipc->dst); - } - - return 0; -} - -static int sbuf_debug_open(struct inode *inode, struct file *file) -{ - return single_open(file, sbuf_debug_show, inode->i_private); -} - -static const struct file_operations sbuf_debug_fops = { - .open = sbuf_debug_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -int sbuf_init_debugfs(void *root) -{ - if (!root) - return -ENXIO; - debugfs_create_file("sbuf", 0444, - (struct dentry *)root, - NULL, &sbuf_debug_fops); - return 0; -} -EXPORT_SYMBOL_GPL(sbuf_init_debugfs); - -#endif /* CONFIG_DEBUG_FS */ - -MODULE_AUTHOR("Chen Gaopeng"); -MODULE_DESCRIPTION("SIPC/SBUF driver"); -MODULE_LICENSE("GPL v2"); diff --git a/quectel_SRPD_PCIE/src/sipc/sbuf.h b/quectel_SRPD_PCIE/src/sipc/sbuf.h deleted file mode 100644 index 80104f0..0000000 --- a/quectel_SRPD_PCIE/src/sipc/sbuf.h +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (C) 2019 Spreadtrum Communications Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef __SBUF_H -#define __SBUF_H - -/* flag for CMD/DONE msg type */ -#define SMSG_CMD_SBUF_INIT 0x0001 -#define SMSG_DONE_SBUF_INIT 0x0002 - -/* flag for EVENT msg type */ -#define SMSG_EVENT_SBUF_WRPTR 0x0001 -#define SMSG_EVENT_SBUF_RDPTR 0x0002 - -#if defined(CONFIG_DEBUG_FS) -#define SIPC_DEBUG_SBUF_RDWT_OWNER -#define MAX_RECORD_CNT 0x10 -#endif - -/* ring buf header */ -struct sbuf_ring_header { - /* send-buffer info */ - u32 txbuf_addr; - u32 txbuf_size; - u32 txbuf_rdptr; - u32 txbuf_wrptr; - - /* recv-buffer info */ - u32 rxbuf_addr; - u32 rxbuf_size; - u32 rxbuf_rdptr; - u32 rxbuf_wrptr; -}; - -struct sbuf_ring_header_op { - /* - * this points point to share memory - * for update rdptr and wtptr on share memory - */ - volatile u32 *rx_rd_p; - volatile u32 *rx_wt_p; - volatile u32 *tx_rd_p; - volatile u32 *tx_wt_p; - - /* - * this member copy from share memory, - * because this contents will not change on share memory - */ - u32 rx_size;/* rxbuf_size */ - u32 tx_size;/* txbuf_size */ -}; - -/* sbuf_mem is the structure of smem for rings */ -struct sbuf_smem_header { - u32 ringnr; - - struct sbuf_ring_header headers[0]; -}; - -struct sbuf_ring { - /* tx/rx buffer info */ - volatile struct sbuf_ring_header *header; - struct sbuf_ring_header_op header_op; - - void *txbuf_virt; - void *rxbuf_virt; - - /* send/recv wait queue */ - wait_queue_head_t txwait; - wait_queue_head_t rxwait; - -#if defined(SIPC_DEBUG_SBUF_RDWT_OWNER) - /* record all task histoy */ - struct list_head tx_list; - struct list_head rx_list; -#endif - - /* send/recv mutex */ - struct mutex txlock; - struct mutex rxlock; - - struct sprd_pms *tx_pms; - struct sprd_pms *rx_pms; - char tx_pms_name[20]; - char rx_pms_name[20]; - - bool need_wake_lock; - unsigned int poll_mask; - /* protect poll_mask member */ - spinlock_t poll_lock; - - void (*handler)(int event, void *data); - void *data; -}; - -#define SBUF_STATE_IDLE 0 -#define SBUF_STATE_READY 1 - -struct sbuf_mgr { - u8 dst; - u8 channel; - bool force_send; - u32 state; - - void *smem_virt; - u32 smem_addr; - u32 smem_size; - - u32 smem_addr_debug; - u32 dst_smem_addr; - u32 ringnr; - - struct sbuf_ring *rings; - struct task_struct *thread; -}; -#endif diff --git a/quectel_SRPD_PCIE/src/sipc/sipc.c b/quectel_SRPD_PCIE/src/sipc/sipc.c deleted file mode 100644 index ee256fa..0000000 --- a/quectel_SRPD_PCIE/src/sipc/sipc.c +++ /dev/null @@ -1,524 +0,0 @@ -/* - * Copyright (C) 2019 Spreadtrum Communications Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../include/sipc.h" -#include "sipc_priv.h" - -#define MBOX_BAMK "mbox" -#define PCIE_BAMK "pcie" - -enum { - NORMAL_MODE = 0, - CHARGE_MODE, - CALI_MODE -}; - -#define CALI_LATENCY (10000 * 1000) -#define NORMAL_LATENCY (1 * 1000) - -/* - * In charge mode, will only boot pm system, - * so just create pm systen sipc. - */ -static u8 g_boot_mode = NORMAL_MODE; -/* -static int __init sipc_early_mode(char *str) -{ - if (!memcmp(str, "charger", 7)) - g_boot_mode = CHARGE_MODE; - else if (!memcmp(str, "cali", 4)) - g_boot_mode = CALI_MODE; - else - g_boot_mode = NORMAL_MODE; - - return 0; -} - -early_param("androidboot.mode", sipc_early_mode); -*/ - -#if defined(CONFIG_DEBUG_FS) -void sipc_debug_putline(struct seq_file *m, char c, int n) -{ - char buf[300]; - int i, max, len; - - /* buf will end with '\n' and 0 */ - max = ARRAY_SIZE(buf) - 2; - len = (n > max) ? max : n; - - for (i = 0; i < len; i++) - buf[i] = c; - - buf[i] = '\n'; - buf[i + 1] = 0; - - seq_puts(m, buf); -} -EXPORT_SYMBOL_GPL(sipc_debug_putline); -#endif - -static u32 sipc_rxirq_status(u8 dst) -{ - return 0; -} - -static void sipc_rxirq_clear(u8 dst) -{ - -} - -static void sipc_txirq_trigger(u8 dst, u64 msg) -{ - struct smsg_ipc *ipc; - - ipc = smsg_ipcs[dst]; - - if (ipc) { -#ifdef CONFIG_SPRD_MAILBOX - if (ipc->type == SIPC_BASE_MBOX) { - mbox_raw_sent(ipc->core_id, msg); - return; - } -#endif - - if (ipc->type == SIPC_BASE_PCIE) { -#ifdef CONFIG_SPRD_PCIE_EP_DEVICE - sprd_ep_dev_raise_irq(ipc->ep_dev, PCIE_DBELL_SIPC_IRQ); -#endif - -#ifdef CONFIG_PCIE_EPF_SPRD - sprd_pci_epf_raise_irq(ipc->ep_fun, PCIE_MSI_SIPC_IRQ); -#endif - return; - } - } -} - -#ifdef SPRD_PCIE_USE_DTS -static int sipc_parse_dt(struct smsg_ipc *ipc, - struct device_node *np, struct device *dev) -{ - u32 val[3]; - int ret; - const char *type; - - /* get name */ - ret = of_property_read_string(np, "sprd,name", &ipc->name); - if (ret) - return ret; - - pr_info("sipc: name=%s\n", ipc->name); - - /* get sipc type, optional */ - if (of_property_read_string(np, "sprd,type", &type) == 0) { - pr_info("sipc: type=%s\n", type); - if (strcmp(MBOX_BAMK, type) == 0) - ipc->type = SIPC_BASE_MBOX; - else if (strcmp(PCIE_BAMK, type) == 0) - ipc->type = SIPC_BASE_PCIE; - } - - /* get sipc client, optional */ - if (of_property_read_u32_array(np, "sprd,client", val, 1) == 0) { - ipc->client = (u8)val[0]; - pr_info("sipc: client=%d\n", ipc->client); - } - - /* get sipc dst */ - ret = of_property_read_u32_array(np, "sprd,dst", val, 1); - if (!ret) { - ipc->dst = (u8)val[0]; - pr_info("sipc: dst =%d\n", ipc->dst); - } - - if (ret || ipc->dst >= SIPC_ID_NR) { - pr_err("sipc: dst err, ret =%d.\n", ret); - return ret; - } - -#ifdef CONFIG_SPRD_MAILBOX - if (ipc->type == SIPC_BASE_MBOX) { - /* get core id */ - ipc->core_id = (u8)MBOX_INVALID_CORE; - ret = of_property_read_u32_array(np, "sprd,core", val, 1); - if (!ret) { - ipc->core_id = (u8)val[0]; - pr_info("sipc: core=%d\n", ipc->core_id); - } else { - pr_err("sipc: core err, ret =%d.\n", ret); - return ret; - } - - /* get core sensor id, optional*/ - ipc->core_sensor_id = (u8)MBOX_INVALID_CORE; - if (of_property_read_u32_array(np, "sprd,core_sensor", - val, 1) == 0) { - ipc->core_sensor_id = (u8)val[0]; - pr_info("sipc: core_sensor=%d\n", ipc->core_sensor_id); - } - } -#endif - -#ifdef CONFIG_SPRD_PCIE_EP_DEVICE - if (ipc->type == SIPC_BASE_PCIE) { -#ifdef CONFIG_SPRD_PCIE - struct device_node *pdev_node; -#endif - - ret = of_property_read_u32_array(np, - "sprd,ep-dev", - &ipc->ep_dev, - 1); - pr_info("sipc: ep_dev=%d\n", ipc->ep_dev); - if (ret || ipc->ep_dev >= PCIE_EP_NR) { - pr_err("sipc: ep_dev err, ret =%d.\n", ret); - return ret; - } - -#ifdef CONFIG_SPRD_PCIE - /* get pcie rc ctrl device */ - pdev_node = of_parse_phandle(np, "sprd,rc-ctrl", 0); - if (!pdev_node) { - pr_err("sipc: sprd,rc-ctrl err.\n"); - return -ENODEV; - } - ipc->pcie_dev = of_find_device_by_node(pdev_node); - of_node_put(pdev_node); - - if (!ipc->pcie_dev) { - pr_err("sipc: find pcie_dev err.\n"); - return -ENODEV; - } -#endif - } -#endif - -#ifdef CONFIG_PCIE_EPF_SPRD - if (ipc->type == SIPC_BASE_PCIE) { - ret = of_property_read_u32_array(np, - "sprd,ep-fun", - &ipc->ep_fun, - 1); - pr_info("sipc: ep_fun=%d\n", ipc->ep_fun); - if (ret || ipc->ep_fun >= SPRD_FUNCTION_MAX) { - pr_err("sipc: ep_fun err, ret =%d.\n", ret); - return ret; - } - - /* parse doolbell irq */ - ret = of_irq_get(np, 0); - if (ret < 0) { - pr_err("sipc: doorbell irq err, ret=%d\n", ret); - return -EINVAL; - } - ipc->irq = ret; - pr_info("sipc: irq=%d\n", ipc->irq); - } -#endif - - /* get smem type */ - ret = of_property_read_u32_array(np, - "sprd,smem-type", - &val[0], - 1); - if (!ret) - ipc->smem_type = (enum smem_type)val[0]; - else - ipc->smem_type = SMEM_LOCAL; - - pr_info("sipc: smem_type = %d, ret =%d\n", ipc->smem_type, ret); - - /* get smem info */ - ret = of_property_read_u32_array(np, - "sprd,smem-info", - val, - 3); - if (ret) { - pr_err("sipc: parse smem info failed.\n"); - return ret; - } - ipc->smem_base = val[0]; - ipc->dst_smem_base = val[1]; - ipc->smem_size = val[2]; - pr_info("sipc: smem_base=0x%x, dst_smem_base=0x%x, smem_size=0x%x\n", - ipc->smem_base, ipc->dst_smem_base, ipc->smem_size); - -#ifdef CONFIG_PHYS_ADDR_T_64BIT - /* try to get high_offset */ - ret = of_property_read_u32(np, - "sprd,high-offset", - val); - if (!ret) { - ipc->high_offset = val[0]; - pr_info("sipc: high_offset=0x%xn", ipc->high_offset); - } -#endif - - if (ipc->type == SIPC_BASE_PCIE) { - /* pcie sipc, the host must use loacal SMEM_LOCAL */ - if (!ipc->client && ipc->smem_type != SMEM_LOCAL) { - pr_err("sipc: host must use local smem!"); - return -EINVAL; - } - - if (ipc->client && ipc->smem_type != SMEM_PCIE) { - pr_err("sipc: client must use pcie smem!"); - return -EINVAL; - } - } - - return 0; -} -#else -static u32 sipc_get_smem_base(size_t size) -{ - unsigned long order = get_order(size); - struct page *page, *p, *e; - - page = alloc_pages(GFP_KERNEL, order); - if(page == NULL) { - printk("sipc alloc pages fail\n"); - return 0; - } - split_page(page, order); - for (p = page +(size >> PAGE_SHIFT), e = page + (1 << order); p < e; p++) - __free_page(p); - - if (PageHighMem(page)) { - phys_addr_t base = __pfn_to_phys(page_to_pfn(page)); - //phys_addr_t end = base + size; - while (size > 0) { - void *ptr = kmap_atomic(page); - memset(ptr, 0, PAGE_SIZE); - kunmap_atomic(ptr); - page++; - size -= PAGE_SIZE; - } - - return base; - } else { - void *ptr = page_address(page); - memset(ptr, 0, size); - return __pa(ptr); - } -} - -static int sipc_parse_dt(struct smsg_ipc *ipc, - struct device_node *np, struct device *dev) -{ - u32 val[3]; - int ret = 0; - //dma_addr_t *dma_handle; - - /* get name */ - ipc->name = "sprd,sipc"; - pr_info("sipc: name=%s\n", ipc->name); - - /* get sipc type, optional */ - ipc->type = SIPC_BASE_PCIE; - pr_info("sipc: type=%d\n", ipc->type); - - /* get sipc client, optional */ - - /* get sipc dst */ - ipc->dst = 1; - pr_info("sipc: dst =%d\n", ipc->dst); - - if (ipc->dst >= SIPC_ID_NR) { - pr_err("sipc: dst err\n"); - return ret; - } - -#ifdef CONFIG_SPRD_PCIE_EP_DEVICE - if (ipc->type == SIPC_BASE_PCIE) { - ipc->ep_dev = 0; - pr_info("sipc: ep_dev=%d\n", ipc->ep_dev); - if (ipc->ep_dev >= PCIE_EP_NR) { - pr_err("sipc: ep_dev err\n"); - return -1; - } - - } -#endif - /* get smem type */ - ipc->smem_type = SMEM_LOCAL; - - pr_info("sipc: smem_type = %d\n", ipc->smem_type); - - /* get smem info */ - val[0] = sipc_get_smem_base(0x0300000); - val[1] = val[0]; - val[2] = 0x0300000; - ipc->smem_base = val[0]; - ipc->dst_smem_base = val[1]; - ipc->smem_size = val[2]; - pr_info("sipc: smem_base=0x%x, dst_smem_base=0x%x, smem_size=0x%x\n", - ipc->smem_base, ipc->dst_smem_base, ipc->smem_size); - -#ifdef CONFIG_PHYS_ADDR_T_64BIT - /* try to get high_offset */ - ipc->high_offset = 0; - pr_info("sipc: high_offset=0x%xn", ipc->high_offset); - -#endif - - if (ipc->type == SIPC_BASE_PCIE) { - /* pcie sipc, the host must use loacal SMEM_LOCAL */ - if (!ipc->client && ipc->smem_type != SMEM_LOCAL) { - pr_err("sipc: host must use local smem!"); - return -EINVAL; - } - - if (ipc->client && ipc->smem_type != SMEM_PCIE) { - pr_err("sipc: client must use pcie smem!"); - return -EINVAL; - } - } - - return 0; -} -#endif - -static int sipc_probe(struct platform_device *pdev) -{ - struct smsg_ipc *ipc; - struct device_node *np; - - if (1) { - np = pdev->dev.of_node; - ipc = devm_kzalloc(&pdev->dev, - sizeof(struct smsg_ipc), - GFP_KERNEL); - if (!ipc) - return -ENOMEM; - - if (sipc_parse_dt(ipc, np, &pdev->dev)) { - pr_err("%s: failed to parse dt!\n", __func__); - return -ENODEV; - } - - /* - * In charge mode, will only boot pm system, - * so just create pm systen sipc. - */ - if (g_boot_mode == CHARGE_MODE && ipc->dst != SIPC_ID_PM_SYS) - return -ENODEV; - - ipc->rxirq_status = sipc_rxirq_status; - ipc->rxirq_clear = sipc_rxirq_clear; - ipc->txirq_trigger = sipc_txirq_trigger; - spin_lock_init(&ipc->txpinlock); - - if (ipc->type == SIPC_BASE_PCIE) { - /* init mpm delay enter idle time for pcie. */ - if (g_boot_mode == CALI_MODE) - ipc->latency = CALI_LATENCY; - else - ipc->latency = NORMAL_LATENCY; - } - - smsg_ipc_create(ipc); - platform_set_drvdata(pdev, ipc); - } - return 0; -} - -static int sipc_remove(struct platform_device *pdev) -{ - struct smsg_ipc *ipc = platform_get_drvdata(pdev); - - smsg_ipc_destroy(ipc); - - devm_kfree(&pdev->dev, ipc); - return 0; -} - -#ifdef SPRD_PCIE_USE_DTS -static const struct of_device_id sipc_match_table[] = { - { .compatible = "sprd,sipc", }, - { }, -}; -#endif - -static struct platform_driver sipc_driver = { - .driver = { - .owner = THIS_MODULE, - .name = "sipc", -#ifdef SPRD_PCIE_USE_DTS - .of_match_table = sipc_match_table, -#endif - }, - .probe = sipc_probe, - .remove = sipc_remove, -}; - -#ifndef SPRD_PCIE_USE_DTS -static void sipc_platform_device_release(struct device *dev) {} -static struct platform_device sipc_device = { - .name = "sipc", - .id = -1, - .dev = { - .release = sipc_platform_device_release, - } -}; -#endif - -int sipc_init(void) -{ - int ret; - - smsg_init_channel2index(); -#ifndef SPRD_PCIE_USE_DTS - if((ret = platform_device_register(&sipc_device))) - return ret; -#endif - - if((ret = platform_driver_register(&sipc_driver))) { -#ifndef SPRD_PCIE_USE_DTS - platform_device_unregister(&sipc_device); -#endif - return ret; - } - - return ret; -} -EXPORT_SYMBOL_GPL(sipc_init); - -void sipc_exit(void) -{ - platform_driver_unregister(&sipc_driver); - printk("dayin is here0\n"); -#ifndef SPRD_PCIE_USE_DTS - platform_device_unregister(&sipc_device); -#endif -} -EXPORT_SYMBOL_GPL(sipc_exit); \ No newline at end of file diff --git a/quectel_SRPD_PCIE/src/sipc/sipc_debugfs.c b/quectel_SRPD_PCIE/src/sipc/sipc_debugfs.c deleted file mode 100644 index 135f139..0000000 --- a/quectel_SRPD_PCIE/src/sipc/sipc_debugfs.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2019 Spreadtrum Communications Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include -#include -#include -#include -#include -#include - -#include "../include/sipc.h" -#if defined(CONFIG_DEBUG_FS) -#include "sipc_debugfs.h" - -int sipc_init_debugfs(void) -{ - struct dentry *root = debugfs_create_dir("sipc", NULL); - - if (!root) - return -ENXIO; - - smsg_init_debugfs(root); -#if defined(CONFIG_SPRD_SIPC_SMSGC) - smsgc_init_debugfs(root); -#endif - sbuf_init_debugfs(root); - sblock_init_debugfs(root); -#ifdef CONFIG_SPRD_SIPC_ZERO_COPY_SIPX - sipx_init_debugfs(root); -#endif -#ifdef CONFIG_SPRD_SIPC_SWCNBLK - swcnblk_init_debugfs(root); -#endif - smem_init_debugfs(root); -#ifdef CONFIG_SPRD_MAILBOX - mbox_init_debugfs(root); -#endif - return 0; -} -EXPORT_SYMBOL_GPL(sipc_init_debugfs); -#endif /* CONFIG_DEBUG_FS */ diff --git a/quectel_SRPD_PCIE/src/sipc/sipc_debugfs.h b/quectel_SRPD_PCIE/src/sipc/sipc_debugfs.h deleted file mode 100644 index e7849f5..0000000 --- a/quectel_SRPD_PCIE/src/sipc/sipc_debugfs.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2019 Spreadtrum Communications Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ -#ifndef __SIPC_DEBUGFS_H -#define __SIPC_DEBUGFS_H - -int sbuf_init_debugfs(void *root); -int smsg_init_debugfs(void *root); -int sblock_init_debugfs(void *root); -int smem_init_debugfs(void *root); - -#ifdef CONFIG_SPRD_SIPC_ZERO_COPY_SIPX -int sipx_init_debugfs(void *root); -#endif - -#ifdef CONFIG_SPRD_SIPC_SWCNBLK -int swcnblk_init_debugfs(void *root); -#endif - -#if defined(CONFIG_SPRD_SIPC_SMSGC) -int smsgc_init_debugfs(void *root); -#endif - -#ifdef CONFIG_SPRD_MAILBOX -int mbox_init_debugfs(void *root); -#endif -#endif /* !__SIPC_DEBUGFS_H */ - diff --git a/quectel_SRPD_PCIE/src/sipc/sipc_priv.h b/quectel_SRPD_PCIE/src/sipc/sipc_priv.h deleted file mode 100644 index 0702faf..0000000 --- a/quectel_SRPD_PCIE/src/sipc/sipc_priv.h +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (C) 2019 Spreadtrum Communications Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef __SIPC_PRIV_H -#define __SIPC_PRIV_H -#include -#include -#include - -#include "../include/sprd_mpm.h" -#ifdef CONFIG_SPRD_MAILBOX -#include -#endif - -#ifdef CONFIG_SPRD_PCIE_EP_DEVICE -#include "../include/sprd_pcie_ep_device.h" -#endif - -#ifdef CONFIG_PCIE_EPF_SPRD -#include -#endif - -#ifdef CONFIG_PCI -#include "../include/sprd_pcie_resource.h" -#endif - -#include "../include/sipc_big_to_little.h" - -#ifndef SZ_1K -#define SZ_1K 0x00000400 -#define SZ_4K 0x00001000 -#endif - -enum { - SIPC_BASE_MBOX = 0, - SIPC_BASE_PCIE, - SIPC_BASE_IPI, - SIPC_BASE_NR -}; - -enum smem_type { - SMEM_LOCAL = 0, - SMEM_PCIE -}; - -extern struct smsg_ipc *smsg_ipcs[]; -#define SMSG_CACHE_NR 256 - -struct smsg_channel { - /* wait queue for recv-buffer */ - wait_queue_head_t rxwait; - struct mutex rxlock; - struct sprd_pms *tx_pms; - struct sprd_pms *rx_pms; - char tx_name[16]; - char rx_name[16]; - - /* cached msgs for recv */ - uintptr_t wrptr[1]; - uintptr_t rdptr[1]; - struct smsg caches[SMSG_CACHE_NR]; -}; - -/* smsg ring-buffer between AP/CP ipc */ -struct smsg_ipc { - const char *name; - struct sprd_pms *sipc_pms; - - u8 dst; - u8 client; /* sipc is client mode */ - /* target core_id over mailbox */ - u8 core_id; - u8 core_sensor_id; - u32 type; /* sipc type, mbox, ipi, pcie */ - - void __iomem *write_addr; - -#ifdef CONFIG_SPRD_PCIE_EP_DEVICE - u32 ep_dev; - struct platform_device *pcie_dev; -#endif -#ifdef CONFIG_PCIE_EPF_SPRD - u32 ep_fun; -#endif - u32 latency; - - /* send-buffer info */ - uintptr_t txbuf_addr; - u32 txbuf_size; /* must be 2^n */ - uintptr_t txbuf_rdptr; - uintptr_t txbuf_wrptr; - - /* recv-buffer info */ - uintptr_t rxbuf_addr; - u32 rxbuf_size; /* must be 2^n */ - uintptr_t rxbuf_rdptr; - uintptr_t rxbuf_wrptr; - - /* sipc irq related */ - int irq; - u32 (*rxirq_status)(u8 id); - void (*rxirq_clear)(u8 id); - void (*txirq_trigger)(u8 id, u64 msg); - - u32 ring_base; - u32 ring_size; - void *smem_vbase; - u32 smem_base; - u32 smem_size; - enum smem_type smem_type; - u32 dst_smem_base; -#ifdef CONFIG_PHYS_ADDR_T_64BIT - u32 high_offset; -#endif - /* lock for send-buffer */ - spinlock_t txpinlock; - /* all fixed channels receivers */ - struct smsg_channel *channels[SMSG_VALID_CH_NR]; - /* record the runtime status of smsg channel */ - atomic_t busy[SMSG_VALID_CH_NR]; - /* all channel states: 0 unused, 1 be opened by other core, 2 opend */ - u8 states[SMSG_VALID_CH_NR]; -}; - -#define CHAN_STATE_UNUSED 0 -#define CHAN_STATE_CLIENT_OPENED 1 -#define CHAN_STATE_HOST_OPENED 2 -#define CHAN_STATE_OPENED 3 -#define CHAN_STATE_FREE 4 - -void smsg_init_channel2index(void); -void smsg_ipc_create(struct smsg_ipc *ipc); -void smsg_ipc_destroy(struct smsg_ipc *ipc); - -/*smem alloc size align*/ -#define SMEM_ALIGN_POOLSZ 0x40000 /*256KB*/ - -#ifdef CONFIG_64BIT -#define SMEM_ALIGN_BYTES 8 -#define SMEM_MIN_ORDER 3 -#else -#define SMEM_ALIGN_BYTES 4 -#define SMEM_MIN_ORDER 2 -#endif - -/* initialize smem pool for AP/CP */ -int smem_init(u32 addr, u32 size, u32 dst, u32 mem_type); -void sbuf_get_status(u8 dst, char *status_info, int size); - -#if defined(CONFIG_DEBUG_FS) -void sipc_debug_putline(struct seq_file *m, char c, int n); -#endif - -#ifdef CONFIG_SPRD_MAILBOX -#define MBOX_INVALID_CORE 0xff -#endif - -/* sipc_smem_request_resource - * local smem no need request resource, just return 0. - */ -static inline int sipc_smem_request_resource(struct sprd_pms *pms, - u8 dst, int timeout) -{ - if (smsg_ipcs[dst]->smem_type == SMEM_LOCAL) - return 0; - - return sprd_pms_request_resource(pms, timeout); -} - -/* sipc_smem_release_resource - * local smem no need release resource, do nothing. - */ -static inline void sipc_smem_release_resource(struct sprd_pms *pms, u8 dst) -{ - if (smsg_ipcs[dst]->smem_type != SMEM_LOCAL) - sprd_pms_release_resource(pms); -} -#endif diff --git a/quectel_SRPD_PCIE/src/sipc/smem.c b/quectel_SRPD_PCIE/src/sipc/smem.c deleted file mode 100644 index 12640c2..0000000 --- a/quectel_SRPD_PCIE/src/sipc/smem.c +++ /dev/null @@ -1,559 +0,0 @@ -/* - * Copyright (C) 2019 Spreadtrum Communications Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../include/sipc.h" -#include "sipc_priv.h" -#define CONFIG_SPRD_IPA_PCIE_WORKROUND -/* - * workround: Due to orca ipa hardware limitations - * the sipc share memory must map from - * 0x2x0000000(orca side) to 0xx0000000(roc1 - * side), and the size must be 256M - */ -#ifdef CONFIG_SPRD_IPA_PCIE_WORKROUND -#define IPA_GET_SRC_BASE(addr) (((addr) & 0xf0000000) + 0x200000000) -#define IPA_GET_DST_BASE(addr) ((addr) & 0xf0000000) -#define IPA_SIZE 0x10000000 -#endif - -struct smem_phead { - struct list_head smem_phead; - spinlock_t lock; - u32 poolnum; -}; - -struct smem_pool { - struct list_head smem_head; - struct list_head smem_plist; - spinlock_t lock; - - void *pcie_base; - u32 addr; - u32 size; - u32 dst; - u32 mem_type; - - atomic_t used; - struct gen_pool *gen; -}; - -struct smem_record { - struct list_head smem_list; - struct task_struct *task; - u32 size; - u32 addr; -}; - -struct smem_map_list { - struct list_head map_head; - spinlock_t lock; - u32 inited; -}; - -struct smem_map { - struct list_head map_list; - struct task_struct *task; - const void *mem; - unsigned int count; -}; - -static struct smem_phead sipc_smem_phead; -static struct smem_map_list mem_mp; - -static struct smem_pool *shmem_find_pool(u8 dst) -{ - struct smem_phead *phead = &sipc_smem_phead; - struct smem_pool *spool = NULL; - struct smem_pool *pos; - unsigned long flags; - - /* The num of one pool is 0, means the poll is not ready */ - if (!phead->poolnum) - return NULL; - - spin_lock_irqsave(&phead->lock, flags); - list_for_each_entry(pos, &phead->smem_phead, smem_plist) { - if (pos->dst == dst) { - spool = pos; - break; - } - } - spin_unlock_irqrestore(&phead->lock, flags); - return spool; -} - -static void *soc_modem_ram_vmap(phys_addr_t start, size_t size, int noncached) -{ - struct page **pages; - phys_addr_t page_start; - unsigned int page_count; - pgprot_t prot; - unsigned int i; - void *vaddr; - phys_addr_t addr; - unsigned long flags; - struct smem_map *map; - struct smem_map_list *smem = &mem_mp; - - map = kzalloc(sizeof(struct smem_map), GFP_KERNEL); - if (!map) - return NULL; - - page_start = start - offset_in_page(start); - page_count = DIV_ROUND_UP(size + offset_in_page(start), PAGE_SIZE); - if (noncached) - prot = pgprot_noncached(PAGE_KERNEL); - else - prot = PAGE_KERNEL; - - pages = kmalloc_array(page_count, sizeof(struct page *), GFP_KERNEL); - if (!pages) { - kfree(map); - return NULL; - } - - for (i = 0; i < page_count; i++) { - addr = page_start + i * PAGE_SIZE; - pages[i] = pfn_to_page(addr >> PAGE_SHIFT); - } - -#if (LINUX_VERSION_CODE < KERNEL_VERSION( 5,10,0 )) - vaddr = vm_map_ram(pages, page_count, -1, prot); -#else - vaddr = vmap(pages, page_count, -1, prot); - //vaddr = vm_map_ram(pages, page_count, -1); -#endif - - kfree(pages); - - if (!vaddr) { - pr_err("smem: vm map failed.\n"); - kfree(map); - return NULL; - } - - vaddr += offset_in_page(start); - map->count = page_count; - map->mem = vaddr; - map->task = current; - - if (smem->inited) { - spin_lock_irqsave(&smem->lock, flags); - list_add_tail(&map->map_list, &smem->map_head); - spin_unlock_irqrestore(&smem->lock, flags); - } - return vaddr; -} - -static void *pcie_modem_ram_vmap(phys_addr_t start, size_t size, int noncached) -{ - if (noncached == 0) { - pr_err("%s: cache not support!\n", __func__); - return NULL; - } - -#ifdef CONFIG_SPRD_PCIE_EP_DEVICE - return sprd_ep_map_memory(PCIE_EP_MODEM, start, size); -#endif - -#ifdef CONFIG_PCIE_EPF_SPRD - return sprd_pci_epf_map_memory(SPRD_FUNCTION_0, start, size); -#endif - - return NULL; -} - -static void pcie_modem_ram_unmap(const void *mem) -{ -#ifdef CONFIG_SPRD_PCIE_EP_DEVICE - return sprd_ep_unmap_memory(PCIE_EP_MODEM, mem); -#endif - -#ifdef CONFIG_PCIE_EPF_SPRD - return sprd_pci_epf_unmap_memory(SPRD_FUNCTION_0, mem); -#endif -} - -static void soc_modem_ram_unmap(const void *mem) -{ - struct smem_map *map, *next; - unsigned long flags; - struct smem_map_list *smem = &mem_mp; - bool found = false; - - if (smem->inited) { - spin_lock_irqsave(&smem->lock, flags); - list_for_each_entry_safe(map, next, &smem->map_head, map_list) { - if (map->mem == mem) { - list_del(&map->map_list); - found = true; - break; - } - } - spin_unlock_irqrestore(&smem->lock, flags); - - if (found) { - vm_unmap_ram(mem - offset_in_page(mem), map->count); - kfree(map); - } - } -} - -static void *shmem_ram_vmap(u8 dst, phys_addr_t start, - size_t size, - int noncached) -{ - struct smem_pool *spool; - - spool = shmem_find_pool(dst); - if (spool == NULL) { - pr_err("%s: pool dst %d is not existed!\n", __func__, dst); - return NULL; - } - - if (spool->mem_type == SMEM_PCIE) { - if (start < spool->addr - || start + size > spool->addr + spool->size) { - pr_info("%s: error, start = 0x%lx, size = 0x%lx.\n", - __func__, - (unsigned long)start, - (unsigned long)size); - return NULL; - } - - pr_info("%s: succ, start = 0x%lx, size = 0x%lx.\n", - __func__, (unsigned long)start, (unsigned long)size); - return (spool->pcie_base + start - spool->addr); - } - - return soc_modem_ram_vmap(start, size, noncached); - -} - -int smem_init(u32 addr, u32 size, u32 dst, u32 mem_type) -{ - struct smem_phead *phead = &sipc_smem_phead; - struct smem_map_list *smem = &mem_mp; - struct smem_pool *spool; - unsigned long flags; - - /* fisrt init, create the pool head */ - if (!phead->poolnum) { - spin_lock_init(&phead->lock); - INIT_LIST_HEAD(&phead->smem_phead); - } - - if (shmem_find_pool(dst)) - return 0; - - spool = kzalloc(sizeof(struct smem_pool), GFP_KERNEL); - if (!spool) - return -1; - - spin_lock_irqsave(&phead->lock, flags); - list_add_tail(&spool->smem_plist, &phead->smem_phead); - phead->poolnum++; - spin_unlock_irqrestore(&phead->lock, flags); - - spool->addr = addr; - spool->dst = dst; - spool->mem_type = mem_type; - - if (size >= SMEM_ALIGN_POOLSZ) - size = PAGE_ALIGN(size); - else - size = ALIGN(size, SMEM_ALIGN_BYTES); - - spool->size = size; - atomic_set(&spool->used, 0); - spin_lock_init(&spool->lock); - INIT_LIST_HEAD(&spool->smem_head); - - spin_lock_init(&smem->lock); - INIT_LIST_HEAD(&smem->map_head); - smem->inited = 1; - - /* allocator block size is times of pages */ - if (spool->size >= SMEM_ALIGN_POOLSZ) - spool->gen = gen_pool_create(PAGE_SHIFT, -1); - else - spool->gen = gen_pool_create(SMEM_MIN_ORDER, -1); - - if (!spool->gen) { - pr_err("Failed to create smem gen pool!\n"); - return -1; - } - - if (gen_pool_add(spool->gen, spool->addr, spool->size, -1) != 0) { - pr_err("Failed to add smem gen pool!\n"); - return -1; - } - pr_info("%s: pool addr = 0x%x, size = 0x%x added.\n", - __func__, spool->addr, spool->size); - - if (mem_type == SMEM_PCIE) { -#ifdef CONFIG_SPRD_IPA_PCIE_WORKROUND -#ifdef CONFIG_PCIE_EPF_SPRD - spool->pcie_base = sprd_epf_ipa_map(IPA_GET_SRC_BASE(addr), - IPA_GET_DST_BASE(addr), - IPA_SIZE); - if (!spool->pcie_base) - return -ENOMEM; - - spool->pcie_base += (addr - IPA_GET_DST_BASE(addr)); -#else - pr_err("Failed to pcie map, can't run here!\n"); - return -ENOMEM; -#endif -#else - spool->pcie_base = pcie_modem_ram_vmap(addr, size, 1); -#endif - } - return 0; -} - -/* ****************************************************************** */ - -int smem_get_area(u8 dst, u32 *base, u32 *size) -{ - struct smem_pool *spool; - - if (!base || !size) - return -EINVAL; - - spool = shmem_find_pool(dst); - if (!spool) { - pr_err("%s: err, dst = %d!\n", __func__, dst); - return -EINVAL; - } - - pr_info("%s: addr = 0x%x, size = 0x%x.\n", - __func__, spool->addr, spool->size); - - *base = spool->addr; - *size = spool->size; - - return 0; -} -EXPORT_SYMBOL_GPL(smem_get_area); - -u32 smem_alloc(u8 dst, u32 size) -{ - struct smem_pool *spool; - struct smem_record *recd; - unsigned long flags; - u32 addr = 0; - - spool = shmem_find_pool(dst); - if (spool == NULL) { - pr_err("%s: pool dst %d is not existed!\n", __func__, dst); - return 0; - } - - recd = kzalloc(sizeof(struct smem_record), GFP_KERNEL); - if (!recd) - return 0; - - if (spool->size >= SMEM_ALIGN_POOLSZ) - size = PAGE_ALIGN(size); - else - size = ALIGN(size, SMEM_ALIGN_BYTES); - - addr = gen_pool_alloc(spool->gen, size); - if (!addr) { - pr_err("%s:pool dst=%d, size=0x%x failed to alloc smem!\n", - __func__, dst, size); - kfree(recd); - return 0; - } - - /* record smem alloc info */ - atomic_add(size, &spool->used); - recd->size = size; - recd->task = current; - recd->addr = addr; - spin_lock_irqsave(&spool->lock, flags); - list_add_tail(&recd->smem_list, &spool->smem_head); - spin_unlock_irqrestore(&spool->lock, flags); - - return addr; -} -EXPORT_SYMBOL_GPL(smem_alloc); - -void smem_free(u8 dst, u32 addr, u32 size) -{ - struct smem_pool *spool; - struct smem_record *recd, *next; - unsigned long flags; - - spool = shmem_find_pool(dst); - if (spool == NULL) { - pr_err("%s: pool dst %d is not existed!\n", __func__, dst); - return; - } - - if (size >= SMEM_ALIGN_POOLSZ) - size = PAGE_ALIGN(size); - else - size = ALIGN(size, SMEM_ALIGN_BYTES); - - atomic_sub(size, &spool->used); - gen_pool_free(spool->gen, addr, size); - /* delete record node from list */ - spin_lock_irqsave(&spool->lock, flags); - list_for_each_entry_safe(recd, next, &spool->smem_head, smem_list) { - if (recd->addr == addr) { - list_del(&recd->smem_list); - kfree(recd); - break; - } - } - spin_unlock_irqrestore(&spool->lock, flags); -} -EXPORT_SYMBOL_GPL(smem_free); - -void *shmem_ram_vmap_nocache(u8 dst, phys_addr_t start, size_t size) -{ - return shmem_ram_vmap(dst, start, size, 1); -} -EXPORT_SYMBOL_GPL(shmem_ram_vmap_nocache); - - -void *shmem_ram_vmap_cache(u8 dst, phys_addr_t start, size_t size) -{ - return shmem_ram_vmap(dst, start, size, 0); -} -EXPORT_SYMBOL_GPL(shmem_ram_vmap_cache); - -void shmem_ram_unmap(u8 dst, const void *mem) -{ - struct smem_pool *spool; - - spool = shmem_find_pool(dst); - if (spool == NULL) { - pr_err("%s: pool dst %d is not existed!\n", __func__, dst); - return; - } - - if (spool->mem_type == SMEM_PCIE) - /* do nothing, because it also do nothing in shmem_ram_vmap */ - return; - else - return soc_modem_ram_unmap(mem); -} -EXPORT_SYMBOL_GPL(shmem_ram_unmap); - -void *modem_ram_vmap_nocache(u32 modem_type, phys_addr_t start, size_t size) -{ - if (modem_type == PCIE_MODEM) - return pcie_modem_ram_vmap(start, size, 1); - else - return soc_modem_ram_vmap(start, size, 1); -} -EXPORT_SYMBOL_GPL(modem_ram_vmap_nocache); - - -void *modem_ram_vmap_cache(u32 modem_type, phys_addr_t start, size_t size) -{ - if (modem_type == PCIE_MODEM) - return pcie_modem_ram_vmap(start, size, 0); - else - return soc_modem_ram_vmap(start, size, 0); -} -EXPORT_SYMBOL_GPL(modem_ram_vmap_cache); - -void modem_ram_unmap(u32 modem_type, const void *mem) -{ - if (modem_type == PCIE_MODEM) - return pcie_modem_ram_unmap(mem); - else - return soc_modem_ram_unmap(mem); -} -EXPORT_SYMBOL_GPL(modem_ram_unmap); - -#ifdef CONFIG_DEBUG_FS -static int smem_debug_show(struct seq_file *m, void *private) -{ - struct smem_phead *phead = &sipc_smem_phead; - struct smem_pool *spool, *pos; - struct smem_record *recd; - u32 fsize; - unsigned long flags; - u32 cnt = 1; - - spin_lock_irqsave(&phead->lock, flags); - list_for_each_entry(pos, &phead->smem_phead, smem_plist) { - spool = pos; - fsize = gen_pool_avail(spool->gen); - - sipc_debug_putline(m, '*', 80); - seq_printf(m, "%d, dst:%d, name: %s, smem pool info:\n", - cnt++, spool->dst, - (smsg_ipcs[spool->dst])->name); - seq_printf(m, "phys_addr=0x%x, total=0x%x, used=0x%x, free=0x%x\n", - spool->addr, spool->size, spool->used.counter, fsize); - seq_puts(m, "smem record list:\n"); - - list_for_each_entry(recd, &spool->smem_head, smem_list) { - seq_printf(m, "task %s: pid=%u, addr=0x%x, size=0x%x\n", - recd->task->comm, - recd->task->pid, - recd->addr, - recd->size); - } - } - spin_unlock_irqrestore(&phead->lock, flags); - return 0; -} - -static int smem_debug_open(struct inode *inode, struct file *file) -{ - return single_open(file, smem_debug_show, inode->i_private); -} - -static const struct file_operations smem_debug_fops = { - .open = smem_debug_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -int smem_init_debugfs(void *root) -{ - if (!root) - return -ENXIO; - debugfs_create_file("smem", 0444, - (struct dentry *)root, NULL, - &smem_debug_fops); - return 0; -} -EXPORT_SYMBOL_GPL(smem_init_debugfs); - -#endif /* endof CONFIG_DEBUG_FS */ - - -MODULE_AUTHOR("Chen Gaopeng"); -MODULE_DESCRIPTION("SIPC/SMEM driver"); -MODULE_LICENSE("GPL v2"); diff --git a/quectel_SRPD_PCIE/src/sipc/smsg.c b/quectel_SRPD_PCIE/src/sipc/smsg.c deleted file mode 100644 index 051800d..0000000 --- a/quectel_SRPD_PCIE/src/sipc/smsg.c +++ /dev/null @@ -1,1103 +0,0 @@ -/* - * Copyright (C) 2019 Spreadtrum Communications Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef CONFIG_SPRD_MAILBOX -#include -#endif - -#include "../include/sipc.h" -#include "sipc_priv.h" -#include "../include/sprd_pcie_resource.h" - -#if defined(CONFIG_DEBUG_FS) -#include "sipc_debugfs.h" -#endif - -#define SMSG_TXBUF_ADDR (0) -#define SMSG_TXBUF_SIZE (SZ_1K) -#define SMSG_RXBUF_ADDR (SMSG_TXBUF_SIZE) -#define SMSG_RXBUF_SIZE (SZ_1K) - -#define SMSG_RINGHDR (SMSG_TXBUF_SIZE + SMSG_RXBUF_SIZE) -#define SMSG_TXBUF_RDPTR (SMSG_RINGHDR + 0) -#define SMSG_TXBUF_WRPTR (SMSG_RINGHDR + 4) -#define SMSG_RXBUF_RDPTR (SMSG_RINGHDR + 8) -#define SMSG_RXBUF_WRPTR (SMSG_RINGHDR + 12) - -#define SMSG_RESERVE_BASE (SMSG_RINGHDR + SZ_1K) -#define SMSG_PCIE_WRPTR (SMSG_RESERVE_BASE + 0) -#define SMSG_PCIE_IRQPTR (SMSG_RESERVE_BASE + 4) - -#define SIPC_READL(addr) readl((__force void __iomem *)(addr)) -#define SIPC_WRITEL(b, addr) writel(b, (__force void __iomem *)(addr)) - -static u8 g_wakeup_flag; - -struct smsg_ipc *smsg_ipcs[SIPC_ID_NR]; -EXPORT_SYMBOL_GPL(smsg_ipcs); - -static ushort debug_enable; - -module_param_named(debug_enable, debug_enable, ushort, 0644); -static u8 channel2index[SMSG_CH_NR + 1]; - -static int smsg_ipc_smem_init(struct smsg_ipc *ipc); - -void smsg_init_channel2index(void) -{ - u16 i, j; - - for (i = 0; i < ARRAY_SIZE(channel2index); i++) { - for (j = 0; j < SMSG_VALID_CH_NR; j++) { - /* find the index of channel i */ - if (sipc_cfg[j].channel == i) - break; - } - - /* if not find, init with INVALID_CHANEL_INDEX, - * else init whith j - */ - if (j == SMSG_VALID_CH_NR) - channel2index[i] = INVALID_CHANEL_INDEX; - else - channel2index[i] = j; - } -} - -static void get_channel_status(u8 dst, char *status, int size) -{ - int i, len; - struct smsg_channel *ch; - - len = strlen(status); - for (i = 0; i < SMSG_VALID_CH_NR && len < size; i++) { - ch = smsg_ipcs[dst]->channels[i]; - if (!ch) - continue; - if (SIPC_READL(ch->rdptr) < SIPC_READL(ch->wrptr)) - snprintf( - status + len, - size - len, - "dst-%d-ch-%d: rd = %u, wr = %u.\n", - dst, - i, - SIPC_READL(ch->rdptr), - SIPC_READL(ch->wrptr) - ); - } -} - -static void smsg_wakeup_print(struct smsg_ipc *ipc, struct smsg *msg) -{ - /* if the first msg come after the irq wake up by sipc, - * use prin_fo to output log - */ - if (g_wakeup_flag) { - g_wakeup_flag = 0; - pr_info("irq read smsg: dst=%d, channel=%d,type=%d, flag=0x%04x, value=0x%08x\n", - ipc->dst, - msg->channel, - msg->type, - msg->flag, - msg->value); - } else { - pr_debug("irq read smsg: dst=%d, channel=%d,type=%d, flag=0x%04x, value=0x%08x\n", - ipc->dst, - msg->channel, - msg->type, - msg->flag, - msg->value); - } -} - -static void smsg_die_process(struct smsg_ipc *ipc, struct smsg *msg) -{ - if (msg->type == SMSG_TYPE_DIE) { - if (debug_enable) { - char sipc_status[100] = {0}; - - get_channel_status(ipc->dst, - sipc_status, - sizeof(sipc_status)); - sbuf_get_status(ipc->dst, - sipc_status, - sizeof(sipc_status)); - panic("cpcrash: %s", sipc_status); - while (1) - ; - } - } -} - -static void smsg_msg_process(struct smsg_ipc *ipc, - struct smsg *msg, bool wake_lock) -{ - struct smsg_channel *ch = NULL; - u32 wr; - u8 ch_index; - - smsg_wakeup_print(ipc, msg); - smsg_die_process(ipc, msg); - - ch_index = channel2index[msg->channel]; - atomic_inc(&ipc->busy[ch_index]); - - pr_debug("smsg:get dst=%d msg channel=%d, type=%d, flag=0x%04x, value=0x%08x\n", - ipc->dst, msg->channel, - msg->type, msg->flag, - msg->value); - - if (msg->type >= SMSG_TYPE_NR) { - /* invalid msg */ - pr_err("invalid smsg: channel=%d, type=%d, flag=0x%04x, value=0x%08x\n", - msg->channel, msg->type, msg->flag, msg->value); - goto exit_msg_proc; - } - - ch = ipc->channels[ch_index]; - if (!ch) { - if (ipc->states[ch_index] == CHAN_STATE_UNUSED && - msg->type == SMSG_TYPE_OPEN && - msg->flag == SMSG_OPEN_MAGIC) - ipc->states[ch_index] = CHAN_STATE_CLIENT_OPENED; - else - /* drop this bad msg since channel - * is not opened - */ - pr_info("smsg channel %d not opened! drop smsg: type=%d, flag=0x%04x, value=0x%08x\n", - msg->channel, msg->type, - msg->flag, msg->value); - - goto exit_msg_proc; - } - - if ((int)(SIPC_READL(ch->wrptr) - SIPC_READL(ch->rdptr)) >= - SMSG_CACHE_NR) { - /* msg cache is full, drop this msg */ - pr_info("smsg channel %d recv cache is full! drop smsg: type=%d, flag=0x%04x, value=0x%08x\n", - msg->channel, msg->type, msg->flag, msg->value); - } else { - /* write smsg to cache */ - wr = SIPC_READL(ch->wrptr) & (SMSG_CACHE_NR - 1); - memcpy(&ch->caches[wr], msg, sizeof(struct smsg)); - SIPC_WRITEL(SIPC_READL(ch->wrptr) + 1, ch->wrptr); - } - - wake_up_interruptible_all(&ch->rxwait); - - if (wake_lock) - sprd_pms_request_wakelock_period(ch->rx_pms, 500); - -exit_msg_proc: - atomic_dec(&ipc->busy[ch_index]); -} - -#ifdef CONFIG_SPRD_MAILBOX -static irqreturn_t smsg_mbox_irq_handler(void *ptr, void *private) -{ - struct smsg_ipc *ipc = (struct smsg_ipc *)private; - struct smsg *msg; - - msg = ptr; - smsg_msg_process(ipc, msg, true); - - return IRQ_HANDLED; -} - -static irqreturn_t smsg_mbox_sensor_irq_handler(void *ptr, void *private) -{ - struct smsg_ipc *ipc = (struct smsg_ipc *)private; - struct smsg *msg; - - msg = ptr; - smsg_msg_process(ipc, msg, false); - - return IRQ_HANDLED; -} - -#endif - -static int sipc_process_all_msg(struct smsg_ipc *ipc) -{ - struct smsg *msg; - struct smsg msg_recv; - uintptr_t rxpos; - - /* msg coming, means resource ok, don't wait */ - sipc_smem_request_resource(ipc->sipc_pms, ipc->dst, 0); - - while (BL_READL(ipc->rxbuf_wrptr) != BL_READL(ipc->rxbuf_rdptr)) { - rxpos = (BL_READL(ipc->rxbuf_rdptr) & (ipc->rxbuf_size - 1)) * - sizeof(struct smsg) + ipc->rxbuf_addr; - msg = (struct smsg *)rxpos; - - /* share memory smsg to ipc msg */ - msg_recv.channel = msg->channel; - msg_recv.type = msg->type; - msg_recv.flag = BL_GETW(msg->flag); - msg_recv.value= BL_GETL(msg->value); - smsg_msg_process(ipc, &msg_recv, true); - /* update smsg rdptr */ - BL_WRITEL(BL_READL(ipc->rxbuf_rdptr) + 1, ipc->rxbuf_rdptr); - } - - sipc_smem_release_resource(ipc->sipc_pms, ipc->dst); - - return 0; -} - - -static irqreturn_t smsg_irq_handler(int irq, void *private) -{ - struct smsg_ipc *ipc = (struct smsg_ipc *)private; - - if (ipc->rxirq_status(ipc->dst)) - ipc->rxirq_clear(ipc->dst); - - sipc_process_all_msg(ipc); - - return IRQ_HANDLED; -} - -static void smsg_ipc_init_smsg_irq_callback(struct smsg_ipc *ipc) -{ -#ifdef CONFIG_SPRD_MAILBOX - if (ipc->type == SIPC_BASE_MBOX) { - mbox_register_irq_handle(ipc->core_id, - smsg_mbox_irq_handler, ipc); - - if ((ipc->dst == SIPC_ID_PM_SYS) && - (ipc->core_sensor_id != MBOX_INVALID_CORE)) - mbox_register_irq_handle(ipc->core_sensor_id, - smsg_mbox_sensor_irq_handler, - ipc); - return; - } -#endif - -#ifdef CONFIG_SPRD_PCIE_EP_DEVICE - if (ipc->type == SIPC_BASE_PCIE) { - sprd_ep_dev_register_irq_handler(ipc->ep_dev, - PCIE_MSI_SIPC_IRQ, - smsg_irq_handler, ipc); - sprd_ep_dev_set_irq_addr(ipc->ep_dev, ipc->write_addr + 4); - return; - } -#endif - -#ifdef CONFIG_PCIE_EPF_SPRD - if (ipc->type == SIPC_BASE_PCIE) { - sprd_pci_epf_register_irq_handler(ipc->ep_fun, - PCIE_DBELL_SIPC_IRQ, - smsg_irq_handler, - ipc); - sprd_pci_epf_set_write_addr(ipc->ep_fun, ipc->write_addr); - return; - } -#endif - - if (ipc->type == SIPC_BASE_IPI) { - int ret; - - /* explicitly call irq handler in case of missing irq on boot */ - smsg_irq_handler(ipc->irq, ipc); - - /* register IPI irq */ - ret = request_irq(ipc->irq, - smsg_irq_handler, - IRQF_NO_SUSPEND, - ipc->name, - ipc); - if (ret) - pr_info("%s: request irq err = %d!\n", ipc->name, ret); - } -} - -static int smsg_ipc_smem_init(struct smsg_ipc *ipc) -{ - void __iomem *base, *p; - phys_addr_t offset = 0; - int ret; - - pr_debug("%s: %s, smem_type = %d!\n", - __func__, ipc->name, ipc->smem_type); - - ret = smem_init(ipc->smem_base, ipc->smem_size, - ipc->dst, ipc->smem_type); - if (ret) { - pr_err("%s: %s err = %d!\n", __func__, ipc->name, ret); - return ret; - } - - if (ipc->type != SIPC_BASE_MBOX) { - ipc->ring_base = smem_alloc(ipc->dst, SZ_4K); - ipc->ring_size = SZ_4K; - pr_info("%s: ring_base = 0x%x, ring_size = 0x%x\n", - __func__, - ipc->ring_base, - ipc->ring_size); - } - -#ifdef CONFIG_PHYS_ADDR_T_64BIT - offset = ipc->high_offset; - offset = offset << 32; -#endif - - if (ipc->ring_base) { - base = (void __iomem *)shmem_ram_vmap_nocache(ipc->dst, - ipc->ring_base + offset, - ipc->ring_size); - if (!base) { - pr_err("%s: ioremap failed!\n", __func__); - smem_free(ipc->dst, ipc->ring_base, SZ_4K); - ipc->ring_base = 0; - return -ENOMEM; - } - - /* assume client is boot later than host */ - if (!ipc->client) { - /** - * memset(base, 0, ipc->ring_size); - * the instruction dc avz - * will abort for nocache memory - */ - for (p = base; p < base + ipc->ring_size;) { -#ifdef CONFIG_64BIT - *(uint64_t *)p = 0x0; - p += sizeof(uint64_t); -#else - *(u32 *)p = 0x0; - p += sizeof(u32); -#endif - } - } - - if (ipc->client) { - /* clent mode, tx is host rx , rx is host tx*/ - ipc->smem_vbase = (void *)base; - ipc->txbuf_size = SMSG_RXBUF_SIZE / - sizeof(struct smsg); - ipc->txbuf_addr = (uintptr_t)base + - SMSG_RXBUF_ADDR; - ipc->txbuf_rdptr = (uintptr_t)base + - SMSG_RXBUF_RDPTR; - ipc->txbuf_wrptr = (uintptr_t)base + - SMSG_RXBUF_WRPTR; - ipc->rxbuf_size = SMSG_TXBUF_SIZE / - sizeof(struct smsg); - ipc->rxbuf_addr = (uintptr_t)base + - SMSG_TXBUF_ADDR; - ipc->rxbuf_rdptr = (uintptr_t)base + - SMSG_TXBUF_RDPTR; - ipc->rxbuf_wrptr = (uintptr_t)base + - SMSG_TXBUF_WRPTR; - } else { - ipc->smem_vbase = (void *)base; - ipc->txbuf_size = SMSG_TXBUF_SIZE / - sizeof(struct smsg); - ipc->txbuf_addr = (uintptr_t)base + - SMSG_TXBUF_ADDR; - ipc->txbuf_rdptr = (uintptr_t)base + - SMSG_TXBUF_RDPTR; - ipc->txbuf_wrptr = (uintptr_t)base + - SMSG_TXBUF_WRPTR; - ipc->rxbuf_size = SMSG_RXBUF_SIZE / - sizeof(struct smsg); - ipc->rxbuf_addr = (uintptr_t)base + - SMSG_RXBUF_ADDR; - ipc->rxbuf_rdptr = (uintptr_t)base + - SMSG_RXBUF_RDPTR; - ipc->rxbuf_wrptr = (uintptr_t)base + - SMSG_RXBUF_WRPTR; - } - ipc->write_addr = base + SMSG_PCIE_WRPTR; - } - - /* after smem_init complete, regist msg irq */ - smsg_ipc_init_smsg_irq_callback(ipc); - - return 0; -} - -#ifdef CONFIG_PCIE_EPF_SPRD -static void smsg_pcie_first_ready(void *data) -{ - struct smsg_ipc *ipc = (struct smsg_ipc *)data; - - if (ipc->smem_type == SMEM_PCIE) - smsg_ipc_smem_init(ipc); - else - pr_err("%s: pcie first ready, smem_type =%d!\n", - ipc->name, ipc->smem_type); -} -#endif - -static void smsg_ipc_mpm_init(struct smsg_ipc *ipc) -{ - /* create modem power manger instance for this sipc */ - sprd_mpm_create(ipc->dst, ipc->name, ipc->latency); - - /* init a power manager source */ - ipc->sipc_pms = sprd_pms_create(ipc->dst, ipc->name, true); - if (!ipc->sipc_pms) - pr_warn("create pms %s failed!\n", ipc->name); - - if (ipc->type == SIPC_BASE_PCIE) { - /* int mpm resource ops */ - sprd_mpm_init_resource_ops(ipc->dst, - sprd_pcie_wait_resource, - sprd_pcie_request_resource, - sprd_pcie_release_resource); - -#ifdef CONFIG_SPRD_PCIE_EP_DEVICE - /* in pcie host side, init pcie host resource */ - sprd_pcie_resource_host_init(ipc->dst, - ipc->ep_dev, ipc->pcie_dev); -#endif - -#ifdef CONFIG_PCIE_EPF_SPRD - /* in pcie ep side, init pcie client resource */ - sprd_pcie_resource_client_init(ipc->dst, ipc->ep_fun); -#endif - } -} - -void smsg_ipc_create(struct smsg_ipc *ipc) -{ - pr_info("%s: %s\n", __func__, ipc->name); - - smsg_ipcs[ipc->dst] = ipc; - - smsg_ipc_mpm_init(ipc); - - - if (ipc->type == SIPC_BASE_PCIE) { -#ifdef CONFIG_PCIE_EPF_SPRD - /* set epf door bell irq number */ - sprd_pci_epf_set_irq_number(ipc->ep_fun, ipc->irq); - - /* register first pcie ready notify */ - sprd_register_pcie_resource_first_ready(ipc->dst, - smsg_pcie_first_ready, - ipc); -#endif - } - - /* if SMEM_PCIE, must init after pcie ready */ - if (ipc->smem_type != SMEM_PCIE) - smsg_ipc_smem_init(ipc); -} - -void smsg_ipc_destroy(struct smsg_ipc *ipc) -{ - shmem_ram_unmap(ipc->dst, ipc->smem_vbase); - smem_free(ipc->dst, ipc->ring_base, SZ_4K); - -#ifdef CONFIG_SPRD_MAILBOX - if (ipc->type == SIPC_BASE_MBOX) { - mbox_unregister_irq_handle(ipc->core_id); - - if ((ipc->dst == SIPC_ID_PM_SYS) && - (ipc->core_sensor_id != MBOX_INVALID_CORE)) - mbox_unregister_irq_handle(ipc->core_sensor_id); - } -#endif - - if (ipc->type == SIPC_BASE_PCIE) { -#ifdef CONFIG_SPRD_PCIE_EP_DEVICE - sprd_ep_dev_unregister_irq_handler(ipc->ep_dev, ipc->irq); -#endif - -#ifdef CONFIG_PCIE_EPF_SPRD - sprd_pci_epf_unregister_irq_handler(ipc->ep_fun, ipc->irq); -#endif - sprd_pcie_resource_trash(ipc->dst); - } else { - free_irq(ipc->irq, ipc); - } - - smsg_ipcs[ipc->dst] = NULL; -} - -int sipc_get_wakeup_flag(void) -{ - return (int)g_wakeup_flag; -} -EXPORT_SYMBOL_GPL(sipc_get_wakeup_flag); - -void sipc_set_wakeup_flag(void) -{ - g_wakeup_flag = 1; -} -EXPORT_SYMBOL_GPL(sipc_set_wakeup_flag); - -void sipc_clear_wakeup_flag(void) -{ - g_wakeup_flag = 0; -} -EXPORT_SYMBOL_GPL(sipc_clear_wakeup_flag); - -int smsg_ch_wake_unlock(u8 dst, u8 channel) -{ - struct smsg_ipc *ipc = smsg_ipcs[dst]; - struct smsg_channel *ch; - u8 ch_index; - - ch_index = channel2index[channel]; - if (ch_index == INVALID_CHANEL_INDEX) { - pr_err("%s:channel %d invalid!\n", __func__, channel); - return -EINVAL; - } - - if (!ipc) - return -ENODEV; - - ch = ipc->channels[ch_index]; - if (!ch) - return -ENODEV; - - sprd_pms_release_wakelock(ch->rx_pms); - return 0; -} -EXPORT_SYMBOL_GPL(smsg_ch_wake_unlock); - -int smsg_ch_open(u8 dst, u8 channel, int timeout) -{ - struct smsg_ipc *ipc = smsg_ipcs[dst]; - struct smsg_channel *ch; - struct smsg mopen; - struct smsg mrecv; - int rval = 0; - u8 ch_index; - - ch_index = channel2index[channel]; - if (ch_index == INVALID_CHANEL_INDEX) { - pr_err("%s:channel %d invalid!\n", __func__, channel); - return -EINVAL; - } - - if (!ipc) - return -ENODEV; - - ch = kzalloc(sizeof(*ch), GFP_KERNEL); - if (!ch) - return -ENOMEM; - - sprintf(ch->tx_name, "smsg-%d-%d-tx", dst, channel); - ch->tx_pms = sprd_pms_create(dst, ch->tx_name, true); - if (!ch->tx_pms) - pr_warn("create pms %s failed!\n", ch->tx_name); - - sprintf(ch->rx_name, "smsg-%d-%d-rx", dst, channel); - ch->rx_pms = sprd_pms_create(dst, ch->rx_name, true); - if (!ch->rx_pms) - pr_warn("create pms %s failed!\n", ch->rx_name); - - atomic_set(&ipc->busy[ch_index], 1); - init_waitqueue_head(&ch->rxwait); - mutex_init(&ch->rxlock); - ipc->channels[ch_index] = ch; - - pr_info("%s: channel %d-%d send open msg!\n", - __func__, dst, channel); - - smsg_set(&mopen, channel, SMSG_TYPE_OPEN, SMSG_OPEN_MAGIC, 0); - rval = smsg_send(dst, &mopen, timeout); - if (rval != 0) { - pr_err("%s: channel %d-%d send open msg error = %d!\n", - __func__, dst, channel, rval); - ipc->states[ch_index] = CHAN_STATE_UNUSED; - ipc->channels[ch_index] = NULL; - atomic_dec(&ipc->busy[ch_index]); - /* guarantee that channel resource isn't used in irq handler */ - while (atomic_read(&ipc->busy[ch_index])) - ; - - kfree(ch); - - return rval; - } - - /* open msg might be got before */ - if (ipc->states[ch_index] == CHAN_STATE_CLIENT_OPENED) - goto open_done; - - ipc->states[ch_index] = CHAN_STATE_HOST_OPENED; - - do { - smsg_set(&mrecv, channel, 0, 0, 0); - rval = smsg_recv(dst, &mrecv, timeout); - if (rval != 0) { - pr_err("%s: channel %d-%d smsg receive error = %d!\n", - __func__, dst, channel, rval); - ipc->states[ch_index] = CHAN_STATE_UNUSED; - ipc->channels[ch_index] = NULL; - atomic_dec(&ipc->busy[ch_index]); - /* guarantee that channel resource isn't used - * in irq handler - */ - while (atomic_read(&ipc->busy[ch_index])) - ; - - kfree(ch); - return rval; - } - } while (mrecv.type != SMSG_TYPE_OPEN || mrecv.flag != SMSG_OPEN_MAGIC); - - pr_info("%s: channel %d-%d receive open msg!\n", - __func__, dst, channel); - -open_done: - pr_info("%s: channel %d-%d success\n", __func__, dst, channel); - ipc->states[ch_index] = CHAN_STATE_OPENED; - atomic_dec(&ipc->busy[ch_index]); - - return 0; -} -EXPORT_SYMBOL_GPL(smsg_ch_open); - -int smsg_ch_close(u8 dst, u8 channel, int timeout) -{ - struct smsg_ipc *ipc = smsg_ipcs[dst]; - struct smsg_channel *ch; - struct smsg mclose; - u8 ch_index; - - ch_index = channel2index[channel]; - if (ch_index == INVALID_CHANEL_INDEX) { - pr_err("%s:channel %d invalid!\n", __func__, channel); - return -EINVAL; - } - - ch = ipc->channels[ch_index]; - if (!ch) - return 0; - - smsg_set(&mclose, channel, SMSG_TYPE_CLOSE, SMSG_CLOSE_MAGIC, 0); - smsg_send(dst, &mclose, timeout); - - ipc->states[ch_index] = CHAN_STATE_FREE; - wake_up_interruptible_all(&ch->rxwait); - - /* wait for the channel being unused */ - while (atomic_read(&ipc->busy[ch_index])) - ; - - /* maybe channel has been free for smsg_ch_open failed */ - if (ipc->channels[ch_index]) { - ipc->channels[ch_index] = NULL; - /* guarantee that channel resource isn't used in irq handler */ - while (atomic_read(&ipc->busy[ch_index])) - ; - sprd_pms_destroy(ch->rx_pms); - sprd_pms_destroy(ch->tx_pms); - kfree(ch); - } - - /* finally, update the channel state*/ - ipc->states[ch_index] = CHAN_STATE_UNUSED; - - return 0; -} -EXPORT_SYMBOL_GPL(smsg_ch_close); - -static void smsg_bl_cpoy_msg(struct smsg *dst, struct smsg *src) -{ - dst->channel = src->channel; - dst->type = src->type; - BL_SETW(dst->flag, src->flag); - BL_SETL(dst->value, src->value); -} - -int smsg_senddie(u8 dst) -{ - struct smsg msg; - struct smsg_ipc *ipc = smsg_ipcs[dst]; - uintptr_t txpos; - int rval = 0; - - if (!ipc) - return -ENODEV; - - msg.channel = SMSG_CH_CTRL; - msg.type = SMSG_TYPE_DIE; - msg.flag = 0; - msg.value = 0; - -#ifdef CONFIG_SPRD_MAILBOX - if (ipc->type == SIPC_BASE_MBOX) { - mbox_just_sent(ipc->core_id, *((u64 *)&msg)); - return 0; - } -#endif - - if (ipc->ring_base) { - /* must wait resource before read or write share memory */ - rval = sprd_pms_request_resource(ipc->sipc_pms, 0); - if (rval < 0) - return rval; - - if (((int)(BL_READL(ipc->txbuf_wrptr) - - BL_READL(ipc->txbuf_rdptr)) >= - ipc->txbuf_size)) { - pr_info("%s: smsg txbuf is full!\n", __func__); - rval = -EBUSY; - } else { - /* calc txpos and write smsg */ - txpos = (BL_READL(ipc->txbuf_wrptr) & - (ipc->txbuf_size - 1)) * - sizeof(struct smsg) + ipc->txbuf_addr; - smsg_bl_cpoy_msg((void *)txpos, &msg); - - /* update wrptr */ - BL_WRITEL(BL_READL(ipc->txbuf_wrptr) + 1, - ipc->txbuf_wrptr); - } - ipc->txirq_trigger(ipc->dst, *((u64 *)&msg)); - sprd_pms_release_resource(ipc->sipc_pms); - } - - return rval; -} -EXPORT_SYMBOL_GPL(smsg_senddie); - -int smsg_send(u8 dst, struct smsg *msg, int timeout) -{ - struct smsg_ipc *ipc = smsg_ipcs[dst]; - struct smsg_channel *ch; - uintptr_t txpos; - int rval = 0; - unsigned long flags; - u8 ch_index; - - ch_index = channel2index[msg->channel]; - if (ch_index == INVALID_CHANEL_INDEX) { - pr_err("%s:channel %d invalid!\n", __func__, msg->channel); - return -EINVAL; - } - - if (!ipc) - return -ENODEV; - - if (!ipc->channels[ch_index]) { - pr_err("%s: channel %d not inited!\n", __func__, msg->channel); - return -ENODEV; - } - - if (ipc->states[ch_index] != CHAN_STATE_OPENED && - msg->type != SMSG_TYPE_OPEN && - msg->type != SMSG_TYPE_CLOSE) { - pr_err("%s: channel %d not opened!\n", __func__, msg->channel); - return -EINVAL; - } - - ch = ipc->channels[ch_index]; - - pr_debug("send smsg: channel=%d, type=%d, flag=0x%04x, value=0x%08x\n", - msg->channel, msg->type, msg->flag, msg->value); - - /* - * Must wait resource before read or write share memory, - * and must wait resource before trigger irq, - * And it must before if (ipc->ring_base), - * because it be inited as the same time as resource ready. - */ - rval = sprd_pms_request_resource(ch->tx_pms, timeout); - if (rval < 0) - return rval; - - if (ipc->ring_base) { - spin_lock_irqsave(&ipc->txpinlock, flags); - if (((int)(BL_READL(ipc->txbuf_wrptr) - - BL_READL(ipc->txbuf_rdptr)) >= - ipc->txbuf_size)) { - pr_err("write smsg: txbuf full, wrptr=0x%x, rdptr=0x%x\n", - BL_READL(ipc->txbuf_wrptr), - BL_READL(ipc->txbuf_rdptr)); - rval = -EBUSY; - } else { - /* calc txpos and write smsg */ - txpos = (BL_READL(ipc->txbuf_wrptr) & - (ipc->txbuf_size - 1)) * - sizeof(struct smsg) + ipc->txbuf_addr; - smsg_bl_cpoy_msg((void *)txpos, msg); - - /* update wrptr */ - BL_WRITEL(BL_READL(ipc->txbuf_wrptr) + 1, - ipc->txbuf_wrptr); - } - spin_unlock_irqrestore(&ipc->txpinlock, flags); - } else if (ipc->type != SIPC_BASE_MBOX) { - pr_err("send smsg:ring_base is NULL"); - sprd_pms_release_resource(ch->tx_pms); - return -EINVAL; - } - - ipc->txirq_trigger(ipc->dst, *(u64 *)msg); - sprd_pms_release_resource(ch->tx_pms); - - return rval; -} -EXPORT_SYMBOL_GPL(smsg_send); - -int smsg_recv(u8 dst, struct smsg *msg, int timeout) -{ - struct smsg_ipc *ipc = smsg_ipcs[dst]; - struct smsg_channel *ch; - u32 rd; - int rval = 0; - u8 ch_index; - - ch_index = channel2index[msg->channel]; - if (ch_index == INVALID_CHANEL_INDEX) { - pr_err("%s:channel %d invalid!\n", __func__, msg->channel); - return -EINVAL; - } - - if (!ipc) - return -ENODEV; - - atomic_inc(&ipc->busy[ch_index]); - - ch = ipc->channels[ch_index]; - - if (!ch) { - pr_err("%s: channel %d not opened!\n", __func__, msg->channel); - atomic_dec(&ipc->busy[ch_index]); - return -ENODEV; - } - - pr_debug("%s: dst=%d, channel=%d, timeout=%d, ch_index = %d\n", - __func__, dst, msg->channel, timeout, ch_index); - - if (timeout == 0) { - if (!mutex_trylock(&ch->rxlock)) { - pr_err("dst=%d, channel=%d recv smsg busy!\n", - dst, msg->channel); - atomic_dec(&ipc->busy[ch_index]); - - return -EBUSY; - } - - /* no wait */ - if (SIPC_READL(ch->wrptr) == SIPC_READL(ch->rdptr)) { - pr_info("dst=%d, channel=%d smsg rx cache is empty!\n", - dst, msg->channel); - - rval = -ENODATA; - - goto recv_failed; - } - } else if (timeout < 0) { - mutex_lock_interruptible(&ch->rxlock); - /* wait forever */ - rval = wait_event_interruptible( - ch->rxwait, - (SIPC_READL(ch->wrptr) != - SIPC_READL(ch->rdptr)) || - (ipc->states[ch_index] == CHAN_STATE_FREE)); - if (rval < 0) { - pr_debug("%s: dst=%d, channel=%d wait interrupted!\n", - __func__, dst, msg->channel); - - goto recv_failed; - } - - if (ipc->states[ch_index] == CHAN_STATE_FREE) { - pr_info("%s: dst=%d, channel=%d channel is free!\n", - __func__, dst, msg->channel); - - rval = -EIO; - - goto recv_failed; - } - } else { - mutex_lock_interruptible(&ch->rxlock); - /* wait timeout */ - rval = wait_event_interruptible_timeout( - ch->rxwait, - (SIPC_READL(ch->wrptr) != SIPC_READL(ch->rdptr)) || - (ipc->states[ch_index] == CHAN_STATE_FREE), - timeout); - if (rval < 0) { - pr_debug("%s: dst=%d, channel=%d wait interrupted!\n", - __func__, dst, msg->channel); - - goto recv_failed; - } else if (rval == 0) { - pr_debug("%s: dst=%d, channel=%d wait timeout!\n", - __func__, dst, msg->channel); - - rval = -ETIME; - - goto recv_failed; - } - - if (ipc->states[ch_index] == CHAN_STATE_FREE) { - pr_info("%s: dst=%d, channel=%d channel is free!\n", - __func__, dst, msg->channel); - - rval = -EIO; - - goto recv_failed; - } - } - - /* read smsg from cache */ - rd = SIPC_READL(ch->rdptr) & (SMSG_CACHE_NR - 1); - memcpy(msg, &ch->caches[rd], sizeof(struct smsg)); - SIPC_WRITEL(SIPC_READL(ch->rdptr) + 1, ch->rdptr); - - if (ipc->ring_base) - pr_debug("read smsg: dst=%d, channel=%d, wrptr=%d, rdptr=%d, rd=%d\n", - dst, - msg->channel, - SIPC_READL(ch->wrptr), - SIPC_READL(ch->rdptr), - rd); - - pr_debug("recv smsg: dst=%d, channel=%d, type=%d, flag=0x%04x, value=0x%08x, rval = %d\n", - dst, msg->channel, msg->type, msg->flag, msg->value, rval); - -recv_failed: - mutex_unlock(&ch->rxlock); - atomic_dec(&ipc->busy[ch_index]); - return rval; -} -EXPORT_SYMBOL_GPL(smsg_recv); - -u8 sipc_channel2index(u8 channel) -{ - return channel2index[channel]; -} -EXPORT_SYMBOL_GPL(sipc_channel2index); - -#if defined(CONFIG_DEBUG_FS) -static int smsg_debug_show(struct seq_file *m, void *private) -{ - struct smsg_ipc *ipc = NULL; - struct smsg_channel *ch; - - int i, j, cnt; - - for (i = 0; i < SIPC_ID_NR; i++) { - ipc = smsg_ipcs[i]; - if (!ipc) - continue; - - sipc_debug_putline(m, '*', 120); - seq_printf(m, "sipc: %s:\n", ipc->name); - seq_printf(m, "dst: 0x%0x, irq: 0x%0x\n", - ipc->dst, ipc->irq); - if (ipc->ring_base) { - /* - * must wait resource before - * read or write share memory. - */ - if (sipc_smem_request_resource(ipc->sipc_pms, - ipc->dst, 1000) < 0) - continue; - - seq_printf(m, "txbufAddr: 0x%p, txbufsize: 0x%x, txbufrdptr: [0x%p]=%d, txbufwrptr: [0x%p]=%d\n", - (void *)ipc->txbuf_addr, - ipc->txbuf_size, - (void *)ipc->txbuf_rdptr, - BL_READL(ipc->txbuf_rdptr), - (void *)ipc->txbuf_wrptr, - BL_READL(ipc->txbuf_wrptr)); - seq_printf(m, "rxbufAddr: 0x%p, rxbufsize: 0x%x, rxbufrdptr: [0x%p]=%d, rxbufwrptr: [0x%p]=%d\n", - (void *)ipc->rxbuf_addr, - ipc->rxbuf_size, - (void *)ipc->rxbuf_rdptr, - BL_READL(ipc->rxbuf_rdptr), - (void *)ipc->rxbuf_wrptr, - BL_READL(ipc->rxbuf_wrptr)); - - /* release resource */ - sipc_smem_release_resource(ipc->sipc_pms, ipc->dst); - } - sipc_debug_putline(m, '-', 80); - seq_puts(m, "1. all channel state list:\n"); - - for (j = 0; j < SMSG_VALID_CH_NR; j++) - seq_printf(m, - "%2d. channel[%3d] states: %d, name: %s\n", - j, - sipc_cfg[j].channel, - ipc->states[j], - sipc_cfg[j].name); - - sipc_debug_putline(m, '-', 80); - seq_puts(m, "2. channel rdpt < wrpt list:\n"); - - cnt = 1; - for (j = 0; j < SMSG_VALID_CH_NR; j++) { - ch = ipc->channels[j]; - if (!ch) - continue; - - if (SIPC_READL(ch->rdptr) < SIPC_READL(ch->wrptr)) - seq_printf(m, "%2d. channel[%3d] rd: %d, wt: %d, name: %s\n", - cnt++, - sipc_cfg[j].channel, - SIPC_READL(ch->rdptr), - SIPC_READL(ch->wrptr), - sipc_cfg[j].name); - } - } - return 0; -} - -static int smsg_debug_open(struct inode *inode, struct file *file) -{ - return single_open(file, smsg_debug_show, inode->i_private); -} - -static const struct file_operations smsg_debug_fops = { - .open = smsg_debug_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -int smsg_init_debugfs(void *root) -{ - if (!root) - return -ENXIO; - debugfs_create_file("smsg", 0444, - (struct dentry *)root, - NULL, - &smsg_debug_fops); - return 0; -} -EXPORT_SYMBOL_GPL(smsg_init_debugfs); - -#endif /* CONFIG_DEBUG_FS */ - - -MODULE_AUTHOR("Chen Gaopeng"); -MODULE_DESCRIPTION("SIPC/SMSG driver"); -MODULE_LICENSE("GPL v2"); diff --git a/quectel_SRPD_PCIE/src/sipc/spipe.c b/quectel_SRPD_PCIE/src/sipc/spipe.c deleted file mode 100644 index 7fbd7bc..0000000 --- a/quectel_SRPD_PCIE/src/sipc/spipe.c +++ /dev/null @@ -1,480 +0,0 @@ -/* - * Copyright (C) 2018 Spreadtrum Communications Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "../include/sipc.h" -#include "sipc_priv.h" -#include "spipe.h" - -#define SPIPE_NR_BASE_NUM MKDEV(254, 0) -#define SDIAG_NR_BASE_NUM MKDEV(253, 0) -#define STTY_NR_BASE_NUM MKDEV(252, 0) -#define SNV_NR_BASE_NUM MKDEV(251, 0) - -struct spipe_device { - struct spipe_init_data *init; - int major; - int minor; - struct cdev cdev; -}; - -struct spipe_sbuf { - u8 dst; - u8 channel; - u32 bufid; -}; - -static struct class *spipe_class; - -static int spipe_open(struct inode *inode, struct file *filp) -{ - int minor = iminor(filp->f_path.dentry->d_inode); - struct spipe_device *spipe; - struct spipe_sbuf *sbuf; - - spipe = container_of(inode->i_cdev, struct spipe_device, cdev); - if (sbuf_status(spipe->init->dst, spipe->init->channel) != 0) { - printk("spipe %d-%d not ready to open!\n", - spipe->init->dst, spipe->init->channel); - filp->private_data = NULL; - return -ENODEV; - } - - sbuf = kmalloc(sizeof(struct spipe_sbuf), GFP_KERNEL); - if (!sbuf) - return -ENOMEM; - filp->private_data = sbuf; - - sbuf->dst = spipe->init->dst; - sbuf->channel = spipe->init->channel; - sbuf->bufid = minor - spipe->minor; - - return 0; -} - -static int spipe_release(struct inode *inode, struct file *filp) -{ - struct spipe_sbuf *sbuf = filp->private_data; - - kfree(sbuf); - - return 0; -} - -static ssize_t spipe_read(struct file *filp, - char __user *buf, size_t count, loff_t *ppos) -{ - struct spipe_sbuf *sbuf = filp->private_data; - int timeout = -1; - - if (filp->f_flags & O_NONBLOCK) - timeout = 0; - - return sbuf_read(sbuf->dst, sbuf->channel, sbuf->bufid, - (void *)buf, count, timeout); -} - -static ssize_t spipe_write(struct file *filp, - const char __user *buf, size_t count, loff_t *ppos) -{ - struct spipe_sbuf *sbuf = filp->private_data; - int timeout = -1; - - if (filp->f_flags & O_NONBLOCK) - timeout = 0; - - return sbuf_write(sbuf->dst, sbuf->channel, sbuf->bufid, - (void *)buf, count, timeout); -} - -static unsigned int spipe_poll(struct file *filp, poll_table *wait) -{ - struct spipe_sbuf *sbuf = filp->private_data; - - return sbuf_poll_wait(sbuf->dst, sbuf->channel, sbuf->bufid, - filp, wait); -} - -static long spipe_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) -{ - return 0; -} - -static const struct file_operations spipe_fops = { - .open = spipe_open, - .release = spipe_release, - .read = spipe_read, - .write = spipe_write, - .poll = spipe_poll, - .unlocked_ioctl = spipe_ioctl, - .owner = THIS_MODULE, - .llseek = default_llseek, -}; - -#ifdef SPRD_PCIE_USE_DTS -static int spipe_parse_dt(struct spipe_init_data **init, - struct device_node *np, struct device *dev, dev_t *devid) -{ - struct spipe_init_data *pdata = NULL; - int ret; - u32 data; - - pdata = devm_kzalloc(dev, sizeof(struct spipe_init_data), GFP_KERNEL); - if (!pdata) - return -ENOMEM; - - ret = of_property_read_string(np, - "sprd,name", - (const char **)&pdata->name); - if (ret) - goto error; - - if (!strcmp(pdata->name, "spipe_nr")) - *devid = SPIPE_NR_BASE_NUM; - else if (!strcmp(pdata->name, "sdiag_nr")) - *devid = SDIAG_NR_BASE_NUM; - else if (!strcmp(pdata->name, "stty_nr")) - *devid = STTY_NR_BASE_NUM; - else if (!strcmp(pdata->name, "snv_nr")) - *devid = SNV_NR_BASE_NUM; - - ret = of_property_read_u32(np, "sprd,dst", (u32 *)&data); - if (ret) - goto error; - pdata->dst = (u8)data; - - ret = of_property_read_u32(np, "sprd,channel", (u32 *)&data); - if (ret) - goto error; - pdata->channel = (u8)data; - - ret = of_property_read_u32(np, - "sprd,ringnr", - (u32 *)&pdata->ringnr); - if (ret) - goto error; - - ret = of_property_read_u32(np, - "sprd,size-rxbuf", - (u32 *)&pdata->rxbuf_size); - if (ret) - goto error; - - ret = of_property_read_u32(np, - "sprd,size-txbuf", - (u32 *)&pdata->txbuf_size); - if (ret) - goto error; - - *init = pdata; - return ret; -error: - devm_kfree(dev, pdata); - *init = NULL; - return ret; -} -#else -static int spipe_parse_dt(struct spipe_init_data **init, - struct device_node *np, struct device *dev, dev_t *devid) -{ - struct spipe_init_data *pdata = *init; - - if (!strcmp(pdata->name, "spipe_nr")) - *devid = SPIPE_NR_BASE_NUM; - else if (!strcmp(pdata->name, "sdiag_nr")) - *devid = SDIAG_NR_BASE_NUM; - else if (!strcmp(pdata->name, "stty_nr")) - *devid = STTY_NR_BASE_NUM; - else if (!strcmp(pdata->name, "snv_nr")) - *devid = SNV_NR_BASE_NUM; - - return 0; -} -#endif - -static inline void spipe_destroy_pdata(struct spipe_init_data **init, - struct device *dev) -{ - *init = NULL; -} - -static int spipe_probe(struct platform_device *pdev) -{ - struct spipe_init_data *init = pdev->dev.platform_data; - struct spipe_device *spipe; - dev_t devid; - int i, rval; - struct device_node *np; - - printk("%s!\n", __func__); - - if (1) { - np = pdev->dev.of_node; - rval = spipe_parse_dt(&init, np, &pdev->dev, &devid); - if (rval) { - pr_err("Failed to parse spipe device tree, ret=%d\n", rval); - return rval; - } - - printk("spipe: after parse device tree, name=%s, dst=%u, channel=%u, ringnr=%u, rxbuf_size=0x%x, txbuf_size=0x%x\n", - init->name, - init->dst, - init->channel, - init->ringnr, - init->rxbuf_size, - init->txbuf_size); - - rval = sbuf_create(init->dst, init->channel, init->ringnr, - init->txbuf_size, init->rxbuf_size); - if (rval != 0) { - printk("Failed to create sbuf: %d\n", rval); - spipe_destroy_pdata(&init, &pdev->dev); - return rval; - } - - spipe = devm_kzalloc(&pdev->dev, - sizeof(struct spipe_device), - GFP_KERNEL); - if (spipe == NULL) { - sbuf_destroy(init->dst, init->channel); - spipe_destroy_pdata(&init, &pdev->dev); - printk("Failed to allocate spipe_device\n"); - return -ENOMEM; - } - - rval = alloc_chrdev_region(&devid, 0, init->ringnr, init->name); - //rval = register_chrdev_region(devid, init->ringnr, init->name); - if (rval != 0) { - sbuf_destroy(init->dst, init->channel); - devm_kfree(&pdev->dev, spipe); - spipe_destroy_pdata(&init, &pdev->dev); - printk("Failed to alloc spipe chrdev\n"); - return rval; - } - - cdev_init(&(spipe->cdev), &spipe_fops); - rval = cdev_add(&(spipe->cdev), devid, init->ringnr); - if (rval != 0) { - sbuf_destroy(init->dst, init->channel); - devm_kfree(&pdev->dev, spipe); - unregister_chrdev_region(devid, init->ringnr); - spipe_destroy_pdata(&init, &pdev->dev); - printk("Failed to add spipe cdev\n"); - return rval; - } - - spipe->major = MAJOR(devid); - spipe->minor = MINOR(devid); - if (init->ringnr > 1) { - for (i = 0; i < init->ringnr; i++) { - device_create(spipe_class, NULL, - MKDEV(spipe->major, spipe->minor + i), - NULL, "%s%d", init->name, i); - } - } else { - device_create(spipe_class, NULL, - MKDEV(spipe->major, spipe->minor), - NULL, "%s", init->name); - } - - spipe->init = init; - - platform_set_drvdata(pdev, spipe); - } - - return 0; -} - -static int spipe_remove(struct platform_device *pdev) -{ - struct spipe_device *spipe = platform_get_drvdata(pdev); - int i; - - if (spipe) { - for (i = 0; i < spipe->init->ringnr; i++) { - device_destroy(spipe_class, MKDEV(spipe->major, spipe->minor + i)); - } - cdev_del(&(spipe->cdev)); - unregister_chrdev_region(MKDEV(spipe->major, spipe->minor), spipe->init->ringnr); - - sbuf_destroy(spipe->init->dst, spipe->init->channel); - - spipe_destroy_pdata(&spipe->init, &pdev->dev); - - devm_kfree(&pdev->dev, spipe); - - platform_set_drvdata(pdev, NULL); - } - - return 0; -} - -#ifdef SPRD_PCIE_USE_DTS -static const struct of_device_id spipe_match_table[] = { - {.compatible = "sprd,spipe", }, - { }, -}; -#endif - -static struct platform_driver spipe_driver = { - .driver = { - .owner = THIS_MODULE, - .name = "spipe", -#ifdef SPRD_PCIE_USE_DTS - .of_match_table = spipe_match_table, -#endif - }, - .probe = spipe_probe, - .remove = spipe_remove, -}; - -static struct platform_device *spipe_pdev[MAX_SPIPE_CHN_NUM]; -static struct spipe_init_data spipe_data[MAX_SPIPE_CHN_NUM] = { - { - .sipc_name = SPIPE_DRVIER_NMAE, - .name = "spipe_nr", - .dst = 1, - .channel = 4, - .ringnr = 15, - .txbuf_size = 0x1000, - .rxbuf_size = 0x1000 - }, - { - .sipc_name = SPIPE_DRVIER_NMAE, - .name = "sdiag_nr", - .dst = 1, - .channel = 21, - .ringnr = 1, - .txbuf_size = 0x40000, - .rxbuf_size = 0x8000 - }, - { - .sipc_name = SPIPE_DRVIER_NMAE, - .name = "stty_nr", - .dst = 1, - .channel = 6, - .ringnr = 32, - .txbuf_size = 0x0800, - .rxbuf_size = 0x0800 - }, - { - .sipc_name = SPIPE_DRVIER_NMAE, - .name = "snv_nr", - .dst = 1, - .channel = 40, - .ringnr = 1, - .txbuf_size = 0x40400, - .rxbuf_size = 0x1000 - } - -}; - -static int spipe_platform_device_reigster(void) -{ - int retval = -ENOMEM; - int i; - - for(i = 0; i < MAX_SPIPE_CHN_NUM; i++) { - spipe_pdev[i] = platform_device_alloc(SPIPE_DRVIER_NMAE, i); - if (!spipe_pdev[i]) { - i--; - while (i >= 0) - platform_device_put(spipe_pdev[i--]); - return retval; - } - } - - for (i = 0; i < MAX_SPIPE_CHN_NUM; i++) { - retval = platform_device_add_data(spipe_pdev[i], &spipe_data[i], - sizeof(struct spipe_init_data)); - if (retval) - goto err_add_pdata; - } - - for (i = 0; i < MAX_SPIPE_CHN_NUM; i++) { - retval = platform_device_add(spipe_pdev[i]); - if (retval < 0) { - i--; - while (i >= 0) - platform_device_del(spipe_pdev[i]); - goto err_add_pdata; - } - } - - return retval; - -err_add_pdata: - for (i = 0; i < MAX_SPIPE_CHN_NUM; i++) - platform_device_put(spipe_pdev[i]); - return retval; -} - -static void spipe_platform_device_unreigster(void) -{ - int i; - for (i = 0; i < MAX_SPIPE_CHN_NUM; i++) { - platform_device_unregister(spipe_pdev[i]); - } -} - - -int spipe_init(void) -{ - int ret; - - spipe_class = class_create(THIS_MODULE, "spipe"); - if (IS_ERR(spipe_class)) - return PTR_ERR(spipe_class); -#ifndef SPRD_PCIE_USE_DTS - if((ret = spipe_platform_device_reigster())) - return ret; -#endif - - if((ret = platform_driver_register(&spipe_driver))) { -#ifndef SPRD_PCIE_USE_DTS - spipe_platform_device_unreigster(); -#endif - return ret; - } - return ret; -} -EXPORT_SYMBOL_GPL(spipe_init); - -void spipe_exit(void) -{ - platform_driver_unregister(&spipe_driver); -#ifndef SPRD_PCIE_USE_DTS - spipe_platform_device_unreigster(); -#endif - class_destroy(spipe_class); -} - -void spipe_device_down(void) -{ - int retval = -ENOMEM; - int i; - - for(i = 0; i < MAX_SPIPE_CHN_NUM; i++) { - sbuf_down(spipe_data[i].dst, spipe_data[i].channel); - } -} - -EXPORT_SYMBOL_GPL(spipe_exit); -EXPORT_SYMBOL_GPL(spipe_device_down); diff --git a/quectel_SRPD_PCIE/src/sipc/spipe.h b/quectel_SRPD_PCIE/src/sipc/spipe.h deleted file mode 100644 index eacca6c..0000000 --- a/quectel_SRPD_PCIE/src/sipc/spipe.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2019 Spreadtrum Communications Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef __SPIPE_H -#define __SPIPE_H - -#define MAX_SPIPE_CHN_NUM 4 -#define SPIPE_DRVIER_NMAE "spipe" - -struct spipe_init_data { - char *name; - char *sipc_name; - u8 dst; - u8 channel; - u32 ringnr; - u32 txbuf_size; - u32 rxbuf_size; -}; -#endif diff --git a/quectel_SRPD_PCIE/src/sipc/spool.c b/quectel_SRPD_PCIE/src/sipc/spool.c deleted file mode 100644 index 724dc96..0000000 --- a/quectel_SRPD_PCIE/src/sipc/spool.c +++ /dev/null @@ -1,538 +0,0 @@ -/* - * Copyright (C) 2018 Spreadtrum Communications Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "../include/sipc.h" -#include "spool.h" - -#define SLOG_NR_BASE_NUM MKDEV(156, 0) - -struct spool_device; - -struct spool_device { - struct spool_init_data *init; - int major; - int minor; - struct cdev cdev; - struct platform_device *plt_dev; - - struct device *sys_dev; /* Device object in sysfs */ -}; - -struct spool_sblock { - u8 dst; - u8 channel; - bool is_hold; - struct sblock hold; -}; - -static struct class *spool_class; - -static int spool_open(struct inode *inode, struct file *filp) -{ - struct spool_device *spool; - struct spool_sblock *sblock; - int ret; - - spool = container_of(inode->i_cdev, struct spool_device, cdev); - ret = sblock_query(spool->init->dst, spool->init->channel); - if (ret) - return ret; - sblock = kmalloc(sizeof(struct spool_sblock), GFP_KERNEL); - if (!sblock) - return -ENOMEM; - filp->private_data = sblock; - - sblock->dst = spool->init->dst; - sblock->channel = spool->init->channel; - sblock->is_hold = 0; - - return 0; -} - -static int spool_release(struct inode *inode, struct file *filp) -{ - struct spool_sblock *sblock = filp->private_data; - - if (sblock->is_hold) { - if (sblock_release(sblock->dst, sblock->channel, &sblock->hold)) - pr_debug("failed to release block!\n"); - } - kfree(sblock); - - return 0; -} - -static ssize_t spool_read(struct file *filp, - char __user *buf, size_t count, loff_t *ppos) -{ - struct spool_sblock *sblock = filp->private_data; - int timeout = -1; - int ret = 0; - int rdsize = 0; - struct sblock blk = {0}; - - if (filp->f_flags & O_NONBLOCK) - timeout = 0; - - if (sblock->is_hold) { - if (count < sblock->hold.length - *ppos) { - rdsize = count; - } else { - rdsize = sblock->hold.length - *ppos; - sblock->is_hold = 0; - } - blk = sblock->hold; - } else{ - *ppos = 0; - ret = sblock_receive(sblock->dst, - sblock->channel, &blk, timeout); - if (ret < 0) { - pr_debug("%s: failed to receive block!\n", __func__); - return ret; - } - if (blk.length <= count) - rdsize = blk.length; - else { - rdsize = count; - sblock->is_hold = 1; - sblock->hold = blk; - } - } - - if (unalign_copy_to_user(buf, blk.addr + *ppos, rdsize)) { - pr_err("%s: failed to copy to user!\n", __func__); - sblock->is_hold = 0; - *ppos = 0; - ret = -EFAULT; - } else { - ret = rdsize; - *ppos += rdsize; - } - - if (sblock->is_hold == 0) { - if (sblock_release(sblock->dst, sblock->channel, &blk)) - pr_err("%s: failed to release block!\n", __func__); - } - - return ret; -} - -static ssize_t spool_write(struct file *filp, - const char __user *buf, size_t count, loff_t *ppos) -{ - struct spool_sblock *sblock = filp->private_data; - int timeout = -1; - int ret = 0; - int wrsize = 0; - int pos = 0; - struct sblock blk = {0}; - size_t len = count; - - if (filp->f_flags & O_NONBLOCK) - timeout = 0; - - do { - ret = sblock_get(sblock->dst, sblock->channel, &blk, timeout); - if (ret < 0) { - pr_info("%s: failed to get block!\n", __func__); - return ret; - } - - wrsize = (blk.length > len ? len : blk.length); - if (unalign_copy_from_user(blk.addr, buf + pos, wrsize)) { - pr_info("%s: failed to copy from user!\n", __func__); - ret = -EFAULT; - } else { - blk.length = wrsize; - len -= wrsize; - pos += wrsize; - } - - if (sblock_send(sblock->dst, sblock->channel, &blk)) - pr_debug("%s: failed to send block!", __func__); - } while (len > 0 && ret == 0); - - return count - len; -} - -static unsigned int spool_poll(struct file *filp, poll_table *wait) -{ - struct spool_sblock *sblock = filp->private_data; - - return sblock_poll_wait(sblock->dst, sblock->channel, filp, wait); -} - -static long spool_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) -{ - return 0; -} - -static const struct file_operations spool_fops = { - .open = spool_open, - .release = spool_release, - .read = spool_read, - .write = spool_write, - .poll = spool_poll, - .unlocked_ioctl = spool_ioctl, - .owner = THIS_MODULE, - .llseek = default_llseek, -}; - -#ifdef SPRD_PCIE_USE_DTS -static int spool_parse_dt(struct spool_init_data **init, struct device *dev, - struct device_node *np, dev_t *dev_no) -{ - struct spool_init_data *pdata = NULL; - int ret; - u32 data; - - pdata = devm_kzalloc(dev, sizeof(struct spool_init_data), GFP_KERNEL); - if (!pdata) - return -ENOMEM; - - ret = of_property_read_string(np, "sprd,name", - (const char **)&pdata->name); - if (ret) - goto error; - - if (!strcmp(pdata->name, "slog_nr")) - *dev_no = SLOG_NR_BASE_NUM; - - ret = of_property_read_u32(np, "sprd,dst", (u32 *)&data); - if (ret) - goto error; - pdata->dst = (u8)data; - - ret = of_property_read_u32(np, "sprd,channel", (u32 *)&data); - if (ret) - goto error; - pdata->channel = (u8)data; - - ret = of_property_read_u32(np, "sprd,preconfigured", (u32 *)&data); - if (!ret) - pdata->pre_cfg = (int)data; - - ret = of_property_read_u32(np, "sprd,tx-blksize", - (u32 *)&pdata->txblocksize); - if (ret) - goto error; - ret = of_property_read_u32(np, "sprd,tx-blknum", - (u32 *)&pdata->txblocknum); - if (ret) - goto error; - ret = of_property_read_u32(np, "sprd,rx-blksize", - (u32 *)&pdata->rxblocksize); - if (ret) - goto error; - ret = of_property_read_u32(np, "sprd,rx-blknum", - (u32 *)&pdata->rxblocknum); - if (ret) - goto error; - - if (!of_property_read_u32(np, "sprd,nodev", (u32 *)&data)) - pdata->nodev = (u8)data; - - *init = pdata; - return ret; -error: - devm_kfree(dev, pdata); - *init = NULL; - return ret; -} -#else -static int spool_parse_dt(struct spool_init_data **init, struct device *dev, - struct device_node *np, dev_t *dev_no) -{ - struct spool_init_data *pdata = NULL; - - pdata = devm_kzalloc(dev, sizeof(struct spool_init_data), GFP_KERNEL); - if (!pdata) - return -ENOMEM; - pdata->name = "slog_nr"; - if (!strcmp(pdata->name, "slog_nr")) - *dev_no = SLOG_NR_BASE_NUM; - pdata->dst = 1; - pdata->channel = 5; - pdata->txblocksize = 0; - pdata->txblocknum = 0; - pdata->rxblocksize = 0x10000; - pdata->rxblocknum = 32; - *init = pdata; - - return 0; -} -#endif - - -static ssize_t base_addr_show(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct spool_device *spool = (struct spool_device *) - dev_get_drvdata(dev); - struct spool_init_data *init = spool->init; - uint32_t addr; - int ret; - - ret = sblock_get_smem_cp_addr(init->dst, init->channel, - &addr); - if (ret < 0) - return ret; - - return snprintf(buf, PAGE_SIZE, "%u %u 0x%08X %d %u %u %u %u\n", - (unsigned int)init->dst, - (unsigned int)init->channel, - addr, - init->pre_cfg, - (unsigned int)init->txblocknum, - (unsigned int)init->txblocksize, - (unsigned int)init->rxblocknum, - (unsigned int)init->rxblocksize); -} - -static DEVICE_ATTR(base_addr, 0440, - base_addr_show, NULL); - -static int create_spool(struct platform_device *pdev, - struct spool_init_data *init, - struct spool_device **out, dev_t dev_no) -{ - int rval; - struct spool_device *spool; - //dev_t dev_no; - char sp_name[16]; - - snprintf(sp_name, sizeof(sp_name), "spool-%u-%u", - (unsigned int)init->dst, - (unsigned int)init->channel); - //rval = alloc_chrdev_region(&dev_no, 0, 1, sp_name); - rval = register_chrdev_region(dev_no, 1, sp_name); - if (rval) - return rval; - - if (init->pre_cfg) - rval = sblock_pcfg_create(init->dst, - init->channel, - init->txblocknum, - init->txblocksize, - init->rxblocknum, - init->rxblocksize); - else - rval = sblock_create(init->dst, - init->channel, - init->txblocknum, - init->txblocksize, - init->rxblocknum, - init->rxblocksize); - if (rval) { - pr_info("Failed to create sblock: %d\n", rval); - goto free_devno; - } - - spool = devm_kzalloc(&pdev->dev, - sizeof(struct spool_device), - GFP_KERNEL); - if (!spool) { - pr_info("Failed to allocate spool_device\n"); - rval = -ENOMEM; - goto free_sblock; - } - - spool->init = init; - spool->major = MAJOR(dev_no); - spool->minor = MINOR(dev_no); - spool->plt_dev = pdev; - - if (!init->nodev) { - cdev_init(&spool->cdev, &spool_fops); - - rval = cdev_add(&spool->cdev, dev_no, 1); - if (rval) { - pr_info("Failed to add spool cdev\n"); - goto free_spool; - } - } - - spool->sys_dev = device_create(spool_class, NULL, - dev_no, - spool, "%s", init->name); - device_create_file(&pdev->dev, &dev_attr_base_addr); - - platform_set_drvdata(pdev, spool); - - *out = spool; - - return 0; - -free_spool: - devm_kfree(&pdev->dev, spool); - -free_sblock: - sblock_destroy(init->dst, init->channel); - -free_devno: - unregister_chrdev_region(dev_no, 1); - return rval; -} - -static int destroy_spool(struct spool_device *spool) -{ - dev_t dev_no = MKDEV(spool->major, spool->minor); - struct spool_init_data *init = spool->init; - - if (spool->sys_dev) { - device_destroy(spool_class, dev_no); - spool->sys_dev = NULL; - } - if (!init->nodev) - cdev_del(&spool->cdev); - sblock_destroy(init->dst, init->channel); - unregister_chrdev_region(dev_no, 1); - devm_kfree(&spool->plt_dev->dev, init); - devm_kfree(&spool->plt_dev->dev, spool); - - return 0; -} - -static int spool_probe(struct platform_device *pdev) -{ - struct device_node *np = pdev->dev.of_node; - int rval; - struct spool_init_data *init; - struct spool_device *spool; - dev_t dev_no; - -#ifdef SPRD_PCIE_USE_DTS - if (!np) - return -ENODEV; -#endif - - rval = spool_parse_dt(&init, &pdev->dev, np, &dev_no); - if (rval) { - pr_err("Failed to parse spool device tree, ret=%d\n", - rval); - return rval; - } - - pr_info("spool: name=%s, dst=%u, channel=%u, pre_cfg=%u\n", - init->name, - init->dst, - init->channel, - init->pre_cfg); - - pr_info("spool: tx_num=%u, tx_size=%u, rx_num=%u, rx_size=%u\n", - init->txblocknum, - init->txblocksize, - init->rxblocknum, - init->rxblocksize); - - rval = create_spool(pdev, init, &spool, dev_no); - if (rval) { - pr_err("Failed to create spool device %u:%u, ret=%d\n", - (unsigned int)init->dst, - (unsigned int)init->channel, rval); - devm_kfree(&pdev->dev, init); - } - - return 0; -} - -static int spool_remove(struct platform_device *pdev) -{ - struct spool_device *priv = (struct spool_device *) - platform_get_drvdata(pdev); - - destroy_spool(priv); - - platform_set_drvdata(pdev, NULL); - - return 0; -} - -#ifdef SPRD_PCIE_USE_DTS -static const struct of_device_id spool_match_table[] = { - { .compatible = "sprd,spool", }, - { }, -}; -#endif - -static struct platform_driver spool_driver = { - .driver = { - .owner = THIS_MODULE, - .name = "spool", -#ifdef SPRD_PCIE_USE_DTS - .of_match_table = spool_match_table, -#endif - }, - .probe = spool_probe, - .remove = spool_remove, -}; - -#ifndef SPRD_PCIE_USE_DTS -static void spool_platform_device_release(struct device *dev) {} -static struct platform_device spool_device = { - .name = "spool", - .id = -1, - .dev = { - .release = spool_platform_device_release, - } -}; -#endif - -int spool_init(void) -{ - int ret; - - spool_class = class_create(THIS_MODULE, "spool"); - if (IS_ERR(spool_class)) - return PTR_ERR(spool_class); -#ifndef SPRD_PCIE_USE_DTS - if((ret = platform_device_register(&spool_device))) - return ret; -#endif - if((ret = platform_driver_register(&spool_driver))) { -#ifndef SPRD_PCIE_USE_DTS - platform_device_unregister(&spool_device); -#endif - return ret; - } - - return ret; -} -EXPORT_SYMBOL_GPL(spool_init); - -void spool_exit(void) -{ - platform_driver_unregister(&spool_driver); -#ifndef SPRD_PCIE_USE_DTS - platform_device_unregister(&spool_device); -#endif - class_destroy(spool_class); -} - - -void spool_device_down(void) -{ - sblock_down(1, 5); -} - -EXPORT_SYMBOL_GPL(spool_exit); -EXPORT_SYMBOL_GPL(spool_device_down); diff --git a/quectel_SRPD_PCIE/src/sipc/spool.h b/quectel_SRPD_PCIE/src/sipc/spool.h deleted file mode 100644 index c0c5d2e..0000000 --- a/quectel_SRPD_PCIE/src/sipc/spool.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2019 Spreadtrum Communications Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef __SPOOL_H -#define __SPOOL_H - -struct spool_init_data { - char *name; - u8 dst; - u8 channel; - u8 nodev; - /* Preconfigured channel */ - int pre_cfg; - u32 txblocknum; - u32 txblocksize; - u32 rxblocknum; - u32 rxblocksize; -}; -#endif diff --git a/quectel_cm_5G/Makefile b/quectel_cm_5G/Makefile deleted file mode 100644 index 5eff117..0000000 --- a/quectel_cm_5G/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -include $(TOPDIR)/rules.mk - -PKG_NAME:= quectel-CM-5G -PKG_VERSION:=1.6.4 -PKG_RELEASE:=1 - -include $(INCLUDE_DIR)/package.mk - -define Package/quectel-CM-5G - SECTION:=utils - CATEGORY:=Utilities - TITLE:=quectel-CM-5G app -endef - -define Build/Prepare - mkdir -p $(PKG_BUILD_DIR) - $(CP) ./src/* $(PKG_BUILD_DIR)/ -endef - -define Build/Compile - $(MAKE) -C "$(PKG_BUILD_DIR)" \ - EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \ - CROSS_COMPILE="$(TARGET_CROSS)" \ - ARCH="$(LINUX_KARCH)" \ - M="$(PKG_BUILD_DIR)" \ - CC="$(TARGET_CC)" -endef - -define Package/quectel-CM-5G/install - $(INSTALL_DIR) $(1)/usr/bin $(1)/lib/netifd/proto - $(INSTALL_BIN) $(PKG_BUILD_DIR)/quectel-CM $(1)/usr/bin - $(INSTALL_BIN) ./files/rmnet_init.sh $(1)/lib/netifd - $(INSTALL_BIN) ./files/rmnet.script $(1)/lib/netifd - $(INSTALL_BIN) ./files/rmnet.sh $(1)/lib/netifd/proto - $(INSTALL_BIN) ./files/rmnet6.sh $(1)/lib/netifd/proto - $(INSTALL_BIN) ./files/rmnet6.script $(1)/lib/netifd -endef - -$(eval $(call BuildPackage,quectel-CM-5G)) diff --git a/quectel_cm_5G/files/dhcp b/quectel_cm_5G/files/dhcp deleted file mode 100644 index 7673927..0000000 --- a/quectel_cm_5G/files/dhcp +++ /dev/null @@ -1,48 +0,0 @@ - -config dnsmasq - option domainneeded '1' - option boguspriv '1' - option filterwin2k '0' - option localise_queries '1' - option rebind_protection '1' - option rebind_localhost '1' - option local '/lan/' - option domain 'lan' - option expandhosts '1' - option nonegcache '0' - option authoritative '1' - option readethers '1' - option leasefile '/tmp/dhcp.leases' - option resolvfile '/tmp/resolv.conf.auto' - option nonwildcard '1' - option localservice '1' - -config dhcp 'lan' - option interface 'lan' - option start '100' - option limit '150' - option leasetime '12h' - option ra 'relay' - option dhcpv6 'disabled' - option ndp 'relay' - -config dhcp 'wan' - option interface 'wan' - option ignore '1' - option ra 'relay' - option dhcpv6 'disabled' - option ndp 'relay' - option ndproxy_routing '0' - option master '1' - -config dhcp 'wan6' - option ra 'relay' - option dhcpv6 'disabled' - option ndp 'relay' - option ndproxy_routing '0' - option master '1' - option interface 'wan6' - -config odhcpd 'odhcpd' - option loglevel '7' - diff --git a/quectel_cm_5G/files/rmnet.script b/quectel_cm_5G/files/rmnet.script deleted file mode 100644 index 5bafb90..0000000 --- a/quectel_cm_5G/files/rmnet.script +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/sh -# Copyright (c) 2019 Qualcomm Technologies, Inc. -# All Rights Reserved. -# Confidential and Proprietary - Qualcomm Technologies, Inc. - - -[ -z "$1" ] && echo "Error: should be run by rmnet" && exit 1 -[ -z "$2" ] && echo "Error: should be run by rmnet" && exit 1 - -. /lib/functions.sh -. /lib/functions/network.sh -. /lib/netifd/netifd-proto.sh - -setup_interface() { - INTERFACE=$1 - CONFIG=/tmp/rmnet_$2_ipv4config - logger "rmnet setup_interface $1 $2 here" - #Fetch information from lower. - [ -f ${CONFIG} ] || { - proto_notify_error "$INTERFACE" "RMNET data call Not ready" - proto_block_restart "$INTERFACE" - return - } - . ${CONFIG} - ip=$PUBLIC_IP - DNS=$DNSSERVERS - router=$GATEWAY - subnet=$NETMASK - interface=$IFNAME - #Send the information to the netifd - proto_init_update "$interface" 1 1 - #ip and subnet - proto_add_ipv4_address "$ip" "${subnet:-255.255.255.0}" - - #Any router? if not, remove below scripts - #router format should be separated by space - for i in $router; do - proto_add_ipv4_route "$i" 32 "" "$ip" - proto_add_ipv4_route 0.0.0.0 0 "$i" "$ip" - done - - #dns information tell the netifd. - for dns in $DNS; do - proto_add_dns_server "$dns" - done - - #Domain information tell the netifd - for domain in $domain; do - proto_add_dns_search "$domain" - done - - #proto_add_data - [ -n "$ZONE" ] && json_add_string zone "$ZONE" - proto_close_data - - proto_send_update "$INTERFACE" - -} - -case "$1" in - renew) - setup_interface $2 $3 - ;; -esac - -exit 0 diff --git a/quectel_cm_5G/files/rmnet.sh b/quectel_cm_5G/files/rmnet.sh deleted file mode 100644 index 101ee60..0000000 --- a/quectel_cm_5G/files/rmnet.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -# Copyright (c) 2019 Qualcomm Technologies, Inc. -# All Rights Reserved. -# Confidential and Proprietary - Qualcomm Technologies, Inc. - -. /lib/functions.sh -. /lib/functions/network.sh -. ../netifd-proto.sh - -init_proto "$@" - -proto_rmnet_setup() { - local cfg="$1" - local iface="$2" - - logger "rmnet started" - #Call rmnet management script below!! - logger "rmnet updated ${cfg} ${iface}" - /lib/netifd/rmnet.script renew $cfg $iface -} - -proto_rmnet_teardown() { - local cfg="$1" - #Tear down rmnet manager script here.*/ -} - -proto_rmnet_init_config() { - #ddno_device=1 - available=1 -} - -add_protocol rmnet diff --git a/quectel_cm_5G/files/rmnet6.script b/quectel_cm_5G/files/rmnet6.script deleted file mode 100644 index bbe05b2..0000000 --- a/quectel_cm_5G/files/rmnet6.script +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/sh -# Copyright (c) 2019 Qualcomm Technologies, Inc. -# All Rights Reserved. -# Confidential and Proprietary - Qualcomm Technologies, Inc. - - -[ -z "$1" ] && echo "Error: should be run by rmnet" && exit 1 -[ -z "$2" ] && echo "Error: should be run by rmnet" && exit 1 - -. /lib/functions.sh -. /lib/functions/network.sh -. /lib/netifd/netifd-proto.sh - -setup_interface() { - INTERFACE=$1 - CONFIG=/tmp/rmnet_$2_ipv6config - logger "rmnet setup_interface $1 $2 here" - #Fetch information from lower. - [ -f ${CONFIG} ] || { - proto_notify_error "$INTERFACE" "RMNET data call NOT ready" - proto_block_restart "$INTERFACE" - return - } - . ${CONFIG} - ADDRESSES=$PUBLIC_IP - interface=$IFNAME - #Send the information to the netifd - proto_init_update "$interface" 1 1 - - #ip and subnet - proto_add_ipv6_address "${PUBLIC_IP}" "128" - proto_add_ipv6_prefix "${PUBLIC_IP}/${PrefixLength}" - - #router format should be separated by space - proto_add_ipv6_route "$GATEWAY" 128 - proto_add_ipv6_route "::0" 0 "$GATEWAY" "" "" "${PUBLIC_IP}/${PrefixLength}" - - #dns information tell the netifd. - for dns in $DNSSERVERS; do - proto_add_dns_server "$dns" - done - - #Domain information tell the netifd - for domain in $domain; do - proto_add_dns_search "$domain" - done - - #proto_add_data - [ -n "$ZONE" ] && json_add_string zone "$ZONE" - proto_close_data - - proto_send_update "$INTERFACE" -} - -case "$1" in - renew|bound) - setup_interface $2 $3 - ;; -esac - -exit 0 diff --git a/quectel_cm_5G/files/rmnet6.sh b/quectel_cm_5G/files/rmnet6.sh deleted file mode 100644 index 57a5495..0000000 --- a/quectel_cm_5G/files/rmnet6.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -# Copyright (c) 2019 Qualcomm Technologies, Inc. -# All Rights Reserved. -# Confidential and Proprietary - Qualcomm Technologies, Inc. - -. /lib/functions.sh -. /lib/functions/network.sh -. ../netifd-proto.sh - -init_proto "$@" - -proto_rmnet6_setup() { - local cfg="$1" - local iface="$2" - - logger "rmnet6 started" - #Call rmnet management script below!! - /lib/netifd/rmnet6.script renew $cfg $iface - logger "rmnet6 updated" -} - -proto_rmnet6_teardown() { - local cfg="$1" - #Tear down rmnet manager script here.*/ -} - -proto_rmnet6_init_config() { - #ddno_device=1 - available=1 -} - -add_protocol rmnet6 diff --git a/quectel_cm_5G/files/rmnet_init.sh b/quectel_cm_5G/files/rmnet_init.sh deleted file mode 100644 index 3d55438..0000000 --- a/quectel_cm_5G/files/rmnet_init.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh - -uci set network.wan='interface' -uci set network.wan.ifname='wwan0' -uci set network.wan.proto='rmnet' - -uci set network.wan6='interface' -uci set network.wan6.ifname='wwan0' -uci set network.wan6.proto='rmnet6' - -uci set dhcp.lan.ra='relay' -uci set dhcp.lan.dhcpv6='disabled' -uci set dhcp.lan.ndp='relay' - -uci set dhcp.wan.ra='relay' -uci set dhcp.wan.dhcpv6='disabled' -uci set dhcp.wan.ndp='relay' -uci set dhcp.wan.ndproxy_routing='0' - -uci set dhcp.wan6=dhcp -uci set dhcp.wan6.interface='wan6' -uci set dhcp.wan6.ra='relay' -uci set dhcp.wan6.dhcpv6='disabled' -uci set dhcp.wan6.ndp='relay' -uci set dhcp.wan6.ndproxy_routing='0' -uci set dhcp.wan6.master='1' - -uci set dhcp.odhcpd=odhcpd -uci set dhcp.odhcpd.loglevel='7' - -uci commit diff --git a/quectel_cm_5G/src/CMakeLists.txt b/quectel_cm_5G/src/CMakeLists.txt deleted file mode 100644 index 8ce3f5a..0000000 --- a/quectel_cm_5G/src/CMakeLists.txt +++ /dev/null @@ -1,36 +0,0 @@ -cmake_minimum_required(VERSION 2.4) - -project(quectel-CM) -add_definitions(-Wall -Wextra -Werror -O1) -option(USE_QRTR "Enable QRTR" OFF) - -set( QL_CM_SRC - QmiWwanCM.c GobiNetCM.c main.c MPQMUX.c QMIThread.c util.c qmap_bridge_mode.c mbim-cm.c device.c - atc.c atchannel.c at_tok.c - udhcpc.c - ) - -if(USE_QRTR) -add_definitions(-DCONFIG_QRTR) -set( QRTR_SRC qrtr.c rmnetctl.c) -endif() - -add_executable(quectel-CM ${QL_CM_SRC} ${QRTR_SRC}) -target_link_libraries(quectel-CM PUBLIC pthread) -install (TARGETS quectel-CM DESTINATION bin) - -add_executable(quectel-qmi-proxy quectel-qmi-proxy.c) -target_link_libraries(quectel-qmi-proxy PUBLIC pthread) -install (TARGETS quectel-qmi-proxy DESTINATION bin) - -add_executable(quectel-mbim-proxy quectel-mbim-proxy.c) -target_link_libraries(quectel-mbim-proxy PUBLIC pthread) -install (TARGETS quectel-mbim-proxy DESTINATION bin) - -add_executable(quectel-atc-proxy quectel-atc-proxy.c atchannel.c at_tok.c util.c) -target_link_libraries(quectel-atc-proxy PUBLIC pthread) -install (TARGETS quectel-atc-proxy DESTINATION bin) - -add_executable(quectel-qrtr-proxy quectel-qrtr-proxy.c) -target_link_libraries(quectel-qrtr-proxy PUBLIC pthread) -install (TARGETS quectel-qrtr-proxy DESTINATION bin) diff --git a/quectel_cm_5G/src/GobiNetCM.c b/quectel_cm_5G/src/GobiNetCM.c deleted file mode 100644 index a270fd8..0000000 --- a/quectel_cm_5G/src/GobiNetCM.c +++ /dev/null @@ -1,246 +0,0 @@ -/****************************************************************************** - @file GobiNetCM.c - @brief GobiNet driver. - - DESCRIPTION - Connectivity Management Tool for USB network adapter of Quectel wireless cellular modules. - - INITIALIZATION AND SEQUENCING REQUIREMENTS - None. - - --------------------------------------------------------------------------- - Copyright (c) 2016 - 2020 Quectel Wireless Solution, Co., Ltd. All Rights Reserved. - Quectel Wireless Solution Proprietary and Confidential. - --------------------------------------------------------------------------- -******************************************************************************/ -#include -#include -#include -#include -#include -#include "QMIThread.h" - -#ifdef CONFIG_GOBINET -static int qmiclientId[QMUX_TYPE_ALL]; - -// IOCTL to generate a client ID for this service type -#define IOCTL_QMI_GET_SERVICE_FILE 0x8BE0 + 1 - -// IOCTL to get the VIDPID of the device -#define IOCTL_QMI_GET_DEVICE_VIDPID 0x8BE0 + 2 - -// IOCTL to get the MEID of the device -#define IOCTL_QMI_GET_DEVICE_MEID 0x8BE0 + 3 - -static int GobiNetSendQMI(PQCQMIMSG pRequest) { - int ret, fd; - - fd = qmiclientId[pRequest->QMIHdr.QMIType]; - pRequest->QMIHdr.ClientId = (fd&0xFF) ? fd&0xFF : pRequest->QMIHdr.QMIType; - - if (fd <= 0) { - dbg_time("%s QMIType: %d has no clientID", __func__, pRequest->QMIHdr.QMIType); - return -ENODEV; - } - - // Always ready to write - if (1 == 1) { - ssize_t nwrites = le16_to_cpu(pRequest->QMIHdr.Length) + 1 - sizeof(QCQMI_HDR); - ret = write(fd, &pRequest->MUXMsg, nwrites); - if (ret == nwrites) { - ret = 0; - } else { - dbg_time("%s write=%d, errno: %d (%s)", __func__, ret, errno, strerror(errno)); - } - } else { - dbg_time("%s poll=%d, errno: %d (%s)", __func__, ret, errno, strerror(errno)); - } - - return ret; -} - -static int GobiNetGetClientID(const char *qcqmi, UCHAR QMIType) { - int ClientId; - ClientId = cm_open_dev(qcqmi); - if (ClientId == -1) { - dbg_time("failed to open %s, errno: %d (%s)", qcqmi, errno, strerror(errno)); - return -1; - } - - if (ioctl(ClientId, IOCTL_QMI_GET_SERVICE_FILE, QMIType) != 0) { - dbg_time("failed to get ClientID for 0x%02x errno: %d (%s)", QMIType, errno, strerror(errno)); - close(ClientId); - ClientId = 0; - } - - switch (QMIType) { - case QMUX_TYPE_WDS: dbg_time("Get clientWDS = %d", ClientId); break; - case QMUX_TYPE_DMS: dbg_time("Get clientDMS = %d", ClientId); break; - case QMUX_TYPE_NAS: dbg_time("Get clientNAS = %d", ClientId); break; - case QMUX_TYPE_QOS: dbg_time("Get clientQOS = %d", ClientId); break; - case QMUX_TYPE_WMS: dbg_time("Get clientWMS = %d", ClientId); break; - case QMUX_TYPE_PDS: dbg_time("Get clientPDS = %d", ClientId); break; - case QMUX_TYPE_UIM: dbg_time("Get clientUIM = %d", ClientId); break; - case QMUX_TYPE_COEX: dbg_time("Get clientCOEX = %d", ClientId); break; - case QMUX_TYPE_WDS_ADMIN: dbg_time("Get clientWDA = %d", ClientId); - break; - default: break; - } - - return ClientId; -} - -static int GobiNetDeInit(void) { - unsigned int i; - for (i = 0; i < sizeof(qmiclientId)/sizeof(qmiclientId[0]); i++) - { - if (qmiclientId[i] != 0) - { - close(qmiclientId[i]); - qmiclientId[i] = 0; - } - } - - return 0; -} - -static void * GobiNetThread(void *pData) { - PROFILE_T *profile = (PROFILE_T *)pData; - const char *qcqmi = (const char *)profile->qmichannel; - int wait_for_request_quit = 0; - - qmiclientId[QMUX_TYPE_WDS] = GobiNetGetClientID(qcqmi, QMUX_TYPE_WDS); - if (profile->enable_ipv6) - qmiclientId[QMUX_TYPE_WDS_IPV6] = GobiNetGetClientID(qcqmi, QMUX_TYPE_WDS); - qmiclientId[QMUX_TYPE_DMS] = GobiNetGetClientID(qcqmi, QMUX_TYPE_DMS); - qmiclientId[QMUX_TYPE_NAS] = GobiNetGetClientID(qcqmi, QMUX_TYPE_NAS); - qmiclientId[QMUX_TYPE_UIM] = GobiNetGetClientID(qcqmi, QMUX_TYPE_UIM); -#ifdef CONFIG_COEX_WWAN_STATE - qmiclientId[QMUX_TYPE_COEX] = GobiNetGetClientID(qcqmi, QMUX_TYPE_COEX); -#endif - if (profile->qmap_mode == 0 || profile->loopback_state) {//when QMAP enabled, set data format in GobiNet Driver - qmiclientId[QMUX_TYPE_WDS_ADMIN] = GobiNetGetClientID(qcqmi, QMUX_TYPE_WDS_ADMIN); - profile->wda_client = qmiclientId[QMUX_TYPE_WDS_ADMIN]; - } - - //donot check clientWDA, there is only one client for WDA, if quectel-CM is killed by SIGKILL, i cannot get client ID for WDA again! - if (qmiclientId[QMUX_TYPE_WDS] == 0) /*|| (clientWDA == -1)*/ { - GobiNetDeInit(); - dbg_time("%s Failed to open %s, errno: %d (%s)", __func__, qcqmi, errno, strerror(errno)); - qmidevice_send_event_to_main(RIL_INDICATE_DEVICE_DISCONNECTED); - pthread_exit(NULL); - return NULL; - } - - qmidevice_send_event_to_main(RIL_INDICATE_DEVICE_CONNECTED); - - while (1) { - struct pollfd pollfds[16] = {{qmidevice_control_fd[1], POLLIN, 0}}; - int ne, ret, nevents = 1; - unsigned int i; - - for (i = 0; i < sizeof(qmiclientId)/sizeof(qmiclientId[0]); i++) - { - if (qmiclientId[i] != 0) - { - pollfds[nevents].fd = qmiclientId[i]; - pollfds[nevents].events = POLLIN; - pollfds[nevents].revents = 0; - nevents++; - } - } - - do { - ret = poll(pollfds, nevents, wait_for_request_quit ? 1000: -1); - } while ((ret < 0) && (errno == EINTR)); - - if (ret == 0 && wait_for_request_quit) { - QmiThreadRecvQMI(NULL); //main thread may pending on QmiThreadSendQMI() - continue; - } - - if (ret <= 0) { - dbg_time("%s poll=%d, errno: %d (%s)", __func__, ret, errno, strerror(errno)); - break; - } - - for (ne = 0; ne < nevents; ne++) { - int fd = pollfds[ne].fd; - short revents = pollfds[ne].revents; - - if (revents & (POLLERR | POLLHUP | POLLNVAL)) { - dbg_time("%s poll err/hup/inval", __func__); - dbg_time("epoll fd = %d, events = 0x%04x", fd, revents); - if (fd == qmidevice_control_fd[1]) { - } else { - } - if (revents & (POLLERR | POLLHUP | POLLNVAL)) - goto __GobiNetThread_quit; - } - - if ((revents & POLLIN) == 0) - continue; - - if (fd == qmidevice_control_fd[1]) { - int triger_event; - if (read(fd, &triger_event, sizeof(triger_event)) == sizeof(triger_event)) { - //DBG("triger_event = 0x%x", triger_event); - switch (triger_event) { - case RIL_REQUEST_QUIT: - goto __GobiNetThread_quit; - break; - case SIG_EVENT_STOP: - wait_for_request_quit = 1; - break; - default: - break; - } - } - continue; - } - - { - ssize_t nreads; - PQCQMIMSG pResponse = (PQCQMIMSG)cm_recv_buf; - - nreads = read(fd, &pResponse->MUXMsg, sizeof(cm_recv_buf) - sizeof(QCQMI_HDR)); - if (nreads <= 0) - { - dbg_time("%s read=%d errno: %d (%s)", __func__, (int)nreads, errno, strerror(errno)); - break; - } - - for (i = 0; i < sizeof(qmiclientId)/sizeof(qmiclientId[0]); i++) - { - if (qmiclientId[i] == fd) - { - pResponse->QMIHdr.QMIType = i; - } - } - - pResponse->QMIHdr.IFType = USB_CTL_MSG_TYPE_QMI; - pResponse->QMIHdr.Length = cpu_to_le16(nreads + sizeof(QCQMI_HDR) - 1); - pResponse->QMIHdr.CtlFlags = 0x00; - pResponse->QMIHdr.ClientId = (fd&0xFF) ? fd&0xFF : pResponse->QMIHdr.QMIType;; - - QmiThreadRecvQMI(pResponse); - } - } - } - -__GobiNetThread_quit: - GobiNetDeInit(); - qmidevice_send_event_to_main(RIL_INDICATE_DEVICE_DISCONNECTED); - QmiThreadRecvQMI(NULL); //main thread may pending on QmiThreadSendQMI() - dbg_time("%s exit", __func__); - pthread_exit(NULL); - return NULL; -} - -const struct qmi_device_ops gobi_qmidev_ops = { - .deinit = GobiNetDeInit, - .send = GobiNetSendQMI, - .read = GobiNetThread, -}; -#endif - diff --git a/quectel_cm_5G/src/MPQCTL.h b/quectel_cm_5G/src/MPQCTL.h deleted file mode 100644 index 49fe5c3..0000000 --- a/quectel_cm_5G/src/MPQCTL.h +++ /dev/null @@ -1,390 +0,0 @@ -/*=========================================================================== - - M P Q C T L. H -DESCRIPTION: - - This module contains QMI QCTL module. - -INITIALIZATION AND SEQUENCING REQUIREMENTS: - -Copyright (C) 2011 by Qualcomm Technologies, Incorporated. All Rights Reserved. -===========================================================================*/ - -#ifndef MPQCTL_H -#define MPQCTL_H - -#include "MPQMI.h" - -#pragma pack(push, 1) - -// ================= QMICTL ================== - -// QMICTL Control Flags -#define QMICTL_CTL_FLAG_CMD 0x00 -#define QMICTL_CTL_FLAG_RSP 0x01 -#define QMICTL_CTL_FLAG_IND 0x02 - -#if 0 -typedef struct _QMICTL_TRANSACTION_ITEM -{ - LIST_ENTRY List; - UCHAR TransactionId; // QMICTL transaction id - PVOID Context; // Adapter or IocDev - PIRP Irp; -} QMICTL_TRANSACTION_ITEM, *PQMICTL_TRANSACTION_ITEM; -#endif - -typedef struct _QCQMICTL_MSG_HDR -{ - UCHAR CtlFlags; // 00-cmd, 01-rsp, 10-ind - UCHAR TransactionId; - USHORT QMICTLType; - USHORT Length; -} __attribute__ ((packed)) QCQMICTL_MSG_HDR, *PQCQMICTL_MSG_HDR; - -#define QCQMICTL_MSG_HDR_SIZE sizeof(QCQMICTL_MSG_HDR) - -typedef struct _QCQMICTL_MSG_HDR_RESP -{ - UCHAR CtlFlags; // 00-cmd, 01-rsp, 10-ind - UCHAR TransactionId; - USHORT QMICTLType; - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT -} __attribute__ ((packed)) QCQMICTL_MSG_HDR_RESP, *PQCQMICTL_MSG_HDR_RESP; - -typedef struct _QCQMICTL_MSG -{ - UCHAR CtlFlags; // 00-cmd, 01-rsp, 10-ind - UCHAR TransactionId; - USHORT QMICTLType; - USHORT Length; - UCHAR Payload; -} __attribute__ ((packed)) QCQMICTL_MSG, *PQCQMICTL_MSG; - -// TLV Header -typedef struct _QCQMICTL_TLV_HDR -{ - UCHAR TLVType; - USHORT TLVLength; -} __attribute__ ((packed)) QCQMICTL_TLV_HDR, *PQCQMICTL_TLV_HDR; - -#define QCQMICTL_TLV_HDR_SIZE sizeof(QCQMICTL_TLV_HDR) - -// QMICTL Type -#define QMICTL_SET_INSTANCE_ID_REQ 0x0020 -#define QMICTL_SET_INSTANCE_ID_RESP 0x0020 -#define QMICTL_GET_VERSION_REQ 0x0021 -#define QMICTL_GET_VERSION_RESP 0x0021 -#define QMICTL_GET_CLIENT_ID_REQ 0x0022 -#define QMICTL_GET_CLIENT_ID_RESP 0x0022 -#define QMICTL_RELEASE_CLIENT_ID_REQ 0x0023 -#define QMICTL_RELEASE_CLIENT_ID_RESP 0x0023 -#define QMICTL_REVOKE_CLIENT_ID_IND 0x0024 -#define QMICTL_INVALID_CLIENT_ID_IND 0x0025 -#define QMICTL_SET_DATA_FORMAT_REQ 0x0026 -#define QMICTL_SET_DATA_FORMAT_RESP 0x0026 -#define QMICTL_SYNC_REQ 0x0027 -#define QMICTL_SYNC_RESP 0x0027 -#define QMICTL_SYNC_IND 0x0027 -#define QMI_MESSAGE_CTL_INTERNAL_PROXY_OPEN 0xFF00 - -#define QMICTL_FLAG_REQUEST 0x00 -#define QMICTL_FLAG_RESPONSE 0x01 -#define QMICTL_FLAG_INDICATION 0x02 - -// QMICTL Message Definitions - -typedef struct _QMICTL_SET_INSTANCE_ID_REQ_MSG -{ - UCHAR CtlFlags; // QMICTL_FLAG_REQUEST - UCHAR TransactionId; - USHORT QMICTLType; // QMICTL_SET_INSTANCE_ID_REQ - USHORT Length; // 4 - UCHAR TLVType; // QCTLV_TYPE_REQUIRED_PARAMETER - USHORT TLVLength; // 1 - UCHAR Value; // Host-unique QMI instance for this device driver -} __attribute__ ((packed)) QMICTL_SET_INSTANCE_ID_REQ_MSG, *PQMICTL_SET_INSTANCE_ID_REQ_MSG; - -typedef struct _QMICTL_SET_INSTANCE_ID_RESP_MSG -{ - UCHAR CtlFlags; // QMICTL_FLAG_RESPONSE - UCHAR TransactionId; - USHORT QMICTLType; // QMICTL_SET_INSTANCE_ID_RESP - USHORT Length; - UCHAR TLVType; // QCTLV_TYPE_RESULT_CODE - USHORT TLVLength; // 0x0004 - USHORT QMIResult; - USHORT QMIError; - UCHAR TLV2Type; // QCTLV_TYPE_REQUIRED_PARAMETER - USHORT TLV2Length; // 0x0002 - USHORT QMI_ID; // Upper byte is assigned by MSM, - // lower assigned by host -} __attribute__ ((packed)) QMICTL_SET_INSTANCE_ID_RESP_MSG, *PQMICTL_SET_INSTANCE_ID_RESP_MSG; - -typedef struct _QMICTL_GET_VERSION_REQ_MSG -{ - UCHAR CtlFlags; // QMICTL_FLAG_REQUEST - UCHAR TransactionId; - USHORT QMICTLType; // QMICTL_GET_VERSION_REQ - USHORT Length; // 0 - UCHAR TLVType; // QCTLV_TYPE_REQUIRED_PARAMETER - USHORT TLVLength; // var - UCHAR QMUXTypes; // List of one byte QMUX_TYPE values - // 0xFF returns a list of versions for all - // QMUX_TYPEs implemented on the device -} __attribute__ ((packed)) QMICTL_GET_VERSION_REQ_MSG, *PQMICTL_GET_VERSION_REQ_MSG; - -typedef struct _QMUX_TYPE_VERSION_STRUCT -{ - UCHAR QMUXType; - USHORT MajorVersion; - USHORT MinorVersion; -} __attribute__ ((packed)) QMUX_TYPE_VERSION_STRUCT, *PQMUX_TYPE_VERSION_STRUCT; - -typedef struct _ADDENDUM_VERSION_PREAMBLE -{ - UCHAR LabelLength; - UCHAR Label; -} __attribute__ ((packed)) ADDENDUM_VERSION_PREAMBLE, *PADDENDUM_VERSION_PREAMBLE; - -#define QMICTL_GET_VERSION_RSP_TLV_TYPE_VERSION 0x01 -#define QMICTL_GET_VERSION_RSP_TLV_TYPE_ADD_VERSION 0x10 - -typedef struct _QMICTL_GET_VERSION_RESP_MSG -{ - UCHAR CtlFlags; // QMICTL_FLAG_RESPONSE - UCHAR TransactionId; - USHORT QMICTLType; // QMICTL_GET_VERSION_RESP - USHORT Length; - UCHAR TLVType; // QCTLV_TYPE_RESULT_CODE - USHORT TLVLength; // 0x0004 - USHORT QMIResult; - USHORT QMIError; - UCHAR TLV2Type; // QCTLV_TYPE_REQUIRED_PARAMETER - USHORT TLV2Length; // var - UCHAR NumElements; // Num of QMUX_TYPE_VERSION_STRUCT - QMUX_TYPE_VERSION_STRUCT TypeVersion[0]; -} __attribute__ ((packed)) QMICTL_GET_VERSION_RESP_MSG, *PQMICTL_GET_VERSION_RESP_MSG; - -typedef struct _QMICTL_GET_CLIENT_ID_REQ_MSG -{ - UCHAR CtlFlags; // QMICTL_FLAG_REQUEST - UCHAR TransactionId; - USHORT QMICTLType; // QMICTL_GET_CLIENT_ID_REQ - USHORT Length; - UCHAR TLVType; // QCTLV_TYPE_REQUIRED_PARAMETER - USHORT TLVLength; // 1 - UCHAR QMIType; // QMUX type -} __attribute__ ((packed)) QMICTL_GET_CLIENT_ID_REQ_MSG, *PQMICTL_GET_CLIENT_ID_REQ_MSG; - -typedef struct _QMICTL_GET_CLIENT_ID_RESP_MSG -{ - UCHAR CtlFlags; // QMICTL_FLAG_RESPONSE - UCHAR TransactionId; - USHORT QMICTLType; // QMICTL_GET_CLIENT_ID_RESP - USHORT Length; - UCHAR TLVType; // QCTLV_TYPE_RESULT_CODE - USHORT TLVLength; // 0x0004 - USHORT QMIResult; // result code - USHORT QMIError; // error code - UCHAR TLV2Type; // QCTLV_TYPE_REQUIRED_PARAMETER - USHORT TLV2Length; // 2 - UCHAR QMIType; - UCHAR ClientId; -} __attribute__ ((packed)) QMICTL_GET_CLIENT_ID_RESP_MSG, *PQMICTL_GET_CLIENT_ID_RESP_MSG; - -typedef struct _QMICTL_RELEASE_CLIENT_ID_REQ_MSG -{ - UCHAR CtlFlags; // QMICTL_FLAG_REQUEST - UCHAR TransactionId; - USHORT QMICTLType; // QMICTL_RELEASE_CLIENT_ID_REQ - USHORT Length; - UCHAR TLVType; // QCTLV_TYPE_REQUIRED_PARAMETER - USHORT TLVLength; // 0x0002 - UCHAR QMIType; - UCHAR ClientId; -} __attribute__ ((packed)) QMICTL_RELEASE_CLIENT_ID_REQ_MSG, *PQMICTL_RELEASE_CLIENT_ID_REQ_MSG; - -typedef struct _QMICTL_RELEASE_CLIENT_ID_RESP_MSG -{ - UCHAR CtlFlags; // QMICTL_FLAG_RESPONSE - UCHAR TransactionId; - USHORT QMICTLType; // QMICTL_RELEASE_CLIENT_ID_RESP - USHORT Length; - UCHAR TLVType; // QCTLV_TYPE_RESULT_CODE - USHORT TLVLength; // 0x0004 - USHORT QMIResult; // result code - USHORT QMIError; // error code - UCHAR TLV2Type; // QCTLV_TYPE_REQUIRED_PARAMETER - USHORT TLV2Length; // 2 - UCHAR QMIType; - UCHAR ClientId; -} __attribute__ ((packed)) QMICTL_RELEASE_CLIENT_ID_RESP_MSG, *PQMICTL_RELEASE_CLIENT_ID_RESP_MSG; - -typedef struct _QMICTL_REVOKE_CLIENT_ID_IND_MSG -{ - UCHAR CtlFlags; // QMICTL_FLAG_INDICATION - UCHAR TransactionId; - USHORT QMICTLType; // QMICTL_REVOKE_CLIENT_ID_IND - USHORT Length; - UCHAR TLVType; // QCTLV_TYPE_REQUIRED_PARAMETER - USHORT TLVLength; // 0x0002 - UCHAR QMIType; - UCHAR ClientId; -} __attribute__ ((packed)) QMICTL_REVOKE_CLIENT_ID_IND_MSG, *PQMICTL_REVOKE_CLIENT_ID_IND_MSG; - -typedef struct _QMICTL_INVALID_CLIENT_ID_IND_MSG -{ - UCHAR CtlFlags; // QMICTL_FLAG_INDICATION - UCHAR TransactionId; - USHORT QMICTLType; // QMICTL_REVOKE_CLIENT_ID_IND - USHORT Length; - UCHAR TLVType; // QCTLV_TYPE_REQUIRED_PARAMETER - USHORT TLVLength; // 0x0002 - UCHAR QMIType; - UCHAR ClientId; -} __attribute__ ((packed)) QMICTL_INVALID_CLIENT_ID_IND_MSG, *PQMICTL_INVALID_CLIENT_ID_IND_MSG; - -typedef struct _QMICTL_SET_DATA_FORMAT_REQ_MSG -{ - UCHAR CtlFlags; // QMICTL_FLAG_REQUEST - UCHAR TransactionId; - USHORT QMICTLType; // QMICTL_SET_DATA_FORMAT_REQ - USHORT Length; - UCHAR TLVType; // QCTLV_TYPE_REQUIRED_PARAMETER - USHORT TLVLength; // 1 - UCHAR DataFormat; // 0-default; 1-QoS hdr present -} __attribute__ ((packed)) QMICTL_SET_DATA_FORMAT_REQ_MSG, *PQMICTL_SET_DATA_FORMAT_REQ_MSG; - -#ifdef QC_IP_MODE -#define SET_DATA_FORMAT_TLV_TYPE_LINK_PROTO 0x10 -#define SET_DATA_FORMAT_LINK_PROTO_ETH 0x0001 -#define SET_DATA_FORMAT_LINK_PROTO_IP 0x0002 -typedef struct _QMICTL_SET_DATA_FORMAT_TLV_LINK_PROT -{ - UCHAR TLVType; // Link-Layer Protocol - USHORT TLVLength; // 2 - USHORT LinkProt; // 0x1: ETH; 0x2: IP -} QMICTL_SET_DATA_FORMAT_TLV_LINK_PROT, *PQMICTL_SET_DATA_FORMAT_TLV_LINK_PROT; - -#ifdef QCMP_UL_TLP -#define SET_DATA_FORMAT_TLV_TYPE_UL_TLP 0x11 -typedef struct _QMICTL_SET_DATA_FORMAT_TLV_UL_TLP -{ - UCHAR TLVType; // 0x11, Uplink TLP Setting - USHORT TLVLength; // 1 - UCHAR UlTlpSetting; // 0x0: Disable; 0x01: Enable -} QMICTL_SET_DATA_FORMAT_TLV_UL_TLP, *PQMICTL_SET_DATA_FORMAT_TLV_UL_TLP; -#endif // QCMP_UL_TLP - -#ifdef QCMP_DL_TLP -#define SET_DATA_FORMAT_TLV_TYPE_DL_TLP 0x13 -typedef struct _QMICTL_SET_DATA_FORMAT_TLV_DL_TLP -{ - UCHAR TLVType; // 0x11, Uplink TLP Setting - USHORT TLVLength; // 1 - UCHAR DlTlpSetting; // 0x0: Disable; 0x01: Enable -} QMICTL_SET_DATA_FORMAT_TLV_DL_TLP, *PQMICTL_SET_DATA_FORMAT_TLV_DL_TLP; -#endif // QCMP_DL_TLP - -#endif // QC_IP_MODE - -#ifdef MP_QCQOS_ENABLED -#define SET_DATA_FORMAT_TLV_TYPE_QOS_SETTING 0x12 -typedef struct _QMICTL_SET_DATA_FORMAT_TLV_QOS_SETTING -{ - UCHAR TLVType; // 0x12, QoS setting - USHORT TLVLength; // 1 - UCHAR QosSetting; // 0x0: Disable; 0x01: Enable -} QMICTL_SET_DATA_FORMAT_TLV_QOS_SETTING, *PQMICTL_SET_DATA_FORMAT_TLV_QOS_SETTING; -#endif // MP_QCQOS_ENABLED - -typedef struct _QMICTL_SET_DATA_FORMAT_RESP_MSG -{ - UCHAR CtlFlags; // QMICTL_FLAG_RESPONSE - UCHAR TransactionId; - USHORT QMICTLType; // QMICTL_SET_DATA_FORMAT_RESP - USHORT Length; - UCHAR TLVType; // QCTLV_TYPE_RESULT_CODE - USHORT TLVLength; // 0x0004 - USHORT QMIResult; // result code - USHORT QMIError; // error code -} __attribute__ ((packed)) QMICTL_SET_DATA_FORMAT_RESP_MSG, *PQMICTL_SET_DATA_FORMAT_RESP_MSG; - -typedef struct _QMICTL_SYNC_REQ_MSG -{ - UCHAR CtlFlags; // QMICTL_FLAG_REQUEST - UCHAR TransactionId; - USHORT QMICTLType; // QMICTL_CTL_SYNC_REQ - USHORT Length; // 0 -} __attribute__ ((packed)) QMICTL_SYNC_REQ_MSG, *PQMICTL_SYNC_REQ_MSG; - -typedef struct _QMICTL_SYNC_RESP_MSG -{ - UCHAR CtlFlags; // QMICTL_FLAG_RESPONSE - UCHAR TransactionId; - USHORT QMICTLType; // QMICTL_CTL_SYNC_RESP - USHORT Length; - UCHAR TLVType; // QCTLV_TYPE_RESULT_CODE - USHORT TLVLength; // 0x0004 - USHORT QMIResult; - USHORT QMIError; -} __attribute__ ((packed)) QMICTL_SYNC_RESP_MSG, *PQMICTL_SYNC_RESP_MSG; - -typedef struct _QMICTL_SYNC_IND_MSG -{ - UCHAR CtlFlags; // QMICTL_FLAG_INDICATION - UCHAR TransactionId; - USHORT QMICTLType; // QMICTL_REVOKE_CLIENT_ID_IND - USHORT Length; -} __attribute__ ((packed)) QMICTL_SYNC_IND_MSG, *PQMICTL_SYNC_IND_MSG; - -typedef struct _QMICTL_LIBQMI_PROXY_OPEN_MSG -{ - UCHAR CtlFlags; // QMICTL_FLAG_RESPONSE - UCHAR TransactionId; - USHORT QMICTLType; // QMICTL_SET_DATA_FORMAT_RESP - USHORT Length; - UCHAR TLVType; // QCTLV_TYPE_RESULT_CODE - USHORT TLVLength; // 0x0004 - char device_path[0]; // result code -} __attribute__ ((packed)) QMICTL_LIBQMI_PROXY_OPEN_MSG, *PQMICTL_LIBQMI_PROXY_OPEN_MSG; - -typedef struct _QMICTL_MSG -{ - union - { - // Message Header - QCQMICTL_MSG_HDR QMICTLMsgHdr; - QCQMICTL_MSG_HDR_RESP QMICTLMsgHdrRsp; - - // QMICTL Message - QMICTL_SET_INSTANCE_ID_REQ_MSG SetInstanceIdReq; - QMICTL_SET_INSTANCE_ID_RESP_MSG SetInstanceIdRsp; - QMICTL_GET_VERSION_REQ_MSG GetVersionReq; - QMICTL_GET_VERSION_RESP_MSG GetVersionRsp; - QMICTL_GET_CLIENT_ID_REQ_MSG GetClientIdReq; - QMICTL_GET_CLIENT_ID_RESP_MSG GetClientIdRsp; - QMICTL_RELEASE_CLIENT_ID_REQ_MSG ReleaseClientIdReq; - QMICTL_RELEASE_CLIENT_ID_RESP_MSG ReleaseClientIdRsp; - QMICTL_REVOKE_CLIENT_ID_IND_MSG RevokeClientIdInd; - QMICTL_INVALID_CLIENT_ID_IND_MSG InvalidClientIdInd; - QMICTL_SET_DATA_FORMAT_REQ_MSG SetDataFormatReq; - QMICTL_SET_DATA_FORMAT_RESP_MSG SetDataFormatRsp; - QMICTL_SYNC_REQ_MSG SyncReq; - QMICTL_SYNC_RESP_MSG SyncRsp; - QMICTL_SYNC_IND_MSG SyncInd; - QMICTL_LIBQMI_PROXY_OPEN_MSG LibQmiProxyOpenReq; - }; -} __attribute__ ((packed)) QMICTL_MSG, *PQMICTL_MSG; -#pragma pack(pop) - -#endif // MPQCTL_H diff --git a/quectel_cm_5G/src/MPQMI.h b/quectel_cm_5G/src/MPQMI.h deleted file mode 100644 index 1d2204b..0000000 --- a/quectel_cm_5G/src/MPQMI.h +++ /dev/null @@ -1,325 +0,0 @@ -/*=========================================================================== - - M P Q M I. H -DESCRIPTION: - - This module contains forward references to the QMI module. - -INITIALIZATION AND SEQUENCING REQUIREMENTS: - -Copyright (C) 2011 by Qualcomm Technologies, Incorporated. All Rights Reserved. -===========================================================================*/ -/*=========================================================================== - - EDIT HISTORY FOR FILE - $Header: //depot/QMI/win/qcdrivers/ndis/MPQMI.h#3 $ - -when who what, where, why --------- --- ---------------------------------------------------------- -11/20/04 hg Initial version. -===========================================================================*/ - -#ifndef USBQMI_H -#define USBQMI_H - -typedef uint8_t uint8; -typedef int8_t int8; -typedef uint16_t uint16; -typedef int16_t int16; -typedef uint32_t uint32; -typedef uint64_t uint64; - -typedef signed char CHAR; -typedef unsigned char UCHAR; -typedef short SHORT; -typedef unsigned short USHORT; -typedef int INT; -typedef unsigned int UINT; -typedef long LONG; -typedef unsigned int ULONG; -typedef unsigned long long ULONG64; -typedef signed char *PCHAR; -typedef unsigned char *PUCHAR; -typedef int *PINT; -typedef int BOOL; - -#define TRUE (1 == 1) -#define FALSE (1 != 1) - -#define QMICTL_SUPPORTED_MAJOR_VERSION 1 -#define QMICTL_SUPPORTED_MINOR_VERSION 0 - -#pragma pack(push, 1) - -// ========= USB Control Message ========== - -#define USB_CTL_MSG_TYPE_QMI 0x01 - -// USB Control Message -typedef struct _QCUSB_CTL_MSG_HDR -{ - UCHAR IFType; -} __attribute__ ((packed)) QCUSB_CTL_MSG_HDR, *PQCUSB_CTL_MSG_HDR; - -#define QCUSB_CTL_MSG_HDR_SIZE sizeof(QCUSB_CTL_MSG_HDR) - -typedef struct _QCUSB_CTL_MSG -{ - UCHAR IFType; - UCHAR Message; -} __attribute__ ((packed)) QCUSB_CTL_MSG, *PQCUSB_CTL_MSG; - -#define QCTLV_TYPE_REQUIRED_PARAMETER 0x01 -#define QCTLV_TYPE_RESULT_CODE 0x02 - -// ================= QMI ================== - -// Define QMI Type -typedef enum _QMI_SERVICE_TYPE -{ - QMUX_TYPE_CTL = 0x00, - QMUX_TYPE_WDS = 0x01, - QMUX_TYPE_DMS = 0x02, - QMUX_TYPE_NAS = 0x03, - QMUX_TYPE_QOS = 0x04, - QMUX_TYPE_WMS = 0x05, - QMUX_TYPE_PDS = 0x06, - QMUX_TYPE_UIM = 0x0B, - QMUX_TYPE_WDS_IPV6 = 0x11, - QMUX_TYPE_WDS_ADMIN = 0x1A, - QMUX_TYPE_COEX = 0x22, - QMUX_TYPE_MAX = 0xFF, - QMUX_TYPE_ALL = 0xFF -} QMI_SERVICE_TYPE; - -typedef enum _QMI_RESULT_CODE_TYPE -{ - QMI_RESULT_SUCCESS = 0x0000, - QMI_RESULT_FAILURE = 0x0001 -} QMI_RESULT_CODE_TYPE; - -typedef enum _QMI_ERROR_CODE_TYPE -{ - QMI_ERR_NONE = 0x0000 - ,QMI_ERR_MALFORMED_MSG = 0x0001 - ,QMI_ERR_NO_MEMORY = 0x0002 - ,QMI_ERR_INTERNAL = 0x0003 - ,QMI_ERR_ABORTED = 0x0004 - ,QMI_ERR_CLIENT_IDS_EXHAUSTED = 0x0005 - ,QMI_ERR_UNABORTABLE_TRANSACTION = 0x0006 - ,QMI_ERR_INVALID_CLIENT_ID = 0x0007 - ,QMI_ERR_NO_THRESHOLDS = 0x0008 - ,QMI_ERR_INVALID_HANDLE = 0x0009 - ,QMI_ERR_INVALID_PROFILE = 0x000A - ,QMI_ERR_INVALID_PINID = 0x000B - ,QMI_ERR_INCORRECT_PIN = 0x000C - ,QMI_ERR_NO_NETWORK_FOUND = 0x000D - ,QMI_ERR_CALL_FAILED = 0x000E - ,QMI_ERR_OUT_OF_CALL = 0x000F - ,QMI_ERR_NOT_PROVISIONED = 0x0010 - ,QMI_ERR_MISSING_ARG = 0x0011 - ,QMI_ERR_ARG_TOO_LONG = 0x0013 - ,QMI_ERR_INVALID_TX_ID = 0x0016 - ,QMI_ERR_DEVICE_IN_USE = 0x0017 - ,QMI_ERR_OP_NETWORK_UNSUPPORTED = 0x0018 - ,QMI_ERR_OP_DEVICE_UNSUPPORTED = 0x0019 - ,QMI_ERR_NO_EFFECT = 0x001A - ,QMI_ERR_NO_FREE_PROFILE = 0x001B - ,QMI_ERR_INVALID_PDP_TYPE = 0x001C - ,QMI_ERR_INVALID_TECH_PREF = 0x001D - ,QMI_ERR_INVALID_PROFILE_TYPE = 0x001E - ,QMI_ERR_INVALID_SERVICE_TYPE = 0x001F - ,QMI_ERR_INVALID_REGISTER_ACTION = 0x0020 - ,QMI_ERR_INVALID_PS_ATTACH_ACTION = 0x0021 - ,QMI_ERR_AUTHENTICATION_FAILED = 0x0022 - ,QMI_ERR_PIN_BLOCKED = 0x0023 - ,QMI_ERR_PIN_PERM_BLOCKED = 0x0024 - ,QMI_ERR_SIM_NOT_INITIALIZED = 0x0025 - ,QMI_ERR_MAX_QOS_REQUESTS_IN_USE = 0x0026 - ,QMI_ERR_INCORRECT_FLOW_FILTER = 0x0027 - ,QMI_ERR_NETWORK_QOS_UNAWARE = 0x0028 - ,QMI_ERR_INVALID_QOS_ID = 0x0029 - ,QMI_ERR_INVALID_ID = 0x0029 - ,QMI_ERR_REQUESTED_NUM_UNSUPPORTED = 0x002A - ,QMI_ERR_INTERFACE_NOT_FOUND = 0x002B - ,QMI_ERR_FLOW_SUSPENDED = 0x002C - ,QMI_ERR_INVALID_DATA_FORMAT = 0x002D - ,QMI_ERR_GENERAL = 0x002E - ,QMI_ERR_UNKNOWN = 0x002F - ,QMI_ERR_INVALID_ARG = 0x0030 - ,QMI_ERR_INVALID_INDEX = 0x0031 - ,QMI_ERR_NO_ENTRY = 0x0032 - ,QMI_ERR_DEVICE_STORAGE_FULL = 0x0033 - ,QMI_ERR_DEVICE_NOT_READY = 0x0034 - ,QMI_ERR_NETWORK_NOT_READY = 0x0035 - ,QMI_ERR_CAUSE_CODE = 0x0036 - ,QMI_ERR_MESSAGE_NOT_SENT = 0x0037 - ,QMI_ERR_MESSAGE_DELIVERY_FAILURE = 0x0038 - ,QMI_ERR_INVALID_MESSAGE_ID = 0x0039 - ,QMI_ERR_ENCODING = 0x003A - ,QMI_ERR_AUTHENTICATION_LOCK = 0x003B - ,QMI_ERR_INVALID_TRANSITION = 0x003C - ,QMI_ERR_NOT_A_MCAST_IFACE = 0x003D - ,QMI_ERR_MAX_MCAST_REQUESTS_IN_USE = 0x003E - ,QMI_ERR_INVALID_MCAST_HANDLE = 0x003F - ,QMI_ERR_INVALID_IP_FAMILY_PREF = 0x0040 - ,QMI_ERR_SESSION_INACTIVE = 0x0041 - ,QMI_ERR_SESSION_INVALID = 0x0042 - ,QMI_ERR_SESSION_OWNERSHIP = 0x0043 - ,QMI_ERR_INSUFFICIENT_RESOURCES = 0x0044 - ,QMI_ERR_DISABLED = 0x0045 - ,QMI_ERR_INVALID_OPERATION = 0x0046 - ,QMI_ERR_INVALID_QMI_CMD = 0x0047 - ,QMI_ERR_TPDU_TYPE = 0x0048 - ,QMI_ERR_SMSC_ADDR = 0x0049 - ,QMI_ERR_INFO_UNAVAILABLE = 0x004A - ,QMI_ERR_SEGMENT_TOO_LONG = 0x004B - ,QMI_ERR_SEGMENT_ORDER = 0x004C - ,QMI_ERR_BUNDLING_NOT_SUPPORTED = 0x004D - ,QMI_ERR_OP_PARTIAL_FAILURE = 0x004E - ,QMI_ERR_POLICY_MISMATCH = 0x004F - ,QMI_ERR_SIM_FILE_NOT_FOUND = 0x0050 - ,QMI_ERR_EXTENDED_INTERNAL = 0x0051 - ,QMI_ERR_ACCESS_DENIED = 0x0052 - ,QMI_ERR_HARDWARE_RESTRICTED = 0x0053 - ,QMI_ERR_ACK_NOT_SENT = 0x0054 - ,QMI_ERR_INJECT_TIMEOUT = 0x0055 - ,QMI_ERR_INCOMPATIBLE_STATE = 0x005A - ,QMI_ERR_FDN_RESTRICT = 0x005B - ,QMI_ERR_SUPS_FAILURE_CAUSE = 0x005C - ,QMI_ERR_NO_RADIO = 0x005D - ,QMI_ERR_NOT_SUPPORTED = 0x005E - ,QMI_ERR_NO_SUBSCRIPTION = 0x005F - ,QMI_ERR_CARD_CALL_CONTROL_FAILED = 0x0060 - ,QMI_ERR_NETWORK_ABORTED = 0x0061 - ,QMI_ERR_MSG_BLOCKED = 0x0062 - ,QMI_ERR_INVALID_SESSION_TYPE = 0x0064 - ,QMI_ERR_INVALID_PB_TYPE = 0x0065 - ,QMI_ERR_NO_SIM = 0x0066 - ,QMI_ERR_PB_NOT_READY = 0x0067 - ,QMI_ERR_PIN_RESTRICTION = 0x0068 - ,QMI_ERR_PIN2_RESTRICTION = 0x0069 - ,QMI_ERR_PUK_RESTRICTION = 0x006A - ,QMI_ERR_PUK2_RESTRICTION = 0x006B - ,QMI_ERR_PB_ACCESS_RESTRICTED = 0x006C - ,QMI_ERR_PB_DELETE_IN_PROG = 0x006D - ,QMI_ERR_PB_TEXT_TOO_LONG = 0x006E - ,QMI_ERR_PB_NUMBER_TOO_LONG = 0x006F - ,QMI_ERR_PB_HIDDEN_KEY_RESTRICTION = 0x0070 -} QMI_ERROR_CODE_TYPE; - -#define QCQMI_CTL_FLAG_SERVICE 0x80 -#define QCQMI_CTL_FLAG_CTL_POINT 0x00 - -typedef struct _QCQMI_HDR -{ - UCHAR IFType; - USHORT Length; - UCHAR CtlFlags; // reserved - UCHAR QMIType; - UCHAR ClientId; -} __attribute__ ((packed)) QCQMI_HDR, *PQCQMI_HDR; - -#define QCQMI_HDR_SIZE (sizeof(QCQMI_HDR)-1) - -typedef struct _QCQMI -{ - UCHAR IFType; - USHORT Length; - UCHAR CtlFlags; // reserved - UCHAR QMIType; - UCHAR ClientId; - UCHAR SDU; -} __attribute__ ((packed)) QCQMI, *PQCQMI; - -typedef struct _QMI_SERVICE_VERSION -{ - USHORT Major; - USHORT Minor; - USHORT AddendumMajor; - USHORT AddendumMinor; -} __attribute__ ((packed)) QMI_SERVICE_VERSION, *PQMI_SERVICE_VERSION; - -// ================= QMUX ================== - -#define QMUX_MSG_OVERHEAD_BYTES 4 // Type(USHORT) Length(USHORT) -- header - -#define QMUX_BROADCAST_CID 0xFF - -typedef struct _QCQMUX_HDR -{ - UCHAR CtlFlags; // 0: single QMUX Msg; 1: - USHORT TransactionId; -} __attribute__ ((packed)) QCQMUX_HDR, *PQCQMUX_HDR; - -typedef struct _QCQMUX -{ - UCHAR CtlFlags; // 0: single QMUX Msg; 1: - USHORT TransactionId; - UCHAR Message; // Type(2), Length(2), Value -} __attribute__ ((packed)) QCQMUX, *PQCQMUX; - -#define QCQMUX_HDR_SIZE sizeof(QCQMUX_HDR) - -typedef struct _QCQMUX_MSG_HDR -{ - USHORT Type; - USHORT Length; -} __attribute__ ((packed)) QCQMUX_MSG_HDR, *PQCQMUX_MSG_HDR; - -#define QCQMUX_MSG_HDR_SIZE sizeof(QCQMUX_MSG_HDR) - -typedef struct _QCQMUX_MSG_HDR_RESP -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT -} __attribute__ ((packed)) QCQMUX_MSG_HDR_RESP, *PQCQMUX_MSG_HDR_RESP; - -typedef struct _QCQMUX_TLV -{ - UCHAR Type; - USHORT Length; - UCHAR Value; -} __attribute__ ((packed)) QCQMUX_TLV, *PQCQMUX_TLV; - -typedef struct _QMI_TLV_HDR -{ - UCHAR TLVType; - USHORT TLVLength; -} __attribute__ ((packed)) QMI_TLV_HDR, *PQMI_TLV_HDR; - -typedef struct _QMI_TLV -{ - UCHAR TLVType; - USHORT TLVLength; - union { - int8_t s8; - uint8_t u8; - int16_t s16; - uint16_t u16; - int32_t s32; - uint32_t u32; - uint64_t u64; - }; -} __attribute__ ((packed)) QMI_TLV, *PQMI_TLV; - -// QMUX Message Definitions -- QMI SDU -#define QMUX_CTL_FLAG_SINGLE_MSG 0x00 -#define QMUX_CTL_FLAG_COMPOUND_MSG 0x01 -#define QMUX_CTL_FLAG_TYPE_CMD 0x00 -#define QMUX_CTL_FLAG_TYPE_RSP 0x02 -#define QMUX_CTL_FLAG_TYPE_IND 0x04 -#define QMUX_CTL_FLAG_MASK_COMPOUND 0x01 -#define QMUX_CTL_FLAG_MASK_TYPE 0x06 // 00-cmd, 01-rsp, 10-ind - -#pragma pack(pop) - -#endif // USBQMI_H diff --git a/quectel_cm_5G/src/MPQMUX.c b/quectel_cm_5G/src/MPQMUX.c deleted file mode 100644 index 7c8dfb3..0000000 --- a/quectel_cm_5G/src/MPQMUX.c +++ /dev/null @@ -1,477 +0,0 @@ -/****************************************************************************** - @file MPQMUX.c - @brief QMI mux. - - DESCRIPTION - Connectivity Management Tool for USB network adapter of Quectel wireless cellular modules. - - INITIALIZATION AND SEQUENCING REQUIREMENTS - None. - - --------------------------------------------------------------------------- - Copyright (c) 2016 - 2020 Quectel Wireless Solution, Co., Ltd. All Rights Reserved. - Quectel Wireless Solution Proprietary and Confidential. - --------------------------------------------------------------------------- -******************************************************************************/ - -#include "QMIThread.h" -static char line[1024]; -static pthread_mutex_t dumpQMIMutex = PTHREAD_MUTEX_INITIALIZER; -#undef dbg -#define dbg( format, arg... ) do {if (strlen(line) < sizeof(line)) snprintf(&line[strlen(line)], sizeof(line) - strlen(line), format, ## arg);} while (0) - -PQMI_TLV_HDR GetTLV (PQCQMUX_MSG_HDR pQMUXMsgHdr, int TLVType); - -typedef struct { - UINT type; - const char *name; -} QMI_NAME_T; - -#define qmi_name_item(type) {type, #type} - -#if 0 -static const QMI_NAME_T qmi_IFType[] = { -{USB_CTL_MSG_TYPE_QMI, "USB_CTL_MSG_TYPE_QMI"}, -}; - -static const QMI_NAME_T qmi_CtlFlags[] = { -qmi_name_item(QMICTL_CTL_FLAG_CMD), -qmi_name_item(QCQMI_CTL_FLAG_SERVICE), -}; - -static const QMI_NAME_T qmi_QMIType[] = { -qmi_name_item(QMUX_TYPE_CTL), -qmi_name_item(QMUX_TYPE_WDS), -qmi_name_item(QMUX_TYPE_DMS), -qmi_name_item(QMUX_TYPE_NAS), -qmi_name_item(QMUX_TYPE_QOS), -qmi_name_item(QMUX_TYPE_WMS), -qmi_name_item(QMUX_TYPE_PDS), -qmi_name_item(QMUX_TYPE_WDS_ADMIN), -qmi_name_item(QMUX_TYPE_COEX), -}; - -static const QMI_NAME_T qmi_ctl_CtlFlags[] = { -qmi_name_item(QMICTL_FLAG_REQUEST), -qmi_name_item(QMICTL_FLAG_RESPONSE), -qmi_name_item(QMICTL_FLAG_INDICATION), -}; -#endif - -static const QMI_NAME_T qmux_ctl_QMICTLType[] = { -// QMICTL Type -qmi_name_item(QMICTL_SET_INSTANCE_ID_REQ), // 0x0020 -qmi_name_item(QMICTL_SET_INSTANCE_ID_RESP), // 0x0020 -qmi_name_item(QMICTL_GET_VERSION_REQ), // 0x0021 -qmi_name_item(QMICTL_GET_VERSION_RESP), // 0x0021 -qmi_name_item(QMICTL_GET_CLIENT_ID_REQ), // 0x0022 -qmi_name_item(QMICTL_GET_CLIENT_ID_RESP), // 0x0022 -qmi_name_item(QMICTL_RELEASE_CLIENT_ID_REQ), // 0x0023 -qmi_name_item(QMICTL_RELEASE_CLIENT_ID_RESP), // 0x0023 -qmi_name_item(QMICTL_REVOKE_CLIENT_ID_IND), // 0x0024 -qmi_name_item(QMICTL_INVALID_CLIENT_ID_IND), // 0x0025 -qmi_name_item(QMICTL_SET_DATA_FORMAT_REQ), // 0x0026 -qmi_name_item(QMICTL_SET_DATA_FORMAT_RESP), // 0x0026 -qmi_name_item(QMICTL_SYNC_REQ), // 0x0027 -qmi_name_item(QMICTL_SYNC_RESP), // 0x0027 -qmi_name_item(QMICTL_SYNC_IND), // 0x0027 -}; - -static const QMI_NAME_T qmux_CtlFlags[] = { -qmi_name_item(QMUX_CTL_FLAG_TYPE_CMD), -qmi_name_item(QMUX_CTL_FLAG_TYPE_RSP), -qmi_name_item(QMUX_CTL_FLAG_TYPE_IND), -}; - - -static const QMI_NAME_T qmux_wds_Type[] = { -qmi_name_item(QMIWDS_SET_EVENT_REPORT_REQ), // 0x0001 -qmi_name_item(QMIWDS_SET_EVENT_REPORT_RESP), // 0x0001 -qmi_name_item(QMIWDS_EVENT_REPORT_IND), // 0x0001 -qmi_name_item(QMIWDS_START_NETWORK_INTERFACE_REQ), // 0x0020 -qmi_name_item(QMIWDS_START_NETWORK_INTERFACE_RESP), // 0x0020 -qmi_name_item(QMIWDS_STOP_NETWORK_INTERFACE_REQ), // 0x0021 -qmi_name_item(QMIWDS_STOP_NETWORK_INTERFACE_RESP), // 0x0021 -qmi_name_item(QMIWDS_GET_PKT_SRVC_STATUS_REQ), // 0x0022 -qmi_name_item(QMIWDS_GET_PKT_SRVC_STATUS_RESP), // 0x0022 -qmi_name_item(QMIWDS_GET_PKT_SRVC_STATUS_IND), // 0x0022 -qmi_name_item(QMIWDS_GET_CURRENT_CHANNEL_RATE_REQ), // 0x0023 -qmi_name_item(QMIWDS_GET_CURRENT_CHANNEL_RATE_RESP), // 0x0023 -qmi_name_item(QMIWDS_GET_PKT_STATISTICS_REQ), // 0x0024 -qmi_name_item(QMIWDS_GET_PKT_STATISTICS_RESP), // 0x0024 -qmi_name_item(QMIWDS_MODIFY_PROFILE_SETTINGS_REQ), // 0x0028 -qmi_name_item(QMIWDS_MODIFY_PROFILE_SETTINGS_RESP), // 0x0028 -qmi_name_item(QMIWDS_GET_PROFILE_SETTINGS_REQ), // 0x002B -qmi_name_item(QMIWDS_GET_PROFILE_SETTINGS_RESP), // 0x002BD -qmi_name_item(QMIWDS_GET_DEFAULT_SETTINGS_REQ), // 0x002C -qmi_name_item(QMIWDS_GET_DEFAULT_SETTINGS_RESP), // 0x002C -qmi_name_item(QMIWDS_GET_RUNTIME_SETTINGS_REQ), // 0x002D -qmi_name_item(QMIWDS_GET_RUNTIME_SETTINGS_RESP), // 0x002D -qmi_name_item(QMIWDS_GET_MIP_MODE_REQ), // 0x002F -qmi_name_item(QMIWDS_GET_MIP_MODE_RESP), // 0x002F -qmi_name_item(QMIWDS_GET_DATA_BEARER_REQ), // 0x0037 -qmi_name_item(QMIWDS_GET_DATA_BEARER_RESP), // 0x0037 -qmi_name_item(QMIWDS_DUN_CALL_INFO_REQ), // 0x0038 -qmi_name_item(QMIWDS_DUN_CALL_INFO_RESP), // 0x0038 -qmi_name_item(QMIWDS_DUN_CALL_INFO_IND), // 0x0038 -qmi_name_item(QMIWDS_SET_CLIENT_IP_FAMILY_PREF_REQ), // 0x004D -qmi_name_item(QMIWDS_SET_CLIENT_IP_FAMILY_PREF_RESP), // 0x004D -qmi_name_item(QMIWDS_SET_AUTO_CONNECT_REQ), // 0x0051 -qmi_name_item(QMIWDS_SET_AUTO_CONNECT_RESP), // 0x0051 -qmi_name_item(QMIWDS_BIND_MUX_DATA_PORT_REQ), // 0x00A2 -qmi_name_item(QMIWDS_BIND_MUX_DATA_PORT_RESP), // 0x00A2 -}; - -static const QMI_NAME_T qmux_dms_Type[] = { -// ======================= DMS ============================== -qmi_name_item(QMIDMS_SET_EVENT_REPORT_REQ), // 0x0001 -qmi_name_item(QMIDMS_SET_EVENT_REPORT_RESP), // 0x0001 -qmi_name_item(QMIDMS_EVENT_REPORT_IND), // 0x0001 -qmi_name_item(QMIDMS_GET_DEVICE_CAP_REQ), // 0x0020 -qmi_name_item(QMIDMS_GET_DEVICE_CAP_RESP), // 0x0020 -qmi_name_item(QMIDMS_GET_DEVICE_MFR_REQ), // 0x0021 -qmi_name_item(QMIDMS_GET_DEVICE_MFR_RESP), // 0x0021 -qmi_name_item(QMIDMS_GET_DEVICE_MODEL_ID_REQ), // 0x0022 -qmi_name_item(QMIDMS_GET_DEVICE_MODEL_ID_RESP), // 0x0022 -qmi_name_item(QMIDMS_GET_DEVICE_REV_ID_REQ), // 0x0023 -qmi_name_item(QMIDMS_GET_DEVICE_REV_ID_RESP), // 0x0023 -qmi_name_item(QMIDMS_GET_MSISDN_REQ), // 0x0024 -qmi_name_item(QMIDMS_GET_MSISDN_RESP), // 0x0024 -qmi_name_item(QMIDMS_GET_DEVICE_SERIAL_NUMBERS_REQ), // 0x0025 -qmi_name_item(QMIDMS_GET_DEVICE_SERIAL_NUMBERS_RESP), // 0x0025 -qmi_name_item(QMIDMS_UIM_SET_PIN_PROTECTION_REQ), // 0x0027 -qmi_name_item(QMIDMS_UIM_SET_PIN_PROTECTION_RESP), // 0x0027 -qmi_name_item(QMIDMS_UIM_VERIFY_PIN_REQ), // 0x0028 -qmi_name_item(QMIDMS_UIM_VERIFY_PIN_RESP), // 0x0028 -qmi_name_item(QMIDMS_UIM_UNBLOCK_PIN_REQ), // 0x0029 -qmi_name_item(QMIDMS_UIM_UNBLOCK_PIN_RESP), // 0x0029 -qmi_name_item(QMIDMS_UIM_CHANGE_PIN_REQ), // 0x002A -qmi_name_item(QMIDMS_UIM_CHANGE_PIN_RESP), // 0x002A -qmi_name_item(QMIDMS_UIM_GET_PIN_STATUS_REQ), // 0x002B -qmi_name_item(QMIDMS_UIM_GET_PIN_STATUS_RESP), // 0x002B -qmi_name_item(QMIDMS_GET_DEVICE_HARDWARE_REV_REQ), // 0x002C -qmi_name_item(QMIDMS_GET_DEVICE_HARDWARE_REV_RESP), // 0x002C -qmi_name_item(QMIDMS_GET_OPERATING_MODE_REQ), // 0x002D -qmi_name_item(QMIDMS_GET_OPERATING_MODE_RESP), // 0x002D -qmi_name_item(QMIDMS_SET_OPERATING_MODE_REQ), // 0x002E -qmi_name_item(QMIDMS_SET_OPERATING_MODE_RESP), // 0x002E -qmi_name_item(QMIDMS_GET_ACTIVATED_STATUS_REQ), // 0x0031 -qmi_name_item(QMIDMS_GET_ACTIVATED_STATUS_RESP), // 0x0031 -qmi_name_item(QMIDMS_ACTIVATE_AUTOMATIC_REQ), // 0x0032 -qmi_name_item(QMIDMS_ACTIVATE_AUTOMATIC_RESP), // 0x0032 -qmi_name_item(QMIDMS_ACTIVATE_MANUAL_REQ), // 0x0033 -qmi_name_item(QMIDMS_ACTIVATE_MANUAL_RESP), // 0x0033 -qmi_name_item(QMIDMS_UIM_GET_ICCID_REQ), // 0x003C -qmi_name_item(QMIDMS_UIM_GET_ICCID_RESP), // 0x003C -qmi_name_item(QMIDMS_UIM_GET_CK_STATUS_REQ), // 0x0040 -qmi_name_item(QMIDMS_UIM_GET_CK_STATUS_RESP), // 0x0040 -qmi_name_item(QMIDMS_UIM_SET_CK_PROTECTION_REQ), // 0x0041 -qmi_name_item(QMIDMS_UIM_SET_CK_PROTECTION_RESP), // 0x0041 -qmi_name_item(QMIDMS_UIM_UNBLOCK_CK_REQ), // 0x0042 -qmi_name_item(QMIDMS_UIM_UNBLOCK_CK_RESP), // 0x0042 -qmi_name_item(QMIDMS_UIM_GET_IMSI_REQ), // 0x0043 -qmi_name_item(QMIDMS_UIM_GET_IMSI_RESP), // 0x0043 -qmi_name_item(QMIDMS_UIM_GET_STATE_REQ), // 0x0044 -qmi_name_item(QMIDMS_UIM_GET_STATE_RESP), // 0x0044 -qmi_name_item(QMIDMS_GET_BAND_CAP_REQ), // 0x0045 -qmi_name_item(QMIDMS_GET_BAND_CAP_RESP), // 0x0045 -}; - -static const QMI_NAME_T qmux_qos_Type[] = { -qmi_name_item( QMI_QOS_SET_EVENT_REPORT_REQ), // 0x0001 -qmi_name_item( QMI_QOS_SET_EVENT_REPORT_RESP), // 0x0001 -qmi_name_item( QMI_QOS_SET_EVENT_REPORT_IND), // 0x0001 -qmi_name_item( QMI_QOS_BIND_DATA_PORT_REQ), // 0x002B -qmi_name_item( QMI_QOS_BIND_DATA_PORT_RESP), // 0x002B -qmi_name_item( QMI_QOS_INDICATION_REGISTER_REQ), // 0x002F -qmi_name_item( QMI_QOS_INDICATION_REGISTER_RESP), // 0x002F -qmi_name_item( QMI_QOS_GLOBAL_QOS_FLOW_IND), // 0x0031 -qmi_name_item( QMI_QOS_GET_QOS_INFO_REQ), // 0x0033 -qmi_name_item( QMI_QOS_GET_QOS_INFO_RESP), // 0x0033 -}; - -static const QMI_NAME_T qmux_nas_Type[] = { -// ======================= NAS ============================== -qmi_name_item(QMINAS_SET_EVENT_REPORT_REQ), // 0x0002 -qmi_name_item(QMINAS_SET_EVENT_REPORT_RESP), // 0x0002 -qmi_name_item(QMINAS_EVENT_REPORT_IND), // 0x0002 -qmi_name_item(QMINAS_GET_SIGNAL_STRENGTH_REQ), // 0x0020 -qmi_name_item(QMINAS_GET_SIGNAL_STRENGTH_RESP), // 0x0020 -qmi_name_item(QMINAS_PERFORM_NETWORK_SCAN_REQ), // 0x0021 -qmi_name_item(QMINAS_PERFORM_NETWORK_SCAN_RESP), // 0x0021 -qmi_name_item(QMINAS_INITIATE_NW_REGISTER_REQ), // 0x0022 -qmi_name_item(QMINAS_INITIATE_NW_REGISTER_RESP), // 0x0022 -qmi_name_item(QMINAS_INITIATE_ATTACH_REQ), // 0x0023 -qmi_name_item(QMINAS_INITIATE_ATTACH_RESP), // 0x0023 -qmi_name_item(QMINAS_GET_SERVING_SYSTEM_REQ), // 0x0024 -qmi_name_item(QMINAS_GET_SERVING_SYSTEM_RESP), // 0x0024 -qmi_name_item(QMINAS_SERVING_SYSTEM_IND), // 0x0024 -qmi_name_item(QMINAS_GET_HOME_NETWORK_REQ), // 0x0025 -qmi_name_item(QMINAS_GET_HOME_NETWORK_RESP), // 0x0025 -qmi_name_item(QMINAS_GET_PREFERRED_NETWORK_REQ), // 0x0026 -qmi_name_item(QMINAS_GET_PREFERRED_NETWORK_RESP), // 0x0026 -qmi_name_item(QMINAS_SET_PREFERRED_NETWORK_REQ), // 0x0027 -qmi_name_item(QMINAS_SET_PREFERRED_NETWORK_RESP), // 0x0027 -qmi_name_item(QMINAS_GET_FORBIDDEN_NETWORK_REQ), // 0x0028 -qmi_name_item(QMINAS_GET_FORBIDDEN_NETWORK_RESP), // 0x0028 -qmi_name_item(QMINAS_SET_FORBIDDEN_NETWORK_REQ), // 0x0029 -qmi_name_item(QMINAS_SET_FORBIDDEN_NETWORK_RESP), // 0x0029 -qmi_name_item(QMINAS_SET_TECHNOLOGY_PREF_REQ), // 0x002A -qmi_name_item(QMINAS_SET_TECHNOLOGY_PREF_RESP), // 0x002A -qmi_name_item(QMINAS_GET_RF_BAND_INFO_REQ), // 0x0031 -qmi_name_item(QMINAS_GET_RF_BAND_INFO_RESP), // 0x0031 -qmi_name_item(QMINAS_GET_CELL_LOCATION_INFO_REQ), -qmi_name_item(QMINAS_GET_CELL_LOCATION_INFO_RESP), -qmi_name_item(QMINAS_GET_PLMN_NAME_REQ), // 0x0044 -qmi_name_item(QMINAS_GET_PLMN_NAME_RESP), // 0x0044 -qmi_name_item(QUECTEL_PACKET_TRANSFER_START_IND), // 0X100 -qmi_name_item(QUECTEL_PACKET_TRANSFER_END_IND), // 0X101 -qmi_name_item(QMINAS_GET_SYS_INFO_REQ), // 0x004D -qmi_name_item(QMINAS_GET_SYS_INFO_RESP), // 0x004D -qmi_name_item(QMINAS_SYS_INFO_IND), // 0x004D -qmi_name_item(QMINAS_GET_SIG_INFO_REQ), -qmi_name_item(QMINAS_GET_SIG_INFO_RESP), - -}; - -static const QMI_NAME_T qmux_wms_Type[] = { -// ======================= WMS ============================== -qmi_name_item(QMIWMS_SET_EVENT_REPORT_REQ), // 0x0001 -qmi_name_item(QMIWMS_SET_EVENT_REPORT_RESP), // 0x0001 -qmi_name_item(QMIWMS_EVENT_REPORT_IND), // 0x0001 -qmi_name_item(QMIWMS_RAW_SEND_REQ), // 0x0020 -qmi_name_item(QMIWMS_RAW_SEND_RESP), // 0x0020 -qmi_name_item(QMIWMS_RAW_WRITE_REQ), // 0x0021 -qmi_name_item(QMIWMS_RAW_WRITE_RESP), // 0x0021 -qmi_name_item(QMIWMS_RAW_READ_REQ), // 0x0022 -qmi_name_item(QMIWMS_RAW_READ_RESP), // 0x0022 -qmi_name_item(QMIWMS_MODIFY_TAG_REQ), // 0x0023 -qmi_name_item(QMIWMS_MODIFY_TAG_RESP), // 0x0023 -qmi_name_item(QMIWMS_DELETE_REQ), // 0x0024 -qmi_name_item(QMIWMS_DELETE_RESP), // 0x0024 -qmi_name_item(QMIWMS_GET_MESSAGE_PROTOCOL_REQ), // 0x0030 -qmi_name_item(QMIWMS_GET_MESSAGE_PROTOCOL_RESP), // 0x0030 -qmi_name_item(QMIWMS_LIST_MESSAGES_REQ), // 0x0031 -qmi_name_item(QMIWMS_LIST_MESSAGES_RESP), // 0x0031 -qmi_name_item(QMIWMS_GET_SMSC_ADDRESS_REQ), // 0x0034 -qmi_name_item(QMIWMS_GET_SMSC_ADDRESS_RESP), // 0x0034 -qmi_name_item(QMIWMS_SET_SMSC_ADDRESS_REQ), // 0x0035 -qmi_name_item(QMIWMS_SET_SMSC_ADDRESS_RESP), // 0x0035 -qmi_name_item(QMIWMS_GET_STORE_MAX_SIZE_REQ), // 0x0036 -qmi_name_item(QMIWMS_GET_STORE_MAX_SIZE_RESP), // 0x0036 -}; - -static const QMI_NAME_T qmux_wds_admin_Type[] = { -qmi_name_item(QMIWDS_ADMIN_SET_DATA_FORMAT_REQ), // 0x0020 -qmi_name_item(QMIWDS_ADMIN_SET_DATA_FORMAT_RESP), // 0x0020 -qmi_name_item(QMIWDS_ADMIN_GET_DATA_FORMAT_REQ), // 0x0021 -qmi_name_item(QMIWDS_ADMIN_GET_DATA_FORMAT_RESP), // 0x0021 -qmi_name_item(QMIWDS_ADMIN_SET_QMAP_SETTINGS_REQ), // 0x002B -qmi_name_item(QMIWDS_ADMIN_SET_QMAP_SETTINGS_RESP), // 0x002B -qmi_name_item(QMIWDS_ADMIN_GET_QMAP_SETTINGS_REQ), // 0x002C -qmi_name_item(QMIWDS_ADMIN_GET_QMAP_SETTINGS_RESP), // 0x002C -qmi_name_item(QMI_WDA_SET_LOOPBACK_CONFIG_REQ), // 0x002F -qmi_name_item(QMI_WDA_SET_LOOPBACK_CONFIG_RESP), // 0x002F -qmi_name_item(QMI_WDA_SET_LOOPBACK_CONFIG_IND), // 0x002F -}; - -static const QMI_NAME_T qmux_uim_Type[] = { -qmi_name_item( QMIUIM_READ_TRANSPARENT_REQ), // 0x0020 -qmi_name_item( QMIUIM_READ_TRANSPARENT_RESP), // 0x0020 -qmi_name_item( QMIUIM_READ_TRANSPARENT_IND), // 0x0020 -qmi_name_item( QMIUIM_READ_RECORD_REQ), // 0x0021 -qmi_name_item( QMIUIM_READ_RECORD_RESP), // 0x0021 -qmi_name_item( QMIUIM_READ_RECORD_IND), // 0x0021 -qmi_name_item( QMIUIM_WRITE_TRANSPARENT_REQ), // 0x0022 -qmi_name_item( QMIUIM_WRITE_TRANSPARENT_RESP), // 0x0022 -qmi_name_item( QMIUIM_WRITE_TRANSPARENT_IND), // 0x0022 -qmi_name_item( QMIUIM_WRITE_RECORD_REQ), // 0x0023 -qmi_name_item( QMIUIM_WRITE_RECORD_RESP), // 0x0023 -qmi_name_item( QMIUIM_WRITE_RECORD_IND), // 0x0023 -qmi_name_item( QMIUIM_SET_PIN_PROTECTION_REQ), // 0x0025 -qmi_name_item( QMIUIM_SET_PIN_PROTECTION_RESP), // 0x0025 -qmi_name_item( QMIUIM_SET_PIN_PROTECTION_IND), // 0x0025 -qmi_name_item( QMIUIM_VERIFY_PIN_REQ), // 0x0026 -qmi_name_item( QMIUIM_VERIFY_PIN_RESP), // 0x0026 -qmi_name_item( QMIUIM_VERIFY_PIN_IND), // 0x0026 -qmi_name_item( QMIUIM_UNBLOCK_PIN_REQ), // 0x0027 -qmi_name_item( QMIUIM_UNBLOCK_PIN_RESP), // 0x0027 -qmi_name_item( QMIUIM_UNBLOCK_PIN_IND), // 0x0027 -qmi_name_item( QMIUIM_CHANGE_PIN_REQ), // 0x0028 -qmi_name_item( QMIUIM_CHANGE_PIN_RESP), // 0x0028 -qmi_name_item( QMIUIM_CHANGE_PIN_IND), // 0x0028 -qmi_name_item( QMIUIM_DEPERSONALIZATION_REQ), // 0x0029 -qmi_name_item( QMIUIM_DEPERSONALIZATION_RESP), // 0x0029 -qmi_name_item( QMIUIM_EVENT_REG_REQ), // 0x002E -qmi_name_item( QMIUIM_EVENT_REG_RESP), // 0x002E -qmi_name_item( QMIUIM_GET_CARD_STATUS_REQ), // 0x002F -qmi_name_item( QMIUIM_GET_CARD_STATUS_RESP), // 0x002F -qmi_name_item( QMIUIM_STATUS_CHANGE_IND), // 0x0032 -}; - -static const QMI_NAME_T qmux_coex_Type[] = { -qmi_name_item(QMI_COEX_GET_WWAN_STATE_REQ), // 0x0022 -qmi_name_item(QMI_COEX_GET_WWAN_STATE_RESP), // 0x0022 -}; - -static const char * qmi_name_get(const QMI_NAME_T *table, size_t size, int type, const char *tag) { - static char unknow[40]; - size_t i; - - if (qmux_CtlFlags == table) { - if (!strcmp(tag, "_REQ")) - tag = "_CMD"; - else if (!strcmp(tag, "_RESP")) - tag = "_RSP"; - } - - for (i = 0; i < size; i++) { - if (table[i].type == (UINT)type) { - if (!tag || (strstr(table[i].name, tag))) - return table[i].name; - } - } - sprintf(unknow, "unknow_%x", type); - return unknow; -} - -#define QMI_NAME(table, type) qmi_name_get(table, sizeof(table) / sizeof(table[0]), type, 0) -#define QMUX_NAME(table, type, tag) qmi_name_get(table, sizeof(table) / sizeof(table[0]), type, tag) - -void dump_tlv(PQCQMUX_MSG_HDR pQMUXMsgHdr) { - int TLVFind = 0; - int i; - //dbg("QCQMUX_TLV-----------------------------------\n"); - //dbg("{Type,\tLength,\tValue}\n"); - - while (1) { - PQMI_TLV_HDR TLVHdr = GetTLV(pQMUXMsgHdr, 0x1000 + (++TLVFind)); - if (TLVHdr == NULL) - break; - - //if ((TLVHdr->TLVType == 0x02) && ((USHORT *)(TLVHdr+1))[0]) - { - dbg("{%02x,\t%04x,\t", TLVHdr->TLVType, le16_to_cpu(TLVHdr->TLVLength)); - for (i = 0; i < le16_to_cpu(TLVHdr->TLVLength); i++) { - dbg("%02x ", ((UCHAR *)(TLVHdr+1))[i]); - } - dbg("}\n"); - } - } // while -} - -void dump_ctl(PQCQMICTL_MSG_HDR CTLHdr) { - const char *tag; - - //dbg("QCQMICTL_MSG--------------------------------------------\n"); - //dbg("CtlFlags: %02x\t\t%s\n", CTLHdr->CtlFlags, QMI_NAME(qmi_ctl_CtlFlags, CTLHdr->CtlFlags)); - dbg("TransactionId: %02x\n", CTLHdr->TransactionId); - switch (CTLHdr->CtlFlags) { - case QMICTL_FLAG_REQUEST: tag = "_REQ"; break; - case QMICTL_FLAG_RESPONSE: tag = "_RESP"; break; - case QMICTL_FLAG_INDICATION: tag = "_IND"; break; - default: tag = 0; break; - } - dbg("QMICTLType: %04x\t%s\n", le16_to_cpu(CTLHdr->QMICTLType), - QMUX_NAME(qmux_ctl_QMICTLType, le16_to_cpu(CTLHdr->QMICTLType), tag)); - dbg("Length: %04x\n", le16_to_cpu(CTLHdr->Length)); - - dump_tlv((PQCQMUX_MSG_HDR)(&CTLHdr->QMICTLType)); -} - -int dump_qmux(QMI_SERVICE_TYPE serviceType, PQCQMUX_HDR QMUXHdr) { - PQCQMUX_MSG_HDR QMUXMsgHdr = (PQCQMUX_MSG_HDR) (QMUXHdr + 1); - const char *tag; - - //dbg("QCQMUX--------------------------------------------\n"); - switch (QMUXHdr->CtlFlags&QMUX_CTL_FLAG_MASK_TYPE) { - case QMUX_CTL_FLAG_TYPE_CMD: tag = "_REQ"; break; - case QMUX_CTL_FLAG_TYPE_RSP: tag = "_RESP"; break; - case QMUX_CTL_FLAG_TYPE_IND: tag = "_IND"; break; - default: tag = 0; break; - } - //dbg("CtlFlags: %02x\t\t%s\n", QMUXHdr->CtlFlags, QMUX_NAME(qmux_CtlFlags, QMUXHdr->CtlFlags, tag)); - dbg("TransactionId: %04x\n", le16_to_cpu(QMUXHdr->TransactionId)); - - //dbg("QCQMUX_MSG_HDR-----------------------------------\n"); - switch (serviceType) { - case QMUX_TYPE_DMS: - dbg("Type: %04x\t%s\n", le16_to_cpu(QMUXMsgHdr->Type), - QMUX_NAME(qmux_dms_Type, le16_to_cpu(QMUXMsgHdr->Type), tag)); - break; - case QMUX_TYPE_NAS: - dbg("Type: %04x\t%s\n", le16_to_cpu(QMUXMsgHdr->Type), - QMUX_NAME(qmux_nas_Type, le16_to_cpu(QMUXMsgHdr->Type), tag)); - break; - case QMUX_TYPE_WDS: - case QMUX_TYPE_WDS_IPV6: - dbg("Type: %04x\t%s\n", le16_to_cpu(QMUXMsgHdr->Type), - QMUX_NAME(qmux_wds_Type, le16_to_cpu(QMUXMsgHdr->Type), tag)); - break; - case QMUX_TYPE_WMS: - dbg("Type: %04x\t%s\n", le16_to_cpu(QMUXMsgHdr->Type), - QMUX_NAME(qmux_wms_Type, le16_to_cpu(QMUXMsgHdr->Type), tag)); - break; - case QMUX_TYPE_WDS_ADMIN: - dbg("Type: %04x\t%s\n", le16_to_cpu(QMUXMsgHdr->Type), - QMUX_NAME(qmux_wds_admin_Type, le16_to_cpu(QMUXMsgHdr->Type), tag)); - break; - case QMUX_TYPE_UIM: - dbg("Type: %04x\t%s\n", le16_to_cpu(QMUXMsgHdr->Type), - QMUX_NAME(qmux_uim_Type, le16_to_cpu(QMUXMsgHdr->Type), tag)); - break; - case QMUX_TYPE_PDS: - case QMUX_TYPE_QOS: - dbg("Type: %04x\t%s\n", le16_to_cpu(QMUXMsgHdr->Type), - QMUX_NAME(qmux_qos_Type, le16_to_cpu(QMUXMsgHdr->Type), tag)); - break; - case QMUX_TYPE_COEX: - dbg("Type: %04x\t%s\n", le16_to_cpu(QMUXMsgHdr->Type), - QMUX_NAME(qmux_coex_Type, le16_to_cpu(QMUXMsgHdr->Type), tag)); - break; - case QMUX_TYPE_CTL: - default: - dbg("Type: %04x\t%s\n", le16_to_cpu(QMUXMsgHdr->Type), "PDS/QOS/CTL/unknown!"); - break; - } - dbg("Length: %04x\n", le16_to_cpu(QMUXMsgHdr->Length)); - - dump_tlv(QMUXMsgHdr); - - return 0; -} - -void dump_qmi(void *dataBuffer, int dataLen) -{ - PQCQMI_HDR QMIHdr = (PQCQMI_HDR)dataBuffer; - PQCQMUX_HDR QMUXHdr = (PQCQMUX_HDR) (QMIHdr + 1); - PQCQMICTL_MSG_HDR CTLHdr = (PQCQMICTL_MSG_HDR) (QMIHdr + 1); - - int i; - - if (!debug_qmi) - return; - - pthread_mutex_lock(&dumpQMIMutex); - line[0] = 0; - for (i = 0; i < dataLen; i++) { - dbg("%02x ", ((unsigned char *)dataBuffer)[i]); - } - dbg_time("%s", line); - line[0] = 0; - - //dbg("QCQMI_HDR-----------------------------------------"); - //dbg("IFType: %02x\t\t%s", QMIHdr->IFType, QMI_NAME(qmi_IFType, QMIHdr->IFType)); - //dbg("Length: %04x", le16_to_cpu(QMIHdr->Length)); - //dbg("CtlFlags: %02x\t\t%s", QMIHdr->CtlFlags, QMI_NAME(qmi_CtlFlags, QMIHdr->CtlFlags)); - //dbg("QMIType: %02x\t\t%s", QMIHdr->QMIType, QMI_NAME(qmi_QMIType, QMIHdr->QMIType)); - //dbg("ClientId: %02x", QMIHdr->ClientId); - - if (QMIHdr->QMIType == QMUX_TYPE_CTL) { - dump_ctl(CTLHdr); - } else { - dump_qmux(QMIHdr->QMIType, QMUXHdr); - } - dbg_time("%s", line); - pthread_mutex_unlock(&dumpQMIMutex); -} diff --git a/quectel_cm_5G/src/MPQMUX.h b/quectel_cm_5G/src/MPQMUX.h deleted file mode 100644 index b7d7bc3..0000000 --- a/quectel_cm_5G/src/MPQMUX.h +++ /dev/null @@ -1,4273 +0,0 @@ -/*=========================================================================== - - M P Q M U X. H -DESCRIPTION: - - This file provides support for QMUX. - -INITIALIZATION AND SEQUENCING REQUIREMENTS: - -Copyright (C) 2011 by Qualcomm Technologies, Incorporated. All Rights Reserved. -===========================================================================*/ - -#ifndef MPQMUX_H -#define MPQMUX_H - -#include "MPQMI.h" - -#pragma pack(push, 1) - -#define QMIWDS_SET_EVENT_REPORT_REQ 0x0001 -#define QMIWDS_SET_EVENT_REPORT_RESP 0x0001 -#define QMIWDS_EVENT_REPORT_IND 0x0001 -#define QMIWDS_START_NETWORK_INTERFACE_REQ 0x0020 -#define QMIWDS_START_NETWORK_INTERFACE_RESP 0x0020 -#define QMIWDS_STOP_NETWORK_INTERFACE_REQ 0x0021 -#define QMIWDS_STOP_NETWORK_INTERFACE_RESP 0x0021 -#define QMIWDS_GET_PKT_SRVC_STATUS_REQ 0x0022 -#define QMIWDS_GET_PKT_SRVC_STATUS_RESP 0x0022 -#define QMIWDS_GET_PKT_SRVC_STATUS_IND 0x0022 -#define QMIWDS_GET_CURRENT_CHANNEL_RATE_REQ 0x0023 -#define QMIWDS_GET_CURRENT_CHANNEL_RATE_RESP 0x0023 -#define QMIWDS_GET_PKT_STATISTICS_REQ 0x0024 -#define QMIWDS_GET_PKT_STATISTICS_RESP 0x0024 -#define QMIWDS_CREATE_PROFILE_REQ 0x0027 -#define QMIWDS_CREATE_PROFILE_RESP 0x0027 -#define QMIWDS_MODIFY_PROFILE_SETTINGS_REQ 0x0028 -#define QMIWDS_MODIFY_PROFILE_SETTINGS_RESP 0x0028 -#define QMIWDS_GET_PROFILE_SETTINGS_REQ 0x002B -#define QMIWDS_GET_PROFILE_SETTINGS_RESP 0x002B -#define QMIWDS_GET_DEFAULT_SETTINGS_REQ 0x002C -#define QMIWDS_GET_DEFAULT_SETTINGS_RESP 0x002C -#define QMIWDS_GET_RUNTIME_SETTINGS_REQ 0x002D -#define QMIWDS_GET_RUNTIME_SETTINGS_RESP 0x002D -#define QMIWDS_GET_MIP_MODE_REQ 0x002F -#define QMIWDS_GET_MIP_MODE_RESP 0x002F -#define QMIWDS_GET_DATA_BEARER_REQ 0x0037 -#define QMIWDS_GET_DATA_BEARER_RESP 0x0037 -#define QMIWDS_DUN_CALL_INFO_REQ 0x0038 -#define QMIWDS_DUN_CALL_INFO_RESP 0x0038 -#define QMIWDS_DUN_CALL_INFO_IND 0x0038 -#define QMIWDS_SET_CLIENT_IP_FAMILY_PREF_REQ 0x004D -#define QMIWDS_SET_CLIENT_IP_FAMILY_PREF_RESP 0x004D -#define QMIWDS_SET_AUTO_CONNECT_REQ 0x0051 -#define QMIWDS_SET_AUTO_CONNECT_RESP 0x0051 -#define QMIWDS_BIND_MUX_DATA_PORT_REQ 0x00A2 -#define QMIWDS_BIND_MUX_DATA_PORT_RESP 0x00A2 - - -// Stats masks -#define QWDS_STAT_MASK_TX_PKT_OK 0x00000001 -#define QWDS_STAT_MASK_RX_PKT_OK 0x00000002 -#define QWDS_STAT_MASK_TX_PKT_ER 0x00000004 -#define QWDS_STAT_MASK_RX_PKT_ER 0x00000008 -#define QWDS_STAT_MASK_TX_PKT_OF 0x00000010 -#define QWDS_STAT_MASK_RX_PKT_OF 0x00000020 - -// TLV Types for xfer statistics -#define TLV_WDS_TX_GOOD_PKTS 0x10 -#define TLV_WDS_RX_GOOD_PKTS 0x11 -#define TLV_WDS_TX_ERROR 0x12 -#define TLV_WDS_RX_ERROR 0x13 -#define TLV_WDS_TX_OVERFLOW 0x14 -#define TLV_WDS_RX_OVERFLOW 0x15 -#define TLV_WDS_CHANNEL_RATE 0x16 -#define TLV_WDS_DATA_BEARER 0x17 -#define TLV_WDS_DORMANCY_STATUS 0x18 - -#define QWDS_PKT_DATA_UNKNOW 0x00 -#define QWDS_PKT_DATA_DISCONNECTED 0x01 -#define QWDS_PKT_DATA_CONNECTED 0x02 -#define QWDS_PKT_DATA_SUSPENDED 0x03 -#define QWDS_PKT_DATA_AUTHENTICATING 0x04 - -#define QMIWDS_ADMIN_SET_DATA_FORMAT_REQ 0x0020 -#define QMIWDS_ADMIN_SET_DATA_FORMAT_RESP 0x0020 -#define QMIWDS_ADMIN_GET_DATA_FORMAT_REQ 0x0021 -#define QMIWDS_ADMIN_GET_DATA_FORMAT_RESP 0x0021 -#define QMIWDS_ADMIN_SET_QMAP_SETTINGS_REQ 0x002B -#define QMIWDS_ADMIN_SET_QMAP_SETTINGS_RESP 0x002B -#define QMIWDS_ADMIN_GET_QMAP_SETTINGS_REQ 0x002C -#define QMIWDS_ADMIN_GET_QMAP_SETTINGS_RESP 0x002C -#define QMI_WDA_SET_LOOPBACK_CONFIG_REQ 0x002F -#define QMI_WDA_SET_LOOPBACK_CONFIG_RESP 0x002F -#define QMI_WDA_SET_LOOPBACK_CONFIG_IND 0x002F - -#define NETWORK_DESC_ENCODING_OCTET 0x00 -#define NETWORK_DESC_ENCODING_EXTPROTOCOL 0x01 -#define NETWORK_DESC_ENCODING_7BITASCII 0x02 -#define NETWORK_DESC_ENCODING_IA5 0x03 -#define NETWORK_DESC_ENCODING_UNICODE 0x04 -#define NETWORK_DESC_ENCODING_SHIFTJIS 0x05 -#define NETWORK_DESC_ENCODING_KOREAN 0x06 -#define NETWORK_DESC_ENCODING_LATINH 0x07 -#define NETWORK_DESC_ENCODING_LATIN 0x08 -#define NETWORK_DESC_ENCODING_GSM7BIT 0x09 -#define NETWORK_DESC_ENCODING_GSMDATA 0x0A -#define NETWORK_DESC_ENCODING_UNKNOWN 0xFF - -typedef struct _QMIWDS_ADMIN_SET_DATA_FORMAT -{ - USHORT Type; // QMUX type 0x0000 - USHORT Length; -} __attribute__ ((packed)) QMIWDS_ADMIN_SET_DATA_FORMAT, *PQMIWDS_ADMIN_SET_DATA_FORMAT; - -typedef struct _QMIWDS_ADMIN_SET_DATA_FORMAT_TLV_QOS -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR QOSSetting; -} __attribute__ ((packed)) QMIWDS_ADMIN_SET_DATA_FORMAT_TLV_QOS, *PQMIWDS_ADMIN_SET_DATA_FORMAT_TLV_QOS; - -typedef struct _QMIWDS_ADMIN_SET_DATA_FORMAT_TLV -{ - UCHAR TLVType; - USHORT TLVLength; - ULONG Value; -} __attribute__ ((packed)) QMIWDS_ADMIN_SET_DATA_FORMAT_TLV, *PQMIWDS_ADMIN_SET_DATA_FORMAT_TLV; - -typedef struct _QMIWDS_ENDPOINT_TLV -{ - UCHAR TLVType; - USHORT TLVLength; - ULONG ep_type; - ULONG iface_id; -} __attribute__ ((packed)) QMIWDS_ENDPOINT_TLV, *PQMIWDS_ENDPOINT_TLV; - -typedef struct _QMIWDS_ADMIN_SET_DATA_FORMAT_REQ_MSG -{ - USHORT Type; - USHORT Length; - QMIWDS_ADMIN_SET_DATA_FORMAT_TLV_QOS QosDataFormatTlv; - QMIWDS_ADMIN_SET_DATA_FORMAT_TLV UnderlyingLinkLayerProtocolTlv; - QMIWDS_ADMIN_SET_DATA_FORMAT_TLV UplinkDataAggregationProtocolTlv; - QMIWDS_ADMIN_SET_DATA_FORMAT_TLV DownlinkDataAggregationProtocolTlv; - QMIWDS_ADMIN_SET_DATA_FORMAT_TLV DownlinkDataAggregationMaxDatagramsTlv; - QMIWDS_ADMIN_SET_DATA_FORMAT_TLV DownlinkDataAggregationMaxSizeTlv; - QMIWDS_ENDPOINT_TLV epTlv; -#ifdef QUECTEL_UL_DATA_AGG - QMIWDS_ADMIN_SET_DATA_FORMAT_TLV DlMinimumPassingTlv; - QMIWDS_ADMIN_SET_DATA_FORMAT_TLV UplinkDataAggregationMaxDatagramsTlv; - QMIWDS_ADMIN_SET_DATA_FORMAT_TLV UplinkDataAggregationMaxSizeTlv; -#endif -} __attribute__ ((packed)) QMIWDS_ADMIN_SET_DATA_FORMAT_REQ_MSG, *PQMIWDS_ADMIN_SET_DATA_FORMAT_REQ_MSG; - -typedef struct _QMI_U8_TLV -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR TLVVaule; -} __attribute__ ((packed)) QMI_U8_TLV, *PQMI_U8_TLV; - -typedef struct _QMI_U32_TLV -{ - UCHAR TLVType; - USHORT TLVLength; - ULONG TLVVaule; -} __attribute__ ((packed)) QMI_U32_TLV, *PQMI_U32_TLV; - -typedef struct _QMI_WDA_SET_LOOPBACK_CONFIG_REQ_MSG { - USHORT Type; - USHORT Length; - QMI_U8_TLV loopback_state; //0x01 - QMI_U32_TLV replication_factor; //0x10 -} __attribute__ ((packed)) QMI_WDA_SET_LOOPBACK_CONFIG_REQ_MSG, *PQMI_WDA_SET_LOOPBACK_CONFIG_REQ_MSG; - -typedef struct _QMI_WDA_SET_LOOPBACK_CONFIG_IND_MSG -{ - USHORT Type; - USHORT Length; - QMI_U8_TLV loopback_state; //0x01 - QMI_U32_TLV replication_factor; //0x10 -} __attribute__ ((packed)) QMI_WDA_SET_LOOPBACK_CONFIG_IND_MSG, *PQMI_WDA_SET_LOOPBACK_CONFIG_IND_MSG; - -#if 0 -typedef enum _QMI_RETURN_CODES { - QMI_SUCCESS = 0, - QMI_SUCCESS_NOT_COMPLETE, - QMI_FAILURE -}QMI_RETURN_CODES; - -typedef struct _QMIWDS_GET_PKT_SRVC_STATUS_REQ_MSG -{ - USHORT Type; // 0x0022 - USHORT Length; // 0x0000 -} QMIWDS_GET_PKT_SRVC_STATUS_REQ_MSG, *PQMIWDS_GET_PKT_SRVC_STATUS_REQ_MSG; - -typedef struct _QMIWDS_GET_PKT_SRVC_STATUS_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; - UCHAR TLVType2; - USHORT TLVLength2; - UCHAR ConnectionStatus; // 0x01: QWDS_PKT_DATAC_DISCONNECTED - // 0x02: QWDS_PKT_DATA_CONNECTED - // 0x03: QWDS_PKT_DATA_SUSPENDED - // 0x04: QWDS_PKT_DATA_AUTHENTICATING -} QMIWDS_GET_PKT_SRVC_STATUS_RESP_MSG, *PQMIWDS_GET_PKT_SRVC_STATUS_RESP_MSG; - -typedef struct _QMIWDS_GET_PKT_SRVC_STATUS_IND_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - UCHAR ConnectionStatus; // 0x01: QWDS_PKT_DATAC_DISCONNECTED - // 0x02: QWDS_PKT_DATA_CONNECTED - // 0x03: QWDS_PKT_DATA_SUSPENDED - UCHAR ReconfigRequired; // 0x00: No need to reconfigure - // 0x01: Reconfiguration required -} QMIWDS_GET_PKT_SRVC_STATUS_IND_MSG, *PQMIWDS_GET_PKT_SRVC_STATUS_IND_MSG; - -typedef struct _WDS_PKT_SRVC_IP_FAMILY_TLV -{ - UCHAR TLVType; // 0x12 - USHORT TLVLength; // 1 - UCHAR IpFamily; // IPV4-0x04, IPV6-0x06 -} WDS_PKT_SRVC_IP_FAMILY_TLV, *PWDS_PKT_SRVC_IP_FAMILY_TLV; - -typedef struct _QMIWDS_DUN_CALL_INFO_REQ_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - ULONG Mask; - UCHAR TLV2Type; - USHORT TLV2Length; - UCHAR ReportConnectionStatus; -} QMIWDS_DUN_CALL_INFO_REQ_MSG, *PQMIWDS_DUN_CALL_INFO_REQ_MSG; - -typedef struct _QMIWDS_DUN_CALL_INFO_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; -} QMIWDS_DUN_CALL_INFO_RESP_MSG, *PQMIWDS_DUN_CALL_INFO_RESP_MSG; - -typedef struct _QMIWDS_DUN_CALL_INFO_IND_MSG -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR ConnectionStatus; -} QMIWDS_DUN_CALL_INFO_IND_MSG, *PQMIWDS_DUN_CALL_INFO_IND_MSG; - -typedef struct _QMIWDS_GET_CURRENT_CHANNEL_RATE_REQ_MSG -{ - USHORT Type; // QMUX type 0x0040 - USHORT Length; -} QMIWDS_GET_CURRENT_CHANNEL_RATE_REQ_MSG, *PQMIWDS_GET_CURRENT_CHANNEL_RATE_REQ_MSG; - -typedef struct _QMIWDS_GET_CURRENT_CHANNEL_RATE_RESP_MSG -{ - USHORT Type; // QMUX type 0x0040 - USHORT Length; - UCHAR TLVType; // 0x02 - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT - - UCHAR TLV2Type; // 0x01 - USHORT TLV2Length; // 16 - //ULONG CallHandle; // Context corresponding to reported channel - ULONG CurrentTxRate; // bps - ULONG CurrentRxRate; // bps - ULONG ServingSystemTxRate; // bps - ULONG ServingSystemRxRate; // bps - -} QMIWDS_GET_CURRENT_CHANNEL_RATE_RESP_MSG, *PQMIWDS_GET_CURRENT_CHANNEL_RATE_RESP; - -#define QWDS_EVENT_REPORT_MASK_RATES 0x01 -#define QWDS_EVENT_REPORT_MASK_STATS 0x02 - -#ifdef QCUSB_MUX_PROTOCOL -#error code not present -#endif // QCUSB_MUX_PROTOCOL - -typedef struct _QMIWDS_SET_EVENT_REPORT_REQ_MSG -{ - USHORT Type; // QMUX type 0x0042 - USHORT Length; - - UCHAR TLVType; // 0x10 -- current channel rate indicator - USHORT TLVLength; // 1 - UCHAR Mode; // 0-do not report; 1-report when rate changes - - UCHAR TLV2Type; // 0x11 - USHORT TLV2Length; // 5 - UCHAR StatsPeriod; // seconds between reports; 0-do not report - ULONG StatsMask; // - - UCHAR TLV3Type; // 0x12 -- current data bearer indicator - USHORT TLV3Length; // 1 - UCHAR Mode3; // 0-do not report; 1-report when changes - - UCHAR TLV4Type; // 0x13 -- dormancy status indicator - USHORT TLV4Length; // 1 - UCHAR DormancyStatus; // 0-do not report; 1-report when changes -} QMIWDS_SET_EVENT_REPORT_REQ_MSG, *PQMIWDS_SET_EVENT_REPORT_REQ_MSG; - -typedef struct _QMIWDS_SET_EVENT_REPORT_RESP_MSG -{ - USHORT Type; // QMUX type 0x0042 - USHORT Length; - - UCHAR TLVType; // 0x02 result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_NO_BATTERY - // QMI_ERR_FAULT -} QMIWDS_SET_EVENT_REPORT_RESP_MSG, *PQMIWDS_SET_EVENT_REPORT_RESP_MSG; - -typedef struct _QMIWDS_EVENT_REPORT_IND_MSG -{ - USHORT Type; // QMUX type 0x0001 - USHORT Length; -} QMIWDS_EVENT_REPORT_IND_MSG, *PQMIWDS_EVENT_REPORT_IND_MSG; - -// PQCTLV_PKT_STATISTICS - -typedef struct _QMIWDS_EVENT_REPORT_IND_CHAN_RATE_TLV -{ - UCHAR Type; - USHORT Length; // 8 - ULONG TxRate; - ULONG RxRate; -} QMIWDS_EVENT_REPORT_IND_CHAN_RATE_TLV, *PQMIWDS_EVENT_REPORT_IND_CHAN_RATE_TLV; - -#ifdef QCUSB_MUX_PROTOCOL -#error code not present -#endif // QCUSB_MUX_PROTOCOL - -typedef struct _QMIWDS_GET_PKT_STATISTICS_REQ_MSG -{ - USHORT Type; // QMUX type 0x0041 - USHORT Length; - UCHAR TLVType; // 0x01 - USHORT TLVLength; // 4 - ULONG StateMask; // 0x00000001 tx success packets - // 0x00000002 rx success packets - // 0x00000004 rx packet errors (checksum) - // 0x00000008 rx packets dropped (memory) - -} QMIWDS_GET_PKT_STATISTICS_REQ_MSG, *PQMIWDS_GET_PKT_STATISTICS_REQ_MSG; - -typedef struct _QMIWDS_GET_PKT_STATISTICS_RESP_MSG -{ - USHORT Type; // QMUX type 0x0041 - USHORT Length; - UCHAR TLVType; // 0x02 - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT -} QMIWDS_GET_PKT_STATISTICS_RESP_MSG, *PQMIWDS_GET_PKT_STATISTICS_RESP_MSG; - -// optional TLV for stats -typedef struct _QCTLV_PKT_STATISTICS -{ - UCHAR TLVType; // see above definitions for TLV types - USHORT TLVLength; // 4 - ULONG Count; -} QCTLV_PKT_STATISTICS, *PQCTLV_PKT_STATISTICS; -#endif - -//#ifdef QC_IP_MODE - -/* - ?Bit 0 ?Profile identifier - ?Bit 1 ?Profile name - ?Bit 2 ?PDP type - ?Bit 3 ?APN name - ?Bit 4 ?DNS address - ?Bit 5 ?UMTS/GPRS granted QoS - ?Bit 6 ?Username - ?Bit 7 ?Authentication Protocol - ?Bit 8 ?IP address - ?Bit 9 ?Gateway information (address and subnet mask) - ?Bit 10 ?PCSCF address using a PCO flag - ?Bit 11 ?PCSCF server address list - ?Bit 12 ?PCSCF domain name list - ?Bit 13 ?MTU - ?Bit 14 ?Domain name list - ?Bit 15 ?IP family - ?Bit 16 ?IM_CM flag - ?Bit 17 ?Technology name - ?Bit 18 ?Operator reserved PCO -*/ -#define QMIWDS_GET_RUNTIME_SETTINGS_MASK_IPV4DNS_ADDR (1 << 4) -#define QMIWDS_GET_RUNTIME_SETTINGS_MASK_IPV4_ADDR (1 << 8) -#define QMIWDS_GET_RUNTIME_SETTINGS_MASK_IPV4GATEWAY_ADDR (1 << 9) -#define QMIWDS_GET_RUNTIME_SETTINGS_MASK_MTU (1 << 13) -#define QMIWDS_GET_RUNTIME_SETTINGS_MASK_PCSCF_SV_ADDR (1 << 11) -#define QMIWDS_GET_RUNTIME_SETTINGS_MASK_PCSCF_DOM_NAME (1 << 14) - -typedef struct _QMIWDS_GET_RUNTIME_SETTINGS_REQ_MSG -{ - USHORT Type; // QMIWDS_GET_RUNTIME_SETTINGS_REQ - USHORT Length; - UCHAR TLVType; // 0x10 - USHORT TLVLength; // 0x0004 - ULONG Mask; // mask, bit 8: IP addr -- 0x0100 -} __attribute__ ((packed)) QMIWDS_GET_RUNTIME_SETTINGS_REQ_MSG, *PQMIWDS_GET_RUNTIME_SETTINGS_REQ_MSG; - -typedef struct _QMIWDS_BIND_MUX_DATA_PORT_REQ_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - ULONG ep_type; - ULONG iface_id; - UCHAR TLV2Type; - USHORT TLV2Length; - UCHAR MuxId; - UCHAR TLV3Type; - USHORT TLV3Length; - ULONG client_type; -} __attribute__ ((packed)) QMIWDS_BIND_MUX_DATA_PORT_REQ_MSG, *PQMIWDS_BIND_MUX_DATA_PORT_REQ_MSG; - -#define QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV4PRIMARYDNS 0x15 -#define QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV4SECONDARYDNS 0x16 -#define QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV4 0x1E -#define QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV4GATEWAY 0x20 -#define QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV4SUBNET 0x21 - -#define QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV6 0x25 -#define QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV6GATEWAY 0x26 -#define QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV6PRIMARYDNS 0x27 -#define QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV6SECONDARYDNS 0x28 -#define QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_MTU 0x29 - -typedef struct _QMIWDS_GET_RUNTIME_SETTINGS_TLV_MTU -{ - UCHAR TLVType; // QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_MTU - USHORT TLVLength; // 4 - ULONG Mtu; // MTU -} __attribute__ ((packed)) QMIWDS_GET_RUNTIME_SETTINGS_TLV_MTU, *PQMIWDS_GET_RUNTIME_SETTINGS_TLV_MTU; - -typedef struct _QMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV4_ADDR -{ - UCHAR TLVType; // QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV4 - USHORT TLVLength; // 4 - ULONG IPV4Address; // address -} __attribute__ ((packed)) QMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV4_ADDR, *PQMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV4_ADDR; - -typedef struct _QMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV6_ADDR -{ - UCHAR TLVType; // QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV6 - USHORT TLVLength; // 16 - UCHAR IPV6Address[16]; // address - UCHAR PrefixLength; // prefix length -} __attribute__ ((packed)) QMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV6_ADDR, *PQMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV6_ADDR; - -typedef struct _QMIWDS_GET_RUNNING_SETTINGS_PCSCF_IPV6_ADDR -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR PCSCFNumber; -} __attribute__ ((packed)) QMIWDS_GET_RUNNING_SETTINGS_PCSCF_IPV6_ADDR, *PQMIWDS_GET_RUNNING_SETTINGS_PCSCF_IPV6_ADDR; - -typedef struct _QMIWDS_GET_RUNNING_SETTINGS_PCSCF_IPV4_ADDR -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR PCSCFNumber; -} __attribute__ ((packed)) QMIWDS_GET_RUNNING_SETTINGS_PCSCF_IPV4_ADDR, *PQMIWDS_GET_RUNNING_SETTINGS_PCSCF_IPV4_ADDR; - -typedef struct _QMIWDS_GET_RUNTIME_SETTINGS_RESP_MSG -{ - USHORT Type; // QMIWDS_GET_RUNTIME_SETTINGS_RESP - USHORT Length; - UCHAR TLVType; // QCTLV_TYPE_RESULT_CODE - USHORT TLVLength; // 0x0004 - USHORT QMUXResult; // result code - USHORT QMUXError; // error code -} __attribute__ ((packed)) QMIWDS_GET_RUNTIME_SETTINGS_RESP_MSG, *PQMIWDS_GET_RUNTIME_SETTINGS_RESP_MSG; - -//#endif // QC_IP_MODE - -typedef struct _QMIWDS_IP_FAMILY_TLV -{ - UCHAR TLVType; // 0x12 - USHORT TLVLength; // 1 - UCHAR IpFamily; // IPV4-0x04, IPV6-0x06 -} __attribute__ ((packed)) QMIWDS_IP_FAMILY_TLV, *PQMIWDS_IP_FAMILY_TLV; - -typedef struct _QMIWDS_PKT_SRVC_TLV -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR ConnectionStatus; - UCHAR ReconfigReqd; -} __attribute__ ((packed)) QMIWDS_PKT_SRVC_TLV, *PQMIWDS_PKT_SRVC_TLV; - -typedef struct _QMIWDS_CALL_END_REASON_TLV -{ - UCHAR TLVType; - USHORT TLVLength; - USHORT CallEndReason; -} __attribute__ ((packed)) QMIWDS_CALL_END_REASON_TLV, *PQMIWDS_CALL_END_REASON_TLV; - -typedef struct _QMIWDS_CALL_END_REASON_V_TLV -{ - UCHAR TLVType; - USHORT TLVLength; - USHORT CallEndReasonType; - USHORT CallEndReason; -} __attribute__ ((packed)) QMIWDS_CALL_END_REASON_V_TLV, *PQMIWDS_CALL_END_REASON_V_TLV; - -typedef struct _QMIWDS_SET_CLIENT_IP_FAMILY_PREF_REQ_MSG -{ - USHORT Type; // QMUX type 0x004D - USHORT Length; - UCHAR TLVType; // 0x01 - USHORT TLVLength; // 1 - UCHAR IpPreference; // IPV4-0x04, IPV6-0x06 -} __attribute__ ((packed)) QMIWDS_SET_CLIENT_IP_FAMILY_PREF_REQ_MSG, *PQMIWDS_SET_CLIENT_IP_FAMILY_PREF_REQ_MSG; - -typedef struct _QMIWDS_SET_CLIENT_IP_FAMILY_PREF_RESP_MSG -{ - USHORT Type; // QMUX type 0x0037 - USHORT Length; - UCHAR TLVType; // 0x02 - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS, QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INTERNAL, QMI_ERR_MALFORMED_MSG, QMI_ERR_INVALID_ARG -} __attribute__ ((packed)) QMIWDS_SET_CLIENT_IP_FAMILY_PREF_RESP_MSG, *PQMIWDS_SET_CLIENT_IP_FAMILY_PREF_RESP_MSG; - -typedef struct _QMIWDS_SET_AUTO_CONNECT_REQ_MSG -{ - USHORT Type; // QMUX type 0x0051 - USHORT Length; - UCHAR TLVType; // 0x01 - USHORT TLVLength; // 1 - UCHAR autoconnect_setting; // 0x00 ?C Disabled, 0x01 ?C Enabled, 0x02 ?C Paused (resume on power cycle) -} __attribute__ ((packed)) QMIWDS_SET_AUTO_CONNECT_REQ_MSG, *PQMIWDS_SET_AUTO_CONNECT_REQ_MSG; - -#if 0 -typedef struct _QMIWDS_GET_MIP_MODE_REQ_MSG -{ - USHORT Type; // QMUX type 0x0040 - USHORT Length; -} QMIWDS_GET_MIP_MODE_REQ_MSG, *PQMIWDS_GET_MIP_MODE_REQ_MSG; - -typedef struct _QMIWDS_GET_MIP_MODE_RESP_MSG -{ - USHORT Type; // QMUX type 0x0040 - USHORT Length; - UCHAR TLVType; // 0x02 - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT - - UCHAR TLV2Type; // 0x01 - USHORT TLV2Length; // 20 - UCHAR MipMode; // -} QMIWDS_GET_MIP_MODE_RESP_MSG, *PQMIWDS_GET_MIP_MODE_RESP_MSG; -#endif - -typedef struct _QMIWDS_TECHNOLOGY_PREFERECE -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR TechPreference; -} __attribute__ ((packed)) QMIWDS_TECHNOLOGY_PREFERECE, *PQMIWDS_TECHNOLOGY_PREFERECE; - -typedef struct _QMIWDS_PROFILE_IDENTIFIER -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR ProfileIndex; -} __attribute__ ((packed)) QMIWDS_PROFILE_IDENTIFIER, *PQMIWDS_PROFILE_IDENTIFIER; - -#if 0 -typedef struct _QMIWDS_IPADDRESS -{ - UCHAR TLVType; - USHORT TLVLength; - ULONG IPv4Address; -}QMIWDS_IPADDRESS, *PQMIWDS_IPADDRESS; - -/* -typedef struct _QMIWDS_UMTS_QOS -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR TrafficClass; - ULONG MaxUplinkBitRate; - ULONG MaxDownlinkBitRate; - ULONG GuarUplinkBitRate; - ULONG GuarDownlinkBitRate; - UCHAR QOSDevOrder; - ULONG MAXSDUSize; - UCHAR SDUErrorRatio; - UCHAR ResidualBerRatio; - UCHAR DeliveryErrorSDUs; - ULONG TransferDelay; - ULONG TrafficHndPri; -}QMIWDS_UMTS_QOS, *PQMIWDS_UMTS_QOS; - -typedef struct _QMIWDS_GPRS_QOS -{ - UCHAR TLVType; - USHORT TLVLength; - ULONG PrecedenceClass; - ULONG DelayClass; - ULONG ReliabilityClass; - ULONG PeekThroClass; - ULONG MeanThroClass; -}QMIWDS_GPRS_QOS, *PQMIWDS_GPRS_QOS; -*/ -#endif - -typedef struct _QMIWDS_PROFILENAME -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR ProfileName; -} __attribute__ ((packed)) QMIWDS_PROFILENAME, *PQMIWDS_PROFILENAME; - -typedef struct _QMIWDS_PDPTYPE -{ - UCHAR TLVType; - USHORT TLVLength; -// 0 ?C PDP-IP (IPv4) -// 1 ?C PDP-PPP -// 2 ?C PDP-IPv6 -// 3 ?C PDP-IPv4v6 - UCHAR PdpType; -} __attribute__ ((packed)) QMIWDS_PDPTYPE, *PQMIWDS_PDPTYPE; - -typedef struct _QMIWDS_USERNAME -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR UserName; -} __attribute__ ((packed)) QMIWDS_USERNAME, *PQMIWDS_USERNAME; - -typedef struct _QMIWDS_PASSWD -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR Passwd; -} __attribute__ ((packed)) QMIWDS_PASSWD, *PQMIWDS_PASSWD; - -typedef struct _QMIWDS_AUTH_PREFERENCE -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR AuthPreference; -} __attribute__ ((packed)) QMIWDS_AUTH_PREFERENCE, *PQMIWDS_AUTH_PREFERENCE; - -typedef struct _QMIWDS_IPTYPE -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR IPType; -} __attribute__ ((packed)) QMIWDS_IPTYPE, *PQMIWDS_IPTYPE; - -typedef struct _QMIWDS_APNNAME -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR ApnName; -} __attribute__ ((packed)) QMIWDS_APNNAME, *PQMIWDS_APNNAME; - -typedef struct _QMIWDS_AUTOCONNECT -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR AutoConnect; -} __attribute__ ((packed)) QMIWDS_AUTOCONNECT, *PQMIWDS_AUTOCONNECT; - -typedef struct _QMIWDS_START_NETWORK_INTERFACE_REQ_MSG -{ - USHORT Type; - USHORT Length; -} __attribute__ ((packed)) QMIWDS_START_NETWORK_INTERFACE_REQ_MSG, *PQMIWDS_START_NETWORK_INTERFACE_REQ_MSG; - -typedef struct _QMIWDS_CALLENDREASON -{ - UCHAR TLVType; - USHORT TLVLength; - USHORT Reason; -}__attribute__ ((packed)) QMIWDS_CALLENDREASON, *PQMIWDS_CALLENDREASON; - -typedef struct _QMIWDS_START_NETWORK_INTERFACE_RESP_MSG -{ - USHORT Type; // QMUX type 0x0040 - USHORT Length; - UCHAR TLVType; // 0x02 - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT - - UCHAR TLV2Type; // 0x01 - USHORT TLV2Length; // 20 - ULONG Handle; // -} __attribute__ ((packed)) QMIWDS_START_NETWORK_INTERFACE_RESP_MSG, *PQMIWDS_START_NETWORK_INTERFACE_RESP_MSG; - -typedef struct _QMIWDS_STOP_NETWORK_INTERFACE_REQ_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - ULONG Handle; -} __attribute__ ((packed)) QMIWDS_STOP_NETWORK_INTERFACE_REQ_MSG, *PQMIWDS_STOP_NETWORK_INTERFACE_REQ_MSG; - -typedef struct _QMIWDS_STOP_NETWORK_INTERFACE_RESP_MSG -{ - USHORT Type; // QMUX type 0x0040 - USHORT Length; - UCHAR TLVType; // 0x02 - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT - -} __attribute__ ((packed)) QMIWDS_STOP_NETWORK_INTERFACE_RESP_MSG, *PQMIWDS_STOP_NETWORK_INTERFACE_RESP_MSG; - -typedef struct _QMIWDS_GET_DEFAULT_SETTINGS_REQ_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - UCHAR ProfileType; -} __attribute__ ((packed)) QMIWDS_GET_DEFAULT_SETTINGS_REQ_MSG, *PQMIWDS_GET_DEFAULT_SETTINGS_REQ_MSG; - -typedef struct _QMIWDS_GET_DEFAULT_SETTINGS_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; -} __attribute__ ((packed)) QMIWDS_GET_DEFAULT_SETTINGS_RESP_MSG, *PQMIWDS_GET_DEFAULT_SETTINGS_RESP_MSG; - -typedef struct _QMIWDS_MODIFY_PROFILE_SETTINGS_REQ_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - UCHAR ProfileType; - UCHAR ProfileIndex; -} __attribute__ ((packed)) QMIWDS_MODIFY_PROFILE_SETTINGS_REQ_MSG, *PQMIWDS_MODIFY_PROFILE_SETTINGS_REQ_MSG; - -typedef struct _QMIWDS_MODIFY_PROFILE_SETTINGS_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; -} __attribute__ ((packed)) QMIWDS_MODIFY_PROFILE_SETTINGS_RESP_MSG, *PQMIWDS_MODIFY_PROFILE_SETTINGS_RESP_MSG; - -typedef struct _QMIWDS_GET_PROFILE_SETTINGS_REQ_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - UCHAR ProfileType; - UCHAR ProfileIndex; -} __attribute__ ((packed)) QMIWDS_GET_PROFILE_SETTINGS_REQ_MSG, *PQMIWDS_GET_PROFILE_SETTINGS_REQ_MSG; - -typedef struct _QMIWDS_CREATE_PROFILE_SETTINGS_REQ_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - UCHAR ProfileType; - UCHAR TLV2Type; //0x25 - USHORT TLV2Length; - UCHAR pdp_context; -} __attribute__ ((packed)) QMIWDS_CREATE_PROFILE_SETTINGS_REQ_MSG, *PQMIWDS_CREATE_PROFILE_SETTINGS_REQ_MSG; - -#if 0 -typedef struct _QMIWDS_EVENT_REPORT_IND_DATA_BEARER_TLV -{ - UCHAR Type; - USHORT Length; - UCHAR DataBearer; -} QMIWDS_EVENT_REPORT_IND_DATA_BEARER_TLV, *PQMIWDS_EVENT_REPORT_IND_DATA_BEARER_TLV; - -typedef struct _QMIWDS_EVENT_REPORT_IND_DORMANCY_STATUS_TLV -{ - UCHAR Type; - USHORT Length; - UCHAR DormancyStatus; -} QMIWDS_EVENT_REPORT_IND_DORMANCY_STATUS_TLV, *PQMIWDS_EVENT_REPORT_IND_DORMANCY_STATUS_TLV; - - -typedef struct _QMIWDS_GET_DATA_BEARER_REQ_MSG -{ - USHORT Type; // QMUX type 0x0037 - USHORT Length; -} QMIWDS_GET_DATA_BEARER_REQ_MSG, *PQMIWDS_GET_DATA_BEARER_REQ_MSG; - -typedef struct _QMIWDS_GET_DATA_BEARER_RESP_MSG -{ - USHORT Type; // QMUX type 0x0037 - USHORT Length; - UCHAR TLVType; // 0x02 - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INTERNAL - // QMI_ERR_MALFORMED_MSG - // QMI_ERR_NO_MEMORY - // QMI_ERR_OUT_OF_CALL - // QMI_ERR_INFO_UNAVAILABLE - UCHAR TLV2Type; // 0x01 - USHORT TLV2Length; // - UCHAR Technology; // -} QMIWDS_GET_DATA_BEARER_RESP_MSG, *PQMIWDS_GET_DATA_BEARER_RESP_MSG; -#endif - -// ======================= DMS ============================== -#define QMIDMS_SET_EVENT_REPORT_REQ 0x0001 -#define QMIDMS_SET_EVENT_REPORT_RESP 0x0001 -#define QMIDMS_EVENT_REPORT_IND 0x0001 -#define QMIDMS_GET_DEVICE_CAP_REQ 0x0020 -#define QMIDMS_GET_DEVICE_CAP_RESP 0x0020 -#define QMIDMS_GET_DEVICE_MFR_REQ 0x0021 -#define QMIDMS_GET_DEVICE_MFR_RESP 0x0021 -#define QMIDMS_GET_DEVICE_MODEL_ID_REQ 0x0022 -#define QMIDMS_GET_DEVICE_MODEL_ID_RESP 0x0022 -#define QMIDMS_GET_DEVICE_REV_ID_REQ 0x0023 -#define QMIDMS_GET_DEVICE_REV_ID_RESP 0x0023 -#define QMIDMS_GET_MSISDN_REQ 0x0024 -#define QMIDMS_GET_MSISDN_RESP 0x0024 -#define QMIDMS_GET_DEVICE_SERIAL_NUMBERS_REQ 0x0025 -#define QMIDMS_GET_DEVICE_SERIAL_NUMBERS_RESP 0x0025 -#define QMIDMS_UIM_SET_PIN_PROTECTION_REQ 0x0027 -#define QMIDMS_UIM_SET_PIN_PROTECTION_RESP 0x0027 -#define QMIDMS_UIM_VERIFY_PIN_REQ 0x0028 -#define QMIDMS_UIM_VERIFY_PIN_RESP 0x0028 -#define QMIDMS_UIM_UNBLOCK_PIN_REQ 0x0029 -#define QMIDMS_UIM_UNBLOCK_PIN_RESP 0x0029 -#define QMIDMS_UIM_CHANGE_PIN_REQ 0x002A -#define QMIDMS_UIM_CHANGE_PIN_RESP 0x002A -#define QMIDMS_UIM_GET_PIN_STATUS_REQ 0x002B -#define QMIDMS_UIM_GET_PIN_STATUS_RESP 0x002B -#define QMIDMS_GET_DEVICE_HARDWARE_REV_REQ 0x002C -#define QMIDMS_GET_DEVICE_HARDWARE_REV_RESP 0x002C -#define QMIDMS_GET_OPERATING_MODE_REQ 0x002D -#define QMIDMS_GET_OPERATING_MODE_RESP 0x002D -#define QMIDMS_SET_OPERATING_MODE_REQ 0x002E -#define QMIDMS_SET_OPERATING_MODE_RESP 0x002E -#define QMIDMS_GET_ACTIVATED_STATUS_REQ 0x0031 -#define QMIDMS_GET_ACTIVATED_STATUS_RESP 0x0031 -#define QMIDMS_ACTIVATE_AUTOMATIC_REQ 0x0032 -#define QMIDMS_ACTIVATE_AUTOMATIC_RESP 0x0032 -#define QMIDMS_ACTIVATE_MANUAL_REQ 0x0033 -#define QMIDMS_ACTIVATE_MANUAL_RESP 0x0033 -#define QMIDMS_UIM_GET_ICCID_REQ 0x003C -#define QMIDMS_UIM_GET_ICCID_RESP 0x003C -#define QMIDMS_UIM_GET_CK_STATUS_REQ 0x0040 -#define QMIDMS_UIM_GET_CK_STATUS_RESP 0x0040 -#define QMIDMS_UIM_SET_CK_PROTECTION_REQ 0x0041 -#define QMIDMS_UIM_SET_CK_PROTECTION_RESP 0x0041 -#define QMIDMS_UIM_UNBLOCK_CK_REQ 0x0042 -#define QMIDMS_UIM_UNBLOCK_CK_RESP 0x0042 -#define QMIDMS_UIM_GET_IMSI_REQ 0x0043 -#define QMIDMS_UIM_GET_IMSI_RESP 0x0043 -#define QMIDMS_UIM_GET_STATE_REQ 0x0044 -#define QMIDMS_UIM_GET_STATE_RESP 0x0044 -#define QMIDMS_GET_BAND_CAP_REQ 0x0045 -#define QMIDMS_GET_BAND_CAP_RESP 0x0045 - -#if 0 -typedef struct _QMIDMS_GET_DEVICE_MFR_REQ_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; -} QMIDMS_GET_DEVICE_MFR_REQ_MSG, *PQMIDMS_GET_DEVICE_MFR_REQ_MSG; - -typedef struct _QMIDMS_GET_DEVICE_MFR_RESP_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT - UCHAR TLV2Type; // 0x01 - required parameter - USHORT TLV2Length; // length of the mfr string - UCHAR DeviceManufacturer; // first byte of string -} QMIDMS_GET_DEVICE_MFR_RESP_MSG, *PQMIDMS_GET_DEVICE_MFR_RESP_MSG; - -typedef struct _QMIDMS_GET_DEVICE_MODEL_ID_REQ_MSG -{ - USHORT Type; // QMUX type 0x0004 - USHORT Length; -} QMIDMS_GET_DEVICE_MODEL_ID_REQ_MSG, *PQMIDMS_GET_DEVICE_MODEL_ID_REQ_MSG; - -typedef struct _QMIDMS_GET_DEVICE_MODEL_ID_RESP_MSG -{ - USHORT Type; // QMUX type 0x0004 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT - UCHAR TLV2Type; // 0x01 - required parameter - USHORT TLV2Length; // length of the modem id string - UCHAR DeviceModelID; // device model id -} QMIDMS_GET_DEVICE_MODEL_ID_RESP_MSG, *PQMIDMS_GET_DEVICE_MODEL_ID_RESP_MSG; -#endif - -typedef struct _QMIDMS_GET_DEVICE_REV_ID_REQ_MSG -{ - USHORT Type; // QMUX type 0x0005 - USHORT Length; -} __attribute__ ((packed)) QMIDMS_GET_DEVICE_REV_ID_REQ_MSG, *PQMIDMS_GET_DEVICE_REV_ID_REQ_MSG; - -typedef struct _DEVICE_REV_ID -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR RevisionID; -} __attribute__ ((packed)) DEVICE_REV_ID, *PDEVICE_REV_ID; - -#if 0 -typedef struct _QMIDMS_GET_DEVICE_REV_ID_RESP_MSG -{ - USHORT Type; // QMUX type 0x0023 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT -} QMIDMS_GET_DEVICE_REV_ID_RESP_MSG, *PQMIDMS_GET_DEVICE_REV_ID_RESP_MSG; - -typedef struct _QMIDMS_GET_MSISDN_REQ_MSG -{ - USHORT Type; // QMUX type 0x0024 - USHORT Length; -} QMIDMS_GET_MSISDN_REQ_MSG, *PQMIDMS_GET_MSISDN_REQ_MSG; - -typedef struct _QCTLV_DEVICE_VOICE_NUMBERS -{ - UCHAR TLVType; // as defined above - USHORT TLVLength; // 4/7/7 - UCHAR VoideNumberString; // ESN, IMEI, or MEID - -} QCTLV_DEVICE_VOICE_NUMBERS, *PQCTLV_DEVICE_VOICE_NUMBERS; - - -typedef struct _QMIDMS_GET_MSISDN_RESP_MSG -{ - USHORT Type; // QMUX type 0x0024 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG -} QMIDMS_GET_MSISDN_RESP_MSG, *PQMIDMS_GET_MSISDN_RESP_MSG; -#endif - -typedef struct _QMIDMS_UIM_GET_IMSI_REQ_MSG -{ - USHORT Type; - USHORT Length; -} __attribute__ ((packed)) QMIDMS_UIM_GET_IMSI_REQ_MSG, *PQMIDMS_UIM_GET_IMSI_REQ_MSG; - -typedef struct _QMIDMS_UIM_GET_IMSI_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; - UCHAR TLV2Type; - USHORT TLV2Length; - UCHAR IMSI; -} __attribute__ ((packed)) QMIDMS_UIM_GET_IMSI_RESP_MSG, *PQMIDMS_UIM_GET_IMSI_RESP_MSG; - -#if 0 -typedef struct _QMIDMS_GET_DEVICE_SERIAL_NUMBERS_REQ_MSG -{ - USHORT Type; // QMUX type 0x0007 - USHORT Length; -} QMIDMS_GET_DEVICE_SERIAL_NUMBERS_REQ_MSG, *PQMIDMS_GET_DEVICE_SERIAL_NUMBERS_REQ_MSG; - -#define QCTLV_TYPE_SER_NUM_ESN 0x10 -#define QCTLV_TYPE_SER_NUM_IMEI 0x11 -#define QCTLV_TYPE_SER_NUM_MEID 0x12 - -typedef struct _QCTLV_DEVICE_SERIAL_NUMBER -{ - UCHAR TLVType; // as defined above - USHORT TLVLength; // 4/7/7 - UCHAR SerialNumberString; // ESN, IMEI, or MEID - -} QCTLV_DEVICE_SERIAL_NUMBER, *PQCTLV_DEVICE_SERIAL_NUMBER; - -typedef struct _QMIDMS_GET_DEVICE_SERIAL_NUMBERS_RESP_MSG -{ - USHORT Type; // QMUX type 0x0007 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT - // followed by optional TLV -} QMIDMS_GET_DEVICE_SERIAL_NUMBERS_RESP_MSG, *PQMIDMS_GET_DEVICE_SERIAL_NUMBERS_RESP; - -typedef struct _QMIDMS_GET_DMS_BAND_CAP -{ - USHORT Type; - USHORT Length; -} QMIDMS_GET_BAND_CAP_REQ_MSG, *PQMIDMS_GET_BAND_CAP_REQ_MSG; - -typedef struct _QMIDMS_GET_BAND_CAP_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_NONE - // QMI_ERR_INTERNAL - // QMI_ERR_MALFORMED_MSG - // QMI_ERR_NO_MEMORY - - UCHAR TLV2Type; // 0x01 - USHORT TLV2Length; // 2 - ULONG64 BandCap; -} QMIDMS_GET_BAND_CAP_RESP_MSG, *PQMIDMS_GET_BAND_CAP_RESP; - -typedef struct _QMIDMS_GET_DEVICE_CAP_REQ_MSG -{ - USHORT Type; // QMUX type 0x0002 - USHORT Length; -} QMIDMS_GET_DEVICE_CAP_REQ_MSG, *PQMIDMS_GET_DEVICE_CAP_REQ_MSG; - -typedef struct _QMIDMS_GET_DEVICE_CAP_RESP_MSG -{ - USHORT Type; // QMUX type 0x0002 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMUX_RESULT_SUCCESS - // QMUX_RESULT_FAILURE - USHORT QMUXError; // QMUX_ERR_INVALID_ARG - // QMUX_ERR_NO_MEMORY - // QMUX_ERR_INTERNAL - // QMUX_ERR_FAULT - UCHAR TLV2Type; // 0x01 - USHORT TLV2Length; // 2 - - ULONG MaxTxChannelRate; - ULONG MaxRxChannelRate; - UCHAR VoiceCap; - UCHAR SimCap; - - UCHAR RadioIfListCnt; // #elements in radio interface list - UCHAR RadioIfList; // N 1-byte elements -} QMIDMS_GET_DEVICE_CAP_RESP_MSG, *PQMIDMS_GET_DEVICE_CAP_RESP_MSG; - -typedef struct _QMIDMS_GET_ACTIVATED_STATUS_REQ_MSG -{ - USHORT Type; // QMUX type 0x0002 - USHORT Length; -} QMIDMS_GET_ACTIVATED_STATUS_REQ_MSG, *PQMIDMS_GET_ACTIVATES_STATUD_REQ_MSG; - -typedef struct _QMIDMS_GET_ACTIVATED_STATUS_RESP_MSG -{ - USHORT Type; // QMUX type 0x0002 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMUX_RESULT_SUCCESS - // QMUX_RESULT_FAILURE - USHORT QMUXError; // QMUX_ERR_INVALID_ARG - // QMUX_ERR_NO_MEMORY - // QMUX_ERR_INTERNAL - // QMUX_ERR_FAULT - UCHAR TLV2Type; // 0x01 - USHORT TLV2Length; // 2 - - USHORT ActivatedStatus; -} QMIDMS_GET_ACTIVATED_STATUS_RESP_MSG, *PQMIDMS_GET_ACTIVATED_STATUS_RESP_MSG; - -typedef struct _QMIDMS_GET_OPERATING_MODE_REQ_MSG -{ - USHORT Type; // QMUX type 0x0002 - USHORT Length; -} QMIDMS_GET_OPERATING_MODE_REQ_MSG, *PQMIDMS_GET_OPERATING_MODE_REQ_MSG; - -typedef struct _OFFLINE_REASON -{ - UCHAR TLVType; - USHORT TLVLength; - USHORT OfflineReason; -} OFFLINE_REASON, *POFFLINE_REASON; - -typedef struct _HARDWARE_RESTRICTED_MODE -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR HardwareControlledMode; -} HARDWARE_RESTRICTED_MODE, *PHARDWARE_RESTRICTED_MODE; - -typedef struct _QMIDMS_GET_OPERATING_MODE_RESP_MSG -{ - USHORT Type; // QMUX type 0x0002 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMUX_RESULT_SUCCESS - // QMUX_RESULT_FAILURE - USHORT QMUXError; // QMUX_ERR_INVALID_ARG - // QMUX_ERR_NO_MEMORY - // QMUX_ERR_INTERNAL - // QMUX_ERR_FAULT - UCHAR TLV2Type; // 0x01 - USHORT TLV2Length; // 2 - - UCHAR OperatingMode; -} QMIDMS_GET_OPERATING_MODE_RESP_MSG, *PQMIDMS_GET_OPERATING_MODE_RESP_MSG; - -typedef struct _QMIDMS_UIM_GET_ICCID_REQ_MSG -{ - USHORT Type; // QMUX type 0x0024 - USHORT Length; -} QMIDMS_UIM_GET_ICCID_REQ_MSG, *PQMIDMS_UIM_GET_ICCID_REQ_MSG; - -typedef struct _QMIDMS_UIM_GET_ICCID_RESP_MSG -{ - USHORT Type; // QMUX type 0x0024 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT - UCHAR TLV2Type; // 0x01 - required parameter - USHORT TLV2Length; // var - UCHAR ICCID; // String of voice number -} QMIDMS_UIM_GET_ICCID_RESP_MSG, *PQMIDMS_UIM_GET_ICCID_RESP_MSG; -#endif - -typedef struct _QMIDMS_SET_OPERATING_MODE_REQ_MSG -{ - USHORT Type; // QMUX type 0x0002 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - UCHAR OperatingMode; -} __attribute__ ((packed)) QMIDMS_SET_OPERATING_MODE_REQ_MSG, *PQMIDMS_SET_OPERATING_MODE_REQ_MSG; - -typedef struct _QMIDMS_SET_OPERATING_MODE_RESP_MSG -{ - USHORT Type; // QMUX type 0x0002 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMUX_RESULT_SUCCESS - // QMUX_RESULT_FAILURE - USHORT QMUXError; // QMUX_ERR_INVALID_ARG - // QMUX_ERR_NO_MEMORY - // QMUX_ERR_INTERNAL - // QMUX_ERR_FAULT -} __attribute__ ((packed)) QMIDMS_SET_OPERATING_MODE_RESP_MSG, *PQMIDMS_SET_OPERATING_MODE_RESP_MSG; - -#if 0 -typedef struct _QMIDMS_ACTIVATE_AUTOMATIC_REQ_MSG -{ - USHORT Type; // QMUX type 0x0024 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // - UCHAR ActivateCodelen; - UCHAR ActivateCode; -} QMIDMS_ACTIVATE_AUTOMATIC_REQ_MSG, *PQMIDMS_ACTIVATE_AUTOMATIC_REQ_MSG; - -typedef struct _QMIDMS_ACTIVATE_AUTOMATIC_RESP_MSG -{ - USHORT Type; // QMUX type 0x0024 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT -} QMIDMS_ACTIVATE_AUTOMATIC_RESP_MSG, *PQMIDMS_ACTIVATE_AUTOMATIC_RESP_MSG; - - -typedef struct _SPC_MSG -{ - UCHAR SPC[6]; - USHORT SID; -} SPC_MSG, *PSPC_MSG; - -typedef struct _MDN_MSG -{ - UCHAR MDNLEN; - UCHAR MDN; -} MDN_MSG, *PMDN_MSG; - -typedef struct _MIN_MSG -{ - UCHAR MINLEN; - UCHAR MIN; -} MIN_MSG, *PMIN_MSG; - -typedef struct _PRL_MSG -{ - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // - USHORT PRLLEN; - UCHAR PRL; -} PRL_MSG, *PPRL_MSG; - -typedef struct _MN_HA_KEY_MSG -{ - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // - UCHAR MN_HA_KEY_LEN; - UCHAR MN_HA_KEY; -} MN_HA_KEY_MSG, *PMN_HA_KEY_MSG; - -typedef struct _MN_AAA_KEY_MSG -{ - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // - UCHAR MN_AAA_KEY_LEN; - UCHAR MN_AAA_KEY; -} MN_AAA_KEY_MSG, *PMN_AAA_KEY_MSG; - -typedef struct _QMIDMS_ACTIVATE_MANUAL_REQ_MSG -{ - USHORT Type; // QMUX type 0x0024 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // - UCHAR Value; -} QMIDMS_ACTIVATE_MANUAL_REQ_MSG, *PQMIDMS_ACTIVATE_MANUAL_REQ_MSG; - -typedef struct _QMIDMS_ACTIVATE_MANUAL_RESP_MSG -{ - USHORT Type; // QMUX type 0x0024 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT -} QMIDMS_ACTIVATE_MANUAL_RESP_MSG, *PQMIDMS_ACTIVATE_MANUAL_RESP_MSG; -#endif - -typedef struct _QMIDMS_UIM_GET_STATE_REQ_MSG -{ - USHORT Type; - USHORT Length; -} __attribute__ ((packed)) QMIDMS_UIM_GET_STATE_REQ_MSG, *PQMIDMS_UIM_GET_STATE_REQ_MSG; - -typedef struct _QMIDMS_UIM_GET_STATE_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; - UCHAR TLV2Type; - USHORT TLV2Length; - UCHAR UIMState; -} __attribute__ ((packed)) QMIDMS_UIM_GET_STATE_RESP_MSG, *PQMIDMS_UIM_GET_STATE_RESP_MSG; - -typedef struct _QMIDMS_UIM_GET_PIN_STATUS_REQ_MSG -{ - USHORT Type; // QMUX type 0x0024 - USHORT Length; -} __attribute__ ((packed)) QMIDMS_UIM_GET_PIN_STATUS_REQ_MSG, *PQMIDMS_UIM_GET_PIN_STATUS_REQ_MSG; - -typedef struct _QMIDMS_UIM_PIN_STATUS -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR PINStatus; - UCHAR PINVerifyRetriesLeft; - UCHAR PINUnblockRetriesLeft; -} __attribute__ ((packed)) QMIDMS_UIM_PIN_STATUS, *PQMIDMS_UIM_PIN_STATUS; - -#define QMI_PIN_STATUS_NOT_INIT 0 -#define QMI_PIN_STATUS_NOT_VERIF 1 -#define QMI_PIN_STATUS_VERIFIED 2 -#define QMI_PIN_STATUS_DISABLED 3 -#define QMI_PIN_STATUS_BLOCKED 4 -#define QMI_PIN_STATUS_PERM_BLOCKED 5 -#define QMI_PIN_STATUS_UNBLOCKED 6 -#define QMI_PIN_STATUS_CHANGED 7 - - -typedef struct _QMIDMS_UIM_GET_PIN_STATUS_RESP_MSG -{ - USHORT Type; // QMUX type 0x0024 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT - UCHAR PinStatus; -} __attribute__ ((packed)) QMIDMS_UIM_GET_PIN_STATUS_RESP_MSG, *PQMIDMS_UIM_GET_PIN_STATUS_RESP_MSG; - -#if 0 -typedef struct _QMIDMS_UIM_GET_CK_STATUS_REQ_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - UCHAR Facility; -} QMIDMS_UIM_GET_CK_STATUS_REQ_MSG, *PQMIDMS_UIM_GET_CK_STATUS_REQ_MSG; - - -typedef struct _QMIDMS_UIM_CK_STATUS -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR FacilityStatus; - UCHAR FacilityVerifyRetriesLeft; - UCHAR FacilityUnblockRetriesLeft; -} QMIDMS_UIM_CK_STATUS, *PQMIDMS_UIM_CK_STATUS; - -typedef struct _QMIDMS_UIM_CK_OPERATION_STATUS -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR OperationBlocking; -} QMIDMS_UIM_CK_OPERATION_STATUS, *PQMIDMS_UIM_CK_OPERATION_STATUS; - -typedef struct _QMIDMS_UIM_GET_CK_STATUS_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; - UCHAR CkStatus; -} QMIDMS_UIM_GET_CK_STATUS_RESP_MSG, *PQMIDMS_UIM_GET_CK_STATUS_RESP_MSG; -#endif - -typedef struct _QMIDMS_UIM_VERIFY_PIN_REQ_MSG -{ - USHORT Type; // QMUX type 0x0024 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - UCHAR PINID; - UCHAR PINLen; - UCHAR PINValue; -} __attribute__ ((packed)) QMIDMS_UIM_VERIFY_PIN_REQ_MSG, *PQMIDMS_UIM_VERIFY_PIN_REQ_MSG; - -typedef struct _QMIDMS_UIM_VERIFY_PIN_RESP_MSG -{ - USHORT Type; // QMUX type 0x0024 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT - UCHAR TLV2Type; - USHORT TLV2Length; - UCHAR PINVerifyRetriesLeft; - UCHAR PINUnblockRetriesLeft; -} __attribute__ ((packed)) QMIDMS_UIM_VERIFY_PIN_RESP_MSG, *PQMIDMS_UIM_VERIFY_PIN_RESP_MSG; - -#if 0 -typedef struct _QMIDMS_UIM_SET_PIN_PROTECTION_REQ_MSG -{ - USHORT Type; // QMUX type 0x0024 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - UCHAR PINID; - UCHAR ProtectionSetting; - UCHAR PINLen; - UCHAR PINValue; -} QMIDMS_UIM_SET_PIN_PROTECTION_REQ_MSG, *PQMIDMS_UIM_SET_PIN_PROTECTION_REQ_MSG; - -typedef struct _QMIDMS_UIM_SET_PIN_PROTECTION_RESP_MSG -{ - USHORT Type; // QMUX type 0x0024 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT - UCHAR TLV2Type; - USHORT TLV2Length; - UCHAR PINVerifyRetriesLeft; - UCHAR PINUnblockRetriesLeft; -} QMIDMS_UIM_SET_PIN_PROTECTION_RESP_MSG, *PQMIDMS_UIM_SET_PIN_PROTECTION_RESP_MSG; - -typedef struct _QMIDMS_UIM_SET_CK_PROTECTION_REQ_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - UCHAR Facility; - UCHAR FacilityState; - UCHAR FacliltyLen; - UCHAR FacliltyValue; -} QMIDMS_UIM_SET_CK_PROTECTION_REQ_MSG, *PQMIDMS_UIM_SET_CK_PROTECTION_REQ_MSG; - -typedef struct _QMIDMS_UIM_SET_CK_PROTECTION_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; - UCHAR TLV2Type; - USHORT TLV2Length; - UCHAR FacilityRetriesLeft; -} QMIDMS_UIM_SET_CK_PROTECTION_RESP_MSG, *PQMIDMS_UIM_SET_CK_PROTECTION_RESP_MSG; - - -typedef struct _UIM_PIN -{ - UCHAR PinLength; - UCHAR PinValue; -} UIM_PIN, *PUIM_PIN; - -typedef struct _QMIDMS_UIM_CHANGE_PIN_REQ_MSG -{ - USHORT Type; // QMUX type 0x0024 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - UCHAR PINID; - UCHAR PinDetails; -} QMIDMS_UIM_CHANGE_PIN_REQ_MSG, *PQMIDMS_UIM_CHANGE_PIN_REQ_MSG; - -typedef struct QMIDMS_UIM_CHANGE_PIN_RESP_MSG -{ - USHORT Type; // QMUX type 0x0024 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT - UCHAR TLV2Type; - USHORT TLV2Length; - UCHAR PINVerifyRetriesLeft; - UCHAR PINUnblockRetriesLeft; -} QMIDMS_UIM_CHANGE_PIN_RESP_MSG, *PQMIDMS_UIM_CHANGE_PIN_RESP_MSG; - -typedef struct _UIM_PUK -{ - UCHAR PukLength; - UCHAR PukValue; -} UIM_PUK, *PUIM_PUK; - -typedef struct _QMIDMS_UIM_UNBLOCK_PIN_REQ_MSG -{ - USHORT Type; // QMUX type 0x0024 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - UCHAR PINID; - UCHAR PinDetails; -} QMIDMS_UIM_UNBLOCK_PIN_REQ_MSG, *PQMIDMS_UIM_BLOCK_PIN_REQ_MSG; - -typedef struct QMIDMS_UIM_UNBLOCK_PIN_RESP_MSG -{ - USHORT Type; // QMUX type 0x0024 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT - UCHAR TLV2Type; - USHORT TLV2Length; - UCHAR PINVerifyRetriesLeft; - UCHAR PINUnblockRetriesLeft; -} QMIDMS_UIM_UNBLOCK_PIN_RESP_MSG, *PQMIDMS_UIM_UNBLOCK_PIN_RESP_MSG; - -typedef struct _QMIDMS_UIM_UNBLOCK_CK_REQ_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - UCHAR Facility; - UCHAR FacliltyUnblockLen; - UCHAR FacliltyUnblockValue; -} QMIDMS_UIM_UNBLOCK_CK_REQ_MSG, *PQMIDMS_UIM_BLOCK_CK_REQ_MSG; - -typedef struct QMIDMS_UIM_UNBLOCK_CK_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; - UCHAR TLV2Type; - USHORT TLV2Length; - UCHAR FacilityUnblockRetriesLeft; -} QMIDMS_UIM_UNBLOCK_CK_RESP_MSG, *PQMIDMS_UIM_UNBLOCK_CK_RESP_MSG; - -typedef struct _QMIDMS_SET_EVENT_REPORT_REQ_MSG -{ - USHORT Type; - USHORT Length; -} QMIDMS_SET_EVENT_REPORT_REQ_MSG, *PQMIDMS_SET_EVENT_REPORT_REQ_MSG; - -typedef struct _QMIDMS_SET_EVENT_REPORT_RESP_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG -} QMIDMS_SET_EVENT_REPORT_RESP_MSG, *PQMIDMS_SET_EVENT_REPORT_RESP_MSG; - -typedef struct _PIN_STATUS -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR ReportPinState; -} PIN_STATUS, *PPIN_STATUS; - -typedef struct _POWER_STATUS -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR PowerStatus; - UCHAR BatteryLvl; -} POWER_STATUS, *PPOWER_STATUS; - -typedef struct _ACTIVATION_STATE -{ - UCHAR TLVType; - USHORT TLVLength; - USHORT ActivationState; -} ACTIVATION_STATE, *PACTIVATION_STATE; - -typedef struct _ACTIVATION_STATE_REQ -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR ActivationState; -} ACTIVATION_STATE_REQ, *PACTIVATION_STATE_REQ; - -typedef struct _OPERATING_MODE -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR OperatingMode; -} OPERATING_MODE, *POPERATING_MODE; - -typedef struct _UIM_STATE -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR UIMState; -} UIM_STATE, *PUIM_STATE; - -typedef struct _WIRELESS_DISABLE_STATE -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR WirelessDisableState; -} WIRELESS_DISABLE_STATE, *PWIRELESS_DISABLE_STATE; - -typedef struct _QMIDMS_EVENT_REPORT_IND_MSG -{ - USHORT Type; - USHORT Length; -} QMIDMS_EVENT_REPORT_IND_MSG, *PQMIDMS_EVENT_REPORT_IND_MSG; -#endif - -// ============================ END OF DMS =============================== - -// ======================= QOS ============================== -typedef struct _MPIOC_DEV_INFO MPIOC_DEV_INFO, *PMPIOC_DEV_INFO; - -#define QMI_QOS_SET_EVENT_REPORT_REQ 0x0001 -#define QMI_QOS_SET_EVENT_REPORT_RESP 0x0001 -#define QMI_QOS_SET_EVENT_REPORT_IND 0x0001 -#define QMI_QOS_BIND_DATA_PORT_REQ 0x002B -#define QMI_QOS_BIND_DATA_PORT_RESP 0x002B -#define QMI_QOS_INDICATION_REGISTER_REQ 0x002F -#define QMI_QOS_INDICATION_REGISTER_RESP 0x002F -#define QMI_QOS_GLOBAL_QOS_FLOW_IND 0x0031 -#define QMI_QOS_GET_QOS_INFO_REQ 0x0033 -#define QMI_QOS_GET_QOS_INFO_RESP 0x0033 - - -#if 1 -typedef struct _QMI_QOS_SET_EVENT_REPORT_REQ_MSG -{ - USHORT Type; // QMUX type 0x0001 - USHORT Length; - // UCHAR TLVType; // 0x01 - physical link state - // USHORT TLVLength; // 1 - // UCHAR PhyLinkStatusRpt; // 0-enable; 1-disable - UCHAR TLVType2; // 0x02 = global flow reporting - USHORT TLVLength2; // 1 - UCHAR GlobalFlowRpt; // 1-enable; 0-disable -} QMI_QOS_SET_EVENT_REPORT_REQ_MSG, *PQMI_QOS_SET_EVENT_REPORT_REQ_MSG; - -typedef struct _QMI_QOS_SET_EVENT_REPORT_RESP_MSG -{ - USHORT Type; // QMUX type 0x0010 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMUX_RESULT_SUCCESS - // QMUX_RESULT_FAILURE - USHORT QMUXError; // QMUX_ERR_INVALID_ARG - // QMUX_ERR_NO_MEMORY - // QMUX_ERR_INTERNAL - // QMUX_ERR_FAULT -} QMI_QOS_SET_EVENT_REPORT_RESP_MSG, *PQMI_QOS_SET_EVENT_REPORT_RESP_MSG; - -typedef struct _QMI_QOS_SET_EVENT_REPORT_IND_MSG -{ - USHORT Type; // QMUX type 0x0001 - USHORT Length; - UCHAR TLVs; -} QMI_QOS_SET_EVENT_REPORT_IND_MSG, *PQMI_QOS_SET_EVENT_REPORT_IND_MSG; - - -typedef struct _QMI_QOS_BIND_DATA_PORT_TLV_EP_ID -{ - UCHAR TLVType; //0x10 - USHORT TLVLength; - ULONG ep_type; - ULONG iface_id; -} __attribute__ ((packed)) QMI_QOS_BIND_DATA_PORT_TLV_EP_ID, *PQMI_QOS_BIND_DATA_PORT_TLV_EP_ID; - -typedef struct _QMI_QOS_BIND_DATA_PORT_TLV_MUX_ID -{ - UCHAR TLVType; //0x11 - USHORT TLVLength; - UCHAR mux_id; -} __attribute__ ((packed)) QMI_QOS_BIND_DATA_PORT_TLV_MUX_ID, *PQMI_QOS_BIND_DATA_PORT_TLV_MUX_ID; - -typedef struct _QMI_QOS_BIND_DATA_PORT_TLV_DATA_PORT -{ - UCHAR TLVType; //0x12 - USHORT TLVLength; - USHORT data_port; -} __attribute__ ((packed)) QMI_QOS_BIND_DATA_PORT_TLV_DATA_PORT, *PQMI_QOS_BIND_DATA_PORT_TLV_DATA_PORT; - -typedef struct _QMI_QOS_BIND_DATA_PORT_REQ_MSG -{ - USHORT Type; - USHORT Length; - QMI_QOS_BIND_DATA_PORT_TLV_EP_ID EpIdTlv; - QMI_QOS_BIND_DATA_PORT_TLV_MUX_ID MuxIdTlv; - //QMI_QOS_BIND_DATA_PORT_TLV_DATA_PORT DataPortTlv; -} __attribute__ ((packed)) QMI_QOS_BIND_DATA_PORT_REQ_MSG, *PQMI_QOS_BIND_DATA_PORT_REQ_MSG; - -typedef struct _QMI_QOS_BIND_DATA_PORT_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; //0x02 - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; -} __attribute__ ((packed)) QMI_QOS_BIND_DATA_PORT_RESP_MSG, *PQMI_QOS_BIND_DATA_PORT_RESP_MSG; - -typedef struct _QMI_QOS_INDICATION_REGISTER_TLV_REPORT_GLOBAL_QOS_FLOW -{ - UCHAR TLVType; //0x10 - USHORT TLVLength; - UCHAR report_global_qos_flows; -} __attribute__ ((packed)) QMI_QOS_INDICATION_REGISTER_TLV_REPORT_GLOBAL_QOS_FLOW, *PQMI_QOS_INDICATION_REGISTER_TLV_REPORT_GLOBAL_QOS_FLOW; - -typedef struct _QMI_QOS_INDICATION_REGISTER_TLV_SUPPRESS_REPORT_FLOW_CTL -{ - UCHAR TLVType; //0x11 - USHORT TLVLength; - UCHAR suppress_report_flow_control; -} __attribute__ ((packed)) QMI_QOS_INDICATION_REGISTER_TLV_SUPPRESS_REPORT_FLOW_CTL, *PQMI_QOS_INDICATION_REGISTER_TLV_SUPPRESS_REPORT_FLOW_CTL; - -typedef struct _QMI_QOS_INDICATION_REGISTER_TLV_SUPPRESS_NW_STATUS_IND -{ - UCHAR TLVType; //0x12 - USHORT TLVLength; - UCHAR suppress_network_status_ind; -} __attribute__ ((packed)) QMI_QOS_INDICATION_REGISTER_TLV_SUPPRESS_NW_STATUS_IND, *PQMI_QOS_INDICATION_REGISTER_TLV_SUPPRESS_NW_STATUS_IND; - -typedef struct _QMI_QOS_INDICATION_REGISTER_REQ_MSG -{ - USHORT Type; - USHORT Length; - QMI_QOS_INDICATION_REGISTER_TLV_REPORT_GLOBAL_QOS_FLOW ReportGlobalQosFlowTlv; - //QMI_QOS_INDICATION_REGISTER_TLV_SUPPRESS_REPORT_FLOW_CTL SuppressReportFlowCtlTlv; - //QMI_QOS_INDICATION_REGISTER_TLV_SUPPRESS_NW_STATUS_IND SuppressNWStatusIndTlv; -} __attribute__ ((packed)) QMI_QOS_INDICATION_REGISTER_REQ_MSG, *PQMI_QOS_INDICATION_REGISTER_REQ_MSG; - -typedef struct _QMI_QOS_INDICATION_REGISTER_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; //0x02 - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; -} __attribute__ ((packed)) QMI_QOS_INDICATION_REGISTER_RESP_MSG, *PQMI_QOS_INDICATION_REGISTER_RESP_MSG; - -typedef struct _QMI_QOS_GLOBAL_QOS_FLOW_TLV_FLOW_STATE -{ - UCHAR TLVType; //0x01 - USHORT TLVLength; - ULONG qos_id; - UCHAR new_flow; - ULONG state_change; -} __attribute__ ((packed)) QMI_QOS_GLOBAL_QOS_FLOW_TLV_FLOW_STATE, *PQMI_QOS_GLOBAL_QOS_FLOW_TLV_FLOW_STATE; - -typedef struct _QMI_QOS_GLOBAL_QOS_FLOW_TLV_FLOW_GRANTED -{ - UCHAR TLVType; //0x10 0x11 - USHORT TLVLength; - ULONG64 flow_valid_params; - ULONG ip_flow_trf_cls; - ULONG64 data_rate_max; - ULONG64 guaranteed_rate; - ULONG peak_rate; - ULONG token_rate; - ULONG bucket_size; - ULONG ip_flow_latency; - ULONG ip_flow_jitter; - USHORT ip_flow_pkt_error_rate_multiplier; - USHORT ip_flow_pkt_error_rate_exponent; - ULONG ip_flow_min_policed_packet_size; - ULONG ip_flow_max_allowed_packet_size; - ULONG ip_flow_3gpp_residual_bit_error_rate; - ULONG ip_flow_3gpp_traffic_handling_priority; - USHORT ip_flow_3gpp2_profile_id; - UCHAR ip_flow_3gpp2_flow_priority; - UCHAR ip_flow_3gpp_im_cn_flag; - UCHAR ip_flow_3gpp_sig_ind; - ULONG ip_flow_lte_qci; -} __attribute__ ((packed)) QMI_QOS_GLOBAL_QOS_FLOW_TLV_FLOW_GRANTED, *PQMI_QOS_GLOBAL_QOS_FLOW_TLV_FLOW_GRANTED; - -typedef struct _QMI_QOS_GLOBAL_QOS_FLOW_TLV_FILTER -{ - UCHAR TLVType; //0x12 0x13 - USHORT TLVLength; - UCHAR tx_rx_qos_filter_len; - UCHAR ip_version; - ULONG64 valid_params0; - ULONG ipv4_addr0; - ULONG subnet_mask0; - ULONG ipv4_addr1; - ULONG subnet_mask1; - UCHAR val4; - UCHAR mask4; - ULONG64 valid_params01; - UCHAR ipv6_address00; - UCHAR ipv6_address01; - UCHAR ipv6_address02; - UCHAR ipv6_address03; - UCHAR ipv6_address04; - UCHAR ipv6_address05; - UCHAR ipv6_address06; - UCHAR ipv6_address07; - UCHAR ipv6_address08; - UCHAR ipv6_address09; - UCHAR ipv6_address010; - UCHAR ipv6_address011; - UCHAR ipv6_address012; - UCHAR ipv6_address013; - UCHAR ipv6_address014; - ULONG ipv6_address015; - UCHAR prefix_len0; - UCHAR ipv6_address10; - UCHAR ipv6_address11; - UCHAR ipv6_address12; - UCHAR ipv6_address13; - UCHAR ipv6_address14; - UCHAR ipv6_address15; - UCHAR ipv6_address16; - UCHAR ipv6_address17; - UCHAR ipv6_address18; - UCHAR ipv6_address19; - UCHAR ipv6_address110; - UCHAR ipv6_address111; - UCHAR ipv6_address112; - UCHAR ipv6_address113; - UCHAR ipv6_address114; - ULONG ipv6_address115; - UCHAR prefix_len1; - UCHAR val6; - UCHAR mask6; - ULONG flow_label; - ULONG xport_protocol; - ULONG64 valid_params2; - USHORT port0; - USHORT range0; - USHORT port1; - USHORT range1; - ULONG64 valid_params3; - USHORT port2; - USHORT range2; - USHORT port3; - USHORT range3; - ULONG64 valid_params4; - UCHAR type; - UCHAR code; - ULONG64 valid_params5; - ULONG spi0; - ULONG64 valid_params6; - ULONG spi1; - USHORT filter_id; - USHORT filter_precedence; -} __attribute__ ((packed)) QMI_QOS_GLOBAL_QOS_FLOW_TLV_FILTER, *PQMI_QOS_GLOBAL_QOS_FLOW_TLV_FILTER; - -typedef struct _QMI_QOS_GLOBAL_QOS_FLOW_TLV_FLOW_TYPE -{ - UCHAR TLVType; //0x14 - USHORT TLVLength; - ULONG flow_type; -} __attribute__ ((packed)) QMI_QOS_GLOBAL_QOS_FLOW_TLV_FLOW_TYPE, *PQMI_QOS_GLOBAL_QOS_FLOW_TLV_FLOW_TYPE; - -typedef struct _QMI_QOS_GLOBAL_QOS_FLOW_TLV_BEARER_ID -{ - UCHAR TLVType; //0x15 - USHORT TLVLength; - UCHAR bearer_id; -} __attribute__ ((packed)) QMI_QOS_GLOBAL_QOS_FLOW_TLV_BEARER_ID, *PQMI_QOS_GLOBAL_QOS_FLOW_TLV_BEARER_ID; - -typedef struct _QMI_QOS_GLOBAL_QOS_FLOW_TLV_FLOW_CTL_SEQ_NUM -{ - UCHAR TLVType; //0x16 - USHORT TLVLength; - USHORT fc_seq_num; -} __attribute__ ((packed)) QMI_QOS_GLOBAL_QOS_FLOW_TLV_FLOW_CTL_SEQ_NUM, *PQMI_QOS_GLOBAL_QOS_FLOW_TLV_FLOW_CTL_SEQ_NUM; - -typedef struct _QMI_QOS_GLOBAL_QOS_FLOW_TLV_5G_QCI -{ - UCHAR TLVType; //0x17 0x18 - USHORT TLVLength; - ULONG tx_rx_5g_qci; -} __attribute__ ((packed)) QMI_QOS_GLOBAL_QOS_FLOW_TLV_5G_QCI, *PQMI_QOS_GLOBAL_QOS_FLOW_TLV_5G_QCI; - -typedef struct _QMI_QOS_GLOBAL_QOS_FLOW_TLV_AVG_WINDOW -{ - UCHAR TLVType; //0x19 0x1A - USHORT TLVLength; - USHORT tx_rx_avg_window; -} __attribute__ ((packed)) QMI_QOS_GLOBAL_QOS_FLOW_TLV_AVG_WINDOW, *PQMI_QOS_GLOBAL_QOS_FLOW_TLV_AVG_WINDOW; - -typedef struct _QMI_QOS_GLOBAL_QOS_FLOW_TLV_TX_FILTER_MATCH_ALL -{ - UCHAR TLVType; //0x1B - USHORT TLVLength; - UCHAR tx_filter_match_all_len; - USHORT filter_id; -} __attribute__ ((packed)) QMI_QOS_GLOBAL_QOS_FLOW_TLV_TX_FILTER_MATCH_ALL, *PQMI_QOS_GLOBAL_QOS_FLOW_TLV_TX_FILTER_MATCH_ALL; - -typedef struct _QMI_QOS_GLOBAL_QOS_FLOW_IND_MSG -{ - USHORT Type; - USHORT Length; - QMI_QOS_GLOBAL_QOS_FLOW_TLV_FLOW_STATE FlowStateTlv; - //QMI_QOS_GLOBAL_QOS_FLOW_TLV_FLOW_GRANTED TxFlowGrantedTlv; - //QMI_QOS_GLOBAL_QOS_FLOW_TLV_FLOW_GRANTED RxFlowGrantedTlv; - //QMI_QOS_GLOBAL_QOS_FLOW_TLV_FILTER TxFilterTlv; - //QMI_QOS_GLOBAL_QOS_FLOW_TLV_FILTER RxFilterTlv; - //QMI_QOS_GLOBAL_QOS_FLOW_TLV_FLOW_TYPE FlowTypeTlv; - //QMI_QOS_GLOBAL_QOS_FLOW_TLV_BEARER_ID BearerIdTlv; - //QMI_QOS_GLOBAL_QOS_FLOW_TLV_FLOW_CTL_SEQ_NUM FlowCtlSeqNumTlv; - //QMI_QOS_GLOBAL_QOS_FLOW_TLV_5G_QCI Tx5GQciTlv; - //QMI_QOS_GLOBAL_QOS_FLOW_TLV_5G_QCI Rx5GQciTlv; - //QMI_QOS_GLOBAL_QOS_FLOW_TLV_AVG_WINDOW AvgWindowTlv; - //QMI_QOS_GLOBAL_QOS_FLOW_TLV_TX_FILTER_MATCH_ALL TxFilterMatchAllTlv; -} __attribute__ ((packed)) QMI_QOS_GLOBAL_QOS_FLOW_IND_MSG, *PQMI_QOS_GLOBAL_QOS_FLOW_IND_MSG; - -typedef struct _QMI_QOS_GET_QOS_INFO_TLV_QOS_ID -{ - UCHAR TLVType; //0x01 - USHORT TLVLength; - ULONG qos_id; -} __attribute__ ((packed)) QMI_QOS_GET_QOS_INFO_TLV_QOS_ID, *PQMI_QOS_GET_QOS_INFO_TLV_QOS_ID; - -typedef struct _QMI_QOS_GET_QOS_INFO_TLV_FLOW_STATUS -{ - UCHAR TLVType; //0x10 - USHORT TLVLength; - UCHAR flow_status; -} __attribute__ ((packed)) QMI_QOS_GET_QOS_INFO_TLV_FLOW_STATUS, *PQMI_QOS_GET_QOS_INFO_TLV_FLOW_STATUS; - -typedef struct _QMI_QOS_GET_QOS_INFO_TLV_GRANTED_FLOW -{ - UCHAR TLVType; //0x11 0x12 - USHORT TLVLength; - ULONG64 flow_valid_params; - ULONG ip_flow_trf_cls; - ULONG64 data_rate_max; - ULONG64 guaranteed_rate; - ULONG peak_rate; - ULONG token_rate; - ULONG bucket_size; - ULONG ip_flow_latency; - ULONG ip_flow_jitter; - USHORT ip_flow_pkt_error_rate_multiplier; - USHORT ip_flow_pkt_error_rate_exponent; - ULONG ip_flow_min_policed_packet_size; - ULONG ip_flow_max_allowed_packet_size; - ULONG ip_flow_3gpp_residual_bit_error_rate; - ULONG ip_flow_3gpp_traffic_handling_priority; - USHORT ip_flow_3gpp2_profile_id; - UCHAR ip_flow_3gpp2_flow_priority; - UCHAR ip_flow_3gpp_im_cn_flag; - UCHAR ip_flow_3gpp_sig_ind; - ULONG ip_flow_lte_qci; -} __attribute__ ((packed)) QMI_QOS_GET_QOS_INFO_TLV_GRANTED_FLOW, *PQMI_QOS_GET_QOS_INFO_TLV_GRANTED_FLOW; - -typedef struct _QMI_QOS_GET_QOS_INFO_TLV_FILTER_SPECS -{ - UCHAR TLVType; //0x13 0x14 - USHORT TLVLength; - UCHAR tx_rx_qos_filter_len; - UCHAR ip_version; - ULONG64 valid_params0; - ULONG ipv4_addr0; - ULONG subnet_mask0; - ULONG ipv4_addr1; - ULONG subnet_mask1; - UCHAR val4; - UCHAR mask4; - ULONG64 valid_params01; - UCHAR ipv6_address00; - UCHAR ipv6_address01; - UCHAR ipv6_address02; - UCHAR ipv6_address03; - UCHAR ipv6_address04; - UCHAR ipv6_address05; - UCHAR ipv6_address06; - UCHAR ipv6_address07; - UCHAR ipv6_address08; - UCHAR ipv6_address09; - UCHAR ipv6_address010; - UCHAR ipv6_address011; - UCHAR ipv6_address012; - UCHAR ipv6_address013; - UCHAR ipv6_address014; - ULONG ipv6_address015; - UCHAR prefix_len0; - UCHAR ipv6_address10; - UCHAR ipv6_address11; - UCHAR ipv6_address12; - UCHAR ipv6_address13; - UCHAR ipv6_address14; - UCHAR ipv6_address15; - UCHAR ipv6_address16; - UCHAR ipv6_address17; - UCHAR ipv6_address18; - UCHAR ipv6_address19; - UCHAR ipv6_address110; - UCHAR ipv6_address111; - UCHAR ipv6_address112; - UCHAR ipv6_address113; - UCHAR ipv6_address114; - ULONG ipv6_address115; - UCHAR prefix_len1; - UCHAR val6; - UCHAR mask6; - ULONG flow_label; - ULONG xport_protocol; - ULONG64 valid_params2; - USHORT port0; - USHORT range0; - USHORT port1; - USHORT range1; - ULONG64 valid_params3; - USHORT port2; - USHORT range2; - USHORT port3; - USHORT range3; - ULONG64 valid_params4; - UCHAR type; - UCHAR code; - ULONG64 valid_params5; - ULONG spi0; - ULONG64 valid_params6; - ULONG spi1; - USHORT filter_id; - USHORT filter_precedence; -} __attribute__ ((packed)) QMI_QOS_GET_QOS_INFO_TLV_FILTER_SPECS, *PQMI_QOS_GET_QOS_INFO_TLV_FILTER_SPECS; - -typedef struct _QMI_QOS_GET_QOS_INFO_TLV_EXT_ERROR_INFO -{ - UCHAR TLVType; //0x15 - USHORT TLVLength; - USHORT ext_error_info; -} __attribute__ ((packed)) QMI_QOS_GET_QOS_INFO_TLV_EXT_ERROR_INFO, *PQMI_QOS_GET_QOS_INFO_TLV_EXT_ERROR_INFO; - -typedef struct _QMI_QOS_GET_QOS_INFO_TLV_5G_QCI -{ - UCHAR TLVType; //0x16 0x17 - USHORT TLVLength; - ULONG tx_rx_5g_qci; -} __attribute__ ((packed)) QMI_QOS_GET_QOS_INFO_TLV_5G_QCI, *PQMI_QOS_GET_QOS_INFO_TLV_5G_QCI; - -typedef struct _QMI_QOS_GET_QOS_INFO_TLV_AVG_WINDOW -{ - UCHAR TLVType; //0x18 0x19 - USHORT TLVLength; - USHORT tx_rx_averaging_window; -} __attribute__ ((packed)) QMI_QOS_GET_QOS_INFO_TLV_AVG_WINDOW, *PQMI_QOS_GET_QOS_INFO_TLV_AVG_WINDOW; - -typedef struct _QMI_QOS_GET_QOS_INFO_TLV_TX_FILTER_MATCH_ALL -{ - UCHAR TLVType; //0x1A - USHORT TLVLength; - UCHAR tx_filter_match_all_len; - USHORT filter_id; -} __attribute__ ((packed)) QMI_QOS_GET_QOS_INFO_TLV_TX_FILTER_MATCH_ALL, *PQMI_QOS_GET_QOS_INFO_TLV_TX_FILTER_MATCH_ALL; - -typedef struct _QMI_QOS_GET_QOS_INFO_REQ_MSG -{ - USHORT Type; - USHORT Length; - QMI_QOS_GET_QOS_INFO_TLV_QOS_ID QosIdTlv; -} __attribute__ ((packed)) QMI_QOS_GET_QOS_INFO_REQ_MSG, *PQMI_QOS_GET_QOS_INFO_REQ_MSG; - -typedef struct _QMI_QOS_GET_QOS_INFO_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; //0x02 - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; - //QMI_QOS_GET_QOS_INFO_TLV_FLOW_STATUS FlowStatusTlv; - //QMI_QOS_GET_QOS_INFO_TLV_GRANTED_FLOW TxGrantedFlowTlv; - //QMI_QOS_GET_QOS_INFO_TLV_GRANTED_FLOW RxGrantedFlowTlv; - //QMI_QOS_GET_QOS_INFO_TLV_FILTER_SPECS TxFilterSpecsTlv; - //QMI_QOS_GET_QOS_INFO_TLV_FILTER_SPECS RxFilterSpecsTlv; - //QMI_QOS_GET_QOS_INFO_TLV_EXT_ERROR_INFO ExtErrorInfoTlv; - //QMI_QOS_GET_QOS_INFO_TLV_5G_QCI Tx5GQciTlv; - //QMI_QOS_GET_QOS_INFO_TLV_5G_QCI Rx5GQciTlv; - //QMI_QOS_GET_QOS_INFO_TLV_AVG_WINDOW TxAvgWindowTlv; - //QMI_QOS_GET_QOS_INFO_TLV_AVG_WINDOW RxAvgWindowTlv; - //QMI_QOS_GET_QOS_INFO_TLV_TX_FILTER_MATCH_ALL TxFilterMatchAllTlv; -} __attribute__ ((packed)) QMI_QOS_GET_QOS_INFO_RESP_MSG, *PQMI_QOS_GET_QOS_INFO_RESP_MSG; - -#define QOS_IND_FLOW_STATE_ACTIVATED 0x00 -#define QOS_IND_FLOW_STATE_MODIFIED 0x01 -#define QOS_IND_FLOW_STATE_DELETED 0x02 -#define QOS_IND_FLOW_STATE_SUSPENDED 0x03 -#define QOS_IND_FLOW_STATE_ENABLED 0x04 -#define QOS_IND_FLOW_STATE_DISABLED 0x05 -#define QOS_IND_FLOW_STATE_INVALID 0x06 - -#define QOS_EVENT_RPT_IND_FLOW_ACTIVATED 0x01 -#define QOS_EVENT_RPT_IND_FLOW_MODIFIED 0x02 -#define QOS_EVENT_RPT_IND_FLOW_DELETED 0x03 -#define QOS_EVENT_RPT_IND_FLOW_SUSPENDED 0x04 -#define QOS_EVENT_RPT_IND_FLOW_ENABLED 0x05 -#define QOS_EVENT_RPT_IND_FLOW_DISABLED 0x06 - -#define QOS_EVENT_RPT_IND_TLV_PHY_LINK_STATE_TYPE 0x01 -#define QOS_EVENT_RPT_IND_TLV_GLOBAL_FL_RPT_STATE 0x10 -#define QOS_EVENT_RPT_IND_TLV_GLOBAL_FL_RPT_TYPE 0x10 -#define QOS_EVENT_RPT_IND_TLV_TX_FLOW_TYPE 0x11 -#define QOS_EVENT_RPT_IND_TLV_RX_FLOW_TYPE 0x12 -#define QOS_EVENT_RPT_IND_TLV_TX_FILTER_TYPE 0x13 -#define QOS_EVENT_RPT_IND_TLV_RX_FILTER_TYPE 0x14 -#define QOS_EVENT_RPT_IND_TLV_FLOW_SPEC 0x10 -#define QOS_EVENT_RPT_IND_TLV_FILTER_SPEC 0x10 - -typedef struct _QOS_EVENT_RPT_IND_TLV_PHY_LINK_STATE -{ - UCHAR TLVType; // 0x01 - USHORT TLVLength; // 1 - UCHAR PhyLinkState; // 0-dormant, 1-active -} QOS_EVENT_RPT_IND_TLV_PHY_LINK_STATE, *PQOS_EVENT_RPT_IND_TLV_PHY_LINK_STATE; - -typedef struct _QOS_EVENT_RPT_IND_TLV_GLOBAL_FL_RPT -{ - UCHAR TLVType; // 0x10 - USHORT TLVLength; // 6 - ULONG QosId; - UCHAR NewFlow; // 1: newly added flow; 0: existing flow - UCHAR StateChange; // 1: activated; 2: modified; 3: deleted; - // 4: suspended(delete); 5: enabled; 6: disabled -} QOS_EVENT_RPT_IND_TLV_GLOBAL_FL_RPT, *PQOS_EVENT_RPT_IND_TLV_GLOBAL_FL_RPT; - -// QOS Flow - -typedef struct _QOS_EVENT_RPT_IND_TLV_FLOW -{ - UCHAR TLVType; // 0x10-TX flow; 0x11-RX flow - USHORT TLVLength; // var - // embedded TLV's -} QOS_EVENT_RPT_IND_TLV_TX_FLOW, *PQOS_EVENT_RPT_IND_TLV_TX_FLOW; - -#define QOS_FLOW_TLV_IP_FLOW_IDX_TYPE 0x10 -#define QOS_FLOW_TLV_IP_FLOW_TRAFFIC_CLASS_TYPE 0x11 -#define QOS_FLOW_TLV_IP_FLOW_DATA_RATE_MIN_MAX_TYPE 0x12 -#define QOS_FLOW_TLV_IP_FLOW_DATA_RATE_TOKEN_BUCKET_TYPE 0x13 -#define QOS_FLOW_TLV_IP_FLOW_LATENCY_TYPE 0x14 -#define QOS_FLOW_TLV_IP_FLOW_JITTER_TYPE 0x15 -#define QOS_FLOW_TLV_IP_FLOW_PKT_ERR_RATE_TYPE 0x16 -#define QOS_FLOW_TLV_IP_FLOW_MIN_PKT_SIZE_TYPE 0x17 -#define QOS_FLOW_TLV_IP_FLOW_MAX_PKT_SIZE_TYPE 0x18 -#define QOS_FLOW_TLV_IP_FLOW_3GPP_BIT_ERR_RATE_TYPE 0x19 -#define QOS_FLOW_TLV_IP_FLOW_3GPP_TRAF_PRIORITY_TYPE 0x1A -#define QOS_FLOW_TLV_IP_FLOW_3GPP2_PROFILE_ID_TYPE 0x1B - -typedef struct _QOS_FLOW_TLV_IP_FLOW_IDX -{ - UCHAR TLVType; // 0x10 - USHORT TLVLength; // 1 - UCHAR IpFlowIndex; -} QOS_FLOW_TLV_IP_FLOW_IDX, *PQOS_FLOW_TLV_IP_FLOW_IDX; - -typedef struct _QOS_FLOW_TLV_IP_FLOW_TRAFFIC_CLASS -{ - UCHAR TLVType; // 0x11 - USHORT TLVLength; // 1 - UCHAR TrafficClass; -} QOS_FLOW_TLV_IP_FLOW_TRAFFIC_CLASS, *PQOS_FLOW_TLV_IP_FLOW_TRAFFIC_CLASS; - -typedef struct _QOS_FLOW_TLV_IP_FLOW_DATA_RATE_MIN_MAX -{ - UCHAR TLVType; // 0x12 - USHORT TLVLength; // 8 - ULONG DataRateMax; - ULONG GuaranteedRate; -} QOS_FLOW_TLV_IP_FLOW_DATA_RATE_MIN_MAX, *PQOS_FLOW_TLV_IP_FLOW_DATA_RATE_MIN_MAX; - -typedef struct _QOS_FLOW_TLV_IP_FLOW_DATA_RATE_TOKEN_BUCKET -{ - UCHAR TLVType; // 0x13 - USHORT TLVLength; // 12 - ULONG PeakRate; - ULONG TokenRate; - ULONG BucketSize; -} QOS_FLOW_TLV_IP_FLOW_DATA_RATE_TOKEN_BUCKET, *PQOS_FLOW_TLV_IP_FLOW_DATA_RATE_TOKEN_BUCKET; - -typedef struct _QOS_FLOW_TLV_IP_FLOW_LATENCY -{ - UCHAR TLVType; // 0x14 - USHORT TLVLength; // 4 - ULONG IpFlowLatency; -} QOS_FLOW_TLV_IP_FLOW_LATENCY, *PQOS_FLOW_TLV_IP_FLOW_LATENCY; - -typedef struct _QOS_FLOW_TLV_IP_FLOW_JITTER -{ - UCHAR TLVType; // 0x15 - USHORT TLVLength; // 4 - ULONG IpFlowJitter; -} QOS_FLOW_TLV_IP_FLOW_JITTER, *PQOS_FLOW_TLV_IP_FLOW_JITTER; - -typedef struct _QOS_FLOW_TLV_IP_FLOW_PKT_ERR_RATE -{ - UCHAR TLVType; // 0x16 - USHORT TLVLength; // 4 - USHORT ErrRateMultiplier; - USHORT ErrRateExponent; -} QOS_FLOW_TLV_IP_FLOW_PKT_ERR_RATE, *PQOS_FLOW_TLV_IP_FLOW_PKT_ERR_RATE; - -typedef struct _QOS_FLOW_TLV_IP_FLOW_MIN_PKT_SIZE -{ - UCHAR TLVType; // 0x17 - USHORT TLVLength; // 4 - ULONG MinPolicedPktSize; -} QOS_FLOW_TLV_IP_FLOW_MIN_PKT_SIZE, *PQOS_FLOW_TLV_IP_FLOW_MIN_PKT_SIZE; - -typedef struct _QOS_FLOW_TLV_IP_FLOW_MAX_PKT_SIZE -{ - UCHAR TLVType; // 0x18 - USHORT TLVLength; // 4 - ULONG MaxAllowedPktSize; -} QOS_FLOW_TLV_IP_FLOW_MAX_PKT_SIZE, *PQOS_FLOW_TLV_IP_FLOW_MAX_PKT_SIZE; - -typedef struct _QOS_FLOW_TLV_IP_FLOW_3GPP_BIT_ERR_RATE -{ - UCHAR TLVType; // 0x19 - USHORT TLVLength; // 1 - UCHAR ResidualBitErrorRate; -} QOS_FLOW_TLV_IP_FLOW_3GPP_BIT_ERR_RATE, *PQOS_FLOW_TLV_IP_FLOW_3GPP_BIT_ERR_RATE; - -typedef struct _QOS_FLOW_TLV_IP_FLOW_3GPP_TRAF_PRIORITY -{ - UCHAR TLVType; // 0x1A - USHORT TLVLength; // 1 - UCHAR TrafficHandlingPriority; -} QOS_FLOW_TLV_IP_FLOW_3GPP_TRAF_PRIORITY, *PQOS_FLOW_TLV_IP_FLOW_3GPP_TRAF_PRIORITY; - -typedef struct _QOS_FLOW_TLV_IP_FLOW_3GPP2_PROFILE_ID -{ - UCHAR TLVType; // 0x1B - USHORT TLVLength; // 2 - USHORT ProfileId; -} QOS_FLOW_TLV_IP_FLOW_3GPP2_PROFILE_ID, *PQOS_FLOW_TLV_IP_FLOW_3GPP2_PROFILE_ID; - -// QOS Filter - -#define QOS_FILTER_TLV_IP_FILTER_IDX_TYPE 0x10 -#define QOS_FILTER_TLV_IP_VERSION_TYPE 0x11 -#define QOS_FILTER_TLV_IPV4_SRC_ADDR_TYPE 0x12 -#define QOS_FILTER_TLV_IPV4_DEST_ADDR_TYPE 0x13 -#define QOS_FILTER_TLV_NEXT_HDR_PROTOCOL_TYPE 0x14 -#define QOS_FILTER_TLV_IPV4_TYPE_OF_SERVICE_TYPE 0x15 -#define QOS_FILTER_TLV_TCP_UDP_PORT_SRC_TCP_TYPE 0x1B -#define QOS_FILTER_TLV_TCP_UDP_PORT_DEST_TCP_TYPE 0x1C -#define QOS_FILTER_TLV_TCP_UDP_PORT_SRC_UDP_TYPE 0x1D -#define QOS_FILTER_TLV_TCP_UDP_PORT_DEST_UDP_TYPE 0x1E -#define QOS_FILTER_TLV_ICMP_FILTER_MSG_TYPE_TYPE 0x1F -#define QOS_FILTER_TLV_ICMP_FILTER_MSG_CODE_TYPE 0x20 -#define QOS_FILTER_TLV_TCP_UDP_PORT_SRC_TYPE 0x24 -#define QOS_FILTER_TLV_TCP_UDP_PORT_DEST_TYPE 0x25 - -typedef struct _QOS_EVENT_RPT_IND_TLV_FILTER -{ - UCHAR TLVType; // 0x12-TX filter; 0x13-RX filter - USHORT TLVLength; // var - // embedded TLV's -} QOS_EVENT_RPT_IND_TLV_RX_FILTER, *PQOS_EVENT_RPT_IND_TLV_RX_FILTER; - -typedef struct _QOS_FILTER_TLV_IP_FILTER_IDX -{ - UCHAR TLVType; // 0x10 - USHORT TLVLength; // 1 - UCHAR IpFilterIndex; -} QOS_FILTER_TLV_IP_FILTER_IDX, *PQOS_FILTER_TLV_IP_FILTER_IDX; - -typedef struct _QOS_FILTER_TLV_IP_VERSION -{ - UCHAR TLVType; // 0x11 - USHORT TLVLength; // 1 - UCHAR IpVersion; -} QOS_FILTER_TLV_IP_VERSION, *PQOS_FILTER_TLV_IP_VERSION; - -typedef struct _QOS_FILTER_TLV_IPV4_SRC_ADDR -{ - UCHAR TLVType; // 0x12 - USHORT TLVLength; // 8 - ULONG IpSrcAddr; - ULONG IpSrcSubnetMask; -} QOS_FILTER_TLV_IPV4_SRC_ADDR, *PQOS_FILTER_TLV_IPV4_SRC_ADDR; - -typedef struct _QOS_FILTER_TLV_IPV4_DEST_ADDR -{ - UCHAR TLVType; // 0x13 - USHORT TLVLength; // 8 - ULONG IpDestAddr; - ULONG IpDestSubnetMask; -} QOS_FILTER_TLV_IPV4_DEST_ADDR, *PQOS_FILTER_TLV_IPV4_DEST_ADDR; - -typedef struct _QOS_FILTER_TLV_NEXT_HDR_PROTOCOL -{ - UCHAR TLVType; // 0x14 - USHORT TLVLength; // 1 - UCHAR NextHdrProtocol; -} QOS_FILTER_TLV_NEXT_HDR_PROTOCOL, *PQOS_FILTER_TLV_NEXT_HDR_PROTOCOL; - -typedef struct _QOS_FILTER_TLV_IPV4_TYPE_OF_SERVICE -{ - UCHAR TLVType; // 0x15 - USHORT TLVLength; // 2 - UCHAR Ipv4TypeOfService; - UCHAR Ipv4TypeOfServiceMask; -} QOS_FILTER_TLV_IPV4_TYPE_OF_SERVICE, *PQOS_FILTER_TLV_IPV4_TYPE_OF_SERVICE; - -typedef struct _QOS_FILTER_TLV_TCP_UDP_PORT -{ - UCHAR TLVType; // source port: 0x1B-TCP; 0x1D-UDP - // dest port: 0x1C-TCP; 0x1E-UDP - USHORT TLVLength; // 4 - USHORT FilterPort; - USHORT FilterPortRange; -} QOS_FILTER_TLV_TCP_UDP_PORT, *PQOS_FILTER_TLV_TCP_UDP_PORT; - -typedef struct _QOS_FILTER_TLV_ICMP_FILTER_MSG_TYPE -{ - UCHAR TLVType; // 0x1F - USHORT TLVLength; // 1 - UCHAR IcmpFilterMsgType; -} QOS_FILTER_TLV_ICMP_FILTER_MSG_TYPE, *PQOS_FILTER_TLV_ICMP_FILTER_MSG_TYPE; - -typedef struct _QOS_FILTER_TLV_ICMP_FILTER_MSG_CODE -{ - UCHAR TLVType; // 0x20 - USHORT TLVLength; // 1 - UCHAR IcmpFilterMsgCode; -} QOS_FILTER_TLV_ICMP_FILTER_MSG_CODE, *PQOS_FILTER_TLV_ICMP_FILTER_MSG_CODE; - -#define QOS_FILTER_PRECEDENCE_INVALID 256 -#define QOS_FILTER_TLV_PRECEDENCE_TYPE 0x22 -#define QOS_FILTER_TLV_ID_TYPE 0x23 - -typedef struct _QOS_FILTER_TLV_PRECEDENCE -{ - UCHAR TLVType; // 0x22 - USHORT TLVLength; // 2 - USHORT Precedence; // precedence of the filter -} QOS_FILTER_TLV_PRECEDENCE, *PQOS_FILTER_TLV_PRECEDENCE; - -typedef struct _QOS_FILTER_TLV_ID -{ - UCHAR TLVType; // 0x23 - USHORT TLVLength; // 2 - USHORT FilterId; // filter ID -} QOS_FILTER_TLV_ID, *PQOS_FILTER_TLV_ID; - -#ifdef QCQOS_IPV6 - -#define QOS_FILTER_TLV_IPV6_SRC_ADDR_TYPE 0x16 -#define QOS_FILTER_TLV_IPV6_DEST_ADDR_TYPE 0x17 -#define QOS_FILTER_TLV_IPV6_NEXT_HDR_PROTOCOL_TYPE 0x14 // same as IPV4 -#define QOS_FILTER_TLV_IPV6_TRAFFIC_CLASS_TYPE 0x19 -#define QOS_FILTER_TLV_IPV6_FLOW_LABEL_TYPE 0x1A - -typedef struct _QOS_FILTER_TLV_IPV6_SRC_ADDR -{ - UCHAR TLVType; // 0x16 - USHORT TLVLength; // 17 - UCHAR IpSrcAddr[16]; - UCHAR IpSrcAddrPrefixLen; // [0..128] -} QOS_FILTER_TLV_IPV6_SRC_ADDR, *PQOS_FILTER_TLV_IPV6_SRC_ADDR; - -typedef struct _QOS_FILTER_TLV_IPV6_DEST_ADDR -{ - UCHAR TLVType; // 0x17 - USHORT TLVLength; // 17 - UCHAR IpDestAddr[16]; - UCHAR IpDestAddrPrefixLen; // [0..128] -} QOS_FILTER_TLV_IPV6_DEST_ADDR, *PQOS_FILTER_TLV_IPV6_DEST_ADDR; - -#define QOS_FILTER_IPV6_NEXT_HDR_PROTOCOL_TCP 0x06 -#define QOS_FILTER_IPV6_NEXT_HDR_PROTOCOL_UDP 0x11 - -typedef struct _QOS_FILTER_TLV_IPV6_TRAFFIC_CLASS -{ - UCHAR TLVType; // 0x19 - USHORT TLVLength; // 2 - UCHAR TrafficClass; - UCHAR TrafficClassMask; // compare the first 6 bits only -} QOS_FILTER_TLV_IPV6_TRAFFIC_CLASS, *PQOS_FILTER_TLV_IPV6_TRAFFIC_CLASS; - -typedef struct _QOS_FILTER_TLV_IPV6_FLOW_LABEL -{ - UCHAR TLVType; // 0x1A - USHORT TLVLength; // 4 - ULONG FlowLabel; -} QOS_FILTER_TLV_IPV6_FLOW_LABEL, *PQOS_FILTER_TLV_IPV6_FLOW_LABEL; - -#endif // QCQOS_IPV6 -#endif - -// ======================= WMS ============================== -#define QMIWMS_SET_EVENT_REPORT_REQ 0x0001 -#define QMIWMS_SET_EVENT_REPORT_RESP 0x0001 -#define QMIWMS_EVENT_REPORT_IND 0x0001 -#define QMIWMS_RAW_SEND_REQ 0x0020 -#define QMIWMS_RAW_SEND_RESP 0x0020 -#define QMIWMS_RAW_WRITE_REQ 0x0021 -#define QMIWMS_RAW_WRITE_RESP 0x0021 -#define QMIWMS_RAW_READ_REQ 0x0022 -#define QMIWMS_RAW_READ_RESP 0x0022 -#define QMIWMS_MODIFY_TAG_REQ 0x0023 -#define QMIWMS_MODIFY_TAG_RESP 0x0023 -#define QMIWMS_DELETE_REQ 0x0024 -#define QMIWMS_DELETE_RESP 0x0024 -#define QMIWMS_GET_MESSAGE_PROTOCOL_REQ 0x0030 -#define QMIWMS_GET_MESSAGE_PROTOCOL_RESP 0x0030 -#define QMIWMS_LIST_MESSAGES_REQ 0x0031 -#define QMIWMS_LIST_MESSAGES_RESP 0x0031 -#define QMIWMS_GET_SMSC_ADDRESS_REQ 0x0034 -#define QMIWMS_GET_SMSC_ADDRESS_RESP 0x0034 -#define QMIWMS_SET_SMSC_ADDRESS_REQ 0x0035 -#define QMIWMS_SET_SMSC_ADDRESS_RESP 0x0035 -#define QMIWMS_GET_STORE_MAX_SIZE_REQ 0x0036 -#define QMIWMS_GET_STORE_MAX_SIZE_RESP 0x0036 - - -#define WMS_MESSAGE_PROTOCOL_CDMA 0x00 -#define WMS_MESSAGE_PROTOCOL_WCDMA 0x01 - -#if 0 -typedef struct _QMIWMS_GET_MESSAGE_PROTOCOL_REQ_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; -} QMIWMS_GET_MESSAGE_PROTOCOL_REQ_MSG, *PQMIWMS_GET_MESSAGE_PROTOCOL_REQ_MSG; - -typedef struct _QMIWMS_GET_MESSAGE_PROTOCOL_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; - UCHAR TLV2Type; - USHORT TLV2Length; - UCHAR MessageProtocol; -} QMIWMS_GET_MESSAGE_PROTOCOL_RESP_MSG, *PQMIWMS_GET_MESSAGE_PROTOCOL_RESP_MSG; - -typedef struct _QMIWMS_GET_STORE_MAX_SIZE_REQ_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - UCHAR StorageType; -} QMIWMS_GET_STORE_MAX_SIZE_REQ_MSG, *PQMIWMS_GET_STORE_MAX_SIZE_REQ_MSG; - -typedef struct _QMIWMS_GET_STORE_MAX_SIZE_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; - UCHAR TLV2Type; - USHORT TLV2Length; - ULONG MemStoreMaxSize; -} QMIWMS_GET_STORE_MAX_SIZE_RESP_MSG, *PQMIWMS_GET_STORE_MAX_SIZE_RESP_MSG; - -typedef struct _REQUEST_TAG -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR TagType; -} REQUEST_TAG, *PREQUEST_TAG; - -typedef struct _QMIWMS_LIST_MESSAGES_REQ_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - UCHAR StorageType; -} QMIWMS_LIST_MESSAGES_REQ_MSG, *PQMIWMS_LIST_MESSAGES_REQ_MSG; - -typedef struct _QMIWMS_MESSAGE -{ - ULONG MessageIndex; - UCHAR TagType; -} QMIWMS_MESSAGE, *PQMIWMS_MESSAGE; - -typedef struct _QMIWMS_LIST_MESSAGES_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; - UCHAR TLV2Type; - USHORT TLV2Length; - ULONG NumMessages; -} QMIWMS_LIST_MESSAGES_RESP_MSG, *PQMIWMS_LIST_MESSAGES_RESP_MSG; - -typedef struct _QMIWMS_RAW_READ_REQ_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - UCHAR StorageType; - ULONG MemoryIndex; -} QMIWMS_RAW_READ_REQ_MSG, *PQMIWMS_RAW_READ_REQ_MSG; - -typedef struct _QMIWMS_RAW_READ_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; - UCHAR TLV2Type; - USHORT TLV2Length; - UCHAR TagType; - UCHAR Format; - USHORT MessageLength; - UCHAR Message; -} QMIWMS_RAW_READ_RESP_MSG, *PQMIWMS_RAW_READ_RESP_MSG; - -typedef struct _QMIWMS_MODIFY_TAG_REQ_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - UCHAR StorageType; - ULONG MemoryIndex; - UCHAR TagType; -} QMIWMS_MODIFY_TAG_REQ_MSG, *PQMIWMS_MODIFY_TAG_REQ_MSG; - -typedef struct _QMIWMS_MODIFY_TAG_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; -} QMIWMS_MODIFY_TAG_RESP_MSG, *PQMIWMS_MODIFY_TAG_RESP_MSG; - -typedef struct _QMIWMS_RAW_SEND_REQ_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - UCHAR SmsFormat; - USHORT SmsLength; - UCHAR SmsMessage; -} QMIWMS_RAW_SEND_REQ_MSG, *PQMIWMS_RAW_SEND_REQ_MSG; - -typedef struct _RAW_SEND_CAUSE_CODE -{ - UCHAR TLVType; - USHORT TLVLength; - USHORT CauseCode; -} RAW_SEND_CAUSE_CODE, *PRAW_SEND_CAUSE_CODE; - - -typedef struct _QMIWMS_RAW_SEND_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; -} QMIWMS_RAW_SEND_RESP_MSG, *PQMIWMS_RAW_SEND_RESP_MSG; - - -typedef struct _WMS_DELETE_MESSAGE_INDEX -{ - UCHAR TLVType; - USHORT TLVLength; - ULONG MemoryIndex; -} WMS_DELETE_MESSAGE_INDEX, *PWMS_DELETE_MESSAGE_INDEX; - -typedef struct _WMS_DELETE_MESSAGE_TAG -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR MessageTag; -} WMS_DELETE_MESSAGE_TAG, *PWMS_DELETE_MESSAGE_TAG; - -typedef struct _QMIWMS_DELETE_REQ_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - UCHAR StorageType; -} QMIWMS_DELETE_REQ_MSG, *PQMIWMS_DELETE_REQ_MSG; - -typedef struct _QMIWMS_DELETE_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; -} QMIWMS_DELETE_RESP_MSG, *PQMIWMS_DELETE_RESP_MSG; - - -typedef struct _QMIWMS_GET_SMSC_ADDRESS_REQ_MSG -{ - USHORT Type; - USHORT Length; -} QMIWMS_GET_SMSC_ADDRESS_REQ_MSG, *PQMIWMS_GET_SMSC_ADDRESS_REQ_MSG; - -typedef struct _QMIWMS_SMSC_ADDRESS -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR SMSCAddressType[3]; - UCHAR SMSCAddressLength; - UCHAR SMSCAddressDigits; -} QMIWMS_SMSC_ADDRESS, *PQMIWMS_SMSC_ADDRESS; - - -typedef struct _QMIWMS_GET_SMSC_ADDRESS_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; - UCHAR SMSCAddress; -} QMIWMS_GET_SMSC_ADDRESS_RESP_MSG, *PQMIWMS_GET_SMSC_ADDRESS_RESP_MSG; - -typedef struct _QMIWMS_SET_SMSC_ADDRESS_REQ_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - UCHAR SMSCAddress; -} QMIWMS_SET_SMSC_ADDRESS_REQ_MSG, *PQMIWMS_SET_SMSC_ADDRESS_REQ_MSG; - -typedef struct _QMIWMS_SET_SMSC_ADDRESS_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; -} QMIWMS_SET_SMSC_ADDRESS_RESP_MSG, *PQMIWMS_SET_SMSC_ADDRESS_RESP_MSG; - -typedef struct _QMIWMS_SET_EVENT_REPORT_REQ_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - UCHAR ReportNewMessage; -} QMIWMS_SET_EVENT_REPORT_REQ_MSG, *PQMIWMS_SET_EVENT_REPORT_REQ_MSG; - -typedef struct _QMIWMS_SET_EVENT_REPORT_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; -} QMIWMS_SET_EVENT_REPORT_RESP_MSG, *PQMIWMS_SET_EVENT_REPORT_RESP_MSG; - -typedef struct _QMIWMS_EVENT_REPORT_IND_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - UCHAR StorageType; - ULONG StorageIndex; -} QMIWMS_EVENT_REPORT_IND_MSG, *PQMIWMS_EVENT_REPORT_IND_MSG; -#endif - -// ======================= End of WMS ============================== - - -// ======================= NAS ============================== -#define QMINAS_SET_EVENT_REPORT_REQ 0x0002 -#define QMINAS_SET_EVENT_REPORT_RESP 0x0002 -#define QMINAS_EVENT_REPORT_IND 0x0002 -#define QMINAS_GET_SIGNAL_STRENGTH_REQ 0x0020 -#define QMINAS_GET_SIGNAL_STRENGTH_RESP 0x0020 -#define QMINAS_PERFORM_NETWORK_SCAN_REQ 0x0021 -#define QMINAS_PERFORM_NETWORK_SCAN_RESP 0x0021 -#define QMINAS_INITIATE_NW_REGISTER_REQ 0x0022 -#define QMINAS_INITIATE_NW_REGISTER_RESP 0x0022 -#define QMINAS_INITIATE_ATTACH_REQ 0x0023 -#define QMINAS_INITIATE_ATTACH_RESP 0x0023 -#define QMINAS_GET_SERVING_SYSTEM_REQ 0x0024 -#define QMINAS_GET_SERVING_SYSTEM_RESP 0x0024 -#define QMINAS_SERVING_SYSTEM_IND 0x0024 -#define QMINAS_GET_HOME_NETWORK_REQ 0x0025 -#define QMINAS_GET_HOME_NETWORK_RESP 0x0025 -#define QMINAS_GET_PREFERRED_NETWORK_REQ 0x0026 -#define QMINAS_GET_PREFERRED_NETWORK_RESP 0x0026 -#define QMINAS_SET_PREFERRED_NETWORK_REQ 0x0027 -#define QMINAS_SET_PREFERRED_NETWORK_RESP 0x0027 -#define QMINAS_GET_FORBIDDEN_NETWORK_REQ 0x0028 -#define QMINAS_GET_FORBIDDEN_NETWORK_RESP 0x0028 -#define QMINAS_SET_FORBIDDEN_NETWORK_REQ 0x0029 -#define QMINAS_SET_FORBIDDEN_NETWORK_RESP 0x0029 -#define QMINAS_SET_TECHNOLOGY_PREF_REQ 0x002A -#define QMINAS_SET_TECHNOLOGY_PREF_RESP 0x002A -#define QMINAS_GET_RF_BAND_INFO_REQ 0x0031 -#define QMINAS_GET_RF_BAND_INFO_RESP 0x0031 -#define QMINAS_GET_CELL_LOCATION_INFO_REQ 0x0043 -#define QMINAS_GET_CELL_LOCATION_INFO_RESP 0x0043 -#define QMINAS_GET_PLMN_NAME_REQ 0x0044 -#define QMINAS_GET_PLMN_NAME_RESP 0x0044 -#define QUECTEL_PACKET_TRANSFER_START_IND 0X100 -#define QUECTEL_PACKET_TRANSFER_END_IND 0X101 -#define QMINAS_GET_SYS_INFO_REQ 0x004D -#define QMINAS_GET_SYS_INFO_RESP 0x004D -#define QMINAS_SYS_INFO_IND 0x004E -#define QMINAS_GET_SIG_INFO_REQ 0x004F -#define QMINAS_GET_SIG_INFO_RESP 0x004F - -typedef struct _QMINAS_GET_HOME_NETWORK_REQ_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; -} __attribute__ ((packed)) QMINAS_GET_HOME_NETWORK_REQ_MSG, *PQMINAS_GET_HOME_NETWORK_REQ_MSG; - -typedef struct _HOME_NETWORK_SYSTEMID -{ - UCHAR TLVType; - USHORT TLVLength; - USHORT SystemID; - USHORT NetworkID; -} __attribute__ ((packed)) HOME_NETWORK_SYSTEMID, *PHOME_NETWORK_SYSTEMID; - -typedef struct _HOME_NETWORK -{ - UCHAR TLVType; - USHORT TLVLength; - USHORT MobileCountryCode; - USHORT MobileNetworkCode; - UCHAR NetworkDesclen; - UCHAR NetworkDesc; -} __attribute__ ((packed)) HOME_NETWORK, *PHOME_NETWORK; - -#if 0 -typedef struct _HOME_NETWORK_EXT -{ - UCHAR TLVType; - USHORT TLVLength; - USHORT MobileCountryCode; - USHORT MobileNetworkCode; - UCHAR NetworkDescDisp; - UCHAR NetworkDescEncoding; - UCHAR NetworkDesclen; - UCHAR NetworkDesc; -} HOME_NETWORK_EXT, *PHOME_NETWORK_EXT; - -typedef struct _QMINAS_GET_HOME_NETWORK_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; -} QMINAS_GET_HOME_NETWORK_RESP_MSG, *PQMINAS_GET_HOME_NETWORK_RESP_MSG; - -typedef struct _QMINAS_GET_PREFERRED_NETWORK_REQ_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; -} QMINAS_GET_PREFERRED_NETWORK_REQ_MSG, *PQMINAS_GET_PREFERRED_NETWORK_REQ_MSG; - - -typedef struct _PREFERRED_NETWORK -{ - USHORT MobileCountryCode; - USHORT MobileNetworkCode; - USHORT RadioAccess; -} PREFERRED_NETWORK, *PPREFERRED_NETWORK; - -typedef struct _QMINAS_GET_PREFERRED_NETWORK_RESP_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT - UCHAR TLV2Type; // 0x01 - required parameter - USHORT TLV2Length; // length of the mfr string - USHORT NumPreferredNetwork; -} QMINAS_GET_PREFERRED_NETWORK_RESP_MSG, *PQMINAS_GET_PREFERRED_NETWORK_RESP_MSG; - -typedef struct _QMINAS_GET_FORBIDDEN_NETWORK_REQ_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; -} QMINAS_GET_FORBIDDEN_NETWORK_REQ_MSG, *PQMINAS_GET_FORBIDDEN_NETWORK_REQ_MSG; - -typedef struct _FORBIDDEN_NETWORK -{ - USHORT MobileCountryCode; - USHORT MobileNetworkCode; -} FORBIDDEN_NETWORK, *PFORBIDDEN_NETWORK; - -typedef struct _QMINAS_GET_FORBIDDEN_NETWORK_RESP_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT - UCHAR TLV2Type; // 0x01 - required parameter - USHORT TLV2Length; // length of the mfr string - USHORT NumForbiddenNetwork; -} QMINAS_GET_FORBIDDEN_NETWORK_RESP_MSG, *PQMINAS_GET_FORBIDDEN_NETWORK_RESP_MSG; - -typedef struct _QMINAS_GET_SERVING_SYSTEM_REQ_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; -} QMINAS_GET_SERVING_SYSTEM_REQ_MSG, *PQMINAS_GET_SERVING_SYSTEM_REQ_MSG; - -typedef struct _QMINAS_ROAMING_INDICATOR_MSG -{ - UCHAR TLVType; // 0x01 - required parameter - USHORT TLVLength; // length of the mfr string - UCHAR RoamingIndicator; -} QMINAS_ROAMING_INDICATOR_MSG, *PQMINAS_ROAMING_INDICATOR_MSG; -#endif - -typedef struct _QMINAS_DATA_CAP -{ - UCHAR TLVType; // 0x01 - required parameter - USHORT TLVLength; // length of the mfr string - UCHAR DataCapListLen; - UCHAR DataCap; -} __attribute__ ((packed)) QMINAS_DATA_CAP, *PQMINAS_DATA_CAP; - -typedef struct _QMINAS_CURRENT_PLMN_MSG -{ - UCHAR TLVType; // 0x01 - required parameter - USHORT TLVLength; // length of the mfr string - USHORT MobileCountryCode; - USHORT MobileNetworkCode; - UCHAR NetworkDesclen; - UCHAR NetworkDesc; -} __attribute__ ((packed)) QMINAS_CURRENT_PLMN_MSG, *PQMINAS_CURRENT_PLMN_MSG; - -typedef struct _QMINAS_GET_SERVING_SYSTEM_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; -} __attribute__ ((packed)) QMINAS_GET_SERVING_SYSTEM_RESP_MSG, *PQMINAS_GET_SERVING_SYSTEM_RESP_MSG; - -typedef struct _SERVING_SYSTEM -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR RegistrationState; - UCHAR CSAttachedState; - UCHAR PSAttachedState; - UCHAR RegistredNetwork; - UCHAR InUseRadioIF; - UCHAR RadioIF; -} __attribute__ ((packed)) SERVING_SYSTEM, *PSERVING_SYSTEM; - -typedef struct _QMINAS_GET_SYS_INFO_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; -} __attribute__ ((packed)) QMINAS_GET_SYS_INFO_RESP_MSG, *PQMINAS_GET_SYS_INFO_RESP_MSG; - -typedef struct _QMINAS_SYS_INFO_IND_MSG -{ - USHORT Type; - USHORT Length; -} __attribute__ ((packed)) QMINAS_SYS_INFO_IND_MSG, *PQMINAS_SYS_INFO_IND_MSG; - -typedef struct _SERVICE_STATUS_INFO -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR SrvStatus; - UCHAR true_srv_status; - UCHAR IsPrefDataPath; -} __attribute__ ((packed)) SERVICE_STATUS_INFO, *PSERVICE_STATUS_INFO; - -typedef struct _CDMA_SYSTEM_INFO -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR SrvDomainValid; - UCHAR SrvDomain; - UCHAR SrvCapabilityValid; - UCHAR SrvCapability; - UCHAR RoamStatusValid; - UCHAR RoamStatus; - UCHAR IsSysForbiddenValid; - UCHAR IsSysForbidden; - UCHAR IsSysPrlMatchValid; - UCHAR IsSysPrlMatch; - UCHAR PRevInUseValid; - UCHAR PRevInUse; - UCHAR BSPRevValid; - UCHAR BSPRev; - UCHAR CCSSupportedValid; - UCHAR CCSSupported; - UCHAR CDMASysIdValid; - USHORT SID; - USHORT NID; - UCHAR BSInfoValid; - USHORT BaseID; - ULONG BaseLAT; - ULONG BaseLONG; - UCHAR PacketZoneValid; - USHORT PacketZone; - UCHAR NetworkIdValid; - UCHAR MCC[3]; - UCHAR MNC[3]; -} __attribute__ ((packed)) CDMA_SYSTEM_INFO, *PCDMA_SYSTEM_INFO; - -typedef struct _HDR_SYSTEM_INFO -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR SrvDomainValid; - UCHAR SrvDomain; - UCHAR SrvCapabilityValid; - UCHAR SrvCapability; - UCHAR RoamStatusValid; - UCHAR RoamStatus; - UCHAR IsSysForbiddenValid; - UCHAR IsSysForbidden; - UCHAR IsSysPrlMatchValid; - UCHAR IsSysPrlMatch; - UCHAR HdrPersonalityValid; - UCHAR HdrPersonality; - UCHAR HdrActiveProtValid; - UCHAR HdrActiveProt; - UCHAR is856SysIdValid; - UCHAR is856SysId[16]; -} __attribute__ ((packed)) HDR_SYSTEM_INFO, *PHDR_SYSTEM_INFO; - -typedef struct _GSM_SYSTEM_INFO -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR SrvDomainValid; - UCHAR SrvDomain; - UCHAR SrvCapabilityValid; - UCHAR SrvCapability; - UCHAR RoamStatusValid; - UCHAR RoamStatus; - UCHAR IsSysForbiddenValid; - UCHAR IsSysForbidden; - UCHAR LacValid; - USHORT Lac; - UCHAR CellIdValid; - ULONG CellId; - UCHAR RegRejectInfoValid; - UCHAR RejectSrvDomain; - UCHAR RejCause; - UCHAR NetworkIdValid; - UCHAR MCC[3]; - UCHAR MNC[3]; - UCHAR EgprsSuppValid; - UCHAR EgprsSupp; - UCHAR DtmSuppValid; - UCHAR DtmSupp; -} __attribute__ ((packed)) GSM_SYSTEM_INFO, *PGSM_SYSTEM_INFO; - -typedef struct _WCDMA_SYSTEM_INFO -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR SrvDomainValid; - UCHAR SrvDomain; - UCHAR SrvCapabilityValid; - UCHAR SrvCapability; - UCHAR RoamStatusValid; - UCHAR RoamStatus; - UCHAR IsSysForbiddenValid; - UCHAR IsSysForbidden; - UCHAR LacValid; - USHORT Lac; - UCHAR CellIdValid; - ULONG CellId; - UCHAR RegRejectInfoValid; - UCHAR RejectSrvDomain; - UCHAR RejCause; - UCHAR NetworkIdValid; - UCHAR MCC[3]; - UCHAR MNC[3]; - UCHAR HsCallStatusValid; - UCHAR HsCallStatus; - UCHAR HsIndValid; - UCHAR HsInd; - UCHAR PscValid; - UCHAR Psc; -} __attribute__ ((packed)) WCDMA_SYSTEM_INFO, *PWCDMA_SYSTEM_INFO; - -typedef struct _LTE_SYSTEM_INFO -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR SrvDomainValid; - UCHAR SrvDomain; - UCHAR SrvCapabilityValid; - UCHAR SrvCapability; - UCHAR RoamStatusValid; - UCHAR RoamStatus; - UCHAR IsSysForbiddenValid; - UCHAR IsSysForbidden; - UCHAR LacValid; - USHORT Lac; - UCHAR CellIdValid; - ULONG CellId; - UCHAR RegRejectInfoValid; - UCHAR RejectSrvDomain; - UCHAR RejCause; - UCHAR NetworkIdValid; - UCHAR MCC[3]; - UCHAR MNC[3]; - UCHAR TacValid; - USHORT Tac; -} __attribute__ ((packed)) LTE_SYSTEM_INFO, *PLTE_SYSTEM_INFO; - -typedef struct _TDSCDMA_SYSTEM_INFO -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR SrvDomainValid; - UCHAR SrvDomain; - UCHAR SrvCapabilityValid; - UCHAR SrvCapability; - UCHAR RoamStatusValid; - UCHAR RoamStatus; - UCHAR IsSysForbiddenValid; - UCHAR IsSysForbidden; - UCHAR LacValid; - USHORT Lac; - UCHAR CellIdValid; - ULONG CellId; - UCHAR RegRejectInfoValid; - UCHAR RejectSrvDomain; - UCHAR RejCause; - UCHAR NetworkIdValid; - UCHAR MCC[3]; - UCHAR MNC[3]; - UCHAR HsCallStatusValid; - UCHAR HsCallStatus; - UCHAR HsIndValid; - UCHAR HsInd; - UCHAR CellParameterIdValid; - USHORT CellParameterId; - UCHAR CellBroadcastCapValid; - ULONG CellBroadcastCap; - UCHAR CsBarStatusValid; - ULONG CsBarStatus; - UCHAR PsBarStatusValid; - ULONG PsBarStatus; - UCHAR CipherDomainValid; - UCHAR CipherDomain; -} __attribute__ ((packed)) TDSCDMA_SYSTEM_INFO, *PTDSCDMA_SYSTEM_INFO; - -typedef enum { - NAS_SYS_SRV_STATUS_NO_SRV_V01 = 0, - NAS_SYS_SRV_STATUS_LIMITED_V01 = 1, - NAS_SYS_SRV_STATUS_SRV_V01 = 2, - NAS_SYS_SRV_STATUS_LIMITED_REGIONAL_V01 = 3, - NAS_SYS_SRV_STATUS_PWR_SAVE_V01 = 4, -}nas_service_status_enum_type_v01; - -typedef enum { - SYS_SRV_DOMAIN_NO_SRV_V01 = 0, - SYS_SRV_DOMAIN_CS_ONLY_V01 = 1, - SYS_SRV_DOMAIN_PS_ONLY_V01 = 2, - SYS_SRV_DOMAIN_CS_PS_V01 = 3, - SYS_SRV_DOMAIN_CAMPED_V01 = 4, -}nas_service_domain_enum_type_v01; - -typedef enum { - QMI_NAS_RADIO_INTERFACE_UNKNOWN = -1, - QMI_NAS_RADIO_INTERFACE_NONE = 0x00, - QMI_NAS_RADIO_INTERFACE_CDMA_1X = 0x01, - QMI_NAS_RADIO_INTERFACE_CDMA_1XEVDO = 0x02, - QMI_NAS_RADIO_INTERFACE_AMPS = 0x03, - QMI_NAS_RADIO_INTERFACE_GSM = 0x04, - QMI_NAS_RADIO_INTERFACE_UMTS = 0x05, - QMI_NAS_RADIO_INTERFACE_LTE = 0x08, - QMI_NAS_RADIO_INTERFACE_TD_SCDMA = 0x09, - QMI_NAS_RADIO_INTERFACE_5GNR = 0x0C, -} QMI_NAS_RADIO_INTERFACE_E; - -typedef enum { - QMI_NAS_ACTIVE_BAND_BC_0 = 0, - QMI_NAS_ACTIVE_BAND_BC_1 = 1, - QMI_NAS_ACTIVE_BAND_BC_2 = 2, - QMI_NAS_ACTIVE_BAND_BC_3 = 3, - QMI_NAS_ACTIVE_BAND_BC_4 = 4, - QMI_NAS_ACTIVE_BAND_BC_5 = 5, - QMI_NAS_ACTIVE_BAND_BC_6 = 6, - QMI_NAS_ACTIVE_BAND_BC_7 = 7, - QMI_NAS_ACTIVE_BAND_BC_8 = 8, - QMI_NAS_ACTIVE_BAND_BC_9 = 9, - QMI_NAS_ACTIVE_BAND_BC_10 = 10, - QMI_NAS_ACTIVE_BAND_BC_11 = 11, - QMI_NAS_ACTIVE_BAND_BC_12 = 12, - QMI_NAS_ACTIVE_BAND_BC_13 = 13, - QMI_NAS_ACTIVE_BAND_BC_14 = 14, - QMI_NAS_ACTIVE_BAND_BC_15 = 15, - QMI_NAS_ACTIVE_BAND_BC_16 = 16, - QMI_NAS_ACTIVE_BAND_BC_17 = 17, - QMI_NAS_ACTIVE_BAND_BC_18 = 18, - QMI_NAS_ACTIVE_BAND_BC_19 = 19, - QMI_NAS_ACTIVE_BAND_GSM_450 = 40, - QMI_NAS_ACTIVE_BAND_GSM_480 = 41, - QMI_NAS_ACTIVE_BAND_GSM_750 = 42, - QMI_NAS_ACTIVE_BAND_GSM_850 = 43, - QMI_NAS_ACTIVE_BAND_GSM_900_EXTENDED = 44, - QMI_NAS_ACTIVE_BAND_GSM_900_PRIMARY = 45, - QMI_NAS_ACTIVE_BAND_GSM_900_RAILWAYS = 46, - QMI_NAS_ACTIVE_BAND_GSM_DCS_1800 = 47, - QMI_NAS_ACTIVE_BAND_GSM_PCS_1900 = 48, - QMI_NAS_ACTIVE_BAND_WCDMA_2100 = 80, - QMI_NAS_ACTIVE_BAND_WCDMA_PCS_1900 = 81, - QMI_NAS_ACTIVE_BAND_WCDMA_DCS_1800 = 82, - QMI_NAS_ACTIVE_BAND_WCDMA_1700_US = 83, - QMI_NAS_ACTIVE_BAND_WCDMA_850 = 84, - QMI_NAS_ACTIVE_BAND_WCDMA_800 = 85, - QMI_NAS_ACTIVE_BAND_WCDMA_2600 = 86, - QMI_NAS_ACTIVE_BAND_WCDMA_900 = 87, - QMI_NAS_ACTIVE_BAND_WCDMA_1700_JAPAN = 88, - QMI_NAS_ACTIVE_BAND_WCDMA_1500_JAPAN = 90, - QMI_NAS_ACTIVE_BAND_WCDMA_850_JAPAN = 91, - QMI_NAS_ACTIVE_BAND_EUTRAN_1 = 120, - QMI_NAS_ACTIVE_BAND_EUTRAN_2 = 121, - QMI_NAS_ACTIVE_BAND_EUTRAN_3 = 122, - QMI_NAS_ACTIVE_BAND_EUTRAN_4 = 123, - QMI_NAS_ACTIVE_BAND_EUTRAN_5 = 124, - QMI_NAS_ACTIVE_BAND_EUTRAN_6 = 125, - QMI_NAS_ACTIVE_BAND_EUTRAN_7 = 126, - QMI_NAS_ACTIVE_BAND_EUTRAN_8 = 127, - QMI_NAS_ACTIVE_BAND_EUTRAN_9 = 128, - QMI_NAS_ACTIVE_BAND_EUTRAN_10 = 129, - QMI_NAS_ACTIVE_BAND_EUTRAN_11 = 130, - QMI_NAS_ACTIVE_BAND_EUTRAN_12 = 131, - QMI_NAS_ACTIVE_BAND_EUTRAN_13 = 132, - QMI_NAS_ACTIVE_BAND_EUTRAN_14 = 133, - QMI_NAS_ACTIVE_BAND_EUTRAN_17 = 134, - QMI_NAS_ACTIVE_BAND_EUTRAN_18 = 143, - QMI_NAS_ACTIVE_BAND_EUTRAN_19 = 144, - QMI_NAS_ACTIVE_BAND_EUTRAN_20 = 145, - QMI_NAS_ACTIVE_BAND_EUTRAN_21 = 146, - QMI_NAS_ACTIVE_BAND_EUTRAN_23 = 152, - QMI_NAS_ACTIVE_BAND_EUTRAN_24 = 147, - QMI_NAS_ACTIVE_BAND_EUTRAN_25 = 148, - QMI_NAS_ACTIVE_BAND_EUTRAN_26 = 153, - QMI_NAS_ACTIVE_BAND_EUTRAN_27 = 164, - QMI_NAS_ACTIVE_BAND_EUTRAN_28 = 158, - QMI_NAS_ACTIVE_BAND_EUTRAN_29 = 159, - QMI_NAS_ACTIVE_BAND_EUTRAN_30 = 160, - QMI_NAS_ACTIVE_BAND_EUTRAN_31 = 165, - QMI_NAS_ACTIVE_BAND_EUTRAN_32 = 154, - QMI_NAS_ACTIVE_BAND_EUTRAN_33 = 135, - QMI_NAS_ACTIVE_BAND_EUTRAN_34 = 136, - QMI_NAS_ACTIVE_BAND_EUTRAN_35 = 137, - QMI_NAS_ACTIVE_BAND_EUTRAN_36 = 138, - QMI_NAS_ACTIVE_BAND_EUTRAN_37 = 139, - QMI_NAS_ACTIVE_BAND_EUTRAN_38 = 140, - QMI_NAS_ACTIVE_BAND_EUTRAN_39 = 141, - QMI_NAS_ACTIVE_BAND_EUTRAN_40 = 142, - QMI_NAS_ACTIVE_BAND_EUTRAN_41 = 149, - QMI_NAS_ACTIVE_BAND_EUTRAN_42 = 150, - QMI_NAS_ACTIVE_BAND_EUTRAN_43 = 151, - QMI_NAS_ACTIVE_BAND_EUTRAN_46 = 163, - QMI_NAS_ACTIVE_BAND_EUTRAN_47 = 166, - QMI_NAS_ACTIVE_BAND_EUTRAN_48 = 167, - QMI_NAS_ACTIVE_BAND_EUTRAN_66 = 161, - QMI_NAS_ACTIVE_BAND_EUTRAN_71 = 168, - QMI_NAS_ACTIVE_BAND_EUTRAN_125 = 155, - QMI_NAS_ACTIVE_BAND_EUTRAN_126 = 156, - QMI_NAS_ACTIVE_BAND_EUTRAN_127 = 157, - QMI_NAS_ACTIVE_BAND_EUTRAN_250 = 162, - QMI_NAS_ACTIVE_BAND_TDSCDMA_A = 200, - QMI_NAS_ACTIVE_BAND_TDSCDMA_B = 201, - QMI_NAS_ACTIVE_BAND_TDSCDMA_C = 202, - QMI_NAS_ACTIVE_BAND_TDSCDMA_D = 203, - QMI_NAS_ACTIVE_BAND_TDSCDMA_E = 204, - QMI_NAS_ACTIVE_BAND_TDSCDMA_F = 205, - QMI_NAS_ACTIVE_BAND_NR5G_BAND_1 = 250, - QMI_NAS_ACTIVE_BAND_NR5G_BAND_2 = 251, - QMI_NAS_ACTIVE_BAND_NR5G_BAND_3 = 252, - QMI_NAS_ACTIVE_BAND_NR5G_BAND_5 = 253, - QMI_NAS_ACTIVE_BAND_NR5G_BAND_7 = 254, - QMI_NAS_ACTIVE_BAND_NR5G_BAND_8 = 255, - QMI_NAS_ACTIVE_BAND_NR5G_BAND_20 = 256, - QMI_NAS_ACTIVE_BAND_NR5G_BAND_28 = 257, - QMI_NAS_ACTIVE_BAND_NR5G_BAND_38 = 258, - QMI_NAS_ACTIVE_BAND_NR5G_BAND_41 = 259, - QMI_NAS_ACTIVE_BAND_NR5G_BAND_50 = 260, - QMI_NAS_ACTIVE_BAND_NR5G_BAND_51 = 261, - QMI_NAS_ACTIVE_BAND_NR5G_BAND_66 = 262, - QMI_NAS_ACTIVE_BAND_NR5G_BAND_70 = 263, - QMI_NAS_ACTIVE_BAND_NR5G_BAND_71 = 264, - QMI_NAS_ACTIVE_BAND_NR5G_BAND_74 = 265, - QMI_NAS_ACTIVE_BAND_NR5G_BAND_75 = 266, - QMI_NAS_ACTIVE_BAND_NR5G_BAND_76 = 267, - QMI_NAS_ACTIVE_BAND_NR5G_BAND_77 = 268, - QMI_NAS_ACTIVE_BAND_NR5G_BAND_78 = 269, - QMI_NAS_ACTIVE_BAND_NR5G_BAND_79 = 270, - QMI_NAS_ACTIVE_BAND_NR5G_BAND_80 = 271, - QMI_NAS_ACTIVE_BAND_NR5G_BAND_81 = 272, - QMI_NAS_ACTIVE_BAND_NR5G_BAND_82 = 273, - QMI_NAS_ACTIVE_BAND_NR5G_BAND_83 = 274, - QMI_NAS_ACTIVE_BAND_NR5G_BAND_84 = 275, - QMI_NAS_ACTIVE_BAND_NR5G_BAND_85 = 276, - QMI_NAS_ACTIVE_BAND_NR5G_BAND_257= 277, - QMI_NAS_ACTIVE_BAND_NR5G_BAND_258= 278, - QMI_NAS_ACTIVE_BAND_NR5G_BAND_259= 279, - QMI_NAS_ACTIVE_BAND_NR5G_BAND_260= 280, - QMI_NAS_ACTIVE_BAND_NR5G_BAND_261= 281, - QMI_NAS_ACTIVE_BAND_NR5G_BAND_12 = 282, - QMI_NAS_ACTIVE_BAND_NR5G_BAND_25 = 283, - QMI_NAS_ACTIVE_BAND_NR5G_BAND_34 = 284, - QMI_NAS_ACTIVE_BAND_NR5G_BAND_39 = 285, - QMI_NAS_ACTIVE_BAND_NR5G_BAND_40 = 286, - QMI_NAS_ACTIVE_BAND_NR5G_BAND_65 = 287, - QMI_NAS_ACTIVE_BAND_NR5G_BAND_86 = 288, - QMI_NAS_ACTIVE_BAND_NR5G_BAND_48 = 289, - QMI_NAS_ACTIVE_BAND_NR5G_BAND_14 = 290 -} QMI_NAS_ACTIVE_BAND_E; - -typedef struct { - UCHAR TLVType; - USHORT TLVLength; - - uint8_t srv_domain_valid; - uint8_t srv_domain; - uint8_t srv_capability_valid; - uint8_t srv_capability; - uint8_t roam_status_valid; - uint8_t roam_status; - uint8_t is_sys_forbidden_valid; - uint8_t is_sys_forbidden; - - uint8_t lac_valid; - uint16_t lac; - uint8_t cell_id_valid; - uint32_t cell_id; - uint8_t reg_reject_info_valid; - uint8_t reject_srv_domain; - uint8_t rej_cause; - uint8_t network_id_valid; - UCHAR MCC[3]; - UCHAR MNC[3]; - - uint8_t tac_valid; - uint16_t tac; -} __attribute__ ((packed)) NR5G_SYSTEM_INFO, *PNR5G_SYSTEM_INFO; - -#if 0 -typedef struct _QMINAS_SERVING_SYSTEM_IND_MSG -{ - USHORT Type; - USHORT Length; -} QMINAS_SERVING_SYSTEM_IND_MSG, *PQMINAS_SERVING_SYSTEM_IND_MSG; - -typedef struct _QMINAS_SET_PREFERRED_NETWORK_REQ_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT NumPreferredNetwork; - USHORT MobileCountryCode; - USHORT MobileNetworkCode; - USHORT RadioAccess; -} QMINAS_SET_PREFERRED_NETWORK_REQ_MSG, *PQMINAS_SET_PREFERRED_NETWORK_REQ_MSG; - -typedef struct _QMINAS_SET_PREFERRED_NETWORK_RESP_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT -} QMINAS_SET_PREFERRED_NETWORK_RESP_MSG, *PQMINAS_SET_PREFERRED_NETWORK_RESP_MSG; - -typedef struct _QMINAS_SET_FORBIDDEN_NETWORK_REQ_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT NumForbiddenNetwork; - USHORT MobileCountryCode; - USHORT MobileNetworkCode; -} QMINAS_SET_FORBIDDEN_NETWORK_REQ_MSG, *PQMINAS_SET_FORBIDDEN_NETWORK_REQ_MSG; - -typedef struct _QMINAS_SET_FORBIDDEN_NETWORK_RESP_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT -} QMINAS_SET_FORBIDDEN_NETWORK_RESP_MSG, *PQMINAS_SET_FORBIDDEN_NETWORK_RESP_MSG; - -typedef struct _QMINAS_PERFORM_NETWORK_SCAN_REQ_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; -} QMINAS_PERFORM_NETWORK_SCAN_REQ_MSG, *PQMINAS_PERFORM_NETWORK_SCAN_REQ_MSG; - -typedef struct _VISIBLE_NETWORK -{ - USHORT MobileCountryCode; - USHORT MobileNetworkCode; - UCHAR NetworkStatus; - UCHAR NetworkDesclen; -} VISIBLE_NETWORK, *PVISIBLE_NETWORK; - -typedef struct _QMINAS_PERFORM_NETWORK_SCAN_RESP_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT -} QMINAS_PERFORM_NETWORK_SCAN_RESP_MSG, *PQMINAS_PERFORM_NETWORK_SCAN_RESP_MSG; - -typedef struct _QMINAS_PERFORM_NETWORK_SCAN_NETWORK_INFO -{ - UCHAR TLVType; // 0x010 - required parameter - USHORT TLVLength; // length - USHORT NumNetworkInstances; -} QMINAS_PERFORM_NETWORK_SCAN_NETWORK_INFO, *PQMINAS_PERFORM_NETWORK_SCAN_NETWORK_INFO; - -typedef struct _QMINAS_PERFORM_NETWORK_SCAN_RAT_INFO -{ - UCHAR TLVType; // 0x011 - required parameter - USHORT TLVLength; // length - USHORT NumInst; -} QMINAS_PERFORM_NETWORK_SCAN_RAT_INFO, *PQMINAS_PERFORM_NETWORK_SCAN_RAT_INFO; - -typedef struct _QMINAS_PERFORM_NETWORK_SCAN_RAT -{ - USHORT MCC; - USHORT MNC; - UCHAR RAT; -} QMINAS_PERFORM_NETWORK_SCAN_RAT, *PQMINAS_PERFORM_NETWORK_SCAN_RAT; - - -typedef struct _QMINAS_MANUAL_NW_REGISTER -{ - UCHAR TLV2Type; // 0x02 - result code - USHORT TLV2Length; // 4 - USHORT MobileCountryCode; - USHORT MobileNetworkCode; - UCHAR RadioAccess; -} QMINAS_MANUAL_NW_REGISTER, *PQMINAS_MANUAL_NW_REGISTER; - -typedef struct _QMINAS_INITIATE_NW_REGISTER_REQ_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - UCHAR RegisterAction; -} QMINAS_INITIATE_NW_REGISTER_REQ_MSG, *PQMINAS_INITIATE_NW_REGISTER_REQ_MSG; - -typedef struct _QMINAS_INITIATE_NW_REGISTER_RESP_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT -} QMINAS_INITIATE_NW_REGISTER_RESP_MSG, *PQMINAS_INITIATE_NW_REGISTER_RESP_MSG; - -typedef struct _QMINAS_SET_TECHNOLOGY_PREF_REQ_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT TechPref; - UCHAR Duration; -} QMINAS_SET_TECHNOLOGY_PREF_REQ_MSG, *PQMINAS_SET_TECHNOLOGY_PREF_REQ_MSG; - -typedef struct _QMINAS_SET_TECHNOLOGY_PREF_RESP_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT -} QMINAS_SET_TECHNOLOGY_PREF_RESP_MSG, *PQMINAS_SET_TECHNOLOGY_PREF_RESP_MSG; - -typedef struct _QMINAS_GET_SIGNAL_STRENGTH_REQ_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; -} QMINAS_GET_SIGNAL_STRENGTH_REQ_MSG, *PQMINAS_GET_SIGNAL_STRENGTH_REQ_MSG; - -typedef struct _QMINAS_SIGNAL_STRENGTH -{ - CHAR SigStrength; - UCHAR RadioIf; -} QMINAS_SIGNAL_STRENGTH, *PQMINAS_SIGNAL_STRENGTH; - -typedef struct _QMINAS_SIGNAL_STRENGTH_LIST -{ - UCHAR TLV3Type; - USHORT TLV3Length; - USHORT NumInstance; -} QMINAS_SIGNAL_STRENGTH_LIST, *PQMINAS_SIGNAL_STRENGTH_LIST; - - -typedef struct _QMINAS_GET_SIGNAL_STRENGTH_RESP_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT - UCHAR TLV2Type; - USHORT TLV2Length; - CHAR SignalStrength; - UCHAR RadioIf; -} QMINAS_GET_SIGNAL_STRENGTH_RESP_MSG, *PQMINAS_GET_SIGNAL_STRENGTH_RESP_MSG; - - -typedef struct _QMINAS_SET_EVENT_REPORT_REQ_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - UCHAR ReportSigStrength; - UCHAR NumTresholds; - CHAR TresholdList[2]; -} QMINAS_SET_EVENT_REPORT_REQ_MSG, *PQMINAS_SET_EVENT_REPORT_REQ_MSG; - -typedef struct _QMINAS_SET_EVENT_REPORT_RESP_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT -} QMINAS_SET_EVENT_REPORT_RESP_MSG, *PQMINAS_SET_EVENT_REPORT_RESP_MSG; - -typedef struct _QMINAS_SIGNAL_STRENGTH_TLV -{ - UCHAR TLVType; - USHORT TLVLength; - CHAR SigStrength; - UCHAR RadioIf; -} QMINAS_SIGNAL_STRENGTH_TLV, *PQMINAS_SIGNAL_STRENGTH_TLV; - -typedef struct _QMINAS_REJECT_CAUSE_TLV -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR ServiceDomain; - USHORT RejectCause; -} QMINAS_REJECT_CAUSE_TLV, *PQMINAS_REJECT_CAUSE_TLV; - -typedef struct _QMINAS_EVENT_REPORT_IND_MSG -{ - USHORT Type; - USHORT Length; -} QMINAS_EVENT_REPORT_IND_MSG, *PQMINAS_EVENT_REPORT_IND_MSG; - -typedef struct _QMINAS_GET_RF_BAND_INFO_REQ_MSG -{ - USHORT Type; - USHORT Length; -} QMINAS_GET_RF_BAND_INFO_REQ_MSG, *PQMINAS_GET_RF_BAND_INFO_REQ_MSG; - -typedef struct _QMINASRF_BAND_INFO -{ - UCHAR RadioIf; - USHORT ActiveBand; - USHORT ActiveChannel; -} QMINASRF_BAND_INFO, *PQMINASRF_BAND_INFO; - -typedef struct _QMINAS_GET_RF_BAND_INFO_RESP_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT - UCHAR TLV2Type; - USHORT TLV2Length; - UCHAR NumInstances; -} QMINAS_GET_RF_BAND_INFO_RESP_MSG, *PQMINAS_GET_RF_BAND_INFO_RESP_MSG; - - -typedef struct _QMINAS_GET_PLMN_NAME_REQ_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT MCC; - USHORT MNC; -} QMINAS_GET_PLMN_NAME_REQ_MSG, *PQMINAS_GET_PLMN_NAME_REQ_MSG; - -typedef struct _QMINAS_GET_PLMN_NAME_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT -} QMINAS_GET_PLMN_NAME_RESP_MSG, *PQMINAS_GET_PLMN_NAME_RESP_MSG; - -typedef struct _QMINAS_GET_PLMN_NAME_SPN -{ - UCHAR TLVType; - USHORT TLVLength; - UCHAR SPN_Enc; - UCHAR SPN_Len; -} QMINAS_GET_PLMN_NAME_SPN, *PQMINAS_GET_PLMN_NAME_SPN; - -typedef struct _QMINAS_GET_PLMN_NAME_PLMN -{ - UCHAR PLMN_Enc; - UCHAR PLMN_Ci; - UCHAR PLMN_SpareBits; - UCHAR PLMN_Len; -} QMINAS_GET_PLMN_NAME_PLMN, *PQMINAS_GET_PLMN_NAME_PLMN; - -typedef struct _QMINAS_INITIATE_ATTACH_REQ_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - UCHAR PsAttachAction; -} QMINAS_INITIATE_ATTACH_REQ_MSG, *PQMINAS_INITIATE_ATTACH_REQ_MSG; - -typedef struct _QMINAS_INITIATE_ATTACH_RESP_MSG -{ - USHORT Type; // QMUX type 0x0003 - USHORT Length; - UCHAR TLVType; // 0x02 - result code - USHORT TLVLength; // 4 - USHORT QMUXResult; // QMI_RESULT_SUCCESS - // QMI_RESULT_FAILURE - USHORT QMUXError; // QMI_ERR_INVALID_ARG - // QMI_ERR_NO_MEMORY - // QMI_ERR_INTERNAL - // QMI_ERR_FAULT -} QMINAS_INITIATE_ATTACH_RESP_MSG, *PQMINAS_INITIATE_ATTACH_RESP_MSG; -#endif -typedef struct { - UCHAR TLVType; - USHORT TLVLength; - CHAR rssi; - SHORT ecio; -} __attribute__ ((packed)) QMINAS_SIG_INFO_CDMA_TLV_MSG, *PQMINAS_SIG_INFO_CDMA_TLV_MSG; - -typedef struct { - UCHAR TLVType; - USHORT TLVLength; - CHAR rssi; - SHORT ecio; - CHAR sinr; - INT io; -} __attribute__ ((packed)) QMINAS_SIG_INFO_HDR_TLV_MSG, *PQMINAS_SIG_INFO_HDR_TLV_MSG; - -typedef struct { - UCHAR TLVType; - USHORT TLVLength; - CHAR rssi; -} __attribute__ ((packed)) QMINAS_SIG_INFO_GSM_TLV_MSG, *PQMINAS_SIG_INFO_GSM_TLV_MSG; - -typedef struct { - UCHAR TLVType; - USHORT TLVLength; - CHAR rssi; - SHORT ecio; -} __attribute__ ((packed)) QMINAS_SIG_INFO_WCDMA_TLV_MSG, *PQMINAS_SIG_INFO_WCDMA_TLV_MSG; - -typedef struct { - UCHAR TLVType; - USHORT TLVLength; - CHAR rssi; - CHAR rsrq; - SHORT rsrp; - SHORT snr; -} __attribute__ ((packed)) QMINAS_SIG_INFO_LTE_TLV_MSG, *PQMINAS_SIG_INFO_LTE_TLV_MSG; - -typedef struct { - UCHAR TLVType; - USHORT TLVLength; - CHAR rscp; -} __attribute__ ((packed)) QMINAS_SIG_INFO_TDSCDMA_TLV_MSG, *PQMINAS_SIG_INFO_TDSCDMA_TLV_MSG; - -typedef struct { - UCHAR TLVType; - USHORT TLVLength; - SHORT rsrp; - SHORT snr; -} __attribute__ ((packed)) QMINAS_SIG_INFO_5G_NSA_TLV_MSG, *PQMINAS_SIG_INFO_5G_NSA_TLV_MSG; - -typedef struct { - UCHAR TLVType; - USHORT TLVLength; - SHORT nr5g_rsrq; -} __attribute__ ((packed)) QMINAS_SIG_INFO_5G_SA_TLV_MSG, *PQMINAS_SIG_INFO_5G_SA_TLV_MSG; - -typedef struct { - uint8 radio_if; - uint16 active_band; - uint16 active_channel; -} __attribute__ ((packed)) NasGetRfBandInfo; - -typedef struct { - UCHAR TLVType; - USHORT TLVLength; - - uint8 num_instances; - NasGetRfBandInfo bands_array[0]; -} __attribute__ ((packed)) NasGetRfBandInfoList; - -typedef struct { - uint8 radio_if; - uint16 dedicated_band; -} __attribute__ ((packed)) NasGetRfBandInfoDedicated; - -typedef struct { - UCHAR TLVType; - USHORT TLVLength; - - uint8 num_instances; - NasGetRfBandInfoDedicated bands_array[0]; -} __attribute__ ((packed)) NasGetRfBandInfoDedicatedList; - -typedef struct { - uint8 radio_if; - uint16 active_band; - uint32 active_channel; -} __attribute__ ((packed)) NasGetRfBandInfoExtended; - -typedef struct { - UCHAR TLVType; - USHORT TLVLength; - - uint8 num_instances; - NasGetRfBandInfoExtended bands_array[0]; -} __attribute__ ((packed)) NasGetRfBandInfoExtendedList; - -typedef struct { - uint8 radio_if; - uint32 bandwidth; -} __attribute__ ((packed)) NasGetRfBandInfoBandWidth; - -typedef struct { - UCHAR TLVType; - USHORT TLVLength; - - uint8 num_instances; - NasGetRfBandInfoBandWidth bands_array[0]; -} __attribute__ ((packed)) NasGetRfBandInfoBandWidthList; - -typedef struct { - UCHAR TLVType; - USHORT TLVLength; - - uint8 plmn[3]; - uint8 tac[3]; - uint64 global_cell_id; - uint16 physical_cell_id; - int16 rsrq; - int16 rsrp; - int16 snr; -} __attribute__ ((packed)) NasGetCellLocationNr5gServingCell; - -typedef struct { - uint16 physical_cell_id; - int16 rsrq; - int16 rsrp; - int16 rssi; - int16 cell_selection_rx_level; -} __attribute__ ((packed)) NasGetCellLocationLteInfoCell; - -typedef struct { - UCHAR TLVType; - USHORT TLVLength; - - uint8 ue_in_idle; - uint8 plmn[3]; - uint16 tracking_area_code; - uint32 global_cell_id; - uint16 absolute_rf_channel_number; - uint16 serving_cell_id; - uint8 cell_reselection_priority; - uint8 s_non_intra_search_threshold; - uint8 serving_cell_low_threshold; - uint8 s_intra_search_threshold; - uint8 cells_len; - NasGetCellLocationLteInfoCell cells_array[0]; -} __attribute__ ((packed)) NasGetCellLocationLteInfoIntrafrequency; - -typedef struct _QmiMessageNasGetCellLocationInfoOutputInterfrequencyLteInfoFrequencyElement { - uint16 eutra_absolute_rf_channel_number; - uint8 cell_selection_rx_level_low_threshold; - uint8 cell_selection_rx_level_high_threshold; - uint8 cell_reselection_priority; - uint8 cells_len; - NasGetCellLocationLteInfoCell cells_array[0]; -} __attribute__ ((packed)) NasGetCellLocationLteInfoInterfrequencyFrequencyElement; - -typedef struct { - UCHAR TLVType; - USHORT TLVLength; - - uint8 ue_in_idle; - uint8 freqs_len; - NasGetCellLocationLteInfoInterfrequencyFrequencyElement freqs[0]; -} __attribute__ ((packed)) NasGetCellLocationLteInfoInterfrequency; - -// ======================= End of NAS ============================== - -// ======================= UIM ============================== -#define QMIUIM_READ_TRANSPARENT_REQ 0x0020 -#define QMIUIM_READ_TRANSPARENT_RESP 0x0020 -#define QMIUIM_READ_TRANSPARENT_IND 0x0020 -#define QMIUIM_READ_RECORD_REQ 0x0021 -#define QMIUIM_READ_RECORD_RESP 0x0021 -#define QMIUIM_READ_RECORD_IND 0x0021 -#define QMIUIM_WRITE_TRANSPARENT_REQ 0x0022 -#define QMIUIM_WRITE_TRANSPARENT_RESP 0x0022 -#define QMIUIM_WRITE_TRANSPARENT_IND 0x0022 -#define QMIUIM_WRITE_RECORD_REQ 0x0023 -#define QMIUIM_WRITE_RECORD_RESP 0x0023 -#define QMIUIM_WRITE_RECORD_IND 0x0023 -#define QMIUIM_SET_PIN_PROTECTION_REQ 0x0025 -#define QMIUIM_SET_PIN_PROTECTION_RESP 0x0025 -#define QMIUIM_SET_PIN_PROTECTION_IND 0x0025 -#define QMIUIM_VERIFY_PIN_REQ 0x0026 -#define QMIUIM_VERIFY_PIN_RESP 0x0026 -#define QMIUIM_VERIFY_PIN_IND 0x0026 -#define QMIUIM_UNBLOCK_PIN_REQ 0x0027 -#define QMIUIM_UNBLOCK_PIN_RESP 0x0027 -#define QMIUIM_UNBLOCK_PIN_IND 0x0027 -#define QMIUIM_CHANGE_PIN_REQ 0x0028 -#define QMIUIM_CHANGE_PIN_RESP 0x0028 -#define QMIUIM_CHANGE_PIN_IND 0x0028 -#define QMIUIM_DEPERSONALIZATION_REQ 0x0029 -#define QMIUIM_DEPERSONALIZATION_RESP 0x0029 -#define QMIUIM_EVENT_REG_REQ 0x002E -#define QMIUIM_EVENT_REG_RESP 0x002E -#define QMIUIM_GET_CARD_STATUS_REQ 0x002F -#define QMIUIM_GET_CARD_STATUS_RESP 0x002F -#define QMIUIM_STATUS_CHANGE_IND 0x0032 -#define QMIUIM_POWER_DOWN 0x0030 -#define QMIUIM_POWER_UP 0x0031 - - -typedef struct _QMIUIM_GET_CARD_STATUS_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; -} __attribute__ ((packed)) QMIUIM_GET_CARD_STATUS_RESP_MSG, *PQMIUIM_GET_CARD_STATUS_RESP_MSG; - -#define UIM_CARD_STATE_ABSENT 0x00 -#define UIM_CARD_STATE_PRESENT 0x01 -#define UIM_CARD_STATE_ERROR 0x02 - -typedef struct _QMIUIM_CARD_STATUS -{ - UCHAR TLVType; - USHORT TLVLength; - USHORT IndexGWPri; - USHORT Index1XPri; - USHORT IndexGWSec; - USHORT Index1XSec; - UCHAR NumSlot; - UCHAR CardState; - UCHAR UPINState; - UCHAR UPINRetries; - UCHAR UPUKRetries; - UCHAR ErrorCode; - UCHAR NumApp; - UCHAR AppType; - UCHAR AppState; - UCHAR PersoState; - UCHAR PersoFeature; - UCHAR PersoRetries; - UCHAR PersoUnblockRetries; - UCHAR AIDLength; -} __attribute__ ((packed)) QMIUIM_CARD_STATUS, *PQMIUIM_CARD_STATUS; - -typedef struct _QMIUIM_PIN_STATE -{ - UCHAR UnivPIN; - UCHAR PIN1State; - UCHAR PIN1Retries; - UCHAR PUK1Retries; - UCHAR PIN2State; - UCHAR PIN2Retries; - UCHAR PUK2Retries; -} __attribute__ ((packed)) QMIUIM_PIN_STATE, *PQMIUIM_PIN_STATE; - -typedef struct _QMIUIM_VERIFY_PIN_REQ_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - UCHAR Session_Type; - UCHAR Aid_Len; - UCHAR TLV2Type; - USHORT TLV2Length; - UCHAR PINID; - UCHAR PINLen; - UCHAR PINValue; -} __attribute__ ((packed)) QMIUIM_VERIFY_PIN_REQ_MSG, *PQMIUIM_VERIFY_PIN_REQ_MSG; - -typedef struct _QMIUIM_VERIFY_PIN_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; - UCHAR TLV2Type; - USHORT TLV2Length; - UCHAR PINVerifyRetriesLeft; - UCHAR PINUnblockRetriesLeft; -} __attribute__ ((packed)) QMIUIM_VERIFY_PIN_RESP_MSG, *PQMIUIM_VERIFY_PIN_RESP_MSG; - -typedef struct _QMIUIM_READ_TRANSPARENT_REQ_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - UCHAR Session_Type; - UCHAR Aid_Len; - UCHAR TLV2Type; - USHORT TLV2Length; - USHORT file_id; - UCHAR path_len; - UCHAR path[]; -} __attribute__ ((packed)) QMIUIM_READ_TRANSPARENT_REQ_MSG, *PQMIUIM_READ_TRANSPARENT_REQ_MSG; - -typedef struct _READ_TRANSPARENT_TLV -{ - UCHAR TLVType; - USHORT TLVLength; - USHORT Offset; - USHORT Length; -} __attribute__ ((packed)) READ_TRANSPARENT_TLV, *PREAD_TRANSPARENT_TLV; - -typedef struct _QMIUIM_CONTENT -{ - UCHAR TLVType; - USHORT TLVLength; - USHORT content_len; - UCHAR content[]; -} __attribute__ ((packed)) QMIUIM_CONTENT, *PQMIUIM_CONTENT; - -typedef struct _QMIUIM_READ_TRANSPARENT_RESP_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - USHORT QMUXResult; - USHORT QMUXError; -} __attribute__ ((packed)) QMIUIM_READ_TRANSPARENT_RESP_MSG, *PQMIUIM_READ_TRANSPARENT_RESP_MSG; - -typedef struct _QMIUIM_SET_CARD_SLOT_REQ_MSG -{ - USHORT Type; - USHORT Length; - UCHAR TLVType; - USHORT TLVLength; - UCHAR slot; -} __attribute__ ((packed)) QMIUIM_SET_CARD_SLOT_REQ_MSG, *PQMIUIM_SET_CARD_SLOT_REQ_MSG; - -// ======================= COEX ============================== -#define QMI_COEX_GET_WWAN_STATE_REQ 0x22 -#define QMI_COEX_GET_WWAN_STATE_RESP 0x22 - -typedef struct { - - uint32_t freq; - /**< Band center frequency in MHz. */ - - uint32_t bandwidth; - /**< Bandwidth in MHz. */ -}coex_band_type_v01; /* Type */ - -typedef struct _QMI_COEX_GET_WWAN_STATE_RESP_MSG_LTE_BAND -{ - UCHAR TLVType; - USHORT TLVLength; - coex_band_type_v01 ul_band; - coex_band_type_v01 dl_band; -} __attribute__ ((packed)) QMI_COEX_GET_WWAN_STATE_RESP_MSG_LTE_BAND, *PQMI_COEX_GET_WWAN_STATE_RESP_MSG_LTE_BAND; - - -typedef struct _QMUX_MSG -{ - QCQMUX_HDR QMUXHdr; - union - { - // Message Header - QCQMUX_MSG_HDR QMUXMsgHdr; - QCQMUX_MSG_HDR_RESP QMUXMsgHdrResp; - - // QMIWDS Message -#if 0 - QMIWDS_GET_PKT_SRVC_STATUS_REQ_MSG PacketServiceStatusReq; - QMIWDS_GET_PKT_SRVC_STATUS_RESP_MSG PacketServiceStatusRsp; - QMIWDS_GET_PKT_SRVC_STATUS_IND_MSG PacketServiceStatusInd; - QMIWDS_EVENT_REPORT_IND_MSG EventReportInd; - QMIWDS_GET_CURRENT_CHANNEL_RATE_REQ_MSG GetCurrChannelRateReq; - QMIWDS_GET_CURRENT_CHANNEL_RATE_RESP_MSG GetCurrChannelRateRsp; - QMIWDS_GET_PKT_STATISTICS_REQ_MSG GetPktStatsReq; - QMIWDS_GET_PKT_STATISTICS_RESP_MSG GetPktStatsRsp; - QMIWDS_SET_EVENT_REPORT_REQ_MSG EventReportReq; - QMIWDS_SET_EVENT_REPORT_RESP_MSG EventReportRsp; -#endif - //#ifdef QC_IP_MODE - QMIWDS_GET_RUNTIME_SETTINGS_REQ_MSG GetRuntimeSettingsReq; - QMIWDS_GET_RUNTIME_SETTINGS_RESP_MSG GetRuntimeSettingsRsp; - //#endif // QC_IP_MODE - QMIWDS_SET_CLIENT_IP_FAMILY_PREF_REQ_MSG SetClientIpFamilyPrefReq; - QMIWDS_SET_CLIENT_IP_FAMILY_PREF_RESP_MSG SetClientIpFamilyPrefResp; - QMIWDS_SET_AUTO_CONNECT_REQ_MSG SetAutoConnectReq; -#if 0 - QMIWDS_GET_MIP_MODE_REQ_MSG GetMipModeReq; - QMIWDS_GET_MIP_MODE_RESP_MSG GetMipModeResp; -#endif - QMIWDS_START_NETWORK_INTERFACE_REQ_MSG StartNwInterfaceReq; - QMIWDS_START_NETWORK_INTERFACE_RESP_MSG StartNwInterfaceResp; - QMIWDS_STOP_NETWORK_INTERFACE_REQ_MSG StopNwInterfaceReq; - QMIWDS_STOP_NETWORK_INTERFACE_RESP_MSG StopNwInterfaceResp; - QMIWDS_GET_DEFAULT_SETTINGS_REQ_MSG GetDefaultSettingsReq; - QMIWDS_GET_DEFAULT_SETTINGS_RESP_MSG GetDefaultSettingsResp; - QMIWDS_MODIFY_PROFILE_SETTINGS_REQ_MSG ModifyProfileSettingsReq; - QMIWDS_MODIFY_PROFILE_SETTINGS_RESP_MSG ModifyProfileSettingsResp; - QMIWDS_GET_PROFILE_SETTINGS_REQ_MSG GetProfileSettingsReq; - QMIWDS_CREATE_PROFILE_SETTINGS_REQ_MSG CreatetProfileSettingsReq; -#if 0 - QMIWDS_GET_DATA_BEARER_REQ_MSG GetDataBearerReq; - QMIWDS_GET_DATA_BEARER_RESP_MSG GetDataBearerResp; - QMIWDS_DUN_CALL_INFO_REQ_MSG DunCallInfoReq; - QMIWDS_DUN_CALL_INFO_RESP_MSG DunCallInfoResp; -#endif - QMIWDS_BIND_MUX_DATA_PORT_REQ_MSG BindMuxDataPortReq; - - // QMIDMS Messages -#if 0 - QMIDMS_GET_DEVICE_MFR_REQ_MSG GetDeviceMfrReq; - QMIDMS_GET_DEVICE_MFR_RESP_MSG GetDeviceMfrRsp; - QMIDMS_GET_DEVICE_MODEL_ID_REQ_MSG GetDeviceModeIdReq; - QMIDMS_GET_DEVICE_MODEL_ID_RESP_MSG GetDeviceModeIdRsp; - QMIDMS_GET_DEVICE_REV_ID_REQ_MSG GetDeviceRevIdReq; - QMIDMS_GET_DEVICE_REV_ID_RESP_MSG GetDeviceRevIdRsp; - QMIDMS_GET_MSISDN_REQ_MSG GetMsisdnReq; - QMIDMS_GET_MSISDN_RESP_MSG GetMsisdnRsp; - QMIDMS_GET_DEVICE_SERIAL_NUMBERS_REQ_MSG GetDeviceSerialNumReq; - QMIDMS_GET_DEVICE_SERIAL_NUMBERS_RESP_MSG GetDeviceSerialNumRsp; - QMIDMS_GET_DEVICE_CAP_REQ_MSG GetDeviceCapReq; - QMIDMS_GET_DEVICE_CAP_RESP_MSG GetDeviceCapResp; - QMIDMS_GET_BAND_CAP_REQ_MSG GetBandCapReq; - QMIDMS_GET_BAND_CAP_RESP_MSG GetBandCapRsp; - QMIDMS_GET_ACTIVATED_STATUS_REQ_MSG GetActivatedStatusReq; - QMIDMS_GET_ACTIVATED_STATUS_RESP_MSG GetActivatedStatusResp; - QMIDMS_GET_OPERATING_MODE_REQ_MSG GetOperatingModeReq; - QMIDMS_GET_OPERATING_MODE_RESP_MSG GetOperatingModeResp; -#endif - QMIDMS_SET_OPERATING_MODE_REQ_MSG SetOperatingModeReq; - QMIDMS_SET_OPERATING_MODE_RESP_MSG SetOperatingModeResp; -#if 0 - QMIDMS_UIM_GET_ICCID_REQ_MSG GetICCIDReq; - QMIDMS_UIM_GET_ICCID_RESP_MSG GetICCIDResp; - QMIDMS_ACTIVATE_AUTOMATIC_REQ_MSG ActivateAutomaticReq; - QMIDMS_ACTIVATE_AUTOMATIC_RESP_MSG ActivateAutomaticResp; - QMIDMS_ACTIVATE_MANUAL_REQ_MSG ActivateManualReq; - QMIDMS_ACTIVATE_MANUAL_RESP_MSG ActivateManualResp; -#endif - QMIDMS_UIM_GET_PIN_STATUS_REQ_MSG UIMGetPinStatusReq; - QMIDMS_UIM_GET_PIN_STATUS_RESP_MSG UIMGetPinStatusResp; - QMIDMS_UIM_VERIFY_PIN_REQ_MSG UIMVerifyPinReq; - QMIDMS_UIM_VERIFY_PIN_RESP_MSG UIMVerifyPinResp; -#if 0 - QMIDMS_UIM_SET_PIN_PROTECTION_REQ_MSG UIMSetPinProtectionReq; - QMIDMS_UIM_SET_PIN_PROTECTION_RESP_MSG UIMSetPinProtectionResp; - QMIDMS_UIM_CHANGE_PIN_REQ_MSG UIMChangePinReq; - QMIDMS_UIM_CHANGE_PIN_RESP_MSG UIMChangePinResp; - QMIDMS_UIM_UNBLOCK_PIN_REQ_MSG UIMUnblockPinReq; - QMIDMS_UIM_UNBLOCK_PIN_RESP_MSG UIMUnblockPinResp; - QMIDMS_SET_EVENT_REPORT_REQ_MSG DmsSetEventReportReq; - QMIDMS_SET_EVENT_REPORT_RESP_MSG DmsSetEventReportResp; - QMIDMS_EVENT_REPORT_IND_MSG DmsEventReportInd; -#endif - QMIDMS_UIM_GET_STATE_REQ_MSG UIMGetStateReq; - QMIDMS_UIM_GET_STATE_RESP_MSG UIMGetStateResp; - QMIDMS_UIM_GET_IMSI_REQ_MSG UIMGetIMSIReq; - QMIDMS_UIM_GET_IMSI_RESP_MSG UIMGetIMSIResp; -#if 0 - QMIDMS_UIM_GET_CK_STATUS_REQ_MSG UIMGetCkStatusReq; - QMIDMS_UIM_GET_CK_STATUS_RESP_MSG UIMGetCkStatusResp; - QMIDMS_UIM_SET_CK_PROTECTION_REQ_MSG UIMSetCkProtectionReq; - QMIDMS_UIM_SET_CK_PROTECTION_RESP_MSG UIMSetCkProtectionResp; - QMIDMS_UIM_UNBLOCK_CK_REQ_MSG UIMUnblockCkReq; - QMIDMS_UIM_UNBLOCK_CK_RESP_MSG UIMUnblockCkResp; -#endif - - // QMIQOS Messages -#if 1 - QMI_QOS_SET_EVENT_REPORT_REQ_MSG QosSetEventReportReq; - QMI_QOS_SET_EVENT_REPORT_RESP_MSG QosSetEventReportRsp; - QMI_QOS_SET_EVENT_REPORT_IND_MSG QosSetEventReportInd; - QMI_QOS_BIND_DATA_PORT_REQ_MSG QosBindDataPortReq; - QMI_QOS_BIND_DATA_PORT_RESP_MSG QosBindDataPortRsp; - QMI_QOS_INDICATION_REGISTER_REQ_MSG QosIndRegReq; - QMI_QOS_INDICATION_REGISTER_RESP_MSG QosIndRegRsp; - QMI_QOS_GLOBAL_QOS_FLOW_IND_MSG QosGlobalQosFlowInd; - QMI_QOS_GET_QOS_INFO_REQ_MSG QosGetQosInfoReq; - QMI_QOS_GET_QOS_INFO_RESP_MSG QosGetQosInfoRsp; -#endif - - // QMIWMS Messages -#if 0 - QMIWMS_GET_MESSAGE_PROTOCOL_REQ_MSG GetMessageProtocolReq; - QMIWMS_GET_MESSAGE_PROTOCOL_RESP_MSG GetMessageProtocolResp; - QMIWMS_GET_SMSC_ADDRESS_REQ_MSG GetSMSCAddressReq; - QMIWMS_GET_SMSC_ADDRESS_RESP_MSG GetSMSCAddressResp; - QMIWMS_SET_SMSC_ADDRESS_REQ_MSG SetSMSCAddressReq; - QMIWMS_SET_SMSC_ADDRESS_RESP_MSG SetSMSCAddressResp; - QMIWMS_GET_STORE_MAX_SIZE_REQ_MSG GetStoreMaxSizeReq; - QMIWMS_GET_STORE_MAX_SIZE_RESP_MSG GetStoreMaxSizeResp; - QMIWMS_LIST_MESSAGES_REQ_MSG ListMessagesReq; - QMIWMS_LIST_MESSAGES_RESP_MSG ListMessagesResp; - QMIWMS_RAW_READ_REQ_MSG RawReadMessagesReq; - QMIWMS_RAW_READ_RESP_MSG RawReadMessagesResp; - QMIWMS_SET_EVENT_REPORT_REQ_MSG WmsSetEventReportReq; - QMIWMS_SET_EVENT_REPORT_RESP_MSG WmsSetEventReportResp; - QMIWMS_EVENT_REPORT_IND_MSG WmsEventReportInd; - QMIWMS_DELETE_REQ_MSG WmsDeleteReq; - QMIWMS_DELETE_RESP_MSG WmsDeleteResp; - QMIWMS_RAW_SEND_REQ_MSG RawSendMessagesReq; - QMIWMS_RAW_SEND_RESP_MSG RawSendMessagesResp; - QMIWMS_MODIFY_TAG_REQ_MSG WmsModifyTagReq; - QMIWMS_MODIFY_TAG_RESP_MSG WmsModifyTagResp; -#endif - - // QMINAS Messages -#if 0 - QMINAS_GET_HOME_NETWORK_REQ_MSG GetHomeNetworkReq; - QMINAS_GET_HOME_NETWORK_RESP_MSG GetHomeNetworkResp; - QMINAS_GET_PREFERRED_NETWORK_REQ_MSG GetPreferredNetworkReq; - QMINAS_GET_PREFERRED_NETWORK_RESP_MSG GetPreferredNetworkResp; - QMINAS_GET_FORBIDDEN_NETWORK_REQ_MSG GetForbiddenNetworkReq; - QMINAS_GET_FORBIDDEN_NETWORK_RESP_MSG GetForbiddenNetworkResp; - QMINAS_GET_SERVING_SYSTEM_REQ_MSG GetServingSystemReq; -#endif - QMINAS_GET_SERVING_SYSTEM_RESP_MSG GetServingSystemResp; - QMINAS_GET_SYS_INFO_RESP_MSG GetSysInfoResp; - QMINAS_SYS_INFO_IND_MSG NasSysInfoInd; -#if 0 - QMINAS_SERVING_SYSTEM_IND_MSG NasServingSystemInd; - QMINAS_SET_PREFERRED_NETWORK_REQ_MSG SetPreferredNetworkReq; - QMINAS_SET_PREFERRED_NETWORK_RESP_MSG SetPreferredNetworkResp; - QMINAS_SET_FORBIDDEN_NETWORK_REQ_MSG SetForbiddenNetworkReq; - QMINAS_SET_FORBIDDEN_NETWORK_RESP_MSG SetForbiddenNetworkResp; - QMINAS_PERFORM_NETWORK_SCAN_REQ_MSG PerformNetworkScanReq; - QMINAS_PERFORM_NETWORK_SCAN_RESP_MSG PerformNetworkScanResp; - QMINAS_INITIATE_NW_REGISTER_REQ_MSG InitiateNwRegisterReq; - QMINAS_INITIATE_NW_REGISTER_RESP_MSG InitiateNwRegisterResp; - QMINAS_SET_TECHNOLOGY_PREF_REQ_MSG SetTechnologyPrefReq; - QMINAS_SET_TECHNOLOGY_PREF_RESP_MSG SetTechnologyPrefResp; - QMINAS_GET_SIGNAL_STRENGTH_REQ_MSG GetSignalStrengthReq; - QMINAS_GET_SIGNAL_STRENGTH_RESP_MSG GetSignalStrengthResp; - QMINAS_SET_EVENT_REPORT_REQ_MSG SetEventReportReq; - QMINAS_SET_EVENT_REPORT_RESP_MSG SetEventReportResp; - QMINAS_EVENT_REPORT_IND_MSG NasEventReportInd; - QMINAS_GET_RF_BAND_INFO_REQ_MSG GetRFBandInfoReq; - QMINAS_GET_RF_BAND_INFO_RESP_MSG GetRFBandInfoResp; - QMINAS_INITIATE_ATTACH_REQ_MSG InitiateAttachReq; - QMINAS_INITIATE_ATTACH_RESP_MSG InitiateAttachResp; - QMINAS_GET_PLMN_NAME_REQ_MSG GetPLMNNameReq; - QMINAS_GET_PLMN_NAME_RESP_MSG GetPLMNNameResp; -#endif - - // QMIUIM Messages - QMIUIM_GET_CARD_STATUS_RESP_MSG UIMGetCardStatus; - QMIUIM_VERIFY_PIN_REQ_MSG UIMUIMVerifyPinReq; - QMIUIM_VERIFY_PIN_RESP_MSG UIMUIMVerifyPinResp; -#if 0 - QMIUIM_SET_PIN_PROTECTION_REQ_MSG UIMUIMSetPinProtectionReq; - QMIUIM_SET_PIN_PROTECTION_RESP_MSG UIMUIMSetPinProtectionResp; - QMIUIM_CHANGE_PIN_REQ_MSG UIMUIMChangePinReq; - QMIUIM_CHANGE_PIN_RESP_MSG UIMUIMChangePinResp; - QMIUIM_UNBLOCK_PIN_REQ_MSG UIMUIMUnblockPinReq; - QMIUIM_UNBLOCK_PIN_RESP_MSG UIMUIMUnblockPinResp; -#endif - QMIUIM_READ_TRANSPARENT_REQ_MSG UIMUIMReadTransparentReq; - QMIUIM_READ_TRANSPARENT_RESP_MSG UIMUIMReadTransparentResp; - QMIUIM_SET_CARD_SLOT_REQ_MSG UIMSetCardSlotReq; - - QMIWDS_ADMIN_SET_DATA_FORMAT_REQ_MSG SetDataFormatReq; - QMI_WDA_SET_LOOPBACK_CONFIG_REQ_MSG SetLoopBackReq; - QMI_WDA_SET_LOOPBACK_CONFIG_IND_MSG SetLoopBackInd; - }; -} __attribute__ ((packed)) QMUX_MSG, *PQMUX_MSG; - -typedef struct _QCQMIMSG { - QCQMI_HDR QMIHdr; - union { - QMICTL_MSG CTLMsg; - QMUX_MSG MUXMsg; - }; -} __attribute__ ((packed)) QCQMIMSG, *PQCQMIMSG; - -#pragma pack(pop) - -#endif // MPQMUX_H - diff --git a/quectel_cm_5G/src/Makefile b/quectel_cm_5G/src/Makefile deleted file mode 100644 index d895de1..0000000 --- a/quectel_cm_5G/src/Makefile +++ /dev/null @@ -1,45 +0,0 @@ -ifneq ($(CROSS_COMPILE),) -CROSS-COMPILE:=$(CROSS_COMPILE) -endif -#CROSS-COMPILE:=/workspace/buildroot/buildroot-qemu_mips_malta_defconfig/output/host/usr/bin/mips-buildroot-linux-uclibc- -#CROSS-COMPILE:=/workspace/buildroot/buildroot-qemu_arm_vexpress_defconfig/output/host/usr/bin/arm-buildroot-linux-uclibcgnueabi- -#CROSS-COMPILE:=/workspace/buildroot-git/qemu_mips64_malta/output/host/usr/bin/mips-gnu-linux- -ifeq ($(CC),cc) -CC:=$(CROSS-COMPILE)gcc -endif -LD:=$(CROSS-COMPILE)ld - -QL_CM_SRC=QmiWwanCM.c GobiNetCM.c main.c MPQMUX.c QMIThread.c util.c qmap_bridge_mode.c mbim-cm.c device.c -QL_CM_SRC+=atc.c atchannel.c at_tok.c -#QL_CM_SRC+=qrtr.c rmnetctl.c -ifeq (1,1) -QL_CM_DHCP=udhcpc.c -else -LIBMNL=libmnl/ifutils.c libmnl/attr.c libmnl/callback.c libmnl/nlmsg.c libmnl/socket.c -DHCP=libmnl/dhcp/dhcpclient.c libmnl/dhcp/dhcpmsg.c libmnl/dhcp/packet.c -QL_CM_DHCP=udhcpc_netlink.c -QL_CM_DHCP+=${LIBMNL} -endif - -LDFLAGS += -lpthread -ldl -lrt - -release: clean qmi-proxy mbim-proxy atc-proxy #qrtr-proxy - $(CC) ${CFLAGS} ${QL_CM_SRC} ${QL_CM_DHCP} -o quectel-CM ${LDFLAGS} - -debug: clean - $(CC) ${CFLAGS} -g -DCM_DEBUG ${QL_CM_SRC} ${QL_CM_DHCP} -o quectel-CM -lpthread -ldl -lrt - -qmi-proxy: - $(CC) ${CFLAGS} quectel-qmi-proxy.c -o quectel-qmi-proxy ${LDFLAGS} - -mbim-proxy: - $(CC) ${CFLAGS} quectel-mbim-proxy.c -o quectel-mbim-proxy ${LDFLAGS} - -qrtr-proxy: - $(CC) ${CFLAGS} quectel-qrtr-proxy.c -o quectel-qrtr-proxy ${LDFLAGS} - -atc-proxy: - $(CC) ${CFLAGS} quectel-atc-proxy.c atchannel.c at_tok.c util.c -o quectel-atc-proxy ${LDFLAGS} - -clean: - rm -rf *.o libmnl/*.o quectel-CM quectel-qmi-proxy quectel-mbim-proxy quectel-atc-proxy diff --git a/quectel_cm_5G/src/Makefile.am b/quectel_cm_5G/src/Makefile.am deleted file mode 100644 index 87e5266..0000000 --- a/quectel_cm_5G/src/Makefile.am +++ /dev/null @@ -1,22 +0,0 @@ -bin_PROGRAMS = quectel-CM -QL_CM_SRC=QmiWwanCM.c GobiNetCM.c main.c MPQMUX.c QMIThread.c util.c qmap_bridge_mode.c mbim-cm.c device.c -QL_CM_SRC+=atc.c atchannel.c at_tok.c -#QL_CM_SRC+=qrtr.c rmnetctl.c -QL_CM_DHCP=udhcpc.c -if USE_QRTR -quectel_CM_CFLAGS = -DCONFIG_QRTR -QL_CM_SRC += qrtr.c rmnetctl.c -if USE_MSM_IPC -quectel_CM_CFLAGS += -DUSE_LINUX_MSM_IPC -endif -endif - -quectel_CM_SOURCES = ${QL_CM_SRC} ${QL_CM_DHCP} - -bin_PROGRAMS += quectel-qmi-proxy -quectel_qmi_proxy_SOURCES = quectel-qmi-proxy.c - -bin_PROGRAMS += quectel-mbim-proxy -quectel_mbim_proxy_SOURCES = quectel-mbim-proxy.c -LIBS = -l pthread -CFLAGS = -Wall -Wextra -Werror -O1 diff --git a/quectel_cm_5G/src/NOTICE b/quectel_cm_5G/src/NOTICE deleted file mode 100644 index 898aac4..0000000 --- a/quectel_cm_5G/src/NOTICE +++ /dev/null @@ -1,7 +0,0 @@ -This program is totally open souce code, and public domain software for customers of Quectel company. - -The APIs of QMI WWAMN interfaces are defined by Qualcomm. And this program complies with Qualcomm QMI WWAN interfaces specification. - -Customers are free to modify the source codes and redistribute them. - -For those who is not Quectel's customer, all rights are closed, and any copying and commercial development over this progrma is not allowed. diff --git a/quectel_cm_5G/src/QMIThread.c b/quectel_cm_5G/src/QMIThread.c deleted file mode 100644 index 40ea8d2..0000000 --- a/quectel_cm_5G/src/QMIThread.c +++ /dev/null @@ -1,2993 +0,0 @@ -/****************************************************************************** - @file QMIThread.c - @brief QMI WWAN connectivity manager. - - DESCRIPTION - Connectivity Management Tool for USB network adapter of Quectel wireless cellular modules. - - INITIALIZATION AND SEQUENCING REQUIREMENTS - None. - - --------------------------------------------------------------------------- - Copyright (c) 2016 - 2020 Quectel Wireless Solution, Co., Ltd. All Rights Reserved. - Quectel Wireless Solution Proprietary and Confidential. - --------------------------------------------------------------------------- -******************************************************************************/ -#include "QMIThread.h" -#include - -#ifndef MIN -#define MIN(a, b) ((a) < (b)? (a): (b)) -#endif - -#define qmi_rsp_check_and_return() do { \ - if (err < 0 || pResponse == NULL) { \ - dbg_time("%s err = %d", __func__, err); \ - return err; \ - } \ - pMUXMsg = &pResponse->MUXMsg; \ - if (le16_to_cpu(pMUXMsg->QMUXMsgHdrResp.QMUXResult) || le16_to_cpu(pMUXMsg->QMUXMsgHdrResp.QMUXError)) { \ - USHORT QMUXError = le16_to_cpu(pMUXMsg->QMUXMsgHdrResp.QMUXError); \ - dbg_time("%s QMUXResult = 0x%x, QMUXError = 0x%x", __func__, \ - le16_to_cpu(pMUXMsg->QMUXMsgHdrResp.QMUXResult), QMUXError); \ - free(pResponse); \ - return QMUXError; \ - } \ -} while(0) - -#define qmi_rsp_check() do { \ - if (err < 0 || pResponse == NULL) { \ - dbg_time("%s err = %d", __func__, err); \ - return err; \ - } \ - pMUXMsg = &pResponse->MUXMsg; \ - if (le16_to_cpu(pMUXMsg->QMUXMsgHdrResp.QMUXResult) || le16_to_cpu(pMUXMsg->QMUXMsgHdrResp.QMUXError)) { \ - USHORT QMUXError = le16_to_cpu(pMUXMsg->QMUXMsgHdrResp.QMUXError); \ - dbg_time("%s QMUXResult = 0x%x, QMUXError = 0x%x", __func__, \ - le16_to_cpu(pMUXMsg->QMUXMsgHdrResp.QMUXResult), QMUXError); \ - } \ -} while(0) - -static uint32_t WdsConnectionIPv4Handle = 0; -static uint32_t WdsConnectionIPv6Handle = 0; -static int s_is_cdma = 0; -static int s_5g_type = WWAN_DATA_CLASS_NONE; -static int s_hdr_personality = 0; // 0x01-HRPD, 0x02-eHRPD -static char *qstrcpy(char *to, const char *from) { //no __strcpy_chk - char *save = to; - for (; (*to = *from) != '\0'; ++from, ++to); - return(save); -} - -static void uchar2char(char *dst_ptr, size_t dst_len, const UCHAR *src_ptr, size_t src_len) { - size_t copy = MIN(dst_len-1, src_len); - - if (copy) - memcpy(dst_ptr, src_ptr, copy); - dst_ptr[copy] = 0; -} - -static int s_9x07 = 1; - -typedef USHORT (*CUSTOMQMUX)(PQMUX_MSG pMUXMsg, void *arg); - -// To retrieve the ith (Index) TLV -PQMI_TLV_HDR GetTLV (PQCQMUX_MSG_HDR pQMUXMsgHdr, int TLVType) { - int TLVFind = 0; - USHORT Length = le16_to_cpu(pQMUXMsgHdr->Length); - PQMI_TLV_HDR pTLVHdr = (PQMI_TLV_HDR)(pQMUXMsgHdr + 1); - - while (Length >= sizeof(QMI_TLV_HDR)) { - TLVFind++; - if (TLVType > 0x1000) { - if ((TLVFind + 0x1000) == TLVType) - return pTLVHdr; - } else if (pTLVHdr->TLVType == TLVType) { - return pTLVHdr; - } - - Length -= (le16_to_cpu((pTLVHdr->TLVLength)) + sizeof(QMI_TLV_HDR)); - pTLVHdr = (PQMI_TLV_HDR)(((UCHAR *)pTLVHdr) + le16_to_cpu(pTLVHdr->TLVLength) + sizeof(QMI_TLV_HDR)); - } - - return NULL; -} - -static USHORT GetQMUXTransactionId(void) { - static int TransactionId = 0; - if (++TransactionId > 0xFFFF) - TransactionId = 1; - return TransactionId; -} - -static PQCQMIMSG ComposeQMUXMsg(UCHAR QMIType, USHORT Type, CUSTOMQMUX customQmuxMsgFunction, void *arg) { - UCHAR QMIBuf[WDM_DEFAULT_BUFSIZE]; - PQCQMIMSG pRequest = (PQCQMIMSG)QMIBuf; - int Length; - - memset(QMIBuf, 0x00, sizeof(QMIBuf)); - pRequest->QMIHdr.IFType = USB_CTL_MSG_TYPE_QMI; - pRequest->QMIHdr.CtlFlags = 0x00; - pRequest->QMIHdr.QMIType = QMIType; - - pRequest->MUXMsg.QMUXHdr.CtlFlags = QMUX_CTL_FLAG_SINGLE_MSG | QMUX_CTL_FLAG_TYPE_CMD; - pRequest->MUXMsg.QMUXHdr.TransactionId = cpu_to_le16(GetQMUXTransactionId()); - pRequest->MUXMsg.QMUXMsgHdr.Type = cpu_to_le16(Type); - if (customQmuxMsgFunction) - pRequest->MUXMsg.QMUXMsgHdr.Length = cpu_to_le16(customQmuxMsgFunction(&pRequest->MUXMsg, arg) - sizeof(QCQMUX_MSG_HDR)); - else - pRequest->MUXMsg.QMUXMsgHdr.Length = cpu_to_le16(0x0000); - - pRequest->QMIHdr.Length = cpu_to_le16(le16_to_cpu(pRequest->MUXMsg.QMUXMsgHdr.Length) + sizeof(QCQMUX_MSG_HDR) + sizeof(QCQMUX_HDR) - + sizeof(QCQMI_HDR) - 1); - Length = le16_to_cpu(pRequest->QMIHdr.Length) + 1; - - pRequest = (PQCQMIMSG)malloc(Length); - if (pRequest == NULL) { - dbg_time("%s fail to malloc", __func__); - } else { - memcpy(pRequest, QMIBuf, Length); - } - - return pRequest; -} - -#if 0 -static USHORT NasSetEventReportReq(PQMUX_MSG pMUXMsg, void *arg) { - pMUXMsg->SetEventReportReq.TLVType = 0x10; - pMUXMsg->SetEventReportReq.TLVLength = 0x04; - pMUXMsg->SetEventReportReq.ReportSigStrength = 0x00; - pMUXMsg->SetEventReportReq.NumTresholds = 2; - pMUXMsg->SetEventReportReq.TresholdList[0] = -113; - pMUXMsg->SetEventReportReq.TresholdList[1] = -50; - return sizeof(QMINAS_SET_EVENT_REPORT_REQ_MSG); -} - -static USHORT WdsSetEventReportReq(PQMUX_MSG pMUXMsg, void *arg) { - pMUXMsg->EventReportReq.TLVType = 0x10; // 0x10 -- current channel rate indicator - pMUXMsg->EventReportReq.TLVLength = 0x0001; // 1 - pMUXMsg->EventReportReq.Mode = 0x00; // 0-do not report; 1-report when rate changes - - pMUXMsg->EventReportReq.TLV2Type = 0x11; // 0x11 - pMUXMsg->EventReportReq.TLV2Length = 0x0005; // 5 - pMUXMsg->EventReportReq.StatsPeriod = 0x00; // seconds between reports; 0-do not report - pMUXMsg->EventReportReq.StatsMask = 0x000000ff; // - - pMUXMsg->EventReportReq.TLV3Type = 0x12; // 0x12 -- current data bearer indicator - pMUXMsg->EventReportReq.TLV3Length = 0x0001; // 1 - pMUXMsg->EventReportReq.Mode3 = 0x01; // 0-do not report; 1-report when changes - - pMUXMsg->EventReportReq.TLV4Type = 0x13; // 0x13 -- dormancy status indicator - pMUXMsg->EventReportReq.TLV4Length = 0x0001; // 1 - pMUXMsg->EventReportReq.DormancyStatus = 0x00; // 0-do not report; 1-report when changes - return sizeof(QMIWDS_SET_EVENT_REPORT_REQ_MSG); -} - -static USHORT DmsSetEventReportReq(PQMUX_MSG pMUXMsg) { - PPIN_STATUS pPinState = (PPIN_STATUS)(&pMUXMsg->DmsSetEventReportReq + 1); - PUIM_STATE pUimState = (PUIM_STATE)(pPinState + 1); - // Pin State - pPinState->TLVType = 0x12; - pPinState->TLVLength = 0x01; - pPinState->ReportPinState = 0x01; - // UIM State - pUimState->TLVType = 0x15; - pUimState->TLVLength = 0x01; - pUimState->UIMState = 0x01; - return sizeof(QMIDMS_SET_EVENT_REPORT_REQ_MSG) + sizeof(PIN_STATUS) + sizeof(UIM_STATE); -} -#endif - -static USHORT WdsStartNwInterfaceReq(PQMUX_MSG pMUXMsg, void *arg) { - PQMIWDS_TECHNOLOGY_PREFERECE pTechPref; - PQMIWDS_AUTH_PREFERENCE pAuthPref; - PQMIWDS_USERNAME pUserName; - PQMIWDS_PASSWD pPasswd; - PQMIWDS_APNNAME pApnName; - PQMIWDS_IP_FAMILY_TLV pIpFamily; - USHORT TLVLength = 0; - UCHAR *pTLV; - PROFILE_T *profile = (PROFILE_T *)arg; - const char *profile_user = profile->user; - const char *profile_password = profile->password; - int profile_auth = profile->auth; - - if (s_is_cdma && (profile_user == NULL || profile_user[0] == '\0') && (profile_password == NULL || profile_password[0] == '\0')) { - profile_user = "ctnet@mycdma.cn"; - profile_password = "vnet.mobi"; - profile_auth = 2; //chap - } - - pTLV = (UCHAR *)(&pMUXMsg->StartNwInterfaceReq + 1); - pMUXMsg->StartNwInterfaceReq.Length = 0; - - // Set technology Preferece - pTechPref = (PQMIWDS_TECHNOLOGY_PREFERECE)(pTLV + TLVLength); - pTechPref->TLVType = 0x30; - pTechPref->TLVLength = cpu_to_le16(0x01); - if (s_is_cdma == 0) - pTechPref->TechPreference = 0x01; - else - pTechPref->TechPreference = 0x02; - TLVLength +=(le16_to_cpu(pTechPref->TLVLength) + sizeof(QCQMICTL_TLV_HDR)); - - // Set APN Name - if (profile->apn && !s_is_cdma) { //cdma no apn - pApnName = (PQMIWDS_APNNAME)(pTLV + TLVLength); - pApnName->TLVType = 0x14; - pApnName->TLVLength = cpu_to_le16(strlen(profile->apn)); - qstrcpy((char *)&pApnName->ApnName, profile->apn); - TLVLength +=(le16_to_cpu(pApnName->TLVLength) + sizeof(QCQMICTL_TLV_HDR)); - } - - // Set User Name - if (profile_user) { - pUserName = (PQMIWDS_USERNAME)(pTLV + TLVLength); - pUserName->TLVType = 0x17; - pUserName->TLVLength = cpu_to_le16(strlen(profile_user)); - qstrcpy((char *)&pUserName->UserName, profile_user); - TLVLength += (le16_to_cpu(pUserName->TLVLength) + sizeof(QCQMICTL_TLV_HDR)); - } - - // Set Password - if (profile_password) { - pPasswd = (PQMIWDS_PASSWD)(pTLV + TLVLength); - pPasswd->TLVType = 0x18; - pPasswd->TLVLength = cpu_to_le16(strlen(profile_password)); - qstrcpy((char *)&pPasswd->Passwd, profile_password); - TLVLength += (le16_to_cpu(pPasswd->TLVLength) + sizeof(QCQMICTL_TLV_HDR)); - } - - // Set Auth Protocol - if (profile_user && profile_password) { - pAuthPref = (PQMIWDS_AUTH_PREFERENCE)(pTLV + TLVLength); - pAuthPref->TLVType = 0x16; - pAuthPref->TLVLength = cpu_to_le16(0x01); - pAuthPref->AuthPreference = profile_auth; // 0 ~ None, 1 ~ Pap, 2 ~ Chap, 3 ~ MsChapV2 - TLVLength += (le16_to_cpu(pAuthPref->TLVLength) + sizeof(QCQMICTL_TLV_HDR)); - } - - // Add IP Family Preference - pIpFamily = (PQMIWDS_IP_FAMILY_TLV)(pTLV + TLVLength); - pIpFamily->TLVType = 0x19; - pIpFamily->TLVLength = cpu_to_le16(0x01); - pIpFamily->IpFamily = profile->curIpFamily; - TLVLength += (le16_to_cpu(pIpFamily->TLVLength) + sizeof(QCQMICTL_TLV_HDR)); - - //Set Profile Index - if (profile->pdp && !s_is_cdma) { //cdma only support one pdp, so no need to set profile index - PQMIWDS_PROFILE_IDENTIFIER pProfileIndex = (PQMIWDS_PROFILE_IDENTIFIER)(pTLV + TLVLength); - pProfileIndex->TLVLength = cpu_to_le16(0x01); - pProfileIndex->TLVType = 0x31; - pProfileIndex->ProfileIndex = profile->pdp; - if (s_is_cdma && s_hdr_personality == 0x02) { - pProfileIndex->TLVType = 0x32; //profile_index_3gpp2 - pProfileIndex->ProfileIndex = 101; - } - TLVLength += (le16_to_cpu(pProfileIndex->TLVLength) + sizeof(QCQMICTL_TLV_HDR)); - } - - return sizeof(QMIWDS_START_NETWORK_INTERFACE_REQ_MSG) + TLVLength; -} - -static USHORT WdsStopNwInterfaceReq(PQMUX_MSG pMUXMsg, void *arg) { - pMUXMsg->StopNwInterfaceReq.TLVType = 0x01; - pMUXMsg->StopNwInterfaceReq.TLVLength = cpu_to_le16(0x04); - if (*((int *)arg) == IpFamilyV4) - pMUXMsg->StopNwInterfaceReq.Handle = cpu_to_le32(WdsConnectionIPv4Handle); - else - pMUXMsg->StopNwInterfaceReq.Handle = cpu_to_le32(WdsConnectionIPv6Handle); - return sizeof(QMIWDS_STOP_NETWORK_INTERFACE_REQ_MSG); -} - -static USHORT WdsSetClientIPFamilyPref(PQMUX_MSG pMUXMsg, void *arg) { - pMUXMsg->SetClientIpFamilyPrefReq.TLVType = 0x01; - pMUXMsg->SetClientIpFamilyPrefReq.TLVLength = cpu_to_le16(0x01); - pMUXMsg->SetClientIpFamilyPrefReq.IpPreference = *((UCHAR *)arg); - return sizeof(QMIWDS_SET_CLIENT_IP_FAMILY_PREF_REQ_MSG); -} - -static USHORT WdsSetAutoConnect(PQMUX_MSG pMUXMsg, void *arg) { - pMUXMsg->SetAutoConnectReq.TLVType = 0x01; - pMUXMsg->SetAutoConnectReq.TLVLength = cpu_to_le16(0x01); - pMUXMsg->SetAutoConnectReq.autoconnect_setting = *((UCHAR *)arg); - return sizeof(QMIWDS_SET_AUTO_CONNECT_REQ_MSG); -} - -enum peripheral_ep_type { - DATA_EP_TYPE_RESERVED = 0x0, - DATA_EP_TYPE_HSIC = 0x1, - DATA_EP_TYPE_HSUSB = 0x2, - DATA_EP_TYPE_PCIE = 0x3, - DATA_EP_TYPE_EMBEDDED = 0x4, - DATA_EP_TYPE_BAM_DMUX = 0x5, -}; - -static USHORT WdsSetQMUXBindMuxDataPort(PQMUX_MSG pMUXMsg, void *arg) { - QMAP_SETTING *qmap_settings = (QMAP_SETTING *)arg; - - pMUXMsg->BindMuxDataPortReq.TLVType = 0x10; - pMUXMsg->BindMuxDataPortReq.TLVLength = cpu_to_le16(0x08); - pMUXMsg->BindMuxDataPortReq.ep_type = cpu_to_le32(qmap_settings->ep_type); - pMUXMsg->BindMuxDataPortReq.iface_id = cpu_to_le32(qmap_settings->iface_id); - pMUXMsg->BindMuxDataPortReq.TLV2Type = 0x11; - pMUXMsg->BindMuxDataPortReq.TLV2Length = cpu_to_le16(0x01); - pMUXMsg->BindMuxDataPortReq.MuxId = qmap_settings->MuxId; - pMUXMsg->BindMuxDataPortReq.TLV3Type = 0x13; - pMUXMsg->BindMuxDataPortReq.TLV3Length = cpu_to_le16(0x04); - pMUXMsg->BindMuxDataPortReq.client_type = cpu_to_le32(1); //WDS_CLIENT_TYPE_TETHERED - - return sizeof(QMIWDS_BIND_MUX_DATA_PORT_REQ_MSG); -} - -static int qmap_version = 0x05; -static USHORT WdaSetDataFormat(PQMUX_MSG pMUXMsg, void *arg) { - QMAP_SETTING *qmap_settings = (QMAP_SETTING *)arg; - - if (qmap_settings->rx_urb_size == 0) { - PQMIWDS_ADMIN_SET_DATA_FORMAT_TLV_QOS pWdsAdminQosTlv; - PQMIWDS_ADMIN_SET_DATA_FORMAT_TLV linkProto; - PQMIWDS_ADMIN_SET_DATA_FORMAT_TLV dlTlp; - - pWdsAdminQosTlv = (PQMIWDS_ADMIN_SET_DATA_FORMAT_TLV_QOS)(&pMUXMsg->QMUXMsgHdr + 1); - pWdsAdminQosTlv->TLVType = 0x10; - pWdsAdminQosTlv->TLVLength = cpu_to_le16(0x0001); - pWdsAdminQosTlv->QOSSetting = 0; /* no-QOS header */ - - linkProto = (PQMIWDS_ADMIN_SET_DATA_FORMAT_TLV)(pWdsAdminQosTlv + 1); - linkProto->TLVType = 0x11; - linkProto->TLVLength = cpu_to_le16(4); - linkProto->Value = cpu_to_le32(0x01); /* Set Ethernet mode */ - - dlTlp = (PQMIWDS_ADMIN_SET_DATA_FORMAT_TLV)(linkProto + 1);; - dlTlp->TLVType = 0x13; - dlTlp->TLVLength = cpu_to_le16(4); - dlTlp->Value = cpu_to_le32(0x00); - - if (sizeof(*linkProto) != 7 ) - dbg_time("%s sizeof(*linkProto) = %zu, is not 7!", __func__, sizeof(*linkProto) ); - - return sizeof(QCQMUX_MSG_HDR) + sizeof(*pWdsAdminQosTlv) + sizeof(*linkProto) + sizeof(*dlTlp); - } - else { - //Indicates whether the Quality of Service(QOS) data format is used by the client. - pMUXMsg->SetDataFormatReq.QosDataFormatTlv.TLVType = 0x10; - pMUXMsg->SetDataFormatReq.QosDataFormatTlv.TLVLength = cpu_to_le16(0x0001); - pMUXMsg->SetDataFormatReq.QosDataFormatTlv.QOSSetting = 0; /* no-QOS header */ - - //Underlying Link Layer Protocol - pMUXMsg->SetDataFormatReq.UnderlyingLinkLayerProtocolTlv.TLVType = 0x11; - pMUXMsg->SetDataFormatReq.UnderlyingLinkLayerProtocolTlv.TLVLength = cpu_to_le16(4); - pMUXMsg->SetDataFormatReq.UnderlyingLinkLayerProtocolTlv.Value = cpu_to_le32(0x02); /* Set IP mode */ - - //Uplink (UL) data aggregation protocol to be used for uplink data transfer. - pMUXMsg->SetDataFormatReq.UplinkDataAggregationProtocolTlv.TLVType = 0x12; - pMUXMsg->SetDataFormatReq.UplinkDataAggregationProtocolTlv.TLVLength = cpu_to_le16(4); - pMUXMsg->SetDataFormatReq.UplinkDataAggregationProtocolTlv.Value = cpu_to_le32(qmap_version); //UL QMAP is enabled - - //Downlink (DL) data aggregation protocol to be used for downlink data transfer - pMUXMsg->SetDataFormatReq.DownlinkDataAggregationProtocolTlv.TLVType = 0x13; - pMUXMsg->SetDataFormatReq.DownlinkDataAggregationProtocolTlv.TLVLength = cpu_to_le16(4); - pMUXMsg->SetDataFormatReq.DownlinkDataAggregationProtocolTlv.Value = cpu_to_le32(qmap_version); //DL QMAP is enabled - - //Maximum number of datagrams in a single aggregated packet on downlink - pMUXMsg->SetDataFormatReq.DownlinkDataAggregationMaxDatagramsTlv.TLVType = 0x15; - pMUXMsg->SetDataFormatReq.DownlinkDataAggregationMaxDatagramsTlv.TLVLength = cpu_to_le16(4); - pMUXMsg->SetDataFormatReq.DownlinkDataAggregationMaxDatagramsTlv.Value = cpu_to_le32(qmap_settings->rx_urb_size/512); - - //Maximum size in bytes of a single aggregated packet allowed on downlink - pMUXMsg->SetDataFormatReq.DownlinkDataAggregationMaxSizeTlv.TLVType = 0x16; - pMUXMsg->SetDataFormatReq.DownlinkDataAggregationMaxSizeTlv.TLVLength = cpu_to_le16(4); - pMUXMsg->SetDataFormatReq.DownlinkDataAggregationMaxSizeTlv.Value = cpu_to_le32(qmap_settings->rx_urb_size); - - //Peripheral End Point ID - pMUXMsg->SetDataFormatReq.epTlv.TLVType = 0x17; - pMUXMsg->SetDataFormatReq.epTlv.TLVLength = cpu_to_le16(8); - pMUXMsg->SetDataFormatReq.epTlv.ep_type = cpu_to_le32(qmap_settings->ep_type); - pMUXMsg->SetDataFormatReq.epTlv.iface_id = cpu_to_le32(qmap_settings->iface_id); - -#ifdef QUECTEL_UL_DATA_AGG - if (!qmap_settings->ul_data_aggregation_max_datagrams) { - return ((size_t)&((QMIWDS_ADMIN_SET_DATA_FORMAT_REQ_MSG *)0)->DlMinimumPassingTlv); - } - - //Maximum number of datagrams in a single aggregated packet on uplink - pMUXMsg->SetDataFormatReq.DlMinimumPassingTlv.TLVType = 0x19; - pMUXMsg->SetDataFormatReq.DlMinimumPassingTlv.TLVLength = cpu_to_le16(4); - pMUXMsg->SetDataFormatReq.DlMinimumPassingTlv.Value = cpu_to_le32(qmap_settings->dl_minimum_padding); - - //Maximum number of datagrams in a single aggregated packet on uplink - pMUXMsg->SetDataFormatReq.UplinkDataAggregationMaxDatagramsTlv.TLVType = 0x1B; - pMUXMsg->SetDataFormatReq.UplinkDataAggregationMaxDatagramsTlv.TLVLength = cpu_to_le16(4); - pMUXMsg->SetDataFormatReq.UplinkDataAggregationMaxDatagramsTlv.Value = cpu_to_le32(qmap_settings->ul_data_aggregation_max_datagrams); - - //Maximum size in bytes of a single aggregated packet allowed on downlink - pMUXMsg->SetDataFormatReq.UplinkDataAggregationMaxSizeTlv.TLVType = 0x1C; - pMUXMsg->SetDataFormatReq.UplinkDataAggregationMaxSizeTlv.TLVLength = cpu_to_le16(4); - pMUXMsg->SetDataFormatReq.UplinkDataAggregationMaxSizeTlv.Value = cpu_to_le32(qmap_settings->ul_data_aggregation_max_size); -#endif - - return sizeof(QMIWDS_ADMIN_SET_DATA_FORMAT_REQ_MSG); - } -} - -#ifdef CONFIG_SIM -static USHORT DmsUIMVerifyPinReqSend(PQMUX_MSG pMUXMsg, void *arg) { - pMUXMsg->UIMVerifyPinReq.TLVType = 0x01; - pMUXMsg->UIMVerifyPinReq.PINID = 0x01; //Pin1, not Puk - pMUXMsg->UIMVerifyPinReq.PINLen = strlen((const char *)arg); - qstrcpy((char *)&pMUXMsg->UIMVerifyPinReq.PINValue, ((const char *)arg)); - pMUXMsg->UIMVerifyPinReq.TLVLength = cpu_to_le16(2 + strlen((const char *)arg)); - return sizeof(QMIDMS_UIM_VERIFY_PIN_REQ_MSG) + (strlen((const char *)arg) - 1); -} - -static USHORT UimVerifyPinReqSend(PQMUX_MSG pMUXMsg, void *arg) -{ - pMUXMsg->UIMUIMVerifyPinReq.TLVType = 0x01; - pMUXMsg->UIMUIMVerifyPinReq.TLVLength = cpu_to_le16(0x02); - pMUXMsg->UIMUIMVerifyPinReq.Session_Type = 0x00; - pMUXMsg->UIMUIMVerifyPinReq.Aid_Len = 0x00; - pMUXMsg->UIMUIMVerifyPinReq.TLV2Type = 0x02; - pMUXMsg->UIMUIMVerifyPinReq.TLV2Length = cpu_to_le16(2 + strlen((const char *)arg)); - pMUXMsg->UIMUIMVerifyPinReq.PINID = 0x01; //Pin1, not Puk - pMUXMsg->UIMUIMVerifyPinReq.PINLen= strlen((const char *)arg); - qstrcpy((char *)&pMUXMsg->UIMUIMVerifyPinReq.PINValue, ((const char *)arg)); - return sizeof(QMIUIM_VERIFY_PIN_REQ_MSG) + (strlen((const char *)arg) - 1); -} - -#ifdef CONFIG_IMSI_ICCID -static USHORT UimReadTransparentIMSIReqSend(PQMUX_MSG pMUXMsg, void *arg) { - PREAD_TRANSPARENT_TLV pReadTransparent; - - pMUXMsg->UIMUIMReadTransparentReq.TLVType = 0x01; - pMUXMsg->UIMUIMReadTransparentReq.TLVLength = cpu_to_le16(0x02); - if (!strcmp((char *)arg, "EF_ICCID")) { - pMUXMsg->UIMUIMReadTransparentReq.Session_Type = 0x06; - pMUXMsg->UIMUIMReadTransparentReq.Aid_Len = 0x00; - - pMUXMsg->UIMUIMReadTransparentReq.TLV2Type = 0x02; - pMUXMsg->UIMUIMReadTransparentReq.file_id = cpu_to_le16(0x2FE2); - pMUXMsg->UIMUIMReadTransparentReq.path_len = 0x02; - pMUXMsg->UIMUIMReadTransparentReq.path[0] = 0x00; - pMUXMsg->UIMUIMReadTransparentReq.path[1] = 0x3F; - } - else if(!strcmp((char *)arg, "EF_IMSI")) { - pMUXMsg->UIMUIMReadTransparentReq.Session_Type = 0x00; - pMUXMsg->UIMUIMReadTransparentReq.Aid_Len = 0x00; - - pMUXMsg->UIMUIMReadTransparentReq.TLV2Type = 0x02; - pMUXMsg->UIMUIMReadTransparentReq.file_id = cpu_to_le16(0x6F07); - pMUXMsg->UIMUIMReadTransparentReq.path_len = 0x04; - pMUXMsg->UIMUIMReadTransparentReq.path[0] = 0x00; - pMUXMsg->UIMUIMReadTransparentReq.path[1] = 0x3F; - pMUXMsg->UIMUIMReadTransparentReq.path[2] = 0xFF; - pMUXMsg->UIMUIMReadTransparentReq.path[3] = 0x7F; - } - - pMUXMsg->UIMUIMReadTransparentReq.TLV2Length = cpu_to_le16(3 + pMUXMsg->UIMUIMReadTransparentReq.path_len); - - pReadTransparent = (PREAD_TRANSPARENT_TLV)(&pMUXMsg->UIMUIMReadTransparentReq.path[pMUXMsg->UIMUIMReadTransparentReq.path_len]); - pReadTransparent->TLVType = 0x03; - pReadTransparent->TLVLength = cpu_to_le16(0x04); - pReadTransparent->Offset = cpu_to_le16(0x00); - pReadTransparent->Length = cpu_to_le16(0x00); - - return (sizeof(QMIUIM_READ_TRANSPARENT_REQ_MSG) + pMUXMsg->UIMUIMReadTransparentReq.path_len + sizeof(READ_TRANSPARENT_TLV)); -} -#endif -#endif - -#ifdef CONFIG_APN -static USHORT WdsCreateProfileSettingsReqSend(PQMUX_MSG pMUXMsg, void *arg) { - PROFILE_T *profile = (PROFILE_T *)arg; - pMUXMsg->CreatetProfileSettingsReq.Length = cpu_to_le16(sizeof(QMIWDS_CREATE_PROFILE_SETTINGS_REQ_MSG) - 4); - pMUXMsg->CreatetProfileSettingsReq.TLVType = 0x01; - pMUXMsg->CreatetProfileSettingsReq.TLVLength = cpu_to_le16(0x01); - pMUXMsg->CreatetProfileSettingsReq.ProfileType = 0x00; // 0 ~ 3GPP, 1 ~ 3GPP2 - pMUXMsg->CreatetProfileSettingsReq.TLV2Type = 0x25; - pMUXMsg->CreatetProfileSettingsReq.TLV2Length = cpu_to_le16(0x01); - pMUXMsg->CreatetProfileSettingsReq.pdp_context = profile->pdp; // 0 ~ 3GPP, 1 ~ 3GPP2 - return sizeof(QMIWDS_CREATE_PROFILE_SETTINGS_REQ_MSG); -} - -static USHORT WdsGetProfileSettingsReqSend(PQMUX_MSG pMUXMsg, void *arg) { - PROFILE_T *profile = (PROFILE_T *)arg; - pMUXMsg->GetProfileSettingsReq.Length = cpu_to_le16(sizeof(QMIWDS_GET_PROFILE_SETTINGS_REQ_MSG) - 4); - pMUXMsg->GetProfileSettingsReq.TLVType = 0x01; - pMUXMsg->GetProfileSettingsReq.TLVLength = cpu_to_le16(0x02); - pMUXMsg->GetProfileSettingsReq.ProfileType = 0x00; // 0 ~ 3GPP, 1 ~ 3GPP2 - pMUXMsg->GetProfileSettingsReq.ProfileIndex = profile->pdp; - return sizeof(QMIWDS_GET_PROFILE_SETTINGS_REQ_MSG); -} - -static USHORT WdsModifyProfileSettingsReq(PQMUX_MSG pMUXMsg, void *arg) { - USHORT TLVLength = 0; - UCHAR *pTLV; - PROFILE_T *profile = (PROFILE_T *)arg; - PQMIWDS_PDPTYPE pPdpType; - - pMUXMsg->ModifyProfileSettingsReq.Length = cpu_to_le16(sizeof(QMIWDS_MODIFY_PROFILE_SETTINGS_REQ_MSG) - 4); - pMUXMsg->ModifyProfileSettingsReq.TLVType = 0x01; - pMUXMsg->ModifyProfileSettingsReq.TLVLength = cpu_to_le16(0x02); - pMUXMsg->ModifyProfileSettingsReq.ProfileType = 0x00; // 0 ~ 3GPP, 1 ~ 3GPP2 - pMUXMsg->ModifyProfileSettingsReq.ProfileIndex = profile->pdp; - - pTLV = (UCHAR *)(&pMUXMsg->ModifyProfileSettingsReq + 1); - - pPdpType = (PQMIWDS_PDPTYPE)(pTLV + TLVLength); - pPdpType->TLVType = 0x11; - pPdpType->TLVLength = cpu_to_le16(0x01); - pPdpType->PdpType = profile->iptype; - TLVLength +=(le16_to_cpu(pPdpType->TLVLength) + sizeof(QCQMICTL_TLV_HDR)); - - // Set APN Name - if (profile->apn) { - PQMIWDS_APNNAME pApnName = (PQMIWDS_APNNAME)(pTLV + TLVLength); - pApnName->TLVType = 0x14; - pApnName->TLVLength = cpu_to_le16(strlen(profile->apn)); - qstrcpy((char *)&pApnName->ApnName, profile->apn); - TLVLength +=(le16_to_cpu(pApnName->TLVLength) + sizeof(QCQMICTL_TLV_HDR)); - } - - // Set User Name - if (profile->user) { - PQMIWDS_USERNAME pUserName = (PQMIWDS_USERNAME)(pTLV + TLVLength); - pUserName->TLVType = 0x1B; - pUserName->TLVLength = cpu_to_le16(strlen(profile->user)); - qstrcpy((char *)&pUserName->UserName, profile->user); - TLVLength += (le16_to_cpu(pUserName->TLVLength) + sizeof(QCQMICTL_TLV_HDR)); - } - - // Set Password - if (profile->password) { - PQMIWDS_PASSWD pPasswd = (PQMIWDS_PASSWD)(pTLV + TLVLength); - pPasswd->TLVType = 0x1C; - pPasswd->TLVLength = cpu_to_le16(strlen(profile->password)); - qstrcpy((char *)&pPasswd->Passwd, profile->password); - TLVLength +=(le16_to_cpu(pPasswd->TLVLength) + sizeof(QCQMICTL_TLV_HDR)); - } - - // Set Auth Protocol - if (profile->user && profile->password) { - PQMIWDS_AUTH_PREFERENCE pAuthPref = (PQMIWDS_AUTH_PREFERENCE)(pTLV + TLVLength); - pAuthPref->TLVType = 0x1D; - pAuthPref->TLVLength = cpu_to_le16(0x01); - pAuthPref->AuthPreference = profile->auth; // 0 ~ None, 1 ~ Pap, 2 ~ Chap, 3 ~ MsChapV2 - TLVLength += (le16_to_cpu(pAuthPref->TLVLength) + sizeof(QCQMICTL_TLV_HDR)); - } - - return sizeof(QMIWDS_MODIFY_PROFILE_SETTINGS_REQ_MSG) + TLVLength; -} -#endif - -static USHORT WdsGetRuntimeSettingReq(PQMUX_MSG pMUXMsg, void *arg) -{ - (void)arg; - pMUXMsg->GetRuntimeSettingsReq.TLVType = 0x10; - pMUXMsg->GetRuntimeSettingsReq.TLVLength = cpu_to_le16(0x04); - // the following mask also applies to IPV6 - pMUXMsg->GetRuntimeSettingsReq.Mask = cpu_to_le32(QMIWDS_GET_RUNTIME_SETTINGS_MASK_IPV4DNS_ADDR | - QMIWDS_GET_RUNTIME_SETTINGS_MASK_IPV4_ADDR | - QMIWDS_GET_RUNTIME_SETTINGS_MASK_MTU | - QMIWDS_GET_RUNTIME_SETTINGS_MASK_IPV4GATEWAY_ADDR) | - QMIWDS_GET_RUNTIME_SETTINGS_MASK_PCSCF_SV_ADDR | - QMIWDS_GET_RUNTIME_SETTINGS_MASK_PCSCF_DOM_NAME; - - return sizeof(QMIWDS_GET_RUNTIME_SETTINGS_REQ_MSG); -} - -static PQCQMIMSG s_pRequest; -static PQCQMIMSG s_pResponse; - -static int is_response(const PQCQMIMSG pRequest, const PQCQMIMSG pResponse) { - if ((pRequest->QMIHdr.QMIType == pResponse->QMIHdr.QMIType) - && (pRequest->QMIHdr.ClientId == pResponse->QMIHdr.ClientId)) { - USHORT requestTID, responseTID; - if (pRequest->QMIHdr.QMIType == QMUX_TYPE_CTL) { - requestTID = pRequest->CTLMsg.QMICTLMsgHdr.TransactionId; - responseTID = pResponse->CTLMsg.QMICTLMsgHdr.TransactionId; - } else { - requestTID = le16_to_cpu(pRequest->MUXMsg.QMUXHdr.TransactionId); - responseTID = le16_to_cpu(pResponse->MUXMsg.QMUXHdr.TransactionId); - } - return (requestTID == responseTID); - } - return 0; -} - -int (*qmidev_send)(PQCQMIMSG pRequest); - -int QmiThreadSendQMITimeout(PQCQMIMSG pRequest, PQCQMIMSG *ppResponse, unsigned msecs, const char *funcname) { - int ret; - - if (!pRequest) - return -EINVAL; - - pthread_mutex_lock(&cm_command_mutex); - - if (ppResponse) - *ppResponse = NULL; - - dump_qmi(pRequest, le16_to_cpu(pRequest->QMIHdr.Length) + 1); - - s_pRequest = pRequest; - s_pResponse = NULL; - - ret = qmidev_send(pRequest); - - if (ret == 0) { - ret = pthread_cond_timeout_np(&cm_command_cond, &cm_command_mutex, msecs); - if (!ret) { - if (s_pResponse && ppResponse) { - *ppResponse = s_pResponse; - } else { - if (s_pResponse) { - free(s_pResponse); - s_pResponse = NULL; - } - } - } else { - dbg_time("%s message timeout", funcname); - } - } - - pthread_mutex_unlock(&cm_command_mutex); - - return ret; -} - -void QmiThreadRecvQMI(PQCQMIMSG pResponse) { - pthread_mutex_lock(&cm_command_mutex); - if (pResponse == NULL) { - if (s_pRequest) { - free(s_pRequest); - s_pRequest = NULL; - s_pResponse = NULL; - pthread_cond_signal(&cm_command_cond); - } - pthread_mutex_unlock(&cm_command_mutex); - return; - } - dump_qmi(pResponse, le16_to_cpu(pResponse->QMIHdr.Length) + 1); - if (s_pRequest && is_response(s_pRequest, pResponse)) { - free(s_pRequest); - s_pRequest = NULL; - s_pResponse = malloc(le16_to_cpu(pResponse->QMIHdr.Length) + 1); - if (s_pResponse != NULL) { - memcpy(s_pResponse, pResponse, le16_to_cpu(pResponse->QMIHdr.Length) + 1); - } - pthread_cond_signal(&cm_command_cond); - } else if ((pResponse->QMIHdr.QMIType == QMUX_TYPE_CTL) - && (le16_to_cpu(pResponse->CTLMsg.QMICTLMsgHdrRsp.QMICTLType == QMICTL_REVOKE_CLIENT_ID_IND))) { - qmidevice_send_event_to_main(MODEM_REPORT_RESET_EVENT); - } else if ((pResponse->QMIHdr.QMIType == QMUX_TYPE_NAS) - && (le16_to_cpu(pResponse->MUXMsg.QMUXMsgHdrResp.Type) == QMINAS_SERVING_SYSTEM_IND)) { - qmidevice_send_event_to_main(RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED); - } else if ((pResponse->QMIHdr.QMIType == QMUX_TYPE_WDS) - && (le16_to_cpu(pResponse->MUXMsg.QMUXMsgHdrResp.Type) == QMIWDS_GET_PKT_SRVC_STATUS_IND)) { - qmidevice_send_event_to_main(RIL_UNSOL_DATA_CALL_LIST_CHANGED); - } else if ((pResponse->QMIHdr.QMIType == QMUX_TYPE_NAS) - && (le16_to_cpu(pResponse->MUXMsg.QMUXMsgHdrResp.Type) == QMINAS_SYS_INFO_IND)) { - qmidevice_send_event_to_main(RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED); - } else if ((pResponse->QMIHdr.QMIType == QMUX_TYPE_WDS_ADMIN) - && (le16_to_cpu(pResponse->MUXMsg.QMUXMsgHdrResp.Type) == QMI_WDA_SET_LOOPBACK_CONFIG_IND)) { - qmidevice_send_event_to_main_ext(RIL_UNSOL_LOOPBACK_CONFIG_IND, - &pResponse->MUXMsg.SetLoopBackInd, sizeof(pResponse->MUXMsg.SetLoopBackInd)); - } -#ifdef CONFIG_REG_QOS_IND - else if ((pResponse->QMIHdr.QMIType == QMUX_TYPE_QOS) - && (le16_to_cpu(pResponse->MUXMsg.QMUXMsgHdrResp.Type) == QMI_QOS_GLOBAL_QOS_FLOW_IND)) { - UINT qos_id = 0; - UCHAR new_flow = ql_get_global_qos_flow_ind_qos_id(pResponse, &qos_id); - if (qos_id != 0 && new_flow == 1) - qmidevice_send_event_to_main_ext(RIL_UNSOL_GLOBAL_QOS_FLOW_IND_QOS_ID, &qos_id, sizeof(qos_id)); -#ifdef CONFIG_GET_QOS_DATA_RATE - if (new_flow) { - ULONG64 max_data_rate[2] = {0}; - if (ql_get_global_qos_flow_ind_data_rate(pResponse, (void *)max_data_rate) == 0){} - } -#endif - } -#endif - else { - if (debug_qmi) - dbg_time("nobody care this qmi msg!!"); - } - pthread_mutex_unlock(&cm_command_mutex); -} - -#ifdef CONFIG_COEX_WWAN_STATE -static int requestGetCoexWWANState(void) { - PQCQMIMSG pRequest; - PQCQMIMSG pResponse; - PQMUX_MSG pMUXMsg; - PQMI_COEX_GET_WWAN_STATE_RESP_MSG_LTE_BAND pLteBand; - static QMI_COEX_GET_WWAN_STATE_RESP_MSG_LTE_BAND oldLteBand = {-1, -1}; - int err; - - pRequest = ComposeQMUXMsg(QMUX_TYPE_COEX, QMI_COEX_GET_WWAN_STATE_REQ, NULL, NULL); - err = QmiThreadSendQMI(pRequest, &pResponse); - - if (err < 0 || pResponse == NULL) { - dbg_time("%s err = %d", __func__, err); - return err; - } - - pMUXMsg = &pResponse->MUXMsg; - if (le16_to_cpu(pMUXMsg->QMUXMsgHdrResp.QMUXResult) || le16_to_cpu(pMUXMsg->QMUXMsgHdrResp.QMUXError)) { - dbg_time("%s QMUXResult = 0x%x, QMUXError = 0x%x", __func__, le16_to_cpu(pMUXMsg->QMUXMsgHdrResp.QMUXResult), le16_to_cpu(pMUXMsg->QMUXMsgHdrResp.QMUXError)); - err = le16_to_cpu(pMUXMsg->QMUXMsgHdrResp.QMUXError); - free(pResponse); - return err; - } - pLteBand = (PQMI_COEX_GET_WWAN_STATE_RESP_MSG_LTE_BAND)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x10); - - if (pLteBand && memcmp(pLteBand, &oldLteBand, sizeof(oldLteBand))) { - oldLteBand = *pLteBand; - dbg_time("%s ul_freq %d ul_bandwidth %d", __func__, le32_to_cpu(pLteBand->ul_band.freq), le32_to_cpu(pLteBand->ul_band.bandwidth)); - dbg_time("%s dl_freq %d dl_bandwidth %d", __func__, le32_to_cpu(pLteBand->dl_band.freq), le32_to_cpu(pLteBand->dl_band.bandwidth)); - } - free(pResponse); - return 0; -} -#endif - -static int requestSetEthMode(PROFILE_T *profile) { - PQCQMIMSG pRequest; - PQCQMIMSG pResponse = NULL; - PQMUX_MSG pMUXMsg; - int err; - PQMIWDS_ADMIN_SET_DATA_FORMAT_TLV linkProto; - UCHAR IpPreference; - UCHAR autoconnect_setting = 0; - QMAP_SETTING qmap_settings = {0}; - - qmap_settings.size = sizeof(qmap_settings); - - if (profile->qmap_mode) { - profile->rawIP = 1; - s_9x07 = profile->rawIP; - - qmap_settings.MuxId = profile->muxid; - - if (profile->hardware_interface == HARDWARE_PCIE) { //SDX20_PCIE - qmap_settings.rx_urb_size = profile->qmap_size; //SDX24&SDX55 support 32KB - qmap_settings.ep_type = DATA_EP_TYPE_PCIE; - qmap_settings.iface_id = 0x04; - } - else { // for MDM9x07&MDM9x40&SDX20 USB - qmap_settings.rx_urb_size = profile->qmap_size; //SDX24&SDX55 support 32KB - qmap_settings.ep_type = DATA_EP_TYPE_HSUSB; - qmap_settings.iface_id = 0x04; - } - - qmap_settings.ul_data_aggregation_max_datagrams = 11; //by test result, 11 can get best TPUT - qmap_settings.ul_data_aggregation_max_size = 8*1024; - qmap_settings.dl_minimum_padding = 0; //no effect when register to real netowrk - if(profile->qmap_version != 0x09) - profile->qmap_version = 0x05; - - qmap_version = profile->qmap_version; - if (profile->rmnet_info.size) { - qmap_settings.rx_urb_size = profile->rmnet_info.rx_urb_size; - qmap_settings.ep_type = profile->rmnet_info.ep_type; - qmap_settings.iface_id = profile->rmnet_info.iface_id; - qmap_settings.dl_minimum_padding = profile->rmnet_info.dl_minimum_padding; - qmap_version = profile->rmnet_info.qmap_version; - } - - if (!profile->wda_client) { - if (qmidev_is_gobinet(profile->qmichannel)) { - //when QMAP enabled, set data format in GobiNet driver - } - else if (profile->proxy[0]) { - /* the first running 'quectel-cm' had alloc wda client and set data format, - so we can ingore to set data format here. */ - } - goto skip_WdaSetDataFormat; - } - } - - pRequest = ComposeQMUXMsg(QMUX_TYPE_WDS_ADMIN, QMIWDS_ADMIN_SET_DATA_FORMAT_REQ, WdaSetDataFormat, (void *)&qmap_settings); - err = QmiThreadSendQMI(pRequest, &pResponse); - qmi_rsp_check_and_return(); - - linkProto = (PQMIWDS_ADMIN_SET_DATA_FORMAT_TLV)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x11); - if (linkProto != NULL) { - profile->rawIP = (le32_to_cpu(linkProto->Value) == 2); - s_9x07 = profile->rawIP; //MDM90x7 only support RAW IP, do not support Eth - } - - linkProto = (PQMIWDS_ADMIN_SET_DATA_FORMAT_TLV)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x16); - if (linkProto != NULL && profile->qmap_mode) { - qmap_settings.rx_urb_size = le32_to_cpu(linkProto->Value); - dbg_time("qmap_settings.rx_urb_size = %u", qmap_settings.rx_urb_size); //must same as rx_urb_size defined in GobiNet&qmi_wwan driver - } - -#ifdef QUECTEL_UL_DATA_AGG - if (qmap_settings.ul_data_aggregation_max_datagrams) - { - linkProto = (PQMIWDS_ADMIN_SET_DATA_FORMAT_TLV)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x17); - if (linkProto != NULL) { - qmap_settings.ul_data_aggregation_max_datagrams = MIN(qmap_settings.ul_data_aggregation_max_datagrams, le32_to_cpu(linkProto->Value)); - dbg_time("qmap_settings.ul_data_aggregation_max_datagrams = %u", qmap_settings.ul_data_aggregation_max_datagrams); - } - - linkProto = (PQMIWDS_ADMIN_SET_DATA_FORMAT_TLV)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x18); - if (linkProto != NULL) { - qmap_settings.ul_data_aggregation_max_size = MIN(qmap_settings.ul_data_aggregation_max_size, le32_to_cpu(linkProto->Value)); - dbg_time("qmap_settings.ul_data_aggregation_max_size = %u", qmap_settings.ul_data_aggregation_max_size); - } - - linkProto = (PQMIWDS_ADMIN_SET_DATA_FORMAT_TLV)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x1A); - if (linkProto != NULL) { - qmap_settings.dl_minimum_padding = le32_to_cpu(linkProto->Value); - dbg_time("qmap_settings.dl_minimum_padding = %u", qmap_settings.dl_minimum_padding); - } - - if (qmap_settings.ul_data_aggregation_max_datagrams > 1) { - ql_set_driver_qmap_setting(profile, &qmap_settings); - } - } -#endif - - free(pResponse); - -skip_WdaSetDataFormat: - if (profile->enable_ipv4) { - if (profile->qmapnet_adapter[0]) { - // bind wds mux data port - pRequest = ComposeQMUXMsg(QMUX_TYPE_WDS, QMIWDS_BIND_MUX_DATA_PORT_REQ , WdsSetQMUXBindMuxDataPort, (void *)&qmap_settings); - err = QmiThreadSendQMI(pRequest, &pResponse); - qmi_rsp_check_and_return(); - if (pResponse) free(pResponse); - } - - // set ipv4 - IpPreference = IpFamilyV4; - pRequest = ComposeQMUXMsg(QMUX_TYPE_WDS, QMIWDS_SET_CLIENT_IP_FAMILY_PREF_REQ, WdsSetClientIPFamilyPref, (void *)&IpPreference); - err = QmiThreadSendQMI(pRequest, &pResponse); - if (pResponse) free(pResponse); - } - - if (profile->enable_ipv6) { - if (profile->qmapnet_adapter[0]) { - // bind wds ipv6 mux data port - pRequest = ComposeQMUXMsg(QMUX_TYPE_WDS_IPV6, QMIWDS_BIND_MUX_DATA_PORT_REQ , WdsSetQMUXBindMuxDataPort, (void *)&qmap_settings); - err = QmiThreadSendQMI(pRequest, &pResponse); - qmi_rsp_check_and_return(); - if (pResponse) free(pResponse); - } - - // set ipv6 - IpPreference = IpFamilyV6; - pRequest = ComposeQMUXMsg(QMUX_TYPE_WDS_IPV6, QMIWDS_SET_CLIENT_IP_FAMILY_PREF_REQ, WdsSetClientIPFamilyPref, (void *)&IpPreference); - err = QmiThreadSendQMI(pRequest, &pResponse); - qmi_rsp_check_and_return(); - if (pResponse) free(pResponse); - } - - pRequest = ComposeQMUXMsg(QMUX_TYPE_WDS, QMIWDS_SET_AUTO_CONNECT_REQ , WdsSetAutoConnect, (void *)&autoconnect_setting); - QmiThreadSendQMI(pRequest, &pResponse); - if (pResponse) free(pResponse); - - return 0; -} - -#ifdef CONFIG_SIM -static int requestGetPINStatus(SIM_Status *pSIMStatus) { - PQCQMIMSG pRequest; - PQCQMIMSG pResponse; - PQMUX_MSG pMUXMsg; - int err; - PQMIDMS_UIM_PIN_STATUS pPin1Status = NULL; - //PQMIDMS_UIM_PIN_STATUS pPin2Status = NULL; - - if (s_9x07) - pRequest = ComposeQMUXMsg(QMUX_TYPE_UIM, QMIUIM_GET_CARD_STATUS_REQ, NULL, NULL); - else - pRequest = ComposeQMUXMsg(QMUX_TYPE_DMS, QMIDMS_UIM_GET_PIN_STATUS_REQ, NULL, NULL); - err = QmiThreadSendQMI(pRequest, &pResponse); - qmi_rsp_check_and_return(); - - pPin1Status = (PQMIDMS_UIM_PIN_STATUS)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x11); - //pPin2Status = (PQMIDMS_UIM_PIN_STATUS)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x12); - - if (pPin1Status != NULL) { - if (pPin1Status->PINStatus == QMI_PIN_STATUS_NOT_VERIF) { - *pSIMStatus = SIM_PIN; - } else if (pPin1Status->PINStatus == QMI_PIN_STATUS_BLOCKED) { - *pSIMStatus = SIM_PUK; - } else if (pPin1Status->PINStatus == QMI_PIN_STATUS_PERM_BLOCKED) { - *pSIMStatus = SIM_BAD; - } - } - - free(pResponse); - return 0; -} - -static int requestGetSIMStatus(SIM_Status *pSIMStatus) { //RIL_REQUEST_GET_SIM_STATUS - PQCQMIMSG pRequest; - PQCQMIMSG pResponse; - PQMUX_MSG pMUXMsg; - int err; - const char * SIM_Status_String[] = { - "SIM_ABSENT", - "SIM_NOT_READY", - "SIM_READY", /* SIM_READY means the radio state is RADIO_STATE_SIM_READY */ - "SIM_PIN", - "SIM_PUK", - "SIM_NETWORK_PERSONALIZATION" - }; - - if (s_9x07) - pRequest = ComposeQMUXMsg(QMUX_TYPE_UIM, QMIUIM_GET_CARD_STATUS_REQ, NULL, NULL); - else - pRequest = ComposeQMUXMsg(QMUX_TYPE_DMS, QMIDMS_UIM_GET_STATE_REQ, NULL, NULL); - - err = QmiThreadSendQMI(pRequest, &pResponse); - qmi_rsp_check_and_return(); - - *pSIMStatus = SIM_ABSENT; - if (s_9x07) - { - PQMIUIM_CARD_STATUS pCardStatus = NULL; - PQMIUIM_PIN_STATE pPINState = NULL; - UCHAR CardState = 0x01; - UCHAR PIN1State = QMI_PIN_STATUS_NOT_VERIF; - //UCHAR PIN1Retries; - //UCHAR PUK1Retries; - //UCHAR PIN2State; - //UCHAR PIN2Retries; - //UCHAR PUK2Retries; - - pCardStatus = (PQMIUIM_CARD_STATUS)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x10); - if (pCardStatus != NULL) - { - pPINState = (PQMIUIM_PIN_STATE)((PUCHAR)pCardStatus + sizeof(QMIUIM_CARD_STATUS) + pCardStatus->AIDLength); - CardState = pCardStatus->CardState; - if (CardState == UIM_CARD_STATE_PRESENT) { - if (pPINState->UnivPIN == 1) - { - PIN1State = pCardStatus->UPINState; - //PIN1Retries = pCardStatus->UPINRetries; - //PUK1Retries = pCardStatus->UPUKRetries; - } - else - { - PIN1State = pPINState->PIN1State; - //PIN1Retries = pPINState->PIN1Retries; - //PUK1Retries = pPINState->PUK1Retries; - } - //PIN2State = pPINState->PIN2State; - //PIN2Retries = pPINState->PIN2Retries; - //PUK2Retries = pPINState->PUK2Retries; - } - } - - *pSIMStatus = SIM_ABSENT; - if ((CardState == 0x01) && ((PIN1State == QMI_PIN_STATUS_VERIFIED)|| (PIN1State == QMI_PIN_STATUS_DISABLED))) - { - *pSIMStatus = SIM_READY; - } - else if (CardState == 0x01) - { - if (PIN1State == QMI_PIN_STATUS_NOT_VERIF) - { - *pSIMStatus = SIM_PIN; - } - if ( PIN1State == QMI_PIN_STATUS_BLOCKED) - { - *pSIMStatus = SIM_PUK; - } - else if (PIN1State == QMI_PIN_STATUS_PERM_BLOCKED) - { - *pSIMStatus = SIM_BAD; - } - else if (PIN1State == QMI_PIN_STATUS_NOT_INIT || PIN1State == QMI_PIN_STATUS_VERIFIED || PIN1State == QMI_PIN_STATUS_DISABLED) - { - *pSIMStatus = SIM_READY; - } - } - else if (CardState == 0x00 || CardState == 0x02) - { - } - else - { - } - } - else - { - //UIM state. Values: - // 0x00 UIM initialization completed - // 0x01 UIM is locked or the UIM failed - // 0x02 UIM is not present - // 0x03 Reserved - // 0xFF UIM state is currently - //unavailable - if (pResponse->MUXMsg.UIMGetStateResp.UIMState == 0x00) { - *pSIMStatus = SIM_READY; - } else if (pResponse->MUXMsg.UIMGetStateResp.UIMState == 0x01) { - *pSIMStatus = SIM_ABSENT; - err = requestGetPINStatus(pSIMStatus); - } else if ((pResponse->MUXMsg.UIMGetStateResp.UIMState == 0x02) || (pResponse->MUXMsg.UIMGetStateResp.UIMState == 0xFF)) { - *pSIMStatus = SIM_ABSENT; - } else { - *pSIMStatus = SIM_ABSENT; - } - } - dbg_time("%s SIMStatus: %s", __func__, SIM_Status_String[*pSIMStatus]); - - free(pResponse); - - return 0; -} - -static int requestEnterSimPin(const char *pPinCode) { - PQCQMIMSG pRequest; - PQCQMIMSG pResponse; - PQMUX_MSG pMUXMsg; - int err; - - if (s_9x07) - pRequest = ComposeQMUXMsg(QMUX_TYPE_UIM, QMIUIM_VERIFY_PIN_REQ, UimVerifyPinReqSend, (void *)pPinCode); - else - pRequest = ComposeQMUXMsg(QMUX_TYPE_DMS, QMIDMS_UIM_VERIFY_PIN_REQ, DmsUIMVerifyPinReqSend, (void *)pPinCode); - err = QmiThreadSendQMI(pRequest, &pResponse); - qmi_rsp_check_and_return(); - - free(pResponse); - return 0; -} -#endif - -#ifdef CONFIG_IMSI_ICCID -static int requestGetICCID(void) { //RIL_REQUEST_GET_IMSI - PQCQMIMSG pRequest; - PQCQMIMSG pResponse; - PQMUX_MSG pMUXMsg; - PQMIUIM_CONTENT pUimContent; - int err; - - if (s_9x07) { - pRequest = ComposeQMUXMsg(QMUX_TYPE_UIM, QMIUIM_READ_TRANSPARENT_REQ, UimReadTransparentIMSIReqSend, (void *)"EF_ICCID"); - err = QmiThreadSendQMI(pRequest, &pResponse); - } else { - return 0; - } - qmi_rsp_check_and_return(); - - pUimContent = (PQMIUIM_CONTENT)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x11); - if (pUimContent != NULL) { - static char DeviceICCID[32] = {'\0'}; - int i = 0, j = 0; - - for (i = 0, j = 0; i < le16_to_cpu(pUimContent->content_len); ++i) { - char charmaps[] = "0123456789ABCDEF"; - - DeviceICCID[j++] = charmaps[(pUimContent->content[i] & 0x0F)]; - DeviceICCID[j++] = charmaps[((pUimContent->content[i] & 0xF0) >> 0x04)]; - } - DeviceICCID[j] = '\0'; - - dbg_time("%s DeviceICCID: %s", __func__, DeviceICCID); - } - - free(pResponse); - return 0; -} - -static int requestGetIMSI(void) { //RIL_REQUEST_GET_IMSI - PQCQMIMSG pRequest; - PQCQMIMSG pResponse; - PQMUX_MSG pMUXMsg; - PQMIUIM_CONTENT pUimContent; - int err; - - if (s_9x07) { - pRequest = ComposeQMUXMsg(QMUX_TYPE_UIM, QMIUIM_READ_TRANSPARENT_REQ, UimReadTransparentIMSIReqSend, (void *)"EF_IMSI"); - err = QmiThreadSendQMI(pRequest, &pResponse); - } else { - return 0; - } - qmi_rsp_check_and_return(); - - pUimContent = (PQMIUIM_CONTENT)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x11); - if (pUimContent != NULL) { - static char DeviceIMSI[32] = {'\0'}; - int i = 0, j = 0; - - for (i = 0, j = 0; i < le16_to_cpu(pUimContent->content[0]); ++i) { - if (i != 0) - DeviceIMSI[j++] = (pUimContent->content[i+1] & 0x0F) + '0'; - DeviceIMSI[j++] = ((pUimContent->content[i+1] & 0xF0) >> 0x04) + '0'; - } - DeviceIMSI[j] = '\0'; - - dbg_time("%s DeviceIMSI: %s", __func__, DeviceIMSI); - } - - free(pResponse); - return 0; -} -#endif - -#if 1 -static void quectel_convert_cdma_mcc_2_ascii_mcc( USHORT *p_mcc, USHORT mcc ) -{ - unsigned int d1, d2, d3, buf = mcc + 111; - - if ( mcc == 0x3FF ) // wildcard - { - *p_mcc = 3; - } - else - { - d3 = buf % 10; - buf = ( d3 == 0 ) ? (buf-10)/10 : buf/10; - - d2 = buf % 10; - buf = ( d2 == 0 ) ? (buf-10)/10 : buf/10; - - d1 = ( buf == 10 ) ? 0 : buf; - -//dbg_time("d1:%d, d2:%d,d3:%d",d1,d2,d3); - if ( d1<10 && d2<10 && d3<10 ) - { - *p_mcc = d1*100+d2*10+d3; -#if 0 - *(p_mcc+0) = '0' + d1; - *(p_mcc+1) = '0' + d2; - *(p_mcc+2) = '0' + d3; -#endif - } - else - { - //dbg_time( "invalid digits %d %d %d", d1, d2, d3 ); - *p_mcc = 0; - } - } -} - -static void quectel_convert_cdma_mnc_2_ascii_mnc( USHORT *p_mnc, USHORT imsi_11_12) -{ - unsigned int d1, d2, buf = imsi_11_12 + 11; - - if ( imsi_11_12 == 0x7F ) // wildcard - { - *p_mnc = 7; - } - else - { - d2 = buf % 10; - buf = ( d2 == 0 ) ? (buf-10)/10 : buf/10; - - d1 = ( buf == 10 ) ? 0 : buf; - - if ( d1<10 && d2<10 ) - { - *p_mnc = d1*10 + d2; - } - else - { - //dbg_time( "invalid digits %d %d", d1, d2, 0 ); - *p_mnc = 0; - } - } -} - -static int requestGetHomeNetwork(USHORT *p_mcc, USHORT *p_mnc, USHORT *p_sid, USHORT *p_nid) { - PQCQMIMSG pRequest; - PQCQMIMSG pResponse; - PQMUX_MSG pMUXMsg; - int err; - PHOME_NETWORK pHomeNetwork; - PHOME_NETWORK_SYSTEMID pHomeNetworkSystemID; - - pRequest = ComposeQMUXMsg(QMUX_TYPE_NAS, QMINAS_GET_HOME_NETWORK_REQ, NULL, NULL); - err = QmiThreadSendQMI(pRequest, &pResponse); - qmi_rsp_check_and_return(); - - pHomeNetwork = (PHOME_NETWORK)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x01); - if (pHomeNetwork && p_mcc && p_mnc ) { - *p_mcc = le16_to_cpu(pHomeNetwork->MobileCountryCode); - *p_mnc = le16_to_cpu(pHomeNetwork->MobileNetworkCode); - //dbg_time("%s MobileCountryCode: %d, MobileNetworkCode: %d", __func__, *pMobileCountryCode, *pMobileNetworkCode); - } - - pHomeNetworkSystemID = (PHOME_NETWORK_SYSTEMID)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x10); - if (pHomeNetworkSystemID && p_sid && p_nid) { - *p_sid = le16_to_cpu(pHomeNetworkSystemID->SystemID); //china-hefei: sid 14451 - *p_nid = le16_to_cpu(pHomeNetworkSystemID->NetworkID); - //dbg_time("%s SystemID: %d, NetworkID: %d", __func__, *pSystemID, *pNetworkID); - } - - free(pResponse); - - return 0; -} -#endif - -#if 0 -// Lookup table for carriers known to produce SIMs which incorrectly indicate MNC length. -static const char * MCCMNC_CODES_HAVING_3DIGITS_MNC[] = { - "302370", "302720", "310260", - "405025", "405026", "405027", "405028", "405029", "405030", "405031", "405032", - "405033", "405034", "405035", "405036", "405037", "405038", "405039", "405040", - "405041", "405042", "405043", "405044", "405045", "405046", "405047", "405750", - "405751", "405752", "405753", "405754", "405755", "405756", "405799", "405800", - "405801", "405802", "405803", "405804", "405805", "405806", "405807", "405808", - "405809", "405810", "405811", "405812", "405813", "405814", "405815", "405816", - "405817", "405818", "405819", "405820", "405821", "405822", "405823", "405824", - "405825", "405826", "405827", "405828", "405829", "405830", "405831", "405832", - "405833", "405834", "405835", "405836", "405837", "405838", "405839", "405840", - "405841", "405842", "405843", "405844", "405845", "405846", "405847", "405848", - "405849", "405850", "405851", "405852", "405853", "405875", "405876", "405877", - "405878", "405879", "405880", "405881", "405882", "405883", "405884", "405885", - "405886", "405908", "405909", "405910", "405911", "405912", "405913", "405914", - "405915", "405916", "405917", "405918", "405919", "405920", "405921", "405922", - "405923", "405924", "405925", "405926", "405927", "405928", "405929", "405930", - "405931", "405932", "502142", "502143", "502145", "502146", "502147", "502148" -}; - -static const char * MCC_CODES_HAVING_3DIGITS_MNC[] = { - "302", //Canada - "310", //United States of America - "311", //United States of America - "312", //United States of America - "313", //United States of America - "314", //United States of America - "315", //United States of America - "316", //United States of America - "334", //Mexico - "338", //Jamaica - "342", //Barbados - "344", //Antigua and Barbuda - "346", //Cayman Islands - "348", //British Virgin Islands - "365", //Anguilla - "708", //Honduras (Republic of) - "722", //Argentine Republic - "732" //Colombia (Republic of) -}; - -int requestGetIMSI(const char **pp_imsi, USHORT *pMobileCountryCode, USHORT *pMobileNetworkCode) { - PQCQMIMSG pRequest; - PQCQMIMSG pResponse; - PQMUX_MSG pMUXMsg; - int err; - - if (pp_imsi) *pp_imsi = NULL; - if (pMobileCountryCode) *pMobileCountryCode = 0; - if (pMobileNetworkCode) *pMobileNetworkCode = 0; - - pRequest = ComposeQMUXMsg(QMUX_TYPE_DMS, QMIDMS_UIM_GET_IMSI_REQ, NULL, NULL); - err = QmiThreadSendQMI(pRequest, &pResponse); - qmi_rsp_check_and_return(); - - if (pMUXMsg->UIMGetIMSIResp.TLV2Type == 0x01 && le16_to_cpu(pMUXMsg->UIMGetIMSIResp.TLV2Length) >= 5) { - int mnc_len = 2; - unsigned i; - char tmp[4]; - - if (pp_imsi) *pp_imsi = strndup((const char *)(&pMUXMsg->UIMGetIMSIResp.IMSI), le16_to_cpu(pMUXMsg->UIMGetIMSIResp.TLV2Length)); - - for (i = 0; i < sizeof(MCCMNC_CODES_HAVING_3DIGITS_MNC)/sizeof(MCCMNC_CODES_HAVING_3DIGITS_MNC[0]); i++) { - if (!strncmp((const char *)(&pMUXMsg->UIMGetIMSIResp.IMSI), MCCMNC_CODES_HAVING_3DIGITS_MNC[i], 6)) { - mnc_len = 3; - break; - } - } - if (mnc_len == 2) { - for (i = 0; i < sizeof(MCC_CODES_HAVING_3DIGITS_MNC)/sizeof(MCC_CODES_HAVING_3DIGITS_MNC[0]); i++) { - if (!strncmp((const char *)(&pMUXMsg->UIMGetIMSIResp.IMSI), MCC_CODES_HAVING_3DIGITS_MNC[i], 3)) { - mnc_len = 3; - break; - } - } - } - - tmp[0] = (&pMUXMsg->UIMGetIMSIResp.IMSI)[0]; - tmp[1] = (&pMUXMsg->UIMGetIMSIResp.IMSI)[1]; - tmp[2] = (&pMUXMsg->UIMGetIMSIResp.IMSI)[2]; - tmp[3] = 0; - if (pMobileCountryCode) *pMobileCountryCode = atoi(tmp); - tmp[0] = (&pMUXMsg->UIMGetIMSIResp.IMSI)[3]; - tmp[1] = (&pMUXMsg->UIMGetIMSIResp.IMSI)[4]; - tmp[2] = 0; - if (mnc_len == 3) { - tmp[2] = (&pMUXMsg->UIMGetIMSIResp.IMSI)[6]; - } - if (pMobileNetworkCode) *pMobileNetworkCode = atoi(tmp); - } - - free(pResponse); - - return 0; -} -#endif - -static struct wwan_data_class_str class2str[] = { - {WWAN_DATA_CLASS_NONE, "UNKNOWN"}, - {WWAN_DATA_CLASS_GPRS, "GPRS"}, - {WWAN_DATA_CLASS_EDGE, "EDGE"}, - {WWAN_DATA_CLASS_UMTS, "UMTS"}, - {WWAN_DATA_CLASS_HSDPA, "HSDPA"}, - {WWAN_DATA_CLASS_HSUPA, "HSUPA"}, - {WWAN_DATA_CLASS_LTE, "LTE"}, - {WWAN_DATA_CLASS_5G_NSA, "5G_NSA"}, - {WWAN_DATA_CLASS_5G_SA, "5G_SA"}, - {WWAN_DATA_CLASS_1XRTT, "1XRTT"}, - {WWAN_DATA_CLASS_1XEVDO, "1XEVDO"}, - {WWAN_DATA_CLASS_1XEVDO_REVA, "1XEVDO_REVA"}, - {WWAN_DATA_CLASS_1XEVDV, "1XEVDV"}, - {WWAN_DATA_CLASS_3XRTT, "3XRTT"}, - {WWAN_DATA_CLASS_1XEVDO_REVB, "1XEVDO_REVB"}, - {WWAN_DATA_CLASS_UMB, "UMB"}, - {WWAN_DATA_CLASS_CUSTOM, "CUSTOM"}, -}; - -static const char *wwan_data_class2str(ULONG class) -{ - unsigned int i = 0; - for (i = 0; i < sizeof(class2str)/sizeof(class2str[0]); i++) { - if (class2str[i].class == class) { - return class2str[i].str; - } - } - return "UNKNOWN"; -} - -static USHORT char2ushort(UCHAR str[3]) { - int i; - char temp[4]; - USHORT ret= 0; - - memcpy(temp, str, 3); - temp[3] = '\0'; - - for (i = 0; i < 4; i++) { - if ((UCHAR)temp[i] == 0xFF) { - temp[i] = '\0'; - } - } - ret = (USHORT)atoi(temp); - - return ret; -} - -static int requestRegistrationState2(UCHAR *pPSAttachedState) { - PQCQMIMSG pRequest; - PQCQMIMSG pResponse; - PQMUX_MSG pMUXMsg; - int err; - USHORT MobileCountryCode = 0; - USHORT MobileNetworkCode = 0; - const char *pDataCapStr = "UNKNOW"; - LONG remainingLen; - PSERVICE_STATUS_INFO pServiceStatusInfo; - int is_lte = 0; - PCDMA_SYSTEM_INFO pCdmaSystemInfo; - PHDR_SYSTEM_INFO pHdrSystemInfo; - PGSM_SYSTEM_INFO pGsmSystemInfo; - PWCDMA_SYSTEM_INFO pWcdmaSystemInfo; - PLTE_SYSTEM_INFO pLteSystemInfo; - PTDSCDMA_SYSTEM_INFO pTdscdmaSystemInfo; - PNR5G_SYSTEM_INFO pNr5gSystemInfo; - UCHAR DeviceClass = 0; - ULONG DataCapList = 0; - - /* Additional LTE System Info - Availability of Dual connectivity of E-UTRA with NR5G */ - uint8_t endc_available_valid = 0; /**< Must be set to true if endc_available is being passed */ - uint8_t endc_available = 0x00; - /**< - Upper layer indication in LTE SIB2. Values: \n - - 0x00 -- 5G Not available \n - - 0x01 -- 5G Available - - */ - /* Additional LTE System Info - DCNR restriction Info */ - uint8_t restrict_dcnr_valid = 0; /**< Must be set to true if restrict_dcnr is being passed */ - uint8_t restrict_dcnr = 0x01; - /**< - DCNR restriction in NAS attach/TAU accept. Values: \n - - 0x00 -- Not restricted \n - - 0x01 -- Restricted - */ - - *pPSAttachedState = 0; - pRequest = ComposeQMUXMsg(QMUX_TYPE_NAS, QMINAS_GET_SYS_INFO_REQ, NULL, NULL); - err = QmiThreadSendQMI(pRequest, &pResponse); - qmi_rsp_check_and_return(); - - pServiceStatusInfo = (PSERVICE_STATUS_INFO)(((PCHAR)&pMUXMsg->GetSysInfoResp) + QCQMUX_MSG_HDR_SIZE); - remainingLen = le16_to_cpu(pMUXMsg->GetSysInfoResp.Length); - - s_is_cdma = 0; - s_5g_type = WWAN_DATA_CLASS_NONE; - s_hdr_personality = 0; - while (remainingLen > 0) { - switch (pServiceStatusInfo->TLVType) { - case 0x10: // CDMA - if (pServiceStatusInfo->SrvStatus == 0x02) { - DataCapList = WWAN_DATA_CLASS_1XRTT| - WWAN_DATA_CLASS_1XEVDO| - WWAN_DATA_CLASS_1XEVDO_REVA| - WWAN_DATA_CLASS_1XEVDV| - WWAN_DATA_CLASS_1XEVDO_REVB; - DeviceClass = DEVICE_CLASS_CDMA; - s_is_cdma = (0 == is_lte); - } - break; - case 0x11: // HDR - if (pServiceStatusInfo->SrvStatus == 0x02) { - DataCapList = WWAN_DATA_CLASS_3XRTT| - WWAN_DATA_CLASS_UMB; - DeviceClass = DEVICE_CLASS_CDMA; - s_is_cdma = (0 == is_lte); - } - break; - case 0x12: // GSM - if (pServiceStatusInfo->SrvStatus == 0x02) { - DataCapList = WWAN_DATA_CLASS_GPRS| - WWAN_DATA_CLASS_EDGE; - DeviceClass = DEVICE_CLASS_GSM; - } - break; - case 0x13: // WCDMA - if (pServiceStatusInfo->SrvStatus == 0x02) { - DataCapList = WWAN_DATA_CLASS_UMTS; - DeviceClass = DEVICE_CLASS_GSM; - } - break; - case 0x14: // LTE - if (pServiceStatusInfo->SrvStatus == 0x02) { - DataCapList = WWAN_DATA_CLASS_LTE; - DeviceClass = DEVICE_CLASS_GSM; - is_lte = 1; - s_is_cdma = 0; - } - break; - case 0x4A: // NR5G Service Status Info - if (pServiceStatusInfo->SrvStatus == NAS_SYS_SRV_STATUS_SRV_V01) { - DataCapList |= WWAN_DATA_CLASS_5G_SA; - DeviceClass = DEVICE_CLASS_GSM; - is_lte = 1; - s_is_cdma = 0; - } - break; - case 0x4B: // NR5G System Info - pNr5gSystemInfo = (PNR5G_SYSTEM_INFO)pServiceStatusInfo; - if (pNr5gSystemInfo->srv_domain_valid == 0x01) { - if (pNr5gSystemInfo->srv_domain & SYS_SRV_DOMAIN_PS_ONLY_V01) { - *pPSAttachedState = 1; - } - } - - if (pNr5gSystemInfo->network_id_valid == 0x01) { - MobileCountryCode = (USHORT)char2ushort(pNr5gSystemInfo->MCC); - MobileNetworkCode = (USHORT)char2ushort(pNr5gSystemInfo->MNC); - } - break; - case 0x4E: //Additional LTE System Info - Availability of Dual Connectivity of E-UTRA with NR5G - endc_available_valid = 1; - endc_available = pServiceStatusInfo->SrvStatus; - break; - - case 0x4F: //Additional LTE System Info - DCNR restriction Info - restrict_dcnr_valid = 1; - restrict_dcnr = pServiceStatusInfo->SrvStatus; - break; - - case 0x24: // TDSCDMA - if (pServiceStatusInfo->SrvStatus == 0x02) { - pDataCapStr = "TD-SCDMA"; - } - break; - case 0x15: // CDMA - // CDMA_SYSTEM_INFO - pCdmaSystemInfo = (PCDMA_SYSTEM_INFO)pServiceStatusInfo; - if (pCdmaSystemInfo->SrvDomainValid == 0x01) { - if (pCdmaSystemInfo->SrvDomain & 0x02) { - *pPSAttachedState = 1; - s_is_cdma = (0 == is_lte); - } - } -#if 0 - if (pCdmaSystemInfo->SrvCapabilityValid == 0x01) { - *pPSAttachedState = 0; - if (pCdmaSystemInfo->SrvCapability & 0x02) { - *pPSAttachedState = 1; - s_is_cdma = (0 == is_lte); - } - } -#endif - if (pCdmaSystemInfo->NetworkIdValid == 0x01) { - MobileCountryCode = (USHORT)char2ushort(pCdmaSystemInfo->MCC); - MobileNetworkCode = (USHORT)char2ushort(pCdmaSystemInfo->MNC); - } - break; - case 0x16: // HDR - // HDR_SYSTEM_INFO - pHdrSystemInfo = (PHDR_SYSTEM_INFO)pServiceStatusInfo; - if (pHdrSystemInfo->SrvDomainValid == 0x01) { - if (pHdrSystemInfo->SrvDomain & 0x02) { - *pPSAttachedState = 1; - s_is_cdma = (0 == is_lte); - } - } -#if 0 - if (pHdrSystemInfo->SrvCapabilityValid == 0x01) { - *pPSAttachedState = 0; - if (pHdrSystemInfo->SrvCapability & 0x02) { - *pPSAttachedState = 1; - s_is_cdma = (0 == is_lte); - } - } -#endif - if (*pPSAttachedState && pHdrSystemInfo->HdrPersonalityValid == 0x01) { - if (pHdrSystemInfo->HdrPersonality == 0x03) - s_hdr_personality = 0x02; - //else if (pHdrSystemInfo->HdrPersonality == 0x02) - // s_hdr_personality = 0x01; - } - USHORT cmda_mcc = 0, cdma_mnc = 0; - if(!requestGetHomeNetwork(&cmda_mcc, &cdma_mnc,NULL, NULL) && cmda_mcc) { - quectel_convert_cdma_mcc_2_ascii_mcc(&MobileCountryCode, cmda_mcc); - quectel_convert_cdma_mnc_2_ascii_mnc(&MobileNetworkCode, cdma_mnc); - } - break; - case 0x17: // GSM - // GSM_SYSTEM_INFO - pGsmSystemInfo = (PGSM_SYSTEM_INFO)pServiceStatusInfo; - if (pGsmSystemInfo->SrvDomainValid == 0x01) { - if (pGsmSystemInfo->SrvDomain & 0x02) { - *pPSAttachedState = 1; - } - } -#if 0 - if (pGsmSystemInfo->SrvCapabilityValid == 0x01) { - *pPSAttachedState = 0; - if (pGsmSystemInfo->SrvCapability & 0x02) { - *pPSAttachedState = 1; - } - } -#endif - if (pGsmSystemInfo->NetworkIdValid == 0x01) { - MobileCountryCode = (USHORT)char2ushort(pGsmSystemInfo->MCC); - MobileNetworkCode = (USHORT)char2ushort(pGsmSystemInfo->MNC); - } - break; - case 0x18: // WCDMA - // WCDMA_SYSTEM_INFO - pWcdmaSystemInfo = (PWCDMA_SYSTEM_INFO)pServiceStatusInfo; - if (pWcdmaSystemInfo->SrvDomainValid == 0x01) { - if (pWcdmaSystemInfo->SrvDomain & 0x02) { - *pPSAttachedState = 1; - } - } -#if 0 - if (pWcdmaSystemInfo->SrvCapabilityValid == 0x01) { - *pPSAttachedState = 0; - if (pWcdmaSystemInfo->SrvCapability & 0x02) { - *pPSAttachedState = 1; - } - } -#endif - if (pWcdmaSystemInfo->NetworkIdValid == 0x01) { - MobileCountryCode = (USHORT)char2ushort(pWcdmaSystemInfo->MCC); - MobileNetworkCode = (USHORT)char2ushort(pWcdmaSystemInfo->MNC); - } - break; - case 0x19: // LTE_SYSTEM_INFO - // LTE_SYSTEM_INFO - pLteSystemInfo = (PLTE_SYSTEM_INFO)pServiceStatusInfo; - if (pLteSystemInfo->SrvDomainValid == 0x01) { - if (pLteSystemInfo->SrvDomain & 0x02) { - *pPSAttachedState = 1; - is_lte = 1; - s_is_cdma = 0; - } - } -#if 0 - if (pLteSystemInfo->SrvCapabilityValid == 0x01) { - *pPSAttachedState = 0; - if (pLteSystemInfo->SrvCapability & 0x02) { - *pPSAttachedState = 1; - is_lte = 1; - s_is_cdma = 0; - } - } -#endif - if (pLteSystemInfo->NetworkIdValid == 0x01) { - MobileCountryCode = (USHORT)char2ushort(pLteSystemInfo->MCC); - MobileNetworkCode = (USHORT)char2ushort(pLteSystemInfo->MNC); - } - break; - case 0x25: // TDSCDMA - // TDSCDMA_SYSTEM_INFO - pTdscdmaSystemInfo = (PTDSCDMA_SYSTEM_INFO)pServiceStatusInfo; - if (pTdscdmaSystemInfo->SrvDomainValid == 0x01) { - if (pTdscdmaSystemInfo->SrvDomain & 0x02) { - *pPSAttachedState = 1; - } - } -#if 0 - if (pTdscdmaSystemInfo->SrvCapabilityValid == 0x01) { - *pPSAttachedState = 0; - if (pTdscdmaSystemInfo->SrvCapability & 0x02) { - *pPSAttachedState = 1; - } - } -#endif - if (pTdscdmaSystemInfo->NetworkIdValid == 0x01) { - MobileCountryCode = (USHORT)char2ushort(pTdscdmaSystemInfo->MCC); - MobileNetworkCode = (USHORT)char2ushort(pTdscdmaSystemInfo->MNC); - } - break; - default: - break; - } /* switch (pServiceStatusInfo->TLYType) */ - - remainingLen -= (le16_to_cpu(pServiceStatusInfo->TLVLength) + 3); - pServiceStatusInfo = (PSERVICE_STATUS_INFO)((PCHAR)&pServiceStatusInfo->TLVLength + le16_to_cpu(pServiceStatusInfo->TLVLength) + sizeof(USHORT)); - } /* while (remainingLen > 0) */ - - if (DataCapList & WWAN_DATA_CLASS_LTE) { - if (endc_available_valid && restrict_dcnr_valid) { - if (endc_available && !restrict_dcnr) { - DataCapList |= WWAN_DATA_CLASS_5G_NSA; - } - } - } - - if (DeviceClass == DEVICE_CLASS_CDMA) { - if (s_hdr_personality == 2) { - pDataCapStr = s_hdr_personality == 2 ? "eHRPD" : "HRPD"; - } else if (DataCapList & WWAN_DATA_CLASS_1XEVDO_REVB) { - pDataCapStr = wwan_data_class2str(WWAN_DATA_CLASS_1XEVDO_REVB); - } else if (DataCapList & WWAN_DATA_CLASS_1XEVDO_REVA) { - pDataCapStr = wwan_data_class2str(WWAN_DATA_CLASS_1XEVDO_REVA); - } else if (DataCapList & WWAN_DATA_CLASS_1XEVDO) { - pDataCapStr = wwan_data_class2str(WWAN_DATA_CLASS_1XEVDO); - } else if (DataCapList & WWAN_DATA_CLASS_1XRTT) { - pDataCapStr = wwan_data_class2str(WWAN_DATA_CLASS_1XRTT); - } else if (DataCapList & WWAN_DATA_CLASS_3XRTT) { - pDataCapStr = wwan_data_class2str(WWAN_DATA_CLASS_3XRTT); - } else if (DataCapList & WWAN_DATA_CLASS_UMB) { - pDataCapStr = wwan_data_class2str(WWAN_DATA_CLASS_UMB); - } - } else { - if (DataCapList & WWAN_DATA_CLASS_5G_SA) { - s_5g_type = WWAN_DATA_CLASS_5G_SA; - pDataCapStr = wwan_data_class2str(WWAN_DATA_CLASS_5G_SA); - } else if (DataCapList & WWAN_DATA_CLASS_5G_NSA) { - s_5g_type = WWAN_DATA_CLASS_5G_NSA; - pDataCapStr = wwan_data_class2str(WWAN_DATA_CLASS_5G_NSA); - } else if (DataCapList & WWAN_DATA_CLASS_LTE) { - pDataCapStr = wwan_data_class2str(WWAN_DATA_CLASS_LTE); - } else if ((DataCapList & WWAN_DATA_CLASS_HSDPA) && (DataCapList & WWAN_DATA_CLASS_HSUPA)) { - pDataCapStr = "HSDPA_HSUPA"; - } else if (DataCapList & WWAN_DATA_CLASS_HSDPA) { - pDataCapStr = wwan_data_class2str(WWAN_DATA_CLASS_HSDPA); - } else if (DataCapList & WWAN_DATA_CLASS_HSUPA) { - pDataCapStr = wwan_data_class2str(WWAN_DATA_CLASS_HSUPA); - } else if (DataCapList & WWAN_DATA_CLASS_UMTS) { - pDataCapStr = wwan_data_class2str(WWAN_DATA_CLASS_UMTS); - } else if (DataCapList & WWAN_DATA_CLASS_EDGE) { - pDataCapStr = wwan_data_class2str(WWAN_DATA_CLASS_EDGE); - } else if (DataCapList & WWAN_DATA_CLASS_GPRS) { - pDataCapStr = wwan_data_class2str(WWAN_DATA_CLASS_GPRS); - } - } - - dbg_time("%s MCC: %d, MNC: %d, PS: %s, DataCap: %s", __func__, - MobileCountryCode, MobileNetworkCode, (*pPSAttachedState == 1) ? "Attached" : "Detached" , pDataCapStr); - - free(pResponse); - - return 0; -} - -static int requestRegistrationState(UCHAR *pPSAttachedState) { - PQCQMIMSG pRequest; - PQCQMIMSG pResponse; - PQMUX_MSG pMUXMsg; - int err; - PQMINAS_CURRENT_PLMN_MSG pCurrentPlmn; - PSERVING_SYSTEM pServingSystem; - PQMINAS_DATA_CAP pDataCap; - USHORT MobileCountryCode = 0; - USHORT MobileNetworkCode = 0; - const char *pDataCapStr = "UNKNOW"; - - if (s_9x07) { - return requestRegistrationState2(pPSAttachedState); - } - - pRequest = ComposeQMUXMsg(QMUX_TYPE_NAS, QMINAS_GET_SERVING_SYSTEM_REQ, NULL, NULL); - err = QmiThreadSendQMI(pRequest, &pResponse); - qmi_rsp_check_and_return(); - - pCurrentPlmn = (PQMINAS_CURRENT_PLMN_MSG)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x12); - if (pCurrentPlmn) { - MobileCountryCode = le16_to_cpu(pCurrentPlmn->MobileCountryCode); - MobileNetworkCode = le16_to_cpu(pCurrentPlmn->MobileNetworkCode); - } - - *pPSAttachedState = 0; - pServingSystem = (PSERVING_SYSTEM)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x01); - if (pServingSystem) { - //Packet-switched domain attach state of the mobile. - //0x00 PS_UNKNOWN ?Unknown or not applicable - //0x01 PS_ATTACHED ?Attached - //0x02 PS_DETACHED ?Detached - *pPSAttachedState = pServingSystem->RegistrationState; - if (pServingSystem->RegistrationState == 0x01) //0x01 ?C REGISTERED ?C Registered with a network - *pPSAttachedState = pServingSystem->PSAttachedState; - else { - //MobileCountryCode = MobileNetworkCode = 0; - *pPSAttachedState = 0x02; - } - } - - pDataCap = (PQMINAS_DATA_CAP)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x11); - if (pDataCap && pDataCap->DataCapListLen) { - UCHAR *DataCap = &pDataCap->DataCap; - if (pDataCap->DataCapListLen == 2) { - if ((DataCap[0] == 0x06) && ((DataCap[1] == 0x08) || (DataCap[1] == 0x0A))) - DataCap[0] = DataCap[1]; - } - switch (DataCap[0]) { - case 0x01: pDataCapStr = "GPRS"; break; - case 0x02: pDataCapStr = "EDGE"; break; - case 0x03: pDataCapStr = "HSDPA"; break; - case 0x04: pDataCapStr = "HSUPA"; break; - case 0x05: pDataCapStr = "UMTS"; break; - case 0x06: pDataCapStr = "1XRTT"; break; - case 0x07: pDataCapStr = "1XEVDO"; break; - case 0x08: pDataCapStr = "1XEVDO_REVA"; break; - case 0x09: pDataCapStr = "GPRS"; break; - case 0x0A: pDataCapStr = "1XEVDO_REVB"; break; - case 0x0B: pDataCapStr = "LTE"; break; - case 0x0C: pDataCapStr = "HSDPA"; break; - case 0x0D: pDataCapStr = "HSDPA"; break; - default: pDataCapStr = "UNKNOW"; break; - } - } - - if (pServingSystem && pServingSystem->RegistrationState == 0x01 && pServingSystem->InUseRadioIF && pServingSystem->RadioIF == 0x09) { - pDataCapStr = "TD-SCDMA"; - } - - s_is_cdma = 0; - if (pServingSystem && pServingSystem->RegistrationState == 0x01 && pServingSystem->InUseRadioIF && (pServingSystem->RadioIF == 0x01 || pServingSystem->RadioIF == 0x02)) { - USHORT cmda_mcc = 0, cdma_mnc = 0; - s_is_cdma = 1; - if(!requestGetHomeNetwork(&cmda_mcc, &cdma_mnc,NULL, NULL) && cmda_mcc) { - quectel_convert_cdma_mcc_2_ascii_mcc(&MobileCountryCode, cmda_mcc); - quectel_convert_cdma_mnc_2_ascii_mnc(&MobileNetworkCode, cdma_mnc); - } - if (1) { - PQCQMUX_TLV pTLV = (PQCQMUX_TLV)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x23); - if (pTLV) - s_hdr_personality = pTLV->Value; - else - s_hdr_personality = 0; - if (s_hdr_personality == 2) - pDataCapStr = "eHRPD"; - } - } - - dbg_time("%s MCC: %d, MNC: %d, PS: %s, DataCap: %s", __func__, - MobileCountryCode, MobileNetworkCode, (*pPSAttachedState == 1) ? "Attached" : "Detached" , pDataCapStr); - - free(pResponse); - - return 0; -} - -static int requestQueryDataCall(UCHAR *pConnectionStatus, int curIpFamily) { - PQCQMIMSG pRequest; - PQCQMIMSG pResponse; - PQMUX_MSG pMUXMsg; - int err; - PQMIWDS_PKT_SRVC_TLV pPktSrvc; - UCHAR oldConnectionStatus = *pConnectionStatus; - UCHAR QMIType = (curIpFamily == IpFamilyV4) ? QMUX_TYPE_WDS : QMUX_TYPE_WDS_IPV6; - - pRequest = ComposeQMUXMsg(QMIType, QMIWDS_GET_PKT_SRVC_STATUS_REQ, NULL, NULL); - err = QmiThreadSendQMI(pRequest, &pResponse); - qmi_rsp_check_and_return(); - - *pConnectionStatus = QWDS_PKT_DATA_DISCONNECTED; - pPktSrvc = (PQMIWDS_PKT_SRVC_TLV)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x01); - if (pPktSrvc) { - *pConnectionStatus = pPktSrvc->ConnectionStatus; - if ((le16_to_cpu(pPktSrvc->TLVLength) == 2) && (pPktSrvc->ReconfigReqd == 0x01)) - *pConnectionStatus = QWDS_PKT_DATA_DISCONNECTED; - } - - if (*pConnectionStatus == QWDS_PKT_DATA_DISCONNECTED) { - if (curIpFamily == IpFamilyV4) - WdsConnectionIPv4Handle = 0; - else - WdsConnectionIPv6Handle = 0; - } - - if (oldConnectionStatus != *pConnectionStatus || debug_qmi) { - dbg_time("%s %sConnectionStatus: %s", __func__, (curIpFamily == IpFamilyV4) ? "IPv4" : "IPv6", - (*pConnectionStatus == QWDS_PKT_DATA_CONNECTED) ? "CONNECTED" : "DISCONNECTED"); - } - - free(pResponse); - return 0; -} - -static int requestSetupDataCall(PROFILE_T *profile, int curIpFamily) { - PQCQMIMSG pRequest; - PQCQMIMSG pResponse; - PQMUX_MSG pMUXMsg; - int err = 0; - UCHAR QMIType = (curIpFamily == IpFamilyV4) ? QMUX_TYPE_WDS : QMUX_TYPE_WDS_IPV6; - -//DualIPSupported means can get ipv4 & ipv6 address at the same time, one wds for ipv4, the other wds for ipv6 - profile->curIpFamily = curIpFamily; - pRequest = ComposeQMUXMsg(QMIType, QMIWDS_START_NETWORK_INTERFACE_REQ, WdsStartNwInterfaceReq, profile); - err = QmiThreadSendQMITimeout(pRequest, &pResponse, 120 * 1000, __func__); - qmi_rsp_check(); - - if (le16_to_cpu(pMUXMsg->QMUXMsgHdrResp.QMUXResult) || le16_to_cpu(pMUXMsg->QMUXMsgHdrResp.QMUXError)) { - PQMI_TLV_HDR pTLVHdr; - - pTLVHdr = GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x10); - if (pTLVHdr) { - uint16_t *data16 = (uint16_t *)(pTLVHdr+1); - uint16_t call_end_reason = le16_to_cpu(data16[0]); - dbg_time("call_end_reason is %d", call_end_reason); - } - - pTLVHdr = GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x11); - if (pTLVHdr) { - uint16_t *data16 = (uint16_t *)(pTLVHdr+1); - uint16_t call_end_reason_type = le16_to_cpu(data16[0]); - uint16_t verbose_call_end_reason = le16_to_cpu(data16[1]); - - dbg_time("call_end_reason_type is %d", call_end_reason_type); - dbg_time("call_end_reason_verbose is %d", verbose_call_end_reason); - } - - free(pResponse); - return le16_to_cpu(pMUXMsg->QMUXMsgHdrResp.QMUXError); - } - - if (curIpFamily == IpFamilyV4) { - WdsConnectionIPv4Handle = le32_to_cpu(pResponse->MUXMsg.StartNwInterfaceResp.Handle); - dbg_time("%s WdsConnectionIPv4Handle: 0x%08x", __func__, WdsConnectionIPv4Handle); - } else { - WdsConnectionIPv6Handle = le32_to_cpu(pResponse->MUXMsg.StartNwInterfaceResp.Handle); - dbg_time("%s WdsConnectionIPv6Handle: 0x%08x", __func__, WdsConnectionIPv6Handle); - } - - free(pResponse); - - return 0; -} - -static int requestDeactivateDefaultPDP(PROFILE_T *profile, int curIpFamily) { - PQCQMIMSG pRequest; - PQCQMIMSG pResponse; - PQMUX_MSG pMUXMsg; - int err; - UCHAR QMIType = (curIpFamily == 0x04) ? QMUX_TYPE_WDS : QMUX_TYPE_WDS_IPV6; - - (void)profile; - if (curIpFamily == IpFamilyV4 && WdsConnectionIPv4Handle == 0) - return 0; - if (curIpFamily == IpFamilyV6 && WdsConnectionIPv6Handle == 0) - return 0; - - dbg_time("%s WdsConnectionIPv%dHandle", __func__, curIpFamily == IpFamilyV4 ? 4 : 6); - - pRequest = ComposeQMUXMsg(QMIType, QMIWDS_STOP_NETWORK_INTERFACE_REQ , WdsStopNwInterfaceReq, &curIpFamily); - err = QmiThreadSendQMI(pRequest, &pResponse); - qmi_rsp_check_and_return(); - - if (curIpFamily == IpFamilyV4) - WdsConnectionIPv4Handle = 0; - else - WdsConnectionIPv6Handle = 0; - free(pResponse); - return 0; -} - -static int requestGetIPAddress(PROFILE_T *profile, int curIpFamily) { - PQCQMIMSG pRequest; - PQCQMIMSG pResponse; - PQMUX_MSG pMUXMsg; - int err; - PQMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV4_ADDR pIpv4Addr; - PQMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV6_ADDR pIpv6Addr = NULL; - PQMIWDS_GET_RUNTIME_SETTINGS_TLV_MTU pMtu; - IPV4_T *pIpv4 = &profile->ipv4; - IPV6_T *pIpv6 = &profile->ipv6; - UCHAR QMIType = (curIpFamily == 0x04) ? QMUX_TYPE_WDS : QMUX_TYPE_WDS_IPV6; - PQMIWDS_GET_RUNNING_SETTINGS_PCSCF_IPV6_ADDR pPCSCFIpv6Addr; - PQMIWDS_GET_RUNNING_SETTINGS_PCSCF_IPV4_ADDR pPCSCFIpv4Addr; - - if (curIpFamily == IpFamilyV4) { - memset(pIpv4, 0x00, sizeof(IPV4_T)); - if (WdsConnectionIPv4Handle == 0) - return 0; - } else if (curIpFamily == IpFamilyV6) { - memset(pIpv6, 0x00, sizeof(IPV6_T)); - if (WdsConnectionIPv6Handle == 0) - return 0; - } - - pRequest = ComposeQMUXMsg(QMIType, QMIWDS_GET_RUNTIME_SETTINGS_REQ, WdsGetRuntimeSettingReq, NULL); - err = QmiThreadSendQMI(pRequest, &pResponse); - qmi_rsp_check_and_return(); - - pPCSCFIpv6Addr = (PQMIWDS_GET_RUNNING_SETTINGS_PCSCF_IPV6_ADDR)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x2e); // 0x2e - pcscf ipv6 address - if (pPCSCFIpv6Addr) { - if (pPCSCFIpv6Addr->PCSCFNumber == 1) { - UCHAR *PCSCFIpv6Addr1 = (UCHAR *)(pPCSCFIpv6Addr + 1); - memcpy(profile->PCSCFIpv6Addr1, PCSCFIpv6Addr1, 16); - }else if (pPCSCFIpv6Addr->PCSCFNumber == 2) { - UCHAR *PCSCFIpv6Addr1 = (UCHAR *)(pPCSCFIpv6Addr + 1); - UCHAR *PCSCFIpv6Addr2 = PCSCFIpv6Addr1 + 16; - memcpy(profile->PCSCFIpv6Addr1, PCSCFIpv6Addr1, 16); - memcpy(profile->PCSCFIpv6Addr2, PCSCFIpv6Addr2, 16); - } - } - - pPCSCFIpv4Addr = (PQMIWDS_GET_RUNNING_SETTINGS_PCSCF_IPV4_ADDR)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x23); // 0x23 - pcscf ipv4 address - if (pPCSCFIpv4Addr) { - if (pPCSCFIpv4Addr->PCSCFNumber == 1) { - UCHAR *PCSCFIpv4Addr1 = (UCHAR *)(pPCSCFIpv4Addr + 1); - memcpy(&profile->PCSCFIpv4Addr1, PCSCFIpv4Addr1, 4); - }else if (pPCSCFIpv4Addr->PCSCFNumber == 2) { - UCHAR *PCSCFIpv4Addr1 = (UCHAR *)(pPCSCFIpv4Addr + 1); - UCHAR *PCSCFIpv4Addr2 = PCSCFIpv4Addr1 + 4; - memcpy(&profile->PCSCFIpv4Addr1, PCSCFIpv4Addr1, 4); - memcpy(&profile->PCSCFIpv4Addr2, PCSCFIpv4Addr2, 4); - } - } - - pIpv4Addr = (PQMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV4_ADDR)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV4PRIMARYDNS); - if (pIpv4Addr) { - pIpv4->DnsPrimary = pIpv4Addr->IPV4Address; - } - - pIpv4Addr = (PQMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV4_ADDR)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV4SECONDARYDNS); - if (pIpv4Addr) { - pIpv4->DnsSecondary = pIpv4Addr->IPV4Address; - } - - pIpv4Addr = (PQMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV4_ADDR)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV4GATEWAY); - if (pIpv4Addr) { - pIpv4->Gateway = pIpv4Addr->IPV4Address; - } - - pIpv4Addr = (PQMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV4_ADDR)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV4SUBNET); - if (pIpv4Addr) { - pIpv4->SubnetMask = pIpv4Addr->IPV4Address; - } - - pIpv4Addr = (PQMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV4_ADDR)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV4); - if (pIpv4Addr) { - pIpv4->Address = pIpv4Addr->IPV4Address; - } - - pIpv6Addr = (PQMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV6_ADDR)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV6PRIMARYDNS); - if (pIpv6Addr) { - memcpy(pIpv6->DnsPrimary, pIpv6Addr->IPV6Address, 16); - } - - pIpv6Addr = (PQMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV6_ADDR)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV6SECONDARYDNS); - if (pIpv6Addr) { - memcpy(pIpv6->DnsSecondary, pIpv6Addr->IPV6Address, 16); - } - - pIpv6Addr = (PQMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV6_ADDR)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV6GATEWAY); - if (pIpv6Addr) { - memcpy(pIpv6->Gateway, pIpv6Addr->IPV6Address, 16); - pIpv6->PrefixLengthGateway = pIpv6Addr->PrefixLength; - } - - pIpv6Addr = (PQMIWDS_GET_RUNTIME_SETTINGS_TLV_IPV6_ADDR)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_IPV6); - if (pIpv6Addr) { - memcpy(pIpv6->Address, pIpv6Addr->IPV6Address, 16); - pIpv6->PrefixLengthIPAddr = pIpv6Addr->PrefixLength; - } - - pMtu = (PQMIWDS_GET_RUNTIME_SETTINGS_TLV_MTU)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, QMIWDS_GET_RUNTIME_SETTINGS_TLV_TYPE_MTU); - if (pMtu) { - if (curIpFamily == IpFamilyV4) - pIpv4->Mtu = le32_to_cpu(pMtu->Mtu); - else - pIpv6->Mtu = le32_to_cpu(pMtu->Mtu); - } - - free(pResponse); - return 0; -} - -#ifdef CONFIG_APN -static int requestSetProfile(PROFILE_T *profile) { - PQCQMIMSG pRequest; - PQCQMIMSG pResponse; - PQMUX_MSG pMUXMsg; - int err; - const char *new_apn = profile->apn ? profile->apn : ""; - const char *new_user = profile->user ? profile->user : ""; - const char *new_password = profile->password ? profile->password : ""; - const char *ipStr[] = {"IPV4", "NULL", "IPV6", "IPV4V6"}; - - dbg_time("%s[%d] %s/%s/%s/%d/%s", __func__, profile->pdp, profile->apn, profile->user, profile->password, profile->auth,ipStr[profile->iptype]); - if (!profile->pdp) - return -1; - - if ( !strcmp(profile->old_apn, new_apn) && !strcmp(profile->old_user, new_user) - && !strcmp(profile->old_password, new_password) - && profile->old_iptype == profile->iptype - && profile->old_auth == profile->auth) - { - dbg_time("no need to set skip the rest"); - return 0; - } - - pRequest = ComposeQMUXMsg(QMUX_TYPE_WDS, QMIWDS_MODIFY_PROFILE_SETTINGS_REQ, WdsModifyProfileSettingsReq, profile); - err = QmiThreadSendQMI(pRequest, &pResponse); - qmi_rsp_check_and_return(); - - free(pResponse); - return 1; -} - -static int requestGetProfile(PROFILE_T *profile) { - PQCQMIMSG pRequest; - PQCQMIMSG pResponse; - PQMUX_MSG pMUXMsg; - int err; - PQMIWDS_APNNAME pApnName; - PQMIWDS_USERNAME pUserName; - PQMIWDS_PASSWD pPassWd; - PQMIWDS_AUTH_PREFERENCE pAuthPref; - PQMIWDS_IPTYPE pIpType; - const char *ipStr[] = {"IPV4", "NULL", "IPV6", "IPV4V6"}; - - profile->old_apn[0] = profile->old_user[0] = profile->old_password[0] = '\0'; - profile->old_auth = 0; - profile->old_iptype = 0; - if (profile->enable_ipv4 && profile->enable_ipv6) - profile->iptype = 3; - else if (profile->enable_ipv6) - profile->iptype = 2; - else - profile->iptype = 0; - - if (!profile->pdp) - return 0; - -_re_check: - pRequest = ComposeQMUXMsg(QMUX_TYPE_WDS, QMIWDS_GET_PROFILE_SETTINGS_REQ, WdsGetProfileSettingsReqSend, profile); - err = QmiThreadSendQMI(pRequest, &pResponse); - if (err == 0 && pResponse && le16_to_cpu(pResponse->MUXMsg.QMUXMsgHdrResp.QMUXResult) - && le16_to_cpu(pResponse->MUXMsg.QMUXMsgHdrResp.QMUXError) == QMI_ERR_EXTENDED_INTERNAL) - { - free(pResponse); - pRequest = ComposeQMUXMsg(QMUX_TYPE_WDS, QMIWDS_CREATE_PROFILE_REQ, WdsCreateProfileSettingsReqSend, profile); - err = QmiThreadSendQMI(pRequest, &pResponse); - qmi_rsp_check_and_return(); - free(pResponse); - goto _re_check; - } - qmi_rsp_check_and_return(); - - pApnName = (PQMIWDS_APNNAME)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x14); - pUserName = (PQMIWDS_USERNAME)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x1B); - pPassWd = (PQMIWDS_PASSWD)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x1C); - pAuthPref = (PQMIWDS_AUTH_PREFERENCE)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x1D); - pIpType = (PQMIWDS_IPTYPE)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x11); - - if (pApnName/* && le16_to_cpu(pApnName->TLVLength)*/) - uchar2char(profile->old_apn, sizeof(profile->old_apn), &pApnName->ApnName, le16_to_cpu(pApnName->TLVLength)); - if (pUserName/* && pUserName->UserName*/) - uchar2char(profile->old_user, sizeof(profile->old_user), &pUserName->UserName, le16_to_cpu(pUserName->TLVLength)); - if (pPassWd/* && le16_to_cpu(pPassWd->TLVLength)*/) - uchar2char(profile->old_password, sizeof(profile->old_password), &pPassWd->Passwd, le16_to_cpu(pPassWd->TLVLength)); - if (pAuthPref/* && le16_to_cpu(pAuthPref->TLVLength)*/) { - profile->old_auth = pAuthPref->AuthPreference; - } - if (pIpType) { - profile->old_iptype = pIpType->IPType; - } - - dbg_time("%s[%d] %s/%s/%s/%d/%s", __func__, profile->pdp, profile->old_apn, profile->old_user, profile->old_password, profile->old_auth, ipStr[profile->old_iptype]); - - free(pResponse); - return 0; -} -#endif - -#ifdef CONFIG_SIGNALINFO -static int requestGetSignalInfo(void) -{ - PQCQMIMSG pRequest; - PQCQMIMSG pResponse; - PQMUX_MSG pMUXMsg; - int err; - - pRequest = ComposeQMUXMsg(QMUX_TYPE_NAS, QMINAS_GET_SIG_INFO_REQ, NULL, NULL); - err = QmiThreadSendQMI(pRequest, &pResponse); - qmi_rsp_check_and_return(); - - - // CDMA - { - PQMINAS_SIG_INFO_CDMA_TLV_MSG ptlv = (PQMINAS_SIG_INFO_CDMA_TLV_MSG)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x10); - if (ptlv && ptlv->TLVLength) - { - dbg_time("%s CDMA: RSSI %d dBm, ECIO %.1lf dBm", __func__, - ptlv->rssi, (-0.5) * (double)ptlv->ecio); - } - } - - // HDR - { - PQMINAS_SIG_INFO_HDR_TLV_MSG ptlv = (PQMINAS_SIG_INFO_HDR_TLV_MSG)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x11); - if (ptlv && ptlv->TLVLength) - { - dbg_time("%s HDR: RSSI %d dBm, ECIO %.1lf dBm, IO %d dBm", __func__, - ptlv->rssi, (-0.5) * (double)ptlv->ecio, ptlv->io); - } - } - - // GSM - { - PQMINAS_SIG_INFO_GSM_TLV_MSG ptlv = (PQMINAS_SIG_INFO_GSM_TLV_MSG)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x12); - if (ptlv && ptlv->TLVLength) - { - dbg_time("%s GSM: RSSI %d dBm", __func__, ptlv->rssi); - } - } - - // WCDMA - { - PQMINAS_SIG_INFO_WCDMA_TLV_MSG ptlv = (PQMINAS_SIG_INFO_WCDMA_TLV_MSG)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x13); - if (ptlv && ptlv->TLVLength) - { - dbg_time("%s WCDMA: RSSI %d dBm, ECIO %.1lf dBm", __func__, - ptlv->rssi, (-0.5) * (double)ptlv->ecio); - } - } - - // LTE - { - PQMINAS_SIG_INFO_LTE_TLV_MSG ptlv = (PQMINAS_SIG_INFO_LTE_TLV_MSG)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x14); - if (ptlv && ptlv->TLVLength) - { - dbg_time("%s LTE: RSSI %d dBm, RSRQ %d dB, RSRP %d dBm, SNR %.1lf dB", __func__, - ptlv->rssi, ptlv->rsrq, ptlv->rsrp, (0.1) * (double)ptlv->snr); - } - } - - // TDSCDMA - { - PQMINAS_SIG_INFO_TDSCDMA_TLV_MSG ptlv = (PQMINAS_SIG_INFO_TDSCDMA_TLV_MSG)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x15); - if (ptlv && ptlv->TLVLength) - { - dbg_time("%s LTE: RSCP %d dBm", __func__, ptlv->rscp); - } - } - - // 5G_NSA - if (s_5g_type == WWAN_DATA_CLASS_5G_NSA) - { - PQMINAS_SIG_INFO_5G_NSA_TLV_MSG ptlv = (PQMINAS_SIG_INFO_5G_NSA_TLV_MSG)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x17); - if (ptlv && ptlv->TLVLength) - { - dbg_time("%s 5G_NSA: RSRP %d dBm, SNR %.1lf dB", __func__, ptlv->rsrp, (0.1) * (double)ptlv->snr); - } - } - - // 5G_SA - if (s_5g_type == WWAN_DATA_CLASS_5G_SA) - { - PQMINAS_SIG_INFO_5G_SA_TLV_MSG ptlv = (PQMINAS_SIG_INFO_5G_SA_TLV_MSG)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x18); - if (ptlv && ptlv->TLVLength) - { - dbg_time("%s 5G_SA: NR5G_RSRQ %d dB", __func__, ptlv->nr5g_rsrq); - } - } - - free(pResponse); - return 0; -} -#endif - -#ifdef CONFIG_VERSION -static int requestBaseBandVersion(PROFILE_T *profile) { - PQCQMIMSG pRequest; - PQCQMIMSG pResponse; - PQMUX_MSG pMUXMsg; - PDEVICE_REV_ID revId; - int err; - - pRequest = ComposeQMUXMsg(QMUX_TYPE_DMS, QMIDMS_GET_DEVICE_REV_ID_REQ, NULL, NULL); - err = QmiThreadSendQMI(pRequest, &pResponse); - qmi_rsp_check_and_return(); - - revId = (PDEVICE_REV_ID)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x01); - - if (revId && le16_to_cpu(revId->TLVLength)) - { - uchar2char(profile->BaseBandVersion, sizeof(profile->BaseBandVersion), &revId->RevisionID, le16_to_cpu(revId->TLVLength)); - dbg_time("%s %s", __func__, profile->BaseBandVersion); - } - - free(pResponse); - return 0; -} -#endif - -static USHORT DmsSetOperatingModeReq(PQMUX_MSG pMUXMsg, void *arg) { - pMUXMsg->SetOperatingModeReq.TLVType = 0x01; - pMUXMsg->SetOperatingModeReq.TLVLength = cpu_to_le16(1); - pMUXMsg->SetOperatingModeReq.OperatingMode = *((UCHAR *)arg); - - return sizeof(QMIDMS_SET_OPERATING_MODE_REQ_MSG); -} - -static USHORT UimSetCardSlotReq(PQMUX_MSG pMUXMsg, void *arg) { - pMUXMsg->UIMSetCardSlotReq.TLVType = 0x01; - pMUXMsg->UIMSetCardSlotReq.TLVLength = cpu_to_le16(1); - pMUXMsg->UIMSetCardSlotReq.slot = *((UCHAR *)arg); - - return sizeof(QMIUIM_SET_CARD_SLOT_REQ_MSG); -} - -static int requestRadioPower(int state) { - PQCQMIMSG pRequest; - PQCQMIMSG pResponse; - PQMUX_MSG pMUXMsg; - int err; - UCHAR OperatingMode = (!!state) ? DMS_OP_MODE_ONLINE : DMS_OP_MODE_LOW_POWER; - USHORT SimOp = (!!state) ? QMIUIM_POWER_UP : QMIUIM_POWER_DOWN; - UCHAR cardSlot = 0x01; - - dbg_time("%s(%d)", __func__, state); - - pRequest = ComposeQMUXMsg(QMUX_TYPE_DMS, QMIDMS_SET_OPERATING_MODE_REQ, DmsSetOperatingModeReq, &OperatingMode); - err = QmiThreadSendQMI(pRequest, &pResponse); - qmi_rsp_check_and_return(); - free(pResponse); - - pRequest = ComposeQMUXMsg(QMUX_TYPE_UIM, SimOp, UimSetCardSlotReq, &cardSlot); - err = QmiThreadSendQMI(pRequest, &pResponse); - qmi_rsp_check_and_return(); - free(pResponse); - - return 0; -} - -static USHORT WdaSetLoopBackReq(PQMUX_MSG pMUXMsg, void *arg) { - (void)arg; - pMUXMsg->SetLoopBackReq.loopback_state.TLVType = 0x01; - pMUXMsg->SetLoopBackReq.loopback_state.TLVLength = cpu_to_le16(1); - - pMUXMsg->SetLoopBackReq.replication_factor.TLVType = 0x10; - pMUXMsg->SetLoopBackReq.replication_factor.TLVLength = cpu_to_le16(4); - - return sizeof(QMI_WDA_SET_LOOPBACK_CONFIG_REQ_MSG); -} - -static int requestSetLoopBackState(UCHAR loopback_state, ULONG replication_factor) { - PQCQMIMSG pRequest; - PQCQMIMSG pResponse; - PQMUX_MSG pMUXMsg; - int err; - - dbg_time("%s(loopback_state=%d, replication_factor=%u)", __func__, loopback_state, replication_factor); - - pRequest = ComposeQMUXMsg(QMUX_TYPE_WDS_ADMIN, QMI_WDA_SET_LOOPBACK_CONFIG_REQ, WdaSetLoopBackReq, NULL); - pRequest->MUXMsg.SetLoopBackReq.loopback_state.TLVVaule = loopback_state; - pRequest->MUXMsg.SetLoopBackReq.replication_factor.TLVVaule = cpu_to_le16(replication_factor); - - err = QmiThreadSendQMI(pRequest, &pResponse); - qmi_rsp_check_and_return(); - - free(pResponse); - return 0; -} - -#ifdef CONFIG_ENABLE_QOS -static USHORT QosSetBindMuxDataPort(PQMUX_MSG pMUXMsg, void *arg) { - PROFILE_T *profile = (PROFILE_T *)arg; - pMUXMsg->QosBindDataPortReq.EpIdTlv.TLVType = 0x10; - pMUXMsg->QosBindDataPortReq.EpIdTlv.TLVLength = cpu_to_le16(8); - pMUXMsg->QosBindDataPortReq.EpIdTlv.ep_type = cpu_to_le32(profile->rmnet_info.ep_type); - pMUXMsg->QosBindDataPortReq.EpIdTlv.iface_id = cpu_to_le32(profile->rmnet_info.iface_id); - pMUXMsg->QosBindDataPortReq.MuxIdTlv.TLVType = 0x11; - pMUXMsg->QosBindDataPortReq.MuxIdTlv.TLVLength = cpu_to_le16(1); - pMUXMsg->QosBindDataPortReq.MuxIdTlv.mux_id = profile->muxid; - return sizeof(QMI_QOS_BIND_DATA_PORT_REQ_MSG); -} - -#ifdef CONFIG_REG_QOS_IND -static USHORT QosIndRegReq(PQMUX_MSG pMUXMsg, void *arg) { - pMUXMsg->QosIndRegReq.ReportGlobalQosFlowTlv.TLVType = 0x10; - pMUXMsg->QosIndRegReq.ReportGlobalQosFlowTlv.TLVLength = cpu_to_le16(1); - pMUXMsg->QosIndRegReq.ReportGlobalQosFlowTlv.report_global_qos_flows = 1; - return sizeof(QMI_QOS_INDICATION_REGISTER_REQ_MSG); -} -#endif - -static int requestRegisterQos(PROFILE_T *profile) { - PQCQMIMSG pRequest; - PQCQMIMSG pResponse = NULL; - PQMUX_MSG pMUXMsg; - int err; - - pRequest = ComposeQMUXMsg(QMUX_TYPE_QOS, QMI_QOS_BIND_DATA_PORT_REQ , QosSetBindMuxDataPort, (void *)profile); - err = QmiThreadSendQMI(pRequest, &pResponse); - dbg_time("%s QosSetBindMuxDataPort", __func__); - qmi_rsp_check_and_return(); - if (pResponse) free(pResponse); - -#ifdef CONFIG_REG_QOS_IND - pRequest = ComposeQMUXMsg(QMUX_TYPE_QOS, QMI_QOS_INDICATION_REGISTER_REQ , QosIndRegReq, NULL); - err = QmiThreadSendQMI(pRequest, &pResponse); - dbg_time("%s QosIndRegReq", __func__); - qmi_rsp_check_and_return(); - if (pResponse) free(pResponse); -#endif - return 0; -} - -#ifdef CONFIG_GET_QOS_INFO -UCHAR ql_get_qos_info_data_rate(PQCQMIMSG pResponse, void *max_data_rate) -{ - PQMI_QOS_GET_QOS_INFO_TLV_GRANTED_FLOW qos_tx_granted_flow = NULL; - PQMI_QOS_GET_QOS_INFO_TLV_GRANTED_FLOW qos_rx_granted_flow = NULL; - qos_tx_granted_flow = (PQMI_QOS_GET_QOS_INFO_TLV_GRANTED_FLOW)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x11); - if(qos_tx_granted_flow != NULL) - { - *(ULONG64 *)(max_data_rate) = le64_to_cpu(qos_tx_granted_flow->data_rate_max); - dbg_time("GET_QOS_INFO: tx_data_rate_max=%llu", *(ULONG64 *)(max_data_rate+0)); - } - else - dbg_time("GET_QOS_INFO: No qos_tx_granted_flow"); - qos_rx_granted_flow = (PQMI_QOS_GET_QOS_INFO_TLV_GRANTED_FLOW)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x12); - if(qos_rx_granted_flow != NULL) - { - *(ULONG64 *)(max_data_rate+sizeof(ULONG64)) = le64_to_cpu(qos_rx_granted_flow->data_rate_max); - dbg_time("GET_QOS_INFO: rx_data_rate_max=%llu", *(ULONG64 *)(max_data_rate+sizeof(ULONG64))); - } - else - dbg_time("GET_QOS_INFO: No qos_rx_granted_flow"); - if(qos_tx_granted_flow != NULL || qos_rx_granted_flow != NULL) - return 0; - else - return 1; -} - -static USHORT QosGetQosInfoReq(PQMUX_MSG pMUXMsg, void *arg) { - PROFILE_T *profile = (PROFILE_T *)arg; - pMUXMsg->QosGetQosInfoReq.QosIdTlv.TLVType = 0x01; - pMUXMsg->QosGetQosInfoReq.QosIdTlv.TLVLength = cpu_to_le16(4); - pMUXMsg->QosGetQosInfoReq.QosIdTlv.qos_id = cpu_to_le32(profile->qos_id); - return sizeof(QMI_QOS_GET_QOS_INFO_REQ_MSG); -} - -static int requestGetQosInfo(PROFILE_T *profile) { - PQCQMIMSG pRequest; - PQCQMIMSG pResponse = NULL; - PQMUX_MSG pMUXMsg; - int err; - - if(profile->qos_id == 0) - { - dbg_time("%s request not send: invalid qos_id", __func__); - return 0; - } - pRequest = ComposeQMUXMsg(QMUX_TYPE_QOS, QMI_QOS_GET_QOS_INFO_REQ , QosGetQosInfoReq, (void *)profile); - err = QmiThreadSendQMI(pRequest, &pResponse); - qmi_rsp_check_and_return(); - if (pResponse) - { -#ifdef CONFIG_GET_QOS_DATA_RATE - ULONG64 max_data_rate[2] = {0}; - if(ql_get_qos_info_data_rate(pResponse, (void *)max_data_rate) == 0){} -#endif - free(pResponse); - } - return 0; -} -#endif //#ifdef CONFIG_GET_QOS_INFO - -#ifdef CONFIG_REG_QOS_IND -UCHAR ql_get_global_qos_flow_ind_qos_id(PQCQMIMSG pResponse, UINT *qos_id) -{ - PQMI_QOS_GLOBAL_QOS_FLOW_TLV_FLOW_STATE qos_flow_state = NULL; - qos_flow_state = (PQMI_QOS_GLOBAL_QOS_FLOW_TLV_FLOW_STATE)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x01); - if(qos_flow_state != NULL) - { - if(le32_to_cpu(qos_flow_state->state_change) == QOS_IND_FLOW_STATE_ACTIVATED && qos_flow_state->new_flow == 1) - { - *qos_id = le32_to_cpu(qos_flow_state->qos_id); - dbg_time("QMI_QOS_GLOBAL_QOS_FLOW_IND: qos_id=%u state=QOS_IND_FLOW_STATE_ACTIVATED", *qos_id); - } - return (qos_flow_state->new_flow); - } - return (0); -} - -#ifdef CONFIG_GET_QOS_DATA_RATE -UCHAR ql_get_global_qos_flow_ind_data_rate(PQCQMIMSG pResponse, void *max_data_rate) -{ - PQMI_QOS_GLOBAL_QOS_FLOW_TLV_FLOW_GRANTED qos_tx_flow_granted = NULL; - PQMI_QOS_GLOBAL_QOS_FLOW_TLV_FLOW_GRANTED qos_rx_flow_granted = NULL; - qos_tx_flow_granted = (PQMI_QOS_GLOBAL_QOS_FLOW_TLV_FLOW_GRANTED)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x10); - if(qos_tx_flow_granted != NULL) - { - *(ULONG64 *)(max_data_rate) = le64_to_cpu(qos_tx_flow_granted->data_rate_max); - dbg_time("QMI_QOS_GLOBAL_QOS_FLOW_IND: tx_data_rate_max=%llu", *(ULONG64 *)(max_data_rate+0)); - } - else - dbg_time("QMI_QOS_GLOBAL_QOS_FLOW_IND: No qos_tx_flow_granted"); - qos_rx_flow_granted = (PQMI_QOS_GLOBAL_QOS_FLOW_TLV_FLOW_GRANTED)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x11); - if(qos_rx_flow_granted != NULL) - { - *(ULONG64 *)(max_data_rate+sizeof(ULONG64)) = le64_to_cpu(qos_rx_flow_granted->data_rate_max); - dbg_time("QMI_QOS_GLOBAL_QOS_FLOW_IND: rx_data_rate_max=%llu", *(ULONG64 *)(max_data_rate+sizeof(ULONG64))); - } - else - dbg_time("QMI_QOS_GLOBAL_QOS_FLOW_IND: No qos_rx_flow_granted"); - if(qos_tx_flow_granted != NULL || qos_rx_flow_granted != NULL) - return 0; - else - return 1; -} -#endif -#endif //#ifdef CONFIG_REG_QOS_IND -#endif //#ifdef CONFIG_ENABLE_QOS - -#ifdef CONFIG_CELLINFO -/* - at+qeng="servingcell" and at+qeng="neighbourcell" - https://gitlab.freedesktop.org/mobile-broadband/libqmi/-/blob/master/src/qmicli/qmicli-nas.c -*/ -static int nas_get_cell_location_info(void); -static int nas_get_rf_band_information(void); - -static int requestGetCellInfoList(void) { - dbg_time("%s", __func__); - nas_get_cell_location_info(); - nas_get_rf_band_information(); - return 0; -} -#endif - -const struct request_ops qmi_request_ops = { -#ifdef CONFIG_VERSION - .requestBaseBandVersion = requestBaseBandVersion, -#endif - .requestSetEthMode = requestSetEthMode, -#ifdef CONFIG_SIM - .requestGetSIMStatus = requestGetSIMStatus, - .requestEnterSimPin = requestEnterSimPin, -#endif -#ifdef CONFIG_IMSI_ICCID - .requestGetICCID = requestGetICCID, - .requestGetIMSI = requestGetIMSI, -#endif -#ifdef CONFIG_APN - .requestSetProfile = requestSetProfile, - .requestGetProfile = requestGetProfile, -#endif - .requestRegistrationState = requestRegistrationState, - .requestSetupDataCall = requestSetupDataCall, - .requestQueryDataCall = requestQueryDataCall, - .requestDeactivateDefaultPDP = requestDeactivateDefaultPDP, - .requestGetIPAddress = requestGetIPAddress, -#ifdef CONFIG_SIGNALINFO - .requestGetSignalInfo = requestGetSignalInfo, -#endif -#ifdef CONFIG_CELLINFO - .requestGetCellInfoList = requestGetCellInfoList, -#endif - .requestSetLoopBackState = requestSetLoopBackState, - .requestRadioPower = requestRadioPower, -#ifdef CONFIG_ENABLE_QOS - .requestRegisterQos = requestRegisterQos, -#endif -#ifdef CONFIG_GET_QOS_INFO - .requestGetQosInfo = requestGetQosInfo, -#endif -#ifdef CONFIG_COEX_WWAN_STATE - .requestGetCoexWWANState = requestGetCoexWWANState, -#endif -}; - -#ifdef CONFIG_CELLINFO -static char *str_from_bcd_plmn (uint8 plmn[3]) -{ - const char bcd_chars[] = "0123456789*#abc\0\0"; - static char str[12]; - int i; - int j = 0; - - for (i = 0; i < 3; i++) { - str[j] = bcd_chars[plmn[i]&0xF]; - if (str[j]) j++; - str[j] = bcd_chars[plmn[i]>>4]; - if (str[j]) j++; - } - - str[j++] = 0; - - return str; -} - -typedef struct { - UINT type; - const char *name; -} ENUM_NAME_T; - -#define enum_name(type) {type, #type} -#define N_ELEMENTS(arr) (sizeof (arr) / sizeof ((arr)[0])) - -static const ENUM_NAME_T QMI_NAS_ACTIVE_BAND_NAME[] = { - enum_name(QMI_NAS_ACTIVE_BAND_BC_0), - enum_name(QMI_NAS_ACTIVE_BAND_BC_1), - enum_name(QMI_NAS_ACTIVE_BAND_BC_2), - enum_name(QMI_NAS_ACTIVE_BAND_BC_3), - enum_name(QMI_NAS_ACTIVE_BAND_BC_4), - enum_name(QMI_NAS_ACTIVE_BAND_BC_5), - enum_name(QMI_NAS_ACTIVE_BAND_BC_6), - enum_name(QMI_NAS_ACTIVE_BAND_BC_7), - enum_name(QMI_NAS_ACTIVE_BAND_BC_8), - enum_name(QMI_NAS_ACTIVE_BAND_BC_9), - enum_name(QMI_NAS_ACTIVE_BAND_BC_10), - enum_name(QMI_NAS_ACTIVE_BAND_BC_11), - enum_name(QMI_NAS_ACTIVE_BAND_BC_12), - enum_name(QMI_NAS_ACTIVE_BAND_BC_13), - enum_name(QMI_NAS_ACTIVE_BAND_BC_14), - enum_name(QMI_NAS_ACTIVE_BAND_BC_15), - enum_name(QMI_NAS_ACTIVE_BAND_BC_16), - enum_name(QMI_NAS_ACTIVE_BAND_BC_17), - enum_name(QMI_NAS_ACTIVE_BAND_BC_18), - enum_name(QMI_NAS_ACTIVE_BAND_BC_19), - enum_name(QMI_NAS_ACTIVE_BAND_GSM_450), - enum_name(QMI_NAS_ACTIVE_BAND_GSM_480), - enum_name(QMI_NAS_ACTIVE_BAND_GSM_750), - enum_name(QMI_NAS_ACTIVE_BAND_GSM_850), - enum_name(QMI_NAS_ACTIVE_BAND_GSM_900_EXTENDED), - enum_name(QMI_NAS_ACTIVE_BAND_GSM_900_PRIMARY), - enum_name(QMI_NAS_ACTIVE_BAND_GSM_900_RAILWAYS), - enum_name(QMI_NAS_ACTIVE_BAND_GSM_DCS_1800), - enum_name(QMI_NAS_ACTIVE_BAND_GSM_PCS_1900), - enum_name(QMI_NAS_ACTIVE_BAND_WCDMA_2100), - enum_name(QMI_NAS_ACTIVE_BAND_WCDMA_PCS_1900), - enum_name(QMI_NAS_ACTIVE_BAND_WCDMA_DCS_1800), - enum_name(QMI_NAS_ACTIVE_BAND_WCDMA_1700_US), - enum_name(QMI_NAS_ACTIVE_BAND_WCDMA_850), - enum_name(QMI_NAS_ACTIVE_BAND_WCDMA_800), - enum_name(QMI_NAS_ACTIVE_BAND_WCDMA_2600), - enum_name(QMI_NAS_ACTIVE_BAND_WCDMA_900), - enum_name(QMI_NAS_ACTIVE_BAND_WCDMA_1700_JAPAN), - enum_name(QMI_NAS_ACTIVE_BAND_WCDMA_1500_JAPAN), - enum_name(QMI_NAS_ACTIVE_BAND_WCDMA_850_JAPAN), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_1), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_2), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_3), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_4), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_5), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_6), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_7), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_8), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_9), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_10), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_11), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_12), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_13), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_14), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_17), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_18), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_19), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_20), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_21), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_23), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_24), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_25), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_26), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_27), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_28), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_29), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_30), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_31), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_32), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_33), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_34), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_35), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_36), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_37), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_38), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_39), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_40), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_41), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_42), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_43), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_46), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_47), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_48), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_66), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_71), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_125), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_126), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_127), - enum_name(QMI_NAS_ACTIVE_BAND_EUTRAN_250), - enum_name(QMI_NAS_ACTIVE_BAND_TDSCDMA_A), - enum_name(QMI_NAS_ACTIVE_BAND_TDSCDMA_B), - enum_name(QMI_NAS_ACTIVE_BAND_TDSCDMA_C), - enum_name(QMI_NAS_ACTIVE_BAND_TDSCDMA_D), - enum_name(QMI_NAS_ACTIVE_BAND_TDSCDMA_E), - enum_name(QMI_NAS_ACTIVE_BAND_TDSCDMA_F), - enum_name(QMI_NAS_ACTIVE_BAND_NR5G_BAND_1 ), - enum_name(QMI_NAS_ACTIVE_BAND_NR5G_BAND_2 ), - enum_name(QMI_NAS_ACTIVE_BAND_NR5G_BAND_3 ), - enum_name(QMI_NAS_ACTIVE_BAND_NR5G_BAND_5 ), - enum_name(QMI_NAS_ACTIVE_BAND_NR5G_BAND_7 ), - enum_name(QMI_NAS_ACTIVE_BAND_NR5G_BAND_8 ), - enum_name(QMI_NAS_ACTIVE_BAND_NR5G_BAND_20), - enum_name(QMI_NAS_ACTIVE_BAND_NR5G_BAND_28), - enum_name(QMI_NAS_ACTIVE_BAND_NR5G_BAND_38), - enum_name(QMI_NAS_ACTIVE_BAND_NR5G_BAND_41), - enum_name(QMI_NAS_ACTIVE_BAND_NR5G_BAND_50), - enum_name(QMI_NAS_ACTIVE_BAND_NR5G_BAND_51), - enum_name(QMI_NAS_ACTIVE_BAND_NR5G_BAND_66), - enum_name(QMI_NAS_ACTIVE_BAND_NR5G_BAND_70), - enum_name(QMI_NAS_ACTIVE_BAND_NR5G_BAND_71), - enum_name(QMI_NAS_ACTIVE_BAND_NR5G_BAND_74), - enum_name(QMI_NAS_ACTIVE_BAND_NR5G_BAND_75), - enum_name(QMI_NAS_ACTIVE_BAND_NR5G_BAND_76), - enum_name(QMI_NAS_ACTIVE_BAND_NR5G_BAND_77), - enum_name(QMI_NAS_ACTIVE_BAND_NR5G_BAND_78), - enum_name(QMI_NAS_ACTIVE_BAND_NR5G_BAND_79), - enum_name(QMI_NAS_ACTIVE_BAND_NR5G_BAND_80), - enum_name(QMI_NAS_ACTIVE_BAND_NR5G_BAND_81), - enum_name(QMI_NAS_ACTIVE_BAND_NR5G_BAND_82), - enum_name(QMI_NAS_ACTIVE_BAND_NR5G_BAND_83), - enum_name(QMI_NAS_ACTIVE_BAND_NR5G_BAND_84), - enum_name(QMI_NAS_ACTIVE_BAND_NR5G_BAND_85), - enum_name(QMI_NAS_ACTIVE_BAND_NR5G_BAND_257), - enum_name(QMI_NAS_ACTIVE_BAND_NR5G_BAND_258), - enum_name(QMI_NAS_ACTIVE_BAND_NR5G_BAND_259), - enum_name(QMI_NAS_ACTIVE_BAND_NR5G_BAND_260), - enum_name(QMI_NAS_ACTIVE_BAND_NR5G_BAND_261), - enum_name(QMI_NAS_ACTIVE_BAND_NR5G_BAND_12), - enum_name(QMI_NAS_ACTIVE_BAND_NR5G_BAND_25), - enum_name(QMI_NAS_ACTIVE_BAND_NR5G_BAND_34), - enum_name(QMI_NAS_ACTIVE_BAND_NR5G_BAND_39), - enum_name(QMI_NAS_ACTIVE_BAND_NR5G_BAND_40), - enum_name(QMI_NAS_ACTIVE_BAND_NR5G_BAND_65), - enum_name(QMI_NAS_ACTIVE_BAND_NR5G_BAND_86), - enum_name(QMI_NAS_ACTIVE_BAND_NR5G_BAND_48), - enum_name(QMI_NAS_ACTIVE_BAND_NR5G_BAND_14), -}; - -static const char *qmi_nas_radio_interface_get_string(uint8 radio_if) -{ - const char *str = NULL; - - switch (radio_if) { - case QMI_NAS_RADIO_INTERFACE_CDMA_1X: str = "cdma-1x"; break; - case QMI_NAS_RADIO_INTERFACE_CDMA_1XEVDO: str = "cdma-1xevdo"; break; - case QMI_NAS_RADIO_INTERFACE_AMPS: str = "amps"; break; - case QMI_NAS_RADIO_INTERFACE_GSM: str = "gsm"; break; - case QMI_NAS_RADIO_INTERFACE_UMTS: str = "umts"; break; - case QMI_NAS_RADIO_INTERFACE_LTE: str = "lte"; break; - case QMI_NAS_RADIO_INTERFACE_TD_SCDMA: str = "td-scdma"; break; - case QMI_NAS_RADIO_INTERFACE_5GNR: str = "5gnr"; break; - default: str = NULL; break; - } - - return str ? str : "unknown"; -} - -static const char *qmi_nas_active_band_get_string(uint32 active_band) -{ - size_t i; - - for (i = 0; i < N_ELEMENTS(QMI_NAS_ACTIVE_BAND_NAME); i++) { - if (active_band == QMI_NAS_ACTIVE_BAND_NAME[i].type) - return QMI_NAS_ACTIVE_BAND_NAME[i].name + strlen("QMI_NAS_ACTIVE_BAND_"); - } - - return "unknown"; -} - -typedef struct { - uint16 min; - uint16 max; - const char *name; -} EarfcnRange; - -/* http://niviuk.free.fr/lte_band.php */ -static const EarfcnRange earfcn_ranges[] = { - { 0, 599, "E-UTRA band 1: 2100" }, - { 600, 1199, "E-UTRA band 2: 1900 PCS" }, - { 1200, 1949, "E-UTRA band 3: 1800+" }, - { 1950, 2399, "E-UTRA band 4: AWS-1" }, - { 2400, 2649, "E-UTRA band 5: 850" }, - { 2650, 2749, "E-UTRA band 6: UMTS only" }, - { 2750, 3449, "E-UTRA band 7: 2600" }, - { 3450, 3799, "E-UTRA band 8: 900" }, - { 3800, 4149, "E-UTRA band 9: 1800" }, - { 4150, 4749, "E-UTRA band 10: AWS-1+" }, - { 4750, 4999, "E-UTRA band 11: 1500 Lower" }, - { 5000, 5179, "E-UTRA band 12: 700 a" }, - { 5180, 5279, "E-UTRA band 13: 700 c" }, - { 5280, 5379, "E-UTRA band 14: 700 PS" }, - { 5730, 5849, "E-UTRA band 17: 700 b" }, - { 5850, 5999, "E-UTRA band 18: 800 Lower" }, - { 6000, 6149, "E-UTRA band 19: 800 Upper" }, - { 6150, 6449, "E-UTRA band 20: 800 DD" }, - { 6450, 6599, "E-UTRA band 21: 1500 Upper" }, - { 6600, 7399, "E-UTRA band 22: 3500" }, - { 7500, 7699, "E-UTRA band 23: 2000 S-band" }, - { 7700, 8039, "E-UTRA band 24: 1600 L-band" }, - { 8040, 8689, "E-UTRA band 25: 1900+" }, - { 8690, 9039, "E-UTRA band 26: 850+" }, - { 9040, 9209, "E-UTRA band 27: 800 SMR" }, - { 9210, 9659, "E-UTRA band 28: 700 APT" }, - { 9660, 9769, "E-UTRA band 29: 700 d" }, - { 9770, 9869, "E-UTRA band 30: 2300 WCS" }, - { 9870, 9919, "E-UTRA band 31: 450" }, - { 9920, 10359, "E-UTRA band 32: 1500 L-band" }, - { 36000, 36199, "E-UTRA band 33: TD 1900" }, - { 36200, 36349, "E-UTRA band 34: TD 2000" }, - { 36350, 36949, "E-UTRA band 35: TD PCS Lower" }, - { 36950, 37549, "E-UTRA band 36: TD PCS Upper" }, - { 37550, 37749, "E-UTRA band 37: TD PCS Center" }, - { 37750, 38249, "E-UTRA band 38: TD 2600" }, - { 38250, 38649, "E-UTRA band 39: TD 1900+" }, - { 38650, 39649, "E-UTRA band 40: TD 2300" }, - { 39650, 41589, "E-UTRA band 41: TD 2500" }, - { 41590, 43589, "E-UTRA band 42: TD 3500" }, - { 43590, 45589, "E-UTRA band 43: TD 3700" }, - { 45590, 46589, "E-UTRA band 44: TD 700" }, -}; - -static const char * earfcn_to_eutra_band_string (uint16 earfcn) -{ - size_t i; - - for (i = 0; i < N_ELEMENTS (earfcn_ranges); i++) { - if (earfcn <= earfcn_ranges[i].max && earfcn >= earfcn_ranges[i].min) - return earfcn_ranges[i].name; - } - - return "unknown"; -} - -static int nas_get_cell_location_info(void) -{ - PQCQMIMSG pRequest; - PQCQMIMSG pResponse; - PQMUX_MSG pMUXMsg; - PQMI_TLV pV; - int err; - int i, j; - - pRequest = ComposeQMUXMsg(QMUX_TYPE_NAS, QMINAS_GET_CELL_LOCATION_INFO_REQ, NULL, NULL); - err = QmiThreadSendQMI(pRequest, &pResponse); - qmi_rsp_check_and_return(); - - pV = (PQMI_TLV)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x2E); - if (pV && pV->TLVLength) { - printf ("5GNR ARFCN: '%u'\n", pV->u32); - } - - { - NasGetCellLocationNr5gServingCell *ptlv = (NasGetCellLocationNr5gServingCell *)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x2F); - if (ptlv && ptlv->TLVLength) - { - printf ("5GNR cell information:\n" - "\tPLMN: '%s'\n" - "\tTracking Area Code: '%u'\n" - "\tGlobal Cell ID: '%" PRIu64 "'\n" - "\tPhysical Cell ID: '%u'\n" - "\tRSRQ: '%.1lf dB'\n" - "\tRSRP: '%.1lf dBm'\n" - "\tSNR: '%.1lf dB'\n", - str_from_bcd_plmn(ptlv->plmn), - ptlv->tac[0]<<16 | ptlv->tac[1]<<8 | ptlv->tac[2] , - ptlv->global_cell_id, - ptlv->physical_cell_id, - (0.1) * ((double)ptlv->rsrq), - (0.1) * ((double)ptlv->rsrp), - (0.1) * ((double)ptlv->snr)); - } - } - - { - NasGetCellLocationLteInfoIntrafrequency *ptlv = (NasGetCellLocationLteInfoIntrafrequency *)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x13); - if (ptlv && ptlv->TLVLength) - { - printf ("Intrafrequency LTE Info:\n" - "\tUE In Idle: '%s'\n" - "\tPLMN: '%s'\n" - "\tTracking Area Code: '%u'\n" - "\tGlobal Cell ID: '%u'\n" - "\tEUTRA Absolute RF Channel Number: '%u' (%s)\n" - "\tServing Cell ID: '%u'\n", - ptlv->ue_in_idle ? "yes" : "no", - str_from_bcd_plmn(ptlv->plmn), - ptlv->tracking_area_code, - ptlv->global_cell_id, - ptlv->absolute_rf_channel_number, earfcn_to_eutra_band_string(ptlv->absolute_rf_channel_number), - ptlv->serving_cell_id); - - if (ptlv->ue_in_idle) - printf ("\tCell Reselection Priority: '%u'\n" - "\tS Non Intra Search Threshold: '%u'\n" - "\tServing Cell Low Threshold: '%u'\n" - "\tS Intra Search Threshold: '%u'\n", - ptlv->cell_reselection_priority, - ptlv->s_non_intra_search_threshold, - ptlv->serving_cell_low_threshold, - ptlv->s_intra_search_threshold); - - - for (i = 0; i < ptlv->cells_len; i++) { - NasGetCellLocationLteInfoCell *cell = &ptlv->cells_array[i]; - - printf ("\tCell [%u]:\n" - "\t\tPhysical Cell ID: '%u'\n" - "\t\tRSRQ: '%.1lf' dB\n" - "\t\tRSRP: '%.1lf' dBm\n" - "\t\tRSSI: '%.1lf' dBm\n", - i, - cell->physical_cell_id, - (double) cell->rsrq * 0.1, - (double) cell->rsrp * 0.1, - (double) cell->rssi * 0.1); - - if (ptlv->ue_in_idle) - printf ("\t\tCell Selection RX Level: '%d'\n", - cell->cell_selection_rx_level); - } - } - } - - { - NasGetCellLocationLteInfoInterfrequency *ptlv = (NasGetCellLocationLteInfoInterfrequency *)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x14); - if (ptlv && ptlv->TLVLength) - { - int off = offsetof(NasGetCellLocationLteInfoInterfrequency, freqs[0]); - printf ("Interfrequency LTE Info:\n" - "\tUE In Idle: '%s'\n", ptlv->ue_in_idle ? "yes" : "no"); - - for (i = 0; i < ptlv->freqs_len; i++) { - NasGetCellLocationLteInfoInterfrequencyFrequencyElement *freq = (((void *)ptlv) + off); - - off += sizeof(*freq); - printf ("\tFrequency [%u]:\n" - "\t\tEUTRA Absolute RF Channel Number: '%u' (%s)\n" - "\t\tSelection RX Level Low Threshold: '%u'\n" - "\t\tCell Selection RX Level High Threshold: '%u'\n", - i, - freq->eutra_absolute_rf_channel_number, earfcn_to_eutra_band_string(freq->eutra_absolute_rf_channel_number), - freq->cell_selection_rx_level_low_threshold, - freq->cell_selection_rx_level_high_threshold); - if (ptlv->ue_in_idle) - printf ("\t\tCell Reselection Priority: '%u'\n", - freq->cell_reselection_priority); - - - for (j = 0; j < freq->cells_len; j++) { - NasGetCellLocationLteInfoCell *cell = &freq->cells_array[j]; - - off += sizeof(*cell); - printf ("\t\tCell [%u]:\n" - "\t\t\tPhysical Cell ID: '%u'\n" - "\t\t\tRSRQ: '%.1lf' dB\n" - "\t\t\tRSRP: '%.1lf' dBm\n" - "\t\t\tRSSI: '%.1lf' dBm\n" - "\t\t\tCell Selection RX Level: '%u'\n", - j, - cell->physical_cell_id, - (double) cell->rsrq * 0.1, - (double) cell->rsrp * 0.1, - (double) cell->rssi * 0.1, - cell->cell_selection_rx_level); - } - } - } - } - - pV = (PQMI_TLV)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x1E); - if (pV && pV->TLVLength) { - if (pV->u32 == 0xFFFFFFFF) - printf ("LTE Timing Advance: 'unavailable'\n"); - else - printf ("LTE Timing Advance: '%u'\n", pV->u32); - } - - free(pResponse); - return 0; -} - -static int nas_get_rf_band_information(void) -{ - PQCQMIMSG pRequest; - PQCQMIMSG pResponse; - PQMUX_MSG pMUXMsg; - int err; - int i; - - pRequest = ComposeQMUXMsg(QMUX_TYPE_NAS, QMINAS_GET_RF_BAND_INFO_REQ, NULL, NULL); - err = QmiThreadSendQMI(pRequest, &pResponse); - qmi_rsp_check_and_return(); - - { - NasGetRfBandInfoList *ptlv = (NasGetRfBandInfoList *)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x01); - if (ptlv && ptlv->TLVLength) - { - printf ("Band Information:\n"); - for (i = 0; i < ptlv->num_instances; i++) { - NasGetRfBandInfo *band = &ptlv->bands_array[i]; - - printf ("\tRadio Interface: '%s'\n" - "\tActive Band Class: '%s'\n" - "\tActive Channel: '%u'\n", - qmi_nas_radio_interface_get_string (band->radio_if), - qmi_nas_active_band_get_string (band->active_band), - band->active_channel); - } - } - } - - { - NasGetRfBandInfoExtendedList *ptlv = (NasGetRfBandInfoExtendedList *)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x11); - if (ptlv && ptlv->TLVLength) - { - printf ("Band Information (Extended):\n"); - for (i = 0; i < ptlv->num_instances; i++) { - NasGetRfBandInfoExtended *band = &ptlv->bands_array[i]; - - printf ("\tRadio Interface: '%s'\n" - "\tActive Band Class: '%s'\n" - "\tActive Channel: '%u'\n", - qmi_nas_radio_interface_get_string (band->radio_if), - qmi_nas_active_band_get_string (band->active_band), - band->active_channel); - } - } - } - - { - NasGetRfBandInfoBandWidthList *ptlv = (NasGetRfBandInfoBandWidthList *)GetTLV(&pResponse->MUXMsg.QMUXMsgHdr, 0x12); - if (ptlv && ptlv->TLVLength) - { - printf ("Bandwidth:\n"); - for (i = 0; i < ptlv->num_instances; i++) { - NasGetRfBandInfoBandWidth *band = &ptlv->bands_array[i]; - - printf ("\tRadio Interface: '%s'\n" - "\tBandwidth: '%u'\n", - qmi_nas_radio_interface_get_string (band->radio_if), - (band->bandwidth)); - } - } - } - - free(pResponse); - return 0; -} -#endif diff --git a/quectel_cm_5G/src/QMIThread.h b/quectel_cm_5G/src/QMIThread.h deleted file mode 100644 index b5dfe1a..0000000 --- a/quectel_cm_5G/src/QMIThread.h +++ /dev/null @@ -1,420 +0,0 @@ -#ifndef __QMI_THREAD_H__ -#define __QMI_THREAD_H__ - -#define CONFIG_GOBINET -#define CONFIG_QMIWWAN -#define CONFIG_SIM -#define CONFIG_APN -#define CONFIG_VERSION -//#define CONFIG_SIGNALINFO -//#define CONFIG_CELLINFO -//#define CONFIG_COEX_WWAN_STATE -#define CONFIG_DEFAULT_PDP 1 -//#define CONFIG_IMSI_ICCID -#define QUECTEL_UL_DATA_AGG -//#define QUECTEL_QMI_MERGE -//#define REBOOT_SIM_CARD_WHEN_APN_CHANGE -//#define REBOOT_SIM_CARD_WHEN_LONG_TIME_NO_PS 60 //unit is seconds -//#define CONFIG_QRTR -//#define CONFIG_ENABLE_QOS -//#define CONFIG_REG_QOS_IND -//#define CONFIG_GET_QOS_INFO -//#define CONFIG_GET_QOS_DATA_RATE - -#if (defined(CONFIG_REG_QOS_IND) || defined(CONFIG_GET_QOS_INFO) || defined(CONFIG_GET_QOS_DATA_RATE)) -#ifndef CONFIG_REG_QOS_IND -#define CONFIG_REG_QOS_IND -#endif -#ifndef CONFIG_ENABLE_QOS -#define CONFIG_ENABLE_QOS -#endif -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "qendian.h" -#include "MPQMI.h" -#include "MPQCTL.h" -#include "MPQMUX.h" -#include "util.h" - -#define DEVICE_CLASS_UNKNOWN 0 -#define DEVICE_CLASS_CDMA 1 -#define DEVICE_CLASS_GSM 2 - -#define WWAN_DATA_CLASS_NONE 0x00000000 -#define WWAN_DATA_CLASS_GPRS 0x00000001 -#define WWAN_DATA_CLASS_EDGE 0x00000002 /* EGPRS */ -#define WWAN_DATA_CLASS_UMTS 0x00000004 -#define WWAN_DATA_CLASS_HSDPA 0x00000008 -#define WWAN_DATA_CLASS_HSUPA 0x00000010 -#define WWAN_DATA_CLASS_LTE 0x00000020 -#define WWAN_DATA_CLASS_5G_NSA 0x00000040 -#define WWAN_DATA_CLASS_5G_SA 0x00000080 -#define WWAN_DATA_CLASS_1XRTT 0x00010000 -#define WWAN_DATA_CLASS_1XEVDO 0x00020000 -#define WWAN_DATA_CLASS_1XEVDO_REVA 0x00040000 -#define WWAN_DATA_CLASS_1XEVDV 0x00080000 -#define WWAN_DATA_CLASS_3XRTT 0x00100000 -#define WWAN_DATA_CLASS_1XEVDO_REVB 0x00200000 /* for future use */ -#define WWAN_DATA_CLASS_UMB 0x00400000 -#define WWAN_DATA_CLASS_CUSTOM 0x80000000 - -struct wwan_data_class_str { - ULONG class; - const char *str; -}; - -#pragma pack(push, 1) -typedef struct __IPV4 { - uint32_t Address; - uint32_t Gateway; - uint32_t SubnetMask; - uint32_t DnsPrimary; - uint32_t DnsSecondary; - uint32_t Mtu; -} IPV4_T; - -typedef struct __IPV6 { - UCHAR Address[16]; - UCHAR Gateway[16]; - UCHAR SubnetMask[16]; - UCHAR DnsPrimary[16]; - UCHAR DnsSecondary[16]; - UCHAR PrefixLengthIPAddr; - UCHAR PrefixLengthGateway; - ULONG Mtu; -} IPV6_T; - -typedef struct { - UINT size; - UINT rx_urb_size; - UINT ep_type; - UINT iface_id; - UINT MuxId; - UINT ul_data_aggregation_max_datagrams; //0x17 - UINT ul_data_aggregation_max_size ;//0x18 - UINT dl_minimum_padding; //0x1A -} QMAP_SETTING; - -//Configured downlink data aggregationprotocol -#define WDA_DL_DATA_AGG_DISABLED (0x00) //DL data aggregation is disabled (default) -#define WDA_DL_DATA_AGG_TLP_ENABLED (0x01) // DL TLP is enabled -#define WDA_DL_DATA_AGG_QC_NCM_ENABLED (0x02) // DL QC_NCM isenabled -#define WDA_DL_DATA_AGG_MBIM_ENABLED (0x03) // DL MBIM isenabled -#define WDA_DL_DATA_AGG_RNDIS_ENABLED (0x04) // DL RNDIS is enabled -#define WDA_DL_DATA_AGG_QMAP_ENABLED (0x05) // DL QMAP isenabled -#define WDA_DL_DATA_AGG_QMAP_V2_ENABLED (0x06) // DL QMAP V2 is enabled -#define WDA_DL_DATA_AGG_QMAP_V3_ENABLED (0x07) // DL QMAP V3 is enabled -#define WDA_DL_DATA_AGG_QMAP_V4_ENABLED (0x08) // DL QMAP V4 is enabled -#define WDA_DL_DATA_AGG_QMAP_V5_ENABLED (0x09) // DL QMAP V5 is enabled - -typedef struct { - unsigned int size; - unsigned int rx_urb_size; - unsigned int ep_type; - unsigned int iface_id; - unsigned int qmap_mode; - unsigned int qmap_version; - unsigned int dl_minimum_padding; - char ifname[8][16]; - unsigned char mux_id[8]; -} RMNET_INFO; - -#define IpFamilyV4 (0x04) -#define IpFamilyV6 (0x06) - -struct __PROFILE; -struct qmi_device_ops { - int (*init)(struct __PROFILE *profile); - int (*deinit)(void); - int (*send)(PQCQMIMSG pRequest); - void* (*read)(void *pData); -}; -#ifdef CONFIG_QRTR -extern const struct qmi_device_ops qrtr_qmidev_ops; -#endif -extern const struct qmi_device_ops gobi_qmidev_ops; -extern const struct qmi_device_ops qmiwwan_qmidev_ops; -extern const struct qmi_device_ops mbim_dev_ops; -extern const struct qmi_device_ops atc_dev_ops; -extern int (*qmidev_send)(PQCQMIMSG pRequest); - -struct usb_device_info { - int idVendor; - int idProduct; - int busnum; - int devnum; - int bNumInterfaces; -}; - -struct usb_interface_info { - int bNumEndpoints; - int bInterfaceClass; - int bInterfaceSubClass; - int bInterfaceProtocol; - char driver[32]; -}; - -#define LIBQMI_PROXY "qmi-proxy" //src/libqmi-glib/qmi-proxy.h -#define LIBMBIM_PROXY "mbim-proxy" -#define QUECTEL_QMI_PROXY "quectel-qmi-proxy" -#define QUECTEL_MBIM_PROXY "quectel-mbim-proxy" -#define QUECTEL_ATC_PROXY "quectel-atc-proxy" -#define QUECTEL_QRTR_PROXY "quectel-qrtr-proxy" - -#ifndef bool -#define bool uint8_t -#endif -struct request_ops; -typedef struct __PROFILE { - //user input start - const char *apn; - const char *user; - const char *password; - int auth; - int iptype; - const char *pincode; - char proxy[32]; - int pdp; - int enable_bridge; - bool enable_ipv4; - bool enable_ipv6; - const char *logfile; - const char *usblogfile; - char expect_adapter[32]; - int kill_pdp; - int replication_factor; - //user input end - - char qmichannel[32]; - char usbnet_adapter[32]; - char qmapnet_adapter[32]; - char driver_name[32]; - int qmap_mode; - int qmap_size; - int qmap_version; - int curIpFamily; - int rawIP; - int muxid; -#ifdef CONFIG_ENABLE_QOS - UINT qos_id; -#endif - int wda_client; - IPV4_T ipv4; - IPV6_T ipv6; - UINT PCSCFIpv4Addr1; - UINT PCSCFIpv4Addr2; - UCHAR PCSCFIpv6Addr1[16]; - UCHAR PCSCFIpv6Addr2[16]; - bool reattach_flag; - int hardware_interface; - int software_interface; - - struct usb_device_info usb_dev; - struct usb_interface_info usb_intf; - - int usbmon_fd; - FILE *usbmon_logfile_fp; - bool loopback_state; - - char BaseBandVersion[64]; - char old_apn[64]; - char old_user[64]; - char old_password[64]; - int old_auth; - int old_iptype; - - const struct qmi_device_ops *qmi_ops; - const struct request_ops *request_ops; - RMNET_INFO rmnet_info; -} PROFILE_T; - -#ifdef QUECTEL_QMI_MERGE -#define MERGE_PACKET_IDENTITY 0x2c7c -#define MERGE_PACKET_VERSION 0x0001 -#define MERGE_PACKET_MAX_PAYLOAD_SIZE 56 -typedef struct __QMI_MSG_HEADER { - uint16_t idenity; - uint16_t version; - uint16_t cur_len; - uint16_t total_len; -} QMI_MSG_HEADER; - -typedef struct __QMI_MSG_PACKET { - QMI_MSG_HEADER header; - uint16_t len; - char buf[4096]; -} QMI_MSG_PACKET; -#endif - -typedef enum { - SIM_ABSENT = 0, - SIM_NOT_READY = 1, - SIM_READY = 2, /* SIM_READY means the radio state is RADIO_STATE_SIM_READY */ - SIM_PIN = 3, - SIM_PUK = 4, - SIM_NETWORK_PERSONALIZATION = 5, - SIM_BAD = 6, -} SIM_Status; - -#pragma pack(pop) - -#define WDM_DEFAULT_BUFSIZE 256 -#define RIL_REQUEST_QUIT 0x1000 -#define RIL_INDICATE_DEVICE_CONNECTED 0x1002 -#define RIL_INDICATE_DEVICE_DISCONNECTED 0x1003 -#define RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED 0x1004 -#define RIL_UNSOL_DATA_CALL_LIST_CHANGED 0x1005 -#define MODEM_REPORT_RESET_EVENT 0x1006 -#define RIL_UNSOL_LOOPBACK_CONFIG_IND 0x1007 -#ifdef CONFIG_REG_QOS_IND -#define RIL_UNSOL_GLOBAL_QOS_FLOW_IND_QOS_ID 0x1008 -#endif - -extern pthread_mutex_t cm_command_mutex; -extern pthread_cond_t cm_command_cond; -extern unsigned int cm_recv_buf[1024]; -extern int cm_open_dev(const char *dev); -extern int cm_open_proxy(const char *name); -extern int pthread_cond_timeout_np(pthread_cond_t *cond, pthread_mutex_t * mutex, unsigned msecs); -extern int QmiThreadSendQMITimeout(PQCQMIMSG pRequest, PQCQMIMSG *ppResponse, unsigned msecs, const char *funcname); -#define QmiThreadSendQMI(pRequest, ppResponse) QmiThreadSendQMITimeout(pRequest, ppResponse, 30 * 1000, __func__) -extern void QmiThreadRecvQMI(PQCQMIMSG pResponse); -extern void udhcpc_start(PROFILE_T *profile); -extern void udhcpc_stop(PROFILE_T *profile); -extern void ql_set_driver_link_state(PROFILE_T *profile, int link_state); -extern void ql_set_driver_qmap_setting(PROFILE_T *profile, QMAP_SETTING *qmap_settings); -extern void ql_get_driver_rmnet_info(PROFILE_T *profile, RMNET_INFO *rmnet_info); -extern void dump_qmi(void *dataBuffer, int dataLen); -extern void qmidevice_send_event_to_main(int triger_event); -extern void qmidevice_send_event_to_main_ext(int triger_event, void *data, unsigned len); -extern uint8_t qmi_over_mbim_get_client_id(uint8_t QMIType); -extern uint8_t qmi_over_mbim_release_client_id(uint8_t QMIType, uint8_t ClientId); -#ifdef CONFIG_REG_QOS_IND -extern UCHAR ql_get_global_qos_flow_ind_qos_id(PQCQMIMSG pResponse, UINT *qos_id); -#endif -#ifdef CONFIG_GET_QOS_DATA_RATE -extern UCHAR ql_get_global_qos_flow_ind_data_rate(PQCQMIMSG pResponse, void *max_data_rate); -#endif - -struct request_ops { - int (*requestBaseBandVersion)(PROFILE_T *profile); - int (*requestSetEthMode)(PROFILE_T *profile); - int (*requestSetLoopBackState)(UCHAR loopback_state, ULONG replication_factor); - int (*requestGetSIMStatus)(SIM_Status *pSIMStatus); - int (*requestEnterSimPin)(const char *pPinCode); - int (*requestSetProfile)(PROFILE_T *profile); // 1 ~ success and apn change, 0 ~ success and no apn change, -1 ~ fail - int (*requestGetProfile)(PROFILE_T *profile); - int (*requestRegistrationState)(UCHAR *pPSAttachedState); - int (*requestSetupDataCall)(PROFILE_T *profile, int curIpFamily); - int (*requestQueryDataCall)(UCHAR *pConnectionStatus, int curIpFamily); - int (*requestDeactivateDefaultPDP)(PROFILE_T *profile, int curIpFamily); - int (*requestGetIPAddress)(PROFILE_T *profile, int curIpFamily); - int (*requestGetSignalInfo)(void); - int (*requestGetCellInfoList)(void); - int (*requestGetICCID)(void); - int (*requestGetIMSI)(void); - int (*requestRadioPower)(int state); - int (*requestRegisterQos)(PROFILE_T *profile); - int (*requestGetQosInfo)(PROFILE_T *profile); - int (*requestGetCoexWWANState)(void); -}; -extern const struct request_ops qmi_request_ops; -extern const struct request_ops mbim_request_ops; -extern const struct request_ops atc_request_ops; - -extern int get_driver_type(PROFILE_T *profile); -extern BOOL qmidevice_detect(char *qmichannel, char *usbnet_adapter, unsigned bufsize, PROFILE_T *profile); -int mhidevice_detect(char *qmichannel, char *usbnet_adapter, PROFILE_T *profile); -int atdevice_detect(char *atchannel, char *usbnet_adapter, PROFILE_T *profile); -extern int ql_bridge_mode_detect(PROFILE_T *profile); -extern int ql_enable_qmi_wwan_rawip_mode(PROFILE_T *profile); -extern int ql_qmap_mode_detect(PROFILE_T *profile); -#ifdef CONFIG_QRTR -extern int rtrmnet_ctl_create_vnd(char *devname, char *vndname, uint8_t muxid, - uint32_t qmap_version, uint32_t ul_agg_cnt, uint32_t ul_agg_size); -#endif - -#define qmidev_is_gobinet(_qmichannel) (strncmp(_qmichannel, "/dev/qcqmi", strlen("/dev/qcqmi")) == 0) -#define qmidev_is_qmiwwan(_qmichannel) (strncmp(_qmichannel, "/dev/cdc-wdm", strlen("/dev/cdc-wdm")) == 0) -#define qmidev_is_pciemhi(_qmichannel) (strncmp(_qmichannel, "/dev/mhi_", strlen("/dev/mhi_")) == 0) - -#define driver_is_qmi(_drv_name) (strncasecmp(_drv_name, "qmi_wwan", strlen("qmi_wwan")) == 0) -#define driver_is_mbim(_drv_name) (strncasecmp(_drv_name, "cdc_mbim", strlen("cdc_mbim")) == 0) - -extern FILE *logfilefp; -extern int debug_qmi; -extern int qmidevice_control_fd[2]; -extern int g_donot_exit_when_modem_hangup; -extern void update_resolv_conf(int iptype, const char *ifname, const char *dns1, const char *dns2); -void update_ipv4_address(const char *ifname, const char *ip, const char *gw, unsigned prefix); -void update_ipv6_address(const char *ifname, const char *ip, const char *gw, unsigned prefix); -int reattach_driver(PROFILE_T *profile); -extern void no_trunc_strncpy(char *dest, const char *src, size_t dest_size); - -enum -{ - DRV_INVALID, - SOFTWARE_QMI, - SOFTWARE_MBIM, - SOFTWARE_ECM_RNDIS_NCM, - SOFTWARE_QRTR, - HARDWARE_PCIE, - HARDWARE_USB, -}; - -enum -{ - SIG_EVENT_START, - SIG_EVENT_CHECK, - SIG_EVENT_STOP, -}; - -typedef enum -{ - DMS_OP_MODE_ONLINE, - DMS_OP_MODE_LOW_POWER, - DMS_OP_MODE_FACTORY_TEST_MODE, - DMS_OP_MODE_OFFLINE, - DMS_OP_MODE_RESETTING, - DMS_OP_MODE_SHUTTING_DOWN, - DMS_OP_MODE_PERSISTENT_LOW_POWER, - DMS_OP_MODE_MODE_ONLY_LOW_POWER, - DMS_OP_MODE_NET_TEST_GW, -}Device_operating_mode; - -#ifdef CM_DEBUG -#define dbg_time(fmt, args...) do { \ - fprintf(stdout, "[%15s-%04d: %s] " fmt "\n", __FILE__, __LINE__, get_time(), ##args); \ - fflush(stdout);\ - if (logfilefp) fprintf(logfilefp, "[%s-%04d: %s] " fmt "\n", __FILE__, __LINE__, get_time(), ##args); \ -} while(0) -#else -#define dbg_time(fmt, args...) do { \ - fprintf(stdout, "[%s] " fmt "\n", get_time(), ##args); \ - fflush(stdout);\ - if (logfilefp) fprintf(logfilefp, "[%s] " fmt "\n", get_time(), ##args); \ -} while(0) -#endif -#endif diff --git a/quectel_cm_5G/src/QmiWwanCM.c b/quectel_cm_5G/src/QmiWwanCM.c deleted file mode 100644 index ede5a07..0000000 --- a/quectel_cm_5G/src/QmiWwanCM.c +++ /dev/null @@ -1,459 +0,0 @@ -/****************************************************************************** - @file QmiWwanCM.c - @brief QMI WWAN connectivity manager. - - DESCRIPTION - Connectivity Management Tool for USB network adapter of Quectel wireless cellular modules. - - INITIALIZATION AND SEQUENCING REQUIREMENTS - None. - - --------------------------------------------------------------------------- - Copyright (c) 2016 - 2020 Quectel Wireless Solution, Co., Ltd. All Rights Reserved. - Quectel Wireless Solution Proprietary and Confidential. - --------------------------------------------------------------------------- -******************************************************************************/ - -#include -#include -#include -#include -#include -#include "QMIThread.h" - -#ifdef CONFIG_QMIWWAN -static int cdc_wdm_fd = -1; -static UCHAR qmiclientId[QMUX_TYPE_ALL]; - -static UCHAR GetQCTLTransactionId(void) { - static int TransactionId = 0; - if (++TransactionId > 0xFF) - TransactionId = 1; - return TransactionId; -} - -typedef USHORT (*CUSTOMQCTL)(PQMICTL_MSG pCTLMsg, void *arg); - -static PQCQMIMSG ComposeQCTLMsg(USHORT QMICTLType, CUSTOMQCTL customQctlMsgFunction, void *arg) { - UCHAR QMIBuf[WDM_DEFAULT_BUFSIZE]; - PQCQMIMSG pRequest = (PQCQMIMSG)QMIBuf; - int Length; - - pRequest->QMIHdr.IFType = USB_CTL_MSG_TYPE_QMI; - pRequest->QMIHdr.CtlFlags = 0x00; - pRequest->QMIHdr.QMIType = QMUX_TYPE_CTL; - pRequest->QMIHdr.ClientId= 0x00; - - pRequest->CTLMsg.QMICTLMsgHdr.CtlFlags = QMICTL_FLAG_REQUEST; - pRequest->CTLMsg.QMICTLMsgHdr.TransactionId = GetQCTLTransactionId(); - pRequest->CTLMsg.QMICTLMsgHdr.QMICTLType = cpu_to_le16(QMICTLType); - if (customQctlMsgFunction) - pRequest->CTLMsg.QMICTLMsgHdr.Length = cpu_to_le16(customQctlMsgFunction(&pRequest->CTLMsg, arg) - sizeof(QCQMICTL_MSG_HDR)); - else - pRequest->CTLMsg.QMICTLMsgHdr.Length = cpu_to_le16(0x0000); - - pRequest->QMIHdr.Length = cpu_to_le16(le16_to_cpu(pRequest->CTLMsg.QMICTLMsgHdr.Length) + sizeof(QCQMICTL_MSG_HDR) + sizeof(QCQMI_HDR) - 1); - Length = le16_to_cpu(pRequest->QMIHdr.Length) + 1; - - pRequest = (PQCQMIMSG)malloc(Length); - if (pRequest == NULL) { - dbg_time("%s fail to malloc", __func__); - } else { - memcpy(pRequest, QMIBuf, Length); - } - - return pRequest; -} - -static USHORT CtlGetVersionReq(PQMICTL_MSG QCTLMsg, void *arg) -{ - (void)arg; - QCTLMsg->GetVersionReq.TLVType = QCTLV_TYPE_REQUIRED_PARAMETER; - QCTLMsg->GetVersionReq.TLVLength = cpu_to_le16(0x0001); - QCTLMsg->GetVersionReq.QMUXTypes = QMUX_TYPE_ALL; - return sizeof(QMICTL_GET_VERSION_REQ_MSG); -} - -static USHORT CtlGetClientIdReq(PQMICTL_MSG QCTLMsg, void *arg) { - QCTLMsg->GetClientIdReq.TLVType = QCTLV_TYPE_REQUIRED_PARAMETER; - QCTLMsg->GetClientIdReq.TLVLength = cpu_to_le16(0x0001); - QCTLMsg->GetClientIdReq.QMIType = ((UCHAR *)arg)[0]; - return sizeof(QMICTL_GET_CLIENT_ID_REQ_MSG); -} - -static USHORT CtlReleaseClientIdReq(PQMICTL_MSG QCTLMsg, void *arg) { - QCTLMsg->ReleaseClientIdReq.TLVType = QCTLV_TYPE_REQUIRED_PARAMETER; - QCTLMsg->ReleaseClientIdReq.TLVLength = cpu_to_le16(0x0002); - QCTLMsg->ReleaseClientIdReq.QMIType = ((UCHAR *)arg)[0]; - QCTLMsg->ReleaseClientIdReq.ClientId = ((UCHAR *)arg)[1] ; - return sizeof(QMICTL_RELEASE_CLIENT_ID_REQ_MSG); -} - -static USHORT CtlLibQmiProxyOpenReq(PQMICTL_MSG QCTLMsg, void *arg) -{ - (void)arg; - const char *device_path = (const char *)(arg); - QCTLMsg->LibQmiProxyOpenReq.TLVType = 0x01; - QCTLMsg->LibQmiProxyOpenReq.TLVLength = cpu_to_le16(strlen(device_path)); - //strcpy(QCTLMsg->LibQmiProxyOpenReq.device_path, device_path); - //__builtin___strcpy_chk - memcpy(QCTLMsg->LibQmiProxyOpenReq.device_path, device_path, strlen(device_path)); - return sizeof(QMICTL_LIBQMI_PROXY_OPEN_MSG) + (strlen(device_path)); -} - -static int libqmi_proxy_open(const char *cdc_wdm) { - int ret; - PQCQMIMSG pResponse; - - ret = QmiThreadSendQMI(ComposeQCTLMsg(QMI_MESSAGE_CTL_INTERNAL_PROXY_OPEN, - CtlLibQmiProxyOpenReq, (void *)cdc_wdm), &pResponse); - if (!ret && pResponse - && pResponse->CTLMsg.QMICTLMsgHdrRsp.QMUXResult == 0 - && pResponse->CTLMsg.QMICTLMsgHdrRsp.QMUXError == 0) { - ret = 0; - } - else { - return -1; - } - - if (pResponse) - free(pResponse); - - return ret; -} - -static int QmiWwanSendQMI(PQCQMIMSG pRequest) { - struct pollfd pollfds[]= {{cdc_wdm_fd, POLLOUT, 0}}; - int ret; - - if (cdc_wdm_fd == -1) { - dbg_time("%s cdc_wdm_fd = -1", __func__); - return -ENODEV; - } - - if (pRequest->QMIHdr.QMIType != QMUX_TYPE_CTL) { - pRequest->QMIHdr.ClientId = qmiclientId[pRequest->QMIHdr.QMIType]; - if (pRequest->QMIHdr.ClientId == 0) { - dbg_time("QMIType %d has no clientID", pRequest->QMIHdr.QMIType); - return -ENODEV; - } - - if (pRequest->QMIHdr.QMIType == QMUX_TYPE_WDS_IPV6) - pRequest->QMIHdr.QMIType = QMUX_TYPE_WDS; - } - - do { - ret = poll(pollfds, sizeof(pollfds)/sizeof(pollfds[0]), 5000); - } while ((ret < 0) && (errno == EINTR)); - - if (pollfds[0].revents & POLLOUT) { - ssize_t nwrites = le16_to_cpu(pRequest->QMIHdr.Length) + 1; - ret = write(cdc_wdm_fd, pRequest, nwrites); - if (ret == nwrites) { - ret = 0; - } else { - dbg_time("%s write=%d, errno: %d (%s)", __func__, ret, errno, strerror(errno)); - } - } else { - dbg_time("%s poll=%d, revents = 0x%x, errno: %d (%s)", __func__, ret, pollfds[0].revents, errno, strerror(errno)); - } - - return ret; -} - -static UCHAR QmiWwanGetClientID(UCHAR QMIType) { - PQCQMIMSG pResponse; - - QmiThreadSendQMI(ComposeQCTLMsg(QMICTL_GET_CLIENT_ID_REQ, CtlGetClientIdReq, &QMIType), &pResponse); - - if (pResponse) { - USHORT QMUXResult = cpu_to_le16(pResponse->CTLMsg.QMICTLMsgHdrRsp.QMUXResult); // QMI_RESULT_SUCCESS - USHORT QMUXError = cpu_to_le16(pResponse->CTLMsg.QMICTLMsgHdrRsp.QMUXError); // QMI_ERR_INVALID_ARG - //UCHAR QMIType = pResponse->CTLMsg.GetClientIdRsp.QMIType; - UCHAR ClientId = pResponse->CTLMsg.GetClientIdRsp.ClientId; - - if (!QMUXResult && !QMUXError && (QMIType == pResponse->CTLMsg.GetClientIdRsp.QMIType)) { - switch (QMIType) { - case QMUX_TYPE_WDS: dbg_time("Get clientWDS = %d", ClientId); break; - case QMUX_TYPE_DMS: dbg_time("Get clientDMS = %d", ClientId); break; - case QMUX_TYPE_NAS: dbg_time("Get clientNAS = %d", ClientId); break; - case QMUX_TYPE_QOS: dbg_time("Get clientQOS = %d", ClientId); break; - case QMUX_TYPE_WMS: dbg_time("Get clientWMS = %d", ClientId); break; - case QMUX_TYPE_PDS: dbg_time("Get clientPDS = %d", ClientId); break; - case QMUX_TYPE_UIM: dbg_time("Get clientUIM = %d", ClientId); break; - case QMUX_TYPE_COEX: dbg_time("Get clientCOEX = %d", ClientId); break; - case QMUX_TYPE_WDS_ADMIN: dbg_time("Get clientWDA = %d", ClientId); - break; - default: break; - } - return ClientId; - } - } - return 0; -} - -static int QmiWwanReleaseClientID(QMI_SERVICE_TYPE QMIType, UCHAR ClientId) { - UCHAR argv[] = {QMIType, ClientId}; - QmiThreadSendQMI(ComposeQCTLMsg(QMICTL_RELEASE_CLIENT_ID_REQ, CtlReleaseClientIdReq, argv), NULL); - return 0; -} - -static int QmiWwanInit(PROFILE_T *profile) { - unsigned i; - int ret; - PQCQMIMSG pResponse; - - if (profile->proxy[0] && !strcmp(profile->proxy, LIBQMI_PROXY)) { - ret = libqmi_proxy_open(profile->qmichannel); - if (ret) - return ret; - } - - if (!profile->proxy[0]) { - for (i = 0; i < 10; i++) { - ret = QmiThreadSendQMITimeout(ComposeQCTLMsg(QMICTL_SYNC_REQ, NULL, NULL), NULL, 1 * 1000, __func__); - if (!ret) - break; - sleep(1); - } - if (ret) - return ret; - } - - QmiThreadSendQMI(ComposeQCTLMsg(QMICTL_GET_VERSION_REQ, CtlGetVersionReq, NULL), &pResponse); - if (profile->qmap_mode) { - if (pResponse) { - if (pResponse->CTLMsg.QMICTLMsgHdrRsp.QMUXResult == 0 && pResponse->CTLMsg.QMICTLMsgHdrRsp.QMUXError == 0) { - uint8_t NumElements = 0; - - for (NumElements = 0; NumElements < pResponse->CTLMsg.GetVersionRsp.NumElements; NumElements++) { -#if 0 - dbg_time("QMUXType = %02x Version = %d.%d", - pResponse->CTLMsg.GetVersionRsp.TypeVersion[NumElements].QMUXType, - pResponse->CTLMsg.GetVersionRsp.TypeVersion[NumElements].MajorVersion, - pResponse->CTLMsg.GetVersionRsp.TypeVersion[NumElements].MinorVersion); -#endif - if (pResponse->CTLMsg.GetVersionRsp.TypeVersion[NumElements].QMUXType == QMUX_TYPE_WDS_ADMIN) - profile->qmap_version = (pResponse->CTLMsg.GetVersionRsp.TypeVersion[NumElements].MinorVersion > 16); - } - } - } - } - if (pResponse) free(pResponse); - qmiclientId[QMUX_TYPE_WDS] = QmiWwanGetClientID(QMUX_TYPE_WDS); - if (profile->enable_ipv6) - qmiclientId[QMUX_TYPE_WDS_IPV6] = QmiWwanGetClientID(QMUX_TYPE_WDS); - qmiclientId[QMUX_TYPE_DMS] = QmiWwanGetClientID(QMUX_TYPE_DMS); - qmiclientId[QMUX_TYPE_NAS] = QmiWwanGetClientID(QMUX_TYPE_NAS); - qmiclientId[QMUX_TYPE_UIM] = QmiWwanGetClientID(QMUX_TYPE_UIM); - qmiclientId[QMUX_TYPE_WDS_ADMIN] = QmiWwanGetClientID(QMUX_TYPE_WDS_ADMIN); -#ifdef CONFIG_COEX_WWAN_STATE - qmiclientId[QMUX_TYPE_COEX] = QmiWwanGetClientID(QMUX_TYPE_COEX); -#endif -#ifdef CONFIG_ENABLE_QOS - qmiclientId[QMUX_TYPE_QOS] = QmiWwanGetClientID(QMUX_TYPE_QOS); -#endif - profile->wda_client = qmiclientId[QMUX_TYPE_WDS_ADMIN]; - - return 0; -} - -static int QmiWwanDeInit(void) { - unsigned int i; - for (i = 0; i < sizeof(qmiclientId)/sizeof(qmiclientId[0]); i++) - { - if (qmiclientId[i] != 0) - { - QmiWwanReleaseClientID(i, qmiclientId[i]); - qmiclientId[i] = 0; - } - } - - return 0; -} - -static ssize_t qmi_proxy_read (int fd, void *buf, size_t size) { - ssize_t nreads; - PQCQMI_HDR pHdr = (PQCQMI_HDR)buf; - - nreads = read(fd, pHdr, sizeof(QCQMI_HDR)); - if (nreads == sizeof(QCQMI_HDR) && le16_to_cpu(pHdr->Length) < size) { - nreads += read(fd, pHdr+1, le16_to_cpu(pHdr->Length) + 1 - sizeof(QCQMI_HDR)); - } - - return nreads; -} - -#ifdef QUECTEL_QMI_MERGE -static int QmiWwanMergeQmiRsp(void *buf, ssize_t *src_size) { - static QMI_MSG_PACKET s_QMIPacket; - QMI_MSG_HEADER *header = NULL; - ssize_t size = *src_size; - - if((uint16_t)size < sizeof(QMI_MSG_HEADER)) - return -1; - - header = (QMI_MSG_HEADER *)buf; - if(le16_to_cpu(header->idenity) != MERGE_PACKET_IDENTITY || le16_to_cpu(header->version) != MERGE_PACKET_VERSION || le16_to_cpu(header->cur_len) > le16_to_cpu(header->total_len)) - return -1; - - if(le16_to_cpu(header->cur_len) == le16_to_cpu(header->total_len)) { - *src_size = le16_to_cpu(header->total_len); - memcpy(buf, buf + sizeof(QMI_MSG_HEADER), *src_size); - s_QMIPacket.len = 0; - return 0; - } - - memcpy(s_QMIPacket.buf + s_QMIPacket.len, buf + sizeof(QMI_MSG_HEADER), le16_to_cpu(header->cur_len)); - s_QMIPacket.len += le16_to_cpu(header->cur_len); - - if (le16_to_cpu(header->cur_len) < MERGE_PACKET_MAX_PAYLOAD_SIZE || s_QMIPacket.len >= le16_to_cpu(header->total_len)) { - memcpy(buf, s_QMIPacket.buf, s_QMIPacket.len); - *src_size = s_QMIPacket.len; - s_QMIPacket.len = 0; - return 0; - } - - return -1; -} -#endif - -static void * QmiWwanThread(void *pData) { - PROFILE_T *profile = (PROFILE_T *)pData; - const char *cdc_wdm = (const char *)profile->qmichannel; - int wait_for_request_quit = 0; - char num = cdc_wdm[strlen(cdc_wdm)-1]; - - if (profile->proxy[0]) { - if (!strncmp(profile->proxy, QUECTEL_QMI_PROXY, strlen(QUECTEL_QMI_PROXY))) { - snprintf(profile->proxy, sizeof(profile->proxy), "%s%c", QUECTEL_QMI_PROXY, num); - } - } - else if (!strncmp(cdc_wdm, "/dev/mhi_IPCR", strlen("/dev/mhi_IPCR"))) { - snprintf(profile->proxy, sizeof(profile->proxy), "%s%c", QUECTEL_QRTR_PROXY, num); - } - else if (profile->qmap_mode > 1) { - snprintf(profile->proxy, sizeof(profile->proxy), "%s%c", QUECTEL_QMI_PROXY, num); - } - - if (profile->proxy[0]) - cdc_wdm_fd = cm_open_proxy(profile->proxy); - else - cdc_wdm_fd = cm_open_dev(cdc_wdm); - - if (cdc_wdm_fd == -1) { - dbg_time("%s Failed to open %s, errno: %d (%s)", __func__, cdc_wdm, errno, strerror(errno)); - qmidevice_send_event_to_main(RIL_INDICATE_DEVICE_DISCONNECTED); - pthread_exit(NULL); - return NULL; - } - - dbg_time("cdc_wdm_fd = %d", cdc_wdm_fd); - - qmidevice_send_event_to_main(RIL_INDICATE_DEVICE_CONNECTED); - while (1) { - struct pollfd pollfds[] = {{qmidevice_control_fd[1], POLLIN, 0}, {cdc_wdm_fd, POLLIN, 0}}; - int ne, ret, nevents = sizeof(pollfds)/sizeof(pollfds[0]); - - do { - ret = poll(pollfds, nevents, wait_for_request_quit ? 1000 : -1); - } while ((ret < 0) && (errno == EINTR)); - - if (ret == 0 && wait_for_request_quit) { - QmiThreadRecvQMI(NULL); - continue; - } - - if (ret <= 0) { - dbg_time("%s poll=%d, errno: %d (%s)", __func__, ret, errno, strerror(errno)); - break; - } - - for (ne = 0; ne < nevents; ne++) { - int fd = pollfds[ne].fd; - short revents = pollfds[ne].revents; - - //dbg_time("{%d, %x, %x}", pollfds[ne].fd, pollfds[ne].events, pollfds[ne].revents); - - if (revents & (POLLERR | POLLHUP | POLLNVAL)) { - dbg_time("%s poll err/hup/inval", __func__); - dbg_time("poll fd = %d, events = 0x%04x", fd, revents); - if (fd == cdc_wdm_fd) { - } else { - } - if (revents & (POLLHUP | POLLNVAL)) //EC20 bug, Can get POLLERR - goto __QmiWwanThread_quit; - } - - if ((revents & POLLIN) == 0) - continue; - - if (fd == qmidevice_control_fd[1]) { - int triger_event; - if (read(fd, &triger_event, sizeof(triger_event)) == sizeof(triger_event)) { - //DBG("triger_event = 0x%x", triger_event); - switch (triger_event) { - case RIL_REQUEST_QUIT: - goto __QmiWwanThread_quit; - break; - case SIG_EVENT_STOP: - wait_for_request_quit = 1; - break; - default: - break; - } - } - } - - if (fd == cdc_wdm_fd) { - ssize_t nreads; - PQCQMIMSG pResponse = (PQCQMIMSG)cm_recv_buf; - - if (!profile->proxy[0]) - nreads = read(fd, cm_recv_buf, sizeof(cm_recv_buf)); - else - nreads = qmi_proxy_read(fd, cm_recv_buf, sizeof(cm_recv_buf)); - //dbg_time("%s read=%d errno: %d (%s)", __func__, (int)nreads, errno, strerror(errno)); - if (nreads <= 0) { - dbg_time("%s read=%d errno: %d (%s)", __func__, (int)nreads, errno, strerror(errno)); - break; - } -#ifdef QUECTEL_QMI_MERGE - if((profile->qmap_mode == 0 || profile->qmap_mode == 1) && QmiWwanMergeQmiRsp(cm_recv_buf, &nreads)) - continue; -#endif - if (nreads != (le16_to_cpu(pResponse->QMIHdr.Length) + 1)) { - dbg_time("%s nreads=%d, pQCQMI->QMIHdr.Length = %d", __func__, (int)nreads, le16_to_cpu(pResponse->QMIHdr.Length)); - continue; - } - - QmiThreadRecvQMI(pResponse); - } - } - } - -__QmiWwanThread_quit: - if (cdc_wdm_fd != -1) { close(cdc_wdm_fd); cdc_wdm_fd = -1; } - qmidevice_send_event_to_main(RIL_INDICATE_DEVICE_DISCONNECTED); - QmiThreadRecvQMI(NULL); //main thread may pending on QmiThreadSendQMI() - dbg_time("%s exit", __func__); - pthread_exit(NULL); - return NULL; -} - -const struct qmi_device_ops qmiwwan_qmidev_ops = { - .init = QmiWwanInit, - .deinit = QmiWwanDeInit, - .send = QmiWwanSendQMI, - .read = QmiWwanThread, -}; - -uint8_t qmi_over_mbim_get_client_id(uint8_t QMIType) { - return QmiWwanGetClientID(QMIType); -} - -uint8_t qmi_over_mbim_release_client_id(uint8_t QMIType, uint8_t ClientId) { - return QmiWwanReleaseClientID(QMIType, ClientId); -} -#endif - diff --git a/quectel_cm_5G/src/ReleaseNote.txt b/quectel_cm_5G/src/ReleaseNote.txt deleted file mode 100644 index 430babe..0000000 --- a/quectel_cm_5G/src/ReleaseNote.txt +++ /dev/null @@ -1,325 +0,0 @@ -Release Notes - -[V1.6.4] -Date: 9/7/2022 -enhancement: - 1. set cflags as -Wall -Wextra -Werror -O1, and fix compile errors - 2. some code refactoring - 3. add quectel-qrtr-proxy -fix: - 1. netmask error when use ifconfig on little endian cpu - -[V1.6.2] -Date: 11/18/2021 -enhancement: - 1. support 'LTE && WiFi Coexistence Solution via QMI'. - If customer want use this feature, need enable CONFIG_COEX_WWAN_STATE in QMIThread.h - -[V1.6.1] -Date: 7/20/2021 -enhancement: - 1. add requestGetCellInfoList requestRadioPower - 2. add QMI OVER MBIM - 3. support qrtr and rmnet - 4. support RG500U PCIE - 5. add qos service && get qos flow data_rate_max func -fix: - 1. mbim: increase mbim open timeout to 3 seconds. some modem take long time for open cmd. - 2. support MsChapV2 - 3. mbim: invalid memory access when only get one DNS - 4. some bug fix for use AT Command to setup data call - -[V1.6.0.26] -Date: 4/22/2021 -enhancement: - 1. add lots of log file to show how to use this tool - 2. support pcie mhi multiple call - 3. at command: support EC200U/EC200T/EC200S/RG801H/RG500U/ -fix: - 1. mbim-proxy: fix errors on big endian cpu, ignore mbim open/close cmd from quectel-cm - -[V1.6.0.25] -Date: 4/8/2021 -enhancement: -fix: - 1. fix compile error when use gcc 9.3.0 - 2. fix yocto 'QA Issue: No GNU_HASH in the ELF binary' - -[V1.6.0.24] -Date: 3/9/2021 -enhancement: - 1. '-p [quectel-][qmi|mbim]-proxy', can connect to quectel/libqmi/libmbim's proxy, even only one data - 2. set variable s_9x07 as 1 (from 0), most of modems are base on MDM90x7 and later QCOM chip. -fix: - 1. define CHAR as signed char - 2. mofidy Makefile to generate more compile warnnings and fix them - -[V1.6.0.23] -Date: 2/26/2021 -enhancement: - 1. support 'AT+QNETDEVCTL' (not release) -fix: - 1. modify help/usage - 2. fix some memroy access error in mbim-cm.c - -[V1.6.0.22] -Date: 2/4/2021 -enhancement: - 1. support connect to libqmi's qmi-proxy - 2. only allow ' 0/1/2/none/pap/chap' for auth of '-s' - 3. '-m iface-idx' bind QMAP data call to wwan0_ -fix: - -[V1.6.0.21] -Date: 1/28/2021 -enhancement: - 1. print 5G signal -fix: - 1. fix compile errors: -Werror=format-truncation= - -[V1.6.0.20] -Date: 12/29/2020 -enhancement: - 1. Code refactoring - 2. support 'AT+QNETDEVCTL' (not release) -fix: - -[V1.6.0.19] -Date: 12/4/2020 -enhancement: - 1. if 'udhcpc's default.script' missed, directy set ip/dns/route by 'ip' co,mand -fix: - -[V1.6.0.18] -Date: 12/4/2020 -enhancement: - 1. Code refactoring -fix: - -[V1.6.0.17] -Date: 8/25/2020 -enhancement: - 1. support MBIM multi-call - 2. support unisoc RG500U mbim - 3. QUECTEL_QMI_MERGE: some SOC can not read more then 64 bytes (QMI)data via USB Endpoint 0 -fix: - -[V1.6.0.15] -Date: 7/24/2020 -enhancement: -fix: - 1. QMAP multi-call, AT+CFUN=4 then AT+CFUN=1, only one call can obtain IP by DHCP - -[V1.6.0.14] -Date: 6/10/2020 -enhancement: - 1. support X55's GobiNet LOOPBACK -fix: - 1. very old uclib do not support htole32 and pthread_condattr_setclock - 2. pthread_cond_wait tv_nsec >= 1000000000U is wrong - 3. do not close socket in udhcpc.c ifc_get_addr() - -[V1.6.0.13] -Date: 6/9/2020 -enhancement: - 1. add some example for openwrt, marco 'QL_OPENWER_NETWORK_SETUP' -fix: - -[V1.6.0.12] -Date: 5/29/2020 -enhancement: -fix: - 1. some EM12's usb-net-qmi/mbim interface is at 8 (not 4) - -[V1.6.0.11] -Date: 5/28/2020 -enhancement: -fix: - 1. fix mbim debug on Big Endian CPU - -[V1.6.0.10] -Date: 5/25/2020 -enhancement: -fix: - 1. set QMAP .ul_data_aggregation_max_datagrams to 11 (from 16) - -[V1.6.0.9] -Date: 5/22/2020 -enhancement: -fix: - 1. dial fail when register to 5G-SA - -[V1.6.0.8] -Date: 4/30/2020 -enhancement: - 1. support '-b' to seletc brige mode -fix: - -[V1.6.0.7] -Date: 4/29/2020 -enhancement: - 1. support QMAP multi-call for qmi_wwan_q and pcie_mhi 's rmnet driver -fix: - -[V1.6.0.6] -Date: 4/20/2020 -enhancement: - 1. support '-k pdn_idx' to hangup call '-n pdn_idx' -fix: - 1. fix set dl_minimum_padding as 0, modems do not support this featrue - -[V1.6.0.5] -Date: 4/10/2020 -enhancement: - 1. support X55's QMAPV5 for PCIE -fix: - -[V1.6.0.3] -Date: 4/8/2020 -enhancement: - 1. support multi-modems all use multi-data-calls -fix: - -[V1.6.0.2] -Date: 4/7/2020 -enhancement: - 1. support X55's QMAPV5 for USB -fix: - -[V1.6.0.1] -Date: 4/1/2020 -enhancement: - 1. support QMAP UL AGG (multi data call) -fix: - 1. some EM12's usb-net-qmi/mbim interface is at 8 (not 4) - -[V1.5.9] -Date: 3/4/2020 -enhancement: - 1. support pcie mhi multi-APN data call - 3. support QMAP UL AGG (single data call) -fix: - 1. set 4 bytes aligned for mbim parameters, or cause dial mbim call fail - -[V1.5.8] -Date: 2/18/2020 -enhancement: - 1. support '-l 14' X55's loopback function -fix: - -[V1.5.7] -Date: 2/6/2020 -enhancement: - 1. support '-u usbmon_log_file' to catch usbmon log -fix: - -[V1.5.6] -Date: 1/20/202 -enhancement: - 1. show driver name and version - 2. support PCSCF - 3. support bridge in mbim -fix: - -[V1.5.5] -Date: 12/31/2019 -enhancement: -fix: - 1. fix some memory access bug in mbim-cm.c - -[WCDMA<E_QConnectManager_Linux&Android_V1.5.4] -Date: 12/17/2019 -enhancement: - 1. Add copyright - 2. auto detect pcie mhi /dev/mhi* -fix: - -[WCDMA<E_QConnectManager_Linux&Android_V1.5.3] -Date: 2019/12/11 -enhancement: -1. support show SignalInfo, controlled by macro CONFIG_SIGNALINFO -2. support show 5G_NSA/5G_NA -3. support Microsoft Extend MBIM message -fix: -1. quectel-qmi-proxy bugs on Big-Endian CPU - -[WCDMA<E_QConnectManager_Linux&Android_V1.5.2] -Date: 12/2/2019 -enhancement: - 1. support requestGetSignalInfo() -fix: - -[WCDMA<E_QConnectManager_Linux&Android_V1.4.1] -Date: 10/23/2019 -enhancement: - 1. support QMI_CTL_REVOKE_CLIENT_ID_IND (Quectel define QMI) - 2. add copyright -fix: - 1. remove SIGUSR - -[WCDMA<E_QConnectManager_Linux&Android_V1.3.10] -Date: 10/14/2019 -enhancement: - 1. increase retry interval -fix: - -[WCDMA<E_QConnectManager_Linux&Android_V1.2.1] -Date: 2019/02/26 -enhancement: -1. Implement help message. - -root@ubuntu:# ./quectel-CM -h -[02-26_10:39:21:353] Usage: ./quectel-CM [options] -[02-26_10:39:21:353] -s [apn [user password auth]] Set apn/user/password/auth get from your network provider -[02-26_10:39:21:353] -p pincode Verify sim card pin if sim card is locked -[02-26_10:39:21:353] -f logfilename Save log message of this program to file -[02-26_10:39:21:353] -i interface Specify network interface(default auto-detect) -[02-26_10:39:21:353] -4 IPv4 protocol -[02-26_10:39:21:353] -6 IPv6 protocol -[02-26_10:39:21:353] -m muxID Specify muxid when set multi-pdn data connection. -[02-26_10:39:21:353] -n channelID Specify channelID when set multi-pdn data connection(default 1). -[02-26_10:39:21:353] [Examples] -[02-26_10:39:21:353] Example 1: ./quectel-CM -[02-26_10:39:21:353] Example 2: ./quectel-CM -s 3gnet -[02-26_10:39:21:353] Example 3: ./quectel-CM -s 3gnet carl 1234 0 -p 1234 -f gobinet_log.txt -root@ubuntu:# -2. Support bridge mode when set multi-pdn data connections. -3. Host device can access network in bridge mode. - -[WCDMA<E_QConnectManager_Linux&Android_V1.1.46] -Date: 2019/02/18 -enhancement: -1. support only IPV6 data call. quectel-CM now support three dialing methods: IPV4 only, IPV6 only, IPV4V6. - ./quectel-CM -4(or no argument) only IPV4 - -6 only IPV6 - -4 -6 IPV4 && IPV6 - -[WCDMA<E_QConnectManager_Linux&Android_V1.1.45] -Date: 2018/09/13 -enhancement: -1. support EG12 PCIE interface - -[WCDMA<E_QConnectManager_Linux&Android_V1.1.44] -Date: 2018/09/10 -enhancement: -1. support setup IPV4&IPV6 data call. - -[WCDMA<E_QConnectManager_Linux&Android_V1.1.43] -[WCDMA<E_QConnectManager_Linux&Android_V1.1.42] -Date: 2018/08/29 -enhancement: -1. support QMI_WWAN's QMAP fucntion and bridge mode, please contact Quectel FAE to get qmi_wwan.c patch. - when enable QMI_WWAN's QMAP IP Mux function, must run 'quectel-qmi-proxy -d /dev/cdc-wdmX' before quectel-CM - -[WCDMA<E_QConnectManager_Linux&Android_V1.1.41] -Date: 2018/05/24 -enhancement: -1. fix a cdma data call error - -[WCDMA<E_QConnectManager_Linux&Android_V1.1.40] -Date: 2018/05/12 -enhancement: -1. support GobiNet's QMAP fucntion and bridge mode. - 'Quectel_WCDMA<E_Linux&Android_GobiNet_Driver_V1.3.5' and later version is required to use QMAP and bridge mode. - for detail, please refer to GobiNet Driver - diff --git a/quectel_cm_5G/src/at_tok.c b/quectel_cm_5G/src/at_tok.c deleted file mode 100644 index 6736cc8..0000000 --- a/quectel_cm_5G/src/at_tok.c +++ /dev/null @@ -1,283 +0,0 @@ -/* //device/system/reference-ril/at_tok.c -** -** Copyright 2006, The Android Open Source Project -** -** Licensed under the Apache License, Version 2.0 (the "License"); -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at -** -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and -** limitations under the License. -*/ - -#include "at_tok.h" -#include -#include -#include -#include -#include - -/** - * Starts tokenizing an AT response string - * returns -1 if this is not a valid response string, 0 on success. - * updates *p_cur with current position - */ -int at_tok_start(char **p_cur) -{ - if (*p_cur == NULL) { - return -1; - } - - // skip prefix - // consume "^[^:]:" - - *p_cur = strchr(*p_cur, ':'); - - if (*p_cur == NULL) { - return -1; - } - - (*p_cur)++; - - return 0; -} - -static void skipWhiteSpace(char **p_cur) -{ - if (*p_cur == NULL) return; - - while (**p_cur != '\0' && isspace(**p_cur)) { - (*p_cur)++; - } -} - -static void skipNextComma(char **p_cur) -{ - if (*p_cur == NULL) return; - - while (**p_cur != '\0' && **p_cur != ',') { - (*p_cur)++; - } - - if (**p_cur == ',') { - (*p_cur)++; - } -} - -static char * nextTok(char **p_cur) -{ - char *ret = NULL; - - skipWhiteSpace(p_cur); - - if (*p_cur == NULL) { - ret = NULL; - } else if (**p_cur == '"') { - (*p_cur)++; - ret = strsep(p_cur, "\""); - skipNextComma(p_cur); - } else { - ret = strsep(p_cur, ","); - } - - return ret; -} - - -/** - * Parses the next integer in the AT response line and places it in *p_out - * returns 0 on success and -1 on fail - * updates *p_cur - * "base" is the same as the base param in strtol - */ - -static int at_tok_nextint_base(char **p_cur, int *p_out, int base, int uns) -{ - char *ret; - - if (*p_cur == NULL) { - return -1; - } - - ret = nextTok(p_cur); - - if (ret == NULL) { - return -1; - } else { - long l; - char *end; - - if (uns) - l = strtoul(ret, &end, base); - else - l = strtol(ret, &end, base); - - *p_out = (int)l; - - if (end == ret) { - return -1; - } - } - - return 0; -} - -/** - * Parses the next base 10 integer in the AT response line - * and places it in *p_out - * returns 0 on success and -1 on fail - * updates *p_cur - */ -int at_tok_nextint(char **p_cur, int *p_out) -{ - return at_tok_nextint_base(p_cur, p_out, 10, 0); -} - -/** - * Parses the next base 16 integer in the AT response line - * and places it in *p_out - * returns 0 on success and -1 on fail - * updates *p_cur - */ -int at_tok_nexthexint(char **p_cur, int *p_out) -{ - return at_tok_nextint_base(p_cur, p_out, 16, 1); -} - -int at_tok_nextbool(char **p_cur, char *p_out) -{ - int ret; - int result; - - ret = at_tok_nextint(p_cur, &result); - - if (ret < 0) { - return -1; - } - - // booleans should be 0 or 1 - if (!(result == 0 || result == 1)) { - return -1; - } - - if (p_out != NULL) { - *p_out = (char)result; - } - - return ret; -} - -int at_tok_nextstr(char **p_cur, char **p_out) -{ - if (*p_cur == NULL) { - return -1; - } - - *p_out = nextTok(p_cur); - - return 0; -} - -/** returns 1 on "has more tokens" and 0 if no */ -int at_tok_hasmore(char **p_cur) -{ - return ! (*p_cur == NULL || **p_cur == '\0'); -} - -int at_tok_count(const char *in_line) -{ - int commas = 0; - const char *p; - - if (!in_line) - return 0; - - for (p = in_line; *p != '\0' ; p++) { - if (*p == ',') commas++; - } - - return commas; -} - -//fmt: d ~ int, x ~ hexint, b ~ bool, s ~ str -int at_tok_scanf(const char *in_line, const char *fmt, ...) -{ - int n = 0; - int err; - va_list ap; - const char *p = fmt; - void *d; - void *dump; - static char s_line[1024]; - char *line = s_line; - - if (!in_line) - return 0; - - strncpy(s_line, in_line, sizeof(s_line) - 1); - - va_start(ap, fmt); - - err = at_tok_start(&line); - if (err < 0) goto error; - - for (; *p; p++) { - if (*p == ',' || *p == ' ') - continue; - - if (*p != '%') { - goto error; - } - p++; - - d = va_arg(ap, void *); - if (!d) - d = &dump; - - if (!at_tok_hasmore(&line)) - break; - - if (*line == '-' && *(line + 1) == ',') { - line += 2; - n++; - if (*p == 'd') - *(int *)d = -1; - continue; - } - - switch(*p) { - case 'd': - err = at_tok_nextint(&line, (int *)d); - if (err < 0) goto error; - break; - case 'x': - err = at_tok_nexthexint(&line, (int *)d); - if (err < 0) goto error; - break; - case 'b': - err = at_tok_nextbool(&line, (char *)d); - if (err < 0) goto error; - break; - case 's': - err = at_tok_nextstr(&line, (char **)d); //if strdup(line), here return free memory to caller - if (err < 0) goto error; - break; - default: - goto error; - break; - } - - n++; - } - - va_end(ap); - -error: - //free(line); - return n; -} diff --git a/quectel_cm_5G/src/at_tok.h b/quectel_cm_5G/src/at_tok.h deleted file mode 100644 index 2fcb683..0000000 --- a/quectel_cm_5G/src/at_tok.h +++ /dev/null @@ -1,33 +0,0 @@ -/* //device/system/reference-ril/at_tok.h -** -** Copyright 2006, The Android Open Source Project -** -** Licensed under the Apache License, Version 2.0 (the "License"); -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at -** -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and -** limitations under the License. -*/ - -#ifndef AT_TOK_H -#define AT_TOK_H 1 - -int at_tok_start(char **p_cur); -int at_tok_nextint(char **p_cur, int *p_out); -int at_tok_nexthexint(char **p_cur, int *p_out); - -int at_tok_nextbool(char **p_cur, char *p_out); -int at_tok_nextstr(char **p_cur, char **out); - -int at_tok_hasmore(char **p_cur); -int at_tok_count(const char *in_line); -int at_tok_scanf(const char *line, const char *fmt, ...); - -#endif /*AT_TOK_H */ - diff --git a/quectel_cm_5G/src/atc.c b/quectel_cm_5G/src/atc.c deleted file mode 100644 index d9fa61e..0000000 --- a/quectel_cm_5G/src/atc.c +++ /dev/null @@ -1,1054 +0,0 @@ -/****************************************************************************** - @file atc.c - @brief at command. - - DESCRIPTION - Connectivity Management Tool for USB network adapter of Quectel wireless cellular modules. - - INITIALIZATION AND SEQUENCING REQUIREMENTS - None. - - --------------------------------------------------------------------------- - Copyright (c) 2016 - 2020 Quectel Wireless Solution, Co., Ltd. All Rights Reserved. - Quectel Wireless Solution Proprietary and Confidential. - --------------------------------------------------------------------------- -******************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -extern int asprintf(char **s, const char *fmt, ...); - -#include "QMIThread.h" - -#include "atchannel.h" -#include "at_tok.h" - -static int asr_style_atc = 0; -static int s_pdp; -#define safe_free(__x) do { if (__x) { free((void *)__x); __x = NULL;}} while(0) -#define safe_at_response_free(__x) { if (__x) { at_response_free(__x); __x = NULL;}} - -#define at_response_error(err, p_response) \ - (err \ - || p_response == NULL \ - || p_response->finalResponse == NULL \ - || p_response->success == 0) - -static int atc_init(PROFILE_T *profile) { - int err; - char *cmd; - ATResponse *p_response = NULL; - - if (profile->proxy[0]) { - s_pdp = profile->pdp; - err = at_send_command_singleline("AT+QNETDEVSTATUS=?", "+QNETDEVSTATUS:", &p_response); - if (at_response_error(err, p_response)) - asr_style_atc = 1; //EC200T/EC100Y do not support this AT, but RG801/RG500U support - safe_at_response_free(p_response); - - return err; - } - - err = at_handshake(); - if (err) { - dbg_time("handshake fail, TODO ... "); - goto exit; - } - - s_pdp = profile->pdp; - at_send_command_singleline("AT+QCFG=\"usbnet\"", "+QCFG:", NULL); - at_send_command_multiline("AT+QNETDEVCTL=?", "+QNETDEVCTL:", NULL); - at_send_command("AT+CGREG=2", NULL); //GPRS Network Registration Status - at_send_command("AT+CEREG=2", NULL); //EPS Network Registration Status - at_send_command("AT+C5GREG=2", NULL); //5GS Network Registration Status - - err = at_send_command_singleline("AT+QNETDEVSTATUS=?", "+QNETDEVSTATUS:", &p_response); - if (at_response_error(err, p_response)) - asr_style_atc = 1; //EC200T/EC100Y do not support this AT, but RG801/RG500U support - safe_at_response_free(p_response); - - err = at_send_command_singleline("AT+QCFG=\"NAT\"", "+QCFG:", &p_response); - if (!at_response_error(err, p_response)) { - int old_nat, new_nat = asr_style_atc ? 1 : 0; - - err = at_tok_scanf(p_response->p_intermediates->line, "%s%d", NULL, &old_nat); - if (err == 2 && old_nat != new_nat) { - safe_at_response_free(p_response); - asprintf(&cmd, "AT+QCFG=\"NAT\",%d", new_nat); - err = at_send_command(cmd, &p_response); - safe_free(cmd); - if (!at_response_error(err, p_response)) { - err = at_send_command("at+cfun=1,1",NULL); - if (!err) - g_donot_exit_when_modem_hangup = 1; - //reboot to take effect - } - safe_at_response_free(p_response); - } - err = 0; - } - safe_at_response_free(p_response); - -exit: - return err; -} - -static int atc_deinit(void) { - return 0; -} - -/** - * Called by atchannel when an unsolicited line appears - * This is called on atchannel's reader thread. AT commands may - * not be issued here - */ -static void onUnsolicited (const char *s, const char *sms_pdu) -{ - (void)sms_pdu; - - if (strStartsWith(s, "+QNETDEVSTATUS:")) { - qmidevice_send_event_to_main(RIL_UNSOL_DATA_CALL_LIST_CHANGED); - } - else if (strStartsWith(s, "+CGREG:") - || strStartsWith(s, "+CEREG:") - || strStartsWith(s, "+C5GREG:")) { - qmidevice_send_event_to_main(RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED); - } -} - -static void onTimeout(void) { - dbg_time("%s", __func__); - //TODO -} - -static void onClose(void) { - dbg_time("%s", __func__); -} - -static void * atc_read_thread(void *param) { - PROFILE_T *profile = (PROFILE_T *)param; - const char *cdc_wdm = (const char *)profile->qmichannel; - int wait_for_request_quit = 0; - int atc_fd; - - atc_fd = cm_open_dev(cdc_wdm); - if (atc_fd <= 0) { - dbg_time("fail to open (%s), errno: %d (%s)", cdc_wdm, errno, strerror(errno)); - goto __quit; - } - - dbg_time("atc_fd = %d", atc_fd); - - if (at_open(atc_fd, onUnsolicited, 0)) - goto __quit; - - at_set_on_timeout(onTimeout); - at_set_on_reader_closed(onClose); - qmidevice_send_event_to_main(RIL_INDICATE_DEVICE_CONNECTED); - - while (atc_fd > 0) { - struct pollfd pollfds[] = {{atc_fd, POLLIN, 0}, {qmidevice_control_fd[1], POLLIN, 0}}; - int ne, ret, nevents = 2; - - ret = poll(pollfds, nevents, wait_for_request_quit ? 1000 : -1); - - if (ret == 0 && wait_for_request_quit) { - break; - } - - if (ret < 0) { - dbg_time("%s poll=%d, errno: %d (%s)", __func__, ret, errno, strerror(errno)); - break; - } - - for (ne = 0; ne < nevents; ne++) { - int fd = pollfds[ne].fd; - short revents = pollfds[ne].revents; - - if (revents & (POLLERR | POLLHUP | POLLNVAL)) { - dbg_time("%s poll err/hup/inval", __func__); - dbg_time("epoll fd = %d, events = 0x%04x", fd, revents); - if (revents & (POLLERR | POLLHUP | POLLNVAL)) - goto __quit; - } - - if ((revents & POLLIN) == 0) - continue; - - if (atc_fd == fd) { - usleep(10*1000); //let atchannel.c read at response. - } - else if (fd == qmidevice_control_fd[1]) { - int triger_event; - if (read(fd, &triger_event, sizeof(triger_event)) == sizeof(triger_event)) { - //dbg_time("triger_event = 0x%x", triger_event); - switch (triger_event) { - case RIL_REQUEST_QUIT: - goto __quit; - break; - case SIG_EVENT_STOP: - wait_for_request_quit = 1; - break; - default: - break; - } - } - } - } - } - -__quit: - at_close(); - qmidevice_send_event_to_main(RIL_INDICATE_DEVICE_DISCONNECTED); - dbg_time("%s exit", __func__); - - return NULL; -} - -const struct qmi_device_ops atc_dev_ops = { - .init = atc_init, - .deinit = atc_deinit, - .read = atc_read_thread, -}; - -static int requestBaseBandVersion(PROFILE_T *profile) { - int retVal = -1; - int err; - ATResponse *p_response = NULL; - - (void)profile; - - err = at_send_command_multiline("AT+CGMR", "\0", &p_response); - if (at_response_error(err, p_response)) - goto exit; - - if (p_response->p_intermediates && p_response->p_intermediates->line) { - strncpy(profile->BaseBandVersion, p_response->p_intermediates->line, sizeof(profile->BaseBandVersion) - 1); - retVal = 0; - } - -exit: - safe_at_response_free(p_response); - return retVal; -} - -static int requestGetSIMStatus(SIM_Status *pSIMStatus) -{ - int err; - ATResponse *p_response = NULL; - char *cpinLine; - char *cpinResult; - int ret = SIM_NOT_READY; - - err = at_send_command_singleline("AT+CPIN?", "+CPIN:", &p_response); - if (at_response_error(err, p_response)) - goto done; - - switch (at_get_cme_error(p_response)) - { - case CME_SUCCESS: - break; - - case CME_SIM_NOT_INSERTED: - case CME_OPERATION_NOT_ALLOWED: - case CME_FAILURE: - ret = SIM_ABSENT; - goto done; - - default: - ret = SIM_NOT_READY; - goto done; - } - - cpinLine = p_response->p_intermediates->line; - err = at_tok_start (&cpinLine); - - if (err < 0) - { - ret = SIM_NOT_READY; - goto done; - } - - err = at_tok_nextstr(&cpinLine, &cpinResult); - - if (err < 0) - { - ret = SIM_NOT_READY; - goto done; - } - - if (0 == strcmp (cpinResult, "SIM PIN")) - { - ret = SIM_PIN; - goto done; - } - else if (0 == strcmp (cpinResult, "SIM PUK")) - { - ret = SIM_PUK; - goto done; - } - else if (0 == strcmp (cpinResult, "PH-NET PIN")) - { - return SIM_NETWORK_PERSONALIZATION; - } - else if (0 != strcmp (cpinResult, "READY")) - { - /* we're treating unsupported lock types as "sim absent" */ - ret = SIM_ABSENT; - goto done; - } - - ret = SIM_READY; - -done: - safe_at_response_free(p_response); - *pSIMStatus = ret; - return err; -} - -static int requestEnterSimPin(const char *pPinCode) { - int retVal = -1; - int err; - ATResponse *p_response = NULL; - char *cmd = NULL; - - asprintf(&cmd, "AT+CPIN=%s", pPinCode); - err = at_send_command(cmd, NULL); - safe_free(cmd); - - if (!at_response_error(err, p_response)) { - retVal = 0; - } - - safe_at_response_free(p_response); - return retVal; -} - -static int requestSetProfile(PROFILE_T *profile) { - int err; - ATResponse *p_response = NULL; - char *cmd = NULL; - const char *new_apn = profile->apn ? profile->apn : ""; - const char *new_user = profile->user ? profile->user : ""; - const char *new_password = profile->password ? profile->password : ""; - const char *ipStr[] = {"NULL", "IPV4", "IPV6", "IPV4V6"}; - - dbg_time("%s[%d] %s/%s/%s/%d/%s", __func__, - profile->pdp, profile->apn, profile->user, profile->password, - profile->auth,ipStr[profile->iptype]); - - if ( !strcmp(profile->old_apn, new_apn) && !strcmp(profile->old_user, new_user) - && !strcmp(profile->old_password, new_password) - && profile->old_iptype == profile->iptype - && profile->old_auth == profile->auth) - { - dbg_time("no need to set skip the rest"); - return 0; - } - - asprintf(&cmd, "AT+QICSGP=%d,%d,\"%s\",\"%s\",\"%s\",%d", - profile->pdp, profile->iptype, new_apn, new_user, new_password, profile->auth); - err = at_send_command(cmd, &p_response); - safe_free(cmd); - if (at_response_error(err, p_response)) { - safe_at_response_free(p_response); - asprintf(&cmd, "AT+CGDCONT=%d,\"%s\",\"%s\"", profile->pdp, ipStr[profile->iptype], new_apn); - err = at_send_command(cmd, &p_response); - safe_free(cmd); - } - - safe_at_response_free(p_response); - return 1; -} - -static int requestGetProfile(PROFILE_T *profile) { - int retVal = -1; - int err; - ATResponse *p_response = NULL; - char *cmd = NULL; - int pdp; - int old_iptype = 1; // 1 ~ IPV4, 2 ~ IPV6, 3 ~ IPV4V6 - char *old_apn = "", *old_user = "", *old_password = ""; - int old_auth = 0; - const char *ipStr[] = {"NULL", "IPV4", "IPV6", "IPV4V6"}; - - if (profile->enable_ipv4 && profile->enable_ipv6) - profile->iptype = 3; - else if (profile->enable_ipv6) - profile->iptype = 2; - else - profile->iptype = 1; - -_re_check: - asprintf(&cmd, "AT+QICSGP=%d", profile->pdp); - err = at_send_command_singleline(cmd, "+QICSGP:", &p_response); - safe_free(cmd); - if (err == AT_ERROR_INVALID_RESPONSE && p_response == NULL) { - //bug of RG801H - safe_at_response_free(p_response); - asprintf(&cmd, "AT+QICSGP=%d,%d,\"\",\"\",\"\",0", profile->pdp, profile->iptype); - err = at_send_command(cmd, &p_response); - safe_free(cmd); - if (!at_response_error(err, p_response)) { - safe_at_response_free(p_response); - goto _re_check; - } - } - - if (!at_response_error(err, p_response)) { - err = at_tok_scanf(p_response->p_intermediates->line, - "%d%s%s%s%d", &old_iptype, &old_apn, &old_user, &old_password, &old_auth); - - if (err != 4 || pdp != profile->pdp) - goto _error; - } - else { - ATLine *atLine = NULL; - char *cgdcont_iptype = NULL; - - safe_at_response_free(p_response); - err = at_send_command_multiline("AT+CGDCONT?", "+CGDCONT:", &p_response); - if (at_response_error(err, p_response)) - goto _error; - - atLine = p_response->p_intermediates; - while (atLine) { - err = at_tok_scanf(atLine->line, "%d%s%s", &pdp, &cgdcont_iptype, &old_apn); - if (err == 3 && pdp == profile->pdp) { - if (!strcasecmp(cgdcont_iptype, ipStr[3])) - old_iptype = 3; - else if (!strcasecmp(cgdcont_iptype, ipStr[2])) - old_iptype = 2; - else - old_iptype = 1; - break; - } - old_apn = NULL; - atLine = atLine->p_next; - } - } - - retVal = 0; - -_error: - if (!old_apn) old_apn = ""; - if (!old_user) old_user = ""; - if (!old_password) old_password = ""; - - strncpy(profile->old_apn, old_apn, sizeof(profile->old_apn)); - strncpy(profile->old_user, old_user, sizeof(profile->old_user)); - strncpy(profile->old_password, old_password, sizeof(profile->old_password)); - profile->old_auth = old_auth; - profile->old_iptype = old_iptype; - - dbg_time("%s[%d] %s/%s/%s/%d/%s", __func__, - profile->pdp, profile->old_apn, profile->old_user, profile->old_password, - profile->old_auth, ipStr[profile->old_iptype]); - - safe_at_response_free(p_response); - - return retVal; -} - -static int requestRegistrationState(UCHAR *pPSAttachedState) { - int retVal = -1; - int err; - ATResponse *p_response = NULL; - ATLine *p_cur; - int i; - int cops_act = -1; - int state = 0, lac = 0, cid = 0, act = 0; - int commas; - char *line; - - *pPSAttachedState = 0; - - err = at_send_command_multiline( - "AT+COPS=3,0;+COPS?;+COPS=3,1;+COPS?;+COPS=3,2;+COPS?", - "+COPS:", &p_response); - if (at_response_error(err, p_response)) - goto error; - -/* -AT< +COPS: 0,0,"CHINA MOBILE",13 -AT< +COPS: 0,1,"CMCC",13 -AT< +COPS: 0,2,"46000",13 -AT< OK -*/ - retVal = 0; - for (i = 0, p_cur = p_response->p_intermediates; p_cur != NULL; p_cur = p_cur->p_next, i++) { - err = at_tok_scanf(p_cur->line, "%d%d%s%d", NULL, NULL, NULL, &cops_act); - if (err != 4) goto error; - - break; - } - - safe_at_response_free(p_response); - switch (cops_act) { - case 2: //UTRAN - case 4: //UTRAN W/HSDPA - case 5: //UTRAN W/HSUPA - case 6: //UTRAN W/HSDPA and HSUPA - //AT+CGREG GPRS Network Registration Status - err = at_send_command_singleline("AT+CGREG?", "+CGREG:", &p_response); - break; - - case 7: //E-UTRAN - case 13: //E-UTRAN-NR dual connectivity - //AT+CEREG EPS Network Registration Status - err = at_send_command_singleline("AT+CEREG?", "+CEREG:", &p_response); - break; - - case 10: //E-UTRAN connected to a 5GCN - case 11: //NR connected to a 5GCN - case 12: //NG-RAN - //AT+C5GREG 5GS Network Registration Status - err = at_send_command_singleline("AT+C5GREG?", "+C5GREG:", &p_response); - break; - - default: - goto error; - break; - } - - if (at_response_error(err, p_response)) - goto error; - if (!p_response->p_intermediates || !p_response->p_intermediates->line) goto error; - - line = p_response->p_intermediates->line; - commas = at_tok_count(line); - switch (commas) { - case 0: /* +CREG: */ - err = at_tok_nextint(&line, &state); - if (err < 0) goto error; - break; - - case 1: /* +CREG: , */ - err = at_tok_scanf(line, "%d%d", NULL, &state); - if (err != 2) goto error; - break; - - case 2: /* +CREG: , , */ - err = at_tok_scanf(line, "%d%x%x", NULL, &state, &lac, &cid); - if (err != 3) goto error; - break; - - case 3: /* +CREG: , , , */ - err = at_tok_scanf(line, "%d%d%x%x", NULL, &state, &lac, &cid); - if (err != 4) goto error; - break; - - case 4: //, , , , */ - case 5: - case 6: - case 7: - err = at_tok_scanf(line, "%d%d%x%x%d", NULL, &state, &lac, &cid, &act); - if (err != 5) goto error; - break; - - default: - goto error; - } - - //dbg_time("state=%d", state); - - if (state == 1 || state == 5) { //Registered, home network / roaming - *pPSAttachedState = 1; - } - -error: - safe_at_response_free(p_response); - return retVal; -} - -static int requestSetupDataCall(PROFILE_T *profile, int curIpFamily) { - int err; - ATResponse *p_response = NULL; - char *cmd = NULL; - ATLine *p_cur = NULL; - int pdp = profile->pdp; - int state = 0; - - (void)curIpFamily; - - if (strStartsWith(profile->BaseBandVersion, "RG801H") || strStartsWith(profile->BaseBandVersion, "EC200H")) { - //RG801H will miss USB_CDC_NOTIFY_NETWORK_CONNECTION - asprintf(&cmd, "ifconfig %s up", profile->usbnet_adapter); - if (system(cmd)) {}; - safe_free(cmd); - } - - if (asr_style_atc) { - err = at_send_command_multiline("AT+CGACT?", "+CGACT:", &p_response); - if (at_response_error(err, p_response)) - goto _error; - - for (p_cur = p_response->p_intermediates; p_cur != NULL; p_cur = p_cur->p_next) { - int cid = 0; - state = 0; - - err = at_tok_scanf(p_cur->line, "%d%d", &cid, &state); - if (cid == pdp) - break; - else if(state) - state = 0; - } - safe_at_response_free(p_response); - - if (state == 0) { - asprintf(&cmd, "AT+CGACT=1,%d", pdp); - err = at_send_command(cmd, &p_response); - safe_free(cmd); - if (at_response_error(err, p_response)) - goto _error; - } - } - - if(asr_style_atc) - asprintf(&cmd, "AT+QNETDEVCTL=1,%d,%d", pdp, 1); - else - asprintf(&cmd, "AT+QNETDEVCTL=%d,1,%d", pdp, 1); - err = at_send_command(cmd, &p_response); - safe_free(cmd); - - if (at_response_error(err, p_response)) - goto _error; - - if (!asr_style_atc) { //TODO some modems do not sync return setup call resule - int t = 0; - - while (t++ < 15) { - asprintf(&cmd, "AT+QNETDEVSTATUS=%d", pdp); - err = at_send_command_singleline(cmd, "+QNETDEVSTATUS", &p_response); - safe_free(cmd); - if (err) goto _error; - - if (!at_response_error(err, p_response)) { - break; - } - safe_at_response_free(p_response); - sleep(1); - } - } - - //some modem do not report URC - qmidevice_send_event_to_main(RIL_UNSOL_DATA_CALL_LIST_CHANGED); - -_error: - safe_at_response_free(p_response); - //dbg_time("%s err=%d", __func__, err); - return err; -} - -static int at_netdevstatus(int pdp, unsigned int *pV4Addr) { - int err; - ATResponse *p_response = NULL; - char *cmd = NULL; - char *ipv4_address = NULL; - char *ipv4_gate = NULL; - char *ipv4_DHCP = NULL; - char *ipv4_pDNS = NULL; - char *ipv4_sDNS = NULL; - char *ipv6_address = NULL; - char *ipv6_gate = NULL; - char *ipv6_DHCP = NULL; - char *ipv6_pDNS = NULL; - char *ipv6_sDNS = NULL; - - *pV4Addr = 0; - - asprintf(&cmd, "AT+QNETDEVSTATUS=%d", pdp); - err = at_send_command_singleline(cmd, "+QNETDEVSTATUS", &p_response); - safe_free(cmd); - if (at_response_error(err, p_response)) goto _error; - if (!p_response->p_intermediates || !p_response->p_intermediates->line) goto _error; - - err = at_tok_scanf(p_response->p_intermediates->line, "%s%s%s%s%s%s%s%s%s%s", - &ipv4_address, &ipv4_gate, &ipv4_DHCP, &ipv4_pDNS, &ipv4_sDNS, - &ipv6_address, &ipv6_gate, &ipv6_DHCP, &ipv6_pDNS, &ipv6_sDNS); - if (err > 0) { -#if 0 - dbg_time("%s,%s,%s,%s,%s,%s,%s,%s,%s,%s", - ipv4_address, ipv4_gate, ipv4_DHCP, ipv4_pDNS, ipv4_sDNS, - ipv6_address, ipv6_gate, ipv6_DHCP, ipv6_pDNS, ipv6_sDNS); -#endif - - if (ipv4_address && ipv4_address[0]) { - int addr[4] = {0, 0, 0, 0}; - - if (strstr(ipv4_address, ".")) { - sscanf(ipv4_address, "%d.%d.%d.%d", &addr[0], &addr[1], &addr[2], &addr[3]); - } - else { - sscanf(ipv4_address, "%02X%02X%02X%02X", &addr[3], &addr[2], &addr[1], &addr[0]); - } - *pV4Addr = (addr[0]) | (addr[1]<<8) | (addr[2]<<16) | (addr[3]<<24); - } - } - -_error: - safe_at_response_free(p_response); - return 0; -} - -static int requestQueryDataCall(UCHAR *pConnectionStatus, int curIpFamily) { - int err; - ATResponse *p_response = NULL; - ATLine *p_cur = NULL; - int state = 0; - int bind = 0; - int cid; - int pdp = s_pdp; - unsigned int v4Addr = 0; - - (void)curIpFamily; - - *pConnectionStatus = QWDS_PKT_DATA_DISCONNECTED; - - if (!asr_style_atc) { - err = at_netdevstatus(pdp, &v4Addr); - if (!err && v4Addr) { - *pConnectionStatus = QWDS_PKT_DATA_CONNECTED; - //if (profile->ipv4.Address == v4Addr) {} //TODO - } - return err; - } - - err = at_send_command_multiline("AT+QNETDEVCTL?", "+QNETDEVCTL:", &p_response); - if (at_response_error(err, p_response)) - goto _error; - - for (p_cur = p_response->p_intermediates; p_cur != NULL; p_cur = p_cur->p_next) - { - //+QNETDECTL:,,, - err = at_tok_scanf(p_cur->line, "%d%d%d%d", &bind, &cid, NULL, &state); - if (err != 4 || cid != pdp) - continue; - if (bind != 1) - bind = 0; - } - safe_at_response_free(p_response); - - if (bind == 0 || state == 0) - goto _error; - - err = at_send_command_multiline("AT+CGACT?", "+CGACT:", &p_response); - if (at_response_error(err, p_response)) - goto _error; - - for (p_cur = p_response->p_intermediates; p_cur != NULL; p_cur = p_cur->p_next) - { - state = 0; - err = at_tok_scanf(p_cur->line, "%d%d", &cid, &state); - if (cid == pdp) - break; - else if(state) - state = 0; - } - safe_at_response_free(p_response); - - if (bind && state) - *pConnectionStatus = QWDS_PKT_DATA_CONNECTED; - -_error: - safe_at_response_free(p_response); - //dbg_time("%s err=%d, call_state=%d", __func__, err, *pConnectionStatus); - return 0; -} - -static int requestDeactivateDefaultPDP(PROFILE_T *profile, int curIpFamily) { - char *cmd = NULL; - int pdp = profile->pdp; - - (void)curIpFamily; - - if (asr_style_atc) - asprintf(&cmd, "AT+QNETDEVCTL=0,%d,%d", pdp, 0); - else - asprintf(&cmd, "AT+QNETDEVCTL=%d,0,%d", pdp, 0); - at_send_command(cmd, NULL); - safe_free(cmd); - - //dbg_time("%s err=%d", __func__, err); - return 0; -} - -static int requestGetIPAddress(PROFILE_T *profile, int curIpFamily) { - int err; - ATResponse *p_response = NULL; - char *cmd = NULL; - ATLine *p_cur = NULL; - int pdp = profile->pdp; - unsigned int v4Addr = 0; - - (void)curIpFamily; - - if (!asr_style_atc) { - err = at_netdevstatus(pdp, &v4Addr); - goto _error; - } - - asprintf(&cmd, "AT+CGPADDR=%d", profile->pdp); - err = at_send_command_singleline(cmd, "+CGPADDR:", &p_response); - safe_free(cmd); - if (at_response_error(err, p_response)) - goto _error; - - //+CGPADDR: 1,"10.201.80.91","2409:8930:4B3:41C7:F9B8:3D9B:A2F7:CA96" - for (p_cur = p_response->p_intermediates; p_cur != NULL; p_cur = p_cur->p_next) - { - char *ipv4 = NULL; - char *ipv6 = NULL; - - err = at_tok_scanf(p_cur->line, "%d%s%s", &pdp, &ipv4, &ipv6); - if (err < 2 || pdp != profile->pdp) - continue; - - if (ipv4) { - int addr[4] = {0, 0, 0, 0}; - - sscanf(ipv4, "%d.%d.%d.%d", &addr[0], &addr[1], &addr[2], &addr[3]); - v4Addr = (addr[0]) | (addr[1]<<8) | (addr[2]<<16) | (addr[3]<<24); - break; - } - } - -_error: - if (v4Addr && profile->ipv4.Address != v4Addr) { - unsigned char *v4 = (unsigned char *)&v4Addr; - - profile->ipv4.Address = v4Addr; - dbg_time("%s %d.%d.%d.%d", __func__, v4[0], v4[1], v4[2], v4[3]); - } - - //dbg_time("%s err=%d", __func__, err); - return v4Addr ? 0 : -1; -} - -static int requestGetSignalInfo(void) { - int retVal = -1; - int err; - ATResponse *p_response = NULL; - int i; - ATLine *p_cur = NULL; - char *rat = NULL; - int cops_act = 0; - int is_nr5g_nsa = 0, nr5g_sa = 0; - int verbose = 0; - - err = at_send_command_singleline("at+cops?", "+COPS:", &p_response); - if (at_response_error(err, p_response)) goto _error; - if (!p_response->p_intermediates || !p_response->p_intermediates->line) goto _error; - - retVal = 0; - err = at_tok_scanf(p_response->p_intermediates->line, "%d%d%s%d", NULL, NULL, NULL, &cops_act); - if (err != 4) goto _error; - - nr5g_sa = (cops_act == 11); - - safe_at_response_free(p_response); - err = at_send_command_multiline("at+qeng=\"servingcell\"", "+QENG:", &p_response); - if (at_response_error(err, p_response)) - goto _error; - - for (i = 0, p_cur = p_response->p_intermediates; p_cur != NULL; p_cur = p_cur->p_next, i++) { - char *type, *state; - - err = at_tok_scanf(p_cur->line, "%s%s", &type, &state); - if (err != 2 || strcmp(type, "servingcell")) - continue; - - if (!strcmp(state, "SEARCH") || !strcmp(state, "LIMSRV")) - continue; - - if (!strcmp(state, "NOCONN") || !strcmp(state, "CONNECT")) { - err = at_tok_scanf(p_cur->line, "%s%s%s", &type, &state, &rat); - if (err != 3) - continue; - } - else { - rat = state; - } - - if (!strcmp(rat, "NR5G-SA")) - { - //+QENG: "servingcell",,"NR5G-SA",,,,,,,,,,,,,, - //+QENG: "servingcell","NOCONN","NR5G-SA","TDD", 454,12,0,21,4ED,636576,78,3,-85,-11,32,0,5184 - struct qeng_servingcell_nr5g_sa { - char *cell_type, *state, *rat, *is_tdd; - int MCC, MNC, cellID/*hex*/; - int PCID, TAC/*hex*/, ARFCN; - int band, NR_DL_bandwidth; - int RSRP, RSRQ, RSSI, SINR; - }; - struct qeng_servingcell_nr5g_sa nr5g_sa; - - memset(&nr5g_sa, 0, sizeof(nr5g_sa)); - err = at_tok_scanf(p_cur->line, "%s,%s,%s,%s,%d,%d,%x,%d,%x,%d,%d,%d,%d,%d,%d,%d", - &nr5g_sa.cell_type, &nr5g_sa.state, &nr5g_sa.rat, &nr5g_sa.is_tdd, - &nr5g_sa.MCC, &nr5g_sa.MNC, &nr5g_sa.cellID, &nr5g_sa.PCID, &nr5g_sa.TAC, - &nr5g_sa.ARFCN, &nr5g_sa.band, &nr5g_sa.NR_DL_bandwidth, - &nr5g_sa.RSRP, &nr5g_sa.RSRQ, &nr5g_sa.RSSI, &nr5g_sa.SINR); - - if (err >= 13 && verbose) { - dbg_time("%s,%s,%s,%s,%d,%d,%x,%d,%x,%d,%d,%d,%d,%d,%d,%d", - nr5g_sa.cell_type, nr5g_sa.state, nr5g_sa.rat, nr5g_sa.is_tdd, - nr5g_sa.MCC, nr5g_sa.MNC, nr5g_sa.cellID, nr5g_sa.PCID, nr5g_sa.TAC, - nr5g_sa.ARFCN, nr5g_sa.band, nr5g_sa.NR_DL_bandwidth, - nr5g_sa.RSRP, nr5g_sa.RSRQ, nr5g_sa.RSSI, nr5g_sa.SINR); - } - } - else if (!strcmp(rat, "NR5G-NSA")) - { - //+QENG: "NR5G-NSA",,,,,< SINR>,,, - struct qeng_servingcell_nr5g_nsa { - char *mcc, *mnc; - int pcid, rsrp, sinr, rsrq; - }; - struct qeng_servingcell_nr5g_nsa nr5g_nsa; - - memset(&nr5g_nsa, 0, sizeof(nr5g_nsa)); - err = at_tok_scanf(p_cur->line, "%s%s%s%s%d%d%d%dd", - NULL, NULL, &nr5g_nsa.mcc, &nr5g_nsa.mnc, &nr5g_nsa.pcid, &nr5g_nsa.rsrp, &nr5g_nsa.sinr, &nr5g_nsa.rsrq); - if (err == 8 && verbose) - { - dbg_time("mcc=%s, mnc=%s, pcid=%d, rsrp=%d, sinr=%d, rsrq=%d", - nr5g_nsa.mcc, nr5g_nsa.mnc, nr5g_nsa.pcid, nr5g_nsa.rsrp, nr5g_nsa.sinr, nr5g_nsa.rsrq); - } - - is_nr5g_nsa = 1; - } - else if (!strcmp(rat, "LTE")) - { - //+QENG: "LTE",,,,,,,,,,,,,,,,, - struct qeng_servingcell_lte { - char *is_tdd, *mcc, *mnc; - int cellID/*hex*/, pcid, earfcn, freq_band_ind, ul_bandwidth, dl_bandwidth; - int tac/*hex*/, rsrp, rsrq, rssi, sinr, cqi,tx_power,srxlev; - }; - struct qeng_servingcell_lte lte; - - memset(<e, 0, sizeof(lte)); - if (!strcmp(rat, state)) - err = at_tok_scanf(p_cur->line, "%s%s%s%s%s%x%d%d%d%d%d%x%d%d%d%d%d%d%d", - NULL, NULL, <e.is_tdd, <e.mcc, <e.mnc, - <e.cellID, <e.pcid, <e.earfcn, <e.freq_band_ind, <e.ul_bandwidth, <e.dl_bandwidth, - <e.tac, <e.rsrp, <e.rsrq, <e.rssi, <e.sinr, <e.cqi, <e.tx_power, <e.srxlev); - else - err = at_tok_scanf(p_cur->line, "%s%s%s%s%s%s%x%d%d%d%d%d%x%d%d%d%d%d%d%d", - NULL, NULL, NULL, <e.is_tdd, <e.mcc, <e.mnc, - <e.cellID, <e.pcid, <e.earfcn, <e.freq_band_ind, <e.ul_bandwidth, <e.dl_bandwidth, - <e.tac, <e.rsrp, <e.rsrq, <e.rssi, <e.sinr, <e.cqi, <e.tx_power, <e.srxlev); - - if (err >= 18 && verbose) - { - dbg_time("is_tdd=%s, mcc=%s, mnc=%s", lte.is_tdd, lte.mcc, lte.mnc); - dbg_time("cellID=%x, pcid=%d, earfcn=%d", lte.cellID, lte.pcid, lte.earfcn); - dbg_time("freq_band_ind=%d, ul_bandwidth=%d, dl_bandwidth=%d", lte.freq_band_ind, lte.ul_bandwidth, lte.dl_bandwidth); - dbg_time("tac=%x, rsrp=%d, rsrq=%d, rssi=%d, sinr=%d", lte.tac, lte.rsrp, lte.rsrq, lte.rssi, lte.sinr); - dbg_time("cqi=%d, tx_power=%d, earfcn=%d", lte.cqi, lte.tx_power, lte.srxlev); - } - } - } - - if (is_nr5g_nsa) { - int endc_avl, plmn_info_list_r15_avl, endc_rstr, nr5g_basic; - - is_nr5g_nsa = 0; - safe_at_response_free(p_response); - err = at_send_command_multiline("at+qendc", "+QENDC:", &p_response); - if (at_response_error(err, p_response)) goto _error; - if (!p_response->p_intermediates || !p_response->p_intermediates->line) goto _error; - - err = at_tok_scanf(p_response->p_intermediates->line, "%d%d%d%d", - &endc_avl, &plmn_info_list_r15_avl, &endc_rstr, &nr5g_basic); - if (err == 4 && nr5g_basic) { - is_nr5g_nsa = 1; - } - } - - if (verbose) - dbg_time("cops_act=%d, nr5g_nsa=%d, nr5g_sa=%d", cops_act, is_nr5g_nsa, nr5g_sa); - -_error: - safe_at_response_free(p_response); - return retVal; -} - -static int requestGetICCID(void) { - int retVal = -1; - int err; - ATResponse *p_response = NULL; - char *iccid; - - err = at_send_command_singleline("AT+QCCID", "+QCCID:", &p_response); - if (at_response_error(err, p_response)) goto _error; - if (!p_response->p_intermediates || !p_response->p_intermediates->line) goto _error; - - err = at_tok_scanf(p_response->p_intermediates->line, "%s", &iccid); - if (err != 1) goto _error; - - if (iccid && iccid[0]) { - dbg_time("%s %s", __func__, iccid); - retVal = 0; - } - -_error: - safe_at_response_free(p_response); - return retVal; -} - -static int requestGetIMSI(void) { - int retVal = -1; - int err; - ATResponse *p_response = NULL; - char *imsi; - - err = at_send_command_numeric("AT+CIMI", &p_response); - if (at_response_error(err, p_response)) goto _error; - if (!p_response->p_intermediates || !p_response->p_intermediates->line) goto _error; - - imsi = p_response->p_intermediates->line; - if (imsi) { - dbg_time("%s %s", __func__, imsi); - retVal = 0; - } - -_error: - safe_at_response_free(p_response); - return retVal; -} - -const struct request_ops atc_request_ops = { - .requestBaseBandVersion = requestBaseBandVersion, - .requestGetSIMStatus = requestGetSIMStatus, - .requestEnterSimPin = requestEnterSimPin, - .requestSetProfile = requestSetProfile, - .requestGetProfile = requestGetProfile, - .requestRegistrationState = requestRegistrationState, - .requestSetupDataCall = requestSetupDataCall, - .requestQueryDataCall = requestQueryDataCall, - .requestDeactivateDefaultPDP = requestDeactivateDefaultPDP, - .requestGetIPAddress = requestGetIPAddress, - .requestGetSignalInfo = requestGetSignalInfo, - .requestGetICCID = requestGetICCID, - .requestGetIMSI = requestGetIMSI, -}; - diff --git a/quectel_cm_5G/src/atchannel.c b/quectel_cm_5G/src/atchannel.c deleted file mode 100644 index 90aa1c4..0000000 --- a/quectel_cm_5G/src/atchannel.c +++ /dev/null @@ -1,1037 +0,0 @@ -/* //device/system/reference-ril/atchannel.c -** -** Copyright 2006, The Android Open Source Project -** -** Licensed under the Apache License, Version 2.0 (the "License"); -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at -** -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and -** limitations under the License. -*/ - -#include "atchannel.h" -#include "at_tok.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "QMIThread.h" -#define LOGE dbg_time -#define LOGD dbg_time - -#define NUM_ELEMS(x) (sizeof(x)/sizeof(x[0])) - -#define MAX_AT_RESPONSE sizeof(cm_recv_buf) -#define HANDSHAKE_RETRY_COUNT 8 -#define HANDSHAKE_TIMEOUT_MSEC 1000 - -static pthread_t s_tid_reader; -static int s_fd = -1; /* fd of the AT channel */ -static ATUnsolHandler s_unsolHandler; -static int s_atc_proxy = 0; /* fd of the AT channel */ - -/* for input buffering */ - -static char *s_ATBuffer = (char *)cm_recv_buf; -static char *s_ATBufferCur = (char *)cm_recv_buf; - -static int s_readCount = 0; - -#if AT_DEBUG -void AT_DUMP(const char* prefix, const char* buff, int len) -{ - if (len < 0) - len = strlen(buff); - LOGD("%.*s", len, buff); -} -#endif - -/* - * for current pending command - * these are protected by s_commandmutex - */ -static ATCommandType s_type; -static const char *s_responsePrefix = NULL; -static const char *s_smsPDU = NULL; -static const char *s_raw_data = NULL; -static size_t s_raw_len; -static ATResponse *sp_response = NULL; - -static void (*s_onTimeout)(void) = NULL; -static void (*s_onReaderClosed)(void) = NULL; -static int s_readerClosed; - -static void onReaderClosed(); -static int writeCtrlZ (const char *s); -static int writeline (const char *s); -static int writeraw (const char *s, size_t len); - -static void sleepMsec(long long msec) -{ - struct timespec ts; - int err; - - ts.tv_sec = (msec / 1000); - ts.tv_nsec = (msec % 1000) * 1000 * 1000; - - do { - err = nanosleep (&ts, &ts); - } while (err < 0 && errno == EINTR); -} - -/** returns 1 if line starts with prefix, 0 if it does not */ -int strStartsWith(const char *line, const char *prefix) -{ - for ( ; *line != '\0' && *prefix != '\0' ; line++, prefix++) { - if (*line != *prefix) { - return 0; - } - } - - return *prefix == '\0'; -} - -/** add an intermediate response to sp_response*/ -static void addIntermediate(const char *line) -{ - ATLine *p_new; - - p_new = (ATLine *) malloc(sizeof(ATLine)); - - p_new->line = strdup(line); - - /* note: this adds to the head of the list, so the list - will be in reverse order of lines received. the order is flipped - again before passing on to the command issuer */ - p_new->p_next = sp_response->p_intermediates; - sp_response->p_intermediates = p_new; -} - - -/** - * returns 1 if line is a final response indicating error - * See 27.007 annex B - * WARNING: NO CARRIER and others are sometimes unsolicited - */ -static const char * s_finalResponsesError[] = { - "ERROR", - "+CMS ERROR:", - "+CME ERROR:", - "NO CARRIER", /* sometimes! */ - "NO ANSWER", - "NO DIALTONE", - "COMMAND NOT SUPPORT", -}; -static int isFinalResponseError(const char *line) -{ - size_t i; - - for (i = 0 ; i < NUM_ELEMS(s_finalResponsesError) ; i++) { - if (strStartsWith(line, s_finalResponsesError[i])) { - return 1; - } - } - - return 0; -} - -/** - * returns 1 if line is a final response indicating success - * See 27.007 annex B - * WARNING: NO CARRIER and others are sometimes unsolicited - */ -static const char * s_finalResponsesSuccess[] = { - "OK", - "+QIND: \"FOTA\",\"END\",0", - "CONNECT" /* some stacks start up data on another channel */ -}; - -static int isFinalResponseSuccess(const char *line) -{ - size_t i; - - for (i = 0 ; i < NUM_ELEMS(s_finalResponsesSuccess) ; i++) { - if (strStartsWith(line, s_finalResponsesSuccess[i])) { - return 1; - } - } - - return 0; -} - -#if 0 -/** - * returns 1 if line is a final response, either error or success - * See 27.007 annex B - * WARNING: NO CARRIER and others are sometimes unsolicited - */ -static int isFinalResponse(const char *line) -{ - return isFinalResponseSuccess(line) || isFinalResponseError(line); -} -#endif - -/** - * returns 1 if line is the first line in (what will be) a two-line - * SMS unsolicited response - */ -static const char * s_smsUnsoliciteds[] = { - "+CMT:", - "+CDS:", - "+CBM:", - "+CMTI:" -}; -static int isSMSUnsolicited(const char *line) -{ - size_t i; - - for (i = 0 ; i < NUM_ELEMS(s_smsUnsoliciteds) ; i++) { - if (strStartsWith(line, s_smsUnsoliciteds[i])) { - return 1; - } - } - - return 0; -} - - -/** assumes s_commandmutex is held */ -static void handleFinalResponse(const char *line) -{ - sp_response->finalResponse = strdup(line); - - pthread_cond_signal(&cm_command_cond); -} - -static void handleUnsolicited(const char *line) -{ - if (s_unsolHandler != NULL) { - s_unsolHandler(line, NULL); - } -} - -static void processLine(const char *line) -{ - pthread_mutex_lock(&cm_command_mutex); - - if (sp_response == NULL) { - /* no command pending */ - handleUnsolicited(line); - } else if (s_raw_data != NULL && 0 == strcmp(line, "CONNECT")) { - usleep(500*1000); //for EC20 - writeraw(s_raw_data, s_raw_len); - s_raw_data = NULL; - } else if (isFinalResponseSuccess(line)) { - if(s_atc_proxy) - handleUnsolicited(line); - sp_response->success = 1; - handleFinalResponse(line); - } else if (isFinalResponseError(line)) { - if(s_atc_proxy) - handleUnsolicited(line); - sp_response->success = 0; - handleFinalResponse(line); - } else if (s_smsPDU != NULL && 0 == strcmp(line, "> ")) { - // See eg. TS 27.005 4.3 - // Commands like AT+CMGS have a "> " prompt - writeCtrlZ(s_smsPDU); - s_smsPDU = NULL; - } else switch (s_type) { - case NO_RESULT: - handleUnsolicited(line); - break; - case NUMERIC: - if (sp_response->p_intermediates == NULL - && isdigit(line[0]) - ) { - addIntermediate(line); - } else { - /* either we already have an intermediate response or - the line doesn't begin with a digit */ - handleUnsolicited(line); - } - break; - case SINGLELINE: - if (sp_response->p_intermediates == NULL - && strStartsWith (line, s_responsePrefix) - ) { - addIntermediate(line); - } else { - /* we already have an intermediate response */ - handleUnsolicited(line); - } - break; - case MULTILINE: - if (strStartsWith (line, s_responsePrefix)) { - addIntermediate(line); - } else { - handleUnsolicited(line); - } - break; - - default: /* this should never be reached */ - LOGE("Unsupported AT command type %d\n", s_type); - handleUnsolicited(line); - break; - } - - pthread_mutex_unlock(&cm_command_mutex); -} - - -/** - * Returns a pointer to the end of the next line - * special-cases the "> " SMS prompt - * - * returns NULL if there is no complete line - */ -static char * findNextEOL(char *cur) -{ - if (cur[0] == '>' && cur[1] == ' ' && cur[2] == '\0') { - /* SMS prompt character...not \r terminated */ - return cur+2; - } - - // Find next newline - while (*cur != '\0' && *cur != '\r' && *cur != '\n') cur++; - - return *cur == '\0' ? NULL : cur; -} - - -/** - * Reads a line from the AT channel, returns NULL on timeout. - * Assumes it has exclusive read access to the FD - * - * This line is valid only until the next call to readline - * - * This function exists because as of writing, android libc does not - * have buffered stdio. - */ - -static const char *readline() -{ - ssize_t count; - - char *p_read = NULL; - char *p_eol = NULL; - char *ret; - - /* this is a little odd. I use *s_ATBufferCur == 0 to - * mean "buffer consumed completely". If it points to a character, than - * the buffer continues until a \0 - */ - if (*s_ATBufferCur == '\0') { - /* empty buffer */ - s_ATBufferCur = s_ATBuffer; - *s_ATBufferCur = '\0'; - p_read = s_ATBuffer; - } else { /* *s_ATBufferCur != '\0' */ - /* there's data in the buffer from the last read */ - - // skip over leading newlines - while (*s_ATBufferCur == '\r' || *s_ATBufferCur == '\n') - s_ATBufferCur++; - - p_eol = findNextEOL(s_ATBufferCur); - - if (p_eol == NULL) { - /* a partial line. move it up and prepare to read more */ - size_t len; - - len = strlen(s_ATBufferCur); - - memmove(s_ATBuffer, s_ATBufferCur, len + 1); - p_read = s_ATBuffer + len; - s_ATBufferCur = s_ATBuffer; - } - /* Otherwise, (p_eol !- NULL) there is a complete line */ - /* that will be returned the while () loop below */ - } - - while (p_eol == NULL) { - if (0 == MAX_AT_RESPONSE - (p_read - s_ATBuffer)) { - LOGE("ERROR: Input line exceeded buffer\n"); - /* ditch buffer and start over again */ - s_ATBufferCur = s_ATBuffer; - *s_ATBufferCur = '\0'; - p_read = s_ATBuffer; - } - - do { - while (s_fd > 0) { - struct pollfd pollfds[1] = {{s_fd, POLLIN, 0}}; - int ret; - - do { - ret = poll(pollfds, 1, -1); - } while ((ret < 0) && (errno == EINTR)); - - if (pollfds[0].revents & (POLLERR | POLLHUP | POLLNVAL)) { - break; - } else if (pollfds[0].revents & (POLLIN)) { - break; - } - }; - - count = (s_fd == -1) ? 0 : read(s_fd, p_read, - MAX_AT_RESPONSE - (p_read - s_ATBuffer)); - } while (count < 0 && errno == EINTR); - - if (count > 0) { - AT_DUMP( "<< ", p_read, count ); - s_readCount += count; - - p_read[count] = '\0'; - - // skip over leading newlines - while (*s_ATBufferCur == '\r' || *s_ATBufferCur == '\n') - s_ATBufferCur++; - - p_eol = findNextEOL(s_ATBufferCur); - p_read += count; - } else if (count <= 0) { - /* read error encountered or EOF reached */ - if(count == 0) { - LOGD("atchannel: EOF reached"); - } else { - LOGD("atchannel: read error %s", strerror(errno)); - } - return NULL; - } - } - - /* a full line in the buffer. Place a \0 over the \r and return */ - - ret = s_ATBufferCur; - *p_eol = '\0'; - s_ATBufferCur = p_eol + 1; /* this will always be <= p_read, */ - /* and there will be a \0 at *p_read */ - - LOGD("AT< %s", ret); - return ret; -} - - -static void onReaderClosed() -{ - LOGE("%s", __func__); - if (s_onReaderClosed != NULL && s_readerClosed == 0) { - - pthread_mutex_lock(&cm_command_mutex); - - s_readerClosed = 1; - - pthread_cond_signal(&cm_command_cond); - - pthread_mutex_unlock(&cm_command_mutex); - - s_onReaderClosed(); - } -} - - -static void *readerLoop(void *arg) -{ - (void)arg; - - for (;;) { - const char * line; - - line = readline(); - - if (line == NULL) { - break; - } - - if(isSMSUnsolicited(line)) { - char *line1; - const char *line2; - - // The scope of string returned by 'readline()' is valid only - // till next call to 'readline()' hence making a copy of line - // before calling readline again. - line1 = strdup(line); - line2 = readline(); - - if (line2 == NULL) { - break; - } - - if (s_unsolHandler != NULL) { - s_unsolHandler (line1, line2); - } - free(line1); - } else { - processLine(line); - } - } - - onReaderClosed(); - - return NULL; -} - -/** - * Sends string s to the radio with a \r appended. - * Returns AT_ERROR_* on error, 0 on success - * - * This function exists because as of writing, android libc does not - * have buffered stdio. - */ -static int writeline (const char *s) -{ - size_t cur = 0; - size_t len = strlen(s); - ssize_t written; - static char at_command[64]; - - if (s_fd < 0 || s_readerClosed > 0) { - return AT_ERROR_CHANNEL_CLOSED; - } - - LOGD("AT> %s", s); - - AT_DUMP( ">> ", s, strlen(s) ); - -#if 1 //send '\r' maybe fail via USB controller: Intel Corporation 7 Series/C210 Series Chipset Family USB xHCI Host Controller (rev 04) - if (len < (sizeof(at_command) - 1)) { - strcpy(at_command, s); - at_command[len++] = '\r'; - s = (const char *)at_command; - } -#endif - - /* the main string */ - while (cur < len) { - do { - written = write (s_fd, s + cur, len - cur); - } while (written < 0 && errno == EINTR); - - if (written < 0) { - return AT_ERROR_GENERIC; - } - - cur += written; - } - -#if 1 //Quectel send '\r' maybe fail via USB controller: Intel Corporation 7 Series/C210 Series Chipset Family USB xHCI Host Controller (rev 04) - if (s == (const char *)at_command) { - return 0; - } -#endif - - /* the \r */ - - do { - written = write (s_fd, "\r" , 1); - } while ((written < 0 && errno == EINTR) || (written == 0)); - - if (written < 0) { - return AT_ERROR_GENERIC; - } - - return 0; -} -static int writeCtrlZ (const char *s) -{ - size_t cur = 0; - size_t len = strlen(s); - ssize_t written; - - if (s_fd < 0 || s_readerClosed > 0) { - return AT_ERROR_CHANNEL_CLOSED; - } - - LOGD("AT> %s^Z", s); - - AT_DUMP( ">* ", s, strlen(s) ); - - /* the main string */ - while (cur < len) { - do { - written = write (s_fd, s + cur, len - cur); - } while (written < 0 && errno == EINTR); - - if (written < 0) { - return AT_ERROR_GENERIC; - } - - cur += written; - } - - /* the ^Z */ - - do { - written = write (s_fd, "\032" , 1); - } while ((written < 0 && errno == EINTR) || (written == 0)); - - if (written < 0) { - return AT_ERROR_GENERIC; - } - - return 0; -} - -static int writeraw (const char *s, size_t len) { - size_t cur = 0; - ssize_t written; - - if (s_fd < 0 || s_readerClosed > 0) { - return AT_ERROR_CHANNEL_CLOSED; - } - - /* the main string */ - while (cur < len) { - struct pollfd pollfds[1] = {{s_fd, POLLOUT, 0}}; - int ret; - - ret = poll(pollfds, 1, -1); - if (ret <= 0) - break; - - do { - written = write (s_fd, s + cur, len - cur); - } while (written < 0 && errno == EINTR); - - if (written < 0) { - return AT_ERROR_GENERIC; - } - - cur += written; - } - - if (written < 0) { - return AT_ERROR_GENERIC; - } - - return cur; -} - -static void clearPendingCommand() -{ - if (sp_response != NULL) { - at_response_free(sp_response); - } - - sp_response = NULL; - s_responsePrefix = NULL; - s_smsPDU = NULL; -} - - -/** - * Starts AT handler on stream "fd' - * returns 0 on success, -1 on error - */ -int at_open(int fd, ATUnsolHandler h, int proxy) -{ - int ret; - pthread_attr_t attr; - - s_fd = fd; - s_unsolHandler = h; - s_readerClosed = 0; - s_atc_proxy = proxy; - - s_responsePrefix = NULL; - s_smsPDU = NULL; - sp_response = NULL; - - pthread_attr_init (&attr); - pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); - - ret = pthread_create(&s_tid_reader, &attr, readerLoop, NULL); - - if (ret < 0) { - LOGE("readerLoop create fail!"); - perror ("pthread_create\n"); - return -1; - } - - return 0; -} - -/* FIXME is it ok to call this from the reader and the command thread? */ -void at_close() -{ - dbg_time("at_close"); - if (s_fd >= 0) { - close(s_fd); - } - s_fd = -1; - - pthread_mutex_lock(&cm_command_mutex); - - s_readerClosed = 1; - - pthread_cond_signal(&cm_command_cond); - - pthread_mutex_unlock(&cm_command_mutex); - - /* the reader thread should eventually die */ -} - -static ATResponse * at_response_new() -{ - return (ATResponse *) calloc(1, sizeof(ATResponse)); -} - -void at_response_free(ATResponse *p_response) -{ - ATLine *p_line; - - if (p_response == NULL) return; - - p_line = p_response->p_intermediates; - - while (p_line != NULL) { - ATLine *p_toFree; - - p_toFree = p_line; - p_line = p_line->p_next; - - free(p_toFree->line); - free(p_toFree); - } - - free (p_response->finalResponse); - free (p_response); -} - -/** - * The line reader places the intermediate responses in reverse order - * here we flip them back - */ -static void reverseIntermediates(ATResponse *p_response) -{ - ATLine *pcur,*pnext; - - pcur = p_response->p_intermediates; - p_response->p_intermediates = NULL; - - while (pcur != NULL) { - pnext = pcur->p_next; - pcur->p_next = p_response->p_intermediates; - p_response->p_intermediates = pcur; - pcur = pnext; - } -} - -/** - * Internal send_command implementation - * Doesn't lock or call the timeout callback - * - * timeoutMsec == 0 means infinite timeout - */ -static int at_send_command_full_nolock (const char *command, ATCommandType type, - const char *responsePrefix, const char *smspdu, - long long timeoutMsec, ATResponse **pp_outResponse) -{ - int err = 0; - - if (!timeoutMsec) - timeoutMsec = 15000; - - if(sp_response != NULL) { - err = AT_ERROR_COMMAND_PENDING; - goto error; - } - - if (command != NULL) - err = writeline (command); - - if (err < 0) { - printf("%s errno: %d (%s)\n", __func__, errno, strerror(errno)); - goto error; - } - - s_type = type; - s_responsePrefix = responsePrefix; - s_smsPDU = smspdu; - sp_response = at_response_new(); - - while (sp_response->finalResponse == NULL && s_readerClosed == 0) { - err = pthread_cond_timeout_np(&cm_command_cond, &cm_command_mutex, timeoutMsec); - - if (err == ETIMEDOUT) { - err = AT_ERROR_TIMEOUT; - goto error; - } - } - - if (pp_outResponse == NULL) { - at_response_free(sp_response); - } else { - /* line reader stores intermediate responses in reverse order */ - reverseIntermediates(sp_response); - *pp_outResponse = sp_response; - } - - sp_response = NULL; - - if(s_readerClosed > 0) { - err = AT_ERROR_CHANNEL_CLOSED; - goto error; - } - - err = 0; -error: - clearPendingCommand(); - - return err; -} - -/** - * Internal send_command implementation - * - * timeoutMsec == 0 means infinite timeout - */ -static int at_send_command_full (const char *command, ATCommandType type, - const char *responsePrefix, const char *smspdu, - long long timeoutMsec, ATResponse **pp_outResponse) -{ - int err; - - if (0 != pthread_equal(s_tid_reader, pthread_self())) { - /* cannot be called from reader thread */ - return AT_ERROR_INVALID_THREAD; - } - - pthread_mutex_lock(&cm_command_mutex); - - err = at_send_command_full_nolock(command, type, - responsePrefix, smspdu, - timeoutMsec, pp_outResponse); - - pthread_mutex_unlock(&cm_command_mutex); - - if (err == AT_ERROR_TIMEOUT && s_onTimeout != NULL) { - s_onTimeout(); - } - - return err; -} - - -/** - * Issue a single normal AT command with no intermediate response expected - * - * "command" should not include \r - * pp_outResponse can be NULL - * - * if non-NULL, the resulting ATResponse * must be eventually freed with - * at_response_free - */ -int at_send_command (const char *command, ATResponse **pp_outResponse) -{ - int err; - - err = at_send_command_full (command, NO_RESULT, NULL, - NULL, 0, pp_outResponse); - - return err; -} - - -int at_send_command_singleline (const char *command, - const char *responsePrefix, - ATResponse **pp_outResponse) -{ - int err; - - err = at_send_command_full (command, SINGLELINE, responsePrefix, - NULL, 0, pp_outResponse); - - if (err == 0 && pp_outResponse != NULL - && (*pp_outResponse)->success > 0 - && (*pp_outResponse)->p_intermediates == NULL - ) { - /* successful command must have an intermediate response */ - at_response_free(*pp_outResponse); - *pp_outResponse = NULL; - return AT_ERROR_INVALID_RESPONSE; - } - - return err; -} - - -int at_send_command_numeric (const char *command, - ATResponse **pp_outResponse) -{ - int err; - - err = at_send_command_full (command, NUMERIC, NULL, - NULL, 0, pp_outResponse); - - if (err == 0 && pp_outResponse != NULL - && (*pp_outResponse)->success > 0 - && (*pp_outResponse)->p_intermediates == NULL - ) { - /* successful command must have an intermediate response */ - at_response_free(*pp_outResponse); - *pp_outResponse = NULL; - return AT_ERROR_INVALID_RESPONSE; - } - - return err; -} - - -int at_send_command_sms (const char *command, - const char *pdu, - const char *responsePrefix, - ATResponse **pp_outResponse) -{ - int err; - - err = at_send_command_full (command, SINGLELINE, responsePrefix, - pdu, 0, pp_outResponse); - - if (err == 0 && pp_outResponse != NULL - && (*pp_outResponse)->success > 0 - && (*pp_outResponse)->p_intermediates == NULL - ) { - /* successful command must have an intermediate response */ - at_response_free(*pp_outResponse); - *pp_outResponse = NULL; - return AT_ERROR_INVALID_RESPONSE; - } - - return err; -} - -int at_send_command_multiline (const char *command, - const char *responsePrefix, - ATResponse **pp_outResponse) -{ - int err; - - err = at_send_command_full (command, MULTILINE, responsePrefix, - NULL, 0, pp_outResponse); - - return err; -} - -int at_send_command_raw (const char *command, - const char *raw_data, unsigned int raw_len, - const char *responsePrefix, - ATResponse **pp_outResponse) -{ - int err; - - s_raw_data = raw_data; - s_raw_len = raw_len; - err = at_send_command_full (command, SINGLELINE, responsePrefix, - NULL, 0, pp_outResponse); - - return err; -} - -/** - * Periodically issue an AT command and wait for a response. - * Used to ensure channel has start up and is active - */ - -int at_handshake() -{ - int i; - int err = 0; - - if (0 != pthread_equal(s_tid_reader, pthread_self())) { - /* cannot be called from reader thread */ - return AT_ERROR_INVALID_THREAD; - } - - pthread_mutex_lock(&cm_command_mutex); - - for (i = 0 ; i < HANDSHAKE_RETRY_COUNT ; i++) { - /* some stacks start with verbose off */ - err = at_send_command_full_nolock ("ATE0Q0V1", NO_RESULT, - NULL, NULL, HANDSHAKE_TIMEOUT_MSEC, NULL); - - if (err == 0) { - break; - } - } - - pthread_mutex_unlock(&cm_command_mutex); - - if (err == 0) { - /* pause for a bit to let the input buffer drain any unmatched OK's - (they will appear as extraneous unsolicited responses) */ - - sleepMsec(HANDSHAKE_TIMEOUT_MSEC); - } - - return err; -} - -AT_CME_Error at_get_cme_error(const ATResponse *p_response) -{ - int ret; - int err; - char *p_cur; - - if (p_response == NULL) - return CME_ERROR_NON_CME; - - if (p_response->success > 0) { - return CME_SUCCESS; - } - - if (p_response->finalResponse == NULL - || !strStartsWith(p_response->finalResponse, "+CME ERROR:") - ) { - return CME_ERROR_NON_CME; - } - - p_cur = p_response->finalResponse; - err = at_tok_start(&p_cur); - - if (err < 0) { - return CME_ERROR_NON_CME; - } - - err = at_tok_nextint(&p_cur, &ret); - - if (err < 0) { - return CME_ERROR_NON_CME; - } - - return (AT_CME_Error) ret; -} - -/** This callback is invoked on the command thread */ -void at_set_on_timeout(void (*onTimeout)(void)) -{ - s_onTimeout = onTimeout; -} - -/** - * This callback is invoked on the reader thread (like ATUnsolHandler) - * when the input stream closes before you call at_close - * (not when you call at_close()) - * You should still call at_close() - */ -void at_set_on_reader_closed(void (*onClose)(void)) -{ - s_onReaderClosed = onClose; -} diff --git a/quectel_cm_5G/src/atchannel.h b/quectel_cm_5G/src/atchannel.h deleted file mode 100644 index cce28b1..0000000 --- a/quectel_cm_5G/src/atchannel.h +++ /dev/null @@ -1,152 +0,0 @@ -/* //device/system/reference-ril/atchannel.h -** -** Copyright 2006, The Android Open Source Project -** -** Licensed under the Apache License, Version 2.0 (the "License"); -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at -** -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and -** limitations under the License. -*/ - -#ifndef ATCHANNEL_H -#define ATCHANNEL_H 1 - -#ifdef __cplusplus -extern "C" { -#endif - -/* define AT_DEBUG to send AT traffic to /tmp/radio-at.log" */ -#define AT_DEBUG 0 - -#if AT_DEBUG -extern void AT_DUMP(const char* prefix, const char* buff, int len); -#else -#define AT_DUMP(prefix,buff,len) do{}while(0) -#endif - -#define AT_ERROR_GENERIC -1 -#define AT_ERROR_COMMAND_PENDING -2 -#define AT_ERROR_CHANNEL_CLOSED -3 -#define AT_ERROR_TIMEOUT -4 -#define AT_ERROR_INVALID_THREAD -5 /* AT commands may not be issued from - reader thread (or unsolicited response - callback */ -#define AT_ERROR_INVALID_RESPONSE -6 /* eg an at_send_command_singleline that - did not get back an intermediate - response */ - - -typedef enum { - NO_RESULT, /* no intermediate response expected */ - NUMERIC, /* a single intermediate response starting with a 0-9 */ - SINGLELINE, /* a single intermediate response starting with a prefix */ - MULTILINE /* multiple line intermediate response - starting with a prefix */ -} ATCommandType; - -/** a singly-lined list of intermediate responses */ -typedef struct ATLine { - struct ATLine *p_next; - char *line; -} ATLine; - -/** Free this with at_response_free() */ -typedef struct { - int success; /* true if final response indicates - success (eg "OK") */ - char *finalResponse; /* eg OK, ERROR */ - ATLine *p_intermediates; /* any intermediate responses */ -} ATResponse; - -/** - * a user-provided unsolicited response handler function - * this will be called from the reader thread, so do not block - * "s" is the line, and "sms_pdu" is either NULL or the PDU response - * for multi-line TS 27.005 SMS PDU responses (eg +CMT:) - */ -typedef void (*ATUnsolHandler)(const char *s, const char *sms_pdu); - -int at_open(int fd, ATUnsolHandler h, int proxy); -void at_close(); - -/* This callback is invoked on the command thread. - You should reset or handshake here to avoid getting out of sync */ -void at_set_on_timeout(void (*onTimeout)(void)); -/* This callback is invoked on the reader thread (like ATUnsolHandler) - when the input stream closes before you call at_close - (not when you call at_close()) - You should still call at_close() - It may also be invoked immediately from the current thread if the read - channel is already closed */ -void at_set_on_reader_closed(void (*onClose)(void)); - -int at_send_command_singleline (const char *command, - const char *responsePrefix, - ATResponse **pp_outResponse); - -int at_send_command_numeric (const char *command, - ATResponse **pp_outResponse); - -int at_send_command_multiline (const char *command, - const char *responsePrefix, - ATResponse **pp_outResponse); - -int at_send_command_raw (const char *command, - const char *raw_data, unsigned int raw_len, - const char *responsePrefix, - ATResponse **pp_outResponse); - -int at_handshake(); - -int at_send_command (const char *command, ATResponse **pp_outResponse); - -int at_send_command_sms (const char *command, const char *pdu, - const char *responsePrefix, - ATResponse **pp_outResponse); - -void at_response_free(ATResponse *p_response); - -int strStartsWith(const char *line, const char *prefix); - -typedef enum { - CME_ERROR_NON_CME = -1, - CME_SUCCESS = 0, - - CME_OPERATION_NOT_ALLOWED = 3, - CME_OPERATION_NOT_SUPPORTED = 4, - CME_PH_SIM_PIN= 5, - CME_PH_FSIM_PIN = 6, - CME_PH_FSIM_PUK = 7, - CME_SIM_NOT_INSERTED =10, - CME_SIM_PIN_REQUIRED = 11, - CME_SIM_PUK_REQUIRED = 12, - CME_FAILURE = 13, - CME_SIM_BUSY = 14, - CME_SIM_WRONG = 15, - CME_INCORRECT_PASSWORD = 16, - CME_SIM_PIN2_REQUIRED = 17, - CME_SIM_PUK2_REQUIRED = 18, - CME_MEMORY_FULL = 20, - CME_INVALID_INDEX = 21, - CME_NOT_FOUND = 22, - CME_MEMORY_FAILURE = 23, - CME_STRING_TO_LONG = 24, - CME_INVALID_CHAR = 25, - CME_DIALSTR_TO_LONG = 26, - CME_INVALID_DIALCHAR = 27, -} AT_CME_Error; - -AT_CME_Error at_get_cme_error(const ATResponse *p_response); - -#ifdef __cplusplus -} -#endif - -#endif /*ATCHANNEL_H*/ diff --git a/quectel_cm_5G/src/configure.ac b/quectel_cm_5G/src/configure.ac deleted file mode 100644 index f4c60ea..0000000 --- a/quectel_cm_5G/src/configure.ac +++ /dev/null @@ -1,48 +0,0 @@ -# -*- Autoconf -*- -# Process this file with autoconf to produce a configure script. - -AC_PREREQ([2.61]) -AC_INIT([quectel-CM], [1.0], [fae-support@quectel.com]) -AC_CONFIG_HEADERS([config.h]) - -# Checks for programs. -AC_PROG_CC - -# Checks for libraries. - -# Checks for header files. - -# Checks for typedefs, structures, and compiler characteristics. -AC_ARG_WITH(sanitized-headers, - AS_HELP_STRING([--with-sanitized-headers=DIR], - [Specify the location of the sanitized Linux headers]), - [CPPFLAGS="$CPPFLAGS -idirafter $withval"]) - -AC_ARG_WITH([qrtr], - AC_HELP_STRING([--with-qrtr], - [enable qrtr, building which use qrtr])) - -if (test "x${with_qrtr}" = "xyes"); then - #AC_DEFINE(ENABLE_USEQTRT, 1, [Define if uses qrtr]) - AC_CHECK_HEADERS([linux/qrtr.h linux/rmnet_data.h]) -fi - -AM_CONDITIONAL(USE_QRTR, test "x${with_qrtr}" = "xyes") - -AC_ARG_WITH([msm-ipc], - AC_HELP_STRING([--with-msm-ipc], - [enable msm-ipc, building which use qrtr])) - -if (test "x${with_msm_ipc}" = "xyes"); then - #AC_DEFINE(ENABLE_USEQTRT, 1, [Define if uses qrtr]) - AC_CHECK_HEADERS([linux/msm_ipc.h linux/rmnet_data.h]) -fi - -AM_CONDITIONAL(USE_MSM_IPC, test "x${with_msm_ipc}" = "xyes") - -# Checks for library functions. - -# Does not strictly follow GNU Coding standards -AM_INIT_AUTOMAKE([foreign subdir-objects]) -AC_CONFIG_FILES([Makefile]) -AC_OUTPUT diff --git a/quectel_cm_5G/src/default.script b/quectel_cm_5G/src/default.script deleted file mode 100644 index 26b95c1..0000000 --- a/quectel_cm_5G/src/default.script +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/sh -# Busybox udhcpc dispatcher script. Copyright (C) 2009 by Axel Beckert. -# -# Based on the busybox example scripts and the old udhcp source -# package default.* scripts. - -RESOLV_CONF="/etc/resolv.conf" - -case $1 in - bound|renew) - [ -n "$broadcast" ] && BROADCAST="broadcast $broadcast" - [ -n "$subnet" ] && NETMASK="netmask $subnet" - - /sbin/ifconfig $interface $ip $BROADCAST $NETMASK - - if [ -n "$router" ]; then - echo "$0: Resetting default routes" - while /sbin/route del default gw 0.0.0.0 dev $interface; do :; done - - metric=0 - for i in $router; do - /sbin/route add default gw $i dev $interface metric $metric - metric=$(($metric + 1)) - done - fi - - # Update resolver configuration file - R="" - [ -n "$domain" ] && R="domain $domain -" - for i in $dns; do - echo "$0: Adding DNS $i" - R="${R}nameserver $i -" - done - - if [ -x /sbin/resolvconf ]; then - echo -n "$R" | resolvconf -a "${interface}.udhcpc" - else - echo -n "$R" > "$RESOLV_CONF" - fi - ;; - - deconfig) - if [ -x /sbin/resolvconf ]; then - resolvconf -d "${interface}.udhcpc" - fi - /sbin/ifconfig $interface 0.0.0.0 - ;; - - leasefail) - echo "$0: Lease failed: $message" - ;; - - nak) - echo "$0: Received a NAK: $message" - ;; - - *) - echo "$0: Unknown udhcpc command: $1"; - exit 1; - ;; -esac diff --git a/quectel_cm_5G/src/default.script_ip b/quectel_cm_5G/src/default.script_ip deleted file mode 100644 index 24f8e59..0000000 --- a/quectel_cm_5G/src/default.script_ip +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/sh -# Busybox udhcpc dispatcher script. Copyright (C) 2009 by Axel Beckert. -# -# Based on the busybox example scripts and the old udhcp source -# package default.* scripts. - -RESOLV_CONF="/etc/resolv.conf" -IPCMD=`which ip` - -case $1 in - bound|renew) - $IPCMD address add broadcast $broadcast $ip/$subnet dev $interface - - if [ -n "$router" ]; then - echo "$0: Resetting default routes" - while $IPCMD route del default dev $interface; do :; done - - metric=0 - for i in $router; do - $IPCMD route add default dev $interface via $router metric $metric - metric=$(($metric + 1)) - done - fi - - # Update resolver configuration file - R="" - [ -n "$domain" ] && R="domain $domain -" - for i in $dns; do - echo "$0: Adding DNS $i" - R="${R}nameserver $i -" - done - - if [ -x /sbin/resolvconf ]; then - echo -n "$R" | resolvconf -a "${interface}.udhcpc" - else - echo -n "$R" > "$RESOLV_CONF" - fi - ;; - - deconfig) - if [ -x /sbin/resolvconf ]; then - resolvconf -d "${interface}.udhcpc" - fi - $IPCMD address flush dev $interface - ;; - - leasefail) - echo "$0: Lease failed: $message" - ;; - - nak) - echo "$0: Received a NAK: $message" - ;; - - *) - echo "$0: Unknown udhcpc command: $1"; - exit 1; - ;; -esac diff --git a/quectel_cm_5G/src/device.c b/quectel_cm_5G/src/device.c deleted file mode 100644 index 6e95405..0000000 --- a/quectel_cm_5G/src/device.c +++ /dev/null @@ -1,768 +0,0 @@ -/****************************************************************************** - @file device.c - @brief QMI device dirver. - - DESCRIPTION - Connectivity Management Tool for USB network adapter of Quectel wireless cellular modules. - - INITIALIZATION AND SEQUENCING REQUIREMENTS - None. - - --------------------------------------------------------------------------- - Copyright (c) 2016 - 2020 Quectel Wireless Solution, Co., Ltd. All Rights Reserved. - Quectel Wireless Solution Proprietary and Confidential. - --------------------------------------------------------------------------- -******************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "QMIThread.h" -#include "ethtool-copy.h" - -#define USB_CLASS_VENDOR_SPEC 0xff -#define USB_CLASS_COMM 2 -#define USB_CDC_SUBCLASS_ACM 0x02 -#define USB_CDC_SUBCLASS_ETHERNET 0x06 -#define USB_CDC_SUBCLASS_NCM 0x0d -#define USB_CDC_SUBCLASS_MBIM 0x0e -#define USB_CLASS_WIRELESS_CONTROLLER 0xe0 - -#define CM_MAX_PATHLEN 256 - -#define CM_INVALID_VAL (~((int)0)) - -/* get first line from file 'fname' - * And convert the content into a hex number, then return this number */ -static int file_get_value(const char *fname, int base) { - FILE *fp = NULL; - long num; - char buff[32 + 1] = {'\0'}; - char *endptr = NULL; - - fp = fopen(fname, "r"); - if (!fp) goto error; - if (fgets(buff, sizeof(buff), fp) == NULL) - goto error; - fclose(fp); - - num = (int) strtol(buff, &endptr, base); - if (errno == ERANGE && (num == LONG_MAX || num == LONG_MIN)) - goto error; - /* if there is no digit in buff */ - if (endptr == buff) - goto error; - - if (debug_qmi) - dbg_time("(%s) = %lx", fname, num); - return (int) num; - - error: - if (fp) fclose(fp); - return CM_INVALID_VAL; -} - -/* - * This function will search the directory 'dirname' and return the first child. - * '.' and '..' is ignored by default - */ -static int dir_get_child(const char *dirname, char *buff, unsigned bufsize, const char *prefix) { - struct dirent *entptr = NULL; - DIR *dirptr; - - buff[0] = 0; - - dirptr = opendir(dirname); - if (!dirptr) - return -1; - - while ((entptr = readdir(dirptr))) { - if (entptr->d_name[0] == '.') - continue; - if (prefix && strlen(prefix) && strncmp(entptr->d_name, prefix, strlen(prefix))) - continue; - snprintf(buff, bufsize, "%.31s", entptr->d_name); - break; - } - closedir(dirptr); - - return 0; -} - -static int conf_get_val(const char *fname, const char *key) { - char buff[128] = {'\0'}; - FILE *fp = fopen(fname, "r"); - if (!fp) - return CM_INVALID_VAL; - - while (fgets(buff, sizeof(buff) - 1, fp)) { - char prefix[128] = {'\0'}; - char tail[128] = {'\0'}; - /* To eliminate cppcheck warnning: Assume string length is no more than 15 */ - sscanf(buff, "%15[^=]=%15s", prefix, tail); - if (!strncasecmp(prefix, key, strlen(key))) { - fclose(fp); - return atoi(tail); - } - } - - fclose(fp); - return CM_INVALID_VAL; -} - -static void query_usb_device_info(char *path, struct usb_device_info *p) { - size_t offset = strlen(path); - - memset(p, 0, sizeof(*p)); - - path[offset] = '\0'; - strcat(path, "/idVendor"); - p->idVendor = file_get_value(path, 16); - - if (p->idVendor == CM_INVALID_VAL) - return; - - path[offset] = '\0'; - strcat(path, "/idProduct"); - p->idProduct = file_get_value(path, 16); - - path[offset] = '\0'; - strcat(path, "/busnum"); - p->busnum = file_get_value(path, 10); - - path[offset] = '\0'; - strcat(path, "/devnum"); - p->devnum = file_get_value(path, 10); - - path[offset] = '\0'; - strcat(path, "/bNumInterfaces"); - p->bNumInterfaces = file_get_value(path, 10); - - path[offset] = '\0'; -} - -static void query_usb_interface_info(char *path, struct usb_interface_info *p) { - char driver[128]; - size_t offset = strlen(path); - int n; - - memset(p, 0, sizeof(*p)); - - path[offset] = '\0'; - strcat(path, "/bNumEndpoints"); - p->bInterfaceClass = file_get_value(path, 16); - - path[offset] = '\0'; - strcat(path, "/bInterfaceClass"); - p->bInterfaceClass = file_get_value(path, 16); - - path[offset] = '\0'; - strcat(path, "/bInterfaceSubClass"); - p->bInterfaceSubClass = file_get_value(path, 16); - - path[offset] = '\0'; - strcat(path, "/bInterfaceProtocol"); - p->bInterfaceProtocol = file_get_value(path, 16); - - path[offset] = '\0'; - strcat(path, "/driver"); - n = readlink(path, driver, sizeof(driver)); - if (n > 0) { - driver[n] = 0; - if (debug_qmi) dbg_time("driver -> %s", driver); - n = strlen(driver); - while (n > 0) { - if (driver[n] == '/') - break; - n--; - } - strncpy(p->driver, &driver[n + 1], sizeof(p->driver) - 1); - } - - path[offset] = '\0'; -} - -static int detect_path_cdc_wdm_or_qcqmi(char *path, char *devname, size_t bufsize) { - size_t offset = strlen(path); - char tmp[32]; - - devname[0] = 0; - - if (access(path, R_OK)) - return -1; - - path[offset] = '\0'; - strcat(path, "/GobiQMI"); - if (!access(path, R_OK)) - goto step_1; - - path[offset] = '\0'; - strcat(path, "/usbmisc"); - if (!access(path, R_OK)) - goto step_1; - - path[offset] = '\0'; - strcat(path, "/usb"); - if (!access(path, R_OK)) - goto step_1; - - return -1; - - step_1: - /* get device(qcqmiX|cdc-wdmX) */ - if (debug_qmi) dbg_time("%s", path); - dir_get_child(path, tmp, sizeof(tmp), NULL); - if (tmp[0] == '\0') - return -1; - - /* There is a chance that, no device(qcqmiX|cdc-wdmX) is generated. We should warn user about that! */ - snprintf(devname, bufsize, "/dev/%s", tmp); - if (access(devname, R_OK | F_OK) && errno == ENOENT) { - int major, minor; - - dbg_time("access %s failed, errno: %d (%s)", devname, errno, strerror(errno)); - strcat(path, "/"); - strcat(path, tmp); - strcat(path, "/uevent"); - major = conf_get_val(path, "MAJOR"); - minor = conf_get_val(path, "MINOR"); - - if (major == CM_INVALID_VAL || minor == CM_INVALID_VAL) - dbg_time("get major and minor failed"); - else if (mknod(devname, S_IFCHR | 0666, (((major & 0xfff) << 8) | (minor & 0xff) | ((minor & 0xfff00) << 12)))) - dbg_time("please mknod %s c %d %d", devname, major, minor); - } - - return 0; -} - -/* To detect the device info of the modem. - * return: - * FALSE -> fail - * TRUE -> ok - */ -BOOL qmidevice_detect(char *qmichannel, char *usbnet_adapter, unsigned bufsize, PROFILE_T *profile) { - struct dirent *ent = NULL; - DIR *pDir; - const char *rootdir = "/sys/bus/usb/devices"; - struct { - char path[255 * 2]; - } *pl; - pl = (typeof(pl)) malloc(sizeof(*pl)); - memset(pl, 0x00, sizeof(*pl)); - - pDir = opendir(rootdir); - if (!pDir) { - dbg_time("opendir %s failed: %s", rootdir, strerror(errno)); - goto error; - } - - while ((ent = readdir(pDir)) != NULL) { - char netcard[32 + 1] = {'\0'}; - char devname[32 + 5] = {'\0'}; //+strlen("/dev/") - int netIntf; - int driver_type; - - if (ent->d_name[0] == 'u') - continue; - - snprintf(pl->path, sizeof(pl->path), "%s/%s", rootdir, ent->d_name); - query_usb_device_info(pl->path, &profile->usb_dev); - if (profile->usb_dev.idVendor == CM_INVALID_VAL) - continue; - - if (profile->usb_dev.idVendor == 0x2c7c || profile->usb_dev.idVendor == 0x05c6) { - dbg_time("Find %s/%s idVendor=0x%x idProduct=0x%x, bus=0x%03x, dev=0x%03x", - rootdir, ent->d_name, profile->usb_dev.idVendor, profile->usb_dev.idProduct, - profile->usb_dev.busnum, profile->usb_dev.devnum); - } - - /* get network interface */ - /* NOTICE: there is a case that, bNumberInterface=6, but the net interface is 8 */ - /* toolchain-mips_24kc_gcc-5.4.0_musl donot support GLOB_BRACE */ - /* RG500U's MBIM is at inteface 0 */ - for (netIntf = 0; netIntf < (profile->usb_dev.bNumInterfaces + 8); netIntf++) { - snprintf(pl->path, sizeof(pl->path), "%s/%s:1.%d/net", rootdir, ent->d_name, netIntf); - dir_get_child(pl->path, netcard, sizeof(netcard), NULL); - if (netcard[0]) - break; - } - - if (netcard[0] == '\0') { //for centos 2.6.x - const char *n = "usb0"; - const char *c = "qcqmi0"; - - snprintf(pl->path, sizeof(pl->path), "%s/%s:1.4/net:%s", rootdir, ent->d_name, n); - if (!access(pl->path, F_OK)) { - snprintf(pl->path, sizeof(pl->path), "%s/%s:1.4/GobiQMI:%s", rootdir, ent->d_name, c); - if (!access(pl->path, F_OK)) { - snprintf(qmichannel, bufsize, "/dev/%s", c); - snprintf(usbnet_adapter, bufsize, "%s", n); - snprintf(pl->path, sizeof(pl->path), "%s/%s:1.4", rootdir, ent->d_name); - query_usb_interface_info(pl->path, &profile->usb_intf); - break; - } - } - } - - if (netcard[0] == '\0') - continue; - - /* not '-i iface' */ - if (usbnet_adapter[0] && strcmp(usbnet_adapter, netcard)) - continue; - - snprintf(pl->path, sizeof(pl->path), "%s/%s:1.%d", rootdir, ent->d_name, netIntf); - query_usb_interface_info(pl->path, &profile->usb_intf); - driver_type = get_driver_type(profile); - - if (driver_type == SOFTWARE_QMI || driver_type == SOFTWARE_MBIM) { - detect_path_cdc_wdm_or_qcqmi(pl->path, devname, sizeof(devname)); - } else if (driver_type == SOFTWARE_ECM_RNDIS_NCM) { - int atIntf = -1; - - if (profile->usb_dev.idVendor == 0x2c7c) { //Quectel - switch (profile->usb_dev.idProduct) { //EC200U - case 0x0901: //EC200U - case 0x8101: //RG801H - atIntf = 2; - break; - case 0x0900: //RG500U - atIntf = 4; - break; - case 0x6026: //EC200T - case 0x6005: //EC200A - case 0x6002: //EC200S - case 0x6001: //EC100Y - atIntf = 3; - break; - default: - dbg_time("unknow at interface for USB idProduct:%04x\n", profile->usb_dev.idProduct); - break; - } - } - - if (atIntf != -1) { - snprintf(pl->path, sizeof(pl->path), "%s/%s:1.%d", rootdir, ent->d_name, atIntf); - dir_get_child(pl->path, devname, sizeof(devname), "tty"); - if (devname[0] && !strcmp(devname, "tty")) { - snprintf(pl->path, sizeof(pl->path), "%s/%s:1.%d/tty", rootdir, ent->d_name, atIntf); - dir_get_child(pl->path, devname, sizeof(devname), "tty"); - } - } - } - - if (netcard[0] && devname[0]) { - if (devname[0] == '/') - snprintf(qmichannel, bufsize, "%s", devname); - else - snprintf(qmichannel, bufsize, "/dev/%s", devname); - snprintf(usbnet_adapter, bufsize, "%s", netcard); - dbg_time("Auto find qmichannel = %s", qmichannel); - dbg_time("Auto find usbnet_adapter = %s", usbnet_adapter); - break; - } - } - closedir(pDir); - - if (qmichannel[0] == '\0' || usbnet_adapter[0] == '\0') { - dbg_time("network interface '%s' or qmidev '%s' is not exist", usbnet_adapter, qmichannel); - goto error; - } - free(pl); - return TRUE; - error: - free(pl); - return FALSE; -} - - -int isContain(const char *str1, const char *str2) { - if (strstr(str1, str2) != NULL) { - return 1; - } else { - return 0; - } -} - -void replaceStr(char *str, char *orig, char *rep) { - char buffer[1024]; - char *p; - while (p = strstr(str, orig)) { - memcpy(buffer, str, p - str); - buffer[p - str] = '\0'; - sprintf(buffer + strlen(buffer), "%s%s", rep, p + strlen(orig)); - strcpy(str, buffer); - } -} - -int mhidevice_detect(char *qmichannel, char *usbnet_adapter, PROFILE_T *profile) { - struct dirent *ent = NULL; - DIR *pDir; - const char *rootdir_mhi[] = {"/sys/bus/mhi_q/devices", "/sys/bus/mhi/devices", NULL}; - int i = 0; - char path[256]; - int find = 0; - while (rootdir_mhi[i]) { - const char *rootdir = rootdir_mhi[i++]; - dbg_time("rootdir : %s ", rootdir); - pDir = opendir(rootdir); - if (!pDir) { - if (errno != ENOENT) { - dbg_time("opendir %s failed: %s", rootdir, strerror(errno)); - } - continue; - } - while ((ent = readdir(pDir)) != NULL) { - char netcard[32] = {'\0'}; - char devname[32] = {'\0'}; - int software_interface = SOFTWARE_QMI; - char *pNode = NULL; - pNode = strstr(ent->d_name, "_IP_HW0"); //0306_00.01.00_IP_HW0 - if (!pNode) { - continue; - } - - char *d_name[32]; - strcpy(d_name, ent->d_name); - replaceStr(d_name, "_IP_HW0", ""); - dbg_time("while -> pcie_name = : %s ", d_name); - - snprintf(path, sizeof(path), "%s/%.32s/net", rootdir, ent->d_name); - dir_get_child(path, netcard, sizeof(netcard), NULL); - if (!netcard[0]) { - continue; - } - if (usbnet_adapter[0] && strcmp(netcard, usbnet_adapter)) { //not '-i x - continue; - } - if (!strcmp(rootdir, "/sys/bus/mhi/devices")) { - // snprintf(path, sizeof(path), "%s/%.13s_IPCR", rootdir, ent->d_name); // 13 is sizeof(0306_00.01.00) - snprintf(path, sizeof(path), "%s/%s_IPCR", rootdir, d_name); - if (!access(path, F_OK)) { - /* we also need 'cat /dev/mhi_0306_00.01.00_pipe_14' to enable rmnet as like USB's DTR - or will get error 'requestSetEthMode QMUXResult = 0x1, QMUXError = 0x46' */ - sprintf(usbnet_adapter, "%s", netcard); - sprintf(qmichannel, "qrtr-%d", 3); // 3 is sdx modem's node id - profile->software_interface = SOFTWARE_QRTR; - find = 1; - break; - } - continue; - } - - //解决PCIE硬编码导致不兼容hv问题 - snprintf(path, sizeof(path), "%s/%s_IPCR", rootdir, d_name); - if (access(path, F_OK)) { - snprintf(path, sizeof(path), "%s/%s_QMI0", rootdir, d_name); - if (access(path, F_OK)) { - snprintf(path, sizeof(path), "%s/%s_MBIM", rootdir, d_name); - if (!access(path, F_OK)) { - software_interface = SOFTWARE_MBIM; - } - } - } - - //原 - // snprintf(path, sizeof(path), "%s/%.14s_IPCR", rootdir, ent->d_name); - // dbg_time("while -> path3 : %s ", path); - // if (access(path, F_OK)) { - // snprintf(path, sizeof(path), "%s/%.14s_QMI0", rootdir, ent->d_name); - // dbg_time("while -> path4 : %s ", path); - // if (access(path, F_OK)) { - // snprintf(path, sizeof(path), "%s/%.14s_MBIM", rootdir, ent->d_name); - // dbg_time("while -> path5 : %s ", path); - // if (!access(path, F_OK)) { - // software_interface = SOFTWARE_MBIM; - // } - // } - // } - - dbg_time("while -> path_final : %s ", path); - if (access(path, F_OK)) { - continue; - } - strncat(path, "/mhi_uci_q", sizeof(path) - 1); - dir_get_child(path, devname, sizeof(devname), NULL); - if (!devname[0]) { - continue; - } - dbg_time("while -> path_final_sub : %s ,dev_name: %s ", path, devname); - sprintf(usbnet_adapter, "%s", netcard); - sprintf(qmichannel, "/dev/%s", devname); - profile->software_interface = software_interface; - find = 1; - break; - } - closedir(pDir); - } - return find; -} - -int atdevice_detect(char *atchannel, char *usbnet_adapter, PROFILE_T *profile) { - if (!access("/sys/class/net/sipa_dummy0", F_OK)) { - strcpy(usbnet_adapter, "sipa_dummy0"); - snprintf(profile->qmapnet_adapter, sizeof(profile->qmapnet_adapter), "%s%d", "pcie", profile->pdp - 1); - } else { - dbg_time("atdevice_detect failed"); - goto error; - } - - if (!access("/dev/stty_nr31", F_OK)) { - strcpy(atchannel, "/dev/stty_nr31"); - profile->software_interface = SOFTWARE_ECM_RNDIS_NCM; - } else { - goto error; - } - - return 1; - error: - return 0; -} - - -int get_driver_type(PROFILE_T *profile) { - /* QMI_WWAN */ - if (profile->usb_intf.bInterfaceClass == USB_CLASS_VENDOR_SPEC) { - return SOFTWARE_QMI; - } else if (profile->usb_intf.bInterfaceClass == USB_CLASS_COMM) { - switch (profile->usb_intf.bInterfaceSubClass) { - case USB_CDC_SUBCLASS_MBIM: - return SOFTWARE_MBIM; - break; - case USB_CDC_SUBCLASS_ETHERNET: - case USB_CDC_SUBCLASS_NCM: - return SOFTWARE_ECM_RNDIS_NCM; - break; - default: - break; - } - } else if (profile->usb_intf.bInterfaceClass == USB_CLASS_WIRELESS_CONTROLLER) { - if (profile->usb_intf.bInterfaceSubClass == 1 && profile->usb_intf.bInterfaceProtocol == 3) - return SOFTWARE_ECM_RNDIS_NCM; - } - - dbg_time("%s unknow bInterfaceClass=%d, bInterfaceSubClass=%d", __func__, - profile->usb_intf.bInterfaceClass, profile->usb_intf.bInterfaceSubClass); - return DRV_INVALID; -} - -struct usbfs_getdriver { - unsigned int interface; - char driver[255 + 1]; -}; - -struct usbfs_ioctl { - int ifno; /* interface 0..N ; negative numbers reserved */ - int ioctl_code; /* MUST encode size + direction of data so the - * macros in give correct values */ - void *data; /* param buffer (in, or out) */ -}; - -#define IOCTL_USBFS_DISCONNECT _IO('U', 22) -#define IOCTL_USBFS_CONNECT _IO('U', 23) - -int usbfs_is_kernel_driver_alive(int fd, int ifnum) { - struct usbfs_getdriver getdrv; - getdrv.interface = ifnum; - if (ioctl(fd, USBDEVFS_GETDRIVER, &getdrv) < 0) { - dbg_time("%s ioctl USBDEVFS_GETDRIVER failed, kernel driver may be inactive", __func__); - return 0; - } - dbg_time("%s find interface %d has match the driver %s", __func__, ifnum, getdrv.driver); - return 1; -} - -void usbfs_detach_kernel_driver(int fd, int ifnum) { - struct usbfs_ioctl operate; - operate.data = NULL; - operate.ifno = ifnum; - operate.ioctl_code = IOCTL_USBFS_DISCONNECT; - if (ioctl(fd, USBDEVFS_IOCTL, &operate) < 0) { - dbg_time("%s detach kernel driver failed", __func__); - } else { - dbg_time("%s detach kernel driver success", __func__); - } -} - -void usbfs_attach_kernel_driver(int fd, int ifnum) { - struct usbfs_ioctl operate; - operate.data = NULL; - operate.ifno = ifnum; - operate.ioctl_code = IOCTL_USBFS_CONNECT; - if (ioctl(fd, USBDEVFS_IOCTL, &operate) < 0) { - dbg_time("%s detach kernel driver failed", __func__); - } else { - dbg_time("%s detach kernel driver success", __func__); - } -} - -int reattach_driver(PROFILE_T *profile) { - int ifnum = 4; - int fd; - char devpath[128] = {'\0'}; - snprintf(devpath, sizeof(devpath), "/dev/bus/usb/%03d/%03d", profile->usb_dev.busnum, profile->usb_dev.devnum); - fd = open(devpath, O_RDWR | O_NOCTTY); - if (fd < 0) { - dbg_time("%s fail to open %s", __func__, devpath); - return -1; - } - usbfs_detach_kernel_driver(fd, ifnum); - usbfs_attach_kernel_driver(fd, ifnum); - close(fd); - return 0; -} - -#define SIOCETHTOOL 0x8946 - -int ql_get_netcard_driver_info(const char *devname) { - int fd = -1; - struct ethtool_drvinfo drvinfo; - struct ifreq ifr; /* ifreq suitable for ethtool ioctl */ - - memset(&ifr, 0, sizeof(ifr)); - strcpy(ifr.ifr_name, devname); - - fd = socket(AF_INET, SOCK_DGRAM, 0); - if (fd < 0) { - dbg_time("Cannot get control socket: errno(%d)(%s)", errno, strerror(errno)); - return -1; - } - - drvinfo.cmd = ETHTOOL_GDRVINFO; - ifr.ifr_data = (void *) &drvinfo; - - if (ioctl(fd, SIOCETHTOOL, &ifr) < 0) { - dbg_time("ioctl() error: errno(%d)(%s)", errno, strerror(errno)); - close(fd); - return -1; - } - - dbg_time("netcard driver = %s, driver version = %s", drvinfo.driver, drvinfo.version); - - close(fd); - - return 0; -} - -int ql_get_netcard_carrier_state(const char *devname) { - int fd = -1; - struct ethtool_value edata; - struct ifreq ifr; /* ifreq suitable for ethtool ioctl */ - - memset(&ifr, 0, sizeof(ifr)); - strcpy(ifr.ifr_name, devname); - - fd = socket(AF_INET, SOCK_DGRAM, 0); - if (fd < 0) { - dbg_time("Cannot get control socket: errno(%d)(%s)", errno, strerror(errno)); - return -1; - } - - edata.cmd = ETHTOOL_GLINK; - edata.data = 0; - ifr.ifr_data = (void *) &edata; - - if (ioctl(fd, SIOCETHTOOL, &ifr) < 0) { - dbg_time("ioctl('%s') error: errno(%d)(%s)", devname, errno, strerror(errno)); - return -1; - } - - if (!edata.data) - dbg_time("netcard carrier = %d", edata.data); - - close(fd); - - return edata.data; -} - -static void *catch_log(void *arg) { - PROFILE_T *profile = (PROFILE_T *) arg; - int nreads = 0; - char tbuff[256 + 32]; - char filter[32]; - size_t tsize = strlen(get_time()) + 1; - - snprintf(filter, sizeof(filter), ":%d:%03d:", profile->usb_dev.busnum, profile->usb_dev.devnum); - - while (1) { - nreads = read(profile->usbmon_fd, tbuff + tsize, sizeof(tbuff) - tsize - 1); - if (nreads <= 0) { - if (nreads == -1 && errno == EINTR) - continue; - break; - } - - tbuff[tsize + nreads] = '\0'; // printf("%s", buff); - - if (!strstr(tbuff + tsize, filter)) - continue; - - snprintf(tbuff, sizeof(tbuff), "%s", get_time()); - tbuff[tsize - 1] = ' '; - - fwrite(tbuff, strlen(tbuff), 1, profile->usbmon_logfile_fp); - } - - return NULL; -} - -int ql_capture_usbmon_log(PROFILE_T *profile, const char *log_path) { - char usbmon_path[256]; - pthread_t pt; - pthread_attr_t attr; - - if (access("/sys/module/usbmon", F_OK)) { - dbg_time("usbmon is not load, please execute \"modprobe usbmon\" or \"insmod usbmon.ko\""); - return -1; - } - - if (access("/sys/kernel/debug/usb", F_OK)) { - dbg_time("debugfs is not mount, please execute \"mount -t debugfs none_debugs /sys/kernel/debug\""); - return -1; - } - - snprintf(usbmon_path, sizeof(usbmon_path), "/sys/kernel/debug/usb/usbmon/%du", profile->usb_dev.busnum); - profile->usbmon_fd = open(usbmon_path, O_RDONLY); - if (profile->usbmon_fd < 0) { - dbg_time("open %s error(%d) (%s)", usbmon_path, errno, strerror(errno)); - return -1; - } - - snprintf(usbmon_path, sizeof(usbmon_path), "cat /sys/kernel/debug/usb/devices >> %s", log_path); - if (system(usbmon_path) == -1) {}; - - profile->usbmon_logfile_fp = fopen(log_path, "wb"); - if (!profile->usbmon_logfile_fp) { - dbg_time("open %s error(%d) (%s)", log_path, errno, strerror(errno)); - close(profile->usbmon_fd); - profile->usbmon_fd = -1; - return -1; - } - - pthread_attr_init(&attr); - pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); - - pthread_create(&pt, &attr, catch_log, (void *) profile); - - return 0; -} - -void ql_stop_usbmon_log(PROFILE_T *profile) { - if (profile->usbmon_fd > 0) - close(profile->usbmon_fd); - if (profile->usbmon_logfile_fp) - fclose(profile->usbmon_logfile_fp); -} diff --git a/quectel_cm_5G/src/ethtool-copy.h b/quectel_cm_5G/src/ethtool-copy.h deleted file mode 100644 index b5515c2..0000000 --- a/quectel_cm_5G/src/ethtool-copy.h +++ /dev/null @@ -1,1100 +0,0 @@ -/* - * ethtool.h: Defines for Linux ethtool. - * - * Copyright (C) 1998 David S. Miller (davem@redhat.com) - * Copyright 2001 Jeff Garzik - * Portions Copyright 2001 Sun Microsystems (thockin@sun.com) - * Portions Copyright 2002 Intel (eli.kupermann@intel.com, - * christopher.leech@intel.com, - * scott.feldman@intel.com) - * Portions Copyright (C) Sun Microsystems 2008 - */ - -#ifndef _LINUX_ETHTOOL_H -#define _LINUX_ETHTOOL_H - -#include -#include - -/* This should work for both 32 and 64 bit userland. */ -struct ethtool_cmd { - __u32 cmd; - __u32 supported; /* Features this interface supports */ - __u32 advertising; /* Features this interface advertises */ - __u16 speed; /* The forced speed (lower bits) in - * Mbps. Please use - * ethtool_cmd_speed()/_set() to - * access it */ - __u8 duplex; /* Duplex, half or full */ - __u8 port; /* Which connector port */ - __u8 phy_address; /* MDIO PHY address (PRTAD for clause 45). - * May be read-only or read-write - * depending on the driver. - */ - __u8 transceiver; /* Which transceiver to use */ - __u8 autoneg; /* Enable or disable autonegotiation */ - __u8 mdio_support; /* MDIO protocols supported. Read-only. - * Not set by all drivers. - */ - __u32 maxtxpkt; /* Tx pkts before generating tx int */ - __u32 maxrxpkt; /* Rx pkts before generating rx int */ - __u16 speed_hi; /* The forced speed (upper - * bits) in Mbps. Please use - * ethtool_cmd_speed()/_set() to - * access it */ - __u8 eth_tp_mdix; /* twisted pair MDI-X status */ - __u8 eth_tp_mdix_ctrl; /* twisted pair MDI-X control, when set, - * link should be renegotiated if necessary - */ - __u32 lp_advertising; /* Features the link partner advertises */ - __u32 reserved[2]; -}; - -static __inline__ void ethtool_cmd_speed_set(struct ethtool_cmd *ep, - __u32 speed) -{ - - ep->speed = (__u16)speed; - ep->speed_hi = (__u16)(speed >> 16); -} - -static __inline__ __u32 ethtool_cmd_speed(const struct ethtool_cmd *ep) -{ - return (ep->speed_hi << 16) | ep->speed; -} - -/* Device supports clause 22 register access to PHY or peripherals - * using the interface defined in . This should not be - * set if there are known to be no such peripherals present or if - * the driver only emulates clause 22 registers for compatibility. - */ -#define ETH_MDIO_SUPPORTS_C22 1 - -/* Device supports clause 45 register access to PHY or peripherals - * using the interface defined in and . - * This should not be set if there are known to be no such peripherals - * present. - */ -#define ETH_MDIO_SUPPORTS_C45 2 - -#define ETHTOOL_FWVERS_LEN 32 -#define ETHTOOL_BUSINFO_LEN 32 -/* these strings are set to whatever the driver author decides... */ -struct ethtool_drvinfo { - __u32 cmd; - char driver[32]; /* driver short name, "tulip", "eepro100" */ - char version[32]; /* driver version string */ - char fw_version[ETHTOOL_FWVERS_LEN]; /* firmware version string */ - char bus_info[ETHTOOL_BUSINFO_LEN]; /* Bus info for this IF. */ - /* For PCI devices, use pci_name(pci_dev). */ - char reserved1[32]; - char reserved2[12]; - /* - * Some struct members below are filled in - * using ops->get_sset_count(). Obtaining - * this info from ethtool_drvinfo is now - * deprecated; Use ETHTOOL_GSSET_INFO - * instead. - */ - __u32 n_priv_flags; /* number of flags valid in ETHTOOL_GPFLAGS */ - __u32 n_stats; /* number of u64's from ETHTOOL_GSTATS */ - __u32 testinfo_len; - __u32 eedump_len; /* Size of data from ETHTOOL_GEEPROM (bytes) */ - __u32 regdump_len; /* Size of data from ETHTOOL_GREGS (bytes) */ -}; - -#define SOPASS_MAX 6 -/* wake-on-lan settings */ -struct ethtool_wolinfo { - __u32 cmd; - __u32 supported; - __u32 wolopts; - __u8 sopass[SOPASS_MAX]; /* SecureOn(tm) password */ -}; - -/* for passing single values */ -struct ethtool_value { - __u32 cmd; - __u32 data; -}; - -/* for passing big chunks of data */ -struct ethtool_regs { - __u32 cmd; - __u32 version; /* driver-specific, indicates different chips/revs */ - __u32 len; /* bytes */ - __u8 data[0]; -}; - -/* for passing EEPROM chunks */ -struct ethtool_eeprom { - __u32 cmd; - __u32 magic; - __u32 offset; /* in bytes */ - __u32 len; /* in bytes */ - __u8 data[0]; -}; - -/** - * struct ethtool_eee - Energy Efficient Ethernet information - * @cmd: ETHTOOL_{G,S}EEE - * @supported: Mask of %SUPPORTED_* flags for the speed/duplex combinations - * for which there is EEE support. - * @advertised: Mask of %ADVERTISED_* flags for the speed/duplex combinations - * advertised as eee capable. - * @lp_advertised: Mask of %ADVERTISED_* flags for the speed/duplex - * combinations advertised by the link partner as eee capable. - * @eee_active: Result of the eee auto negotiation. - * @eee_enabled: EEE configured mode (enabled/disabled). - * @tx_lpi_enabled: Whether the interface should assert its tx lpi, given - * that eee was negotiated. - * @tx_lpi_timer: Time in microseconds the interface delays prior to asserting - * its tx lpi (after reaching 'idle' state). Effective only when eee - * was negotiated and tx_lpi_enabled was set. - */ -struct ethtool_eee { - __u32 cmd; - __u32 supported; - __u32 advertised; - __u32 lp_advertised; - __u32 eee_active; - __u32 eee_enabled; - __u32 tx_lpi_enabled; - __u32 tx_lpi_timer; - __u32 reserved[2]; -}; - -/** - * struct ethtool_modinfo - plugin module eeprom information - * @cmd: %ETHTOOL_GMODULEINFO - * @type: Standard the module information conforms to %ETH_MODULE_SFF_xxxx - * @eeprom_len: Length of the eeprom - * - * This structure is used to return the information to - * properly size memory for a subsequent call to %ETHTOOL_GMODULEEEPROM. - * The type code indicates the eeprom data format - */ -struct ethtool_modinfo { - __u32 cmd; - __u32 type; - __u32 eeprom_len; - __u32 reserved[8]; -}; - -/** - * struct ethtool_coalesce - coalescing parameters for IRQs and stats updates - * @cmd: ETHTOOL_{G,S}COALESCE - * @rx_coalesce_usecs: How many usecs to delay an RX interrupt after - * a packet arrives. - * @rx_max_coalesced_frames: Maximum number of packets to receive - * before an RX interrupt. - * @rx_coalesce_usecs_irq: Same as @rx_coalesce_usecs, except that - * this value applies while an IRQ is being serviced by the host. - * @rx_max_coalesced_frames_irq: Same as @rx_max_coalesced_frames, - * except that this value applies while an IRQ is being serviced - * by the host. - * @tx_coalesce_usecs: How many usecs to delay a TX interrupt after - * a packet is sent. - * @tx_max_coalesced_frames: Maximum number of packets to be sent - * before a TX interrupt. - * @tx_coalesce_usecs_irq: Same as @tx_coalesce_usecs, except that - * this value applies while an IRQ is being serviced by the host. - * @tx_max_coalesced_frames_irq: Same as @tx_max_coalesced_frames, - * except that this value applies while an IRQ is being serviced - * by the host. - * @stats_block_coalesce_usecs: How many usecs to delay in-memory - * statistics block updates. Some drivers do not have an - * in-memory statistic block, and in such cases this value is - * ignored. This value must not be zero. - * @use_adaptive_rx_coalesce: Enable adaptive RX coalescing. - * @use_adaptive_tx_coalesce: Enable adaptive TX coalescing. - * @pkt_rate_low: Threshold for low packet rate (packets per second). - * @rx_coalesce_usecs_low: How many usecs to delay an RX interrupt after - * a packet arrives, when the packet rate is below @pkt_rate_low. - * @rx_max_coalesced_frames_low: Maximum number of packets to be received - * before an RX interrupt, when the packet rate is below @pkt_rate_low. - * @tx_coalesce_usecs_low: How many usecs to delay a TX interrupt after - * a packet is sent, when the packet rate is below @pkt_rate_low. - * @tx_max_coalesced_frames_low: Maximum nuumber of packets to be sent before - * a TX interrupt, when the packet rate is below @pkt_rate_low. - * @pkt_rate_high: Threshold for high packet rate (packets per second). - * @rx_coalesce_usecs_high: How many usecs to delay an RX interrupt after - * a packet arrives, when the packet rate is above @pkt_rate_high. - * @rx_max_coalesced_frames_high: Maximum number of packets to be received - * before an RX interrupt, when the packet rate is above @pkt_rate_high. - * @tx_coalesce_usecs_high: How many usecs to delay a TX interrupt after - * a packet is sent, when the packet rate is above @pkt_rate_high. - * @tx_max_coalesced_frames_high: Maximum number of packets to be sent before - * a TX interrupt, when the packet rate is above @pkt_rate_high. - * @rate_sample_interval: How often to do adaptive coalescing packet rate - * sampling, measured in seconds. Must not be zero. - * - * Each pair of (usecs, max_frames) fields specifies this exit - * condition for interrupt coalescing: - * (usecs > 0 && time_since_first_completion >= usecs) || - * (max_frames > 0 && completed_frames >= max_frames) - * It is illegal to set both usecs and max_frames to zero as this - * would cause interrupts to never be generated. To disable - * coalescing, set usecs = 0 and max_frames = 1. - * - * Some implementations ignore the value of max_frames and use the - * condition: - * time_since_first_completion >= usecs - * This is deprecated. Drivers for hardware that does not support - * counting completions should validate that max_frames == !rx_usecs. - * - * Adaptive RX/TX coalescing is an algorithm implemented by some - * drivers to improve latency under low packet rates and improve - * throughput under high packet rates. Some drivers only implement - * one of RX or TX adaptive coalescing. Anything not implemented by - * the driver causes these values to be silently ignored. - * - * When the packet rate is below @pkt_rate_high but above - * @pkt_rate_low (both measured in packets per second) the - * normal {rx,tx}_* coalescing parameters are used. - */ -struct ethtool_coalesce { - __u32 cmd; - __u32 rx_coalesce_usecs; - __u32 rx_max_coalesced_frames; - __u32 rx_coalesce_usecs_irq; - __u32 rx_max_coalesced_frames_irq; - __u32 tx_coalesce_usecs; - __u32 tx_max_coalesced_frames; - __u32 tx_coalesce_usecs_irq; - __u32 tx_max_coalesced_frames_irq; - __u32 stats_block_coalesce_usecs; - __u32 use_adaptive_rx_coalesce; - __u32 use_adaptive_tx_coalesce; - __u32 pkt_rate_low; - __u32 rx_coalesce_usecs_low; - __u32 rx_max_coalesced_frames_low; - __u32 tx_coalesce_usecs_low; - __u32 tx_max_coalesced_frames_low; - __u32 pkt_rate_high; - __u32 rx_coalesce_usecs_high; - __u32 rx_max_coalesced_frames_high; - __u32 tx_coalesce_usecs_high; - __u32 tx_max_coalesced_frames_high; - __u32 rate_sample_interval; -}; - -/* for configuring RX/TX ring parameters */ -struct ethtool_ringparam { - __u32 cmd; /* ETHTOOL_{G,S}RINGPARAM */ - - /* Read only attributes. These indicate the maximum number - * of pending RX/TX ring entries the driver will allow the - * user to set. - */ - __u32 rx_max_pending; - __u32 rx_mini_max_pending; - __u32 rx_jumbo_max_pending; - __u32 tx_max_pending; - - /* Values changeable by the user. The valid values are - * in the range 1 to the "*_max_pending" counterpart above. - */ - __u32 rx_pending; - __u32 rx_mini_pending; - __u32 rx_jumbo_pending; - __u32 tx_pending; -}; - -/** - * struct ethtool_channels - configuring number of network channel - * @cmd: ETHTOOL_{G,S}CHANNELS - * @max_rx: Read only. Maximum number of receive channel the driver support. - * @max_tx: Read only. Maximum number of transmit channel the driver support. - * @max_other: Read only. Maximum number of other channel the driver support. - * @max_combined: Read only. Maximum number of combined channel the driver - * support. Set of queues RX, TX or other. - * @rx_count: Valid values are in the range 1 to the max_rx. - * @tx_count: Valid values are in the range 1 to the max_tx. - * @other_count: Valid values are in the range 1 to the max_other. - * @combined_count: Valid values are in the range 1 to the max_combined. - * - * This can be used to configure RX, TX and other channels. - */ - -struct ethtool_channels { - __u32 cmd; - __u32 max_rx; - __u32 max_tx; - __u32 max_other; - __u32 max_combined; - __u32 rx_count; - __u32 tx_count; - __u32 other_count; - __u32 combined_count; -}; - -/* for configuring link flow control parameters */ -struct ethtool_pauseparam { - __u32 cmd; /* ETHTOOL_{G,S}PAUSEPARAM */ - - /* If the link is being auto-negotiated (via ethtool_cmd.autoneg - * being true) the user may set 'autoneg' here non-zero to have the - * pause parameters be auto-negotiated too. In such a case, the - * {rx,tx}_pause values below determine what capabilities are - * advertised. - * - * If 'autoneg' is zero or the link is not being auto-negotiated, - * then {rx,tx}_pause force the driver to use/not-use pause - * flow control. - */ - __u32 autoneg; - __u32 rx_pause; - __u32 tx_pause; -}; - -#define ETH_GSTRING_LEN 32 -enum ethtool_stringset { - ETH_SS_TEST = 0, - ETH_SS_STATS, - ETH_SS_PRIV_FLAGS, - ETH_SS_NTUPLE_FILTERS, /* Do not use, GRXNTUPLE is now deprecated */ - ETH_SS_FEATURES, -}; - -/* for passing string sets for data tagging */ -struct ethtool_gstrings { - __u32 cmd; /* ETHTOOL_GSTRINGS */ - __u32 string_set; /* string set id e.c. ETH_SS_TEST, etc*/ - __u32 len; /* number of strings in the string set */ - __u8 data[0]; -}; - -struct ethtool_sset_info { - __u32 cmd; /* ETHTOOL_GSSET_INFO */ - __u32 reserved; - __u64 sset_mask; /* input: each bit selects an sset to query */ - /* output: each bit a returned sset */ - __u32 data[0]; /* ETH_SS_xxx count, in order, based on bits - in sset_mask. One bit implies one - __u32, two bits implies two - __u32's, etc. */ -}; - -/** - * enum ethtool_test_flags - flags definition of ethtool_test - * @ETH_TEST_FL_OFFLINE: if set perform online and offline tests, otherwise - * only online tests. - * @ETH_TEST_FL_FAILED: Driver set this flag if test fails. - * @ETH_TEST_FL_EXTERNAL_LB: Application request to perform external loopback - * test. - * @ETH_TEST_FL_EXTERNAL_LB_DONE: Driver performed the external loopback test - */ - -enum ethtool_test_flags { - ETH_TEST_FL_OFFLINE = (1 << 0), - ETH_TEST_FL_FAILED = (1 << 1), - ETH_TEST_FL_EXTERNAL_LB = (1 << 2), - ETH_TEST_FL_EXTERNAL_LB_DONE = (1 << 3), -}; - -/* for requesting NIC test and getting results*/ -struct ethtool_test { - __u32 cmd; /* ETHTOOL_TEST */ - __u32 flags; /* ETH_TEST_FL_xxx */ - __u32 reserved; - __u32 len; /* result length, in number of u64 elements */ - __u64 data[0]; -}; - -/* for dumping NIC-specific statistics */ -struct ethtool_stats { - __u32 cmd; /* ETHTOOL_GSTATS */ - __u32 n_stats; /* number of u64's being returned */ - __u64 data[0]; -}; - -struct ethtool_perm_addr { - __u32 cmd; /* ETHTOOL_GPERMADDR */ - __u32 size; - __u8 data[0]; -}; - -/* boolean flags controlling per-interface behavior characteristics. - * When reading, the flag indicates whether or not a certain behavior - * is enabled/present. When writing, the flag indicates whether - * or not the driver should turn on (set) or off (clear) a behavior. - * - * Some behaviors may read-only (unconditionally absent or present). - * If such is the case, return EINVAL in the set-flags operation if the - * flag differs from the read-only value. - */ -enum ethtool_flags { - ETH_FLAG_TXVLAN = (1 << 7), /* TX VLAN offload enabled */ - ETH_FLAG_RXVLAN = (1 << 8), /* RX VLAN offload enabled */ - ETH_FLAG_LRO = (1 << 15), /* LRO is enabled */ - ETH_FLAG_NTUPLE = (1 << 27), /* N-tuple filters enabled */ - ETH_FLAG_RXHASH = (1 << 28), -}; - -/* The following structures are for supporting RX network flow - * classification and RX n-tuple configuration. Note, all multibyte - * fields, e.g., ip4src, ip4dst, psrc, pdst, spi, etc. are expected to - * be in network byte order. - */ - -/** - * struct ethtool_tcpip4_spec - flow specification for TCP/IPv4 etc. - * @ip4src: Source host - * @ip4dst: Destination host - * @psrc: Source port - * @pdst: Destination port - * @tos: Type-of-service - * - * This can be used to specify a TCP/IPv4, UDP/IPv4 or SCTP/IPv4 flow. - */ -struct ethtool_tcpip4_spec { - __be32 ip4src; - __be32 ip4dst; - __be16 psrc; - __be16 pdst; - __u8 tos; -}; - -/** - * struct ethtool_ah_espip4_spec - flow specification for IPsec/IPv4 - * @ip4src: Source host - * @ip4dst: Destination host - * @spi: Security parameters index - * @tos: Type-of-service - * - * This can be used to specify an IPsec transport or tunnel over IPv4. - */ -struct ethtool_ah_espip4_spec { - __be32 ip4src; - __be32 ip4dst; - __be32 spi; - __u8 tos; -}; - -#define ETH_RX_NFC_IP4 1 - -/** - * struct ethtool_usrip4_spec - general flow specification for IPv4 - * @ip4src: Source host - * @ip4dst: Destination host - * @l4_4_bytes: First 4 bytes of transport (layer 4) header - * @tos: Type-of-service - * @ip_ver: Value must be %ETH_RX_NFC_IP4; mask must be 0 - * @proto: Transport protocol number; mask must be 0 - */ -struct ethtool_usrip4_spec { - __be32 ip4src; - __be32 ip4dst; - __be32 l4_4_bytes; - __u8 tos; - __u8 ip_ver; - __u8 proto; -}; - -union ethtool_flow_union { - struct ethtool_tcpip4_spec tcp_ip4_spec; - struct ethtool_tcpip4_spec udp_ip4_spec; - struct ethtool_tcpip4_spec sctp_ip4_spec; - struct ethtool_ah_espip4_spec ah_ip4_spec; - struct ethtool_ah_espip4_spec esp_ip4_spec; - struct ethtool_usrip4_spec usr_ip4_spec; - struct ethhdr ether_spec; - __u8 hdata[52]; -}; - -/** - * struct ethtool_flow_ext - additional RX flow fields - * @h_dest: destination MAC address - * @vlan_etype: VLAN EtherType - * @vlan_tci: VLAN tag control information - * @data: user defined data - * - * Note, @vlan_etype, @vlan_tci, and @data are only valid if %FLOW_EXT - * is set in &struct ethtool_rx_flow_spec @flow_type. - * @h_dest is valid if %FLOW_MAC_EXT is set. - */ -struct ethtool_flow_ext { - __u8 padding[2]; - unsigned char h_dest[ETH_ALEN]; - __be16 vlan_etype; - __be16 vlan_tci; - __be32 data[2]; -}; - -/** - * struct ethtool_rx_flow_spec - classification rule for RX flows - * @flow_type: Type of match to perform, e.g. %TCP_V4_FLOW - * @h_u: Flow fields to match (dependent on @flow_type) - * @h_ext: Additional fields to match - * @m_u: Masks for flow field bits to be matched - * @m_ext: Masks for additional field bits to be matched - * Note, all additional fields must be ignored unless @flow_type - * includes the %FLOW_EXT or %FLOW_MAC_EXT flag - * (see &struct ethtool_flow_ext description). - * @ring_cookie: RX ring/queue index to deliver to, or %RX_CLS_FLOW_DISC - * if packets should be discarded - * @location: Location of rule in the table. Locations must be - * numbered such that a flow matching multiple rules will be - * classified according to the first (lowest numbered) rule. - */ -struct ethtool_rx_flow_spec { - __u32 flow_type; - union ethtool_flow_union h_u; - struct ethtool_flow_ext h_ext; - union ethtool_flow_union m_u; - struct ethtool_flow_ext m_ext; - __u64 ring_cookie; - __u32 location; -}; - -/** - * struct ethtool_rxnfc - command to get or set RX flow classification rules - * @cmd: Specific command number - %ETHTOOL_GRXFH, %ETHTOOL_SRXFH, - * %ETHTOOL_GRXRINGS, %ETHTOOL_GRXCLSRLCNT, %ETHTOOL_GRXCLSRULE, - * %ETHTOOL_GRXCLSRLALL, %ETHTOOL_SRXCLSRLDEL or %ETHTOOL_SRXCLSRLINS - * @flow_type: Type of flow to be affected, e.g. %TCP_V4_FLOW - * @data: Command-dependent value - * @fs: Flow classification rule - * @rule_cnt: Number of rules to be affected - * @rule_locs: Array of used rule locations - * - * For %ETHTOOL_GRXFH and %ETHTOOL_SRXFH, @data is a bitmask indicating - * the fields included in the flow hash, e.g. %RXH_IP_SRC. The following - * structure fields must not be used. - * - * For %ETHTOOL_GRXRINGS, @data is set to the number of RX rings/queues - * on return. - * - * For %ETHTOOL_GRXCLSRLCNT, @rule_cnt is set to the number of defined - * rules on return. If @data is non-zero on return then it is the - * size of the rule table, plus the flag %RX_CLS_LOC_SPECIAL if the - * driver supports any special location values. If that flag is not - * set in @data then special location values should not be used. - * - * For %ETHTOOL_GRXCLSRULE, @fs.@location specifies the location of an - * existing rule on entry and @fs contains the rule on return. - * - * For %ETHTOOL_GRXCLSRLALL, @rule_cnt specifies the array size of the - * user buffer for @rule_locs on entry. On return, @data is the size - * of the rule table, @rule_cnt is the number of defined rules, and - * @rule_locs contains the locations of the defined rules. Drivers - * must use the second parameter to get_rxnfc() instead of @rule_locs. - * - * For %ETHTOOL_SRXCLSRLINS, @fs specifies the rule to add or update. - * @fs.@location either specifies the location to use or is a special - * location value with %RX_CLS_LOC_SPECIAL flag set. On return, - * @fs.@location is the actual rule location. - * - * For %ETHTOOL_SRXCLSRLDEL, @fs.@location specifies the location of an - * existing rule on entry. - * - * A driver supporting the special location values for - * %ETHTOOL_SRXCLSRLINS may add the rule at any suitable unused - * location, and may remove a rule at a later location (lower - * priority) that matches exactly the same set of flows. The special - * values are: %RX_CLS_LOC_ANY, selecting any location; - * %RX_CLS_LOC_FIRST, selecting the first suitable location (maximum - * priority); and %RX_CLS_LOC_LAST, selecting the last suitable - * location (minimum priority). Additional special values may be - * defined in future and drivers must return -%EINVAL for any - * unrecognised value. - */ -struct ethtool_rxnfc { - __u32 cmd; - __u32 flow_type; - __u64 data; - struct ethtool_rx_flow_spec fs; - __u32 rule_cnt; - __u32 rule_locs[0]; -}; - - -/** - * struct ethtool_rxfh_indir - command to get or set RX flow hash indirection - * @cmd: Specific command number - %ETHTOOL_GRXFHINDIR or %ETHTOOL_SRXFHINDIR - * @size: On entry, the array size of the user buffer, which may be zero. - * On return from %ETHTOOL_GRXFHINDIR, the array size of the hardware - * indirection table. - * @ring_index: RX ring/queue index for each hash value - * - * For %ETHTOOL_GRXFHINDIR, a @size of zero means that only the size - * should be returned. For %ETHTOOL_SRXFHINDIR, a @size of zero means - * the table should be reset to default values. This last feature - * is not supported by the original implementations. - */ -struct ethtool_rxfh_indir { - __u32 cmd; - __u32 size; - __u32 ring_index[0]; -}; - -/** - * struct ethtool_rx_ntuple_flow_spec - specification for RX flow filter - * @flow_type: Type of match to perform, e.g. %TCP_V4_FLOW - * @h_u: Flow field values to match (dependent on @flow_type) - * @m_u: Masks for flow field value bits to be ignored - * @vlan_tag: VLAN tag to match - * @vlan_tag_mask: Mask for VLAN tag bits to be ignored - * @data: Driver-dependent data to match - * @data_mask: Mask for driver-dependent data bits to be ignored - * @action: RX ring/queue index to deliver to (non-negative) or other action - * (negative, e.g. %ETHTOOL_RXNTUPLE_ACTION_DROP) - * - * For flow types %TCP_V4_FLOW, %UDP_V4_FLOW and %SCTP_V4_FLOW, where - * a field value and mask are both zero this is treated as if all mask - * bits are set i.e. the field is ignored. - */ -struct ethtool_rx_ntuple_flow_spec { - __u32 flow_type; - union { - struct ethtool_tcpip4_spec tcp_ip4_spec; - struct ethtool_tcpip4_spec udp_ip4_spec; - struct ethtool_tcpip4_spec sctp_ip4_spec; - struct ethtool_ah_espip4_spec ah_ip4_spec; - struct ethtool_ah_espip4_spec esp_ip4_spec; - struct ethtool_usrip4_spec usr_ip4_spec; - struct ethhdr ether_spec; - __u8 hdata[72]; - } h_u, m_u; - - __u16 vlan_tag; - __u16 vlan_tag_mask; - __u64 data; - __u64 data_mask; - - __s32 action; -#define ETHTOOL_RXNTUPLE_ACTION_DROP (-1) /* drop packet */ -#define ETHTOOL_RXNTUPLE_ACTION_CLEAR (-2) /* clear filter */ -}; - -/** - * struct ethtool_rx_ntuple - command to set or clear RX flow filter - * @cmd: Command number - %ETHTOOL_SRXNTUPLE - * @fs: Flow filter specification - */ -struct ethtool_rx_ntuple { - __u32 cmd; - struct ethtool_rx_ntuple_flow_spec fs; -}; - -#define ETHTOOL_FLASH_MAX_FILENAME 128 -enum ethtool_flash_op_type { - ETHTOOL_FLASH_ALL_REGIONS = 0, -}; - -/* for passing firmware flashing related parameters */ -struct ethtool_flash { - __u32 cmd; - __u32 region; - char data[ETHTOOL_FLASH_MAX_FILENAME]; -}; - -/** - * struct ethtool_dump - used for retrieving, setting device dump - * @cmd: Command number - %ETHTOOL_GET_DUMP_FLAG, %ETHTOOL_GET_DUMP_DATA, or - * %ETHTOOL_SET_DUMP - * @version: FW version of the dump, filled in by driver - * @flag: driver dependent flag for dump setting, filled in by driver during - * get and filled in by ethtool for set operation. - * flag must be initialized by macro ETH_FW_DUMP_DISABLE value when - * firmware dump is disabled. - * @len: length of dump data, used as the length of the user buffer on entry to - * %ETHTOOL_GET_DUMP_DATA and this is returned as dump length by driver - * for %ETHTOOL_GET_DUMP_FLAG command - * @data: data collected for get dump data operation - */ - -#define ETH_FW_DUMP_DISABLE 0 - -struct ethtool_dump { - __u32 cmd; - __u32 version; - __u32 flag; - __u32 len; - __u8 data[0]; -}; - -/* for returning and changing feature sets */ - -/** - * struct ethtool_get_features_block - block with state of 32 features - * @available: mask of changeable features - * @requested: mask of features requested to be enabled if possible - * @active: mask of currently enabled features - * @never_changed: mask of features not changeable for any device - */ -struct ethtool_get_features_block { - __u32 available; - __u32 requested; - __u32 active; - __u32 never_changed; -}; - -/** - * struct ethtool_gfeatures - command to get state of device's features - * @cmd: command number = %ETHTOOL_GFEATURES - * @size: in: number of elements in the features[] array; - * out: number of elements in features[] needed to hold all features - * @features: state of features - */ -struct ethtool_gfeatures { - __u32 cmd; - __u32 size; - struct ethtool_get_features_block features[0]; -}; - -/** - * struct ethtool_set_features_block - block with request for 32 features - * @valid: mask of features to be changed - * @requested: values of features to be changed - */ -struct ethtool_set_features_block { - __u32 valid; - __u32 requested; -}; - -/** - * struct ethtool_sfeatures - command to request change in device's features - * @cmd: command number = %ETHTOOL_SFEATURES - * @size: array size of the features[] array - * @features: feature change masks - */ -struct ethtool_sfeatures { - __u32 cmd; - __u32 size; - struct ethtool_set_features_block features[0]; -}; - -/** - * struct ethtool_ts_info - holds a device's timestamping and PHC association - * @cmd: command number = %ETHTOOL_GET_TS_INFO - * @so_timestamping: bit mask of the sum of the supported SO_TIMESTAMPING flags - * @phc_index: device index of the associated PHC, or -1 if there is none - * @tx_types: bit mask of the supported hwtstamp_tx_types enumeration values - * @rx_filters: bit mask of the supported hwtstamp_rx_filters enumeration values - * - * The bits in the 'tx_types' and 'rx_filters' fields correspond to - * the 'hwtstamp_tx_types' and 'hwtstamp_rx_filters' enumeration values, - * respectively. For example, if the device supports HWTSTAMP_TX_ON, - * then (1 << HWTSTAMP_TX_ON) in 'tx_types' will be set. - */ -struct ethtool_ts_info { - __u32 cmd; - __u32 so_timestamping; - __s32 phc_index; - __u32 tx_types; - __u32 tx_reserved[3]; - __u32 rx_filters; - __u32 rx_reserved[3]; -}; - -/* - * %ETHTOOL_SFEATURES changes features present in features[].valid to the - * values of corresponding bits in features[].requested. Bits in .requested - * not set in .valid or not changeable are ignored. - * - * Returns %EINVAL when .valid contains undefined or never-changeable bits - * or size is not equal to required number of features words (32-bit blocks). - * Returns >= 0 if request was completed; bits set in the value mean: - * %ETHTOOL_F_UNSUPPORTED - there were bits set in .valid that are not - * changeable (not present in %ETHTOOL_GFEATURES' features[].available) - * those bits were ignored. - * %ETHTOOL_F_WISH - some or all changes requested were recorded but the - * resulting state of bits masked by .valid is not equal to .requested. - * Probably there are other device-specific constraints on some features - * in the set. When %ETHTOOL_F_UNSUPPORTED is set, .valid is considered - * here as though ignored bits were cleared. - * %ETHTOOL_F_COMPAT - some or all changes requested were made by calling - * compatibility functions. Requested offload state cannot be properly - * managed by kernel. - * - * Meaning of bits in the masks are obtained by %ETHTOOL_GSSET_INFO (number of - * bits in the arrays - always multiple of 32) and %ETHTOOL_GSTRINGS commands - * for ETH_SS_FEATURES string set. First entry in the table corresponds to least - * significant bit in features[0] fields. Empty strings mark undefined features. - */ -enum ethtool_sfeatures_retval_bits { - ETHTOOL_F_UNSUPPORTED__BIT, - ETHTOOL_F_WISH__BIT, - ETHTOOL_F_COMPAT__BIT, -}; - -#define ETHTOOL_F_UNSUPPORTED (1 << ETHTOOL_F_UNSUPPORTED__BIT) -#define ETHTOOL_F_WISH (1 << ETHTOOL_F_WISH__BIT) -#define ETHTOOL_F_COMPAT (1 << ETHTOOL_F_COMPAT__BIT) - - -/* CMDs currently supported */ -#define ETHTOOL_GSET 0x00000001 /* Get settings. */ -#define ETHTOOL_SSET 0x00000002 /* Set settings. */ -#define ETHTOOL_GDRVINFO 0x00000003 /* Get driver info. */ -#define ETHTOOL_GREGS 0x00000004 /* Get NIC registers. */ -#define ETHTOOL_GWOL 0x00000005 /* Get wake-on-lan options. */ -#define ETHTOOL_SWOL 0x00000006 /* Set wake-on-lan options. */ -#define ETHTOOL_GMSGLVL 0x00000007 /* Get driver message level */ -#define ETHTOOL_SMSGLVL 0x00000008 /* Set driver msg level. */ -#define ETHTOOL_NWAY_RST 0x00000009 /* Restart autonegotiation. */ -/* Get link status for host, i.e. whether the interface *and* the - * physical port (if there is one) are up (ethtool_value). */ -#define ETHTOOL_GLINK 0x0000000a -#define ETHTOOL_GEEPROM 0x0000000b /* Get EEPROM data */ -#define ETHTOOL_SEEPROM 0x0000000c /* Set EEPROM data. */ -#define ETHTOOL_GCOALESCE 0x0000000e /* Get coalesce config */ -#define ETHTOOL_SCOALESCE 0x0000000f /* Set coalesce config. */ -#define ETHTOOL_GRINGPARAM 0x00000010 /* Get ring parameters */ -#define ETHTOOL_SRINGPARAM 0x00000011 /* Set ring parameters. */ -#define ETHTOOL_GPAUSEPARAM 0x00000012 /* Get pause parameters */ -#define ETHTOOL_SPAUSEPARAM 0x00000013 /* Set pause parameters. */ -#define ETHTOOL_GRXCSUM 0x00000014 /* Get RX hw csum enable (ethtool_value) */ -#define ETHTOOL_SRXCSUM 0x00000015 /* Set RX hw csum enable (ethtool_value) */ -#define ETHTOOL_GTXCSUM 0x00000016 /* Get TX hw csum enable (ethtool_value) */ -#define ETHTOOL_STXCSUM 0x00000017 /* Set TX hw csum enable (ethtool_value) */ -#define ETHTOOL_GSG 0x00000018 /* Get scatter-gather enable - * (ethtool_value) */ -#define ETHTOOL_SSG 0x00000019 /* Set scatter-gather enable - * (ethtool_value). */ -#define ETHTOOL_TEST 0x0000001a /* execute NIC self-test. */ -#define ETHTOOL_GSTRINGS 0x0000001b /* get specified string set */ -#define ETHTOOL_PHYS_ID 0x0000001c /* identify the NIC */ -#define ETHTOOL_GSTATS 0x0000001d /* get NIC-specific statistics */ -#define ETHTOOL_GTSO 0x0000001e /* Get TSO enable (ethtool_value) */ -#define ETHTOOL_STSO 0x0000001f /* Set TSO enable (ethtool_value) */ -#define ETHTOOL_GPERMADDR 0x00000020 /* Get permanent hardware address */ -#define ETHTOOL_GUFO 0x00000021 /* Get UFO enable (ethtool_value) */ -#define ETHTOOL_SUFO 0x00000022 /* Set UFO enable (ethtool_value) */ -#define ETHTOOL_GGSO 0x00000023 /* Get GSO enable (ethtool_value) */ -#define ETHTOOL_SGSO 0x00000024 /* Set GSO enable (ethtool_value) */ -#define ETHTOOL_GFLAGS 0x00000025 /* Get flags bitmap(ethtool_value) */ -#define ETHTOOL_SFLAGS 0x00000026 /* Set flags bitmap(ethtool_value) */ -#define ETHTOOL_GPFLAGS 0x00000027 /* Get driver-private flags bitmap */ -#define ETHTOOL_SPFLAGS 0x00000028 /* Set driver-private flags bitmap */ - -#define ETHTOOL_GRXFH 0x00000029 /* Get RX flow hash configuration */ -#define ETHTOOL_SRXFH 0x0000002a /* Set RX flow hash configuration */ -#define ETHTOOL_GGRO 0x0000002b /* Get GRO enable (ethtool_value) */ -#define ETHTOOL_SGRO 0x0000002c /* Set GRO enable (ethtool_value) */ -#define ETHTOOL_GRXRINGS 0x0000002d /* Get RX rings available for LB */ -#define ETHTOOL_GRXCLSRLCNT 0x0000002e /* Get RX class rule count */ -#define ETHTOOL_GRXCLSRULE 0x0000002f /* Get RX classification rule */ -#define ETHTOOL_GRXCLSRLALL 0x00000030 /* Get all RX classification rule */ -#define ETHTOOL_SRXCLSRLDEL 0x00000031 /* Delete RX classification rule */ -#define ETHTOOL_SRXCLSRLINS 0x00000032 /* Insert RX classification rule */ -#define ETHTOOL_FLASHDEV 0x00000033 /* Flash firmware to device */ -#define ETHTOOL_RESET 0x00000034 /* Reset hardware */ -#define ETHTOOL_SRXNTUPLE 0x00000035 /* Add an n-tuple filter to device */ -#define ETHTOOL_GRXNTUPLE 0x00000036 /* deprecated */ -#define ETHTOOL_GSSET_INFO 0x00000037 /* Get string set info */ -#define ETHTOOL_GRXFHINDIR 0x00000038 /* Get RX flow hash indir'n table */ -#define ETHTOOL_SRXFHINDIR 0x00000039 /* Set RX flow hash indir'n table */ - -#define ETHTOOL_GFEATURES 0x0000003a /* Get device offload settings */ -#define ETHTOOL_SFEATURES 0x0000003b /* Change device offload settings */ -#define ETHTOOL_GCHANNELS 0x0000003c /* Get no of channels */ -#define ETHTOOL_SCHANNELS 0x0000003d /* Set no of channels */ -#define ETHTOOL_SET_DUMP 0x0000003e /* Set dump settings */ -#define ETHTOOL_GET_DUMP_FLAG 0x0000003f /* Get dump settings */ -#define ETHTOOL_GET_DUMP_DATA 0x00000040 /* Get dump data */ -#define ETHTOOL_GET_TS_INFO 0x00000041 /* Get time stamping and PHC info */ -#define ETHTOOL_GMODULEINFO 0x00000042 /* Get plug-in module information */ -#define ETHTOOL_GMODULEEEPROM 0x00000043 /* Get plug-in module eeprom */ -#define ETHTOOL_GEEE 0x00000044 /* Get EEE settings */ -#define ETHTOOL_SEEE 0x00000045 /* Set EEE settings */ - -/* compatibility with older code */ -#define SPARC_ETH_GSET ETHTOOL_GSET -#define SPARC_ETH_SSET ETHTOOL_SSET - -/* Indicates what features are supported by the interface. */ -#define SUPPORTED_10baseT_Half (1 << 0) -#define SUPPORTED_10baseT_Full (1 << 1) -#define SUPPORTED_100baseT_Half (1 << 2) -#define SUPPORTED_100baseT_Full (1 << 3) -#define SUPPORTED_1000baseT_Half (1 << 4) -#define SUPPORTED_1000baseT_Full (1 << 5) -#define SUPPORTED_Autoneg (1 << 6) -#define SUPPORTED_TP (1 << 7) -#define SUPPORTED_AUI (1 << 8) -#define SUPPORTED_MII (1 << 9) -#define SUPPORTED_FIBRE (1 << 10) -#define SUPPORTED_BNC (1 << 11) -#define SUPPORTED_10000baseT_Full (1 << 12) -#define SUPPORTED_Pause (1 << 13) -#define SUPPORTED_Asym_Pause (1 << 14) -#define SUPPORTED_2500baseX_Full (1 << 15) -#define SUPPORTED_Backplane (1 << 16) -#define SUPPORTED_1000baseKX_Full (1 << 17) -#define SUPPORTED_10000baseKX4_Full (1 << 18) -#define SUPPORTED_10000baseKR_Full (1 << 19) -#define SUPPORTED_10000baseR_FEC (1 << 20) -#define SUPPORTED_20000baseMLD2_Full (1 << 21) -#define SUPPORTED_20000baseKR2_Full (1 << 22) -#define SUPPORTED_40000baseKR4_Full (1 << 23) -#define SUPPORTED_40000baseCR4_Full (1 << 24) -#define SUPPORTED_40000baseSR4_Full (1 << 25) -#define SUPPORTED_40000baseLR4_Full (1 << 26) - -/* Indicates what features are advertised by the interface. */ -#define ADVERTISED_10baseT_Half (1 << 0) -#define ADVERTISED_10baseT_Full (1 << 1) -#define ADVERTISED_100baseT_Half (1 << 2) -#define ADVERTISED_100baseT_Full (1 << 3) -#define ADVERTISED_1000baseT_Half (1 << 4) -#define ADVERTISED_1000baseT_Full (1 << 5) -#define ADVERTISED_Autoneg (1 << 6) -#define ADVERTISED_TP (1 << 7) -#define ADVERTISED_AUI (1 << 8) -#define ADVERTISED_MII (1 << 9) -#define ADVERTISED_FIBRE (1 << 10) -#define ADVERTISED_BNC (1 << 11) -#define ADVERTISED_10000baseT_Full (1 << 12) -#define ADVERTISED_Pause (1 << 13) -#define ADVERTISED_Asym_Pause (1 << 14) -#define ADVERTISED_2500baseX_Full (1 << 15) -#define ADVERTISED_Backplane (1 << 16) -#define ADVERTISED_1000baseKX_Full (1 << 17) -#define ADVERTISED_10000baseKX4_Full (1 << 18) -#define ADVERTISED_10000baseKR_Full (1 << 19) -#define ADVERTISED_10000baseR_FEC (1 << 20) -#define ADVERTISED_20000baseMLD2_Full (1 << 21) -#define ADVERTISED_20000baseKR2_Full (1 << 22) -#define ADVERTISED_40000baseKR4_Full (1 << 23) -#define ADVERTISED_40000baseCR4_Full (1 << 24) -#define ADVERTISED_40000baseSR4_Full (1 << 25) -#define ADVERTISED_40000baseLR4_Full (1 << 26) - -/* The following are all involved in forcing a particular link - * mode for the device for setting things. When getting the - * devices settings, these indicate the current mode and whether - * it was forced up into this mode or autonegotiated. - */ - -/* The forced speed, 10Mb, 100Mb, gigabit, 2.5Gb, 10GbE. */ -#define SPEED_10 10 -#define SPEED_100 100 -#define SPEED_1000 1000 -#define SPEED_2500 2500 -#define SPEED_10000 10000 -#define SPEED_UNKNOWN -1 - -/* Duplex, half or full. */ -#define DUPLEX_HALF 0x00 -#define DUPLEX_FULL 0x01 -#define DUPLEX_UNKNOWN 0xff - -/* Which connector port. */ -#define PORT_TP 0x00 -#define PORT_AUI 0x01 -#define PORT_MII 0x02 -#define PORT_FIBRE 0x03 -#define PORT_BNC 0x04 -#define PORT_DA 0x05 -#define PORT_NONE 0xef -#define PORT_OTHER 0xff - -/* Which transceiver to use. */ -#define XCVR_INTERNAL 0x00 -#define XCVR_EXTERNAL 0x01 -#define XCVR_DUMMY1 0x02 -#define XCVR_DUMMY2 0x03 -#define XCVR_DUMMY3 0x04 - -/* Enable or disable autonegotiation. If this is set to enable, - * the forced link modes above are completely ignored. - */ -#define AUTONEG_DISABLE 0x00 -#define AUTONEG_ENABLE 0x01 - -/* MDI or MDI-X status/control - if MDI/MDI_X/AUTO is set then - * the driver is required to renegotiate link - */ -#define ETH_TP_MDI_INVALID 0x00 /* status: unknown; control: unsupported */ -#define ETH_TP_MDI 0x01 /* status: MDI; control: force MDI */ -#define ETH_TP_MDI_X 0x02 /* status: MDI-X; control: force MDI-X */ -#define ETH_TP_MDI_AUTO 0x03 /* control: auto-select */ - -/* Wake-On-Lan options. */ -#define WAKE_PHY (1 << 0) -#define WAKE_UCAST (1 << 1) -#define WAKE_MCAST (1 << 2) -#define WAKE_BCAST (1 << 3) -#define WAKE_ARP (1 << 4) -#define WAKE_MAGIC (1 << 5) -#define WAKE_MAGICSECURE (1 << 6) /* only meaningful if WAKE_MAGIC */ - -/* L2-L4 network traffic flow types */ -#define TCP_V4_FLOW 0x01 /* hash or spec (tcp_ip4_spec) */ -#define UDP_V4_FLOW 0x02 /* hash or spec (udp_ip4_spec) */ -#define SCTP_V4_FLOW 0x03 /* hash or spec (sctp_ip4_spec) */ -#define AH_ESP_V4_FLOW 0x04 /* hash only */ -#define TCP_V6_FLOW 0x05 /* hash only */ -#define UDP_V6_FLOW 0x06 /* hash only */ -#define SCTP_V6_FLOW 0x07 /* hash only */ -#define AH_ESP_V6_FLOW 0x08 /* hash only */ -#define AH_V4_FLOW 0x09 /* hash or spec (ah_ip4_spec) */ -#define ESP_V4_FLOW 0x0a /* hash or spec (esp_ip4_spec) */ -#define AH_V6_FLOW 0x0b /* hash only */ -#define ESP_V6_FLOW 0x0c /* hash only */ -#define IP_USER_FLOW 0x0d /* spec only (usr_ip4_spec) */ -#define IPV4_FLOW 0x10 /* hash only */ -#define IPV6_FLOW 0x11 /* hash only */ -#define ETHER_FLOW 0x12 /* spec only (ether_spec) */ -/* Flag to enable additional fields in struct ethtool_rx_flow_spec */ -#define FLOW_EXT 0x80000000 -#define FLOW_MAC_EXT 0x40000000 - -/* L3-L4 network traffic flow hash options */ -#define RXH_L2DA (1 << 1) -#define RXH_VLAN (1 << 2) -#define RXH_L3_PROTO (1 << 3) -#define RXH_IP_SRC (1 << 4) -#define RXH_IP_DST (1 << 5) -#define RXH_L4_B_0_1 (1 << 6) /* src port in case of TCP/UDP/SCTP */ -#define RXH_L4_B_2_3 (1 << 7) /* dst port in case of TCP/UDP/SCTP */ -#define RXH_DISCARD (1 << 31) - -#define RX_CLS_FLOW_DISC 0xffffffffffffffffULL - -/* Special RX classification rule insert location values */ -#define RX_CLS_LOC_SPECIAL 0x80000000 /* flag */ -#define RX_CLS_LOC_ANY 0xffffffff -#define RX_CLS_LOC_FIRST 0xfffffffe -#define RX_CLS_LOC_LAST 0xfffffffd - -/* EEPROM Standards for plug in modules */ -#define ETH_MODULE_SFF_8079 0x1 -#define ETH_MODULE_SFF_8079_LEN 256 -#define ETH_MODULE_SFF_8472 0x2 -#define ETH_MODULE_SFF_8472_LEN 512 - -/* Reset flags */ -/* The reset() operation must clear the flags for the components which - * were actually reset. On successful return, the flags indicate the - * components which were not reset, either because they do not exist - * in the hardware or because they cannot be reset independently. The - * driver must never reset any components that were not requested. - */ -enum ethtool_reset_flags { - /* These flags represent components dedicated to the interface - * the command is addressed to. Shift any flag left by - * ETH_RESET_SHARED_SHIFT to reset a shared component of the - * same type. - */ - ETH_RESET_MGMT = 1 << 0, /* Management processor */ - ETH_RESET_IRQ = 1 << 1, /* Interrupt requester */ - ETH_RESET_DMA = 1 << 2, /* DMA engine */ - ETH_RESET_FILTER = 1 << 3, /* Filtering/flow direction */ - ETH_RESET_OFFLOAD = 1 << 4, /* Protocol offload */ - ETH_RESET_MAC = 1 << 5, /* Media access controller */ - ETH_RESET_PHY = 1 << 6, /* Transceiver/PHY */ - ETH_RESET_RAM = 1 << 7, /* RAM shared between - * multiple components */ - - ETH_RESET_DEDICATED = 0x0000ffff, /* All components dedicated to - * this interface */ - ETH_RESET_ALL = 0xffffffff, /* All components used by this - * interface, even if shared */ -}; -#define ETH_RESET_SHARED_SHIFT 16 - -#endif /* _LINUX_ETHTOOL_H */ diff --git a/quectel_cm_5G/src/log/cdc_mbim.txt b/quectel_cm_5G/src/log/cdc_mbim.txt deleted file mode 100644 index 8acdfde..0000000 --- a/quectel_cm_5G/src/log/cdc_mbim.txt +++ /dev/null @@ -1,71 +0,0 @@ -root@ZhuoTK:/# dmesg -[ 788.920000] usb 1-1.3: new high-speed USB device number 4 using ehci-platform -[ 789.160000] cdc_mbim 1-1.3:1.4: cdc-wdm0: USB WDM device -[ 789.170000] cdc_mbim 1-1.3:1.4 wwan0: register 'cdc_mbim' at usb-101c0000.ehci-1.3, CDC MBIM, a2:58:dc:4d:dd:ca - -root@ZhuoTK:/# quectel-CM -s cmnet & -[04-13_05:24:38:767] Quectel_QConnectManager_Linux_V1.6.0.25 -[04-13_05:24:38:769] Find /sys/bus/usb/devices/1-1.3 idVendor=0x2c7c idProduct=0x125, bus=0x001, dev=0x004 -[04-13_05:24:38:771] Auto find qmichannel = /dev/cdc-wdm0 -[04-13_05:24:38:771] Auto find usbnet_adapter = wwan0 -[04-13_05:24:38:771] netcard driver = cdc_mbim, driver version = 22-Aug-2005 -[04-13_05:24:38:771] Modem works in MBIM mode -[04-13_05:24:38:779] cdc_wdm_fd = 7 -[04-13_05:24:38:779] mbim_open_device() -[04-13_05:24:39:624] mbim_device_caps_query() -[04-13_05:24:39:656] DeviceId: 866758045439136 -[04-13_05:24:39:656] FirmwareInfo: EC25EFAR06A11M4G -[04-13_05:24:39:656] HardwareInfo: QUECTEL Mobile Broadband Modul -[04-13_05:24:39:657] mbim_device_services_query() -[04-13_05:24:39:688] mbim_set_radio_state( 1 ) -[04-13_05:24:39:721] HwRadioState: 1, SwRadioState: 1 -[04-13_05:24:39:721] mbim_subscriber_status_query() -[04-13_05:24:39:784] SubscriberId: 460028563800461 -[04-13_05:24:39:784] SimIccId: 89860015120716380461 -[04-13_05:24:39:785] SubscriberReadyState NotInitialized -> Initialized -[04-13_05:24:39:785] mbim_register_state_query() -[04-13_05:24:39:816] RegisterState Unknown -> Home -[04-13_05:24:39:816] mbim_packet_service_query() -[04-13_05:24:39:848] PacketServiceState Unknown -> Attached -[04-13_05:24:39:848] mbim_query_connect(sessionID=0) -[04-13_05:24:39:880] ActivationState Unknown -> Deactivated -[04-13_05:24:39:881] ifconfig wwan0 0.0.0.0 -[04-13_05:24:39:899] ifconfig wwan0 down -[04-13_05:24:39:913] mbim_set_connect(onoff=1, sessionID=0) -[04-13_05:24:39:976] ActivationState Deactivated -> Activated -[04-13_05:24:39:977] mbim_ip_config(sessionID=0) -[04-13_05:24:40:008] < SessionId = 0 -[04-13_05:24:40:008] < IPv4ConfigurationAvailable = 0xf -[04-13_05:24:40:008] < IPv6ConfigurationAvailable = 0x0 -[04-13_05:24:40:008] < IPv4AddressCount = 0x1 -[04-13_05:24:40:008] < IPv4AddressOffset = 0x3c -[04-13_05:24:40:009] < IPv6AddressCount = 0x0 -[04-13_05:24:40:009] < IPv6AddressOffset = 0x0 -[04-13_05:24:40:009] < IPv4 = 10.129.90.29/30 -[04-13_05:24:40:009] < gw = 10.129.90.30 -[04-13_05:24:40:009] < dns1 = 211.138.180.2 -[04-13_05:24:40:009 < dns2 = 211.138.180.3 -[04-13_05:24:40:009] < ipv4 mtu = 1500 -[04-13_05:24:40:041] ifconfig wwan0 up -[04-13_05:24:40:063] ip -4 address flush dev wwan0 -[04-13_05:24:40:073] ip -4 address add 10.129.90.29/30 dev wwan0 -[04-13_05:24:40:084] ip -4 route add default via 10.129.90.30 dev wwan0 - -root@ZhuoTK:/# ifconfig wwan0 -wwan0 Link encap:Ethernet HWaddr A2:58:DC:4D:DD:CA - inet addr:10.129.90.29 Bcast:0.0.0.0 Mask:255.255.255.252 - inet6 addr: fe80::a058:dcff:fe4d:ddca/64 Scope:Link - UP BROADCAST RUNNING NOARP MULTICAST MTU:1500 Metric:1 - RX packets:0 errors:0 dropped:0 overruns:0 frame:0 - TX packets:5 errors:0 dropped:0 overruns:0 carrier:0 - collisions:0 txqueuelen:1000 - RX bytes:0 (0.0 B) TX bytes:380 (380.0 B) - -root@ZhuoTK:/# ip ro show -default via 10.129.90.30 dev wwan0 -10.129.90.28/30 dev wwan0 proto kernel scope link src 10.129.90.29 -192.168.1.0/24 dev br-lan proto kernel scope link src 192.168.1.251 - -root@ZhuoTK:/# ping www.qq.com -PING www.qq.com (183.194.238.117): 56 data bytes -64 bytes from 183.194.238.117: seq=0 ttl=53 time=58.674 ms \ No newline at end of file diff --git a/quectel_cm_5G/src/log/cdc_mbim_vlan.txt b/quectel_cm_5G/src/log/cdc_mbim_vlan.txt deleted file mode 100644 index 79e15a4..0000000 --- a/quectel_cm_5G/src/log/cdc_mbim_vlan.txt +++ /dev/null @@ -1,168 +0,0 @@ -root@ZhuoTK:/# dmesg -[ 788.920000] usb 1-1.3: new high-speed USB device number 4 using ehci-platform -[ 789.160000] cdc_mbim 1-1.3:1.4: cdc-wdm0: USB WDM device -[ 789.170000] cdc_mbim 1-1.3:1.4 wwan0: register 'cdc_mbim' at usb-101c0000.ehci-1.3, CDC MBIM, a2:58:dc:4d:dd:ca - -root@ZhuoTK:/# ip link add link wwan0 name wwan0.1 type vlan id 1 -root@ZhuoTK:/# ip link add link wwan0 name wwan0.2 type vlan id 2 -root@ZhuoTK:/# ifconfig wwan0.1 -wwan0.1 Link encap:Ethernet HWaddr A2:58:DC:4D:DD:CA - BROADCAST NOARP MULTICAST MTU:1500 Metric:1 - RX packets:0 errors:0 dropped:0 overruns:0 frame:0 - TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 - collisions:0 txqueuelen:0 - RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) - -root@ZhuoTK:/# ifconfig wwan0.2 -wwan0.2 Link encap:Ethernet HWaddr A2:58:DC:4D:DD:CA - BROADCAST NOARP MULTICAST MTU:1500 Metric:1 - RX packets:0 errors:0 dropped:0 overruns:0 frame:0 - TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 - collisions:0 txqueuelen:0 - RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) - -root@ZhuoTK:/# quectel-mbim-proxy & -root@ZhuoTK:/# [04-13_07:04:27:543] mbim_dev_fd=3 -[04-13_07:04:27:543] mbim_send_open_msg() -[04-13_07:04:28:321] receive MBIM_OPEN_DONE, status=0 -[04-13_07:04:28:321] mbim_server_fd=4 - -root@ZhuoTK:/# quectel-CM -n 1 -s cmnet & -[04-13_07:04:34:256] Quectel_QConnectManager_Linux_V1.6.0.25 -[04-13_07:04:34:259] Find /sys/bus/usb/devices/1-1.3 idVendor=0x2c7c idProduct=0x125, bus=0x001, dev=0x004 -[04-13_07:04:34:260] Auto find qmichannel = /dev/cdc-wdm0 -[04-13_07:04:34:260] Auto find usbnet_adapter = wwan0 -[04-13_07:04:34:260] netcard driver = cdc_mbim, driver version = 22-Aug-2005 -[04-13_07:04:34:261] mbim_qmap_mode = 4, vlan_id = 0x01, qmap_netcard = wwan0.1 -[04-13_07:04:34:261] Modem works in MBIM mode -[04-13_07:04:34:261] handle_client_connect client_fd=5, client_idx=1 -[04-13_07:04:34:262] connect to quectel-mbim-proxy sockfd = 7 -[04-13_07:04:34:262] cdc_wdm_fd = 7 -[04-13_07:04:34:262] mbim_open_device() -[04-13_07:04:35:106] mbim_device_caps_query() -[04-13_07:04:35:139] DeviceId: 866758045439136 -[04-13_07:04:35:139] FirmwareInfo: EC25EFAR06A11M4G -[04-13_07:04:35:139] HardwareInfo: QUECTEL Mobile Broadband Modul -[04-13_07:04:35:139] mbim_device_services_query() -[04-13_07:04:35:170] mbim_set_radio_state( 1 ) -[04-13_07:04:35:202] HwRadioState: 1, SwRadioState: 1 -[04-13_07:04:35:202] mbim_subscriber_status_query() -[04-13_07:04:35:267] SubscriberId: 460028563800461 -[04-13_07:04:35:267] SimIccId: 89860015120716380461 -[04-13_07:04:35:267] SubscriberReadyState NotInitialized -> Initialized -[04-13_07:04:35:267] mbim_register_state_query() -[04-13_07:04:35:297] RegisterState Unknown -> Home -[04-13_07:04:35:298] mbim_packet_service_query() -[04-13_07:04:35:329] PacketServiceState Unknown -> Attached -[04-13_07:04:35:330] mbim_query_connect(sessionID=1) -[04-13_07:04:35:361] ActivationState Unknown -> Deactivated -[04-13_07:04:35:362] ifconfig wwan0.1 0.0.0.0 -[04-13_07:04:35:373] ifconfig wwan0.1 down -[04-13_07:04:35:383] mbim_set_connect(onoff=1, sessionID=1) -[04-13_07:04:35:426] ActivationState Deactivated -> Activated -[04-13_07:04:35:426] mbim_ip_config(sessionID=1) -[04-13_07:04:35:457] < SessionId = 1 -[04-13_07:04:35:457] < IPv4ConfigurationAvailable = 0xf -[04-13_07:04:35:457] < IPv6ConfigurationAvailable = 0x0 -[04-13_07:04:35:457] < IPv4AddressCount = 0x1 -[04-13_07:04:35:458] < IPv4AddressOffset = 0x3c -[04-13_07:04:35:458] < IPv6AddressCount = 0x0 -[04-13_07:04:35:458] < IPv6AddressOffset = 0x0 -[04-13_07:04:35:458] < IPv4 = 10.129.90.29/30 -[04-13_07:04:35:458] < gw = 10.129.90.30 -[04-13_07:04:35:458] < dns1 = 211.138.180.2 -[04-13_07:04:35:458] < dns2 = 211.138.180.3 -[04-13_07:04:35:458] < ipv4 mtu = 1500 -[04-13_07:04:35:489] ifconfig wwan0 up -[04-13_07:04:35:509] ifconfig wwan0.1 down -[04-13_07:04:35:522] ifconfig wwan0.1 up -[04-13_07:04:35:535] ip -4 address flush dev wwan0.1 -[04-13_07:04:35:545] ip -4 address add 10.129.90.29/30 dev wwan0.1 -[04-13_07:04:35:556] ip -4 route add default via 10.129.90.30 dev wwan0.1 - -root@ZhuoTK:/# quectel-CM -n 2 -s 4gnet & -[04-13_07:04:45:150] Quectel_QConnectManager_Linux_V1.6.0.25 -[04-13_07:04:45:152] Find /sys/bus/usb/devices/1-1.3 idVendor=0x2c7c idProduct=0x125, bus=0x001, dev=0x004 -[04-13_07:04:45:154] Auto find qmichannel = /dev/cdc-wdm0 -[04-13_07:04:45:154] Auto find usbnet_adapter = wwan0 -[04-13_07:04:45:154] netcard driver = cdc_mbim, driver version = 22-Aug-2005 -[04-13_07:04:45:155] mbim_qmap_mode = 4, vlan_id = 0x02, qmap_netcard = wwan0.2 -[04-13_07:04:45:155] Modem works in MBIM mode -[04-13_07:04:45:155] handle_client_connect client_fd=6, client_idx=2 -[04-13_07:04:45:156] connect to quectel-mbim-proxy sockfd = 7 -[04-13_07:04:45:156] cdc_wdm_fd = 7 -[04-13_07:04:45:156] mbim_open_device() -[04-13_07:04:46:025] mbim_device_caps_query() -[04-13_07:04:46:056] DeviceId: 866758045439136 -[04-13_07:04:46:056] FirmwareInfo: EC25EFAR06A11M4G -[04-13_07:04:46:056] HardwareInfo: QUECTEL Mobile Broadband Modul -[04-13_07:04:46:056] mbim_device_services_query() -[04-13_07:04:46:088] mbim_set_radio_state( 1 ) -[04-13_07:04:46:119] HwRadioState: 1, SwRadioState: 1 -[04-13_07:04:46:119] mbim_subscriber_status_query() -[04-13_07:04:46:183] SubscriberId: 460028563800461 -[04-13_07:04:46:184] SimIccId: 89860015120716380461 -[04-13_07:04:46:184] SubscriberReadyState NotInitialized -> Initialized -[04-13_07:04:46:184] mbim_register_state_query() -[04-13_07:04:46:216] RegisterState Unknown -> Home -[04-13_07:04:46:216] mbim_packet_service_query() -[04-13_07:04:46:248] PacketServiceState Unknown -> Attached -[04-13_07:04:46:248] mbim_query_connect(sessionID=2) -[04-13_07:04:46:280] ActivationState Unknown -> Deactivated -[04-13_07:04:46:280] ifconfig wwan0.2 0.0.0.0 -[04-13_07:04:46:291] ifconfig wwan0.2 down -[04-13_07:04:46:304] mbim_set_connect(onoff=1, sessionID=2) -[04-13_07:04:46:504] ActivationState Deactivated -> Activated -[04-13_07:04:46:505] mbim_ip_config(sessionID=2) -[04-13_07:04:46:537] < SessionId = 2 -[04-13_07:04:46:537] < IPv4ConfigurationAvailable = 0xf -[04-13_07:04:46:537] < IPv6ConfigurationAvailable = 0x0 -[04-13_07:04:46:538] < IPv4AddressCount = 0x1 -[04-13_07:04:46:538] < IPv4AddressOffset = 0x3c -[04-13_07:04:46:538] < IPv6AddressCount = 0x0 -[04-13_07:04:46:538] < IPv6AddressOffset = 0x0 -[04-13_07:04:46:538] < IPv4 = 10.129.37.205/30 -[04-13_07:04:46:538] < gw = 10.129.37.206 -[04-13_07:04:46:538] < dns1 = 211.138.180.2 -[04-13_07:04:46:538] < dns2 = 211.138.180.3 -[04-13_07:04:46:538] < ipv4 mtu = 1500 -[04-13_07:04:46:569] ifconfig wwan0 up -[04-13_07:04:46:579] ifconfig wwan0.2 up -[04-13_07:04:46:592] ip -4 address flush dev wwan0.2 -[04-13_07:04:46:602] ip -4 address add 10.129.37.205/30 dev wwan0.2 -[04-13_07:04:46:613] ip -4 route add default via 10.129.37.206 dev wwan0.2 - -root@ZhuoTK:/# ifconfig wwan0.1 -wwan0.1 Link encap:Ethernet HWaddr A2:58:DC:4D:DD:CA - inet addr:10.129.90.29 Bcast:0.0.0.0 Mask:255.255.255.252 - inet6 addr: fe80::a058:dcff:fe4d:ddca/64 Scope:Link - UP BROADCAST RUNNING NOARP MULTICAST MTU:1500 Metric:1 - RX packets:4 errors:0 dropped:0 overruns:0 frame:0 - TX packets:13 errors:0 dropped:0 overruns:0 carrier:0 - collisions:0 txqueuelen:0 - RX bytes:304 (304.0 B) TX bytes:1170 (1.1 KiB) - -root@ZhuoTK:/# ifconfig wwan0.2 -wwan0.2 Link encap:Ethernet HWaddr A2:58:DC:4D:DD:CA - inet addr:10.129.37.205 Bcast:0.0.0.0 Mask:255.255.255.252 - inet6 addr: fe80::a058:dcff:fe4d:ddca/64 Scope:Link - UP BROADCAST RUNNING NOARP MULTICAST MTU:1500 Metric:1 - RX packets:0 errors:0 dropped:0 overruns:0 frame:0 - TX packets:8 errors:0 dropped:0 overruns:0 carrier:0 - collisions:0 txqueuelen:0 - RX bytes:0 (0.0 B) TX bytes:720 (720.0 B) - -root@ZhuoTK:/# ip ro del 8.8.8.8/32 -RTNETLINK answers: No such process -root@ZhuoTK:/# ip ro add 8.8.8.8/32 dev wwan0.1 -root@ZhuoTK:/# ping 8.8.8.8 -PING 8.8.8.8 (8.8.8.8): 56 data bytes -64 bytes from 8.8.8.8: seq=0 ttl=52 time=98.584 ms - -root@ZhuoTK:/# ip ro del 8.8.8.8/32 -root@ZhuoTK:/# ip ro del 8.8.8.8/32 -RTNETLINK answers: No such process -root@ZhuoTK:/# ip ro add 8.8.8.8/32 dev wwan0.2 -root@ZhuoTK:/# ping 8.8.8.8 -PING 8.8.8.8 (8.8.8.8): 56 data bytes -64 bytes from 8.8.8.8: seq=0 ttl=111 time=101.770 ms \ No newline at end of file diff --git a/quectel_cm_5G/src/log/ecm_ncm_rndis.txt b/quectel_cm_5G/src/log/ecm_ncm_rndis.txt deleted file mode 100644 index 2ae7e6b..0000000 --- a/quectel_cm_5G/src/log/ecm_ncm_rndis.txt +++ /dev/null @@ -1,129 +0,0 @@ -# ./quectel-CM -s cmnet & -[04-21_17:35:14:362] Quectel_QConnectManager_Linux_V1.6.0.26 -[04-21_17:35:14:363] Find /sys/bus/usb/devices/2-4 idVendor=0x2c7c idProduct=0x8101, bus=0x002, dev=0x016 -[04-21_17:35:14:363] Auto find qmichannel = /dev/ttyUSB0 -[04-21_17:35:14:363] Auto find usbnet_adapter = usb0 -[04-21_17:35:14:363] netcard driver = cdc_ncm, driver version = 22-Aug-2005 -[04-21_17:35:14:363] Modem works in ECM_RNDIS_NCM mode -[04-21_17:35:14:371] atc_fd = 7 -[04-21_17:35:14:371] AT> ATE0Q0V1 -[04-21_17:35:14:372] AT< RDATE0Q0V1 -[04-21_17:35:14:372] AT< COMMAND NOT SUPPORT -[04-21_17:35:15:373] AT> AT+QCFG="usbnet" -[04-21_17:35:15:373] AT< +QCFG: "usbnet",5 -[04-21_17:35:15:373] AT< OK -[04-21_17:35:15:373] AT> AT+QNETDEVCTL=? -[04-21_17:35:15:374] AT< +QNETDEVCTL: (1-11),(0,1),(0,1) -[04-21_17:35:15:374] AT< OK -[04-21_17:35:15:374] AT> AT+CGREG=2 -[04-21_17:35:15:376] AT< OK -[04-21_17:35:15:376] AT> AT+CEREG=2 -[04-21_17:35:15:381] AT< OK -[04-21_17:35:15:381] AT> AT+C5GREG=2 -[04-21_17:35:15:384] AT< OK -[04-21_17:35:15:384] AT> AT+QNETDEVSTATUS=? -[04-21_17:35:15:385] AT< +QNETDEVSTATUS: (1-11) -[04-21_17:35:15:385] AT< OK -[04-21_17:35:15:385] AT> AT+QCFG="NAT" -[04-21_17:35:15:385] AT< +QCFG: "nat",0 -[04-21_17:35:15:385] AT< OK -[04-21_17:35:15:385] AT> AT+CGMR -[04-21_17:35:15:386] AT< RG801HEAAAR03A01M8G -[04-21_17:35:15:386] AT< OK -[04-21_17:35:15:386] AT> AT+CPIN? -[04-21_17:35:15:388] AT< +CPIN: READY -[04-21_17:35:15:388] AT< OK -[04-21_17:35:15:389] AT> AT+QCCID -[04-21_17:35:15:393] AT< +QCCID: 89860015120716380461 -[04-21_17:35:15:393] AT< OK -[04-21_17:35:15:393] requestGetICCID 89860015120716380461 -[04-21_17:35:15:393] AT> AT+CIMI -[04-21_17:35:15:409] AT< 460028563800461 -[04-21_17:35:15:409] AT< OK -[04-21_17:35:15:409] requestGetIMSI 460028563800461 -[04-21_17:35:15:409] AT> AT+QICSGP=1 -[04-21_17:35:15:411] AT< +QICSGP: 1,1,"cment","","",0,,0, -[04-21_17:35:15:411] AT< OK -[04-21_17:35:15:411] AT> AT+QICSGP=1 -[04-21_17:35:15:415] AT< +QICSGP: 1,1,"cment","","",0,,0, -[04-21_17:35:15:415] AT< OK -[04-21_17:35:15:415] AT> AT+COPS=3,0;+COPS?;+COPS=3,1;+COPS?;+COPS=3,2;+COPS? -[04-21_17:35:15:421] AT< +COPS: 0,0,"CHINA MOBILE",12 -[04-21_17:35:15:421] AT< +COPS: 0,1,"CMCC",12 -[04-21_17:35:15:421] AT< +COPS: 0,2,"46000",12 -[04-21_17:35:15:421] AT< OK -[04-21_17:35:15:421] AT> AT+C5GREG? -[04-21_17:35:15:424] AT< +C5GREG: 2,1,"46550B","0000000170C23000",11,1,"01" -[04-21_17:35:15:424] AT< OK -[04-21_17:35:15:424] AT> at+cops? -[04-21_17:35:15:427] AT< +COPS: 0,2,"46000",12 -[04-21_17:35:15:427] AT< OK -[04-21_17:35:15:427] AT> at+qeng="servingcell" -[04-21_17:35:15:441] AT< +QENG: "servingcell","NOCONN","NR5G-SA","TDD",460,00,170C23000,901,46550B,504990,41,-,-54,-10,16,-,- -[04-21_17:35:15:441] AT< OK -[04-21_17:35:15:441] AT> AT+QNETDEVSTATUS=1 -[04-21_17:35:15:445] AT< ERROR -[04-21_17:35:15:445] ifconfig usb0 0.0.0.0 -[04-21_17:35:15:446] ifconfig usb0 down -[04-21_17:35:15:448] AT> AT+QNETDEVCTL=1,1,0 -[04-21_17:35:15:454] AT< OK -[04-21_17:35:15:456] AT> AT+QNETDEVSTATUS=1 -[04-21_17:35:15:458] AT< ERROR -[04-21_17:35:15:989] AT< +QNETDEVSTATUS:1,1,"IPV4" -[04-21_17:35:16:459] AT> AT+QNETDEVSTATUS=1 -[04-21_17:35:16:461] AT< +QNETDEVSTATUS: 4F10190A,E0FFFFFF,4110190A,4110190A,02B48AD3,03B48AD3, 85600, 85600 -[04-21_17:35:16:461] AT< OK -[04-21_17:35:16:461] AT> AT+QNETDEVSTATUS=1 -[04-21_17:35:16:462] AT< +QNETDEVSTATUS: 4F10190A,E0FFFFFF,4110190A,4110190A,02B48AD3,03B48AD3, 85600, 85600 -[04-21_17:35:16:462] AT< OK -[04-21_17:35:16:462] requestGetIPAddress 10.25.16.79 -[04-21_17:35:16:462] AT> at+cops? -[04-21_17:35:16:463] AT< +COPS: 0,2,"46000",12 -[04-21_17:35:16:463] AT< OK -[04-21_17:35:16:463] AT> at+qeng="servingcell" -[04-21_17:35:16:465] AT< +QENG: "servingcell","CONNECT","NR5G-SA","TDD",460,00,170C23000,901,46550B,504990,41,-,-52,-11,15,-,- -[04-21_17:35:16:465] AT< OK -[04-21_17:35:16:465] AT> AT+QNETDEVSTATUS=1 -[04-21_17:35:16:466] AT< +QNETDEVSTATUS: 4F10190A,E0FFFFFF,4110190A,4110190A,02B48AD3,03B48AD3, 85600, 85600 -[04-21_17:35:16:466] AT< OK -[04-21_17:35:16:466] ifconfig usb0 up -[04-21_17:35:16:470] busybox udhcpc -f -n -q -t 5 -i usb0 -udhcpc: started, v1.30.1 -udhcpc: sending discover -udhcpc: sending select for 10.25.16.79 -udhcpc: lease of 10.25.16.79 obtained, lease time 518400 -[04-21_17:35:16:602] /etc/udhcpc/default.script: Resetting default routes -SIOCDELRT: No such process -SIOCADDRT: Network is unreachable -[04-21_17:35:16:606] /etc/udhcpc/default.script: Adding DNS 211.138.180.2 -[04-21_17:35:16:606] /etc/udhcpc/default.script: Adding DNS 211.138.180.3 -[04-21_17:35:16:655] AT> at+cops? -[04-21_17:35:16:656] AT< +COPS: 0,2,"46000",12 -[04-21_17:35:16:656] AT< OK -[04-21_17:35:16:656] AT> at+qeng="servingcell" -[04-21_17:35:16:657] AT< +QENG: "servingcell","CONNECT","NR5G-SA","TDD",460,00,170C23000,901,46550B,504990,41,-,-50,-11,17,-,- -[04-21_17:35:16:658] AT< OK -err = 16 -[04-21_17:35:16:658] AT> AT+QNETDEVSTATUS=1 -[04-21_17:35:16:659] AT< +QNETDEVSTATUS: 4F10190A,E0FFFFFF,4110190A,4110190A,02B48AD3,03B48AD3, 85600, 85600 -[04-21_17:35:16:659] AT< OK - -root@carl-ThinkPad-X1-Carbon-7th:/home/carl/q/quectel-CM# ifconfig usb0 -usb0: flags=4163 mtu 1500 - inet 10.25.16.79 netmask 255.255.255.224 broadcast 10.25.16.95 - inet6 fe80::5c98:e9d4:c82d:5f prefixlen 64 scopeid 0x20 - ether 0c:5b:8f:27:9a:64 txqueuelen 1000 (Ethernet) - RX packets 7 bytes 1656 (1.6 KB) - RX errors 0 dropped 0 overruns 0 frame 0 - TX packets 32 bytes 5112 (5.1 KB) - TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 - -root@carl-ThinkPad-X1-Carbon-7th:/home/carl/q/quectel-CM# [04-21_17:35:31:670] AT> at+cops? -[04-21_17:35:31:671] AT< +COPS: 0,2,"46000",12 -[04-21_17:35:31:671] AT< OK -[04-21_17:35:31:671] AT> at+qeng="servingcell" -[04-21_17:35:31:673] AT< +QENG: "servingcell","CONNECT","NR5G-SA","TDD",460,00,170C23000,901,46550B,504990,41,-,-48,-10,17,-,- -[04-21_17:35:31:673] AT< OK -[04-21_17:35:31:673] AT> AT+QNETDEVSTATUS=1 -[04-21_17:35:31:674] AT< +QNETDEVSTATUS: 4F10190A,E0FFFFFF,4110190A,4110190A,02B48AD3,03B48AD3, 85600, 85600 -[04-21_17:35:31:674] AT< OK diff --git a/quectel_cm_5G/src/log/gobinet.txt b/quectel_cm_5G/src/log/gobinet.txt deleted file mode 100644 index 2b286de..0000000 --- a/quectel_cm_5G/src/log/gobinet.txt +++ /dev/null @@ -1,62 +0,0 @@ -root@ZhuoTK:/# dmesg -[ 230.590000] GobiNet 1-1.3:1.4 usb0: register 'GobiNet' at usb-101c0000.ehci-1.3, GobiNet Ethernet Device, 02:50:f4:00:00:00 -[ 230.600000] creating qcqmi0 - -root@ZhuoTK:/# quectel-CM -s cmnet & -[04-13_03:24:58:213] Quectel_QConnectManager_Linux_V1.6.0.25 -[04-13_03:24:58:216] Find /sys/bus/usb/devices/1-1.3 idVendor=0x2c7c idProduct=0x125, bus=0x001, dev=0x004 -[04-13_03:24:58:218] Auto find qmichannel = /dev/qcqmi0 -[04-13_03:24:58:218] Auto find usbnet_adapter = usb0 -[04-13_03:24:58:218] netcard driver = GobiNet, driver version = V1.6.2.13 -[04-13_03:24:58:219] Modem works in QMI mode -[04-13_03:24:58:260] Get clientWDS = 7 -[04-13_03:24:58:292] Get clientDMS = 8 -[04-13_03:24:58:324] Get clientNAS = 9 -[04-13_03:24:58:355] Get clientUIM = 10 -[04-13_03:24:58:388] Get clientWDA = 11 -[04-13_03:24:58:420] requestBaseBandVersion EC25EFAR06A11M4G -[04-13_03:24:58:548] requestGetSIMStatus SIMStatus: SIM_READY -[04-13_03:24:58:549] requestSetProfile[1] cmnet///0 -[04-13_03:24:58:613] requestGetProfile[1] cmnet///0 -[04-13_03:24:58:645] requestRegistrationState2 MCC: 460, MNC: 0, PS: Attached, DataCap: LTE -[04-13_03:24:58:677] requestQueryDataCall IPv4ConnectionStatus: DISCONNECTED -[04-13_03:24:58:677] ifconfig usb0 0.0.0.0 -[04-13_03:24:58:696] ifconfig usb0 down -[04-13_03:24:59:028] requestSetupDataCall WdsConnectionIPv4Handle: 0x87245bd0 -[04-13_03:24:59:189] ifconfig usb0 up -[04-13_03:24:59:214] you are use OpenWrt? -[04-13_03:24:59:215] should not calling udhcpc manually? -[04-13_03:24:59:215] should modify /etc/config/network as below? -[04-13_03:24:59:215] config interface wan -[04-13_03:24:59:215] option ifname usb0 -[04-13_03:24:59:215] option proto dhcp -[04-13_03:24:59:215] should use "/sbin/ifstaus wan" to check usb0 's status? -[04-13_03:24:59:216] busybox udhcpc -f -n -q -t 5 -i usb0 -[04-13_03:24:59:226] udhcpc (v1.23.2) started -[04-13_03:24:59:238] Sending discover... -[04-13_03:24:59:248] Sending select for 10.198.78.154... -[04-13_03:24:59:251] Lease of 10.198.78.154 obtained, lease time 7200 -[04-13_03:24:59:257] udhcpc: ifconfig usb0 10.198.78.154 netmask 255.255.255.252 broadcast + -[04-13_03:24:59:266] udhcpc: setting default routers: 10.198.78.153 - -root@ZhuoTK:/# ifconfig usb0 -usb0 Link encap:Ethernet HWaddr 02:50:F4:00:00:00 - inet addr:10.198.78.154 Mask:255.255.255.252 - inet6 addr: fe80::50:f4ff:fe00:0/64 Scope:Link - UP RUNNING NOARP MTU:1500 Metric:1 - RX packets:6 errors:0 dropped:0 overruns:0 frame:0 - TX packets:6 errors:0 dropped:0 overruns:0 carrier:0 - collisions:0 txqueuelen:1000 - RX bytes:916 (916.0 B) TX bytes:960 (960.0 B) - -root@ZhuoTK:/# ip ro show -default via 10.198.78.153 dev usb0 -10.198.78.152/30 dev usb0 proto kernel scope link src 10.198.78.154 -192.168.1.0/24 dev br-lan proto kernel scope link src 192.168.1.251 - -root@ZhuoTK:/# killall quectel-CM -[04-13_03:25:38:779] requestDeactivateDefaultPDP WdsConnectionIPv4Handle -[04-13_03:25:39:061] ifconfig usb0 0.0.0.0 -[04-13_03:25:39:072] ifconfig usb0 down -[04-13_03:25:39:284] GobiNetThread exit -[04-13_03:25:39:285] qmi_main exit diff --git a/quectel_cm_5G/src/log/gobinet_bridge.txt b/quectel_cm_5G/src/log/gobinet_bridge.txt deleted file mode 100644 index 7ed229e..0000000 --- a/quectel_cm_5G/src/log/gobinet_bridge.txt +++ /dev/null @@ -1,60 +0,0 @@ -root@ZhuoTK:/# insmod GobiNet.ko -[ 80.460000] GobiNet: Quectel_Linux&Android_GobiNet_Driver_V1.6.2.13 -[ 80.460000] usbcore: registered new interface driver GobiNet -[ 97.710000] usb 1-1.3: new high-speed USB device number 3 using ehci-platform -[ 97.930000] usb 1-1.3: GSM modem (1-port) converter now attached to ttyUSB103 -[ 97.950000] GobiNet 1-1.3:1.4 usb0: register 'GobiNet' at usb-101c0000.ehci-1.3, GobiNet Ethernet Device, 02:50:f4:00:00:00 -[ 97.960000] creating qcqmi0 - -root@ZhuoTK:/# brctl addbr br0 -root@ZhuoTK:/# brctl addif br0 eth0.1 -root@ZhuoTK:/# brctl addif br0 usb0 -root@ZhuoTK:/# brctl show -bridge name bridge id STP enabled interfaces -br0 8000.00ca019197b9 no eth0.1 - usb0 - -root@ZhuoTK:/# quectel-CM -s cment -b & -[04-13_05:13:18:213] Quectel_QConnectManager_Linux_V1.6.0.25 -[04-13_05:13:18:216] Find /sys/bus/usb/devices/1-1.3 idVendor=0x2c7c idProduct=0x125, bus=0x001, dev=0x003 -[ 122.270000] net usb0: bridge_mode change to 0x1 -[04-13_05:13:18:218] Auto find qmichannel = /dev/qcqmi0 -[04-13_05:13:18:218] Auto find usbnet_adapter = usb0 -[04-13_05:13:18:218] netcard driver = GobiNet, driver version = V1.6.2.13 -[04-13_05:13:18:224] Modem works in QMI mode -[04-13_05:13:18:251] Get clientWDS = 7 -[04-13_05:13:18:282] Get clientDMS = 8 -[04-13_05:13:18:316] Get clientNAS = 9 -[04-13_05:13:18:347] Get clientUIM = 10 -[04-13_05:13:18:379] Get clientWDA = 11 -[04-13_05:13:18:411] requestBaseBandVersion EC25EFAR06A11M4G -[04-13_05:13:18:539] requestGetSIMStatus SIMStatus: SIM_READY -[04-13_05:13:18:540] requestSetProfile[1] cment///0 -[04-13_05:13:18:603] requestGetProfile[1] cment///0 -[04-13_05:13:18:637] requestRegistrationState2 MCC: 460, MNC: 0, PS: Attached, DataCap: LTE -[04-13_05:13:18:666] requestQueryDataCall IPv4ConnectionStatus: DISCONNECTED -[04-13_05:13:18:667] ifconfig usb0 0.0.0.0 -[04-13_05:13:18:687] ifconfig usb0 down -[04-13_05:13:19:083] requestSetupDataCall WdsConnectionIPv4Handle: 0x8724d220 -[04-13_05:13:19:243] ifconfig usb0 up -[04-13_05:13:19:270] echo '0xa218480' > /sys/class/net/usb0/bridge_ipv4 - -root@ZhuoTK:/# ifconfig br0 up -[ 135.530000] usb0 PC Mac Address: 00:0e:c6:a6:6c:f1 -[ 135.570000] usb0 PC Mac Address: 00:0e:c6:a6:6c:f1 -[ 135.580000] usb0 PC Mac Address: 00:0e:c6:a6:6c:f1 -[ 135.610000] usb0 sip = 10.33.132.128, tip=10.33.132.129, ipv4=10.33.132.128 -[ 135.620000] usb0 sip = 10.33.132.128, tip=10.33.132.129, ipv4=10.33.132.128 -[ 135.910000] usb0 sip = 0.0.0.0, tip=10.33.132.128, ipv4=10.33.132.128 -[ 136.000000] usb0 sip = 10.33.132.128, tip=10.33.132.129, ipv4=10.33.132.128 -[ 136.910000] usb0 sip = 0.0.0.0, tip=10.33.132.128, ipv4=10.33.132.128 -[ 137.910000] usb0 sip = 0.0.0.0, tip=10.33.132.128, ipv4=10.33.132.128 -[ 138.740000] usb0 sip = 10.33.132.128, tip=10.33.132.129, ipv4=10.33.132.128 -[ 138.910000] usb0 sip = 10.33.132.128, tip=10.33.132.128, ipv4=10.33.132.128 -[ 139.000000] usb0 sip = 10.33.132.128, tip=10.33.132.129, ipv4=10.33.132.128 -[ 140.860000] usb0 sip = 10.33.132.128, tip=10.33.132.129, ipv4=10.33.132.128 -[ 143.160000] br0: port 2(usb0) entered forwarding state -[ 143.160000] br0: port 1(eth0.1) entered forwarding state -[ 148.870000] usb0 sip = 10.33.132.128, tip=10.33.132.129, ipv4=10.33.132.128 -[ 149.010000] usb0 sip = 10.33.132.128, tip=10.33.132.129, ipv4=10.33.132.128 -[ 165.630000] usb0 sip = 10.33.132.128, tip=10.33.132.129, ipv4=10.33.132.128 diff --git a/quectel_cm_5G/src/log/gobinet_qmap=1.txt b/quectel_cm_5G/src/log/gobinet_qmap=1.txt deleted file mode 100644 index 83cedd9..0000000 --- a/quectel_cm_5G/src/log/gobinet_qmap=1.txt +++ /dev/null @@ -1,45 +0,0 @@ -root@ZhuoTK:/# insmod GobiNet.ko qmap_mode=1 -[ 798.480000] GobiNet: Quectel_Linux&Android_GobiNet_Driver_V1.6.2.13 -[ 798.490000] GobiNet 1-1.3:1.4 usb0: register 'GobiNet' at usb-101c0000.ehci-1.3, GobiNet Ethernet Device, 02:50:f4:00:00:00 -[ 798.510000] creating qcqmi0 -[ 798.510000] usbcore: registered new interface driver GobiNet -[ 799.620000] GobiNet::QMIWDASetDataFormat qmap settings qmap_version=5, rx_size=4096, tx_size=4096 -[ 799.630000] GobiNet::QMIWDASetDataFormat qmap settings ul_data_aggregation_max_size=4096, ul_data_aggregation_max_datagrams=16 - -root@ZhuoTK:/# quectel-CM -s cmnet & -[04-13_03:32:31:248] Quectel_QConnectManager_Linux_V1.6.0.25 -[04-13_03:32:31:251] Find /sys/bus/usb/devices/1-1.3 idVendor=0x2c7c idProduct=0x125, bus=0x001, dev=0x005 -[04-13_03:32:31:253] Auto find qmichannel = /dev/qcqmi0 -[04-13_03:32:31:253] Auto find usbnet_adapter = usb0 -[04-13_03:32:31:253] netcard driver = GobiNet, driver version = V1.6.2.13 -[04-13_03:32:31:253] qmap_mode = 1, qmap_version = 5, qmap_size = 4096, muxid = 0x81, qmap_netcard = usb0 -[04-13_03:32:31:254] Modem works in QMI mode -[04-13_03:32:31:289] Get clientWDS = 7 -[04-13_03:32:31:320] Get clientDMS = 8 -[04-13_03:32:31:353] Get clientNAS = 9 -[04-13_03:32:31:385] Get clientUIM = 10 -[04-13_03:32:31:417] requestBaseBandVersion EC25EFAR06A11M4G -[04-13_03:32:31:545] requestGetSIMStatus SIMStatus: SIM_READY -[04-13_03:32:31:545] requestSetProfile[1] cmnet///0 -[04-13_03:32:31:609] requestGetProfile[1] cmnet///0 -[04-13_03:32:31:641] requestRegistrationState2 MCC: 460, MNC: 0, PS: Attached, DataCap: LTE -[04-13_03:32:31:673] requestQueryDataCall IPv4ConnectionStatus: DISCONNECTED -[04-13_03:32:31:674] ifconfig usb0 0.0.0.0 -[04-13_03:32:31:698] ifconfig usb0 down -[04-13_03:32:31:770] requestSetupDataCall WdsConnectionIPv4Handle: 0x872481a0 -[ 857.000000] net usb0: link_state 0x0 -> 0x1 -[04-13_03:32:31:902] ifconfig usb0 up -[04-13_03:32:31:928] you are use OpenWrt? -[04-13_03:32:31:928] should not calling udhcpc manually? -[04-13_03:32:31:928] should modify /etc/config/network as below? -[04-13_03:32:31:928] config interface wan -[04-13_03:32:31:928] option ifname usb0 -[04-13_03:32:31:929] option proto dhcp -[04-13_03:32:31:929] should use "/sbin/ifstaus wan" to check usb0 's status? -[04-13_03:32:31:929] busybox udhcpc -f -n -q -t 5 -i usb0 -[04-13_03:32:31:939] udhcpc (v1.23.2) started -[04-13_03:32:31:951] Sending discover... -[04-13_03:32:31:956] Sending select for 10.199.102.71... -[04-13_03:32:31:959] Lease of 10.199.102.71 obtained, lease time 7200 -[04-13_03:32:31:964] udhcpc: ifconfig usb0 10.199.102.71 netmask 255.255.255.240 broadcast + -[04-13_03:32:31:974] udhcpc: setting default routers: 10.199.102.72 diff --git a/quectel_cm_5G/src/log/gobinet_qmap=1_bridge.txt b/quectel_cm_5G/src/log/gobinet_qmap=1_bridge.txt deleted file mode 100644 index 64a8374..0000000 --- a/quectel_cm_5G/src/log/gobinet_qmap=1_bridge.txt +++ /dev/null @@ -1,62 +0,0 @@ -root@ZhuoTK:/# insmod GobiNet.ko qmap_mode=1 -[ 41.540000] GobiNet: Quectel_Linux&Android_GobiNet_Driver_V1.6.2.13 -[ 41.550000] GobiNet 1-1.3:1.4 usb0: register 'GobiNet' at usb-101c0000.ehci-1.3, GobiNet Ethernet Device, 02:50:f4:00:00:00 -[ 41.570000] creating qcqmi0 -[ 41.570000] usbcore: registered new interface driver GobiNet -[ 42.700000] GobiNet::QMIWDASetDataFormat qmap settings qmap_version=5, rx_size=4096, tx_size=4096 -[ 42.710000] GobiNet::QMIWDASetDataFormat qmap settings ul_data_aggregation_max_size=4096, ul_data_aggregation_max_datagrams=16 - -root@ZhuoTK:/# brctl addbr br0 -root@ZhuoTK:/# brctl addif br0 eth0.1 -root@ZhuoTK:/# brctl addif br0 usb0 -root@ZhuoTK:/# brctl show -bridge name bridge id STP enabled interfaces -br0 8000.00ca019197b9 no eth0.1 - usb0 - -root@ZhuoTK:/# quectel-CM -s cmnet -b & -# [04-13_05:12:29:338] Quectel_QConnectManager_Linux_V1.6.0.25 -[04-13_05:12:29:340] Find /sys/bus/usb/devices/1-1.3 idVendor=0x2c7c idProduct=0x125, bus=0x001, dev=0x003 -[ 73.380000] net usb0: bridge_mode change to 0x1 -[04-13_05:12:29:342] Auto find qmichannel = /dev/qcqmi0 -[04-13_05:12:29:342] Auto find usbnet_adapter = usb0 -[04-13_05:12:29:342] netcard driver = GobiNet, driver version = V1.6.2.13 -[04-13_05:12:29:343] qmap_mode = 1, qmap_version = 5, qmap_size = 4096, muxid = 0x81, qmap_netcard = usb0 -[04-13_05:12:29:348] Modem works in QMI mode -[04-13_05:12:29:382] Get clientWDS = 7 -[04-13_05:12:29:414] Get clientDMS = 8 -[04-13_05:12:29:447] Get clientNAS = 9 -[04-13_05:12:29:479] Get clientUIM = 10 -[04-13_05:12:29:512] requestBaseBandVersion EC25EFAR06A11M4G -[04-13_05:12:29:640] requestGetSIMStatus SIMStatus: SIM_READY -[04-13_05:12:29:640] requestSetProfile[1] cmnet///0 -[04-13_05:12:29:704] requestGetProfile[1] cmnet///0 -[04-13_05:12:29:735] requestRegistrationState2 MCC: 460, MNC: 0, PS: Attached, DataCap: LTE -[04-13_05:12:29:767] requestQueryDataCall IPv4ConnectionStatus: DISCONNECTED -[04-13_05:12:29:768] ifconfig usb0 0.0.0.0 -[04-13_05:12:29:792] ifconfig usb0 down -[04-13_05:12:29:863] requestSetupDataCall WdsConnectionIPv4Handle: 0x8724d820 -[ 74.030000] net usb0: link_state 0x0 -> 0x1 -[04-13_05:12:29:996] ifconfig usb0 up -[04-13_05:12:30:022] echo '0xa16b769' > /sys/class/net/usb0/bridge_ipv4 - -root@ZhuoTK:/# ifconfig br0 up -[ 82.210000] br0: port 2(usb0) entered forwarding state -[ 82.210000] br0: port 2(usb0) entered forwarding state -[ 82.220000] br0: port 1(eth0.1) entered forwarding state -[ 82.220000] br0: port 1(eth0.1) entered forwarding state -[ 88.830000] rt305x-esw 10110000.esw: link changed 0x01 -[ 89.010000] usb0 PC Mac Address: 00:0e:c6:a6:6c:f1 -[ 89.040000] usb0 PC Mac Address: 00:0e:c6:a6:6c:f1 -[ 89.050000] usb0 PC Mac Address: 00:0e:c6:a6:6c:f1 -[ 89.120000] usb0 sip = 10.22.183.105, tip=10.22.183.106, ipv4=10.22.183.105 -[ 89.350000] usb0 sip = 0.0.0.0, tip=10.22.183.105, ipv4=10.22.183.105 -[ 89.400000] usb0 sip = 10.22.183.105, tip=10.22.183.106, ipv4=10.22.183.105 -[ 89.520000] usb0 sip = 10.22.183.105, tip=10.22.183.106, ipv4=10.22.183.105 -[ 90.350000] usb0 sip = 0.0.0.0, tip=10.22.183.105, ipv4=10.22.183.105 -[ 91.350000] usb0 sip = 0.0.0.0, tip=10.22.183.105, ipv4=10.22.183.105 -[ 92.350000] usb0 sip = 10.22.183.105, tip=10.22.183.105, ipv4=10.22.183.105 -[ 92.430000] usb0 sip = 10.22.183.105, tip=10.22.183.106, ipv4=10.22.183.105 -[ 92.660000] usb0 sip = 10.22.183.105, tip=10.22.183.106, ipv4=10.22.183.105 -[ 97.240000] br0: port 2(usb0) entered forwarding state -[ 97.240000] br0: port 1(eth0.1) entered forwarding state diff --git a/quectel_cm_5G/src/log/gobinet_qmap=4.txt b/quectel_cm_5G/src/log/gobinet_qmap=4.txt deleted file mode 100644 index 5ec02bf..0000000 --- a/quectel_cm_5G/src/log/gobinet_qmap=4.txt +++ /dev/null @@ -1,146 +0,0 @@ -root@ZhuoTK:/# insmod GobiNet.ko qmap_mode=4 -[ 970.380000] GobiNet: Quectel_Linux&Android_GobiNet_Driver_V1.6.2.13 -[ 970.380000] usbcore: registered new interface driver GobiNet -[ 989.620000] usb 1-1.3: new high-speed USB device number 6 using ehci-platform -[ 989.860000] GobiNet 1-1.3:1.4 usb0: register 'GobiNet' at usb-101c0000.ehci-1.3, GobiNet Ethernet Device, 02:50:f4:00:00:00 -[ 989.870000] creating qcqmi0 -[ 989.880000] GobiNet::qmap_register_device usb0.1 -[ 989.880000] GobiNet::qmap_register_device usb0.2 -[ 989.890000] GobiNet::qmap_register_device usb0.3 -[ 989.890000] GobiNet::qmap_register_device usb0.4 -[ 994.820000] GobiNet::QMIWDASetDataFormat qmap settings qmap_version=5, rx_size=4096, tx_size=4096 -[ 994.830000] GobiNet::QMIWDASetDataFormat qmap settings ul_data_aggregation_max_size=4096, ul_data_aggregation_max_datagrams=16 - -root@ZhuoTK:/# quectel-CM -n 1 -s cmnet & -[04-13_03:35:31:878] Quectel_QConnectManager_Linux_V1.6.0.25 -[04-13_03:35:31:881] Find /sys/bus/usb/devices/1-1.3 idVendor=0x2c7c idProduct=0x125, bus=0x001, dev=0x006 -[04-13_03:35:31:882] Auto find qmichannel = /dev/qcqmi0 -[04-13_03:35:31:882] Auto find usbnet_adapter = usb0 -[04-13_03:35:31:883] netcard driver = GobiNet, driver version = V1.6.2.13 -[04-13_03:35:31:883] qmap_mode = 4, qmap_version = 5, qmap_size = 4096, muxid = 0x81, qmap_netcard = usb0.1 -[04-13_03:35:31:883] Modem works in QMI mode -[04-13_03:35:31:896] Get clientWDS = 7 -[04-13_03:35:31:927] Get clientDMS = 8 -[04-13_03:35:31:959] Get clientNAS = 9 -[04-13_03:35:31:992] Get clientUIM = 10 -[04-13_03:35:32:024] requestBaseBandVersion EC25EFAR06A11M4G -[04-13_03:35:32:152] requestGetSIMStatus SIMStatus: SIM_READY -[04-13_03:35:32:152] requestSetProfile[1] cmnet///0 -[04-13_03:35:32:216] requestGetProfile[1] cmnet///0 -[04-13_03:35:32:248] requestRegistrationState2 MCC: 460, MNC: 0, PS: Attached, DataCap: LTE -[04-13_03:35:32:279] requestQueryDataCall IPv4ConnectionStatus: DISCONNECTED -[04-13_03:35:32:280] ifconfig usb0 down -[04-13_03:35:32:290] ifconfig usb0.1 0.0.0.0 -[04-13_03:35:32:301] ifconfig usb0.1 down -[04-13_03:35:32:344] requestSetupDataCall WdsConnectionIPv4Handle: 0x8723eef0 -[ 1037.570000] net usb0: link_state 0x0 -> 0x1 -[04-13_03:35:32:477] ifconfig usb0 up -[04-13_03:35:32:496] ifconfig usb0.1 up -[04-13_03:35:32:508] you are use OpenWrt? -[04-13_03:35:32:509] should not calling udhcpc manually? -[04-13_03:35:32:509] should modify /etc/config/network as below? -[04-13_03:35:32:509] config interface wan -[04-13_03:35:32:509] option ifname usb0.1 -[04-13_03:35:32:509] option proto dhcp -[04-13_03:35:32:509] should use "/sbin/ifstaus wan" to check usb0.1 's status? -[04-13_03:35:32:510] busybox udhcpc -f -n -q -t 5 -i usb0.1 -[04-13_03:35:32:520] udhcpc (v1.23.2) started -[04-13_03:35:32:532] Sending discover... -[04-13_03:35:32:540] Sending select for 10.187.142.20... -[04-13_03:35:32:545] Lease of 10.187.142.20 obtained, lease time 7200 -[04-13_03:35:32:550] udhcpc: ifconfig usb0.1 10.187.142.20 netmask 255.255.255.248 broadcast + -[04-13_03:35:32:560] udhcpc: setting default routers: 10.187.142.21 - -root@ZhuoTK:/# quectel-CM -n 2 -s 4gnet & -[04-13_03:35:38:766] Quectel_QConnectManager_Linux_V1.6.0.25 -[04-13_03:35:38:769] Find /sys/bus/usb/devices/1-1.3 idVendor=0x2c7c idProduct=0x125, bus=0x001, dev=0x006 -[04-13_03:35:38:770] Auto find qmichannel = /dev/qcqmi0 -[04-13_03:35:38:770] Auto find usbnet_adapter = usb0 -[04-13_03:35:38:771] netcard driver = GobiNet, driver version = V1.6.2.13 -[04-13_03:35:38:771] qmap_mode = 4, qmap_version = 5, qmap_size = 4096, muxid = 0x82, qmap_netcard = usb0.2 -[04-13_03:35:38:771] Modem works in QMI mode -[04-13_03:35:38:809] Get clientWDS = 7 -[04-13_03:35:38:841] Get clientDMS = 8 -[04-13_03:35:38:873] Get clientNAS = 9 -[04-13_03:35:38:905] Get clientUIM = 10 -[04-13_03:35:38:937] requestBaseBandVersion EC25EFAR06A11M4G -[04-13_03:35:39:065] requestGetSIMStatus SIMStatus: SIM_READY -[04-13_03:35:39:065] requestSetProfile[2] 4gnet///0 -[04-13_03:35:39:129] requestGetProfile[2] 4gnet///0 -[04-13_03:35:39:161] requestRegistrationState2 MCC: 460, MNC: 0, PS: Attached, DataCap: LTE -[04-13_03:35:39:193] requestQueryDataCall IPv4ConnectionStatus: DISCONNECTED -[04-13_03:35:39:193] ifconfig usb0.2 0.0.0.0 -[04-13_03:35:39:206] ifconfig usb0.2 down -[04-13_03:35:39:417] requestSetupDataCall WdsConnectionIPv4Handle: 0x87252eb0 -[ 1044.650000] net usb0: link_state 0x1 -> 0x3 -[04-13_03:35:39:550] ifconfig usb0 up -[04-13_03:35:39:560] ifconfig usb0.2 up -[04-13_03:35:39:573] you are use OpenWrt? -[04-13_03:35:39:573] should not calling udhcpc manually? -[04-13_03:35:39:573] should modify /etc/config/network as below? -[04-13_03:35:39:573] config interface wan -[04-13_03:35:39:573] option ifname usb0.2 -[04-13_03:35:39:573] option proto dhcp -[04-13_03:35:39:573] should use "/sbin/ifstaus wan" to check usb0.2 's status? -[04-13_03:35:39:574] busybox udhcpc -f -n -q -t 5 -i usb0.2 -[04-13_03:35:39:585] udhcpc (v1.23.2) started -[04-13_03:35:39:597] Sending discover... -[04-13_03:35:39:601] Sending select for 10.197.125.183... -[04-13_03:35:39:606] Lease of 10.197.125.183 obtained, lease time 7200 -[04-13_03:35:39:611] udhcpc: ifconfig usb0.2 10.197.125.183 netmask 255.255.255.240 broadcast + -[04-13_03:35:39:621] udhcpc: setting default routers: 10.197.125.184 - -root@ZhuoTK:/# ifconfig usb0.1 -usb0.1 Link encap:Ethernet HWaddr 02:50:F4:00:00:00 - inet addr:10.187.142.20 Mask:255.255.255.248 - inet6 addr: fe80::50:f4ff:fe00:0/64 Scope:Link - UP RUNNING NOARP MTU:1500 Metric:1 - RX packets:4 errors:0 dropped:0 overruns:0 frame:0 - TX packets:10 errors:0 dropped:0 overruns:0 carrier:0 - collisions:0 txqueuelen:1000 - RX bytes:764 (764.0 B) TX bytes:1824 (1.7 KiB) - -root@ZhuoTK:/# ifconfig usb0.2 -usb0.2 Link encap:Ethernet HWaddr 02:50:F4:00:00:00 - inet addr:10.197.125.183 Mask:255.255.255.240 - inet6 addr: fe80::50:f4ff:fe00:0/64 Scope:Link - UP RUNNING NOARP MTU:1500 Metric:1 - RX packets:3 errors:0 dropped:0 overruns:0 frame:0 - TX packets:9 errors:0 dropped:0 overruns:0 carrier:0 - collisions:0 txqueuelen:1000 - RX bytes:688 (688.0 B) TX bytes:1224 (1.1 KiB) - -root@ZhuoTK:/# ip ro add 8.8.8.8/32 dev usb0.1 -root@ZhuoTK:/# ping 8.8.8.8 -PING 8.8.8.8 (8.8.8.8): 56 data bytes -64 bytes from 8.8.8.8: seq=0 ttl=52 time=74.450 ms - -root@ZhuoTK:/# ip ro del 8.8.8.8/32 -root@ZhuoTK:/# ip ro del 8.8.8.8/32 -RTNETLINK answers: No such process - -root@ZhuoTK:/# ip ro add 8.8.8.8/32 dev usb0.2 -root@ZhuoTK:/# ping 8.8.8.8 -PING 8.8.8.8 (8.8.8.8): 56 data bytes -64 bytes from 8.8.8.8: seq=0 ttl=52 time=257.851 ms - -root@ZhuoTK:/# quectel-CM -k 2 -[04-13_03:39:16:986] Quectel_QConnectManager_Linux_V1.6.0.25 -[04-13_03:39:16:988] /proc/2294/cmdline: quectel-CM -n 2 -s 4gnet -[04-13_03:39:16:988] send SIGINT to process 2294 -[04-13_03:39:16:989] requestDeactivateDefaultPDP WdsConnectionIPv4Handle -[ 1262.310000] net usb0: link_state 0x3 -> 0x1 -[04-13_03:39:17:216] ifconfig usb0.2 0.0.0.0 -[04-13_03:39:17:228] ifconfig usb0.2 down -[04-13_03:39:17:370] GobiNetThread exit -[04-13_03:39:17:371] qmi_main exit - -[2]+ Done quectel-CM -n 2 -s 4gnet - -root@ZhuoTK:/# ifconfig usb0.2 -usb0.2 Link encap:Ethernet HWaddr 02:50:F4:00:00:00 - NOARP MTU:1500 Metric:1 - RX packets:30 errors:0 dropped:0 overruns:0 frame:0 - TX packets:35 errors:0 dropped:0 overruns:0 carrier:0 - collisions:0 txqueuelen:1000 - RX bytes:2816 (2.7 KiB) TX bytes:3408 (3.3 KiB) diff --git a/quectel_cm_5G/src/log/gobinet_qmap=4_bridge.txt b/quectel_cm_5G/src/log/gobinet_qmap=4_bridge.txt deleted file mode 100644 index ebfd4fb..0000000 --- a/quectel_cm_5G/src/log/gobinet_qmap=4_bridge.txt +++ /dev/null @@ -1,114 +0,0 @@ -root@ZhuoTK:/# insmod GobiNet.ko qmap_mode=4 -[ 42.120000] GobiNet: Quectel_Linux&Android_GobiNet_Driver_V1.6.2.13 -[ 42.130000] GobiNet 1-1.3:1.4 usb0: register 'GobiNet' at usb-101c0000.ehci-1.3, GobiNet Ethernet Device, 02:50:f4:00:00:00 -[ 42.140000] creating qcqmi0 -[ 42.150000] GobiNet::qmap_register_device usb0.1 -[ 42.150000] GobiNet::qmap_register_device usb0.2 -[ 42.160000] GobiNet::qmap_register_device usb0.3 -[ 42.160000] GobiNet::qmap_register_device usb0.4 -[ 42.170000] usbcore: registered new interface driver GobiNet -[ 43.270000] GobiNet::QMIWDASetDataFormat qmap settings qmap_version=5, rx_size=4096, tx_size=4096 -[ 43.280000] GobiNet::QMIWDASetDataFormat qmap settings ul_data_aggregation_max_size=4096, ul_data_aggregation_max_datagrams=16 - -root@ZhuoTK:/# brctl addbr br0 -root@ZhuoTK:/# brctl addif br0 eth0.1 -root@ZhuoTK:/# brctl addif br0 usb0.1 -root@ZhuoTK:/# brctl show -bridge name bridge id STP enabled interfaces -br0 8000.00ca019197b9 no eth0.1 - usb0.1 - -root@ZhuoTK:/# quectel-CM -n 1 -s cmnet -b & -[04-13_05:12:42:155] Quectel_QConnectManager_Linux_V1.6.0.25 -[04-13_05:12:42:158] Find /sys/bus/usb/devices/1-1.3 idVendor=0x2c7c idProduct=0x125, bus=0x001, dev=0x003 -[ 86.130000] net usb0.1: bridge_mode change to 0x1 -[04-13_05:12:42:159] Auto find qmichannel = /dev/qcqmi0 -[04-13_05:12:42:160] Auto find usbnet_adapter = usb0 -[04-13_05:12:42:160] netcard driver = GobiNet, driver version = V1.6.2.13 -[04-13_05:12:42:160] qmap_mode = 4, qmap_version = 5, qmap_size = 4096, muxid = 0x81, qmap_netcard = usb0.1 -[04-13_05:12:42:166] Modem works in QMI mode -[04-13_05:12:42:181] Get clientWDS = 7 -[04-13_05:12:42:213] Get clientDMS = 8 -[04-13_05:12:42:246] Get clientNAS = 9 -[04-13_05:12:42:278] Get clientUIM = 10 -[04-13_05:12:42:310] requestBaseBandVersion EC25EFAR06A11M4G -[04-13_05:12:42:438] requestGetSIMStatus SIMStatus: SIM_READY -[04-13_05:12:42:439] requestSetProfile[1] cmnet///0 -[04-13_05:12:42:502] requestGetProfile[1] cmnet///0 -[04-13_05:12:42:534] requestRegistrationState2 MCC: 460, MNC: 0, PS: Attached, DataCap: LTE -[04-13_05:12:42:565] requestQueryDataCall IPv4ConnectionStatus: DISCONNECTED -[04-13_05:12:42:566] ifconfig usb0 down -[04-13_05:12:42:576] ifconfig usb0.1 0.0.0.0 -[04-13_05:12:42:587] ifconfig usb0.1 down -[04-13_05:12:42:629] requestSetupDataCall WdsConnectionIPv4Handle: 0x8724d740 -[ 86.730000] net usb0: link_state 0x0 -> 0x1 -[04-13_05:12:42:762] ifconfig usb0 up -[04-13_05:12:42:782] ifconfig usb0.1 up -[04-13_05:12:42:794] echo '0xa16b769' > /sys/class/net/usb0.1/bridge_ipv4 - -root@ZhuoTK:/# ifconfig br0 up -[ 98.270000] usb0.1 PC Mac Address: 00:0e:c6:a6:6c:f1 -[ 98.360000] usb0.1 sip = 0.0.0.0, tip=10.22.183.105, ipv4=10.22.183.105 -[ 98.370000] usb0.1 sip = 10.22.183.105, tip=10.22.183.106, ipv4=10.22.183.105 -[ 99.360000] usb0.1 sip = 0.0.0.0, tip=10.22.183.105, ipv4=10.22.183.105 -[ 100.360000] usb0.1 sip = 0.0.0.0, tip=10.22.183.105, ipv4=10.22.183.105 -[ 100.500000] usb0.1 sip = 10.22.183.105, tip=10.22.183.106, ipv4=10.22.183.105 - -root@ZhuoTK:/# quectel-CM -n 2 -s 4gnet & -[04-13_05:13:05:715] Quectel_QConnectManager_Linux_V1.6.0.25 -[04-13_05:13:05:717] Find /sys/bus/usb/devices/1-1.3 idVendor=0x2c7c idProduct=0x125, bus=0x001, dev=0x003 -[04-13_05:13:05:719] Auto find qmichannel = /dev/qcqmi0 -[04-13_05:13:05:719] Auto find usbnet_adapter = usb0 -[04-13_05:13:05:719] netcard driver = GobiNet, driver version = V1.6.2.13 -[04-13_05:13:05:719] qmap_mode = 4, qmap_version = 5, qmap_size = 4096, muxid = 0x82, qmap_netcard = usb0.2 -[04-13_05:13:05:720] Modem works in QMI mode -[04-13_05:13:05:734] Get clientWDS = 7 -[04-13_05:13:05:766] Get clientDMS = 8 -[04-13_05:13:05:798] Get clientNAS = 9 -[04-13_05:13:05:830] Get clientUIM = 10 -[04-13_05:13:05:861] requestBaseBandVersion EC25EFAR06A11M4G -[04-13_05:13:05:990] requestGetSIMStatus SIMStatus: SIM_READY -[04-13_05:13:05:991] requestSetProfile[2] 4gnet///0 -[04-13_05:13:06:054] requestGetProfile[2] 4gnet///0 -[04-13_05:13:06:086] requestRegistrationState2 MCC: 460, MNC: 0, PS: Attached, DataCap: LTE -[04-13_05:13:06:118] requestQueryDataCall IPv4ConnectionStatus: DISCONNECTED -[04-13_05:13:06:119] ifconfig usb0.2 0.0.0.0 -[04-13_05:13:06:131] ifconfig usb0.2 down -[04-13_05:13:06:375] requestSetupDataCall WdsConnectionIPv4Handle: 0x872b8c50 -[ 110.470000] net usb0: link_state 0x1 -> 0x3 -[04-13_05:13:06:507] ifconfig usb0 up -[04-13_05:13:06:518] ifconfig usb0.2 up -[04-13_05:13:06:539] you are use OpenWrt? -[04-13_05:13:06:540] should not calling udhcpc manually? -[04-13_05:13:06:540] should modify /etc/config/network as below? -[04-13_05:13:06:540] config interface wan -[04-13_05:13:06:540] option ifname usb0.2 -[04-13_05:13:06:540] option proto dhcp -[04-13_05:13:06:540] should use "/sbin/ifstaus wan" to check usb0.2 's status? -[04-13_05:13:06:540] busybox udhcpc -f -n -q -t 5 -i usb0.2 -[04-13_05:13:06:554] udhcpc (v1.23.2) started -[04-13_05:13:06:614] Sending discover... -[04-13_05:13:06:619] Sending select for 10.22.58.141... -[04-13_05:13:06:623] Lease of 10.22.58.141 obtained, lease time 7200 -[04-13_05:13:06:629] udhcpc: ifconfig usb0.2 10.22.58.141 netmask 255.255.255.252 broadcast + -[04-13_05:13:06:638] udhcpc: setting default routers: 10.22.58.142 - -root@ZhuoTK:/# ifconfig usb0.2 -usb0.2 Link encap:Ethernet HWaddr 02:50:F4:00:00:00 - inet addr:10.22.58.141 Mask:255.255.255.252 - inet6 addr: fe80::50:f4ff:fe00:0/64 Scope:Link - UP RUNNING NOARP MTU:1500 Metric:1 - RX packets:2 errors:0 dropped:0 overruns:0 frame:0 - TX packets:7 errors:0 dropped:0 overruns:0 carrier:0 - collisions:0 txqueuelen:1000 - RX bytes:612 (612.0 B) TX bytes:1064 (1.0 KiB) - -root@ZhuoTK:/# ip ro show -default via 10.22.58.142 dev usb0.2 -10.22.58.140/30 dev usb0.2 proto kernel scope link src 10.22.58.141 -192.168.1.0/24 dev br-lan proto kernel scope link src 192.168.1.251 - -root@ZhuoTK:/# ping 8.8.8.8 -PING 8.8.8.8 (8.8.8.8): 56 data bytes -64 bytes from 8.8.8.8: seq=0 ttl=52 time=69.822 ms - diff --git a/quectel_cm_5G/src/log/pcie_mhi_mbim.txt b/quectel_cm_5G/src/log/pcie_mhi_mbim.txt deleted file mode 100644 index 7a988a9..0000000 --- a/quectel_cm_5G/src/log/pcie_mhi_mbim.txt +++ /dev/null @@ -1,80 +0,0 @@ -root@OpenWrt:/# lspci -00:00.0 Class 0604: 17cb:1001 -01:00.0 Class ff00: 17cb:0306 - -root@OpenWrt:/# insmod pcie_mhi.ko mhi_mbim_enabled=1 -[ 63.094154] mhi_init Quectel_Linux_PCIE_MHI_Driver_V1.3.0.17 -[ 63.094739] mhi_pci_probe pci_dev->name = 0000:01:00.0, domain=0, bus=1, slot=0, vendor=17CB, device=0306 -[ 63.099373] mhi_q 0000:01:00.0: BAR 0: assigned [mem 0x48000000-0x48000fff 64bit] -[ 63.108476] mhi_q 0000:01:00.0: enabling device (0140 -> 0142) -[ 63.293451] [I][mhi_netdev_enable_iface] Prepare the channels for transfer -[ 63.324757] [I][mhi_netdev_enable_iface] Exited. -[ 63.326265] rmnet_vnd_register_device(rmnet_mhi0.1)=0 - -root@OpenWrt:/# quectel-CM -s cment & -[04-13_09:25:23:910] Quectel_QConnectManager_Linux_V1.6.0.25 -[04-13_09:25:23:912] network interface '' or qmidev '' is not exist -[04-13_09:25:23:912] netcard driver = pcie_mhi, driver version = V1.3.0.17 -[04-13_09:25:23:913] mbim_qmap_mode = 1, vlan_id = 0x00, qmap_netcard = rmnet_mhi0.1 -[04-13_09:25:23:913] Modem works in MBIM mode -[04-13_09:25:23:965] cdc_wdm_fd = 7 -[04-13_09:25:23:965] mbim_open_device() -[04-13_09:25:24:549] mbim_device_caps_query() -[04-13_09:25:24:575] DeviceId: 869710030002905 -[04-13_09:25:24:575] FirmwareInfo: RM500QGLABR10A03M4G_01.001.03 -[04-13_09:25:24:575] HardwareInfo: RM500QGL_VH -[04-13_09:25:24:576] mbim_device_services_query() -[04-13_09:25:24:585] mbim_set_radio_state( 1 ) -[04-13_09:25:24:588] HwRadioState: 1, SwRadioState: 1 -[04-13_09:25:24:588] mbim_subscriber_status_query() -[04-13_09:25:24:612] SubscriberId: 460028563800461 -[04-13_09:25:24:612] SimIccId: 89860015120716380461 -[04-13_09:25:24:613] SubscriberReadyState NotInitialized -> Initialized -[04-13_09:25:24:613] mbim_register_state_query() -[04-13_09:25:24:617] RegisterState Unknown -> Home -[04-13_09:25:24:617] mbim_packet_service_query() -[04-13_09:25:24:619] PacketServiceState Unknown -> Attached -[04-13_09:25:24:619] CurrentDataClass = 5G_NSA -[04-13_09:25:24:620] mbim_query_connect(sessionID=0) -[04-13_09:25:24:631] ActivationState Unknown -> Deactivated -[04-13_09:25:24:631] ifconfig rmnet_mhi0 down -[04-13_09:25:24:657] ifconfig rmnet_mhi0.1 0.0.0.0 -ifconfig: SIOCSIFFLAGS: Network is down -[04-13_09:25:24:681] ifconfig rmnet_mhi0.1 down -[04-13_09:25:24:705] mbim_register_state_query() -[04-13_09:25:24:709] mbim_packet_service_query() -[04-13_09:25:24:713] CurrentDataClass = 5G_NSA -[04-13_09:25:24:713] mbim_set_connect(onoff=1, sessionID=0) -[04-13_09:25:25:096] ActivationState Deactivated -> Activated -[04-13_09:25:25:097] mbim_ip_config(sessionID=0) -[04-13_09:25:25:100] < SessionId = 0 -[04-13_09:25:25:100] < IPv4ConfigurationAvailable = 0xf -[04-13_09:25:25:100] < IPv6ConfigurationAvailable = 0x0 -[04-13_09:25:25:101] < IPv4AddressCount = 0x1 -[04-13_09:25:25:101] < IPv4AddressOffset = 0x3c -[04-13_09:25:25:101] < IPv6AddressCount = 0x0 -[04-13_09:25:25:102] < IPv6AddressOffset = 0x0 -[04-13_09:25:25:102] < IPv4 = 10.190.166.229/30 -[04-13_09:25:25:103] < gw = 10.190.166.230 -[04-13_09:25:25:103] < dns1 = 211.138.180.2 -[04-13_09:25:25:103] < dns2 = 211.138.180.3 -[04-13_09:25:25:104] < ipv4 mtu = 1500 -[04-13_09:25:25:112] ifconfig rmnet_mhi0 up -[04-13_09:25:25:141] ifconfig rmnet_mhi0.1 up -[04-13_09:25:25:170] ip -4 address flush dev rmnet_mhi0.1 -[04-13_09:25:25:190] ip -4 address add 10.190.166.229/30 dev rmnet_mhi0.1 -[04-13_09:25:25:213] ip -4 route add default via 10.190.166.230 dev rmnet_mhi0.1 - -root@OpenWrt:/# ifconfig rmnet_mhi0.1 -rmnet_mhi0.1 Link encap:Ethernet HWaddr 02:50:F4:00:00:00 - inet addr:10.190.166.229 Mask:255.255.255.252 - inet6 addr: fe80::50:f4ff:fe00:0/64 Scope:Link - UP RUNNING NOARP MTU:1500 Metric:1 - RX packets:19 errors:0 dropped:0 overruns:0 frame:0 - TX packets:29 errors:0 dropped:0 overruns:0 carrier:0 - collisions:0 txqueuelen:1000 - RX bytes:2326 (2.2 KiB) TX bytes:2991 (2.9 KiB) - -root@OpenWrt:/# ping 8.8.8.8 -PING 8.8.8.8 (8.8.8.8): 56 data bytes -64 bytes from 8.8.8.8: seq=0 ttl=52 time=278.561 ms diff --git a/quectel_cm_5G/src/log/pcie_mhi_mbim_qmap=4.txt b/quectel_cm_5G/src/log/pcie_mhi_mbim_qmap=4.txt deleted file mode 100644 index 4d6cdf0..0000000 --- a/quectel_cm_5G/src/log/pcie_mhi_mbim_qmap=4.txt +++ /dev/null @@ -1,170 +0,0 @@ -root@OpenWrt:/# lspci -00:00.0 Class 0604: 17cb:1001 -01:00.0 Class ff00: 17cb:0304 -root@OpenWrt:/# insmod pcie_mhi.ko mhi_mbim_enabled=1 qmap_mode=4 -[ 76.596827] mhi_init Quectel_Linux_PCIE_MHI_Driver_V1.3.0.17 -[ 76.598596] mhi_pci_probe pci_dev->name = 0000:01:00.0, domain=0, bus=1, slot=0, vendor=17CB, device=0304 -[ 76.602863] mhi_q 0000:01:00.0: BAR 0: assigned [mem 0x48000000-0x48000fff 64bit] -[ 76.611323] mhi_q 0000:01:00.0: enabling device (0140 -> 0142) -[ 76.760239] [I][mhi_netdev_enable_iface] Prepare the channels for transfer -[ 76.828699] [I][mhi_netdev_enable_iface] Exited. -[ 76.832727] rmnet_vnd_register_device(rmnet_mhi0.1)=0 -[ 76.836596] rmnet_vnd_register_device(rmnet_mhi0.2)=0 -[ 76.841170] rmnet_vnd_register_device(rmnet_mhi0.3)=0 -[ 76.846373] rmnet_vnd_register_device(rmnet_mhi0.4)=0 - -root@OpenWrt:~# quectel-mbim-proxy -d /dev/mhi_MBIM & -root@OpenWrt:~# [04-14_03:05:36:296] mbim_dev_fd=3 -[04-14_03:05:36:297] mbim_send_open_msg() -[04-14_03:05:36:669] receive MBIM_OPEN_DONE, status=0 -[04-14_03:05:36:670] mbim_server_fd=4 - -root@OpenWrt:~# quectel-CM -n 1 -s cmnet & -[04-14_03:05:45:955] Quectel_QConnectManager_Linux_V1.6.0.25 -[04-14_03:05:45:956] network interface '' or qmidev '' is not exist -[04-14_03:05:45:957] netcard driver = pcie_mhi, driver version = V1.3.0.17 -[04-14_03:05:45:957] mbim_qmap_mode = 4, vlan_id = 0x01, qmap_netcard = rmnet_mhi0.1 -[04-14_03:05:45:958] Modem works in MBIM mode -[04-14_03:05:45:959] connect to quectel-mbim-proxy sockfd = 7 -[04-14_03:05:45:959] handle_client_connect client_fd=5, client_idx=1 -[04-14_03:05:45:959] cdc_wdm_fd = 7 -[04-14_03:05:45:960] mbim_open_device() -[04-14_03:05:45:961] mbim_device_caps_query() -[04-14_03:05:45:967] DeviceId: 860459050041596 -[04-14_03:05:45:968] FirmwareInfo: EM120RGLAPR02A03M4G_01.001.07 - -[04-14_03:05:45:968] HardwareInfo: EM120R_GL -[04-14_03:05:45:968] mbim_device_services_query() -[04-14_03:05:45:972] mbim_set_radio_state( 1 ) -[04-14_03:05:45:976] HwRadioState: 1, SwRadioState: 1 -[04-14_03:05:45:976] mbim_subscriber_status_query() -[04-14_03:05:45:985] SubscriberId: 460028563800461 -[04-14_03:05:45:985] SimIccId: 89860015120716380461 -[04-14_03:05:45:986] SubscriberReadyState NotInitialized -> Initialized -[04-14_03:05:45:986] mbim_register_state_query() -[04-14_03:05:45:991] RegisterState Unknown -> Home -[04-14_03:05:45:991] mbim_packet_service_query() -[04-14_03:05:45:995] PacketServiceState Unknown -> Attached -[04-14_03:05:45:996] mbim_query_connect(sessionID=1) -[04-14_03:05:46:000] ActivationState Unknown -> Deactivated -[04-14_03:05:46:000] ifconfig rmnet_mhi0 down -[04-14_03:05:46:024] ifconfig rmnet_mhi0.1 0.0.0.0 -ifconfig: SIOCSIFFLAGS: Network is down -[04-14_03:05:46:049] ifconfig rmnet_mhi0.1 down -[04-14_03:05:46:072] mbim_set_connect(onoff=1, sessionID=1) -[04-14_03:05:46:099] ActivationState Deactivated -> Activated -[04-14_03:05:46:099] mbim_ip_config(sessionID=1) -[ 222.484298] net rmnet_mhi0: link_state 0x0 -> 0x1 -[04-14_03:05:46:103] < SessionId = 1 -[04-14_03:05:46:104] < IPv4ConfigurationAvailable = 0xf -[04-14_03:05:46:104] < IPv6ConfigurationAvailable = 0x0 -[04-14_03:05:46:104] < IPv4AddressCount = 0x1 -[04-14_03:05:46:105] < IPv4AddressOffset = 0x3c -[ 222.507775] [I][mhi_netdev_open] Opened net dev interface -[04-14_03:05:46:105] < IPv6AddressCount = 0x0 -[04-14_03:05:46:105] < IPv6AddressOffset = 0x0 -[04-14_03:05:46:106] < IPv4 = 10.38.21.158/30 -[04-14_03:05:46:106] < gw = 10.38.21.157 -[04-14_03:05:46:106] < dns1 = 211.138.180.2 -[04-14_03:05:46:107] < dns2 = 211.138.180.3 -[04-14_03:05:46:107] < ipv4 mtu = 1500 -[04-14_03:05:46:112] ifconfig rmnet_mhi0 up -[04-14_03:05:46:140] ifconfig rmnet_mhi0.1 up -[04-14_03:05:46:168] ip -4 address flush dev rmnet_mhi0.1 -[04-14_03:05:46:190] ip -4 address add 10.38.21.158/30 dev rmnet_mhi0.1 -[04-14_03:05:46:212] ip -4 route add default via 10.38.21.157 dev rmnet_mhi0.1 -[04-14_03:05:50:730] handle_client_connect client_fd=6, client_idx=2 -[ 227.558631] net rmnet_mhi0: link_state 0x1 -> 0x3 - -root@OpenWrt:~# quectel-CM -n 2 -s 4gnet -[04-14_03:05:50:725] Quectel_QConnectManager_Linux_V1.6.0.25 -[04-14_03:05:50:726] network interface '' or qmidev '' is not exist -[04-14_03:05:50:727] netcard driver = pcie_mhi, driver version = V1.3.0.17 -[04-14_03:05:50:728] mbim_qmap_mode = 4, vlan_id = 0x02, qmap_netcard = rmnet_mhi0.2 -[04-14_03:05:50:729] Modem works in MBIM mode -[04-14_03:05:50:730] connect to quectel-mbim-proxy sockfd = 8 -[04-14_03:05:50:730] cdc_wdm_fd = 8 -[04-14_03:05:50:731] mbim_open_device() -[04-14_03:05:50:732] mbim_device_caps_query() -[04-14_03:05:50:738] DeviceId: 860459050041596 -[04-14_03:05:50:739] FirmwareInfo: EM120RGLAPR02A03M4G_01.001.07 - -[04-14_03:05:50:739] HardwareInfo: EM120R_GL -[04-14_03:05:50:740] mbim_device_services_query() -[04-14_03:05:50:744] mbim_set_radio_state( 1 ) -[04-14_03:05:50:747] HwRadioState: 1, SwRadioState: 1 -[04-14_03:05:50:747] mbim_subscriber_status_query() -[04-14_03:05:50:757] SubscriberId: 460028563800461 -[04-14_03:05:50:758] SimIccId: 89860015120716380461 -[04-14_03:05:50:758] SubscriberReadyState NotInitialized -> Initialized -[04-14_03:05:50:759] mbim_register_state_query() -[04-14_03:05:50:763] RegisterState Unknown -> Home -[04-14_03:05:50:764] mbim_packet_service_query() -[04-14_03:05:50:768] PacketServiceState Unknown -> Attached -[04-14_03:05:50:769] mbim_query_connect(sessionID=2) -[04-14_03:05:50:772] ActivationState Unknown -> Deactivated -[04-14_03:05:50:773] ifconfig rmnet_mhi0.2 0.0.0.0 -[04-14_03:05:50:799] ifconfig rmnet_mhi0.2 down -[04-14_03:05:50:834] mbim_set_connect(onoff=1, sessionID=2) -[04-14_03:05:51:170] ActivationState Deactivated -> Activated -[04-14_03:05:51:171] mbim_ip_config(sessionID=2) -[04-14_03:05:51:174] < SessionId = 2 -[04-14_03:05:51:174] < IPv4ConfigurationAvailable = 0xf -[04-14_03:05:51:175] < IPv6ConfigurationAvailable = 0x0 -[04-14_03:05:51:175] < IPv4AddressCount = 0x1 -[04-14_03:05:51:175] < IPv4AddressOffset = 0x3c -[04-14_03:05:51:176] < IPv6AddressCount = 0x0 -[04-14_03:05:51:176] < IPv6AddressOffset = 0x0 -[04-14_03:05:51:176] < IPv4 = 10.36.109.217/30 -[04-14_03:05:51:177] < gw = 10.36.109.218 -[04-14_03:05:51:177] < dns1 = 211.138.180.2 -[04-14_03:05:51:178] < dns2 = 211.138.180.3 -[04-14_03:05:51:178] < ipv4 mtu = 1500 -[04-14_03:05:51:182] ifconfig rmnet_mhi0 up -[04-14_03:05:51:206] ifconfig rmnet_mhi0.2 up -[04-14_03:05:51:233] ip -4 address flush dev rmnet_mhi0.2 -[04-14_03:05:51:254] ip -4 address add 10.36.109.217/30 dev rmnet_mhi0.2 -[04-14_03:05:51:277] ip -4 route add default via 10.36.109.218 dev rmnet_mhi0.2 - -root@OpenWrt:~# ifconfig rmnet_mhi0.1 -rmnet_mhi0.1 Link encap:Ethernet HWaddr 02:50:F4:00:00:00 - inet addr:10.38.21.158 Mask:255.255.255.252 - inet6 addr: fe80::50:f4ff:fe00:0/64 Scope:Link - UP RUNNING NOARP MTU:1500 Metric:1 - RX packets:37 errors:0 dropped:0 overruns:0 frame:0 - TX packets:29 errors:0 dropped:0 overruns:0 carrier:0 - collisions:0 txqueuelen:1000 - RX bytes:9907 (9.6 KiB) TX bytes:2764 (2.6 KiB) - -root@OpenWrt:~# ifconfig rmnet_mhi0.2 -rmnet_mhi0.2 Link encap:Ethernet HWaddr 02:50:F4:00:00:00 - inet addr:10.36.109.217 Mask:255.255.255.252 - inet6 addr: fe80::50:f4ff:fe00:0/64 Scope:Link - UP RUNNING NOARP MTU:1500 Metric:1 - RX packets:5 errors:0 dropped:0 overruns:0 frame:0 - TX packets:18 errors:0 dropped:0 overruns:0 carrier:0 - collisions:0 txqueuelen:1000 - RX bytes:344 (344.0 B) TX bytes:1152 (1.1 KiB) - -root@OpenWrt:~# ip ro del 8.8.8.8/32 -RTNETLINK answers: No such process -root@OpenWrt:~# ip ro add 8.8.8.8/32 dev rmnet_mhi0.1 -root@OpenWrt:~# ping 8.8.8.8 -PING 8.8.8.8 (8.8.8.8): 56 data bytes -64 bytes from 8.8.8.8: seq=0 ttl=52 time=73.248 ms - -root@OpenWrt:~# ip ro del 8.8.8.8/32 -root@OpenWrt:~# ip ro del 8.8.8.8/32 -RTNETLINK answers: No such process -root@OpenWrt:~# ip ro add 8.8.8.8/32 dev rmnet_mhi0.2 -root@OpenWrt:~# ping 8.8.8.8 -PING 8.8.8.8 (8.8.8.8): 56 data bytes -64 bytes from 8.8.8.8: seq=0 ttl=52 time=99.637 ms - -root@OpenWrt:~# quectel-CM -k 2 -[04-14_03:06:58:912] Quectel_QConnectManager_Linux_V1.6.0.25 -[04-14_03:06:59:063] /proc/3565/cmdline: quectel-CM -n 2 -s 4gnet -[04-14_03:06:59:064] send SIGINT to process 3565 -[ 295.719442] net rmnet_mhi0: link_state 0x3 -> 0x1 -[04-14_03:06:59:407] proxy_loop poll fd = 6, revents = 0011 -[04-14_03:06:59:408] handle_client_disconnect client_fd=6, client_idx=2 diff --git a/quectel_cm_5G/src/log/pcie_mhi_qmap=1.txt b/quectel_cm_5G/src/log/pcie_mhi_qmap=1.txt deleted file mode 100644 index c93af7e..0000000 --- a/quectel_cm_5G/src/log/pcie_mhi_qmap=1.txt +++ /dev/null @@ -1,127 +0,0 @@ -root@OpenWrt:/# cat /sys/class/net/rmnet_mhi0/qmap_mode -1 -root@OpenWrt:/# cat /sys/module/pcie_mhi/parameters/mhi_mbim_enabled -0 -root@OpenWrt:/# dmesg | grep mhi -[ 18.442226] mhi_init Quectel_Linux_PCIE_MHI_Driver_V1.3.0.17 -[ 18.443032] mhi_pci_probe pci_dev->name = 0000:01:00.0, domain=0, bus=1, slot=0, vendor=17CB, device=0306 -[ 18.447488] mhi_q 0000:01:00.0: BAR 0: assigned [mem 0x48000000-0x48000fff 64bit] -[ 18.456563] mhi_q 0000:01:00.0: enabling device (0140 -> 0142) -[ 18.464184] [I][mhi_init_pci_dev] msi_required = 5, msi_allocated = 5, msi_irq = 197 -[ 18.464215] [I][mhi_power_up] dev_state:RESET -[ 18.464225] [I][mhi_async_power_up] Requested to power on -[ 18.464432] [I][mhi_alloc_coherent] size = 114688, dma_handle = 8d400000 -[ 18.464445] [I][mhi_init_dev_ctxt] mhi_ctxt->ctrl_seg = d1766000 -[ 18.466003] [I][mhi_async_power_up] dev_state:RESET ee:AMSS -[ 18.466080] [I][mhi_pm_st_worker] Transition to state:READY -[ 18.466109] [I][mhi_pm_st_worker] INVALID_EE -> AMSS -[ 18.466135] [I][mhi_ready_state_transition] Waiting to enter READY state -[ 18.466224] [I][mhi_async_power_up] Power on setup success -[ 18.466265] [I][mhi_pci_probe] Return successful -[ 18.577299] [I][mhi_intvec_threaded_handlr] device ee:AMSS dev_state:READY, pm_state:POR -[ 18.577312] [I][mhi_ready_state_transition] Device in READY State -[ 18.577325] [I][mhi_intvec_threaded_handlr] device ee:AMSS dev_state:READY, INVALID_EE -[ 18.577329] [I][mhi_tryset_pm_state] Transition to pm state from:POR to:POR -[ 18.577337] [I][mhi_init_mmio] Initializing MMIO -[ 18.577344] [I][mhi_init_mmio] CHDBOFF:0x300 -[ 18.577361] [I][mhi_init_mmio] ERDBOFF:0x700 -[ 18.577372] [I][mhi_init_mmio] Programming all MMIO values. -[ 18.690834] [I][mhi_dump_tre] carl_ev evt_state_change mhistate=2 -[ 18.690854] [I][mhi_process_ctrl_ev_ring] MHI state change event to state:M0 -[ 18.690866] [I][mhi_pm_m0_transition] Entered With State:READY PM_STATE:POR -[ 18.690879] [I][mhi_tryset_pm_state] Transition to pm state from:POR to:M0 -[ 18.694229] [I][mhi_dump_tre] carl_ev evt_ee_state execenv=2 -[ 18.694241] [I][mhi_process_ctrl_ev_ring] MHI EE received event:AMSS -[ 18.694293] [I][mhi_pm_st_worker] Transition to state:MISSION MODE -[ 18.694310] [I][mhi_pm_st_worker] INVALID_EE -> AMSS -[ 18.694319] [I][mhi_pm_mission_mode_transition] Processing Mission Mode Transition -[ 18.694341] [I][mhi_init_timesync] No timesync capability found -[ 18.694350] [I][mhi_pm_mission_mode_transition] Adding new devices -[ 18.696365] [I][mhi_dtr_probe] Enter for DTR control channel -[ 18.696383] [I][__mhi_prepare_channel] Entered: preparing channel:18 -[ 18.703113] [I][mhi_dump_tre] carl_ev evt_cmd_comp code=1, type=33 -[ 18.703164] [I][__mhi_prepare_channel] Chan:18 successfully moved to start state -[ 18.703174] [I][__mhi_prepare_channel] Entered: preparing channel:19 -[ 18.710681] [I][mhi_dump_tre] carl_ev evt_cmd_comp code=1, type=33 -[ 18.710734] [I][__mhi_prepare_channel] Chan:19 successfully moved to start state -[ 18.710804] [I][mhi_dtr_probe] Exit with ret:0 -[ 18.711774] [I][mhi_netdev_enable_iface] Prepare the channels for transfer -[ 18.711811] [I][__mhi_prepare_channel] Entered: preparing channel:100 -[ 18.732097] [I][mhi_dump_tre] carl_ev evt_cmd_comp code=1, type=33 -[ 18.732151] [I][__mhi_prepare_channel] Chan:100 successfully moved to start state -[ 18.732162] [I][__mhi_prepare_channel] Entered: preparing channel:101 -[ 18.744170] [I][mhi_dump_tre] carl_ev evt_cmd_comp code=1, type=33 -[ 18.744219] [I][__mhi_prepare_channel] Chan:101 successfully moved to start state -[ 18.749132] [I][mhi_netdev_enable_iface] Exited. -[ 18.750306] rmnet_vnd_register_device(rmnet_mhi0.1)=0 -[ 18.752927] [I][mhi_pm_mission_mode_transition] Exit with ret:0 - -root@OpenWrt:/# busybox microcom /dev/mhi_DUN -at+cpin? -+CPIN: READY - -OK -at+cops? -+COPS: 0,0,"CHINA MOBILE",13 - -OK -at+csq -+csq: 23,99 - -OK - -root@OpenWrt:/# quectel-CM -s cmnet & -[04-13_09:26:58:077] Quectel_QConnectManager_Linux_V1.6.0.25 -[04-13_09:26:58:078] network interface '' or qmidev '' is not exist -[04-13_09:26:58:079] netcard driver = pcie_mhi, driver version = V1.3.0.17 -[04-13_09:26:58:080] qmap_mode = 1, qmap_version = 9, qmap_size = 16384, muxid = 0x81, qmap_netcard = rmnet_mhi0.1 -[04-13_09:26:58:080] Modem works in QMI mode -[04-13_09:26:58:131] cdc_wdm_fd = 7 -[04-13_09:26:59:132] QmiWwanInit message timeout -[04-13_09:27:00:140] Get clientWDS = 15 -[04-13_09:27:00:144] Get clientDMS = 1 -[04-13_09:27:00:147] Get clientNAS = 4 -[04-13_09:27:00:151] Get clientUIM = 1 -[04-13_09:27:00:155] Get clientWDA = 1 -[04-13_09:27:00:158] requestBaseBandVersion RM500QGLABR10A03M4G -[04-13_09:27:00:161] qmap_settings.rx_urb_size = 16384 -[04-13_09:27:00:162] qmap_settings.ul_data_aggregation_max_datagrams = 11 -[04-13_09:27:00:162] qmap_settings.ul_data_aggregation_max_size = 8192 -[04-13_09:27:00:163] qmap_settings.dl_minimum_padding = 0 -[04-13_09:27:00:176] requestGetSIMStatus SIMStatus: SIM_READY -[04-13_09:27:00:177] requestSetProfile[1] cmnet///0 -[04-13_09:27:00:190] requestGetProfile[1] cmnet///0 -[04-13_09:27:00:193] requestRegistrationState2 MCC: 460, MNC: 0, PS: Attached, DataCap: 5G_NSA -[04-13_09:27:00:197] requestQueryDataCall IPv4ConnectionStatus: DISCONNECTED -[04-13_09:27:00:198] ifconfig rmnet_mhi0 down -[04-13_09:27:00:222] ifconfig rmnet_mhi0.1 0.0.0.0 -[04-13_09:27:00:247] ifconfig rmnet_mhi0.1 down -[04-13_09:27:00:281] requestSetupDataCall WdsConnectionIPv4Handle: 0x1228bb20 -[ 245.284909] net rmnet_mhi0: link_state 0x0 -> 0x1 -[04-13_09:27:00:293] ifconfig rmnet_mhi0 up -[ 245.308696] [I][mhi_netdev_open] Opened net dev interface -[04-13_09:27:00:318] ifconfig rmnet_mhi0.1 up -[04-13_09:27:00:353] you are use OpenWrt? -[04-13_09:27:00:354] should not calling udhcpc manually? -[04-13_09:27:00:354] should modify /etc/config/network as below? -[04-13_09:27:00:355] config interface wan -[04-13_09:27:00:355] option ifname rmnet_mhi0.1 -[04-13_09:27:00:355] option proto dhcp -[04-13_09:27:00:356] should use "/sbin/ifstaus wan" to check rmnet_mhi0.1 's status? -[04-13_09:27:00:356] busybox udhcpc -f -n -q -t 5 -i rmnet_mhi0.1 -udhcpc: started, v1.28.3 -udhcpc: sending discover -udhcpc: sending select for 10.128.73.23 -udhcpc: lease of 10.128.73.23 obtained, lease time 7200 -[04-13_09:27:00:710] udhcpc: ifconfig rmnet_mhi0.1 10.128.73.23 netmask 255.255.255.240 broadcast + -[04-13_09:27:00:742] udhcpc: setting default routers: 10.128.73.24 - -root@OpenWrt:/# ifconfig rmnet_mhi0.1 -rmnet_mhi0.1 Link encap:Ethernet HWaddr 02:50:F4:00:00:00 - inet addr:10.128.73.23 Mask:255.255.255.240 - inet6 addr: fe80::50:f4ff:fe00:0/64 Scope:Link - UP RUNNING NOARP MTU:1500 Metric:1 - RX packets:2 errors:0 dropped:0 overruns:0 frame:0 - TX packets:2 errors:0 dropped:0 overruns:0 carrier:0 - collisions:0 txqueuelen:1000 - RX bytes:612 (612.0 B) TX bytes:684 (684.0 B) diff --git a/quectel_cm_5G/src/log/pcie_mhi_qmap=1_bridge.txt b/quectel_cm_5G/src/log/pcie_mhi_qmap=1_bridge.txt deleted file mode 100644 index 0ab6de7..0000000 --- a/quectel_cm_5G/src/log/pcie_mhi_qmap=1_bridge.txt +++ /dev/null @@ -1,76 +0,0 @@ -root@OpenWrt:/# lspci -00:00.0 Class 0604: 17cb:1001 -01:00.0 Class ff00: 17cb:0306 - -root@OpenWrt:~# insmod pcie_mhi.ko -[ 77.949271] mhi_init Quectel_Linux_PCIE_MHI_Driver_V1.3.0.17 -[ 77.950949] mhi_pci_probe pci_dev->name = 0000:01:00.0, domain=0, bus=1, slot=0, vendor=17CB, device=0306 -[ 77.955331] mhi_q 0000:01:00.0: BAR 0: assigned [mem 0x48000000-0x48000fff 64bit] -[ 77.963756] mhi_q 0000:01:00.0: enabling device (0140 -> 0142) -[ 78.048911] [I][mhi_netdev_enable_iface] Prepare the channels for transfer -[ 78.092304] [I][mhi_netdev_enable_iface] Exited. -[ 78.096580] rmnet_vnd_register_device(rmnet_mhi0.1)=0 - -root@OpenWrt:~# brctl addbr br0 -root@OpenWrt:~# brctl addif br0 rmnet_mhi0.1 -root@OpenWrt:~# brctl addif br0 eth1 -[ 250.017213] device eth1 entered promiscuous mode -root@OpenWrt:~# brctl show -bridge name bridge id STP enabled interfaces -br0 8000.00001c353487 no eth1 - rmnet_mhi0.1 - -root@OpenWrt:~# quectel-CM -s cmnet -b & -[04-14_06:43:28:473] Quectel_QConnectManager_Linux_V1.6.0.25 -[04-14_06:43:28:474] network interface '' or qmidev '' is not exist -[04-14_06:43:28:475] netcard driver = pcie_mhi, driver version = V1.3.0.17 -[04-14_06:43:28:476] qmap_mode = 1, qmap_version = 9, qmap_size = 16384, muxid = 0x81, qmap_netcard = rmnet_mhi0.1 -[04-14_06:43:28:477] Modem works in QMI mode -[04-14_06:43:28:531] cdc_wdm_fd = 7 -[04-14_06:43:29:532] QmiWwanInit message timeout -[04-14_06:43:30:540] Get clientWDS = 15 -[04-14_06:43:30:543] Get clientDMS = 1 -[04-14_06:43:30:546] Get clientNAS = 4 -[04-14_06:43:30:550] Get clientUIM = 1 -[04-14_06:43:30:553] Get clientWDA = 1 -[04-14_06:43:30:557] requestBaseBandVersion RM500QGLABR10A03M4G -[04-14_06:43:30:560] qmap_settings.rx_urb_size = 16384 -[04-14_06:43:30:561] qmap_settings.ul_data_aggregation_max_datagrams = 11 -[04-14_06:43:30:561] qmap_settings.ul_data_aggregation_max_size = 8192 -[04-14_06:43:30:561] qmap_settings.dl_minimum_padding = 0 -[04-14_06:43:30:575] requestGetSIMStatus SIMStatus: SIM_READY -[04-14_06:43:30:575] requestSetProfile[1] cmnet///0 -[04-14_06:43:30:588] requestGetProfile[1] cmnet///0 -[04-14_06:43:30:591] requestRegistrationState2 MCC: 460, MNC: 0, PS: Attached, DataCap: 5G_NSA -[04-14_06:43:30:595] requestQueryDataCall IPv4ConnectionStatus: DISCONNECTED -[04-14_06:43:30:595] ifconfig rmnet_mhi0 down -[04-14_06:43:30:620] ifconfig rmnet_mhi0.1 0.0.0.0 -ifconfig: SIOCSIFFLAGS: Network is down -[04-14_06:43:30:644] ifconfig rmnet_mhi0.1 down -[04-14_06:43:30:679] requestSetupDataCall WdsConnectionIPv4Handle: 0xb41f47d0 -[ 263.869899] net rmnet_mhi0: link_state 0x0 -> 0x1 -[04-14_06:43:30:693] ifconfig rmnet_mhi0 up -[ 263.892647] [I][mhi_netdev_open] Opened net dev interface -[04-14_06:43:30:718] ifconfig rmnet_mhi0.1 up -[04-14_06:43:30:746] echo '0xa59316b' > /sys/class/net/rmnet_mhi0.1/bridge_ipv4 - -root@OpenWrt:~# ifconfig br0 up -[ 268.800026] br0: port 2(eth1) entered forwarding state -[ 268.800336] br0: port 2(eth1) entered forwarding state -[ 268.804251] br0: port 1(rmnet_mhi0.1) entered forwarding state -[ 268.809465] br0: port 1(rmnet_mhi0.1) entered forwarding state -[ 283.845790] br0: port 2(eth1) entered forwarding state - -[ 296.512489] rmnet_mhi0.1 PC Mac Address: 00:0e:c6:a6:6c:f1 -[ 296.515756] rmnet_mhi0.1 PC Mac Address: 00:0e:c6:a6:6c:f1 -[ 296.586584] rmnet_mhi0.1 sip = 10.89.49.107, tip=10.89.49.108, ipv4=10.89.49.107 -[ 296.672356] rmnet_mhi0.1 sip = 10.89.49.107, tip=10.89.49.108, ipv4=10.89.49.107 -[ 296.792061] rmnet_mhi0.1 sip = 10.89.49.107, tip=10.89.49.108, ipv4=10.89.49.107 -[ 296.832822] rmnet_mhi0.1 sip = 10.89.49.107, tip=10.89.49.108, ipv4=10.89.49.107 -[ 296.941073] rmnet_mhi0.1 sip = 0.0.0.0, tip=10.89.49.107, ipv4=10.89.49.107 -[ 297.941310] rmnet_mhi0.1 sip = 0.0.0.0, tip=10.89.49.107, ipv4=10.89.49.107 -[ 298.941528] rmnet_mhi0.1 sip = 0.0.0.0, tip=10.89.49.107, ipv4=10.89.49.107 -[ 299.941704] rmnet_mhi0.1 sip = 10.89.49.107, tip=10.89.49.107, ipv4=10.89.49.107 -[ 300.024484] rmnet_mhi0.1 sip = 10.89.49.107, tip=10.89.49.108, ipv4=10.89.49.107 -[ 300.051995] rmnet_mhi0.1 sip = 10.89.49.107, tip=10.89.49.108, ipv4=10.89.49.107 -[ 303.915933] rmnet_mhi0.1 sip = 10.89.49.107, tip=10.89.49.108, ipv4=10.89.49.107 diff --git a/quectel_cm_5G/src/log/pcie_mhi_qmap=4.txt b/quectel_cm_5G/src/log/pcie_mhi_qmap=4.txt deleted file mode 100644 index 5f43a74..0000000 --- a/quectel_cm_5G/src/log/pcie_mhi_qmap=4.txt +++ /dev/null @@ -1,138 +0,0 @@ -root@OpenWrt:/# lspci -00:00.0 Class 0604: 17cb:1001 -01:00.0 Class ff00: 17cb:0306 - -root@OpenWrt:/# insmod pcie_mhi.ko qmap_mode=4 -[ 61.988878] mhi_init Quectel_Linux_PCIE_MHI_Driver_V1.3.0.17 -[ 61.989484] mhi_pci_probe pci_dev->name = 0000:01:00.0, domain=0, bus=1, slot=0, vendor=17CB, device=0306 -[ 61.994039] mhi_q 0000:01:00.0: BAR 0: assigned [mem 0x48000000-0x48000fff 64bit] -[ 62.003208] mhi_q 0000:01:00.0: enabling device (0140 -> 0142) -[ 62.191947] [I][mhi_netdev_enable_iface] Prepare the channels for transfer -[ 62.224065] [I][mhi_netdev_enable_iface] Exited. -[ 62.225619] rmnet_vnd_register_device(rmnet_mhi0.1)=0 -[ 62.229289] rmnet_vnd_register_device(rmnet_mhi0.2)=0 -[ 62.234378] rmnet_vnd_register_device(rmnet_mhi0.3)=0 -[ 62.240039] rmnet_vnd_register_device(rmnet_mhi0.4)=0 - -root@OpenWrt:/# quectel-qmi-proxy -d /dev/mhi_QMI0 & -[04-13_09:25:12:278] Will use cdc-wdm='/dev/mhi_QMI0', proxy='quectel-qmi-proxy0' -[04-13_09:25:12:297] qmi_proxy_init enter -[04-13_09:25:12:297] qmi_proxy_loop enter thread_id 0xb6e88d44 -[04-13_09:25:14:298] qmi_proxy_init succful -[04-13_09:25:14:299] local server: quectel-qmi-proxy0 sockfd = 4 -[04-13_09:25:14:299] qmi_proxy_server_fd = 4 - -root@OpenWrt:/# quectel-CM -n 1 -s cmnet & -[04-13_09:25:32:336] Quectel_QConnectManager_Linux_V1.6.0.25 -[04-13_09:25:32:337] network interface '' or qmidev '' is not exist -[04-13_09:25:32:338] netcard driver = pcie_mhi, driver version = V1.3.0.17 -[04-13_09:25:32:339] qmap_mode = 4, qmap_version = 9, qmap_size = 16384, muxid = 0x81, qmap_netcard = rmnet_mhi0.1 -[04-13_09:25:32:340] Modem works in QMI mode -[04-13_09:25:32:341] connect to quectel-qmi-proxy0 sockfd = 7 -[04-13_09:25:32:342] cdc_wdm_fd = 7 -[04-13_09:25:32:380] requestBaseBandVersion RM500QGLABR10A03M4G -[04-13_09:25:32:382] qmap_settings.rx_urb_size = 16384 -[04-13_09:25:32:383] qmap_settings.ul_data_aggregation_max_datagrams = 11 -[04-13_09:25:32:383] qmap_settings.ul_data_aggregation_max_size = 8192 -[04-13_09:25:32:384] qmap_settings.dl_minimum_padding = 0 -[04-13_09:25:32:394] requestGetSIMStatus SIMStatus: SIM_READY -[04-13_09:25:32:395] requestSetProfile[1] cmnet///0 -[04-13_09:25:32:409] requestGetProfile[1] cmnet///0 -[04-13_09:25:32:414] requestRegistrationState2 MCC: 460, MNC: 0, PS: Attached, DataCap: 5G_NSA -[04-13_09:25:32:418] requestQueryDataCall IPv4ConnectionStatus: DISCONNECTED -[04-13_09:25:32:419] ifconfig rmnet_mhi0 down -[04-13_09:25:32:448] ifconfig rmnet_mhi0.1 0.0.0.0 -[04-13_09:25:32:473] ifconfig rmnet_mhi0.1 down -[04-13_09:25:32:514] requestSetupDataCall WdsConnectionIPv4Handle: 0x2313a2a0 -[ 121.648172] net rmnet_mhi0: link_state 0x0 -> 0x1 -[04-13_09:25:32:525] ifconfig rmnet_mhi0 up -[ 121.671210] [I][mhi_netdev_open] Opened net dev interface -[04-13_09:25:32:551] ifconfig rmnet_mhi0.1 up -[04-13_09:25:32:586] you are use OpenWrt? -[04-13_09:25:32:587] should not calling udhcpc manually? -[04-13_09:25:32:587] should modify /etc/config/network as below? -[04-13_09:25:32:587] config interface wan -[04-13_09:25:32:588] option ifname rmnet_mhi0.1 -[04-13_09:25:32:588] option proto dhcp -[04-13_09:25:32:589] should use "/sbin/ifstaus wan" to check rmnet_mhi0.1 's status? -[04-13_09:25:32:589] busybox udhcpc -f -n -q -t 5 -i rmnet_mhi0.1 -udhcpc: started, v1.28.3 -udhcpc: sending discover -udhcpc: sending select for 10.174.91.70 -udhcpc: lease of 10.174.91.70 obtained, lease time 7200 -[04-13_09:25:32:980] udhcpc: ifconfig rmnet_mhi0.1 10.174.91.70 netmask 255.255.255.252 broadcast + -[04-13_09:25:33:007] udhcpc: setting default routers: 10.174.91.69 - -root@OpenWrt:/# quectel-CM -n 2 -s 4gnet & -[04-13_09:25:42:976] Quectel_QConnectManager_Linux_V1.6.0.25 -[04-13_09:25:42:977] network interface '' or qmidev '' is not exist -[04-13_09:25:42:978] netcard driver = pcie_mhi, driver version = V1.3.0.17 -[04-13_09:25:42:978] qmap_mode = 4, qmap_version = 9, qmap_size = 16384, muxid = 0x82, qmap_netcard = rmnet_mhi0.2 -[04-13_09:25:42:979] Modem works in QMI mode -[04-13_09:25:42:981] connect to quectel-qmi-proxy0 sockfd = 7 -[04-13_09:25:42:982] cdc_wdm_fd = 7 -[04-13_09:25:43:010] requestBaseBandVersion RM500QGLABR10A03M4G -[04-13_09:25:43:013] qmap_settings.rx_urb_size = 16384 -[04-13_09:25:43:014] qmap_settings.ul_data_aggregation_max_datagrams = 11 -[04-13_09:25:43:014] qmap_settings.ul_data_aggregation_max_size = 8192 -[04-13_09:25:43:015] qmap_settings.dl_minimum_padding = 0 -[04-13_09:25:43:030] requestGetSIMStatus SIMStatus: SIM_READY -[04-13_09:25:43:030] requestSetProfile[2] 4gnet///0 -[04-13_09:25:43:046] requestGetProfile[2] 4gnet///0 -[04-13_09:25:43:050] requestRegistrationState2 MCC: 460, MNC: 0, PS: Attached, DataCap: 5G_NSA -[04-13_09:25:43:054] requestQueryDataCall IPv4ConnectionStatus: DISCONNECTED -[04-13_09:25:43:055] ifconfig rmnet_mhi0.2 0.0.0.0 -[04-13_09:25:43:082] ifconfig rmnet_mhi0.2 down -[04-13_09:25:43:507] requestSetupDataCall WdsConnectionIPv4Handle: 0x2332a780 -[ 132.641313] net rmnet_mhi0: link_state 0x1 -> 0x3 -[04-13_09:25:43:519] ifconfig rmnet_mhi0 up -[04-13_09:25:43:543] ifconfig rmnet_mhi0.2 up -[04-13_09:25:43:570] you are use OpenWrt? -[04-13_09:25:43:570] should not calling udhcpc manually? -[04-13_09:25:43:571] should modify /etc/config/network as below? -[04-13_09:25:43:571] config interface wan -[04-13_09:25:43:571] option ifname rmnet_mhi0.2 -[04-13_09:25:43:572] option proto dhcp -[04-13_09:25:43:572] should use "/sbin/ifstaus wan" to check rmnet_mhi0.2 's status? -[04-13_09:25:43:573] busybox udhcpc -f -n -q -t 5 -i rmnet_mhi0.2 -udhcpc: started, v1.28.3 -udhcpc: sending discover -udhcpc: sending select for 10.163.253.197 -udhcpc: lease of 10.163.253.197 obtained, lease time 7200 -[04-13_09:25:43:810] udhcpc: ifconfig rmnet_mhi0.2 10.163.253.197 netmask 255.255.255.252 broadcast + -[04-13_09:25:43:836] udhcpc: setting default routers: 10.163.253.198 - -root@OpenWrt:/# ifconfig rmnet_mhi0.1 -rmnet_mhi0.1 Link encap:Ethernet HWaddr 02:50:F4:00:00:00 - inet addr:10.174.91.70 Mask:255.255.255.252 - inet6 addr: fe80::50:f4ff:fe00:0/64 Scope:Link - UP RUNNING NOARP MTU:1500 Metric:1 - RX packets:2 errors:0 dropped:0 overruns:0 frame:0 - TX packets:4 errors:0 dropped:0 overruns:0 carrier:0 - collisions:0 txqueuelen:1000 - RX bytes:612 (612.0 B) TX bytes:1380 (1.3 KiB) - -root@OpenWrt:/# ifconfig rmnet_mhi0.2 -rmnet_mhi0.2 Link encap:Ethernet HWaddr 02:50:F4:00:00:00 - inet addr:10.163.253.197 Mask:255.255.255.252 - inet6 addr: fe80::50:f4ff:fe00:0/64 Scope:Link - UP RUNNING NOARP MTU:1500 Metric:1 - RX packets:2 errors:0 dropped:0 overruns:0 frame:0 - TX packets:2 errors:0 dropped:0 overruns:0 carrier:0 - collisions:0 txqueuelen:1000 - RX bytes:612 (612.0 B) TX bytes:684 (684.0 B) - -root@OpenWrt:/# ip ro del 8.8.8.8/32 -RTNETLINK answers: No such process -root@OpenWrt:/# ip ro add 8.8.8.8/32 dev rmnet_mhi0.1 -root@OpenWrt:/# ping 8.8.8.8 -PING 8.8.8.8 (8.8.8.8): 56 data bytes -64 bytes from 8.8.8.8: seq=0 ttl=52 time=390.869 ms - -root@OpenWrt:/# ip ro del 8.8.8.8/32 -root@OpenWrt:/# ip ro del 8.8.8.8/32 -RTNETLINK answers: No such process -root@OpenWrt:/# ip ro add 8.8.8.8/32 dev rmnet_mhi0.2 -root@OpenWrt:/# ping 8.8.8.8 -PING 8.8.8.8 (8.8.8.8): 56 data bytes -64 bytes from 8.8.8.8: seq=0 ttl=111 time=314.395 ms \ No newline at end of file diff --git a/quectel_cm_5G/src/log/pcie_mhi_qmap=4_bridge.txt b/quectel_cm_5G/src/log/pcie_mhi_qmap=4_bridge.txt deleted file mode 100644 index 0af5ff0..0000000 --- a/quectel_cm_5G/src/log/pcie_mhi_qmap=4_bridge.txt +++ /dev/null @@ -1,147 +0,0 @@ -root@OpenWrt:~# lspci -00:00.0 Class 0604: 17cb:1001 -01:00.0 Class ff00: 17cb:0306 -root@OpenWrt:~# - -root@OpenWrt:~# insmod pcie_mhi.ko qmap_mode=4 -[ 200.906104] mhi_init Quectel_Linux_PCIE_MHI_Driver_V1.3.0.17 -[ 200.907913] mhi_pci_probe pci_dev->name = 0000:01:00.0, domain=0, bus=1, slot=0, vendor=17CB, device=0306 -[ 200.912164] mhi_q 0000:01:00.0: BAR 0: assigned [mem 0x48000000-0x48000fff 64bit] -[ 200.920593] mhi_q 0000:01:00.0: enabling device (0140 -> 0142) -root@OpenWrt:~# [ 201.112214] [I][mhi_netdev_enable_iface] Prepare the channels for transfer -[ 201.154640] [I][mhi_netdev_enable_iface] Exited. -[ 201.159271] rmnet_vnd_register_device(rmnet_mhi0.1)=0 -[ 201.162953] rmnet_vnd_register_device(rmnet_mhi0.2)=0 -[ 201.167698] rmnet_vnd_register_device(rmnet_mhi0.3)=0 -[ 201.172178] rmnet_vnd_register_device(rmnet_mhi0.4)=0 - -root@OpenWrt:~# brctl addbr br0 -root@OpenWrt:~# brctl addif br0 eth1 -root@OpenWrt:~# brctl addif br0 rmnet_mhi0.2 -root@OpenWrt:~# brctl show -bridge name bridge id STP enabled interfaces -br0 8000.00001c353487 no eth1 - rmnet_mhi0.2 - -root@OpenWrt:~# quectel-qmi-proxy -d /dev/mhi_QMI0 & -[04-14_06:44:01:556] Will use cdc-wdm='/dev/mhi_QMI0', proxy='quectel-qmi-proxy0' -[04-14_06:44:01:573] qmi_proxy_init enter -[04-14_06:44:01:573] qmi_proxy_loop enter thread_id 0xb6f20d44 -[04-14_06:44:03:574] qmi_proxy_init succful -[04-14_06:44:03:574] local server: quectel-qmi-proxy0 sockfd = 4 -[04-14_06:44:03:575] qmi_proxy_server_fd = 4 - - -root@OpenWrt:~# quectel-CM -n 1 -s cmnet & -[04-14_06:47:53:303] Quectel_QConnectManager_Linux_V1.6.0.25 -[04-14_06:47:53:314] network interface '' or qmidev '' is not exist -[04-14_06:47:53:315] netcard driver = pcie_mhi, driver version = V1.3.0.17 -[04-14_06:47:53:316] qmap_mode = 4, qmap_version = 9, qmap_size = 16384, muxid = 0x81, qmap_netcard = rmnet_mhi0.1 -[04-14_06:47:53:316] Modem works in QMI mode -[04-14_06:47:53:318] connect to quectel-qmi-proxy0 sockfd = 7 -[04-14_06:47:53:318] cdc_wdm_fd = 7 -[04-14_06:47:53:326] Get clientWDS = 15 -[04-14_06:47:53:329] Get clientDMS = 2 -[04-14_06:47:53:334] Get clientNAS = 4 -[04-14_06:47:53:338] Get clientUIM = 1 -[04-14_06:47:53:343] Get clientWDA = 1 -[04-14_06:47:53:347] requestBaseBandVersion RM500QGLABR10A03M4G -[04-14_06:47:53:351] qmap_settings.rx_urb_size = 16384 -[04-14_06:47:53:352] qmap_settings.ul_data_aggregation_max_datagrams = 11 -[04-14_06:47:53:352] qmap_settings.ul_data_aggregation_max_size = 8192 -[04-14_06:47:53:352] qmap_settings.dl_minimum_padding = 0 -[04-14_06:47:53:369] requestGetSIMStatus SIMStatus: SIM_READY -[04-14_06:47:53:370] requestSetProfile[1] cmnet///0 -[04-14_06:47:53:402] requestGetProfile[1] cmnet///0 -[04-14_06:47:53:407] requestRegistrationState2 MCC: 0, MNC: 0, PS: Detached, DataCap: UNKNOW -[04-14_06:47:53:411] requestQueryDataCall IPv4ConnectionStatus: DISCONNECTED -[04-14_06:47:53:412] ifconfig rmnet_mhi0 down -[04-14_06:47:53:436] ifconfig rmnet_mhi0.1 0.0.0.0 -[04-14_06:47:53:460] ifconfig rmnet_mhi0.1 down -[04-14_06:48:26:399] requestRegistrationState2 MCC: 460, MNC: 0, PS: Detached, DataCap: UNKNOW -[04-14_06:48:26:405] requestRegistrationState2 MCC: 460, MNC: 0, PS: Detached, DataCap: UNKNOW -[04-14_06:48:26:411] requestRegistrationState2 MCC: 460, MNC: 0, PS: Detached, DataCap: UNKNOW -[04-14_06:48:26:970] requestRegistrationState2 MCC: 460, MNC: 0, PS: Attached, DataCap: 5G_NSA -[04-14_06:48:26:992] requestSetupDataCall WdsConnectionIPv4Handle: 0x34176710 -[04-14_06:48:27:005] ifconfig rmnet_mhi0 up -[04-14_06:48:27:031] ifconfig rmnet_mhi0.1 up -[04-14_06:48:27:057] you are use OpenWrt? -[04-14_06:48:27:057] should not calling udhcpc manually? -[04-14_06:48:27:080] should use "/sbin/ifstaus wan" to check rmnet_mhi0.1 's status? -[04-14_06:48:27:081] busybox udhcpc -f -n -q -t 5 -i rmnet_mhi0.1 -[04-14_06:48:27:363] udhcpc: ifconfig rmnet_mhi0.1 10.245.22.3 netmask 255.255.255.248 broadcast + -[04-14_06:48:27:398] udhcpc: setting default routers: 10.245.22.4 -[04-14_06:48:27:491] requestRegistrationState2 MCC: 460, MNC: 0, PS: Attached, DataCap: 5G_NSA - -root@OpenWrt:~# quectel-CM -n 2 -s 4gnet -b & -[04-14_06:48:06:842] Quectel_QConnectManager_Linux_V1.6.0.25 -[04-14_06:48:06:853] network interface '' or qmidev '' is not exist -[04-14_06:48:06:854] netcard driver = pcie_mhi, driver version = V1.3.0.17 -[04-14_06:48:06:855] qmap_mode = 4, qmap_version = 9, qmap_size = 16384, muxid = 0x82, qmap_netcard = rmnet_mhi0.2 -[04-14_06:48:06:855] Modem works in QMI mode -[04-14_06:48:06:857] connect to quectel-qmi-proxy0 sockfd = 7 -[04-14_06:48:06:858] cdc_wdm_fd = 7 -[04-14_06:48:06:864] Get clientWDS = 16 -[04-14_06:48:06:867] Get clientDMS = 3 -[04-14_06:48:06:871] Get clientNAS = 5 -[04-14_06:48:06:874] Get clientUIM = 2 -[04-14_06:48:06:879] Get clientWDA = 2 -[04-14_06:48:06:886] requestBaseBandVersion RM500QGLABR10A03M4G -[04-14_06:48:06:891] qmap_settings.rx_urb_size = 16384 -[04-14_06:48:06:891] qmap_settings.ul_data_aggregation_max_datagrams = 11 -[04-14_06:48:06:892] qmap_settings.ul_data_aggregation_max_size = 8192 -[04-14_06:48:06:892] qmap_settings.dl_minimum_padding = 0 -[04-14_06:48:06:909] requestGetSIMStatus SIMStatus: SIM_READY -[04-14_06:48:06:909] requestSetProfile[2] 4gnet///0 -[04-14_06:48:06:940] requestGetProfile[2] 4gnet///0 -[04-14_06:48:06:944] requestRegistrationState2 MCC: 0, MNC: 0, PS: Detached, DataCap: UNKNOW -[04-14_06:48:06:949] requestQueryDataCall IPv4ConnectionStatus: DISCONNECTED -[04-14_06:48:06:949] ifconfig rmnet_mhi0 down -[04-14_06:48:06:973] ifconfig rmnet_mhi0.2 0.0.0.0 -[04-14_06:48:06:998] ifconfig rmnet_mhi0.2 down -[04-14_06:48:26:400] requestRegistrationState2 MCC: 460, MNC: 0, PS: Detached, DataCap: UNKNOW -[04-14_06:48:26:405] requestRegistrationState2 MCC: 460, MNC: 0, PS: Detached, DataCap: UNKNOW -[04-14_06:48:26:411] requestRegistrationState2 MCC: 460, MNC: 0, PS: Detached, DataCap: UNKNOW -[04-14_06:48:26:970] requestRegistrationState2 MCC: 460, MNC: 0, PS: Attached, DataCap: 5G_NSA -[04-14_06:48:27:220] requestSetupDataCall WdsConnectionIPv4Handle: 0x341450a0 -[04-14_06:48:27:228] requestRegistrationState2 MCC: 460, MNC: 0, PS: Attached, DataCap: 5G_NSA -[04-14_06:48:27:238] ifconfig rmnet_mhi0 up -[04-14_06:48:27:263] ifconfig rmnet_mhi0.2 up -[04-14_06:48:27:313] echo '0xaf51be9' > /sys/class/net/rmnet_mhi0.2/bridge_ipv4 - -root@OpenWrt:~# ifconfig rmnet_mhi0.1 -rmnet_mhi0.1 Link encap:Ethernet HWaddr 02:50:F4:00:00:00 - inet addr:10.245.22.3 Mask:255.255.255.248 - inet6 addr: fe80::50:f4ff:fe00:0/64 Scope:Link - UP RUNNING NOARP MTU:1500 Metric:1 - RX packets:6 errors:0 dropped:0 overruns:0 frame:0 - TX packets:6 errors:0 dropped:0 overruns:0 carrier:0 - collisions:0 txqueuelen:1000 - RX bytes:1836 (1.7 KiB) TX bytes:2052 (2.0 KiB) - -root@OpenWrt:~# ifconfig rmnet_mhi0.2 -rmnet_mhi0.2 Link encap:Ethernet HWaddr 02:50:F4:00:00:00 - inet6 addr: fe80::50:f4ff:fe00:0/64 Scope:Link - UP RUNNING NOARP MTU:1500 Metric:1 - RX packets:347 errors:0 dropped:0 overruns:0 frame:0 - TX packets:795 errors:0 dropped:0 overruns:0 carrier:0 - collisions:0 txqueuelen:1000 - RX bytes:119871 (117.0 KiB) TX bytes:121254 (118.4 KiB) - -root@OpenWrt:~# ifconfig br0 up -[ 520.005476] rmnet_mhi0.2 PC Mac Address: 00:0e:c6:a6:6c:f1 -[ 520.025896] rmnet_mhi0.2 PC Mac Address: 00:0e:c6:a6:6c:f1 -[ 520.028002] rmnet_mhi0.2 PC Mac Address: 00:0e:c6:a6:6c:f1 -[ 520.144371] rmnet_mhi0.2 sip = 10.245.27.233, tip=10.245.27.234, ipv4=10.245.27.233 -[ 520.410052] rmnet_mhi0.2 sip = 0.0.0.0, tip=10.245.27.233, ipv4=10.245.27.233 -[ 520.414504] rmnet_mhi0.2 sip = 10.245.27.233, tip=10.245.27.234, ipv4=10.245.27.233 -[ 520.847074] rmnet_mhi0.2 sip = 10.245.27.233, tip=10.245.27.234, ipv4=10.245.27.233 -[ 521.410241] rmnet_mhi0.2 sip = 0.0.0.0, tip=10.245.27.233, ipv4=10.245.27.233 -[ 522.410455] rmnet_mhi0.2 sip = 0.0.0.0, tip=10.245.27.233, ipv4=10.245.27.233 -[ 522.822594] rmnet_mhi0.2 sip = 10.245.27.233, tip=10.245.27.234, ipv4=10.245.27.233 -[ 523.410638] rmnet_mhi0.2 sip = 10.245.27.233, tip=10.245.27.233, ipv4=10.245.27.233 -[ 523.510028] rmnet_mhi0.2 sip = 10.245.27.233, tip=10.245.27.234, ipv4=10.245.27.233 -[ 523.997961] rmnet_mhi0.2 sip = 10.245.27.233, tip=10.245.27.234, ipv4=10.245.27.233 -[ 543.799483] rmnet_mhi0.2 sip = 10.245.27.233, tip=10.245.27.234, ipv4=10.245.27.233 -[ 543.929301] rmnet_mhi0.2 sip = 10.245.27.233, tip=10.245.27.234, ipv4=10.245.27.233 - diff --git a/quectel_cm_5G/src/log/qmi_wwan_q.txt b/quectel_cm_5G/src/log/qmi_wwan_q.txt deleted file mode 100644 index 161dbbd..0000000 --- a/quectel_cm_5G/src/log/qmi_wwan_q.txt +++ /dev/null @@ -1,65 +0,0 @@ -root@ZhuoTK:/# dmesg -[ 15.840000] qmi_wwan_q 1-1.3:1.4: cdc-wdm0: USB WDM device -[ 15.860000] qmi_wwan_q 1-1.3:1.4: Quectel Android work on RawIP mode -[ 15.860000] qmi_wwan_q 1-1.3:1.4: rx_urb_size = 1520 -[ 15.870000] qmi_wwan_q 1-1.3:1.4 wwan0: register 'qmi_wwan_q' at usb-101c0000.ehci-1.3, WWAN/QMI device, da:0b:ce:b2:db:21 - -root@ZhuoTK:/# quectel-CM -s cment & -[04-13_03:20:20:456] Quectel_QConnectManager_Linux_V1.6.0.25 -[04-13_03:20:20:459] Find /sys/bus/usb/devices/1-1.3 idVendor=0x2c7c idProduct=0x125, bus=0x001, dev=0x003 -[04-13_03:20:20:460] Auto find qmichannel = /dev/cdc-wdm0 -[04-13_03:20:20:460] Auto find usbnet_adapter = wwan0 -[04-13_03:20:20:461] netcard driver = qmi_wwan_q, driver version = V1.2.0.23 -[04-13_03:20:20:461] Modem works in QMI mode -[04-13_03:20:20:469] cdc_wdm_fd = 7 -[04-13_03:20:20:547] Get clientWDS = 4 -[04-13_03:20:20:579] Get clientDMS = 1 -[04-13_03:20:20:611] Get clientNAS = 4 -[04-13_03:20:20:643] Get clientUIM = 1 -[04-13_03:20:20:675] Get clientWDA = 1 -[04-13_03:20:20:707] requestBaseBandVersion EC25EFAR06A11M4G -[04-13_03:20:20:836] requestGetSIMStatus SIMStatus: SIM_READY -[04-13_03:20:20:836] requestSetProfile[1] cment///0 -[04-13_03:20:20:899] requestGetProfile[1] cment///0 -[04-13_03:20:20:931] requestRegistrationState2 MCC: 460, MNC: 0, PS: Attached, DataCap: LTE -[04-13_03:20:20:963] requestQueryDataCall IPv4ConnectionStatus: DISCONNECTED -[04-13_03:20:20:963] ifconfig wwan0 0.0.0.0 -[04-13_03:20:20:976] ifconfig wwan0 down -[04-13_03:20:21:186] requestSetupDataCall WdsConnectionIPv4Handle: 0x8723e780 -[04-13_03:20:21:316] ifconfig wwan0 up -[04-13_03:20:21:329] you are use OpenWrt? -[04-13_03:20:21:330] should not calling udhcpc manually? -[04-13_03:20:21:330] should modify /etc/config/network as below? -[04-13_03:20:21:330] config interface wan -[04-13_03:20:21:330] option ifname wwan0 -[04-13_03:20:21:330] option proto dhcp -[04-13_03:20:21:330] should use "/sbin/ifstaus wan" to check wwan0 's status? -[04-13_03:20:21:331] busybox udhcpc -f -n -q -t 5 -i wwan0 -[04-13_03:20:21:341] udhcpc (v1.23.2) started -[04-13_03:20:21:353] Sending discover... -[04-13_03:20:21:362] Sending select for 10.90.1.113... -[04-13_03:20:21:365] Lease of 10.90.1.113 obtained, lease time 7200 -[04-13_03:20:21:370] udhcpc: ifconfig wwan0 10.90.1.113 netmask 255.255.255.252 broadcast + -[04-13_03:20:21:380] udhcpc: setting default routers: 10.90.1.114 - -root@ZhuoTK:/# ifconfig wwan0 -wwan0 Link encap:Ethernet HWaddr 00:CA:01:91:97:BA - inet addr:10.90.1.113 Mask:255.255.255.252 - inet6 addr: fe80::2ca:1ff:fe91:97ba/64 Scope:Link - UP RUNNING NOARP MTU:1500 Metric:1 - RX packets:38 errors:0 dropped:0 overruns:0 frame:0 - TX packets:46 errors:0 dropped:0 overruns:0 carrier:0 - collisions:0 txqueuelen:1000 - RX bytes:5244 (5.1 KiB) TX bytes:6964 (6.8 KiB) - -root@ZhuoTK:/# ip ro show -default via 10.90.1.114 dev wwan0 -10.90.1.112/30 dev wwan0 proto kernel scope link src 10.90.1.113 -192.168.1.0/24 dev br-lan proto kernel scope link src 192.168.1.251 - -root@ZhuoTK:/# killall quectel-CM -[04-13_03:20:46:130] requestDeactivateDefaultPDP WdsConnectionIPv4Handle -[04-13_03:20:46:406] ifconfig wwan0 0.0.0.0 -[04-13_03:20:46:418] ifconfig wwan0 down -[04-13_03:20:46:600] QmiWwanThread exit -[04-13_03:20:46:600] qmi_main exit diff --git a/quectel_cm_5G/src/log/qmi_wwan_q_bridge.txt b/quectel_cm_5G/src/log/qmi_wwan_q_bridge.txt deleted file mode 100644 index b979af9..0000000 --- a/quectel_cm_5G/src/log/qmi_wwan_q_bridge.txt +++ /dev/null @@ -1,57 +0,0 @@ -root@ZhuoTK:/# insmod qmi_wwan_q.ko -[ 116.910000] qmi_wwan_q 1-1.3:1.4: cdc-wdm0: USB WDM device -[ 116.930000] qmi_wwan_q 1-1.3:1.4: Quectel Android work on RawIP mode -[ 116.930000] qmi_wwan_q 1-1.3:1.4: rx_urb_size = 1520 -[ 116.940000] qmi_wwan_q 1-1.3:1.4 wwan0: register 'qmi_wwan_q' at usb-101c0000.ehci-1.3, WWAN/QMI device, 06:fb:51:a3:d6:c5 -[ 116.950000] usbcore: registered new interface driver qmi_wwan_q - -root@ZhuoTK:/# brctl addbr br0 -root@ZhuoTK:/# brctl addif br0 eth0.1 -root@ZhuoTK:/# brctl addif br0 wwan0 -root@ZhuoTK:/# brctl show -bridge name bridge id STP enabled interfaces -br0 8000.00ca019197b9 no eth0.1 - wwan0 - -root@ZhuoTK:/# quectel-CM -s cmnet -b & -root@ZhuoTK:/# [04-13_05:13:39:369] Quectel_QConnectManager_Linux_V1.6.0.25 -[04-13_05:13:39:372] Find /sys/bus/usb/devices/1-1.3 idVendor=0x2c7c idProduct=0x125, bus=0x001, dev=0x003 -[ 143.340000] net wwan0: bridge_mode change to 0x1 -[04-13_05:13:39:373] Auto find qmichannel = /dev/cdc-wdm0 -[04-13_05:13:39:374] Auto find usbnet_adapter = wwan0 -[04-13_05:13:39:374] netcard driver = qmi_wwan_q, driver version = V1.2.0.23 -[04-13_05:13:39:380] Modem works in QMI mode -[04-13_05:13:39:388] cdc_wdm_fd = 7 -[04-13_05:13:39:466] Get clientWDS = 5 -[04-13_05:13:39:496] Get clientDMS = 2 -[04-13_05:13:39:527] Get clientNAS = 4 -[04-13_05:13:39:559] Get clientUIM = 1 -[04-13_05:13:39:592] Get clientWDA = 1 -[04-13_05:13:39:626] requestBaseBandVersion EC25EFAR06A11M4G -[04-13_05:13:39:752] requestGetSIMStatus SIMStatus: SIM_READY -[04-13_05:13:39:752] requestSetProfile[1] cmnet///0 -[04-13_05:13:39:816] requestGetProfile[1] cmnet///0 -[04-13_05:13:39:848] requestRegistrationState2 MCC: 460, MNC: 0, PS: Attached, DataCap: LTE -[04-13_05:13:39:879] requestQueryDataCall IPv4ConnectionStatus: DISCONNECTED -[04-13_05:13:39:880] ifconfig wwan0 0.0.0.0 -[04-13_05:13:39:893] ifconfig wwan0 down -[04-13_05:13:39:943] requestSetupDataCall WdsConnectionIPv4Handle: 0x872627c0 -[04-13_05:13:40:073] ifconfig wwan0 up -[04-13_05:13:40:085] echo '0xa8d9237' > /sys/class/net/wwan0/bridge_ipv4 - -root@ZhuoTK:/# ifconfig br0 up -[ 165.730000] wwan0 PC Mac Address: 00:0e:c6:a6:6c:f1 -[ 165.750000] wwan0 PC Mac Address: 00:0e:c6:a6:6c:f1 -[ 165.860000] wwan0 sip = 10.141.146.55, tip=10.141.146.56, ipv4=10.141.146.55 -[ 165.870000] wwan0 sip = 10.141.146.55, tip=10.141.146.56, ipv4=10.141.146.55 -[ 165.990000] wwan0 sip = 10.141.146.55, tip=10.141.146.56, ipv4=10.141.146.55 -[ 166.010000] wwan0 sip = 0.0.0.0, tip=10.141.146.55, ipv4=10.141.146.55 -[ 166.070000] wwan0 sip = 10.141.146.55, tip=10.141.146.56, ipv4=10.141.146.55 -[ 167.010000] wwan0 sip = 0.0.0.0, tip=10.141.146.55, ipv4=10.141.146.55 -[ 167.480000] br0: port 2(wwan0) entered forwarding state -[ 167.520000] br0: port 1(eth0.1) entered forwarding state -[ 168.020000] wwan0 sip = 0.0.0.0, tip=10.141.146.55, ipv4=10.141.146.55 -[ 169.010000] wwan0 sip = 10.141.146.55, tip=10.141.146.55, ipv4=10.141.146.55 -[ 169.120000] wwan0 sip = 10.141.146.55, tip=10.141.146.56, ipv4=10.141.146.55 -[ 169.130000] wwan0 sip = 10.141.146.55, tip=10.141.146.56, ipv4=10.141.146.55 -[ 176.620000] wwan0 sip = 10.141.146.55, tip=10.141.146.56, ipv4=10.141.146.55 diff --git a/quectel_cm_5G/src/log/qmi_wwan_q_qmap=1.txt b/quectel_cm_5G/src/log/qmi_wwan_q_qmap=1.txt deleted file mode 100644 index 9f088e5..0000000 --- a/quectel_cm_5G/src/log/qmi_wwan_q_qmap=1.txt +++ /dev/null @@ -1,54 +0,0 @@ -root@ZhuoTK:/# insmod qmi_wwan_q.ko qmap_mode=1 -[ 1367.200000] usbcore: registered new interface driver qmi_wwan_q -[ 1383.840000] usb 1-1.3: new high-speed USB device number 7 using ehci-platform -[ 1384.080000] qmi_wwan_q 1-1.3:1.4: cdc-wdm0: USB WDM device -[ 1384.080000] qmi_wwan_q 1-1.3:1.4: Quectel Android work on RawIP mode -[ 1384.100000] qmi_wwan_q 1-1.3:1.4: rx_urb_size = 4096 -[ 1384.100000] qmi_wwan_q 1-1.3:1.4 wwan0: register 'qmi_wwan_q' at usb-101c0000.ehci-1.3, WWAN/QMI device, da:0b:ce:b2:db:21 - -root@ZhuoTK:/# quectel-CM -s cmnet & -[04-13_03:41:28:144] Quectel_QConnectManager_Linux_V1.6.0.25 -[04-13_03:41:28:146] Find /sys/bus/usb/devices/1-1.3 idVendor=0x2c7c idProduct=0x125, bus=0x001, dev=0x007 -[04-13_03:41:28:148] Auto find qmichannel = /dev/cdc-wdm0 -[04-13_03:41:28:148] Auto find usbnet_adapter = wwan0 -[04-13_03:41:28:148] netcard driver = qmi_wwan_q, driver version = V1.2.0.23 -[04-13_03:41:28:149] qmap_mode = 1, qmap_version = 5, qmap_size = 4096, muxid = 0x81, qmap_netcard = wwan0 -[04-13_03:41:28:150] Modem works in QMI mode -[04-13_03:41:28:158] cdc_wdm_fd = 7 -[04-13_03:41:28:238] Get clientWDS = 4 -[04-13_03:41:28:271] Get clientDMS = 1 -[04-13_03:41:28:302] Get clientNAS = 4 -[04-13_03:41:28:334] Get clientUIM = 1 -[04-13_03:41:28:365] Get clientWDA = 1 -[04-13_03:41:28:397] requestBaseBandVersion EC25EFAR06A11M4G -[04-13_03:41:28:430] qmap_settings.rx_urb_size = 4096 -[ 1393.530000] net wwan0: ul_data_aggregation_max_datagrams=11, ul_data_aggregation_max_size=4096, dl_minimum_padding=0 -[04-13_03:41:28:431] qmap_settings.ul_data_aggregation_max_datagrams = 11 -[04-13_03:41:28:431] qmap_settings.ul_data_aggregation_max_size = 4096 -[04-13_03:41:28:431] qmap_settings.dl_minimum_padding = 0 -[04-13_03:41:28:557] requestGetSIMStatus SIMStatus: SIM_READY -[04-13_03:41:28:558] requestSetProfile[1] cmnet///0 -[04-13_03:41:28:622] requestGetProfile[1] cmnet///0 -[04-13_03:41:28:654] requestRegistrationState2 MCC: 460, MNC: 0, PS: Attached, DataCap: LTE -[04-13_03:41:28:685] requestQueryDataCall IPv4ConnectionStatus: DISCONNECTED -[ 1393.790000] net wwan0: link_state 0x1 -> 0x0 -[04-13_03:41:28:692] ifconfig wwan0 0.0.0.0 -[04-13_03:41:28:703] ifconfig wwan0 down -[04-13_03:41:28:751] requestSetupDataCall WdsConnectionIPv4Handle: 0x8729a6b0 -[ 1393.980000] net wwan0: link_state 0x0 -> 0x1 -[04-13_03:41:28:882] ifconfig wwan0 up -[04-13_03:41:28:895] you are use OpenWrt? -[04-13_03:41:28:895] should not calling udhcpc manually? -[04-13_03:41:28:895] should modify /etc/config/network as below? -[04-13_03:41:28:896] config interface wan -[04-13_03:41:28:896] option ifname wwan0 -[04-13_03:41:28:896] option proto dhcp -[04-13_03:41:28:896] should use "/sbin/ifstaus wan" to check wwan0 's status? -[04-13_03:41:28:896] busybox udhcpc -f -n -q -t 5 -i wwan0 -[04-13_03:41:28:907] udhcpc (v1.23.2) started -[04-13_03:41:28:919] Sending discover... -[04-13_03:41:28:925] Sending select for 10.129.198.20... -[04-13_03:41:28:929] Lease of 10.129.198.20 obtained, lease time 7200 -[04-13_03:41:28:934] udhcpc: ifconfig wwan0 10.129.198.20 netmask 255.255.255.248 broadcast + -[04-13_03:41:28:949] udhcpc: setting default routers: 10.129.198.21 - diff --git a/quectel_cm_5G/src/log/qmi_wwan_q_qmap=1_bridge.txt b/quectel_cm_5G/src/log/qmi_wwan_q_qmap=1_bridge.txt deleted file mode 100644 index 05919d6..0000000 --- a/quectel_cm_5G/src/log/qmi_wwan_q_qmap=1_bridge.txt +++ /dev/null @@ -1,86 +0,0 @@ -root@ZhuoTK:/# insmod qmi_wwan_q.ko qmap_mode=1 -[ 49.000000] qmi_wwan_q 1-1.3:1.4: cdc-wdm0: USB WDM device -[ 49.000000] qmi_wwan_q 1-1.3:1.4: Quectel Android work on RawIP mode -[ 49.020000] qmi_wwan_q 1-1.3:1.4: rx_urb_size = 4096 -[ 49.020000] qmi_wwan_q 1-1.3:1.4 wwan0: register 'qmi_wwan_q' at usb-101c0000.ehci-1.3, WWAN/QMI device, de:ae:5c:82:b5:b2 -[ 49.030000] usbcore: registered new interface driver qmi_wwan_q - -root@ZhuoTK:/# brctl addbr br0 -root@ZhuoTK:/# brctl addif br0 eth0.1 -root@ZhuoTK:/# brctl addif br0 wwan0 -root@ZhuoTK:/# brctl show -bridge name bridge id STP enabled interfaces -br0 8000.00ca019197b9 no eth0.1 - wwan0 - -root@ZhuoTK:/# quectel-CM -s cmnet -b & -[04-13_05:11:46:442] Quectel_QConnectManager_Linux_V1.6.0.25 -[04-13_05:11:46:444] Find /sys/bus/usb/devices/1-1.3 idVendor=0x2c7c idProduct=0x125, bus=0x001, dev=0x003 -[ 84.340000] net wwan0: bridge_mode change to 0x1 -[04-13_05:11:46:446] Auto find qmichannel = /dev/cdc-wdm0 -[04-13_05:11:46:446] Auto find usbnet_adapter = wwan0 -[04-13_05:11:46:446] netcard driver = qmi_wwan_q, driver version = V1.2.0.23 -[04-13_05:11:46:447] qmap_mode = 1, qmap_version = 5, qmap_size = 4096, muxid = 0x81, qmap_netcard = wwan0 -[04-13_05:11:46:454] Modem works in QMI mode -[04-13_05:11:46:462] cdc_wdm_fd = 7 -[04-13_05:11:46:537] Get clientWDS = 5 -[04-13_05:11:46:569] Get clientDMS = 1 -[04-13_05:11:46:601] Get clientNAS = 4 -[04-13_05:11:46:633] Get clientUIM = 1 -[04-13_05:11:46:666] Get clientWDA = 1 -[04-13_05:11:46:697] requestBaseBandVersion EC25EFAR06A11M4G -[04-13_05:11:46:730] qmap_settings.rx_urb_size = 4096 -[ 84.620000] net wwan0: ul_data_aggregation_max_datagrams=11, ul_data_aggregation_max_size=4096, dl_minimum_padding=0 -[04-13_05:11:46:730] qmap_settings.ul_data_aggregation_max_datagrams = 11 -[04-13_05:11:46:730] qmap_settings.ul_data_aggregation_max_size = 4096 -[04-13_05:11:46:730] qmap_settings.dl_minimum_padding = 0 -[04-13_05:11:46:859] requestGetSIMStatus SIMStatus: SIM_READY -[04-13_05:11:46:859] requestSetProfile[1] cmnet///0 -[04-13_05:11:46:922] requestGetProfile[1] cmnet///0 -[04-13_05:11:46:954] requestRegistrationState2 MCC: 460, MNC: 0, PS: Attached, DataCap: LTE -[04-13_05:11:46:986] requestQueryDataCall IPv4ConnectionStatus: DISCONNECTED -[ 84.880000] net wwan0: link_state 0x1 -> 0x0 -[04-13_05:11:46:992] ifconfig wwan0 0.0.0.0 -[04-13_05:11:47:005] ifconfig wwan0 down -[04-13_05:11:47:050] requestSetupDataCall WdsConnectionIPv4Handle: 0x872a5830 -[ 85.070000] net wwan0: link_state 0x0 -> 0x1 -[04-13_05:11:47:183] ifconfig wwan0 up -[04-13_05:11:47:195] echo '0xa54a78b' > /sys/class/net/wwan0/bridge_ipv4 - -root@ZhuoTK:/# ifconfig wwan0 -wwan0 Link encap:Ethernet HWaddr DE:AE:5C:82:B5:B2 - inet6 addr: fe80::dcae:5cff:fe82:b5b2/64 Scope:Link - UP RUNNING NOARP MTU:1500 Metric:1 - RX packets:3792 errors:0 dropped:0 overruns:0 frame:0 - TX packets:3271 errors:0 dropped:36 overruns:0 carrier:0 - collisions:0 txqueuelen:1000 - RX bytes:2271762 (2.1 MiB) TX bytes:565184 (551.9 KiB) - -root@ZhuoTK:/# ifconfig br0 up -[ 89.530000] br0: port 2(wwan0) entered forwarding state -[ 89.530000] br0: port 2(wwan0) entered forwarding state -[ 89.540000] br0: port 1(eth0.1) entered forwarding state -[ 89.540000] br0: port 1(eth0.1) entered forwarding state - -root@ZhuoTK:/# -[ 93.720000] wwan0 sip = 192.168.1.153, tip=10.84.167.140, ipv4=10.84.167.139 -[ 104.560000] br0: port 2(wwan0) entered forwarding state -[ 104.560000] br0: port 1(eth0.1) entered forwarding state -[ 111.750000] rt305x-esw 10110000.esw: link changed 0x00 -[ 116.440000] rt305x-esw 10110000.esw: link changed 0x01 -[ 116.620000] wwan0 PC Mac Address: 00:0e:c6:a6:6c:f1 -[ 116.680000] wwan0 PC Mac Address: 00:0e:c6:a6:6c:f1 -[ 116.690000] wwan0 PC Mac Address: 00:0e:c6:a6:6c:f1 -[ 116.760000] wwan0 sip = 10.84.167.139, tip=10.84.167.140, ipv4=10.84.167.139 -[ 117.050000] wwan0 sip = 10.84.167.139, tip=10.84.167.140, ipv4=10.84.167.139 -[ 117.220000] wwan0 sip = 0.0.0.0, tip=10.84.167.139, ipv4=10.84.167.139 -[ 117.820000] wwan0 sip = 10.84.167.139, tip=10.84.167.140, ipv4=10.84.167.139 -[ 118.220000] wwan0 sip = 0.0.0.0, tip=10.84.167.139, ipv4=10.84.167.139 -[ 118.300000] wwan0 sip = 10.84.167.139, tip=10.84.167.140, ipv4=10.84.167.139 -[ 119.220000] wwan0 sip = 0.0.0.0, tip=10.84.167.139, ipv4=10.84.167.139 -[ 120.220000] wwan0 sip = 10.84.167.139, tip=10.84.167.139, ipv4=10.84.167.139 -[ 120.300000] wwan0 sip = 10.84.167.139, tip=10.84.167.140, ipv4=10.84.167.139 -[ 121.430000] wwan0 sip = 10.84.167.139, tip=10.84.167.140, ipv4=10.84.167.139 -[ 141.730000] wwan0 sip = 10.84.167.139, tip=10.84.167.140, ipv4=10.84.167.139 -[ 144.390000] wwan0 sip = 10.84.167.139, tip=10.84.167.140, ipv4=10.84.167.139 -[ 144.510000] wwan0 sip = 10.84.167.139, tip=10.84.167.140, ipv4=10.84.167.139 diff --git a/quectel_cm_5G/src/log/qmi_wwan_q_qmap=4.txt b/quectel_cm_5G/src/log/qmi_wwan_q_qmap=4.txt deleted file mode 100644 index 6464f27..0000000 --- a/quectel_cm_5G/src/log/qmi_wwan_q_qmap=4.txt +++ /dev/null @@ -1,185 +0,0 @@ -root@ZhuoTK:/# insmod qmi_wwan_q.ko qmap_mode=4 -[ 1515.180000] usbcore: registered new interface driver qmi_wwan_q -[ 1530.260000] usb 1-1.3: new high-speed USB device number 8 using ehci-platform -[ 1530.500000] qmi_wwan_q 1-1.3:1.4: cdc-wdm0: USB WDM device -[ 1530.500000] qmi_wwan_q 1-1.3:1.4: Quectel Android work on RawIP mode -[ 1530.520000] qmi_wwan_q 1-1.3:1.4: rx_urb_size = 4096 -[ 1530.520000] qmi_wwan_q 1-1.3:1.4 wwan0: register 'qmi_wwan_q' at usb-101c0000.ehci-1.3, RMNET/USB device, da:0b:ce:b2:db:21 -[ 1530.530000] net wwan0: qmap_register_device wwan0_1 -[ 1530.540000] net wwan0: qmap_register_device wwan0_2 -[ 1530.550000] net wwan0: qmap_register_device wwan0_3 -[ 1530.550000] net wwan0: qmap_register_device wwan0_4 - -root@ZhuoTK:~# quectel-qmi-proxy & -[04-13_03:44:53:958] Will use cdc-wdm='/dev/cdc-wdm0', proxy='quectel-qmi-proxy0' -[04-13_03:44:53:959] qmi_proxy_init enter -[04-13_03:44:53:960] qmi_proxy_loop enter thread_id 0x77c07530 -[04-13_03:44:54:960] qmi_proxy_init succful -[04-13_03:44:54:960] local server: quectel-qmi-proxy0 sockfd = 4 -[04-13_03:44:54:960] qmi_proxy_server_fd = 4 -[04-13_03:45:04:346] +++ ClientFd=5 -[04-13_03:45:04:410] +++ ClientFd=5 QMIType=1 ClientId=4 -[04-13_03:45:04:442] +++ ClientFd=5 QMIType=2 ClientId=1 -[04-13_03:45:04:474] +++ ClientFd=5 QMIType=3 ClientId=4 -[04-13_03:45:04:506] +++ ClientFd=5 QMIType=11 ClientId=1 -[04-13_03:45:04:539] +++ ClientFd=5 QMIType=26 ClientId=1 -[04-13_03:45:10:770] +++ ClientFd=6 -[04-13_03:45:10:811] +++ ClientFd=6 QMIType=1 ClientId=21 -[04-13_03:45:10:843] +++ ClientFd=6 QMIType=2 ClientId=2 -[04-13_03:45:10:875] +++ ClientFd=6 QMIType=3 ClientId=5 -[04-13_03:45:10:907] +++ ClientFd=6 QMIType=11 ClientId=2 -[04-13_03:46:31:419] --- ClientFd=6 QMIType=1 ClientId=21 -[04-13_03:46:31:451] --- ClientFd=6 QMIType=2 ClientId=2 -[04-13_03:46:31:484] --- ClientFd=6 QMIType=3 ClientId=5 -[04-13_03:46:31:517] --- ClientFd=6 QMIType=11 ClientId=2 -[04-13_03:46:31:518] qmi_proxy_loop poll fd = 6, revents = 0011 -[04-13_03:46:31:519] --- ClientFd=6 - -root@ZhuoTK:/# quectel-CM -n 1 -s cmnet & -root@ZhuoTK:/# [04-13_03:45:04:340] Quectel_QConnectManager_Linux_V1.6.0.25 -[04-13_03:45:04:343] Find /sys/bus/usb/devices/1-1.3 idVendor=0x2c7c idProduct=0x125, bus=0x001, dev=0x008 -[04-13_03:45:04:344] Auto find qmichannel = /dev/cdc-wdm0 -[04-13_03:45:04:344] Auto find usbnet_adapter = wwan0 -[04-13_03:45:04:345] netcard driver = qmi_wwan_q, driver version = V1.2.0.23 -[04-13_03:45:04:345] qmap_mode = 4, qmap_version = 5, qmap_size = 4096, muxid = 0x81, qmap_netcard = wwan0_1 -[04-13_03:45:04:345] Modem works in QMI mode -[04-13_03:45:04:347] connect to quectel-qmi-proxy0 sockfd = 7 -[04-13_03:45:04:347] cdc_wdm_fd = 7 -[04-13_03:45:04:411] Get clientWDS = 4 -[04-13_03:45:04:443] Get clientDMS = 1 -[04-13_03:45:04:475] Get clientNAS = 4 -[04-13_03:45:04:507] Get clientUIM = 1 -[04-13_03:45:04:540] Get clientWDA = 1 -[04-13_03:45:04:571] requestBaseBandVersion EC25EFAR06A11M4G -[04-13_03:45:04:602] qmap_settings.rx_urb_size = 4096 -[ 1609.700000] net wwan0: ul_data_aggregation_max_datagrams=11, ul_data_aggregation_max_size=4096, dl_minimum_padding=0 -[04-13_03:45:04:603] qmap_settings.ul_data_aggregation_max_datagrams = 11 -[04-13_03:45:04:603] qmap_settings.ul_data_aggregation_max_size = 4096 -[04-13_03:45:04:603] qmap_settings.dl_minimum_padding = 0 -[04-13_03:45:04:731] requestGetSIMStatus SIMStatus: SIM_READY -[04-13_03:45:04:731] requestSetProfile[1] cmnet///0 -[04-13_03:45:04:795] requestGetProfile[1] cmnet///0 -[04-13_03:45:04:827] requestRegistrationState2 MCC: 460, MNC: 0, PS: Attached, DataCap: LTE -[04-13_03:45:04:858] requestQueryDataCall IPv4ConnectionStatus: DISCONNECTED -[ 1609.960000] net wwan0: link_state 0x1 -> 0x0 -[04-13_03:45:04:865] ifconfig wwan0 down -[04-13_03:45:04:879] ifconfig wwan0_1 0.0.0.0 -[04-13_03:45:04:889] ifconfig wwan0_1 down -[04-13_03:45:04:955] requestSetupDataCall WdsConnectionIPv4Handle: 0x87253410 -[ 1610.180000] net wwan0: link_state 0x0 -> 0x1 -[04-13_03:45:05:087] ifconfig wwan0 up -[ 1610.200000] IPv6: ADDRCONF(NETDEV_UP): wwan0: link is not ready -[04-13_03:45:05:105] ifconfig wwan0_1 up -[ 1610.220000] IPv6: ADDRCONF(NETDEV_CHANGE): wwan0: link becomes ready -[04-13_03:45:05:125] you are use OpenWrt? -[04-13_03:45:05:125] should not calling udhcpc manually? -[04-13_03:45:05:125] should modify /etc/config/network as below? -[04-13_03:45:05:125] config interface wan -[04-13_03:45:05:125] option ifname wwan0_1 -[04-13_03:45:05:125] option proto dhcp -[04-13_03:45:05:126] should use "/sbin/ifstaus wan" to check wwan0_1 's status? -[04-13_03:45:05:126] busybox udhcpc -f -n -q -t 5 -i wwan0_1 -[04-13_03:45:05:136] udhcpc (v1.23.2) started -[04-13_03:45:05:148] Sending discover... -[04-13_03:45:05:155] Sending select for 10.244.10.206... -[04-13_03:45:05:160] Lease of 10.244.10.206 obtained, lease time 7200 -[04-13_03:45:05:165] udhcpc: ifconfig wwan0_1 10.244.10.206 netmask 255.255.255.252 broadcast + -[04-13_03:45:05:174] udhcpc: setting default routers: 10.244.10.205 - -root@ZhuoTK:/# quectel-CM -n 2 -s 4gnet & -[04-13_03:45:10:764] Quectel_QConnectManager_Linux_V1.6.0.25 -[04-13_03:45:10:767] Find /sys/bus/usb/devices/1-1.3 idVendor=0x2c7c idProduct=0x125, bus=0x001, dev=0x008 -[04-13_03:45:10:768] Auto find qmichannel = /dev/cdc-wdm0 -[04-13_03:45:10:768] Auto find usbnet_adapter = wwan0 -[04-13_03:45:10:768] netcard driver = qmi_wwan_q, driver version = V1.2.0.23 -[04-13_03:45:10:769] qmap_mode = 4, qmap_version = 5, qmap_size = 4096, muxid = 0x82, qmap_netcard = wwan0_2 -[04-13_03:45:10:769] Modem works in QMI mode -[04-13_03:45:10:771] connect to quectel-qmi-proxy0 sockfd = 7 -[04-13_03:45:10:771] cdc_wdm_fd = 7 -[04-13_03:45:10:812] Get clientWDS = 21 -[04-13_03:45:10:844] Get clientDMS = 2 -[04-13_03:45:10:876] Get clientNAS = 5 -[04-13_03:45:10:908] Get clientUIM = 2 -[04-13_03:45:10:971] requestBaseBandVersion EC25EFAR06A11M4G -[04-13_03:45:11:099] requestGetSIMStatus SIMStatus: SIM_READY -[04-13_03:45:11:099] requestSetProfile[2] 4gnet///0 -[04-13_03:45:11:163] requestGetProfile[2] 4gnet///0 -[04-13_03:45:11:195] requestRegistrationState2 MCC: 460, MNC: 0, PS: Attached, DataCap: LTE -[04-13_03:45:11:227] requestQueryDataCall IPv4ConnectionStatus: DISCONNECTED -[04-13_03:45:11:227] ifconfig wwan0_2 0.0.0.0 -[ 1616.340000] IPv6: ADDRCONF(NETDEV_UP): wwan0_2: link is not ready -[04-13_03:45:11:246] ifconfig wwan0_2 down -[04-13_03:45:11:642] requestSetupDataCall WdsConnectionIPv4Handle: 0x87254580 -[ 1616.870000] net wwan0: link_state 0x1 -> 0x3 -[04-13_03:45:11:775] ifconfig wwan0 up -[04-13_03:45:11:785] ifconfig wwan0_2 up -[04-13_03:45:11:798] you are use OpenWrt? -[04-13_03:45:11:798] should not calling udhcpc manually? -[04-13_03:45:11:798] should modify /etc/config/network as below? -[04-13_03:45:11:798] config interface wan -[04-13_03:45:11:798] option ifname wwan0_2 -[04-13_03:45:11:798] option proto dhcp -[04-13_03:45:11:798] should use "/sbin/ifstaus wan" to check wwan0_2 's status? -[04-13_03:45:11:799] busybox udhcpc -f -n -q -t 5 -i wwan0_2 -[04-13_03:45:11:809] udhcpc (v1.23.2) started -[04-13_03:45:11:821] Sending discover... -[04-13_03:45:11:830] Sending select for 10.245.78.212... -[04-13_03:45:11:836] Lease of 10.245.78.212 obtained, lease time 7200 -[04-13_03:45:11:842] udhcpc: ifconfig wwan0_2 10.245.78.212 netmask 255.255.255.248 broadcast + -[04-13_03:45:11:852] udhcpc: setting default routers: 10.245.78.213 - -root@ZhuoTK:/# ifconfig wwan0_1 -wwan0_1 Link encap:Ethernet HWaddr DA:0B:CE:B2:DB:21 - inet addr:10.244.10.206 Mask:255.255.255.252 - inet6 addr: fe80::d80b:ceff:feb2:db21/64 Scope:Link - UP RUNNING NOARP MTU:1500 Metric:1 - RX packets:2 errors:0 dropped:0 overruns:0 frame:0 - TX packets:4 errors:0 dropped:0 overruns:0 carrier:0 - collisions:0 txqueuelen:1000 - RX bytes:640 (640.0 B) TX bytes:1344 (1.3 KiB) - -root@ZhuoTK:/# ifconfig wwan0_2 -wwan0_2 Link encap:Ethernet HWaddr DA:0B:CE:B2:DB:21 - inet addr:10.245.78.212 Mask:255.255.255.248 - inet6 addr: fe80::d80b:ceff:feb2:db21/64 Scope:Link - UP RUNNING NOARP MTU:1500 Metric:1 - RX packets:8 errors:0 dropped:0 overruns:0 frame:0 - TX packets:7 errors:0 dropped:0 overruns:0 carrier:0 - collisions:0 txqueuelen:1000 - RX bytes:1193 (1.1 KiB) TX bytes:1028 (1.0 KiB) - -root@ZhuoTK:/# ip ro del 8.8.8.8/32 -RTNETLINK answers: No such process - -root@ZhuoTK:/# ip ro add 8.8.8.8/32 dev wwan0_1 -root@ZhuoTK:/# ping 8.8.8.8 -PING 8.8.8.8 (8.8.8.8): 56 data bytes -64 bytes from 8.8.8.8: seq=0 ttl=52 time=113.508 ms - -root@ZhuoTK:/# ip ro del 8.8.8.8/32 -root@ZhuoTK:/# ip ro del 8.8.8.8/32 -RTNETLINK answers: No such process - -root@ZhuoTK:/# ip ro add 8.8.8.8/32 dev wwan0_2 -root@ZhuoTK:/# ping 8.8.8.8 -PING 8.8.8.8 (8.8.8.8): 56 data bytes -64 bytes from 8.8.8.8: seq=0 ttl=111 time=123.651 ms - -root@ZhuoTK:/# quectel-CM -k 2 -[04-13_03:46:30:808] Quectel_QConnectManager_Linux_V1.6.0.25 -[04-13_03:46:30:811] /proc/2834/cmdline: quectel-CM -n 2 -s 4gnet -[04-13_03:46:30:811] send SIGINT to process 2834 -[04-13_03:46:30:811] requestDeactivateDefaultPDP WdsConnectionIPv4Handle -[ 1696.460000] net wwan0: link_state 0x3 -> 0x1 -[04-13_03:46:31:361] ifconfig wwan0_2 0.0.0.0 -[04-13_03:46:31:373] ifconfig wwan0_2 down -[04-13_03:46:31:516] QmiWwanThread exit -[04-13_03:46:31:516] qmi_main exit - -root@ZhuoTK:/# ifconfig wwan0_2 -wwan0_2 Link encap:Ethernet HWaddr DA:0B:CE:B2:DB:21 - NOARP MTU:1500 Metric:1 - RX packets:16 errors:0 dropped:0 overruns:0 frame:0 - TX packets:15 errors:0 dropped:0 overruns:0 carrier:0 - collisions:0 txqueuelen:1000 - RX bytes:1865 (1.8 KiB) TX bytes:1620 (1.5 KiB) diff --git a/quectel_cm_5G/src/log/qmi_wwan_q_qmap=4_bridge.txt b/quectel_cm_5G/src/log/qmi_wwan_q_qmap=4_bridge.txt deleted file mode 100644 index 504d11a..0000000 --- a/quectel_cm_5G/src/log/qmi_wwan_q_qmap=4_bridge.txt +++ /dev/null @@ -1,132 +0,0 @@ -root@ZhuoTK:/# brctl addbr br0 -brctl: bridge br0: File exists -root@ZhuoTK:/# brctl delbr br0 -root@ZhuoTK:/# brctl addbr br0 -root@ZhuoTK:/# brctl addif br0 eth0.1 - -root@ZhuoTK:/# insmod qmi_wwan_q.ko qmap_mode=4 -[ 365.340000] usbcore: registered new interface driver qmi_wwan_q -[ 380.860000] usb 1-1.3: new high-speed USB device number 4 using ehci-platform -[ 381.100000] qmi_wwan_q 1-1.3:1.4: cdc-wdm0: USB WDM device -[ 381.100000] qmi_wwan_q 1-1.3:1.4: Quectel Android work on RawIP mode -[ 381.120000] qmi_wwan_q 1-1.3:1.4: rx_urb_size = 4096 -[ 381.120000] qmi_wwan_q 1-1.3:1.4 wwan0: register 'qmi_wwan_q' at usb-101c0000.ehci-1.3, RMNET/USB device, fa:24:73:b5:39:a8 -[ 381.130000] net wwan0: qmap_register_device wwan0_1 -[ 381.140000] net wwan0: qmap_register_device wwan0_2 -[ 381.150000] net wwan0: qmap_register_device wwan0_3 -[ 381.150000] net wwan0: qmap_register_device wwan0_4 - -root@ZhuoTK:/# brctl addbr br0 -root@ZhuoTK:/# brctl addif br0 eth0.1 -root@ZhuoTK:/# brctl addif br0 wwan0_2 -root@ZhuoTK:/# brctl show -bridge name bridge id STP enabled interfaces -br0 8000.00ca019197b9 no eth0.1 - wwan0_2 - -root@ZhuoTK:/# quectel-qmi-proxy & -[04-13_05:18:10:832] Will use cdc-wdm='/dev/cdc-wdm0', proxy='quectel-qmi-proxy0' -[04-13_05:18:10:833] qmi_proxy_init enter -[04-13_05:18:10:833] qmi_proxy_loop enter thread_id 0x77995530 -[04-13_05:18:11:833] qmi_proxy_init succful -[04-13_05:18:11:833] local server: quectel-qmi-proxy0 sockfd = 4 -[04-13_05:18:11:833] qmi_proxy_server_fd = 4 - -root@ZhuoTK:/# quectel-CM -n 2 -s 4gnet -b & -[04-13_05:18:20:144] Quectel_QConnectManager_Linux_V1.6.0.25 -[04-13_05:18:20:146] Find /sys/bus/usb/devices/1-1.3 idVendor=0x2c7c idProduct=0x125, bus=0x001, dev=0x004 -[04-13_05:18:20:147] Auto find qmichannel = /dev/cdc-wdm0 -[04-13_05:18:20:148] Auto find usbnet_adapter = wwan0 -[04-13_05:18:20:148] netcard driver = qmi_wwan_q, driver version = V1.2.0.23 -[04-13_05:18:20:148] qmap_mode = 4, qmap_version = 5, qmap_size = 4096, muxid = 0x82, qmap_netcard = wwan0_2 -[04-13_05:18:20:149] Modem works in QMI mode -[04-13_05:18:20:150] connect to quectel-qmi-proxy0 sockfd = 7 -[04-13_05:18:20:150] cdc_wdm_fd = 7 -[04-13_05:18:20:370] requestBaseBandVersion EC25EFAR06A11M4G -[04-13_05:18:20:403] qmap_settings.rx_urb_size = 4096 -[04-13_05:18:20:404] qmap_settings.ul_data_aggregation_max_datagrams = 11 -[04-13_05:18:20:404] qmap_settings.ul_data_aggregation_max_size = 4096 -[04-13_05:18:20:404] qmap_settings.dl_minimum_padding = 0 -[04-13_05:18:20:530] requestGetSIMStatus SIMStatus: SIM_READY -[04-13_05:18:20:530] requestSetProfile[2] 4gnet///0 -[04-13_05:18:20:594] requestGetProfile[2] 4gnet///0 -[04-13_05:18:20:626] requestRegistrationState2 MCC: 460, MNC: 0, PS: Attached, DataCap: LTE -[04-13_05:18:20:657] requestQueryDataCall IPv4ConnectionStatus: DISCONNECTED -[04-13_05:18:20:658] ifconfig wwan0_2 0.0.0.0 -[04-13_05:18:20:669] ifconfig wwan0_2 down -[04-13_05:18:21:010] requestSetupDataCall WdsConnectionIPv4Handle: 0x87249650 -[ 425.100000] net wwan0: link_state 0x1 -> 0x3 -[04-13_05:18:21:143] ifconfig wwan0 up -[04-13_05:18:21:156] ifconfig wwan0_2 up -[04-13_05:18:21:168] echo '0xa8ceec7' > /sys/class/net/wwan0_2/bridge_ipv4 - -root@ZhuoTK:/# ifconfig br0 up - -[ 450.520000] br0: port 2(wwan0_2) entered forwarding state -[ 450.520000] br0: port 1(eth0.1) entered forwarding state -[ 450.770000] wwan0_2 PC Mac Address: 00:0e:c6:a6:6c:f1 -[ 450.790000] wwan0_2 PC Mac Address: 00:0e:c6:a6:6c:f1 -[ 450.840000] wwan0_2 sip = 10.140.238.199, tip=10.140.238.200, ipv4=10.140.238.199 -[ 450.950000] wwan0_2 sip = 10.140.238.199, tip=10.140.238.200, ipv4=10.140.238.199 -[ 450.950000] wwan0_2 sip = 10.140.238.199, tip=10.140.238.200, ipv4=10.140.238.199 -[ 451.120000] wwan0_2 sip = 0.0.0.0, tip=10.140.238.199, ipv4=10.140.238.199 -[ 451.180000] wwan0_2 sip = 10.140.238.199, tip=10.140.238.200, ipv4=10.140.238.199 -[ 452.120000] wwan0_2 sip = 0.0.0.0, tip=10.140.238.199, ipv4=10.140.238.199 -[ 453.080000] wwan0_2 sip = 10.140.238.199, tip=10.140.238.200, ipv4=10.140.238.199 -[ 453.120000] wwan0_2 sip = 0.0.0.0, tip=10.140.238.199, ipv4=10.140.238.199 -[ 454.120000] wwan0_2 sip = 10.140.238.199, tip=10.140.238.199, ipv4=10.140.238.199 -[ 454.220000] wwan0_2 sip = 10.140.238.199, tip=10.140.238.200, ipv4=10.140.238.199 -[ 456.200000] wwan0_2 sip = 10.140.238.199, tip=10.140.238.200, ipv4=10.140.238.199 -[ 458.120000] wwan0_2 sip = 10.140.238.199, tip=10.140.238.200, ipv4=10.140.238.199 -[ 459.240000] wwan0_2 sip = 10.140.238.199, tip=10.140.238.200, ipv4=10.140.238.199 - -root@ZhuoTK:/# quectel-CM -n 1 -s cmnet & -[04-13_05:19:21:122] Quectel_QConnectManager_Linux_V1.6.0.25 -[04-13_05:19:21:125] Find /sys/bus/usb/devices/1-1.3 idVendor=0x2c7c idProduct=0x125, bus=0x001, dev=0x004 -[04-13_05:19:21:126] Auto find qmichannel = /dev/cdc-wdm0 -[04-13_05:19:21:126] Auto find usbnet_adapter = wwan0 -[04-13_05:19:21:127] netcard driver = qmi_wwan_q, driver version = V1.2.0.23 -[04-13_05:19:21:127] qmap_mode = 4, qmap_version = 5, qmap_size = 4096, muxid = 0x81, qmap_netcard = wwan0_1 -[04-13_05:19:21:127] Modem works in QMI mode -[04-13_05:19:21:128] connect to quectel-qmi-proxy0 sockfd = 7 -[04-13_05:19:21:129] cdc_wdm_fd = 7 -[04-13_05:19:21:331] requestBaseBandVersion EC25EFAR06A11M4G -[04-13_05:19:21:459] requestGetSIMStatus SIMStatus: SIM_READY -[04-13_05:19:21:459] requestSetProfile[1] cmnet///0 -[04-13_05:19:21:522] requestGetProfile[1] cmnet///0 -[04-13_05:19:21:554] requestRegistrationState2 MCC: 460, MNC: 0, PS: Attached, DataCap: LTE -[04-13_05:19:21:585] requestQueryDataCall IPv4ConnectionStatus: DISCONNECTED -[ 485.550000] net wwan0: link_state 0x3 -> 0x2 -[04-13_05:19:21:592] ifconfig wwan0_1 0.0.0.0 -[ 485.570000] IPv6: ADDRCONF(NETDEV_UP): wwan0_1: link is not ready -[04-13_05:19:21:610] ifconfig wwan0_1 down -[04-13_05:19:21:682] requestSetupDataCall WdsConnectionIPv4Handle: 0x8725ed70 -[ 485.780000] net wwan0: link_state 0x2 -> 0x3 -[04-13_05:19:21:815] ifconfig wwan0 up -[04-13_05:19:21:826] ifconfig wwan0_1 up -[04-13_05:19:21:845] you are use OpenWrt? -[04-13_05:19:21:845] should not calling udhcpc manually? -[04-13_05:19:21:845] should modify /etc/config/network as below? -[04-13_05:19:21:845] config interface wan -[04-13_05:19:21:845] option ifname wwan0_1 -[04-13_05:19:21:845] option proto dhcp -[04-13_05:19:21:845] should use "/sbin/ifstaus wan" to check wwan0_1 's status? -[04-13_05:19:21:846] busybox udhcpc -f -n -q -t 5 -i wwan0_1 -[04-13_05:19:21:863] udhcpc (v1.23.2) started -[04-13_05:19:21:923] Sending discover... -[04-13_05:19:21:927] Sending select for 10.141.146.55... -[04-13_05:19:21:932] Lease of 10.141.146.55 obtained, lease time 7200 -[04-13_05:19:21:938] udhcpc: ifconfig wwan0_1 10.141.146.55 netmask 255.255.255.240 broadcast + -[04-13_05:19:21:949] udhcpc: setting default routers: 10.141.146.56 - -root@ZhuoTK:/# ip ro show -default via 10.141.146.56 dev wwan0_1 -10.141.146.48/28 dev wwan0_1 proto kernel scope link src 10.141.146.55 -192.168.1.0/24 dev br-lan proto kernel scope link src 192.168.1.251 - -root@ZhuoTK:/# ping 8.8.8.8 -PING 8.8.8.8 (8.8.8.8): 56 data bytes -64 bytes from 8.8.8.8: seq=0 ttl=111 time=86.006 ms -64 bytes from 8.8.8.8: seq=1 ttl=111 time=74.763 ms -64 bytes from 8.8.8.8: seq=2 ttl=111 time=85.501 ms -64 bytes from 8.8.8.8: seq=3 ttl=111 time=74.231 ms diff --git a/quectel_cm_5G/src/log/qmi_wwan_qmap=4.txt b/quectel_cm_5G/src/log/qmi_wwan_qmap=4.txt deleted file mode 100644 index c0067bf..0000000 --- a/quectel_cm_5G/src/log/qmi_wwan_qmap=4.txt +++ /dev/null @@ -1,55 +0,0 @@ -# dmesg -[ 1737.738025] usb 1-1.2: new high-speed USB device number 5 using xhci-hcd -[ 1737.838917] usb 1-1.2: New USB device found, idVendor=2c7c, idProduct=0512, bcdDevice= 3.18 -[ 1737.838948] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3 -[ 1737.838963] usb 1-1.2: Product: EG12-EA -[ 1737.838975] usb 1-1.2: Manufacturer: Quectel -[ 1737.838986] usb 1-1.2: SerialNumber: 0123456789ABCDE -[ 1737.994955] option 1-1.2:1.0: GSM modem (1-port) converter detected -[ 1737.995430] usb 1-1.2: GSM modem (1-port) converter now attached to ttyUSB0 -[ 1737.995978] option 1-1.2:1.1: GSM modem (1-port) converter detected -[ 1737.996409] usb 1-1.2: GSM modem (1-port) converter now attached to ttyUSB1 -[ 1737.996963] option 1-1.2:1.2: GSM modem (1-port) converter detected -[ 1737.997351] usb 1-1.2: GSM modem (1-port) converter now attached to ttyUSB2 -[ 1737.997909] option 1-1.2:1.3: GSM modem (1-port) converter detected -[ 1737.998976] usb 1-1.2: GSM modem (1-port) converter now attached to ttyUSB3 -[ 1825.835796] qmi_wwan 1-1.2:1.4: cdc-wdm0: USB WDM device -[ 1825.839685] qmi_wwan 1-1.2:1.4 wwan0: register 'qmi_wwan' at usb-fe9c0000.xhci-1.2, WWAN/QMI device, 0e:80:14:b1:f6:b9 -[ 1825.840062] usbcore: registered new interface driver qmi_wwan - -# ifconfig wwan0 down -# echo Y > /sys/class/net/wwan0/qmi/raw_ip - -# echo 1 > /sys/class/net/wwan0/qmi/add_mux -# ifconfig qmimux0 -qmimux0: flags=4240 mtu 1500 - unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 1000 (UNSPEC) - RX packets 0 bytes 0 (0.0 B) - RX errors 0 dropped 0 overruns 0 frame 0 - TX packets 0 bytes 0 (0.0 B) - TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 - -# echo 2 > /sys/class/net/wwan0/qmi/add_mux -# echo 3 > /sys/class/net/wwan0/qmi/add_mux -# echo 4 > /sys/class/net/wwan0/qmi/add_mux -# ifconfig qmimux3 -qmimux3: flags=4240 mtu 1500 - unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 1000 (UNSPEC) - RX packets 0 bytes 0 (0.0 B) - RX errors 0 dropped 0 overruns 0 frame 0 - TX packets 0 bytes 0 (0.0 B) - TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 - -set wwan0's mtu to max qmap packet size, for usbnet.c:usbnet_change_mtu() do not accept -# ifconfig wwan0 mtu 16385 - -run qmi proxy programm, -# quectel-CM/quectel-qmi-proxy -d /dev/cdc-wdm0 -or libqmi's qmi-proxy, if use libqmi's qmi-proxy, you can use qmicli to setup data call. -# /usr/libexec/qmi-proxy --verbose --no-exit - -use quectel-CM to setup data call, if use libqmi's qmi-proxy, use '-p qmi-proxy' instead of '-p quectel-qmi-proxy' -# quectel-CM -p quectel-qmi-proxy -n 4 -s cmnet4 -# quectel-CM -p quectel-qmi-proxy -n 1 -s cmnet - -for how to use libqmi to setup data call, please refer to https://knowledge.quectel.com/display/SWSYSTLinuxAndroid/libqmi_How+to+using+QMAP+multiplexing \ No newline at end of file diff --git a/quectel_cm_5G/src/log/usage_of_argument/6.txt b/quectel_cm_5G/src/log/usage_of_argument/6.txt deleted file mode 100644 index 5ab9533..0000000 --- a/quectel_cm_5G/src/log/usage_of_argument/6.txt +++ /dev/null @@ -1,68 +0,0 @@ -root@OpenWrt:~# quectel-CM -s cmnet -4 -6 -[04-14_06:56:51:778] Quectel_QConnectManager_Linux_V1.6.0.25 -[04-14_06:56:51:779] network interface '' or qmidev '' is not exist -[04-14_06:56:51:780] netcard driver = pcie_mhi, driver version = V1.3.0.17 -[04-14_06:56:51:781] qmap_mode = 4, qmap_version = 9, qmap_size = 16384, muxid = 0x81, qmap_netcard = rmnet_mhi0.1 -[04-14_06:56:51:782] Modem works in QMI mode -[04-14_06:56:51:783] connect to quectel-qmi-proxy0 sockfd = 7 -[04-14_06:56:51:783] cdc_wdm_fd = 7 -[04-14_06:56:51:789] Get clientWDS = 15 -[04-14_06:56:51:792] Get clientWDS = 16 -[04-14_06:56:51:794] Get clientDMS = 3 -[04-14_06:56:51:798] Get clientNAS = 4 -[04-14_06:56:51:801] Get clientUIM = 1 -[04-14_06:56:51:805] Get clientWDA = 1 -[04-14_06:56:51:809] requestBaseBandVersion RM500QGLABR10A03M4G -[04-14_06:56:51:813] qmap_settings.rx_urb_size = 16384 -[04-14_06:56:51:813] qmap_settings.ul_data_aggregation_max_datagrams = 11 -[04-14_06:56:51:814] qmap_settings.ul_data_aggregation_max_size = 8192 -[04-14_06:56:51:814] qmap_settings.dl_minimum_padding = 0 -[04-14_06:56:51:835] requestGetSIMStatus SIMStatus: SIM_READY -[04-14_06:56:51:836] requestSetProfile[1] cmnet///0 -[04-14_06:56:51:848] requestGetProfile[1] cmnet///0 -[04-14_06:56:51:852] requestRegistrationState2 MCC: 460, MNC: 0, PS: Attached, DataCap: 5G_NSA -[04-14_06:56:51:857] requestQueryDataCall IPv4ConnectionStatus: DISCONNECTED -[04-14_06:56:51:860] requestQueryDataCall IPv6ConnectionStatus: DISCONNECTED -[04-14_06:56:51:861] ifconfig rmnet_mhi0 down -[04-14_06:56:51:885] ifconfig rmnet_mhi0.1 0.0.0.0 -ifconfig: SIOCSIFFLAGS: Network is down -[04-14_06:56:51:909] ifconfig rmnet_mhi0.1 down -[04-14_06:56:51:943] requestSetupDataCall WdsConnectionIPv4Handle: 0x341450a0 -[04-14_06:56:52:423] requestSetupDataCall WdsConnectionIPv6Handle: 0x341439f0 -[ 1001.561353] net rmnet_mhi0: link_state 0x0 -> 0x1 -[04-14_06:56:52:441] ifconfig rmnet_mhi0 up -[ 1001.584623] [I][mhi_netdev_open] Opened net dev interface -[04-14_06:56:52:467] ifconfig rmnet_mhi0.1 up -[04-14_06:56:52:495] you are use OpenWrt? -[04-14_06:56:52:496] should not calling udhcpc manually? -[04-14_06:56:52:496] should modify /etc/config/network as below? -[04-14_06:56:52:497] config interface wan -[04-14_06:56:52:497] option ifname rmnet_mhi0.1 -[04-14_06:56:52:497] option proto dhcp -[04-14_06:56:52:498] should use "/sbin/ifstaus wan" to check rmnet_mhi0.1 's status? -[04-14_06:56:52:498] busybox udhcpc -f -n -q -t 5 -i rmnet_mhi0.1 -udhcpc: started, v1.28.3 -udhcpc: sending discover -udhcpc: sending select for 10.245.22.3 -udhcpc: lease of 10.245.22.3 obtained, lease time 7200 -[04-14_06:56:52:713] udhcpc: ifconfig rmnet_mhi0.1 10.245.22.3 netmask 255.255.255.248 broadcast + -[04-14_06:56:52:754] udhcpc: setting default routers: 10.245.22.4 -[04-14_06:56:52:838] ip -6 address flush dev rmnet_mhi0.1 -[04-14_06:56:52:861] ip -6 address add 2409:8930:463:3daa:7c8e:429a:c902:c6cc/64 dev rmnet_mhi0.1 -[04-14_06:56:52:884] ip -6 route add default dev rmnet_mhi0.1 - -root@OpenWrt:~# cat /etc/resolv.conf -nameserver 2409:8030:2000:0:0:0:0:1 # IPV6 rmnet_mhi0.1 -nameserver 2409:8030:2000:0:0:0:0:2 # IPV6 rmnet_mhi0.1 -search lan -nameserver 127.0.0.1 - -root@OpenWrt:~# ip -6 ro show -2409:8930:463:96df::/64 dev rmnet_mhi0.1 proto kernel metric 256 -fe80::/64 dev br-lan proto kernel metric 256 -fe80::/64 dev br0 proto kernel metric 256 -default dev rmnet_mhi0.1 metric 1024 - -root@OpenWrt:~# ping6 www.qq.com -PING www.qq.com (2402:4e00:1430:1301::9227:79cc:76f2): 56 data bytes -64 bytes from 2402:4e00:1430:1301::9227:79cc:76f2: seq=0 ttl=51 time=97.230 ms diff --git a/quectel_cm_5G/src/log/usage_of_argument/m.txt b/quectel_cm_5G/src/log/usage_of_argument/m.txt deleted file mode 100644 index c4c46b8..0000000 --- a/quectel_cm_5G/src/log/usage_of_argument/m.txt +++ /dev/null @@ -1,58 +0,0 @@ -root@ZhuoTK:/# quectel-CM -n 1 -m 4 -s cmnet & -[04-13_05:12:07:455] Quectel_QConnectManager_Linux_V1.6.0.25 -[04-13_05:12:07:458] Find /sys/bus/usb/devices/1-1.3 idVendor=0x2c7c idProduct=0x125, bus=0x001, dev=0x003 -[04-13_05:12:07:459] Auto find qmichannel = /dev/qcqmi0 -[04-13_05:12:07:459] Auto find usbnet_adapter = usb0 -[04-13_05:12:07:467] netcard driver = GobiNet, driver version = V1.6.2.13 -[04-13_05:12:07:467] qmap_mode = 4, qmap_version = 5, qmap_size = 4096, muxid = 0x84, qmap_netcard = usb0.4 -[04-13_05:12:07:467] Modem works in QMI mode -[04-13_05:12:07:495] Get clientWDS = 7 -[04-13_05:12:07:529] Get clientDMS = 8 -[04-13_05:12:07:561] Get clientNAS = 9 -[04-13_05:12:07:591] Get clientUIM = 10 -[04-13_05:12:07:623] requestBaseBandVersion EC25EFAR06A11M4G -[04-13_05:12:07:752] requestGetSIMStatus SIMStatus: SIM_READY -[04-13_05:12:07:752] requestSetProfile[1] cmnet///0 -[04-13_05:12:07:817] requestGetProfile[1] cmnet///0 -[04-13_05:12:07:849] requestRegistrationState2 MCC: 460, MNC: 0, PS: Attached, DataCap: LTE -[04-13_05:12:07:881] requestQueryDataCall IPv4ConnectionStatus: DISCONNECTED -[04-13_05:12:07:881] ifconfig usb0 down -[04-13_05:12:07:892] ifconfig usb0.4 0.0.0.0 -[04-13_05:12:07:903] ifconfig usb0.4 down -[04-13_05:12:07:944] requestSetupDataCall WdsConnectionIPv4Handle: 0x87265c40 -[ 52.020000] net usb0: link_state 0x0 -> 0x8 -[04-13_05:12:08:077] ifconfig usb0 up -[04-13_05:12:08:096] ifconfig usb0.4 up -[04-13_05:12:08:116] you are use OpenWrt? -[04-13_05:12:08:116] should not calling udhcpc manually? -[04-13_05:12:08:116] should modify /etc/config/network as below? -[04-13_05:12:08:116] config interface wan -[04-13_05:12:08:116] option ifname usb0.4 -[04-13_05:12:08:116] option proto dhcp -[04-13_05:12:08:116] should use "/sbin/ifstaus wan" to check usb0.4 's status? -[04-13_05:12:08:117] busybox udhcpc -f -n -q -t 5 -i usb0.4 -[04-13_05:12:08:134] udhcpc (v1.23.2) started -[04-13_05:12:08:193] Sending discover... -[04-13_05:12:08:197] Sending select for 10.84.241.180... -[04-13_05:12:08:203] Lease of 10.84.241.180 obtained, lease time 7200 -[04-13_05:12:08:208] udhcpc: ifconfig usb0.4 10.84.241.180 netmask 255.255.255.248 broadcast + -[04-13_05:12:08:221] udhcpc: setting default routers: 10.84.241.181 - -root@ZhuoTK:/# ifconfig usb0.4 -usb0.4 Link encap:Ethernet HWaddr 02:50:F4:00:00:00 - inet addr:10.84.241.180 Mask:255.255.255.248 - inet6 addr: fe80::50:f4ff:fe00:0/64 Scope:Link - UP RUNNING NOARP MTU:1500 Metric:1 - RX packets:2 errors:0 dropped:0 overruns:0 frame:0 - TX packets:6 errors:0 dropped:0 overruns:0 carrier:0 - collisions:0 txqueuelen:1000 - RX bytes:612 (612.0 B) TX bytes:984 (984.0 B) - -root@ZhuoTK:/# ip ro show -default via 10.84.241.181 dev usb0.4 -10.84.241.176/29 dev usb0.4 proto kernel scope link src 10.84.241.180 -192.168.1.0/24 dev br-lan proto kernel scope link src 192.168.1.251 - -root@ZhuoTK:/# ping 8.8.8.8 -PING 8.8.8.8 (8.8.8.8): 56 data bytes -64 bytes from 8.8.8.8: seq=0 ttl=52 time=99.431 ms diff --git a/quectel_cm_5G/src/main.c b/quectel_cm_5G/src/main.c deleted file mode 100644 index e39a5f3..0000000 --- a/quectel_cm_5G/src/main.c +++ /dev/null @@ -1,934 +0,0 @@ -/****************************************************************************** - @file main.c - @brief The entry program. - - DESCRIPTION - Connectivity Management Tool for USB network adapter of Quectel wireless cellular modules. - - INITIALIZATION AND SEQUENCING REQUIREMENTS - None. - - --------------------------------------------------------------------------- - Copyright (c) 2016 -2020 Quectel Wireless Solution, Co., Ltd. All Rights Reserved. - Quectel Wireless Solution Proprietary and Confidential. - --------------------------------------------------------------------------- -******************************************************************************/ - -#include "QMIThread.h" -#include -#include -#include -#include - -#include "util.h" -//#define CONFIG_PID_FILE_FORMAT "/var/run/quectel-CM-%s.pid" //for example /var/run/quectel-CM-wwan0.pid - -static PROFILE_T s_profile; -int debug_qmi = 0; -int qmidevice_control_fd[2]; -static int signal_control_fd[2]; -int g_donot_exit_when_modem_hangup = 0; -extern int ql_ifconfig(int argc, char *argv[]); -extern int ql_get_netcard_driver_info(const char*); -extern int ql_capture_usbmon_log(PROFILE_T *profile, const char *log_path); -extern void ql_stop_usbmon_log(PROFILE_T *profile); -//UINT ifc_get_addr(const char *ifname); -static int s_link = -1; -static void usbnet_link_change(int link, PROFILE_T *profile) { - if (s_link == link) - return; - - s_link = link; - - if (!(link & (1<ipv4, 0, sizeof(IPV4_T)); - - if (!(link & (1<ipv6, 0, sizeof(IPV6_T)); - - if (link) { - udhcpc_start(profile); - } else { - udhcpc_stop(profile); - } -} - -static int check_ipv4_address(PROFILE_T *profile) { - uint32_t oldAddress = profile->ipv4.Address; - - if (profile->request_ops == &mbim_request_ops) - return 1; //we will get a new ipv6 address per requestGetIPAddress() - if (profile->request_ops == &atc_request_ops) - return 1; //TODO - - if (profile->request_ops->requestGetIPAddress(profile, IpFamilyV4) == 0) { - if (profile->ipv4.Address != oldAddress || debug_qmi) { - unsigned char *l = (unsigned char *)&oldAddress; - unsigned char *r = (unsigned char *)&profile->ipv4.Address; - dbg_time("localIP: %d.%d.%d.%d VS remoteIP: %d.%d.%d.%d", - l[3], l[2], l[1], l[0], r[3], r[2], r[1], r[0]); - } - return (profile->ipv4.Address == oldAddress); - } - - return 0; -} - -static void main_send_event_to_qmidevice(int triger_event) { - if (write(qmidevice_control_fd[0], &triger_event, sizeof(triger_event)) == -1) {}; -} - -static void send_signo_to_main(int signo) { - if (write(signal_control_fd[0], &signo, sizeof(signo)) == -1) {}; -} - -void qmidevice_send_event_to_main(int triger_event) { - if (write(qmidevice_control_fd[1], &triger_event, sizeof(triger_event)) == -1) {}; -} - -void qmidevice_send_event_to_main_ext(int triger_event, void *data, unsigned len) { - if (write(qmidevice_control_fd[1], &triger_event, sizeof(triger_event)) == -1) {}; - if (write(qmidevice_control_fd[1], data, len) == -1) {}; -} - -#define MAX_PATH 256 - -static int ls_dir(const char *dir, int (*match)(const char *dir, const char *file, void *argv[]), void *argv[]) -{ - DIR *pDir; - struct dirent* ent = NULL; - int match_times = 0; - - pDir = opendir(dir); - if (pDir == NULL) { - dbg_time("Cannot open directory: %s, errno: %d (%s)", dir, errno, strerror(errno)); - return 0; - } - - while ((ent = readdir(pDir)) != NULL) { - match_times += match(dir, ent->d_name, argv); - } - closedir(pDir); - - return match_times; -} - -static int is_same_linkfile(const char *dir, const char *file, void *argv[]) -{ - const char *qmichannel = (const char *)argv[1]; - char linkname[MAX_PATH*2+6]; - char filename[MAX_PATH]; - int linksize; - - snprintf(linkname, sizeof(linkname), "%.256s/%s", dir, file); - linksize = readlink(linkname, filename, sizeof(filename)); - if (linksize <= 0) - return 0; - - filename[linksize] = 0; - if (strcmp(filename, qmichannel)) - return 0; - - dbg_time("%s -> %s", linkname, filename); - return 1; -} - -static int is_brother_process(const char *dir, const char *file, void *argv[]) -{ - //const char *myself = (const char *)argv[0]; - char linkname[MAX_PATH*2+6]; - char filename[MAX_PATH]; - int linksize; - int i = 0, kill_timeout = 15; - pid_t pid; - - //dbg_time("%s", file); - while (file[i]) { - if (!isdigit(file[i])) - break; - i++; - } - - if (file[i]) { - //dbg_time("%s not digit", file); - return 0; - } - - snprintf(linkname, sizeof(linkname), "%s/%s/exe", dir, file); - linksize = readlink(linkname, filename, sizeof(filename)); - if (linksize <= 0) - return 0; - - filename[linksize] = 0; - - pid = atoi(file); - if (pid >= getpid()) - return 0; - - snprintf(linkname, sizeof(linkname), "%s/%s/fd", dir, file); - if (!ls_dir(linkname, is_same_linkfile, argv)) - return 0; - - dbg_time("%s/%s/exe -> %s", dir, file, filename); - while (kill_timeout-- && !kill(pid, 0)) - { - kill(pid, SIGTERM); - sleep(1); - } - if (!kill(pid, 0)) - { - dbg_time("force kill %s/%s/exe -> %s", dir, file, filename); - kill(pid, SIGKILL); - sleep(1); - } - - return 1; -} - -static int kill_brothers(const char *qmichannel) -{ - char myself[MAX_PATH]; - int filenamesize; - void *argv[2] = {myself, (void *)qmichannel}; - - filenamesize = readlink("/proc/self/exe", myself, sizeof(myself)); - if (filenamesize <= 0) - return 0; - myself[filenamesize] = 0; - - if (ls_dir("/proc", is_brother_process, argv)) - sleep(1); - - return 0; -} - -static int kill_data_call_pdp(int pdp, char *self) { - int pid; - char *p = NULL; - - p = self; - while (*self) { - if (*self == '/') - p = self+1; - self++; - } - - pid = getpid_by_pdp(pdp, p); - if (pid > 0) { - dbg_time("send SIGINT to process %d", pid); - return kill(pid, SIGINT); - } - - return -1; -} - -static void ql_sigaction(int signo) { - if (SIGALRM == signo) - send_signo_to_main(SIG_EVENT_START); - else - { - g_donot_exit_when_modem_hangup = 0; - send_signo_to_main(SIG_EVENT_STOP); - main_send_event_to_qmidevice(SIG_EVENT_STOP); //main may be wating qmi response - } -} - -static int usage(const char *progname) { - dbg_time("Usage: %s [options]", progname); - dbg_time("-s [apn [user password auth]] Set apn/user/password/auth get from your network provider. auth: 1~pap, 2~chap, 3~MsChapV2"); - dbg_time("-p pincode Verify sim card pin if sim card is locked"); - dbg_time("-p [quectel-][qmi|mbim]-proxy Request to use proxy"); - dbg_time("-f logfilename Save log message of this program to file"); - dbg_time("-u usbmonlog filename Save usbmon log to file"); - dbg_time("-i interface Specify which network interface to setup data call when multi-modems exits"); - dbg_time("-4 Setup IPv4 data call (default)"); - dbg_time("-6 Setup IPv6 data call"); - dbg_time("-n pdn Specify which pdn to setup data call (default 1 for QMI, 0 for MBIM)"); - dbg_time("-k pdn Specify which pdn to hangup data call (by send SIGINT to 'quectel-CM -n pdn')"); - dbg_time("-m iface-idx Bind QMI data call to wwan0_ when QMAP used. E.g '-n 7 -m 1' bind pdn-7 data call to wwan0_1"); - dbg_time("-b Enable network interface bridge function (default 0)"); - dbg_time("-v Verbose log mode, for debug purpose."); - dbg_time("[Examples]"); - dbg_time("Example 1: %s ", progname); - dbg_time("Example 2: %s -s 3gnet ", progname); - dbg_time("Example 3: %s -s 3gnet carl 1234 1 -p 1234 -f gobinet_log.txt", progname); - return 0; -} - -static int qmi_main(PROFILE_T *profile) -{ - int triger_event = 0; - int signo; -#ifdef CONFIG_SIM - SIM_Status SIMStatus = SIM_ABSENT; -#endif - UCHAR PSAttachedState = 0; - UCHAR IPv4ConnectionStatus = QWDS_PKT_DATA_UNKNOW; - UCHAR IPv6ConnectionStatus = QWDS_PKT_DATA_UNKNOW; - unsigned SetupCallFail = 0; - unsigned long SetupCallAllowTime = clock_msec(); -#ifdef REBOOT_SIM_CARD_WHEN_LONG_TIME_NO_PS - unsigned PsAttachFail = 0; - unsigned long PsAttachTime = clock_msec(); -#endif - int qmierr = 0; - const struct request_ops *request_ops = profile ->request_ops; - pthread_t gQmiThreadID = 0; - -//sudo apt-get install udhcpc -//sudo apt-get remove ModemManager - if (profile->reattach_flag) { - if (!reattach_driver(profile)) - sleep(2); - } - - /* try to recreate FDs*/ - if (socketpair( AF_LOCAL, SOCK_STREAM, 0, signal_control_fd) < 0 ) { - dbg_time("%s Faild to create main_control_fd: %d (%s)", __func__, errno, strerror(errno)); - return -1; - } - - if ( socketpair( AF_LOCAL, SOCK_STREAM, 0, qmidevice_control_fd ) < 0 ) { - dbg_time("%s Failed to create thread control socket pair: %d (%s)", __func__, errno, strerror(errno)); - return 0; - } - - if ((profile->qmap_mode == 0 || profile->qmap_mode == 1) - && (!profile->proxy[0] || strstr(profile->qmichannel, "_IPCR"))) { - kill_brothers(profile->qmichannel); - } - - if (pthread_create( &gQmiThreadID, 0, profile->qmi_ops->read, (void *)profile) != 0) { - dbg_time("%s Failed to create QMIThread: %d (%s)", __func__, errno, strerror(errno)); - return 0; - } - - if ((read(qmidevice_control_fd[0], &triger_event, sizeof(triger_event)) != sizeof(triger_event)) - || (triger_event != RIL_INDICATE_DEVICE_CONNECTED)) { - dbg_time("%s Failed to init QMIThread: %d (%s)", __func__, errno, strerror(errno)); - return 0; - } - - if (profile->qmi_ops->init && profile->qmi_ops->init(profile)) { - dbg_time("%s Failed to qmi init: %d (%s)", __func__, errno, strerror(errno)); - return 0; - } - - if (request_ops->requestBaseBandVersion) - request_ops->requestBaseBandVersion(profile); - - if (request_ops->requestSetEthMode) - request_ops->requestSetEthMode(profile); - - if (request_ops->requestSetLoopBackState && profile->loopback_state) { - qmierr = request_ops->requestSetLoopBackState(profile->loopback_state, profile->replication_factor); - if (qmierr != QMI_ERR_INVALID_QMI_CMD) //X20 return this error - profile->loopback_state = 0; //wait for RIL_UNSOL_LOOPBACK_CONFIG_IND - } - - if (request_ops->requestGetSIMStatus) { - qmierr = request_ops->requestGetSIMStatus(&SIMStatus); - - while (qmierr == QMI_ERR_OP_DEVICE_UNSUPPORTED) { - sleep(1); - qmierr = request_ops->requestGetSIMStatus(&SIMStatus); - } - - if ((SIMStatus == SIM_PIN) && profile->pincode && request_ops->requestEnterSimPin) { - request_ops->requestEnterSimPin(profile->pincode); - } - } - - if (SIMStatus == SIM_READY) { - if (request_ops->requestGetICCID) - request_ops->requestGetICCID(); - - if (request_ops->requestGetIMSI) - request_ops->requestGetIMSI(); - } - - if (request_ops->requestGetProfile) - request_ops->requestGetProfile(profile); - - if (request_ops->requestSetProfile && (profile->apn || profile->user || profile->password)) { - if (request_ops->requestSetProfile(profile) == 1) { -#ifdef REBOOT_SIM_CARD_WHEN_APN_CHANGE //enable at only when customer asked - if (request_ops->requestRadioPower) { - request_ops->requestRadioPower(0); - request_ops->requestRadioPower(1); - } -#endif - } - } - - request_ops->requestRegistrationState(&PSAttachedState); - -#ifdef CONFIG_ENABLE_QOS - request_ops->requestRegisterQos(profile); -#endif - - send_signo_to_main(SIG_EVENT_CHECK); - - while (1) - { - struct pollfd pollfds[] = {{signal_control_fd[1], POLLIN, 0}, {qmidevice_control_fd[0], POLLIN, 0}}; - int ne, ret, nevents = sizeof(pollfds)/sizeof(pollfds[0]); - - do { - ret = poll(pollfds, nevents, 15*1000); - } while ((ret < 0) && (errno == EINTR)); - - if (ret == 0) - { - send_signo_to_main(SIG_EVENT_CHECK); - continue; - } - - if (ret <= 0) { - dbg_time("%s poll=%d, errno: %d (%s)", __func__, ret, errno, strerror(errno)); - goto __main_quit; - } - - for (ne = 0; ne < nevents; ne++) { - int fd = pollfds[ne].fd; - short revents = pollfds[ne].revents; - - if (revents & (POLLERR | POLLHUP | POLLNVAL)) { - dbg_time("%s poll err/hup", __func__); - dbg_time("epoll fd = %d, events = 0x%04x", fd, revents); - main_send_event_to_qmidevice(RIL_REQUEST_QUIT); - if (revents & POLLHUP) - goto __main_quit; - } - - if ((revents & POLLIN) == 0) - continue; - - if (fd == signal_control_fd[1]) - { - if (read(fd, &signo, sizeof(signo)) == sizeof(signo)) - { - alarm(0); - switch (signo) - { - case SIG_EVENT_START: - if (PSAttachedState != 1 && profile->loopback_state == 0) - break; - - if (SetupCallAllowTime > clock_msec()) { - alarm((SetupCallAllowTime - clock_msec()+999)/1000); - break; - } - - if (profile->enable_ipv4 && IPv4ConnectionStatus != QWDS_PKT_DATA_CONNECTED) { - qmierr = request_ops->requestSetupDataCall(profile, IpFamilyV4); - - if ((qmierr > 0) && profile->user && profile->user[0] && profile->password && profile->password[0]) { - int old_auto = profile->auth; - - //may be fail because wrong auth mode, try pap->chap, or chap->pap - profile->auth = (profile->auth == 1) ? 2 : 1; - qmierr = request_ops->requestSetupDataCall(profile, IpFamilyV4); - - if (qmierr) - profile->auth = old_auto; //still fail, restore old auth moe - } - - if (!qmierr) { - qmierr = request_ops->requestGetIPAddress(profile, IpFamilyV4); - if (!qmierr) - IPv4ConnectionStatus = QWDS_PKT_DATA_CONNECTED; - } - - } - - if (profile->enable_ipv6 && IPv6ConnectionStatus != QWDS_PKT_DATA_CONNECTED) { - if (profile->enable_ipv4 && profile->request_ops != &qmi_request_ops) { - IPv6ConnectionStatus = IPv4ConnectionStatus; - } - else { - qmierr = request_ops->requestSetupDataCall(profile, IpFamilyV6); - - if (!qmierr) { - qmierr = request_ops->requestGetIPAddress(profile, IpFamilyV6); - if (!qmierr) - IPv6ConnectionStatus = QWDS_PKT_DATA_CONNECTED; - } - } - } - - if ((profile->enable_ipv4 && IPv4ConnectionStatus == QWDS_PKT_DATA_DISCONNECTED) - || (profile->enable_ipv6 && IPv6ConnectionStatus == QWDS_PKT_DATA_DISCONNECTED)) { - const unsigned allow_time[] = {5, 10, 20, 40, 60}; - - if (SetupCallFail < (sizeof(allow_time)/sizeof(unsigned))) - SetupCallAllowTime = allow_time[SetupCallFail]; - else - SetupCallAllowTime = 60; - SetupCallFail++; - dbg_time("try to requestSetupDataCall %ld second later", SetupCallAllowTime); - alarm(SetupCallAllowTime); - SetupCallAllowTime = SetupCallAllowTime*1000 + clock_msec(); - } - else if (IPv4ConnectionStatus == QWDS_PKT_DATA_CONNECTED || IPv6ConnectionStatus == QWDS_PKT_DATA_CONNECTED) { - SetupCallFail = 0; - SetupCallAllowTime = clock_msec(); - } - break; - - case SIG_EVENT_CHECK: - if (request_ops->requestGetSignalInfo) - request_ops->requestGetSignalInfo(); - - if (request_ops->requestGetCellInfoList) - request_ops->requestGetCellInfoList(); - - if (request_ops->requestGetCoexWWANState) - request_ops->requestGetCoexWWANState(); - - if (PSAttachedState != 1) - request_ops->requestRegistrationState(&PSAttachedState); - -#ifdef REBOOT_SIM_CARD_WHEN_LONG_TIME_NO_PS - if (PSAttachedState) { - PsAttachTime = clock_msec(); - PsAttachFail = 0; - } - else { - unsigned long diff = (clock_msec() - PsAttachTime) / 1000; - unsigned long threshold = REBOOT_SIM_CARD_WHEN_LONG_TIME_NO_PS << PsAttachFail; - - if (diff > threshold || diff > 960) { - //interval time is 60 -> 120 - > 240 - > 480 -> 960 - PsAttachTime = clock_msec(); - PsAttachFail++; - - if (request_ops->requestRadioPower) { - request_ops->requestRadioPower(0); - request_ops->requestRadioPower(1); - } - } - } -#endif - - if (profile->enable_ipv4 && IPv4ConnectionStatus != QWDS_PKT_DATA_DISCONNECTED - && !request_ops->requestQueryDataCall(&IPv4ConnectionStatus, IpFamilyV4)) - { - if (QWDS_PKT_DATA_CONNECTED == IPv4ConnectionStatus && profile->ipv4.Address == 0) { - //killall -9 quectel-CM for MBIM and ATC call - qmierr = request_ops->requestGetIPAddress(profile, IpFamilyV4); - if (qmierr) - IPv4ConnectionStatus = QWDS_PKT_DATA_DISCONNECTED; - } - - //local ip is different with remote ip - if (QWDS_PKT_DATA_CONNECTED == IPv4ConnectionStatus && check_ipv4_address(profile) == 0) { - request_ops->requestDeactivateDefaultPDP(profile, IpFamilyV4); - IPv4ConnectionStatus = QWDS_PKT_DATA_DISCONNECTED; - } - } - else { - IPv4ConnectionStatus = QWDS_PKT_DATA_DISCONNECTED; - } - - if (profile->enable_ipv6 && IPv6ConnectionStatus != QWDS_PKT_DATA_DISCONNECTED) { - if (profile->enable_ipv4 && profile->request_ops != &qmi_request_ops) { - IPv6ConnectionStatus = IPv4ConnectionStatus; - } - else { - request_ops->requestQueryDataCall(&IPv6ConnectionStatus, IpFamilyV6); - } - } - else { - IPv6ConnectionStatus = QWDS_PKT_DATA_DISCONNECTED; - } - - if (IPv4ConnectionStatus == QWDS_PKT_DATA_DISCONNECTED && IPv6ConnectionStatus == QWDS_PKT_DATA_DISCONNECTED) { - usbnet_link_change(0, profile); - } - else if (IPv4ConnectionStatus == QWDS_PKT_DATA_CONNECTED || IPv6ConnectionStatus == QWDS_PKT_DATA_CONNECTED) { - int link = 0; - if (IPv4ConnectionStatus == QWDS_PKT_DATA_CONNECTED) - link |= (1<enable_ipv4 && IPv4ConnectionStatus == QWDS_PKT_DATA_DISCONNECTED) - || (profile->enable_ipv6 && IPv6ConnectionStatus == QWDS_PKT_DATA_DISCONNECTED)) { - send_signo_to_main(SIG_EVENT_START); - } - break; - - case SIG_EVENT_STOP: - if (profile->enable_ipv4 && IPv4ConnectionStatus == QWDS_PKT_DATA_CONNECTED) { - request_ops->requestDeactivateDefaultPDP(profile, IpFamilyV4); - } - if (profile->enable_ipv6 && IPv6ConnectionStatus == QWDS_PKT_DATA_CONNECTED) { - if (profile->enable_ipv4 && profile->request_ops != &qmi_request_ops) { - - } - else { - request_ops->requestDeactivateDefaultPDP(profile, IpFamilyV6); - } - } - usbnet_link_change(0, profile); - if (profile->qmi_ops->deinit) - profile->qmi_ops->deinit(); - main_send_event_to_qmidevice(RIL_REQUEST_QUIT); - goto __main_quit; - break; - - default: - break; - } - } - } - - if (fd == qmidevice_control_fd[0]) { - if (read(fd, &triger_event, sizeof(triger_event)) == sizeof(triger_event)) { - switch (triger_event) { - case RIL_INDICATE_DEVICE_DISCONNECTED: - usbnet_link_change(0, profile); - goto __main_quit; - break; - - case RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED: - request_ops->requestRegistrationState(&PSAttachedState); - if (PSAttachedState == 1) { - if ((profile->enable_ipv4 && IPv4ConnectionStatus == QWDS_PKT_DATA_DISCONNECTED) - || (profile->enable_ipv6 && IPv6ConnectionStatus == QWDS_PKT_DATA_DISCONNECTED)) { - send_signo_to_main(SIG_EVENT_START); - } - } else { - SetupCallAllowTime = clock_msec(); - } - break; - - case RIL_UNSOL_DATA_CALL_LIST_CHANGED: - if (IPv4ConnectionStatus == QWDS_PKT_DATA_CONNECTED || IPv6ConnectionStatus == QWDS_PKT_DATA_CONNECTED) { - SetupCallAllowTime = clock_msec() + 1000; //from connect -> disconnect, do not re-dail immediately, wait network stable - } - send_signo_to_main(SIG_EVENT_CHECK); - break; - - case MODEM_REPORT_RESET_EVENT: - { - dbg_time("main recv MODEM RESET SIGNAL"); - main_send_event_to_qmidevice(RIL_REQUEST_QUIT); - g_donot_exit_when_modem_hangup = 1; - goto __main_quit; - } - break; - - case RIL_UNSOL_LOOPBACK_CONFIG_IND: - { - QMI_WDA_SET_LOOPBACK_CONFIG_IND_MSG SetLoopBackInd; - if (read(fd, &SetLoopBackInd, sizeof(SetLoopBackInd)) == sizeof(SetLoopBackInd)) { - profile->loopback_state = SetLoopBackInd.loopback_state.TLVVaule; - profile->replication_factor = le32_to_cpu(SetLoopBackInd.replication_factor.TLVVaule); - dbg_time("SetLoopBackInd: loopback_state=%d, replication_factor=%u", - profile->loopback_state, profile->replication_factor); - if (profile->loopback_state) - send_signo_to_main(SIG_EVENT_START); - } - } - break; -#ifdef CONFIG_REG_QOS_IND - case RIL_UNSOL_GLOBAL_QOS_FLOW_IND_QOS_ID: - { - UINT qos_id = 0; - if (read(fd, &qos_id, sizeof(qos_id)) == sizeof(qos_id)) { - profile->qos_id = qos_id; - } - } - break; -#endif - default: - break; - } - } - } - } - } - -__main_quit: - usbnet_link_change(0, profile); - if (gQmiThreadID && pthread_join(gQmiThreadID, NULL)) { - dbg_time("%s Error joining to listener thread (%s)", __func__, strerror(errno)); - } - - close(signal_control_fd[0]); - close(signal_control_fd[1]); - close(qmidevice_control_fd[0]); - close(qmidevice_control_fd[1]); - dbg_time("%s exit", __func__); - - return 0; -} - -static int quectel_CM(PROFILE_T *profile) -{ - int ret = 0; - char qmichannel[32] = {'\0'}; - char usbnet_adapter[32] = {'\0'}; - - if (profile->expect_adapter[0]) - strncpy(usbnet_adapter, profile->expect_adapter, sizeof(usbnet_adapter)); - - if (qmidevice_detect(qmichannel, usbnet_adapter, sizeof(qmichannel), profile)) { - profile->hardware_interface = HARDWARE_USB; - } - else if (mhidevice_detect(qmichannel, usbnet_adapter, profile)) { - profile->hardware_interface = HARDWARE_PCIE; - } - else if (atdevice_detect(qmichannel, usbnet_adapter, profile)) { - profile->hardware_interface = HARDWARE_PCIE; - } -#ifdef CONFIG_QRTR - else if (1) { - strcpy(qmichannel, "qrtr"); - strcpy(usbnet_adapter, "rmnet_mhi0"); - profile->hardware_interface = HARDWARE_PCIE; - profile->software_interface = SOFTWARE_QRTR; - } -#endif - else { - dbg_time("qmidevice_detect failed"); - goto error; - } - - strncpy(profile->qmichannel, qmichannel, sizeof(profile->qmichannel)); - strncpy(profile->usbnet_adapter, usbnet_adapter, sizeof(profile->usbnet_adapter)); - ql_get_netcard_driver_info(profile->usbnet_adapter); - - if ((profile->hardware_interface == HARDWARE_USB) && profile->usblogfile) - ql_capture_usbmon_log(profile, profile->usblogfile); - - if (profile->hardware_interface == HARDWARE_USB) { - profile->software_interface = get_driver_type(profile); - } - - ql_qmap_mode_detect(profile); - - if (profile->software_interface == SOFTWARE_MBIM) { - dbg_time("Modem works in MBIM mode"); - profile->request_ops = &mbim_request_ops; - profile->qmi_ops = &mbim_dev_ops; - ret = qmi_main(profile); - } - else if (profile->software_interface == SOFTWARE_QMI) { - dbg_time("Modem works in QMI mode"); - profile->request_ops = &qmi_request_ops; - if (qmidev_is_gobinet(profile->qmichannel)) - profile->qmi_ops = &gobi_qmidev_ops; - else - profile->qmi_ops = &qmiwwan_qmidev_ops; - qmidev_send = profile->qmi_ops->send; - ret = qmi_main(profile); - } - else if (profile->software_interface == SOFTWARE_ECM_RNDIS_NCM) { - dbg_time("Modem works in ECM_RNDIS_NCM mode"); - profile->request_ops = &atc_request_ops; - profile->qmi_ops = &atc_dev_ops; - ret = qmi_main(profile); - } -#ifdef CONFIG_QRTR - else if (profile->software_interface == SOFTWARE_QRTR) { - dbg_time("Modem works in QRTR mode"); - profile->request_ops = &qmi_request_ops; - profile->qmi_ops = &qrtr_qmidev_ops; - qmidev_send = profile->qmi_ops->send; - ret = qmi_main(profile); - } -#endif - else { - dbg_time("unsupport software_interface %d", profile->software_interface); - } - - ql_stop_usbmon_log(profile); - -error: - return ret; -} - -static int parse_user_input(int argc, char **argv, PROFILE_T *profile) { - int opt = 1; - - profile->pdp = CONFIG_DEFAULT_PDP; - - if (!strcmp(argv[argc-1], "&")) - argc--; - -#define has_more_argv() ((opt < argc) && (argv[opt][0] != '-')) - while (opt < argc) { - if (argv[opt][0] != '-') { - return usage(argv[0]); - } - - switch (argv[opt++][1]) - { - case 's': - profile->apn = profile->user = profile->password = ""; - if (has_more_argv()) { - profile->apn = argv[opt++]; - } - if (has_more_argv()) { - profile->user = argv[opt++]; - } - if (has_more_argv()) { - profile->password = argv[opt++]; - if (profile->password && profile->password[0]) - profile->auth = 2; //default chap, customers may miss auth - } - if (has_more_argv()) { - const char *auth = argv[opt++]; - - if (!strcmp(auth, "0") || !strcasecmp(auth, "none")) { - profile->auth = 0; - } - else if (!strcmp(auth, "1") || !strcasecmp(auth, "pap")) { - profile->auth = 1; - } - else if (!strcmp(auth, "2") || !strcasecmp(auth, "chap")) { - profile->auth = 2; - } - else if (!strcmp(auth, "3") || !strcasecmp(auth, "MsChapV2")) { - profile->auth = 3; - } - else { - dbg_time("unknow auth '%s'", auth); - return usage(argv[0]); - } - } - break; - - case 'p': - if (has_more_argv()) { - const char *arg = argv[opt++]; - - if (!strcmp(arg, QUECTEL_QMI_PROXY) || !strcmp(arg, QUECTEL_MBIM_PROXY) - || !strcmp(arg, LIBQMI_PROXY) || !strcmp(arg, LIBMBIM_PROXY) || !strcmp(arg, QUECTEL_ATC_PROXY)) { - strncpy(profile->proxy, arg, sizeof(profile->proxy) - 1); - } - else if ((999 < atoi(arg)) && (atoi(arg) < 10000)) { - profile->pincode = arg; - } - else { - dbg_time("unknow -p '%s'", arg); - return usage(argv[0]); - } - } - break; - - case 'm': - if (has_more_argv()) - profile->muxid = argv[opt++][0] - '0' + 0x80; - break; - - case 'n': - if (has_more_argv()) - profile->pdp = argv[opt++][0] - '0'; - break; - - case 'f': - if (has_more_argv()) { - profile->logfile = argv[opt++]; - } - break; - - case 'i': - if (has_more_argv()) { - strncpy(profile->expect_adapter, argv[opt++], sizeof(profile->expect_adapter) - 1); - } - break; - - case 'v': - debug_qmi = 1; - break; - - case 'l': - if (has_more_argv()) { - profile->replication_factor = atoi(argv[opt++]); - if (profile->replication_factor > 0) { - profile->loopback_state = 1; - } - } - break; - - case '4': - profile->enable_ipv4 = 1; - break; - - case '6': - profile->enable_ipv6 = 1; - break; - - case 'u': - if (has_more_argv()) { - profile->usblogfile = argv[opt++]; - } - break; - - case 'b': - profile->enable_bridge = 1; - break; - - case 'k': - if (has_more_argv()) { - profile->kill_pdp = argv[opt++][0] - '0'; - } - break; - - default: - return usage(argv[0]); - break; - } - } - - if (profile->enable_ipv4 != 1 && profile->enable_ipv6 != 1) { // default enable IPv4 - profile->enable_ipv4 = 1; - } - - return 1; -} - -int main(int argc, char *argv[]) -{ - int ret; - PROFILE_T *ctx = &s_profile; - - dbg_time("QConnectManager_Linux_V1.6.4"); - - ret = parse_user_input(argc, argv, ctx); - if (!ret) - return ret; - - if (ctx->kill_pdp) { - return kill_data_call_pdp(ctx->kill_pdp, argv[0]); - } - - if (ctx->logfile) { - logfilefp = fopen(ctx->logfile, "a+"); - if (!logfilefp) { - dbg_time("Fail to open %s, errno: %d(%s)", ctx->logfile, errno, strerror(errno)); - } - } - - signal(SIGINT, ql_sigaction); - signal(SIGTERM, ql_sigaction); - signal(SIGALRM, ql_sigaction); - - do { - ret = quectel_CM(ctx); - if (g_donot_exit_when_modem_hangup > 0) - sleep(3); - } while (g_donot_exit_when_modem_hangup > 0); - - if (logfilefp) { - fclose(logfilefp); - } - - return ret; -} diff --git a/quectel_cm_5G/src/mbim-cm.c b/quectel_cm_5G/src/mbim-cm.c deleted file mode 100644 index b96ff55..0000000 --- a/quectel_cm_5G/src/mbim-cm.c +++ /dev/null @@ -1,2426 +0,0 @@ -/****************************************************************************** - @file mbim-cm.c - @brief MIBIM drivers. - - DESCRIPTION - Connectivity Management Tool for USB network adapter of Quectel wireless cellular modules. - - INITIALIZATION AND SEQUENCING REQUIREMENTS - None. - - --------------------------------------------------------------------------- - Copyright (c) 2016 - 2020 Quectel Wireless Solution, Co., Ltd. All Rights Reserved. - Quectel Wireless Solution Proprietary and Confidential. - --------------------------------------------------------------------------- -******************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "QMIThread.h" - -#define mbim_debug dbg_time - -#define UUID_BASIC_CONNECT "a289cc33-bcbb-8b4f-b6b0-133ec2aae6df" -//https://docs.microsoft.com/en-us/windows-hardware/drivers/network/mb-5g-data-class-support -#define UUID_BASIC_CONNECT_EXT "3d01dcc5-fef5-4d05-0d3a-bef7058e9aaf" -#define UUID_SMS "533fbeeb-14fe-4467-9f90-33a223e56c3f" -#define UUID_USSD "e550a0c8-5e82-479e-82f7-10abf4c3351f" -#define UUID_PHONEBOOK "4bf38476-1e6a-41db-b1d8-bed289c25bdb" -#define UUID_STK "d8f20131-fcb5-4e17-8602-d6ed3816164c" -#define UUID_AUTH "1d2b5ff7-0aa1-48b2-aa52-50f15767174e" -#define UUID_DSS "c08a26dd-7718-4382-8482-6e0d583c4d0e" -#define uuid_ext_qmux "d1a30bc2-f97a-6e43-bf65-c7e24fb0f0d3" -#define uuid_mshsd "883b7c26-985f-43fa-9804-27d7fb80959c" -#define uuid_qmbe "2d0c12c9-0e6a-495a-915c-8d174fe5d63c" -#define UUID_MSFWID "e9f7dea2-feaf-4009-93ce-90a3694103b6" -#define uuid_atds "5967bdcc-7fd2-49a2-9f5c-b2e70e527db3" -#define uuid_qdu "6427015f-579d-48f5-8c54-f43ed1e76f83" -#define UUID_MS_UICC_LOW_LEVEL "c2f6588e-f037-4bc9-8665-f4d44bd09367" -#define UUID_MS_SARControl "68223D04-9F6C-4E0F-822D-28441FB72340" -#define UUID_VOICEEXTENSIONS "8d8b9eba-37be-449b-8f1e-61cb034a702e" -#define UUID_LIBMBIM_PROXY "838cf7fb-8d0d-4d7f-871e-d71dbefbb39b" - -#define UUID_MBIMContextTypeInternet "7E5E2A7E-4E6F-7272-736B-656E7E5E2A7E" - -typedef unsigned char UINT8; -typedef unsigned short UINT16; -typedef unsigned int UINT32; -typedef unsigned long long UINT64; - -#pragma pack(4) -typedef enum { - MBIM_CID_CMD_TYPE_QUERY = 0, - MBIM_CID_CMD_TYPE_SET = 1, -} MBIM_CID_CMD_TYPE_E; - -typedef enum { - MBIM_CID_DEVICE_CAPS = 1, - MBIM_CID_SUBSCRIBER_READY_STATUS = 2, - MBIM_CID_RADIO_STATE = 3, MBIM_CID_PIN = 4, - MBIM_CID_PIN_LIS = 5, - MBIM_CID_HOME_PROVIDER = 6, - MBIM_CID_PREFERRED_PROVIDERS = 7, - MBIM_CID_VISIBLE_PROVIDERS = 8, - MBIM_CID_REGISTER_STATE = 9, - MBIM_CID_PACKET_SERVICE = 10, - MBIM_CID_SIGNAL_STATE = 11, - MBIM_CID_CONNECT = 12, - MBIM_CID_PROVISIONED_CONTEXTS = 13, - MBIM_CID_SERVICE_ACTIVATION = 14, - MBIM_CID_IP_CONFIGURATION = 15, - MBIM_CID_DEVICE_SERVICES = 16, - MBIM_CID_DEVICE_SERVICE_SUBSCRIBE_LIST = 19, - MBIM_CID_PACKET_STATISTICS = 20, - MBIM_CID_NETWORK_IDLE_HINT = 21, - MBIM_CID_EMERGENCY_MODE = 22, - MBIM_CID_IP_PACKET_FILTERS = 23, - MBIM_CID_MULTICARRIER_PROVIDERS = 24, -} UUID_BASIC_CONNECT_CID_E; - -typedef enum{ - MBIM_CID_MS_PROVISIONED_CONTEXT_V2 = 1, - MBIM_CID_MS_NETWORK_BLACKLIST = 2, - MBIM_CID_MS_LTE_ATTACH_CONFIG = 3, - MBIM_CID_MS_LTE_ATTACH_STATUS = 4, - MBIM_CID_MS_SYS_CAPS = 5, - MBIM_CID_MS_DEVICE_CAPS_V2 = 6, - MBIM_CID_MS_DEVICE_SLOT_MAPPING = 7, - MBIM_CID_MS_SLOT_INFO_STATUS = 8, - MBIM_CID_MS_PCO = 9, - MBIM_CID_MS_DEVICE_RESET = 10, - MBIM_CID_MS_BASE_STATIONS_INFO = 11, - MBIM_CID_MS_LOCATION_INFO_STATUS = 12, - MBIM_CID_NOT_DEFINED = 13, - MBIM_CID_MS_PIN_EX = 14, - MBIM_CID_MS_VERSION = 15, -} UUID_BASIC_CONNECT_EXT_CID_E; - -typedef enum { - MBIM_CID_SMS_CONFIGURATION = 1, // Y Y Y - MBIM_CID_SMS_READ = 2, // N Y Y - MBIM_CID_SMS_SEND = 3, // Y N N - MBIM_CID_SMS_DELETE = 4, // Y N N - MBIM_CID_SMS_MESSAGE_STORE_STATUS = 5, // N Y Y -} UUID_SMS_CID_E; - -typedef enum { - MBIM_CID_DSS_CONNECT = 1, // Y N N -} UUID_DSS_CID_E; - -typedef enum{ - MBIM_OPEN_MSG = 1, - MBIM_CLOSE_MSG = 2, - MBIM_COMMAND_MSG = 3, - MBIM_HOST_ERROR_MSG = 4, - MBIM_OPEN_DONE = 0x80000001, - MBIM_CLOSE_DONE = 0x80000002, - MBIM_COMMAND_DONE = 0x80000003, - MBIM_FUNCTION_ERROR_MSG = 0x80000004, - MBIM_INDICATE_STATUS_MSG = 0x80000007, -} MBIM_MSG_Type_E; - -typedef enum { /*< since=1.10 >*/ - MBIM_CID_PROXY_CONTROL_UNKNOWN = 0, - MBIM_CID_PROXY_CONTROL_CONFIGURATION = 1 -} UUID_LIBMBIM_PROXY_CID_E; - -typedef enum { - MBIM_CID_MS_UICC_ATR = 1, - MBIM_CID_MS_UICC_OPEN_CHANNEL = 2, - MBIM_CID_MS_UICC_CLOSE_CHANNEL = 3, - MBIM_CID_MS_UICC_APDU = 4, - MBIM_CID_MS_UICC_TERMINAL_CAPABILITY = 5, - MBIM_CID_MS_UICC_RESET = 6, - MBIM_CID_MS_APP_LIST = 7, -} UUID_MS_UICC_CID_E; - -typedef enum { - MBIM_ERROR_TIMEOUT_FRAGMENT = 1, - MBIM_ERROR_FRAGMENT_OUT_OF_SEQUENCE = 2, - MBIM_ERROR_LENGTH_MISMATCH = 3, - MBIM_ERROR_DUPLICATED_TID = 4, - MBIM_ERROR_NOT_OPENED = 5, - MBIM_ERROR_UNKNOWN = 6, - MBIM_ERROR_CANCEL = 7, - MBIM_ERROR_MAX_TRANSFER = 8, -} MBIM_ERROR_E; - -typedef enum { - MBIM_STATUS_SUCCESS = 0, - MBIM_STATUS_BUSY = 1, - MBIM_STATUS_FAILURE = 2, - MBIM_STATUS_SIM_NOT_INSERTED = 3, - MBIM_STATUS_BAD_SIM = 4, - MBIM_STATUS_PIN_REQUIRED = 5, - MBIM_STATUS_PIN_DISABLED = 6, - MBIM_STATUS_NOT_REGISTERED = 7, - MBIM_STATUS_PROVIDERS_NOT_FOUND = 8, - MBIM_STATUS_NO_DEVICE_SUPPORT = 9, - MBIM_STATUS_PROVIDER_NOT_VISIBLE = 10, - MBIM_STATUS_DATA_CLASS_NOT_AVAILABL = 11, - MBIM_STATUS_PACKET_SERVICE_DETACHED = 12, -} MBIM_STATUS_CODES_E; - -typedef enum { - MBIMPacketServiceActionAttach = 0, - MBIMPacketServiceActionDetach = 1, -} MBIM_PACKET_SERVICE_ACTION_E; - -typedef enum { - MBIMPacketServiceStateUnknown = 0, - MBIMPacketServiceStateAttaching = 1, - MBIMPacketServiceStateAttached = 2, - MBIMPacketServiceStateDetaching = 3, - MBIMPacketServiceStateDetached = 4, -} MBIM_PACKET_SERVICE_STATE_E; - -static const char *MBIMPacketServiceStateStr(int _val) { - struct { int val;char *name;} _enumstr[] = { - {MBIMPacketServiceStateUnknown, "Unknown"}, - {MBIMPacketServiceStateAttaching, "Attaching"}, - {MBIMPacketServiceStateAttached, "Attached"}, - {MBIMPacketServiceStateDetaching, "Detaching"}, - {MBIMPacketServiceStateDetached, "Detached"}, - }; - int idx; - - for (idx = 0; idx < (int)(sizeof(_enumstr)/sizeof(_enumstr[0])); idx++) { - if (_val == _enumstr[idx].val) - return _enumstr[idx].name; - } - - return "Undefined"; -}; - -typedef enum { - MBIMDataClassNone = 0x0, - MBIMDataClassGPRS = 0x1, - MBIMDataClassEDGE = 0x2, - MBIMDataClassUMTS = 0x4, - MBIMDataClassHSDPA = 0x8, - MBIMDataClassHSUPA = 0x10, - MBIMDataClassLTE = 0x20, - MBIMDataClass5G_NSA = 0x40, - MBIMDataClass5G_SA = 0x80, - MBIMDataClass1XRTT = 0x10000, - MBIMDataClass1XEVDO = 0x20000, - MBIMDataClass1XEVDORevA = 0x40000, - MBIMDataClass1XEVDV = 0x80000, - MBIMDataClass3XRTT = 0x100000, - MBIMDataClass1XEVDORevB = 0x200000, - MBIMDataClassUMB = 0x400000, - MBIMDataClassCustom = 0x80000000, -} MBIM_DATA_CLASS_E; - -static const char *MBIMDataClassStr(int _val) { - struct { int val;char *name;} _enumstr[] = { - {MBIMDataClassNone, "None"}, - {MBIMDataClassGPRS, "GPRS"}, - {MBIMDataClassEDGE, "EDGE"}, - {MBIMDataClassUMTS, "UMTS"}, - {MBIMDataClassHSDPA, "HSDPA"}, - {MBIMDataClassHSUPA, "HSUPA"}, - {MBIMDataClassLTE, "LTE"}, - {MBIMDataClass5G_NSA, "5G_NSA"}, - {MBIMDataClass5G_SA, "5G_SA"}, - {MBIMDataClass1XRTT, "1XRTT"}, - {MBIMDataClass1XEVDO, "1XEVDO"}, - {MBIMDataClass1XEVDORevA, "1XEVDORevA"}, - {MBIMDataClass1XEVDV, "1XEVDV"}, - {MBIMDataClass3XRTT, "3XRTT"}, - {MBIMDataClass1XEVDORevB, "1XEVDORevB"}, - {MBIMDataClassUMB, "UMB"}, - {MBIMDataClassCustom, "Custom"}, - }; - int idx; - - for (idx = 0; idx < (int)(sizeof(_enumstr)/sizeof(_enumstr[0])); idx++) { - if (_val == _enumstr[idx].val) - return _enumstr[idx].name; - } - - return "Unknow"; -}; - -typedef struct { - UINT32 NwError; - UINT32 PacketServiceState; //MBIM_PACKET_SERVICE_STATE_E - UINT32 HighestAvailableDataClass; //MBIM_DATA_CLASS_E - UINT64 UplinkSpeed; - UINT64 DownlinkSpeed; -} MBIM_PACKET_SERVICE_INFO_T; - -typedef struct { - UINT32 NwError; - UINT32 PacketServiceState; //MBIM_PACKET_SERVICE_STATE_E - UINT32 CurrentDataClass; //MBIM_DATA_CLASS_E - UINT64 UplinkSpeed; - UINT64 DownlinkSpeed; - UINT32 FrequencyRange; -} MBIM_PACKET_SERVICE_INFO_V2_T; - -typedef enum { - MBIMSubscriberReadyStateNotInitialized = 0, - MBIMSubscriberReadyStateInitialized = 1, - MBIMSubscriberReadyStateSimNotInserted = 2, - MBIMSubscriberReadyStateBadSim = 3, - MBIMSubscriberReadyStateFailure = 4, - MBIMSubscriberReadyStateNotActivated = 5, - MBIMSubscriberReadyStateDeviceLocked = 6, -}MBIM_SUBSCRIBER_READY_STATE_E; - -static const char *MBIMSubscriberReadyStateStr(int _val) { - struct { int val;char *name;} _enumstr[] = { - {MBIMSubscriberReadyStateNotInitialized, "NotInitialized"}, - {MBIMSubscriberReadyStateInitialized, "Initialized"}, - {MBIMSubscriberReadyStateSimNotInserted, "NotInserted"}, - {MBIMSubscriberReadyStateBadSim, "BadSim"}, - {MBIMSubscriberReadyStateFailure, "Failure"}, - {MBIMSubscriberReadyStateNotActivated, "NotActivated"}, - {MBIMSubscriberReadyStateDeviceLocked, "DeviceLocked"}, - }; - int idx; - - for (idx = 0; idx < (int)(sizeof(_enumstr)/sizeof(_enumstr[0])); idx++) { - if (_val == _enumstr[idx].val) - return _enumstr[idx].name; - } - - return "Undefined"; -}; - -typedef struct { - UINT32 DeviceType; //MBIM_DEVICE_TYPE - UINT32 CellularClass; //MBIM_CELLULAR_CLASS - UINT32 VoiceClass; //MBIM_VOICE_CLASS - UINT32 SimClass; //MBIM_SIM_CLASS - UINT32 DataClass; //MBIM_DATA_CLASS - UINT32 SmsCaps; //MBIM_SMS_CAPS - UINT32 ControlCaps; //MBIM_CTRL_CAPS - UINT32 MaxSessions; - UINT32 CustomDataClassOffset; - UINT32 CustomDataClassSize; - UINT32 DeviceIdOffset; - UINT32 DeviceIdSize; - UINT32 FirmwareInfoOffset; - UINT32 FirmwareInfoSize; - UINT32 HardwareInfoOffset; - UINT32 HardwareInfoSize; - UINT8 DataBuffer[0]; //DeviceId FirmwareInfo HardwareInfo -} MBIM_DEVICE_CAPS_INFO_T; - -typedef enum { - MBIMRadioOff = 0, - MBIMRadioOn = 1, -} MBIM_RADIO_SWITCH_STATE_E; - -typedef struct { - MBIM_RADIO_SWITCH_STATE_E RadioState; -} MBIM_SET_RADIO_STATE_T; - -typedef struct { - MBIM_RADIO_SWITCH_STATE_E HwRadioState; - MBIM_RADIO_SWITCH_STATE_E SwRadioState; -} MBIM_RADIO_STATE_INFO_T; - -typedef enum { - MBIMReadyInfoFlagsNone, - MBIMReadyInfoFlagsProtectUniqueID, -}MBIM_UNIQUE_ID_FLAGS; - -typedef struct { - UINT32 ReadyState; - UINT32 SubscriberIdOffset; - UINT32 SubscriberIdSize; - UINT32 SimIccIdOffset; - UINT32 SimIccIdSize; - UINT32 ReadyInfo; - UINT32 ElementCount; - UINT8 *TelephoneNumbersRefList; - UINT8 *DataBuffer; -} MBIM_SUBSCRIBER_READY_STATUS_T; - -typedef enum { - MBIMRegisterActionAutomatic, - MBIMRegisterActionManual, -}MBIM_REGISTER_ACTION_E; - -typedef enum { - MBIMRegisterStateUnknown = 0, - MBIMRegisterStateDeregistered = 1, - MBIMRegisterStateSearching = 2, - MBIMRegisterStateHome = 3, - MBIMRegisterStateRoaming = 4, - MBIMRegisterStatePartner = 5, - MBIMRegisterStateDenied = 6, -}MBIM_REGISTER_STATE_E; - -typedef enum { - MBIMRegisterModeUnknown = 0, - MBIMRegisterModeAutomatic = 1, - MBIMRegisterModeManual = 2, -}MBIM_REGISTER_MODE_E; - -static const char *MBIMRegisterStateStr(int _val) { - struct { int val;char *name;} _enumstr[] ={ - {MBIMRegisterStateUnknown, "Unknown"}, - {MBIMRegisterStateDeregistered, "Deregistered"}, - {MBIMRegisterStateSearching, "Searching"}, - {MBIMRegisterStateHome, "Home"}, - {MBIMRegisterStateRoaming, "Roaming"}, - {MBIMRegisterStatePartner, "Partner"}, - {MBIMRegisterStateDenied, "Denied"}, - }; - int idx; - - for (idx = 0; idx < (int)(sizeof(_enumstr)/sizeof(_enumstr[0])); idx++) { - if (_val == _enumstr[idx].val) - return _enumstr[idx].name; - } - - return "Undefined"; -}; - -static const char *MBIMRegisterModeStr(int _val) { - struct { int val;char *name;} _enumstr[] = { - {MBIMRegisterModeUnknown, "Unknown"}, - {MBIMRegisterModeAutomatic, "Automatic"}, - {MBIMRegisterModeManual, "Manual"}, - }; - int idx; - - for (idx = 0; idx < (int)(sizeof(_enumstr)/sizeof(_enumstr[0])); idx++) { - if (_val == _enumstr[idx].val) - return _enumstr[idx].name; - } - - return "Undefined"; -}; - -typedef enum { - MBIM_REGISTRATION_NONE, - MBIM_REGISTRATION_MANUAL_SELECTION_NOT_AVAILABLE, - MBIM_REGISTRATION_PACKET_SERVICE_AUTOMATIC_ATTACH, -}MBIM_REGISTRATION_FLAGS_E; - -typedef struct { - UINT32 NwError; - UINT32 RegisterState; //MBIM_REGISTER_STATE_E - UINT32 RegisterMode; - UINT32 AvailableDataClasses; - UINT32 CurrentCellularClass; - UINT32 ProviderIdOffset; - UINT32 ProviderIdSize; - UINT32 ProviderNameOffset; - UINT32 ProviderNameSize; - UINT32 RoamingTextOffset; - UINT32 RoamingTextSize; - UINT32 RegistrationFlag; - UINT8 *DataBuffer; -} MBIM_REGISTRATION_STATE_INFO_T; - -typedef struct { - UINT32 NwError; - UINT32 RegisterState; //MBIM_REGISTER_STATE_E - UINT32 RegisterMode; - UINT32 AvailableDataClasses; - UINT32 CurrentCellularClass; - UINT32 ProviderIdOffset; - UINT32 ProviderIdSize; - UINT32 ProviderNameOffset; - UINT32 ProviderNameSize; - UINT32 RoamingTextOffset; - UINT32 RoamingTextSize; - UINT32 RegistrationFlag; - UINT32 PreferredDataClass; - UINT8 *DataBuffer; -} MBIM_REGISTRATION_STATE_INFO_V2_T; - -typedef struct { - UINT32 MessageType; //Specifies the MBIM message type. - UINT32 MessageLength; //Specifies the total length of this MBIM message in bytes. - /* Specifies the MBIM message id value. This value is used to match host sent messages with function responses. - This value must be unique among all outstanding transactions. - For notifications, the TransactionId must be set to 0 by the function */ - UINT32 TransactionId; -} MBIM_MESSAGE_HEADER; - -typedef struct { - UINT32 TotalFragments; //this field indicates how many fragments there are intotal. - UINT32 CurrentFragment; //This field indicates which fragment this message is. Values are 0 to TotalFragments?\1 -} MBIM_FRAGMENT_HEADER; - -typedef struct { - MBIM_MESSAGE_HEADER MessageHeader; - UINT32 MaxControlTransfer; -} MBIM_OPEN_MSG_T; - -typedef struct { - MBIM_MESSAGE_HEADER MessageHeader; - UINT32 Status; //MBIM_STATUS_CODES_E -} MBIM_OPEN_DONE_T; - -typedef struct { - MBIM_MESSAGE_HEADER MessageHeader; -} MBIM_CLOSE_MSG_T; - -typedef struct { - MBIM_MESSAGE_HEADER MessageHeader; - UINT32 Status; -} MBIM_CLOSE_DONE_T; - -typedef struct { - UINT8 uuid[16]; -} UUID_T; - -typedef struct { - MBIM_MESSAGE_HEADER MessageHeader; - MBIM_FRAGMENT_HEADER FragmentHeader; - UUID_T DeviceServiceId; //A 16 byte UUID that identifies the device service the following CID value applies. - UINT32 CID; //Specifies the CID that identifies the parameter being queried for - UINT32 CommandType; //0 for a query operation, 1 for a Set operation - UINT32 InformationBufferLength; //Size of the Total InformationBuffer, may be larger than current message if fragmented. - UINT8 InformationBuffer[0]; //Data supplied to device specific to the CID -} MBIM_COMMAND_MSG_T; - -typedef struct { - MBIM_MESSAGE_HEADER MessageHeader; - MBIM_FRAGMENT_HEADER FragmentHeader; - UUID_T DeviceServiceId; //A 16 byte UUID that identifies the device service the following CID value applies. - UINT32 CID; //Specifies the CID that identifies the parameter being queried for - UINT32 Status; - UINT32 InformationBufferLength; //Size of the Total InformationBuffer, may be larger than current message if fragmented. - UINT8 InformationBuffer[0]; //Data supplied to device specific to the CID -} MBIM_COMMAND_DONE_T; - -typedef struct { - MBIM_MESSAGE_HEADER MessageHeader; - UINT32 ErrorStatusCode; -} MBIM_HOST_ERROR_MSG_T; - -typedef struct { - MBIM_MESSAGE_HEADER MessageHeader; - UINT32 ErrorStatusCode; -} MBIM_FUNCTION_ERROR_MSG_T; - -typedef struct { - MBIM_MESSAGE_HEADER MessageHeader; - MBIM_FRAGMENT_HEADER FragmentHeader; - UUID_T DeviceServiceId; //A 16 byte UUID that identifies the device service the following CID value applies. - UINT32 CID; //Specifies the CID that identifies the parameter being queried for - UINT32 InformationBufferLength; //Size of the Total InformationBuffer, may be larger than current message if fragmented. - UINT8 InformationBuffer[0]; //Data supplied to device specific to the CID -} MBIM_INDICATE_STATUS_MSG_T; - -typedef struct { - UINT32 offset; - UINT32 size; -} OL_PAIR_LIST; - -typedef struct { - UUID_T DeviceServiceId; - UINT32 DssPayload; - UINT32 MaxDssInstances; - UINT32 CidCount; - UINT32 CidList[]; -} MBIM_DEVICE_SERVICE_ELEMENT_T; - -typedef struct { - UINT32 DeviceServicesCount; - UINT32 MaxDssSessions; - OL_PAIR_LIST DeviceServicesRefList[]; -} MBIM_DEVICE_SERVICES_INFO_T; - -typedef enum { - MBIMActivationCommandDeactivate = 0, - MBIMActivationCommandActivate = 1, -} MBIM_ACTIVATION_COMMAND_E; - -typedef enum { - MBIMCompressionNone = 0, - MBIMCompressionEnable = 1, -} MBIM_COMPRESSION_E; - -typedef enum { - MBIMAuthProtocolNone = 0, - MBIMAuthProtocolPap = 1, - MBIMAuthProtocolChap = 2, - MBIMAuthProtocolMsChapV2 = 3, -} MBIM_AUTH_PROTOCOL_E; - -typedef enum { - MBIMContextIPTypeDefault = 0, - MBIMContextIPTypeIPv4 = 1, - MBIMContextIPTypeIPv6 = 2, - MBIMContextIPTypeIPv4v6 = 3, - MBIMContextIPTypeIPv4AndIPv6 = 4, -} MBIM_CONTEXT_IP_TYPE_E; - -typedef enum { - MBIMActivationStateUnknown = 0, - MBIMActivationStateActivated = 1, - MBIMActivationStateActivating = 2, - MBIMActivationStateDeactivated = 3, - MBIMActivationStateDeactivating = 4, -} MBIM_ACTIVATION_STATE_E; - -typedef enum { - MBIMVoiceCallStateNone = 0, - MBIMVoiceCallStateInProgress = 1, - MBIMVoiceCallStateHangUp = 2, -} MBIM_VOICECALL_STATE_E; - -static const char *MBIMMSGTypeStr(int _val) { - struct { int val;char *name;} _enumstr[] = { - {MBIM_OPEN_MSG, "MBIM_OPEN_MSG"}, - {MBIM_CLOSE_MSG, "MBIM_CLOSE_MSG"}, - {MBIM_COMMAND_MSG, "MBIM_COMMAND_MSG"}, - {MBIM_HOST_ERROR_MSG, "MBIM_HOST_ERROR_MSG"}, - {MBIM_OPEN_DONE, "MBIM_OPEN_DONE"}, - {MBIM_CLOSE_DONE, "MBIM_CLOSE_DONE"}, - {MBIM_COMMAND_DONE, "MBIM_COMMAND_DONE"}, - {MBIM_FUNCTION_ERROR_MSG, "MBIM_FUNCTION_ERROR_MSG"}, - {MBIM_INDICATE_STATUS_MSG, "MBIM_INDICATE_STATUS_MSG"}, - }; - int idx; - - for (idx = 0; idx < (int)(sizeof(_enumstr)/sizeof(_enumstr[0])); idx++) { - if (_val == _enumstr[idx].val) - return _enumstr[idx].name; - } - - return "MBIMMSGTypeUnknow"; -}; - -static const char *MBIMContextIPTypeStr(int _val) { - struct { int val;char *name;} _enumstr[] = { - {MBIMContextIPTypeDefault, "MBIMContextIPTypeDefault"}, - {MBIMContextIPTypeIPv4, "MBIMContextIPTypeIPv4"}, - {MBIMContextIPTypeIPv6, "MBIMContextIPTypeIPv6"}, - {MBIMContextIPTypeIPv4v6, "MBIMContextIPTypeIPv4v6"}, - {MBIMContextIPTypeIPv4AndIPv6, "MBIMContextIPTypeIPv4AndIPv6"}, - }; - int idx; - - for (idx = 0; idx < (int)(sizeof(_enumstr)/sizeof(_enumstr[0])); idx++) { - if (_val == _enumstr[idx].val) - return _enumstr[idx].name; - } - - return "MBIMContextIPTypeUnknow"; -} - -static const char *MBIMActivationStateStr(int _val) { - struct { int val;char *name;} _enumstr[] = { - {MBIMActivationStateUnknown, "Unknown"}, - {MBIMActivationStateActivated, "Activated"}, - {MBIMActivationStateActivating, "Activating"}, - {MBIMActivationStateDeactivated, "Deactivated"}, - {MBIMActivationStateDeactivating, "Deactivating"}, - }; - int idx; - - for (idx = 0; idx < (int)(sizeof(_enumstr)/sizeof(_enumstr[0])); idx++) { - if (_val == _enumstr[idx].val) - return _enumstr[idx].name; - } - - return "Undefined"; -}; - -static const char *MBIMVoiceCallStateStr(int _val) { - struct { int val;char *name;} _enumstr[] = { - {MBIMVoiceCallStateNone, "None"}, - {MBIMVoiceCallStateInProgress, "InProgress"}, - {MBIMVoiceCallStateHangUp, "HangUp"}, - }; - int idx; - - for (idx = 0; idx < (int)(sizeof(_enumstr)/sizeof(_enumstr[0])); idx++) { - if (_val == _enumstr[idx].val) - return _enumstr[idx].name; - } - - return "Undefined"; -}; - -typedef struct { - const char *uuid; - UINT32 cid; - const char *name; -} UUID_CID_STR; - -static const UUID_CID_STR uuid_cid_string[] = { - {UUID_BASIC_CONNECT, MBIM_CID_DEVICE_CAPS, "MBIM_CID_DEVICE_CAPS"}, - {UUID_BASIC_CONNECT, MBIM_CID_SUBSCRIBER_READY_STATUS, "MBIM_CID_SUBSCRIBER_READY_STATUS"}, - {UUID_BASIC_CONNECT, MBIM_CID_RADIO_STATE, "MBIM_CID_RADIO_STATE"}, - {UUID_BASIC_CONNECT, MBIM_CID_PIN, "MBIM_CID_PIN"}, - {UUID_BASIC_CONNECT, MBIM_CID_PIN_LIS, "MBIM_CID_PIN_LIS"}, - {UUID_BASIC_CONNECT, MBIM_CID_HOME_PROVIDER, "MBIM_CID_HOME_PROVIDER"}, - {UUID_BASIC_CONNECT, MBIM_CID_PREFERRED_PROVIDERS, "MBIM_CID_PREFERRED_PROVIDERS"}, - {UUID_BASIC_CONNECT, MBIM_CID_VISIBLE_PROVIDERS, "MBIM_CID_VISIBLE_PROVIDERS"}, - {UUID_BASIC_CONNECT, MBIM_CID_REGISTER_STATE, "MBIM_CID_REGISTER_STATE"}, - {UUID_BASIC_CONNECT, MBIM_CID_PACKET_SERVICE, "MBIM_CID_PACKET_SERVICE"}, - {UUID_BASIC_CONNECT, MBIM_CID_SIGNAL_STATE, "MBIM_CID_SIGNAL_STATE"}, - {UUID_BASIC_CONNECT, MBIM_CID_CONNECT, "MBIM_CID_CONNECT"}, - {UUID_BASIC_CONNECT, MBIM_CID_PROVISIONED_CONTEXTS, "MBIM_CID_PROVISIONED_CONTEXTS"}, - {UUID_BASIC_CONNECT, MBIM_CID_SERVICE_ACTIVATION, "MBIM_CID_SERVICE_ACTIVATION"}, - {UUID_BASIC_CONNECT, MBIM_CID_IP_CONFIGURATION, "MBIM_CID_IP_CONFIGURATION"}, - {UUID_BASIC_CONNECT, MBIM_CID_DEVICE_SERVICES, "MBIM_CID_DEVICE_SERVICES"}, - {UUID_BASIC_CONNECT, MBIM_CID_DEVICE_SERVICE_SUBSCRIBE_LIST, "MBIM_CID_DEVICE_SERVICE_SUBSCRIBE_LIST"}, - {UUID_BASIC_CONNECT, MBIM_CID_PACKET_STATISTICS, "MBIM_CID_PACKET_STATISTICS"}, - {UUID_BASIC_CONNECT, MBIM_CID_NETWORK_IDLE_HINT, "MBIM_CID_NETWORK_IDLE_HINT"}, - {UUID_BASIC_CONNECT, MBIM_CID_EMERGENCY_MODE, "MBIM_CID_EMERGENCY_MODE"}, - {UUID_BASIC_CONNECT, MBIM_CID_IP_PACKET_FILTERS, "MBIM_CID_IP_PACKET_FILTERS"}, - {UUID_BASIC_CONNECT, MBIM_CID_MULTICARRIER_PROVIDERS, "MBIM_CID_MULTICARRIER_PROVIDERS"}, - - {UUID_BASIC_CONNECT_EXT, MBIM_CID_MS_PROVISIONED_CONTEXT_V2, "MBIM_CID_MS_PROVISIONED_CONTEXT_V2"}, - {UUID_BASIC_CONNECT_EXT, MBIM_CID_MS_NETWORK_BLACKLIST, "MBIM_CID_MS_NETWORK_BLACKLIST"}, - {UUID_BASIC_CONNECT_EXT, MBIM_CID_MS_LTE_ATTACH_CONFIG, "MBIM_CID_MS_LTE_ATTACH_CONFIG"}, - {UUID_BASIC_CONNECT_EXT, MBIM_CID_MS_LTE_ATTACH_STATUS, "MBIM_CID_MS_LTE_ATTACH_STATUS"}, - {UUID_BASIC_CONNECT_EXT, MBIM_CID_MS_SYS_CAPS, "MBIM_CID_MS_SYS_CAPS"}, - {UUID_BASIC_CONNECT_EXT, MBIM_CID_MS_DEVICE_CAPS_V2, "MBIM_CID_MS_DEVICE_CAPS_V2"}, - {UUID_BASIC_CONNECT_EXT, MBIM_CID_MS_DEVICE_SLOT_MAPPING, "MBIM_CID_MS_DEVICE_SLOT_MAPPING"}, - {UUID_BASIC_CONNECT_EXT, MBIM_CID_MS_SLOT_INFO_STATUS, "MBIM_CID_MS_SLOT_INFO_STATUS"}, - {UUID_BASIC_CONNECT_EXT, MBIM_CID_MS_PCO, "MBIM_CID_MS_PCO"}, - {UUID_BASIC_CONNECT_EXT, MBIM_CID_MS_DEVICE_RESET, "MBIM_CID_MS_DEVICE_RESET"}, - {UUID_BASIC_CONNECT_EXT, MBIM_CID_MS_BASE_STATIONS_INFO, "MBIM_CID_MS_BASE_STATIONS_INFO"}, - {UUID_BASIC_CONNECT_EXT, MBIM_CID_MS_LOCATION_INFO_STATUS, "MBIM_CID_MS_LOCATION_INFO_STATUS"}, - {UUID_BASIC_CONNECT_EXT, MBIM_CID_NOT_DEFINED, "MBIM_CID_NOT_DEFINED"}, - {UUID_BASIC_CONNECT_EXT, MBIM_CID_MS_PIN_EX, "MBIM_CID_MS_PIN_EX"}, - {UUID_BASIC_CONNECT_EXT, MBIM_CID_MS_VERSION, "MBIM_CID_MS_VERSION"}, - - {UUID_MS_UICC_LOW_LEVEL, MBIM_CID_MS_UICC_ATR, "MBIM_CID_MS_UICC_ATR"}, - {UUID_MS_UICC_LOW_LEVEL, MBIM_CID_MS_UICC_OPEN_CHANNEL, "MBIM_CID_MS_UICC_OPEN_CHANNEL"}, - {UUID_MS_UICC_LOW_LEVEL, MBIM_CID_MS_UICC_CLOSE_CHANNEL, "MBIM_CID_MS_UICC_CLOSE_CHANNEL"}, - {UUID_MS_UICC_LOW_LEVEL, MBIM_CID_MS_UICC_APDU, "MBIM_CID_MS_UICC_APDU"}, - {UUID_MS_UICC_LOW_LEVEL, MBIM_CID_MS_UICC_TERMINAL_CAPABILITY, "MBIM_CID_MS_UICC_TERMINAL_CAPABILITY"}, - {UUID_MS_UICC_LOW_LEVEL, MBIM_CID_MS_UICC_RESET, "MBIM_CID_MS_UICC_RESET"}, - {UUID_MS_UICC_LOW_LEVEL, MBIM_CID_MS_APP_LIST, "MBIM_CID_MS_APP_LIST"}, -}; - -typedef struct { - UINT32 SessionId; - UINT32 ActivationCommand; //MBIM_ACTIVATION_COMMAND_E - UINT32 AccessStringOffset; - UINT32 AccessStringSize; - UINT32 UserNameOffset; - UINT32 UserNameSize; - UINT32 PasswordOffset; - UINT32 PasswordSize; - UINT32 Compression; //MBIM_COMPRESSION_E - UINT32 AuthProtocol; //MBIM_AUTH_PROTOCOL_E - UINT32 IPType; //MBIM_CONTEXT_IP_TYPE_E - UUID_T ContextType; - UINT8 DataBuffer[0]; /* apn, username, password */ -} MBIM_SET_CONNECT_T; - -typedef struct { - UINT32 SessionId; - UINT32 ActivationState; //MBIM_ACTIVATION_STATE_E - UINT32 VoiceCallState; - UINT32 IPType; //MBIM_CONTEXT_IP_TYPE_E - UUID_T ContextType; - UINT32 NwError; -} MBIM_CONNECT_T; - -typedef struct { - UINT32 OnLinkPrefixLength; - UINT8 IPv4Address[4]; -} MBIM_IPV4_ELEMENT_T; - -typedef struct { - UINT32 OnLinkPrefixLength; - UINT8 IPv6Address[16]; -} MBIM_IPV6_ELEMENT_T; - -typedef struct { - UINT32 SessionId; - UINT32 IPv4ConfigurationAvailable; //bit0~Address, bit1~gateway, bit2~DNS, bit3~MTU - UINT32 IPv6ConfigurationAvailable; //bit0~Address, bit1~gateway, bit2~DNS, bit3~MTU - UINT32 IPv4AddressCount; - UINT32 IPv4AddressOffset; - UINT32 IPv6AddressCount; - UINT32 IPv6AddressOffset; - UINT32 IPv4GatewayOffset; - UINT32 IPv6GatewayOffset; - UINT32 IPv4DnsServerCount; - UINT32 IPv4DnsServerOffset; - UINT32 IPv6DnsServerCount; - UINT32 IPv6DnsServerOffset; - UINT32 IPv4Mtu; - UINT32 IPv6Mtu; - UINT8 DataBuffer[]; -} MBIM_IP_CONFIGURATION_INFO_T; - -typedef struct { - UINT32 RSRP; - UINT32 SNR; - UINT32 RSRPThreshold; - UINT32 SNRThreshold; - UINT32 SystemType; -} MBIM_RSRP_SNR_INFO_T; - -typedef struct { - UINT32 Elementcount; - MBIM_RSRP_SNR_INFO_T RsrpSnr[0]; -} MBIM_RSRP_SNR_T; - -typedef struct { - UINT32 Rssi; - UINT32 ErrorRate; - UINT32 SignalStrengthInterval; - UINT32 RssiThreshold; - UINT32 ErrorRateThreshold; -} MBIM_SIGNAL_STATE_INFO_T; - -typedef struct { - UINT32 Rssi; - UINT32 ErrorRate; - UINT32 SignalStrengthInterval; - UINT32 RssiThreshold; - UINT32 ErrorRateThreshold; - UINT32 RsrpSnrOffset; - UINT32 RsrpSnrSize; - UINT8 DataBuffer[]; -} MBIM_SIGNAL_STATE_INFO_V2_T; - -typedef struct { - UINT32 SignalStrengthInterval; - UINT32 RssiThreshold; - UINT32 ErrorRateThreshold; -} MBIM_SET_SIGNAL_STATE_T; - -typedef struct { - UINT32 DevicePathOffset; - UINT32 DevicePathSize; - UINT32 Timeout; - UINT8 DataBuffer[]; -} MBIM_LIBQMI_PROXY_CONFIG_T; - -typedef struct { - UINT32 AtrSize; - UINT32 AtrOffset; - UINT8 DataBuffer[]; -} MBIM_MS_ATR_INFO_T; - -#pragma pack() - -static pthread_t s_tid_reader = 0; -static int mbim_verbose = 0; -static UINT32 TransactionId = 1; -static unsigned mbim_default_timeout = 30000; -static const char *mbim_apn = NULL; -static const char *mbim_user = NULL; -static const char *mbim_passwd = NULL; -static int mbim_iptype = MBIMContextIPTypeDefault; -static int mbim_auth = MBIMAuthProtocolNone; -static int mbim_sessionID = 0; -static int mbim_fd = -1; -static MBIM_MESSAGE_HEADER *mbim_pRequest; -static MBIM_MESSAGE_HEADER *mbim_pResponse; - -static unsigned int qmi_over_mbim_support = 0; -static int qmi_over_mbim_sk[2] = {-1, -1}; -static pthread_mutex_t mbim_command_mutex = PTHREAD_MUTEX_INITIALIZER; -static pthread_cond_t mbim_command_cond = PTHREAD_COND_INITIALIZER; -static int mbim_ms_version = 1; -static uint8_t qmi_over_mbim_nas = 0; -int qmi_over_mbim_qmidev_send(PQCQMIMSG pQMI); - -static const UUID_T * str2uuid(const char *str) { - static UUID_T uuid; - UINT32 d[16]; - char tmp[16*2+4+1]; - unsigned i = 0; - - while (str[i]) { - tmp[i] = tolower(str[i]); - i++; - } - tmp[i] = '\0'; - - sscanf(tmp, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", - &d[0], &d[1], &d[2], &d[3], &d[4], &d[5], &d[6], &d[7], - &d[8], &d[9], &d[10], &d[11], &d[12], &d[13], &d[14], &d[15]); - - for (i = 0; i < 16; i++) { - uuid.uuid[i] = d[i]&0xFF; - } - - return &uuid; -} - -static void wchar2char(const char *src, size_t src_size, char *dst, size_t dst_len) { - size_t i; - - for (i = 0; i < (dst_len-1) && i < (src_size/2); i++) - dst[i] = src[i*2]; - dst[i] = 0; -} - -static size_t char2wchar(const char *src, size_t src_len, uint8_t *dst, size_t dst_len) { - size_t i; - - if (src_len > (dst_len/2)) - src_len = (dst_len/2); - - for (i = 0; i < src_len; i++) { - *dst++ = *src++; - *dst++ = 0; - } - - return i*2; -} - -#define mbim_alloc( _size) malloc(_size) -#define mbim_free(_mem) do { if (_mem) { free(_mem); _mem = NULL;}} while(0) - -static int mbim_open_state = 0; -static MBIM_SUBSCRIBER_READY_STATE_E ReadyState = MBIMSubscriberReadyStateNotInitialized; -static MBIM_REGISTER_STATE_E RegisterState = MBIMRegisterStateUnknown; -static MBIM_PACKET_SERVICE_STATE_E PacketServiceState = MBIMPacketServiceStateUnknown; -static MBIM_ACTIVATION_STATE_E ActivationState = MBIMActivationStateUnknown; -static MBIM_SUBSCRIBER_READY_STATE_E oldReadyState = MBIMSubscriberReadyStateNotInitialized; -static MBIM_REGISTER_STATE_E oldRegisterState = MBIMRegisterStateUnknown; -static MBIM_PACKET_SERVICE_STATE_E oldPacketServiceState = MBIMPacketServiceStateUnknown; -static MBIM_ACTIVATION_STATE_E oldActivationState = MBIMActivationStateUnknown; -static int mbim_update_state(void); - -static __inline uint32_t mbim2qmi_ipv4addr(uint32_t addr) { - return (addr>>24) | (addr>>8&0xff00) | (addr<<8&0xff0000) | (addr<<24); -} - -static __inline void mbim2qmi_ipv6addr(const unsigned char *src, unsigned char *dst) { - int i; - - for (i = 0; i < 16 ; i++) { - dst[i] = src[i]; - } -} - -static MBIM_MESSAGE_HEADER *compose_open_command(UINT32 MaxControlTransfer) -{ - MBIM_OPEN_MSG_T *pRequest = (MBIM_OPEN_MSG_T *)mbim_alloc(sizeof(MBIM_OPEN_MSG_T)); - - if(!pRequest) - return NULL; - - pRequest->MessageHeader.MessageType = htole32(MBIM_OPEN_MSG); - pRequest->MessageHeader.MessageLength = htole32(sizeof(MBIM_OPEN_MSG_T)); - pRequest->MessageHeader.TransactionId = htole32(TransactionId++); - pRequest->MaxControlTransfer = htole32(MaxControlTransfer); - - return &pRequest->MessageHeader; -} - -static MBIM_MESSAGE_HEADER *compose_close_command(void) -{ - MBIM_CLOSE_MSG_T *pRequest = (MBIM_CLOSE_MSG_T *)mbim_alloc(sizeof(MBIM_CLOSE_MSG_T)); - - if(!pRequest) - return NULL; - - pRequest->MessageHeader.MessageType = htole32(MBIM_CLOSE_MSG); - pRequest->MessageHeader.MessageLength = htole32(sizeof(MBIM_CLOSE_MSG_T)); - pRequest->MessageHeader.TransactionId = htole32(TransactionId++); - - return &pRequest->MessageHeader; -} - -static MBIM_MESSAGE_HEADER *compose_basic_connect_command(UINT32 CID, UINT32 CommandType, void *pInformationBuffer, UINT32 InformationBufferLength) -{ - MBIM_COMMAND_MSG_T *pRequest = (MBIM_COMMAND_MSG_T *)mbim_alloc(sizeof(MBIM_COMMAND_MSG_T) + InformationBufferLength); - - if (!pRequest) - return NULL; - - pRequest->MessageHeader.MessageType = htole32(MBIM_COMMAND_MSG); - pRequest->MessageHeader.MessageLength = htole32((sizeof(MBIM_COMMAND_MSG_T) + InformationBufferLength)); - pRequest->MessageHeader.TransactionId = htole32(TransactionId++); - - pRequest->FragmentHeader.TotalFragments = htole32(1); - pRequest->FragmentHeader.CurrentFragment= htole32(0); - - memcpy(pRequest->DeviceServiceId.uuid, str2uuid(UUID_BASIC_CONNECT), 16); - - pRequest->CID = htole32(CID); - pRequest->CommandType = htole32(CommandType); - if (InformationBufferLength && pInformationBuffer) { - pRequest->InformationBufferLength = htole32(InformationBufferLength); - memcpy(pRequest->InformationBuffer, pInformationBuffer, InformationBufferLength); - } else { - pRequest->InformationBufferLength = htole32(0); - } - - return &pRequest->MessageHeader; -} - -static MBIM_MESSAGE_HEADER *compose_basic_connect_ext_command(UINT32 CID, UINT32 CommandType, void *pInformationBuffer, UINT32 InformationBufferLength) -{ - MBIM_COMMAND_MSG_T *pRequest = (MBIM_COMMAND_MSG_T *)compose_basic_connect_command(CID, CommandType, pInformationBuffer, InformationBufferLength); - - if (!pRequest) - return NULL; - - memcpy(pRequest->DeviceServiceId.uuid, str2uuid(UUID_BASIC_CONNECT_EXT), 16); - - return &pRequest->MessageHeader; -} - -static MBIM_MESSAGE_HEADER *compose_qmi_over_mbim_command(UINT32 CID, UINT32 CommandType, void *pInformationBuffer, UINT32 InformationBufferLength) -{ - MBIM_COMMAND_MSG_T *pRequest = (MBIM_COMMAND_MSG_T *)compose_basic_connect_command(CID, CommandType, pInformationBuffer, InformationBufferLength); - - if (!pRequest) - return NULL; - - memcpy(pRequest->DeviceServiceId.uuid, str2uuid(uuid_ext_qmux), 16); - - return &pRequest->MessageHeader; -} - -static const char * uuid2str(const UUID_T *pUUID) { - static char str[16*2+4+1]; - const UINT8 *d = pUUID->uuid; - - snprintf(str, sizeof(str), "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", - d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], - d[8], d[9], d[10], d[11], d[12], d[13], d[14], d[15]); - - return str; -} - -static const char *DeviceServiceId2str(const UUID_T *pUUID) { - const char *str = uuid2str(pUUID); - - struct { char *val;char *name;} _enumstr[] = { - {UUID_BASIC_CONNECT, "UUID_BASIC_CONNECT"}, - {UUID_BASIC_CONNECT_EXT, "UUID_BASIC_CONNECT_EXT"}, - {UUID_SMS, "UUID_SMS"}, - {UUID_USSD, "UUID_USSD"}, - {UUID_PHONEBOOK, "UUID_PHONEBOOK"}, - {UUID_STK, "UUID_STK"}, - {UUID_AUTH, "UUID_AUTH"}, - {UUID_DSS, "UUID_DSS"}, - {uuid_ext_qmux, "uuid_ext_qmux"}, - {uuid_mshsd, "uuid_mshsd"}, - {uuid_qmbe, "uuid_qmbe"}, - {UUID_MSFWID, "UUID_MSFWID"}, - {uuid_atds, "uuid_atds"}, - {uuid_qdu, "uuid_qdu"}, - {UUID_MS_UICC_LOW_LEVEL, "UUID_MS_UICC_LOW_LEVEL"}, - {UUID_MS_SARControl, "UUID_MS_SARControl"}, - {UUID_VOICEEXTENSIONS, "UUID_VOICEEXTENSIONS"}, - {UUID_LIBMBIM_PROXY, "UUID_LIBMBIM_PROXY"}, - }; - int idx; - - for (idx = 0; idx < (int)(sizeof(_enumstr)/sizeof(_enumstr[0])); idx++) { - if (!strcasecmp(str, _enumstr[idx].val)) - return _enumstr[idx].name; - } - - return str; -} - -static const char *mbim_get_segment(void *_pMsg, UINT32 offset, UINT32 len) -{ - int idx; - static char buff[256] = {'\0'}; - UINT8 *pMsg = (UINT8*)_pMsg; - - for (idx = 0; idx < (int)(len/2); idx++) - buff[idx] = pMsg[offset+idx*2]; - buff[idx] = '\0'; - return buff; -} - -static void mbim_dump_header(MBIM_MESSAGE_HEADER *pMsg, const char *direction) { - mbim_debug("%s Header:", direction); - mbim_debug("%s MessageLength = %u", direction, le32toh(pMsg->MessageLength)); - mbim_debug("%s MessageType = %s (0x%08x)", direction, MBIMMSGTypeStr(le32toh(pMsg->MessageType)), le32toh(pMsg->MessageType)); - mbim_debug("%s TransactionId = %u", direction, le32toh(pMsg->TransactionId)); - mbim_debug("%s Contents:", direction); -} - -static void mbim_dump_uuid_cid(const UUID_T *pUUID, UINT32 CID, const char *direction) { - size_t idx; - const char *uuidStr = uuid2str(pUUID); - const char *cidStr = "unknow"; - - for (idx = 0; idx < (sizeof(uuid_cid_string)/sizeof(uuid_cid_string[0])); idx++) { - if (!strcmp(uuidStr, uuid_cid_string[idx].uuid) && uuid_cid_string[idx].cid == CID) { - cidStr = uuid_cid_string[idx].name; - } - } - - mbim_debug("%s DeviceServiceId = %s (%s)", direction, DeviceServiceId2str(pUUID), uuidStr); - mbim_debug("%s CID = %s (%u)", direction, cidStr, le32toh(CID)); -} - - -static void mbim_dump_command_msg(MBIM_COMMAND_MSG_T *pCmdMsg, const char *direction) { - mbim_dump_uuid_cid(&pCmdMsg->DeviceServiceId, le32toh(pCmdMsg->CID), direction); - mbim_debug("%s CommandType = %s (%u)", direction, le32toh(pCmdMsg->CommandType) ? "set" : "query", le32toh(pCmdMsg->CommandType)); - mbim_debug("%s InformationBufferLength = %u", direction, le32toh(pCmdMsg->InformationBufferLength)); -} - -static void mbim_dump_command_done(MBIM_COMMAND_DONE_T *pCmdDone, const char *direction) { - mbim_dump_uuid_cid(&pCmdDone->DeviceServiceId, le32toh(pCmdDone->CID), direction); - mbim_debug("%s Status = %u", direction, le32toh(pCmdDone->Status)); - mbim_debug("%s InformationBufferLength = %u", direction, le32toh(pCmdDone->InformationBufferLength)); -} - -static void mbim_dump_indicate_msg(MBIM_INDICATE_STATUS_MSG_T *pIndMsg, const char *direction) { - mbim_dump_uuid_cid(&pIndMsg->DeviceServiceId, le32toh(pIndMsg->CID), direction); - mbim_debug("%s InformationBufferLength = %u", direction, le32toh(pIndMsg->InformationBufferLength)); -} - -static void mbim_dump_connect(MBIM_CONNECT_T *pInfo, const char *direction) { - mbim_debug("%s SessionId = %u", direction, le32toh(pInfo->SessionId)); - mbim_debug("%s ActivationState = %s (%u)", direction, MBIMActivationStateStr(le32toh(pInfo->ActivationState)), le32toh(pInfo->ActivationState)); - mbim_debug("%s IPType = %s", direction, MBIMContextIPTypeStr(le32toh(pInfo->IPType))); - mbim_debug("%s VoiceCallState = %s", direction, MBIMVoiceCallStateStr(le32toh(pInfo->VoiceCallState))); - mbim_debug("%s ContextType = %s", direction, uuid2str(&pInfo->ContextType)); - mbim_debug("%s NwError = %u", direction, le32toh(pInfo->NwError)); -} - -static void mbim_dump_signal_state(MBIM_SIGNAL_STATE_INFO_T *pInfo, const char *direction) -{ - mbim_debug("%s Rssi = %u", direction, le32toh(pInfo->Rssi)); - mbim_debug("%s ErrorRate = %u", direction, le32toh(pInfo->ErrorRate)); - mbim_debug("%s SignalStrengthInterval = %u", direction, le32toh(pInfo->SignalStrengthInterval)); - mbim_debug("%s RssiThreshold = %u", direction, le32toh(pInfo->RssiThreshold)); - mbim_debug("%s ErrorRateThreshold = %u", direction, le32toh(pInfo->ErrorRateThreshold)); -} - -static void mbim_dump_packet_service(MBIM_PACKET_SERVICE_INFO_T *pInfo, const char *direction) -{ - mbim_debug("%s NwError = %u", direction, le32toh(pInfo->NwError)); - mbim_debug("%s PacketServiceState = %s", direction, MBIMPacketServiceStateStr(le32toh(pInfo->PacketServiceState))); - mbim_debug("%s HighestAvailableDataClass = %s", direction, MBIMDataClassStr(le32toh(pInfo->HighestAvailableDataClass))); - mbim_debug("%s UplinkSpeed = %ld", direction, (long)le64toh(pInfo->UplinkSpeed)); - mbim_debug("%s DownlinkSpeed = %ld", direction, (long)le64toh(pInfo->DownlinkSpeed)); -} - -static void mbim_dump_subscriber_status(MBIM_SUBSCRIBER_READY_STATUS_T *pInfo, const char *direction) -{ - mbim_debug("%s ReadyState = %s", direction, MBIMSubscriberReadyStateStr(le32toh(pInfo->ReadyState))); - mbim_debug("%s SIMICCID = %s", direction, mbim_get_segment(pInfo, le32toh(pInfo->SimIccIdOffset), le32toh(pInfo->SimIccIdSize))); - mbim_debug("%s SubscriberID = %s", direction, mbim_get_segment(pInfo, le32toh(pInfo->SubscriberIdOffset), le32toh(pInfo->SubscriberIdSize))); - /* maybe more than one number */ - uint32_t idx; - for (idx = 0; idx < le32toh(pInfo->ElementCount); idx++) { - UINT32 offset = ((UINT32*)((UINT8*)pInfo+offsetof(MBIM_SUBSCRIBER_READY_STATUS_T, TelephoneNumbersRefList)))[0]; - UINT32 length = ((UINT32*)((UINT8*)pInfo+offsetof(MBIM_SUBSCRIBER_READY_STATUS_T, TelephoneNumbersRefList)))[1]; - mbim_debug("%s Number = %s", direction, mbim_get_segment(pInfo, le32toh(offset), le32toh(length))); - } -} - -static void mbim_dump_regiester_status(MBIM_REGISTRATION_STATE_INFO_T *pInfo, const char *direction) -{ - mbim_debug("%s NwError = %u", direction, le32toh(pInfo->NwError)); - mbim_debug("%s RegisterState = %s", direction, MBIMRegisterStateStr(le32toh(pInfo->RegisterState))); - mbim_debug("%s RegisterMode = %s", direction, MBIMRegisterModeStr(le32toh(pInfo->RegisterMode))); -} - -static void mbim_dump_ipconfig(MBIM_IP_CONFIGURATION_INFO_T *pInfo, const char *direction) -{ - UINT8 prefix = 0, *ipv4=NULL, *ipv6=NULL, *gw=NULL, *dns1=NULL, *dns2=NULL; - - mbim_debug("%s SessionId = %u", direction, le32toh(pInfo->SessionId)); - mbim_debug("%s IPv4ConfigurationAvailable = 0x%x", direction, le32toh(pInfo->IPv4ConfigurationAvailable)); - mbim_debug("%s IPv6ConfigurationAvailable = 0x%x", direction, le32toh(pInfo->IPv6ConfigurationAvailable)); - mbim_debug("%s IPv4AddressCount = 0x%x", direction, le32toh(pInfo->IPv4AddressCount)); - mbim_debug("%s IPv4AddressOffset = 0x%x", direction, le32toh(pInfo->IPv4AddressOffset)); - mbim_debug("%s IPv6AddressCount = 0x%x", direction, le32toh(pInfo->IPv6AddressCount)); - mbim_debug("%s IPv6AddressOffset = 0x%x", direction, le32toh(pInfo->IPv6AddressOffset)); - - /* IPv4 */ - if (le32toh(pInfo->IPv4ConfigurationAvailable)&0x1) { - MBIM_IPV4_ELEMENT_T *pAddress = (MBIM_IPV4_ELEMENT_T *)(&pInfo->DataBuffer[le32toh(pInfo->IPv4AddressOffset)-sizeof(MBIM_IP_CONFIGURATION_INFO_T)]); - prefix = le32toh(pAddress->OnLinkPrefixLength); - ipv4 = pAddress->IPv4Address; - mbim_debug("%s IPv4 = %u.%u.%u.%u/%u", direction, ipv4[0], ipv4[1], ipv4[2], ipv4[3], prefix); - } - if (le32toh(pInfo->IPv4ConfigurationAvailable)&0x2) { - gw = (UINT8 *)(&pInfo->DataBuffer[le32toh(pInfo->IPv4GatewayOffset)-sizeof(MBIM_IP_CONFIGURATION_INFO_T)]); - mbim_debug("%s gw = %u.%u.%u.%u", direction, gw[0], gw[1], gw[2], gw[3]); - } - if (le32toh(pInfo->IPv4ConfigurationAvailable)&0x3) { - dns1 = (UINT8 *)(&pInfo->DataBuffer[le32toh(pInfo->IPv4DnsServerOffset) -sizeof(MBIM_IP_CONFIGURATION_INFO_T)]); - mbim_debug("%s dns1 = %u.%u.%u.%u", direction, dns1[0], dns1[1], dns1[2], dns1[3]); - if (le32toh(pInfo->IPv4DnsServerCount) == 2) { - dns2 = dns1 + 4; - mbim_debug("%s dns2 = %u.%u.%u.%u", direction, dns2[0], dns2[1], dns2[2], dns2[3]); - } - } - if (le32toh(pInfo->IPv4Mtu)) mbim_debug("%s ipv4 mtu = %u", direction, le32toh(pInfo->IPv4Mtu)); - - /* IPv6 */ - if (le32toh(pInfo->IPv6ConfigurationAvailable)&0x1) { - MBIM_IPV6_ELEMENT_T *pAddress = (MBIM_IPV6_ELEMENT_T *)(&pInfo->DataBuffer[le32toh(pInfo->IPv6AddressOffset)-sizeof(MBIM_IP_CONFIGURATION_INFO_T)]); - prefix = le32toh(pAddress->OnLinkPrefixLength); - ipv6 = pAddress->IPv6Address; - mbim_debug("%s IPv6 = %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x/%d", \ - direction, ipv6[0], ipv6[1], ipv6[2], ipv6[3], ipv6[4], ipv6[5], ipv6[6], ipv6[7], \ - ipv6[8], ipv6[9], ipv6[10], ipv6[11], ipv6[12], ipv6[13], ipv6[14], ipv6[15], prefix); - } - if (le32toh(pInfo->IPv6ConfigurationAvailable)&0x2) { - gw = (UINT8 *)(&pInfo->DataBuffer[le32toh(pInfo->IPv6GatewayOffset)-sizeof(MBIM_IP_CONFIGURATION_INFO_T)]); - mbim_debug("%s gw = %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x", \ - direction, gw[0], gw[1], gw[2], gw[3], gw[4], gw[5], gw[6], gw[7], \ - gw[8], gw[9], gw[10], gw[11], gw[12], gw[13], gw[14], gw[15]); - } - if (le32toh(pInfo->IPv6ConfigurationAvailable)&0x3) { - dns1 = (UINT8 *)(&pInfo->DataBuffer[le32toh(pInfo->IPv6DnsServerOffset)-sizeof(MBIM_IP_CONFIGURATION_INFO_T)]); - mbim_debug("%s dns1 = %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x", \ - direction, dns1[0], dns1[1], dns1[2], dns1[3], dns1[4], dns1[5], dns1[6], dns1[7], \ - dns1[8], dns1[9], dns1[10], dns1[11], dns1[12], dns1[13], dns1[14], dns1[15]); - if (le32toh(pInfo->IPv6DnsServerCount) == 2) { - dns2 = dns1 + 16; - mbim_debug("%s dns2 = %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x", \ - direction, dns2[0], dns2[1], dns2[2], dns2[3], dns1[4], dns1[5], dns1[6], dns1[7], - dns2[8], dns2[9], dns2[10], dns2[11], dns2[12], dns2[13], dns2[14], dns2[15]); - } - } - if (le32toh(pInfo->IPv6Mtu)) mbim_debug("%s ipv6 mtu = %u", direction, le32toh(pInfo->IPv6Mtu)); -} - -static void mbim_dump(MBIM_MESSAGE_HEADER *pMsg, int mbim_verbose) { - unsigned char *data = (unsigned char *)pMsg; - const char *direction = (le32toh(pMsg->MessageType) & 0x80000000) ? "<" : ">"; - - if (!mbim_verbose) - return; - - if (mbim_verbose) { - unsigned i; - static char *_tmp = NULL; - - if (!_tmp) - _tmp = (char *)malloc(4096); - - if (_tmp) { - _tmp[0] = (le32toh(pMsg->MessageType) & 0x80000000) ? '<' : '>'; - _tmp[1] = '\0'; - for (i = 0; i < le32toh(pMsg->MessageLength) && i < 4096; i++) - snprintf(_tmp + strlen(_tmp), 4096 - strlen(_tmp), "%02X:", data[i]); - mbim_debug("%s", _tmp); - } - } - - mbim_dump_header(pMsg, direction); - - switch (le32toh(pMsg->MessageType)) { - case MBIM_OPEN_MSG: { - MBIM_OPEN_MSG_T *pOpenMsg = (MBIM_OPEN_MSG_T *)pMsg; - mbim_debug("%s MaxControlTransfer = %u", direction, le32toh(pOpenMsg->MaxControlTransfer)); - } - break; - case MBIM_OPEN_DONE: { - MBIM_OPEN_DONE_T *pOpenDone = (MBIM_OPEN_DONE_T *)pMsg; - mbim_debug("%s Status = %u", direction, le32toh(pOpenDone->Status)); - } - break; - case MBIM_CLOSE_MSG: { - - } - break; - case MBIM_CLOSE_DONE: { - MBIM_CLOSE_DONE_T *pCloseDone = (MBIM_CLOSE_DONE_T *)pMsg; - mbim_debug("%s Status = %u", direction, le32toh(pCloseDone->Status)); - } - break; - case MBIM_COMMAND_MSG: { - MBIM_COMMAND_MSG_T *pCmdMsg = (MBIM_COMMAND_MSG_T *)pMsg; - - mbim_dump_command_msg(pCmdMsg, direction); - if (!memcmp(pCmdMsg->DeviceServiceId.uuid, str2uuid(UUID_BASIC_CONNECT), 16)) { - switch (le32toh(pCmdMsg->CID)) { - case MBIM_CID_CONNECT: { - MBIM_SET_CONNECT_T *pInfo = (MBIM_SET_CONNECT_T *)pCmdMsg->InformationBuffer; - mbim_debug("%s SessionId = %u", direction, le32toh(pInfo->SessionId)); - } - break; - case MBIM_CID_IP_CONFIGURATION: { - MBIM_IP_CONFIGURATION_INFO_T *pInfo = (MBIM_IP_CONFIGURATION_INFO_T *)pCmdMsg->InformationBuffer; - mbim_debug("%s SessionId = %u", direction, le32toh(pInfo->SessionId)); - } - break; - default: - break; - } - } - } - break; - case MBIM_COMMAND_DONE: { - MBIM_COMMAND_DONE_T *pCmdDone = (MBIM_COMMAND_DONE_T *)pMsg; - - mbim_dump_command_done(pCmdDone, direction); - if (le32toh(pCmdDone->InformationBufferLength) == 0) - return; - - if (!memcmp(pCmdDone->DeviceServiceId.uuid, str2uuid(UUID_BASIC_CONNECT), 16)) { - switch (le32toh(pCmdDone->CID)) { - case MBIM_CID_CONNECT: { - MBIM_CONNECT_T *pInfo = (MBIM_CONNECT_T *)pCmdDone->InformationBuffer; - mbim_dump_connect(pInfo, direction); - } - break; - case MBIM_CID_IP_CONFIGURATION: { - //MBIM_IP_CONFIGURATION_INFO_T *pInfo = (MBIM_IP_CONFIGURATION_INFO_T *)pCmdDone->InformationBuffer; - //mbim_dump_ipconfig(pInfo, direction); - } - break; - case MBIM_CID_PACKET_SERVICE: { - MBIM_PACKET_SERVICE_INFO_T *pInfo = (MBIM_PACKET_SERVICE_INFO_T *)pCmdDone->InformationBuffer; - mbim_dump_packet_service(pInfo, direction); - } - break; - case MBIM_CID_SUBSCRIBER_READY_STATUS: { - MBIM_SUBSCRIBER_READY_STATUS_T *pInfo = (MBIM_SUBSCRIBER_READY_STATUS_T *)pCmdDone->InformationBuffer; - mbim_dump_subscriber_status(pInfo, direction); - } - break; - case MBIM_CID_REGISTER_STATE: { - MBIM_REGISTRATION_STATE_INFO_T *pInfo = (MBIM_REGISTRATION_STATE_INFO_T *)pCmdDone->InformationBuffer; - mbim_dump_regiester_status(pInfo, direction); - } - break; - default: - break; - } - } - } - break; - case MBIM_INDICATE_STATUS_MSG: { - MBIM_INDICATE_STATUS_MSG_T *pIndMsg = (MBIM_INDICATE_STATUS_MSG_T *)pMsg; - - mbim_dump_indicate_msg(pIndMsg, direction); - if (le32toh(pIndMsg->InformationBufferLength) == 0) - return; - - if (!memcmp(pIndMsg->DeviceServiceId.uuid, str2uuid(UUID_BASIC_CONNECT), 16)) { - switch (le32toh(pIndMsg->CID)) { - case MBIM_CID_CONNECT: { - MBIM_CONNECT_T *pInfo = (MBIM_CONNECT_T *)pIndMsg->InformationBuffer; - mbim_dump_connect(pInfo, direction); - } - break; - case MBIM_CID_SIGNAL_STATE: { - MBIM_SIGNAL_STATE_INFO_T *pInfo = (MBIM_SIGNAL_STATE_INFO_T *)pIndMsg->InformationBuffer; - mbim_dump_signal_state(pInfo, direction); - } - break; - case MBIM_CID_SUBSCRIBER_READY_STATUS: { - MBIM_SUBSCRIBER_READY_STATUS_T *pInfo = (MBIM_SUBSCRIBER_READY_STATUS_T *)pIndMsg->InformationBuffer; - mbim_dump_subscriber_status(pInfo, direction); - } - break; - case MBIM_CID_REGISTER_STATE: { - MBIM_REGISTRATION_STATE_INFO_T *pInfo = (MBIM_REGISTRATION_STATE_INFO_T *)pIndMsg->InformationBuffer; - mbim_dump_regiester_status(pInfo, direction); - } - break; - case MBIM_CID_PACKET_SERVICE: { - MBIM_PACKET_SERVICE_INFO_T *pInfo = (MBIM_PACKET_SERVICE_INFO_T *)pIndMsg->InformationBuffer; - mbim_dump_packet_service(pInfo, direction); - } - break; - default: - break; - } - } - else if (!memcmp(pIndMsg->DeviceServiceId.uuid, str2uuid(UUID_BASIC_CONNECT_EXT), 16)) { - } - } - break; - case MBIM_FUNCTION_ERROR_MSG: { - MBIM_FUNCTION_ERROR_MSG_T *pErrMsg = (MBIM_FUNCTION_ERROR_MSG_T*)pMsg; - mbim_debug("%s ErrorStatusCode = %u", direction, le32toh(pErrMsg->ErrorStatusCode)); - } - break; - default: - break; - } -} - -static void mbim_recv_command(MBIM_MESSAGE_HEADER *pResponse, unsigned size) -{ - (void)size; - pthread_mutex_lock(&mbim_command_mutex); - - if (pResponse) - mbim_dump(pResponse, mbim_verbose); - - if (pResponse == NULL) { - pthread_cond_signal(&mbim_command_cond); - } - else if (mbim_pRequest && le32toh(mbim_pRequest->TransactionId) == le32toh(pResponse->TransactionId)) { - mbim_pResponse = mbim_alloc(le32toh(pResponse->MessageLength)); - if (mbim_pResponse) - memcpy(mbim_pResponse, pResponse, le32toh(pResponse->MessageLength)); - pthread_cond_signal(&mbim_command_cond); - } - else if (le32toh(pResponse->MessageType) == MBIM_INDICATE_STATUS_MSG) { - MBIM_INDICATE_STATUS_MSG_T *pIndMsg = (MBIM_INDICATE_STATUS_MSG_T *)pResponse; - - if (!memcmp(pIndMsg->DeviceServiceId.uuid, str2uuid(UUID_BASIC_CONNECT), 16)) - { - switch (le32toh(pIndMsg->CID)) { - case MBIM_CID_SUBSCRIBER_READY_STATUS: { - MBIM_SUBSCRIBER_READY_STATUS_T *pInfo = (MBIM_SUBSCRIBER_READY_STATUS_T *)pIndMsg->InformationBuffer; - if (oldReadyState != le32toh(pInfo->ReadyState)) - qmidevice_send_event_to_main(RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED); - } - break; - case MBIM_CID_REGISTER_STATE: { - MBIM_REGISTRATION_STATE_INFO_T *pInfo = (MBIM_REGISTRATION_STATE_INFO_T *)pIndMsg->InformationBuffer; - if (oldRegisterState != le32toh(pInfo->RegisterState)) - qmidevice_send_event_to_main(RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED); - } - break; - case MBIM_CID_PACKET_SERVICE: { - MBIM_PACKET_SERVICE_INFO_T *pInfo = (MBIM_PACKET_SERVICE_INFO_T *)pIndMsg->InformationBuffer; - MBIM_PACKET_SERVICE_STATE_E state = le32toh(pInfo->PacketServiceState); - - if (oldPacketServiceState != state - && (1 || MBIMPacketServiceStateAttached == state || MBIMPacketServiceStateDetached == state)) - qmidevice_send_event_to_main(RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED); - } - break; - case MBIM_CID_CONNECT: { - MBIM_CONNECT_T *pInfo = (MBIM_CONNECT_T *)pIndMsg->InformationBuffer; - if (pInfo->SessionId == (uint32_t)mbim_sessionID) { - MBIM_ACTIVATION_STATE_E state = le32toh(pInfo->ActivationState); - - if (oldActivationState != state - && (1 || MBIMActivationStateActivated == state || MBIMActivationStateDeactivated == state)) - qmidevice_send_event_to_main(RIL_UNSOL_DATA_CALL_LIST_CHANGED); - } - } - break; - default: - break; - } - } - } - - pthread_mutex_unlock(&mbim_command_mutex); -} - -static int mbim_send_command(MBIM_MESSAGE_HEADER *pRequest, MBIM_COMMAND_DONE_T **ppCmdDone, unsigned msecs) { - int ret; - - if (ppCmdDone) - *ppCmdDone = NULL; - - if (mbim_fd <= 0) - return -ENODEV; - - if (s_tid_reader == 0) - return -EINVAL; - - if (!pRequest) - return -ENOMEM; - - pthread_mutex_lock(&mbim_command_mutex); - - if (pRequest) { - if (pRequest->TransactionId == (0xFFFFFF + 1)) { //quectel-mbim-proxy need 0xFF000000 to indicat client - TransactionId = 1; - pRequest->TransactionId = htole32(TransactionId++); - } - mbim_dump(pRequest, mbim_verbose); - } - - mbim_pRequest = pRequest; - mbim_pResponse = NULL; - - ret = write(mbim_fd, pRequest, le32toh(pRequest->MessageLength)); - - if (ret > 0 && (uint32_t)ret == le32toh(pRequest->MessageLength)) { - ret = pthread_cond_timeout_np(&mbim_command_cond, &mbim_command_mutex, msecs); - if (!ret) { - if (mbim_pResponse && ppCmdDone) { - *ppCmdDone = (MBIM_COMMAND_DONE_T *)mbim_pResponse; - } - } - } else { - mbim_debug("%s pthread_cond_timeout_np=%d", __func__, ret); - } - - mbim_pRequest = mbim_pResponse = NULL; - - pthread_mutex_unlock(&mbim_command_mutex); - - return ret; -} - -static ssize_t mbim_proxy_read (int fd, MBIM_MESSAGE_HEADER *pResponse, size_t size) { - ssize_t nreads; - - nreads = read(fd, pResponse, sizeof(MBIM_MESSAGE_HEADER)); - if (nreads == sizeof(MBIM_MESSAGE_HEADER) && le32toh(pResponse->MessageLength) <= size) { - nreads += read(fd, pResponse+1, le32toh(pResponse->MessageLength) - sizeof(MBIM_MESSAGE_HEADER)); - } - - return nreads; -} - -static void * mbim_read_thread(void *param) { - PROFILE_T *profile = (PROFILE_T *)param; - const char *cdc_wdm = (const char *)profile->qmichannel; - int wait_for_request_quit = 0; - - mbim_verbose = debug_qmi; - s_tid_reader = pthread_self(); - - if (profile->qmap_mode > 1 && profile->qmapnet_adapter[0]) { - if (!profile->proxy[0]) - sprintf(profile->proxy, "%s", QUECTEL_MBIM_PROXY); - mbim_sessionID = profile->pdp; - } - - if (profile->proxy[0]) { - mbim_fd = cm_open_proxy(profile->proxy); - } - else { - mbim_fd = cm_open_dev(cdc_wdm); - } - - if (mbim_fd <= 0) { - mbim_debug("fail to open (%s), errno: %d (%s)", cdc_wdm, errno, strerror(errno)); - goto __quit; - } - - dbg_time("cdc_wdm_fd = %d", mbim_fd); - - qmidevice_send_event_to_main(RIL_INDICATE_DEVICE_CONNECTED); - - while (mbim_fd > 0) { - struct pollfd pollfds[] = {{mbim_fd, POLLIN, 0}, {qmidevice_control_fd[1], POLLIN, 0}, {qmi_over_mbim_sk[1], POLLIN, 0}}; - int ne, ret, nevents = 2; - - if (pollfds[nevents].fd != -1) - nevents++; - - ret = poll(pollfds, nevents, wait_for_request_quit ? 1000 : -1); - - if (ret == 0 && wait_for_request_quit) { - break; - } - - if (ret < 0) { - mbim_debug("%s poll=%d, errno: %d (%s)", __func__, ret, errno, strerror(errno)); - break; - } - - for (ne = 0; ne < nevents; ne++) { - int fd = pollfds[ne].fd; - short revents = pollfds[ne].revents; - - if (revents & (POLLERR | POLLHUP | POLLNVAL)) { - mbim_debug("%s poll err/hup/inval", __func__); - mbim_debug("epoll fd = %d, events = 0x%04x", fd, revents); - if (revents & (POLLERR | POLLHUP | POLLNVAL)) - goto __quit; - } - - if ((revents & POLLIN) == 0) - continue; - - if (mbim_fd == fd) { - ssize_t nreads; - MBIM_MESSAGE_HEADER *pResponse = (MBIM_MESSAGE_HEADER *) cm_recv_buf; - - if (profile->proxy[0]) - nreads = mbim_proxy_read(fd, pResponse, sizeof(cm_recv_buf)); - else - nreads = read(fd, pResponse, sizeof(cm_recv_buf)); - - if (nreads <= 0) { - mbim_debug("%s read=%d errno: %d (%s)", __func__, (int)nreads, errno, strerror(errno)); - break; - } - - mbim_recv_command(pResponse, nreads); - } - else if (fd == qmidevice_control_fd[1]) { - int triger_event; - if (read(fd, &triger_event, sizeof(triger_event)) == sizeof(triger_event)) { - //mbim_debug("triger_event = 0x%x", triger_event); - switch (triger_event) { - case RIL_REQUEST_QUIT: - goto __quit; - break; - case SIG_EVENT_STOP: - wait_for_request_quit = 1; - break; - default: - break; - } - } - } - else if (fd == qmi_over_mbim_sk[1]) { - ssize_t nreads = read(fd, cm_recv_buf, sizeof(cm_recv_buf)); - if (nreads > 0) - QmiThreadRecvQMI((PQCQMIMSG)cm_recv_buf); - } - } - } - -__quit: - if (mbim_fd != -1) { close(mbim_fd); mbim_fd = -1; } - mbim_recv_command(NULL, 0); - qmidevice_send_event_to_main(RIL_INDICATE_DEVICE_DISCONNECTED); - mbim_debug("%s exit", __func__); - s_tid_reader = 0; - - return NULL; -} - -static int mbim_status_code(MBIM_MESSAGE_HEADER *pMsgHdr) { - int status = 0; - - if (!pMsgHdr) - return 0; - - switch (le32toh(pMsgHdr->MessageType)) { - case MBIM_OPEN_DONE: { - MBIM_OPEN_DONE_T *pOpenDone = (MBIM_OPEN_DONE_T *)pMsgHdr; - status = le32toh(pOpenDone->Status); - } - break; - case MBIM_CLOSE_DONE: { - MBIM_CLOSE_DONE_T *pCloseDone = (MBIM_CLOSE_DONE_T *)pMsgHdr; - status = le32toh(pCloseDone->Status); - } - break; - case MBIM_COMMAND_DONE: { - MBIM_COMMAND_DONE_T *pCmdDone = (MBIM_COMMAND_DONE_T *)pMsgHdr; - status = le32toh(pCmdDone->Status); - } - break; - case MBIM_FUNCTION_ERROR_MSG: { - MBIM_FUNCTION_ERROR_MSG_T *pErrMsg = (MBIM_FUNCTION_ERROR_MSG_T *)pMsgHdr; - status = le32toh(pErrMsg->ErrorStatusCode); - if (status == MBIM_ERROR_NOT_OPENED) - mbim_open_state = 0; //EM06ELAR03A05M4G when suspend/resume, may get this error - } - break; - default: - break; - } - - return status; -} - -#define mbim_check_err(err, pRequest, pCmdDone) do { \ - int _status = mbim_status_code(pCmdDone ? &pCmdDone->MessageHeader : NULL); \ - if (err || _status || !pCmdDone) { \ - if (pCmdDone) { mbim_dump(&pCmdDone->MessageHeader, (mbim_verbose == 0)); } \ - mbim_free(pRequest); mbim_free(pCmdDone); \ - mbim_debug("%s:%d err=%d, Status=%d", __func__, __LINE__, err, _status); \ - if (err) return err; \ - if (_status) return _status; \ - return 8888; \ - } \ -} while(0) - -/* - * MBIM device can be open repeatly without error - * So, we can call the function, no matter it have been opened or not - */ -static int mbim_open_device(uint32_t MaxControlTransfer) { - MBIM_MESSAGE_HEADER *pRequest = NULL; - MBIM_OPEN_DONE_T *pOpenDone = NULL; - int err = 0; - - mbim_debug("%s()", __func__); - pRequest = compose_open_command(MaxControlTransfer); - err = mbim_send_command(pRequest, (MBIM_COMMAND_DONE_T **)&pOpenDone, 3*1000); //EM06ELAR03A09M4G take about 2.5 seconds - mbim_check_err(err, pRequest, pOpenDone); - - err = le32toh(pOpenDone->Status); - mbim_free(pRequest); mbim_free(pOpenDone); - - return err; -} - -static int mbim_close_device(void) { - MBIM_MESSAGE_HEADER *pRequest = NULL; - MBIM_CLOSE_DONE_T *pCloseDone = NULL; - int err = 0; - - mbim_debug("%s()", __func__); - pRequest = compose_close_command(); - err = mbim_send_command(pRequest, (MBIM_COMMAND_DONE_T **)&pCloseDone, mbim_default_timeout); - mbim_check_err(err, pRequest, pCloseDone); - - err = le32toh(pCloseDone->Status); - mbim_free(pRequest); mbim_free(pCloseDone); - - return err; -} - -static int mbim_query_connect(int sessionID) { - MBIM_MESSAGE_HEADER *pRequest = NULL; - MBIM_COMMAND_DONE_T *pCmdDone = NULL; - MBIM_SET_CONNECT_T set_connect; - int err; - - if (ActivationState != MBIMActivationStateActivated || mbim_verbose) - mbim_debug("%s(sessionID=%d)", __func__, sessionID); //avoid two many log - set_connect.SessionId = htole32(sessionID); - pRequest = compose_basic_connect_command(MBIM_CID_CONNECT, MBIM_CID_CMD_TYPE_QUERY, &set_connect, sizeof(set_connect)); - err = mbim_send_command(pRequest, &pCmdDone, mbim_default_timeout); - mbim_check_err(err, pRequest, pCmdDone); - - if (le32toh(pCmdDone->InformationBufferLength)) - { - MBIM_CONNECT_T *pInfo = (MBIM_CONNECT_T *)pCmdDone->InformationBuffer; - ActivationState = le32toh(pInfo->ActivationState); - mbim_update_state(); - } - mbim_free(pRequest); mbim_free(pCmdDone); - return err; -} - -static int mbim_ms_version_query(void) { - MBIM_MESSAGE_HEADER *pRequest = NULL; - MBIM_COMMAND_DONE_T *pCmdDone = NULL; - int err; - - struct _bc_ext_version { - UINT8 ver_minor; - UINT8 ver_major; - UINT8 ext_ver_minor; - UINT8 ext_ver_major; - } __attribute__ ((packed)) bc_ext_version; - - bc_ext_version.ver_major = 1; - bc_ext_version.ver_minor = 0; - bc_ext_version.ext_ver_major = 2; - bc_ext_version.ext_ver_minor = 0; - - pRequest = compose_basic_connect_ext_command(MBIM_CID_MS_VERSION, MBIM_CID_CMD_TYPE_QUERY, &bc_ext_version, sizeof(bc_ext_version)); - err = mbim_send_command(pRequest, &pCmdDone, mbim_default_timeout); - mbim_check_err(err, pRequest, pCmdDone); - - if (le32toh(pCmdDone->InformationBufferLength)) { - struct _bc_ext_version *pInfo = (struct _bc_ext_version *)pCmdDone->InformationBuffer; - //mbim_debug("%s ext_rel_ver major=%d, minor=%d", __func__, pInfo->ext_ver_major, pInfo->ext_ver_minor); - mbim_ms_version = pInfo->ext_ver_major; - } - - mbim_free(pRequest); mbim_free(pCmdDone); - return err; -} - -static int mbim_device_services_query(void) { - MBIM_MESSAGE_HEADER *pRequest = NULL; - MBIM_COMMAND_DONE_T *pCmdDone = NULL; - int err; - int mbim_v2_support = 0; - - mbim_debug("%s()", __func__); - pRequest = compose_basic_connect_command(MBIM_CID_DEVICE_SERVICES, MBIM_CID_CMD_TYPE_QUERY, NULL, 0); - err = mbim_send_command(pRequest, &pCmdDone, mbim_default_timeout); - mbim_check_err(err, pRequest, pCmdDone); - - if (pCmdDone->InformationBufferLength) { - MBIM_DEVICE_SERVICES_INFO_T *pInfo = (MBIM_DEVICE_SERVICES_INFO_T *)pCmdDone->InformationBuffer; - UINT32 i; - - for (i = 0; i < le32toh(pInfo->DeviceServicesCount) ; i++) { - //UINT32 size = pInfo->DeviceServicesRefList[i].size; - UINT32 offset = le32toh(pInfo->DeviceServicesRefList[i].offset); - MBIM_DEVICE_SERVICE_ELEMENT_T *pSrvEle = (MBIM_DEVICE_SERVICE_ELEMENT_T *)((void *)pInfo + offset); - - //mbim_debug("\t[%2d] %s (%s)", i, DeviceServiceId2str(&pSrvEle->DeviceServiceId), uuid2str(&pSrvEle->DeviceServiceId)); - if (!strcasecmp(UUID_BASIC_CONNECT_EXT, uuid2str(&pSrvEle->DeviceServiceId))) { - UINT32 cid = 0; - - for (cid = 0; cid < le32toh(pSrvEle->CidCount); cid++) { - if (MBIM_CID_MS_VERSION == le32toh(pSrvEle->CidList[cid])) { - mbim_v2_support = 1; - } - } - } - else if (!strcasecmp(uuid_ext_qmux, uuid2str(&pSrvEle->DeviceServiceId))) { - qmi_over_mbim_support = 1; - } - } - } - mbim_free(pRequest); mbim_free(pCmdDone); - - if (mbim_v2_support) { - mbim_ms_version_query(); - } - - return err; -} - -static int mbim_device_caps_query(PROFILE_T *profile) { - MBIM_MESSAGE_HEADER *pRequest = NULL; - MBIM_COMMAND_DONE_T *pCmdDone = NULL; - int err; - - mbim_debug("%s()", __func__); - pRequest = compose_basic_connect_command(MBIM_CID_DEVICE_CAPS, MBIM_CID_CMD_TYPE_QUERY, NULL, 0); - err = mbim_send_command(pRequest, &pCmdDone, mbim_default_timeout); - mbim_check_err(err, pRequest, pCmdDone); - - if (le32toh(pCmdDone->InformationBufferLength)) { - MBIM_DEVICE_CAPS_INFO_T *pInfo = (MBIM_DEVICE_CAPS_INFO_T *)pCmdDone->InformationBuffer; - char tmp[32]; - - if (le32toh(pInfo->DeviceIdOffset) && le32toh(pInfo->DeviceIdSize)) { - wchar2char((const char *)pInfo + le32toh(pInfo->DeviceIdOffset), le32toh(pInfo->DeviceIdSize), tmp, sizeof(tmp)); - mbim_debug("DeviceId: %s", tmp); - } - if (le32toh(pInfo->FirmwareInfoOffset) && le32toh(pInfo->FirmwareInfoSize)) { - wchar2char((const char *)pInfo + le32toh(pInfo->FirmwareInfoOffset), le32toh(pInfo->FirmwareInfoSize), tmp, sizeof(tmp)); - strncpy(profile->BaseBandVersion, tmp, sizeof(profile->BaseBandVersion)); - mbim_debug("FirmwareInfo: %s", tmp); - } - if (le32toh(pInfo->HardwareInfoOffset) && le32toh(pInfo->HardwareInfoSize)) { - wchar2char((const char *)pInfo + le32toh(pInfo->HardwareInfoOffset), le32toh(pInfo->HardwareInfoSize), tmp, sizeof(tmp)); - mbim_debug("HardwareInfo: %s", tmp); - } - } - mbim_free(pRequest); mbim_free(pCmdDone); - return err; -} - -#if 0 -static int mbim_radio_state_query(void) { - MBIM_MESSAGE_HEADER *pRequest = NULL; - MBIM_COMMAND_DONE_T *pCmdDone = NULL; - int err; - - mbim_debug("%s()", __func__); - pRequest = compose_basic_connect_command(MBIM_CID_RADIO_STATE, MBIM_CID_CMD_TYPE_QUERY, NULL, 0); - err = mbim_send_command(pRequest, &pCmdDone, mbim_default_timeout); - mbim_check_err(err, pRequest, pCmdDone); - - if (pCmdDone->InformationBufferLength) { - MBIM_RADIO_STATE_INFO_T *pInfo = (MBIM_RADIO_STATE_INFO_T *)pCmdDone->InformationBuffer; - mbim_debug("HwRadioState: %d, SwRadioState: %d", pInfo->HwRadioState, pInfo->SwRadioState); - } - mbim_free(pRequest); mbim_free(pCmdDone); - return err; -} -#endif - -static int mbim_set_radio_state(MBIM_RADIO_SWITCH_STATE_E RadioState) { - MBIM_MESSAGE_HEADER *pRequest = NULL; - MBIM_COMMAND_DONE_T *pCmdDone = NULL; - UINT32 value = htole32(RadioState); - int err; - - mbim_debug("%s( %d )", __func__, RadioState); - pRequest = compose_basic_connect_command(MBIM_CID_RADIO_STATE, MBIM_CID_CMD_TYPE_SET, &value, sizeof(value)); - err = mbim_send_command(pRequest, &pCmdDone, mbim_default_timeout); - mbim_check_err(err, pRequest, pCmdDone); - - if (le32toh(pCmdDone->InformationBufferLength)) { - MBIM_RADIO_STATE_INFO_T *pInfo = (MBIM_RADIO_STATE_INFO_T *)pCmdDone->InformationBuffer; - mbim_debug("HwRadioState: %d, SwRadioState: %d", le32toh(pInfo->HwRadioState), le32toh(pInfo->SwRadioState)); - } - mbim_free(pRequest); mbim_free(pCmdDone); - return err; -} - -static int mbim_subscriber_status_query(void) { - MBIM_MESSAGE_HEADER *pRequest = NULL; - MBIM_COMMAND_DONE_T *pCmdDone = NULL; - int err; - - mbim_debug("%s()", __func__); - pRequest = compose_basic_connect_command(MBIM_CID_SUBSCRIBER_READY_STATUS, MBIM_CID_CMD_TYPE_QUERY, NULL, 0); - err = mbim_send_command(pRequest, &pCmdDone, mbim_default_timeout); - mbim_check_err(err, pRequest, pCmdDone); - - if (le32toh(pCmdDone->InformationBufferLength)) { - MBIM_SUBSCRIBER_READY_STATUS_T *pInfo = (MBIM_SUBSCRIBER_READY_STATUS_T *)pCmdDone->InformationBuffer; - char tmp[32]; - - wchar2char((const char *)pInfo + le32toh(pInfo->SubscriberIdOffset), le32toh(pInfo->SubscriberIdSize), tmp, sizeof(tmp)); - mbim_debug("SubscriberId: %s", tmp); - wchar2char((const char *)pInfo + le32toh(pInfo->SimIccIdOffset), le32toh(pInfo->SimIccIdSize), tmp, sizeof(tmp)); - mbim_debug("SimIccId: %s", tmp); - ReadyState = le32toh(pInfo->ReadyState); - mbim_update_state(); - } - mbim_free(pRequest); mbim_free(pCmdDone); - return err; -} - -static int mbim_register_state_query(void) { - MBIM_MESSAGE_HEADER *pRequest = NULL; - MBIM_COMMAND_DONE_T *pCmdDone = NULL; - int err; - - mbim_debug("%s()", __func__); - pRequest = compose_basic_connect_command(MBIM_CID_REGISTER_STATE, MBIM_CID_CMD_TYPE_QUERY, NULL, 0); - err = mbim_send_command(pRequest, &pCmdDone, mbim_default_timeout); - mbim_check_err(err, pRequest, pCmdDone); - - if (le32toh(pCmdDone->InformationBufferLength)) { - MBIM_REGISTRATION_STATE_INFO_T *pInfo = (MBIM_REGISTRATION_STATE_INFO_T *)pCmdDone->InformationBuffer;; - RegisterState = le32toh(pInfo->RegisterState); - mbim_update_state(); - } - mbim_free(pRequest); mbim_free(pCmdDone); - return err; -} - -static int mbim_packet_service_query(void) { - MBIM_MESSAGE_HEADER *pRequest = NULL; - MBIM_COMMAND_DONE_T *pCmdDone = NULL; - int err; - - mbim_debug("%s()", __func__); - pRequest = compose_basic_connect_command(MBIM_CID_PACKET_SERVICE, MBIM_CID_CMD_TYPE_QUERY, NULL, 0); - err = mbim_send_command(pRequest, &pCmdDone, mbim_default_timeout); - mbim_check_err(err, pRequest, pCmdDone); - - if (le32toh(pCmdDone->InformationBufferLength)) { - MBIM_PACKET_SERVICE_INFO_T *pInfo = (MBIM_PACKET_SERVICE_INFO_T *)pCmdDone->InformationBuffer; - PacketServiceState = le32toh(pInfo->PacketServiceState); - mbim_update_state(); - - if (le32toh(pCmdDone->InformationBufferLength) == sizeof(MBIM_PACKET_SERVICE_INFO_V2_T)) { - MBIM_PACKET_SERVICE_INFO_V2_T *pInfo = (MBIM_PACKET_SERVICE_INFO_V2_T *)pCmdDone->InformationBuffer; - mbim_debug("CurrentDataClass = %s", MBIMDataClassStr(le32toh(pInfo->CurrentDataClass))); - } - } - mbim_free(pRequest); mbim_free(pCmdDone); - return err; -} - -static int mbim_packet_service_set(MBIM_PACKET_SERVICE_ACTION_E action) { - MBIM_MESSAGE_HEADER *pRequest = NULL; - MBIM_COMMAND_DONE_T *pCmdDone = NULL; - UINT32 value = htole32(action); - int err; - - mbim_debug("%s()", __func__); - pRequest = compose_basic_connect_command(MBIM_CID_PACKET_SERVICE, MBIM_CID_CMD_TYPE_SET, &value, sizeof(value)); - err = mbim_send_command(pRequest, &pCmdDone, mbim_default_timeout); - mbim_check_err(err, pRequest, pCmdDone); - - if (le32toh(pCmdDone->InformationBufferLength)) { - MBIM_PACKET_SERVICE_INFO_T *pInfo = (MBIM_PACKET_SERVICE_INFO_T *)pCmdDone->InformationBuffer; - PacketServiceState = le32toh(pInfo->PacketServiceState); - mbim_update_state(); - } - mbim_free(pRequest); mbim_free(pCmdDone); - return err; -} - -#define _align_32(len) {len += (len % 4) ? (4 - (len % 4)) : 0;} -static int mbim_populate_connect_data(MBIM_SET_CONNECT_T **connect_req_ptr) { - int offset; - int buflen = 0; - - if (mbim_apn && strlen(mbim_apn) > 0) buflen += 2*strlen(mbim_apn) ; - _align_32(buflen); - if (mbim_user && strlen(mbim_user) > 0) buflen += 2*strlen(mbim_user); - _align_32(buflen); - if (mbim_passwd && strlen(mbim_passwd) > 0) buflen += 2*strlen(mbim_passwd); - _align_32(buflen); - - *connect_req_ptr = (MBIM_SET_CONNECT_T*)malloc(sizeof(MBIM_SET_CONNECT_T) + buflen); - if (! *connect_req_ptr) { - mbim_debug("not enough memory\n"); - return -1; - } - memset(*connect_req_ptr, 0, sizeof(MBIM_SET_CONNECT_T) + buflen); - - offset = 0; - if (mbim_apn && strlen(mbim_apn) > 0) { - (*connect_req_ptr)->AccessStringSize = htole32(2*strlen(mbim_apn)); - (*connect_req_ptr)->AccessStringOffset = htole32(offset + sizeof(MBIM_SET_CONNECT_T)); - offset = char2wchar(mbim_apn, strlen(mbim_apn), &(*connect_req_ptr)->DataBuffer[offset], buflen - offset); - _align_32(offset); - } - - if (mbim_user && strlen(mbim_user) > 0) { - (*connect_req_ptr)->UserNameSize = htole32(2*strlen(mbim_user)); - (*connect_req_ptr)->UserNameOffset = htole32(offset + sizeof(MBIM_SET_CONNECT_T)); - offset = char2wchar(mbim_user, strlen(mbim_user), &(*connect_req_ptr)->DataBuffer[offset], buflen - offset); - _align_32(offset); - } - - if (mbim_passwd && strlen(mbim_passwd) > 0) { - (*connect_req_ptr)->PasswordSize = htole32(2*strlen(mbim_passwd)); - (*connect_req_ptr)->PasswordOffset = htole32(offset + sizeof(MBIM_SET_CONNECT_T)); - offset = char2wchar(mbim_passwd, strlen(mbim_passwd), &(*connect_req_ptr)->DataBuffer[offset], buflen - offset); - } - - return buflen; -} - -static int mbim_set_connect(int onoff, int sessionID) { - MBIM_MESSAGE_HEADER *pRequest = NULL; - MBIM_COMMAND_DONE_T *pCmdDone = NULL; - MBIM_SET_CONNECT_T *set_connect = NULL; - int err; - - mbim_debug("%s(onoff=%d, sessionID=%d)", __func__, onoff, sessionID); - /* alloc memory then populate APN USERNAME PASSWORD */ - int buflen = mbim_populate_connect_data(&set_connect); - if (buflen < 0) { - return ENOMEM; - } - - set_connect->SessionId = htole32(sessionID); - if (onoff == 0) - set_connect->ActivationCommand = htole32(MBIMActivationCommandDeactivate); - else - set_connect->ActivationCommand = htole32(MBIMActivationCommandActivate); - - set_connect->Compression = htole32(MBIMCompressionNone); - set_connect->AuthProtocol = htole32(mbim_auth); - set_connect->IPType = htole32(mbim_iptype); - memcpy(set_connect->ContextType.uuid, str2uuid(UUID_MBIMContextTypeInternet), 16); - - pRequest = compose_basic_connect_command(MBIM_CID_CONNECT, MBIM_CID_CMD_TYPE_SET, set_connect, sizeof(MBIM_SET_CONNECT_T) + buflen); - mbim_free(set_connect); - err = mbim_send_command(pRequest, &pCmdDone, mbim_default_timeout*10); - mbim_check_err(err, pRequest, pCmdDone); - - if (le32toh(pCmdDone->InformationBufferLength)) { - MBIM_CONNECT_T *pInfo = (MBIM_CONNECT_T *)pCmdDone->InformationBuffer; - ActivationState = le32toh(pInfo->ActivationState); - mbim_update_state(); - } - - mbim_free(pRequest); mbim_free(pCmdDone); - return err; -} - -static int mbim_ip_config(PROFILE_T *profile, int sessionID) { - MBIM_MESSAGE_HEADER *pRequest = NULL; - MBIM_COMMAND_DONE_T *pCmdDone = NULL; - MBIM_IP_CONFIGURATION_INFO_T ip_info; - int err; - - if (profile->ipv4.Address == 0 || mbim_verbose) - mbim_debug("%s(sessionID=%d)", __func__, sessionID); - ip_info.SessionId = htole32(sessionID); - pRequest = compose_basic_connect_command(MBIM_CID_IP_CONFIGURATION, MBIM_CID_CMD_TYPE_QUERY, &ip_info, sizeof(ip_info)); - err = mbim_send_command(pRequest, &pCmdDone, mbim_default_timeout); - mbim_check_err(err, pRequest, pCmdDone); - - if (le32toh(pCmdDone->InformationBufferLength)) { - UINT8 prefix, *ipv4=NULL, *ipv6=NULL, *gw=NULL, *dns1=NULL, *dns2=NULL; - UINT32 mtu = 1500; - MBIM_IP_CONFIGURATION_INFO_T *pInfo = (MBIM_IP_CONFIGURATION_INFO_T *)pCmdDone->InformationBuffer; - - /* IPv4 network configration */ - if (le32toh(pInfo->IPv4ConfigurationAvailable)&0x1) { - MBIM_IPV4_ELEMENT_T *pAddress = (MBIM_IPV4_ELEMENT_T *)(&pInfo->DataBuffer[le32toh(pInfo->IPv4AddressOffset)-sizeof(MBIM_IP_CONFIGURATION_INFO_T)]); - prefix = le32toh(pAddress->OnLinkPrefixLength); - ipv4 = pAddress->IPv4Address; - - if (le32toh(pInfo->IPv4ConfigurationAvailable)&0x2) - gw = (UINT8 *)(&pInfo->DataBuffer[le32toh(pInfo->IPv4GatewayOffset)-sizeof(MBIM_IP_CONFIGURATION_INFO_T)]); - - if (le32toh(pInfo->IPv4ConfigurationAvailable)&0x4) { - dns1 = (UINT8 *)(&pInfo->DataBuffer[le32toh(pInfo->IPv4DnsServerOffset)-sizeof(MBIM_IP_CONFIGURATION_INFO_T)]); - if (le32toh(pInfo->IPv4DnsServerCount) == 2) - dns2 = dns1 + 4; - } - - if (le32toh(pInfo->IPv4ConfigurationAvailable)&0x8) - mtu = le32toh(pInfo->IPv4Mtu); - - if (profile->ipv4.Address != mbim2qmi_ipv4addr(*(uint32_t *)ipv4) || mbim_verbose) { - mbim_dump_ipconfig(pInfo, "<"); - profile->ipv4.Address = mbim2qmi_ipv4addr(*(uint32_t *)ipv4); - } - - if(gw != NULL) - profile->ipv4.Gateway = mbim2qmi_ipv4addr(*(uint32_t *)gw); - profile->ipv4.SubnetMask = mbim2qmi_ipv4addr(0xFFFFFFFF>>(32-prefix)<<(32-prefix)); - if(dns1 != NULL) - profile->ipv4.DnsPrimary = mbim2qmi_ipv4addr(*(uint32_t *)dns1); - if(dns2 != NULL) - profile->ipv4.DnsSecondary = mbim2qmi_ipv4addr(*(uint32_t *)dns2); - profile->ipv4.Mtu = mbim2qmi_ipv4addr(mtu); - } - - /* IPv6 network configration */ - if (le32toh(pInfo->IPv6ConfigurationAvailable)&0x1) { - gw = NULL; dns1 = NULL; dns2 = NULL; - MBIM_IPV6_ELEMENT_T *pAddress = (MBIM_IPV6_ELEMENT_T *)(&pInfo->DataBuffer[le32toh(pInfo->IPv6AddressOffset)-sizeof(MBIM_IP_CONFIGURATION_INFO_T)]); - prefix = le32toh(pAddress->OnLinkPrefixLength); - ipv6 = pAddress->IPv6Address; - - if (le32toh(pInfo->IPv6ConfigurationAvailable)&0x2) - gw = (UINT8 *)(&pInfo->DataBuffer[le32toh(pInfo->IPv6GatewayOffset)-sizeof(MBIM_IP_CONFIGURATION_INFO_T)]); - - if (le32toh(pInfo->IPv6ConfigurationAvailable)&0x4) { - dns1 = (UINT8 *)(&pInfo->DataBuffer[le32toh(pInfo->IPv6DnsServerOffset)-sizeof(MBIM_IP_CONFIGURATION_INFO_T)]); - if (le32toh(pInfo->IPv6DnsServerCount) == 2) - dns2 = dns1 + 16; - } - - if (le32toh(pInfo->IPv6ConfigurationAvailable)&0x8) - mtu = le32toh(pInfo->IPv6Mtu); - - if(ipv6 != NULL) - mbim2qmi_ipv6addr(ipv6, profile->ipv6.Address); - if(gw != NULL) - mbim2qmi_ipv6addr(gw, profile->ipv6.Gateway); - if(dns1 != NULL) - mbim2qmi_ipv6addr(dns1, profile->ipv6.DnsPrimary); - if(dns2 != NULL) - mbim2qmi_ipv6addr(dns2, profile->ipv6.DnsSecondary); - profile->ipv6.PrefixLengthIPAddr = prefix; - profile->ipv6.PrefixLengthGateway = prefix; - profile->ipv6.Mtu = mbim2qmi_ipv4addr(mtu); - } - } - return err; -} - -int mbim_proxy_configure(const char *dev) { - MBIM_MESSAGE_HEADER *pRequest = NULL; - MBIM_COMMAND_DONE_T *pCmdDone = NULL; - MBIM_LIBQMI_PROXY_CONFIG_T *cfg; - int err; - - pRequest = compose_basic_connect_command( - MBIM_CID_PROXY_CONTROL_CONFIGURATION, - MBIM_CID_CMD_TYPE_SET, - NULL, - sizeof(*cfg) + strlen(dev)*2); - if (pRequest) { - memcpy(((MBIM_COMMAND_MSG_T *)pRequest)->DeviceServiceId.uuid, str2uuid(UUID_LIBMBIM_PROXY), 16); - cfg = (MBIM_LIBQMI_PROXY_CONFIG_T *)((MBIM_COMMAND_MSG_T *)pRequest)->InformationBuffer; - - cfg->DevicePathOffset = sizeof(*cfg); - cfg->DevicePathSize = char2wchar(dev, strlen(dev), cfg->DataBuffer, strlen(dev)*2); - cfg->Timeout = 15; - } - - err = mbim_send_command(pRequest, &pCmdDone, mbim_default_timeout); - mbim_check_err(err, pRequest, pCmdDone); - - mbim_free(pRequest); mbim_free(pCmdDone); - return err; -} - -static int mbim_update_state(void) { - int chages = 0; - - if (oldReadyState != ReadyState) { - mbim_debug("SubscriberReadyState %s -> %s ", MBIMSubscriberReadyStateStr(oldReadyState), MBIMSubscriberReadyStateStr(ReadyState)); - oldReadyState = ReadyState; chages++; - } - if (oldRegisterState != RegisterState) { - mbim_debug("RegisterState %s -> %s ", MBIMRegisterStateStr(oldRegisterState), MBIMRegisterStateStr(RegisterState)); - oldRegisterState = RegisterState; chages++; - } - if (oldPacketServiceState != PacketServiceState) { - mbim_debug("PacketServiceState %s -> %s ", MBIMPacketServiceStateStr(oldPacketServiceState), MBIMPacketServiceStateStr(PacketServiceState)); - oldPacketServiceState = PacketServiceState; chages++; - } - if (oldActivationState != ActivationState) { - mbim_debug("ActivationState %s -> %s ", MBIMActivationStateStr(oldActivationState), MBIMActivationStateStr(ActivationState)); - oldActivationState = ActivationState; chages++; - } - - return chages; -} - -static int mbim_init(PROFILE_T *profile) { - int retval; - int t = 0; - - if (profile->proxy[0] && !strcmp(profile->proxy, LIBMBIM_PROXY)) { - retval = mbim_proxy_configure(profile->qmichannel); - if (retval) goto exit; - } - - while (t++ < 10) { - retval = mbim_open_device(4096); - if (retval != ETIMEDOUT) - break; - } - if (retval) goto exit; - retval = mbim_device_caps_query(profile); - if (retval) goto exit; - mbim_update_state(); - retval = mbim_device_services_query(); - if (retval) goto exit; - mbim_update_state(); - retval = mbim_set_radio_state(MBIMRadioOn); - if (retval) goto exit; - mbim_update_state(); - - if (qmi_over_mbim_support) { - if (!socketpair( AF_LOCAL, SOCK_STREAM, 0, qmi_over_mbim_sk)) { - qmidev_send = qmi_over_mbim_qmidev_send; -#ifdef CONFIG_CELLINFO //by now, only this function need QMI OVER MBIM - qmi_over_mbim_nas = qmi_over_mbim_get_client_id(QMUX_TYPE_NAS); -#endif - } - } - - return 0; - -exit: - return retval; -} - -static int mbim_deinit(void) { - if (qmi_over_mbim_nas) { - qmi_over_mbim_release_client_id(QMUX_TYPE_NAS, qmi_over_mbim_nas); - qmi_over_mbim_nas = 0; - } - - mbim_close_device(); - - if (qmi_over_mbim_sk[0] != -1) { - close(qmi_over_mbim_sk[0]); - close(qmi_over_mbim_sk[1]); - } - - return 0; -} - -const struct qmi_device_ops mbim_dev_ops = { - .init = mbim_init, - .deinit = mbim_deinit, - .read = mbim_read_thread, -}; - -static int requestBaseBandVersion(PROFILE_T *profile) { - (void)profile; - return 0; -} - -static int requestGetSIMStatus(SIM_Status *pSIMStatus) -{ - int retval; - - *pSIMStatus = SIM_ABSENT; - retval = mbim_subscriber_status_query(); - if (retval) - goto exit; - mbim_update_state(); - - switch(ReadyState) { - case MBIMSubscriberReadyStateNotInitialized: *pSIMStatus = SIM_NOT_READY; break; - case MBIMSubscriberReadyStateInitialized: *pSIMStatus = SIM_READY; break; - case MBIMSubscriberReadyStateSimNotInserted: *pSIMStatus = SIM_ABSENT; break; - case MBIMSubscriberReadyStateBadSim: *pSIMStatus = SIM_BAD; break; - case MBIMSubscriberReadyStateFailure: *pSIMStatus = SIM_ABSENT; break; - case MBIMSubscriberReadyStateNotActivated: *pSIMStatus = SIM_ABSENT; break; - case MBIMSubscriberReadyStateDeviceLocked: *pSIMStatus = SIM_PIN; break; - default: *pSIMStatus = SIM_ABSENT; break; - } - -exit: - return retval; -} - -static int requestRegistrationState(UCHAR *pPSAttachedState) { - int retval; - - *pPSAttachedState = 0; - retval = mbim_register_state_query(); - if (retval) - goto exit; - mbim_update_state(); - - switch (RegisterState) { - case MBIMRegisterStateUnknown: *pPSAttachedState = 0; break; - case MBIMRegisterStateDeregistered: *pPSAttachedState = 0; break; - case MBIMRegisterStateSearching: *pPSAttachedState = 0; break; - case MBIMRegisterStateHome: *pPSAttachedState = 1; break; - case MBIMRegisterStateRoaming: *pPSAttachedState = 1; break; - case MBIMRegisterStatePartner: *pPSAttachedState = 0; break; - case MBIMRegisterStateDenied: *pPSAttachedState = 0; break; - default: *pPSAttachedState = 0; break; - } - - if (*pPSAttachedState == 0) - goto exit; - - retval = mbim_packet_service_query(); - if (retval) - goto exit; - - switch (PacketServiceState) { - case MBIMPacketServiceStateUnknown: *pPSAttachedState = 0; break; - case MBIMPacketServiceStateAttaching: *pPSAttachedState = 0; break; - case MBIMPacketServiceStateAttached: *pPSAttachedState = 1; break; - case MBIMPacketServiceStateDetaching: *pPSAttachedState = 0; break; - case MBIMPacketServiceStateDetached: *pPSAttachedState = 0; break; - default: *pPSAttachedState = 0; break; - } - - if (*pPSAttachedState == 0) - mbim_packet_service_set(MBIMPacketServiceActionAttach); - -exit: - return retval; -} - -static int requestSetupDataCall(PROFILE_T *profile, int curIpFamily) { - int retval; - - (void)curIpFamily; - - if (profile->apn) - mbim_apn = profile->apn; - if (profile->user) - mbim_user = profile->user; - if (profile->password) - mbim_passwd = profile->password; - if (profile->auth) - mbim_auth = profile->auth; - if (profile->enable_ipv4) - mbim_iptype = MBIMContextIPTypeIPv4; - if (profile->enable_ipv6) - mbim_iptype = MBIMContextIPTypeIPv6; - if (profile->enable_ipv4 && profile->enable_ipv6) - mbim_iptype = MBIMContextIPTypeIPv4AndIPv6; - - retval = mbim_set_connect(1, mbim_sessionID); - if (retval) - goto exit; - -exit: - return retval; -} - -static int requestQueryDataCall(UCHAR *pConnectionStatus, int curIpFamily) { - int retval; - - (void)curIpFamily; - - *pConnectionStatus = QWDS_PKT_DATA_DISCONNECTED; - - retval = mbim_query_connect(mbim_sessionID); - if (retval) - goto exit; - - switch(ActivationState) { - case MBIMActivationStateUnknown: *pConnectionStatus = QWDS_PKT_DATA_UNKNOW; break; - case MBIMActivationStateActivated: *pConnectionStatus = QWDS_PKT_DATA_CONNECTED; break; - case MBIMActivationStateActivating: *pConnectionStatus = QWDS_PKT_DATA_DISCONNECTED; break; - case MBIMActivationStateDeactivated: *pConnectionStatus = QWDS_PKT_DATA_DISCONNECTED; break; - case MBIMActivationStateDeactivating: *pConnectionStatus = QWDS_PKT_DATA_DISCONNECTED; break; - default: *pConnectionStatus = QWDS_PKT_DATA_DISCONNECTED; break; - } - -exit: - return retval; -} - -static int requestDeactivateDefaultPDP(PROFILE_T *profile, int curIpFamily) { - int retval; - - (void)profile; - (void)curIpFamily; - - retval = mbim_set_connect(0, mbim_sessionID); - if (retval) - goto exit; - -exit: - return retval; -} - -static int requestGetIPAddress(PROFILE_T *profile, int curIpFamily) { - int retval; - - (void)curIpFamily; - retval = mbim_ip_config(profile, mbim_sessionID); - if (retval) - goto exit; - -exit: - return retval; -} - -#ifdef CONFIG_CELLINFO -static int requestGetCellInfoList(void) { - if (qmi_over_mbim_nas) { - if (qmi_request_ops.requestGetCellInfoList) - return qmi_request_ops.requestGetCellInfoList(); - } - - return 0; -} -#endif - -const struct request_ops mbim_request_ops = { - .requestBaseBandVersion = requestBaseBandVersion, - .requestGetSIMStatus = requestGetSIMStatus, - .requestRegistrationState = requestRegistrationState, - .requestSetupDataCall = requestSetupDataCall, - .requestQueryDataCall = requestQueryDataCall, - .requestDeactivateDefaultPDP = requestDeactivateDefaultPDP, - .requestGetIPAddress = requestGetIPAddress, -#ifdef CONFIG_CELLINFO - .requestGetCellInfoList = requestGetCellInfoList, -#endif -}; - -int qmi_over_mbim_qmidev_send(PQCQMIMSG pQMI) { - MBIM_MESSAGE_HEADER *pRequest = NULL; - MBIM_COMMAND_DONE_T *pCmdDone = NULL; - int err; - size_t len = le16toh(pQMI->QMIHdr.Length) + 1; - - if (pQMI->QMIHdr.QMIType != QMUX_TYPE_CTL) { - if (pQMI->QMIHdr.QMIType == QMUX_TYPE_NAS) - pQMI->QMIHdr.ClientId = qmi_over_mbim_nas; - - if (pQMI->QMIHdr.ClientId == 0) { - dbg_time("QMIType %d has no clientID", pQMI->QMIHdr.QMIType); - return -ENODEV; - } - } - - pRequest = compose_qmi_over_mbim_command(1, MBIM_CID_CMD_TYPE_SET, pQMI, len); - err = mbim_send_command(pRequest, &pCmdDone, mbim_default_timeout); - mbim_check_err(err, pRequest, pCmdDone); - - err = -1; - len = le32toh(pCmdDone->InformationBufferLength); - if (len) { - if (write(qmi_over_mbim_sk[0], pCmdDone->InformationBuffer, len) == (long)len) { - err = 0; - }; - } - - mbim_free(pRequest); mbim_free(pCmdDone); - return err; -} diff --git a/quectel_cm_5G/src/qendian.h b/quectel_cm_5G/src/qendian.h deleted file mode 100644 index 5e99d5f..0000000 --- a/quectel_cm_5G/src/qendian.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef __QUECTEL_ENDIAN_H__ -#define __QUECTEL_ENDIAN_H__ -#include - -#ifndef htole32 -#if __BYTE_ORDER == __LITTLE_ENDIAN -#define htole16(x) (uint16_t)(x) -#define le16toh(x) (uint16_t)(x) -#define letoh16(x) (uint16_t)(x) -#define htole32(x) (uint32_t)(x) -#define le32toh(x) (uint32_t)(x) -#define letoh32(x) (uint32_t)(x) -#define htole64(x) (uint64_t)(x) -#define le64toh(x) (uint64_t)(x) -#define letoh64(x) (uint64_t)(x) -#else -static __inline uint16_t __bswap16(uint16_t __x) { - return (__x<<8) | (__x>>8); -} - -static __inline uint32_t __bswap32(uint32_t __x) { - return (__x>>24) | (__x>>8&0xff00) | (__x<<8&0xff0000) | (__x<<24); -} - -static __inline uint64_t __bswap64(uint64_t __x) { - return (__bswap32(__x)+0ULL<<32) | (__bswap32(__x>>32)); -} - -#define htole16(x) __bswap16(x) -#define le16toh(x) __bswap16(x) -#define letoh16(x) __bswap16(x) -#define htole32(x) __bswap32(x) -#define le32toh(x) __bswap32(x) -#define letoh32(x) __bswap32(x) -#define htole64(x) __bswap64(x) -#define le64toh(x) __bswap64(x) -#define letoh64(x) __bswap64(x) -#endif -#endif - -#define le16_to_cpu(x) le16toh((uint16_t)(x)) -#define le32_to_cpu(x) le32toh((uint32_t)(x)) -#define le64_to_cpu(x) le64toh((uint64_t)(x)) -#define cpu_to_le16(x) htole16((uint16_t)(x)) -#define cpu_to_le32(x) htole32((uint32_t)(x)) -#define cpu_to_le64(x) htole64((uint64_t)(x)) - -static __inline uint32_t ql_swap32(uint32_t __x) { - return (__x>>24) | (__x>>8&0xff00) | (__x<<8&0xff0000) | (__x<<24); -} -#endif //__QUECTEL_ENDIAN_H__ - diff --git a/quectel_cm_5G/src/qlist.h b/quectel_cm_5G/src/qlist.h deleted file mode 100644 index c7f95cf..0000000 --- a/quectel_cm_5G/src/qlist.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef __QUECTEL_LIST_H__ -#define __QUECTEL_LIST_H__ -struct qlistnode -{ - struct qlistnode *next; - struct qlistnode *prev; -}; - -#define qnode_to_item(node, container, member) \ - (container *) (((char*) (node)) - offsetof(container, member)) - -#define qlist_for_each(node, list) \ - for (node = (list)->next; node != (list); node = node->next) - -#define qlist_empty(list) ((list) == (list)->next) -#define qlist_head(list) ((list)->next) -#define qlist_tail(list) ((list)->prev) - -static void qlist_init(struct qlistnode *node) -{ - node->next = node; - node->prev = node; -} - -static void qlist_add_tail(struct qlistnode *head, struct qlistnode *item) -{ - item->next = head; - item->prev = head->prev; - head->prev->next = item; - head->prev = item; -} - -static void qlist_remove(struct qlistnode *item) -{ - item->next->prev = item->prev; - item->prev->next = item->next; -} -#endif \ No newline at end of file diff --git a/quectel_cm_5G/src/qmap_bridge_mode.c b/quectel_cm_5G/src/qmap_bridge_mode.c deleted file mode 100644 index 0148b0f..0000000 --- a/quectel_cm_5G/src/qmap_bridge_mode.c +++ /dev/null @@ -1,402 +0,0 @@ -/****************************************************************************** - @file qmap_bridge_mode.c - @brief Connectivity bridge manager. - - DESCRIPTION - Connectivity Management Tool for USB network adapter of Quectel wireless cellular modules. - - INITIALIZATION AND SEQUENCING REQUIREMENTS - None. - - --------------------------------------------------------------------------- - Copyright (c) 2016 - 2020 Quectel Wireless Solution, Co., Ltd. All Rights Reserved. - Quectel Wireless Solution Proprietary and Confidential. - --------------------------------------------------------------------------- -******************************************************************************/ -#include "QMIThread.h" - -static size_t ql_fread(const char *filename, void *buf, size_t size) { - FILE *fp = fopen(filename , "r"); - size_t n = 0; - - memset(buf, 0x00, size); - - if (fp) { - n = fread(buf, 1, size, fp); - if (n <= 0 || n == size) { - dbg_time("warnning: fail to fread(%s), fread=%zu, buf_size=%zu: (%s)", filename, n, size, strerror(errno)); - } - fclose(fp); - } - - return n > 0 ? n : 0; -} - -static size_t ql_fwrite(const char *filename, const void *buf, size_t size) { - FILE *fp = fopen(filename , "w"); - size_t n = 0; - - if (fp) { - n = fwrite(buf, 1, size, fp); - if (n != size) { - dbg_time("warnning: fail to fwrite(%s), fwrite=%zu, buf_size=%zu: (%s)", filename, n, size, strerror(errno)); - } - fclose(fp); - } - - return n > 0 ? n : 0; -} - -int ql_bridge_mode_detect(PROFILE_T *profile) { - const char *ifname = profile->qmapnet_adapter[0] ? profile->qmapnet_adapter : profile->usbnet_adapter; - const char *driver; - char bridge_mode[128]; - char bridge_ipv4[128]; - char ipv4[128]; - char buf[64]; - size_t n; - int in_bridge = 0; - - driver = profile->driver_name; - snprintf(bridge_mode, sizeof(bridge_mode), "/sys/class/net/%s/bridge_mode", ifname); - snprintf(bridge_ipv4, sizeof(bridge_ipv4), "/sys/class/net/%s/bridge_ipv4", ifname); - - if (access(bridge_ipv4, R_OK)) { - if (errno != ENOENT) { - dbg_time("fail to access %s, errno: %d (%s)", bridge_mode, errno, strerror(errno)); - return 0; - } - - snprintf(bridge_mode, sizeof(bridge_mode), "/sys/module/%s/parameters/bridge_mode", driver); - snprintf(bridge_ipv4, sizeof(bridge_ipv4), "/sys/module/%s/parameters/bridge_ipv4", driver); - - if (access(bridge_mode, R_OK)) { - if (errno != ENOENT) { - dbg_time("fail to access %s, errno: %d (%s)", bridge_mode, errno, strerror(errno)); - } - return 0; - } - } - - n = ql_fread(bridge_mode, buf, sizeof(buf)); - if (n > 0) { - in_bridge = (buf[0] != '0'); - } - if (!in_bridge) - return 0; - - memset(ipv4, 0, sizeof(ipv4)); - - if (strstr(bridge_ipv4, "/sys/class/net/") || profile->qmap_mode == 0 || profile->qmap_mode == 1) { - snprintf(ipv4, sizeof(ipv4), "0x%x", profile->ipv4.Address); - dbg_time("echo '%s' > %s", ipv4, bridge_ipv4); - ql_fwrite(bridge_ipv4, ipv4, strlen(ipv4)); - } - else { - snprintf(ipv4, sizeof(ipv4), "0x%x:%d", profile->ipv4.Address, profile->muxid); - dbg_time("echo '%s' > %s", ipv4, bridge_ipv4); - ql_fwrite(bridge_ipv4, ipv4, strlen(ipv4)); - } - - return in_bridge; -} - -int ql_enable_qmi_wwan_rawip_mode(PROFILE_T *profile) { - char filename[256]; - char buf[4]; - size_t n; - FILE *fp; - - if (!qmidev_is_qmiwwan(profile->qmichannel)) - return 0; - - snprintf(filename, sizeof(filename), "/sys/class/net/%s/qmi/rawip", profile->usbnet_adapter); - n = ql_fread(filename, buf, sizeof(buf)); - - if (n == 0) - return 0; - - if (buf[0] == '1' || buf[0] == 'Y') - return 0; - - fp = fopen(filename , "w"); - if (fp == NULL) { - dbg_time("Fail to fopen(%s, \"w\"), errno: %d (%s)", filename, errno, strerror(errno)); - return 1; - } - - buf[0] = 'Y'; - n = fwrite(buf, 1, 1, fp); - if (n != 1) { - dbg_time("Fail to fwrite(%s), errno: %d (%s)", filename, errno, strerror(errno)); - fclose(fp); - return 1; - } - fclose(fp); - - return 0; -} - -int ql_driver_type_detect(PROFILE_T *profile) { - if (qmidev_is_gobinet(profile->qmichannel)) { - profile->qmi_ops = &gobi_qmidev_ops; - } - else { - profile->qmi_ops = &qmiwwan_qmidev_ops; - } - qmidev_send = profile->qmi_ops->send; - - return 0; -} - -void ql_set_driver_bridge_mode(PROFILE_T *profile) { - char enable[16]; - char filename[256]; - - if(profile->qmap_mode) - snprintf(filename, sizeof(filename), "/sys/class/net/%s/bridge_mode", profile->qmapnet_adapter); - else - snprintf(filename, sizeof(filename), "/sys/class/net/%s/bridge_mode", profile->usbnet_adapter); - snprintf(enable, sizeof(enable), "%02d\n", profile->enable_bridge); - ql_fwrite(filename, enable, sizeof(enable)); -} - -static int ql_qmi_qmap_mode_detect(PROFILE_T *profile) { - char buf[128]; - int n; - struct { - char filename[255 * 2]; - char linkname[255 * 2]; - } *pl; - - pl = (typeof(pl)) malloc(sizeof(*pl)); - - snprintf(pl->linkname, sizeof(pl->linkname), "/sys/class/net/%s/device/driver", profile->usbnet_adapter); - n = readlink(pl->linkname, pl->filename, sizeof(pl->filename)); - pl->filename[n] = '\0'; - while (pl->filename[n] != '/') - n--; - strncpy(profile->driver_name, &pl->filename[n+1], sizeof(profile->driver_name) - 1); - - ql_get_driver_rmnet_info(profile, &profile->rmnet_info); - if (profile->rmnet_info.size) { - profile->qmap_mode = profile->rmnet_info.qmap_mode; - if (profile->qmap_mode) { - int offset_id = (profile->muxid == 0)? profile->pdp - 1 : profile->muxid - 0x81; - - if (profile->qmap_mode == 1) - offset_id = 0; - profile->muxid = profile->rmnet_info.mux_id[offset_id]; - strncpy(profile->qmapnet_adapter, profile->rmnet_info.ifname[offset_id], sizeof(profile->qmapnet_adapter) - 1); - profile->qmap_size = profile->rmnet_info.rx_urb_size; - profile->qmap_version = profile->rmnet_info.qmap_version; - } - - goto _out; - } - - snprintf(pl->filename, sizeof(pl->filename), "/sys/class/net/%s/qmap_mode", profile->usbnet_adapter); - if (access(pl->filename, R_OK)) { - if (errno != ENOENT) { - dbg_time("fail to access %s, errno: %d (%s)", pl->filename, errno, strerror(errno)); - goto _out; - } - - snprintf(pl->filename, sizeof(pl->filename), "/sys/module/%s/parameters/qmap_mode", profile->driver_name); - if (access(pl->filename, R_OK)) { - if (errno != ENOENT) { - dbg_time("fail to access %s, errno: %d (%s)", pl->filename, errno, strerror(errno)); - goto _out; - } - - snprintf(pl->filename, sizeof(pl->filename), "/sys/class/net/%s/device/driver/module/parameters/qmap_mode", profile->usbnet_adapter); - if (access(pl->filename, R_OK)) { - if (errno != ENOENT) { - dbg_time("fail to access %s, errno: %d (%s)", pl->filename, errno, strerror(errno)); - goto _out; - } - } - } - } - - if (!access(pl->filename, R_OK)) { - n = ql_fread(pl->filename, buf, sizeof(buf)); - if (n > 0) { - profile->qmap_mode = atoi(buf); - - if (profile->qmap_mode > 1) { - if(!profile->muxid) - profile->muxid = profile->pdp + 0x80; //muxis is 0x8X for PDN-X - snprintf(profile->qmapnet_adapter, sizeof(profile->qmapnet_adapter), - "%.16s.%d", profile->usbnet_adapter, profile->muxid - 0x80); - } if (profile->qmap_mode == 1) { - profile->muxid = 0x81; - strncpy(profile->qmapnet_adapter, profile->usbnet_adapter, sizeof(profile->qmapnet_adapter)); - } - } - } - else if (qmidev_is_qmiwwan(profile->qmichannel)) { - snprintf(pl->filename, sizeof(pl->filename), "/sys/class/net/qmimux%d", profile->pdp - 1); - if (access(pl->filename, R_OK)) { - if (errno != ENOENT) { - dbg_time("fail to access %s, errno: %d (%s)", pl->filename, errno, strerror(errno)); - } - goto _out; - } - - //upstream Kernel Style QMAP qmi_wwan.c - snprintf(pl->filename, sizeof(pl->filename), "/sys/class/net/%s/qmi/add_mux", profile->usbnet_adapter); - n = ql_fread(pl->filename, buf, sizeof(buf)); - if (n >= 5) { - dbg_time("If use QMAP by /sys/class/net/%s/qmi/add_mux", profile->usbnet_adapter); - #if 1 - dbg_time("Please set mtu of wwan0 >= max dl qmap packet size"); - #else - dbg_time("File:%s Line:%d Please make sure add next patch to qmi_wwan.c", __func__, __LINE__); - /* - diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c - index 74bebbd..db8a777 100644 - --- a/drivers/net/usb/qmi_wwan.c - +++ b/drivers/net/usb/qmi_wwan.c - @@ -379,6 +379,24 @@ static ssize_t add_mux_store(struct device *d, struct device_attribute *attr, c - if (!ret) { - info->flags |= QMI_WWAN_FLAG_MUX; - ret = len; - +#if 1 //Add by Quectel - + if (le16_to_cpu(dev->udev->descriptor.idVendor) == 0x2c7c) { - + int idProduct = le16_to_cpu(dev->udev->descriptor.idProduct); - + - + if (idProduct == 0x0121 || idProduct == 0x0125 || idProduct == 0x0435) //MDM9x07 - + dev->rx_urb_size = 4*1024; - + else if (idProduct == 0x0306) //MDM9x40 - + dev->rx_urb_size = 16*1024; - + else if (idProduct == 0x0512) //SDX20 - + dev->rx_urb_size = 32*1024; - + else if (idProduct == 0x0620) //SDX24 - + dev->rx_urb_size = 32*1024; - + else if (idProduct == 0x0800) //SDX55 - + dev->rx_urb_size = 32*1024; - + else - + dev->rx_urb_size = 32*1024; - + } - +#endif - } - err: - rtnl_unlock(); - */ - #endif - profile->qmap_mode = n/5; //0x11\n0x22\n0x33\n - if (profile->qmap_mode > 1) { - //PDN-X map to qmimux-X - if(!profile->muxid) { - profile->muxid = (buf[5*(profile->pdp - 1) + 2] - '0')*16 + (buf[5*(profile->pdp - 1) + 3] - '0'); - snprintf(profile->qmapnet_adapter, sizeof(profile->qmapnet_adapter), "qmimux%d", profile->pdp - 1); - } else { - profile->muxid = (buf[5*(profile->muxid - 0x81) + 2] - '0')*16 + (buf[5*(profile->muxid - 0x81) + 3] - '0'); - snprintf(profile->qmapnet_adapter, sizeof(profile->qmapnet_adapter), "qmimux%d", profile->muxid - 0x81); - } - } else if (profile->qmap_mode == 1) { - profile->muxid = (buf[5*0 + 2] - '0')*16 + (buf[5*0 + 3] - '0'); - snprintf(profile->qmapnet_adapter, sizeof(profile->qmapnet_adapter), - "qmimux%d", 0); - } - } - } - -_out: - if (profile->qmap_mode) { - if (profile->qmap_size == 0) { - profile->qmap_size = 16*1024; - snprintf(pl->filename, sizeof(pl->filename), "/sys/class/net/%s/qmap_size", profile->usbnet_adapter); - if (!access(pl->filename, R_OK)) { - size_t n; - char buf[32]; - n = ql_fread(pl->filename, buf, sizeof(buf)); - if (n > 0) { - profile->qmap_size = atoi(buf); - } - } - } - - if (profile->qmap_version == 0) { - profile->qmap_version = WDA_DL_DATA_AGG_QMAP_ENABLED; - } - - dbg_time("qmap_mode = %d, qmap_version = %d, qmap_size = %d, muxid = 0x%02x, qmap_netcard = %s", - profile->qmap_mode, profile->qmap_version, profile->qmap_size, profile->muxid, profile->qmapnet_adapter); - } - ql_set_driver_bridge_mode(profile); - free(pl); - - return 0; -} - -static int ql_mbim_usb_vlan_mode_detect(PROFILE_T *profile) { - char tmp[128]; - - snprintf(tmp, sizeof(tmp), "/sys/class/net/%s.%d", profile->usbnet_adapter, profile->pdp); - if (!access(tmp, F_OK)) { - profile->qmap_mode = 4; - profile->muxid = profile->pdp; - no_trunc_strncpy(profile->qmapnet_adapter, tmp + strlen("/sys/class/net/"), sizeof(profile->qmapnet_adapter) - 1); - - dbg_time("mbim_qmap_mode = %d, vlan_id = 0x%02x, qmap_netcard = %s", - profile->qmap_mode, profile->muxid, profile->qmapnet_adapter); - } - - return 0; -} - -static int ql_mbim_mhi_qmap_mode_detect(PROFILE_T *profile) { - ql_get_driver_rmnet_info(profile, &profile->rmnet_info); - if (profile->rmnet_info.size) { - profile->qmap_mode = profile->rmnet_info.qmap_mode; - if (profile->qmap_mode) { - int offset_id = profile->pdp - 1; - - if (profile->qmap_mode == 1) - offset_id = 0; - profile->muxid = profile->pdp; - strcpy(profile->qmapnet_adapter, profile->rmnet_info.ifname[offset_id]); - profile->qmap_size = profile->rmnet_info.rx_urb_size; - profile->qmap_version = profile->rmnet_info.qmap_version; - - dbg_time("mbim_qmap_mode = %d, vlan_id = 0x%02x, qmap_netcard = %s", - profile->qmap_mode, profile->muxid, profile->qmapnet_adapter); - } - - goto _out; - } - -_out: - return 0; -} - -int ql_qmap_mode_detect(PROFILE_T *profile) { - if (profile->software_interface == SOFTWARE_MBIM) { - if (profile->hardware_interface == HARDWARE_USB) - return ql_mbim_usb_vlan_mode_detect(profile); - else if (profile->hardware_interface == HARDWARE_PCIE) - return ql_mbim_mhi_qmap_mode_detect(profile); - } else if (profile->software_interface == SOFTWARE_QMI) { - return ql_qmi_qmap_mode_detect(profile); - } -#ifdef CONFIG_QRTR - else if(profile->software_interface == SOFTWARE_QRTR) { - char tmp[128]; - - profile->qmap_mode = 4; - profile->qmap_version = WDA_DL_DATA_AGG_QMAP_V5_ENABLED; - profile->qmap_size = 31*1024; - profile->muxid = 0x80 | profile->pdp; - snprintf(profile->qmapnet_adapter, sizeof(profile->qmapnet_adapter), "rmnet_data%d", profile->muxid&0xF); - - snprintf(tmp, sizeof(tmp), "/sys/class/net/%s", profile->qmapnet_adapter); - if (access(tmp, F_OK)) { - rtrmnet_ctl_create_vnd(profile->usbnet_adapter, profile->qmapnet_adapter, - profile->muxid, profile->qmap_version, 11, 4096); - } - } -#endif - return 0; -} diff --git a/quectel_cm_5G/src/qrtr.c b/quectel_cm_5G/src/qrtr.c deleted file mode 100644 index 2dc1853..0000000 --- a/quectel_cm_5G/src/qrtr.c +++ /dev/null @@ -1,657 +0,0 @@ -//https://github.com/andersson/qrtr -/****************************************************************************** - @file QrtrCM.c - @brief GobiNet driver. - - DESCRIPTION - Connectivity Management Tool for USB network adapter of Quectel wireless cellular modules. - - INITIALIZATION AND SEQUENCING REQUIREMENTS - None. - - --------------------------------------------------------------------------- - Copyright (c) 2016 - 2020 Quectel Wireless Solution, Co., Ltd. All Rights Reserved. - Quectel Wireless Solution Proprietary and Confidential. - --------------------------------------------------------------------------- -******************************************************************************/ -#include -#include -#include -#include -#include -#include "QMIThread.h" - -typedef struct { - uint32_t service; - uint32_t version; - uint32_t instance; - uint32_t node; - uint32_t port; -} QrtrService; - -#define QRTR_MAX (QMUX_TYPE_WDS_ADMIN + 1) -static QrtrService service_list[QRTR_MAX]; -static int qmiclientId[QRTR_MAX]; -static int get_client(UCHAR QMIType); -static uint32_t node_modem = 3; //IPQ ~ 3, QCM ~ 0 - -#ifdef USE_LINUX_MSM_IPC -#include - -struct xport_ipc_router_server_addr { - uint32_t service; - uint32_t instance; - uint32_t node_id; - uint32_t port_id; -}; - -union ctl_msg { - uint32_t cmd; - struct { - uint32_t cmd; - uint32_t service; - uint32_t instance; - uint32_t node_id; - uint32_t port_id; - } srv; - struct { - uint32_t cmd; - uint32_t node_id; - uint32_t port_id; - } cli; - }; -#define CTL_CMD_NEW_SERVER 4 -#define CTL_CMD_REMOVE_SERVER 5 - -#define VERSION_MASK 0xff -#define GET_VERSION(x) (x & 0xff) -#define GET_XPORT_SVC_INSTANCE(x) GET_VERSION(x) -#define GET_INSTANCE(x) ((x & 0xff00) >> 8) - -static int msm_ipc_socket(const char *name) -{ - int sock; - int flags; - - sock = socket(AF_MSM_IPC, SOCK_DGRAM, 0); - if (sock < 0) { - dbg_time("%s(%s) errno: %d (%s)\n", __func__, name, errno, strerror(errno)); - return -1; - } - - fcntl(sock, F_SETFD, FD_CLOEXEC); - flags = fcntl(sock, F_GETFL, 0); - fcntl(sock, F_SETFL, flags | O_NONBLOCK); - - return sock; -} - -static uint32_t xport_lookup -( - int lookup_sock_fd, - uint32_t service_id, - uint32_t version -) -{ - uint32_t num_servers_found = 0; - uint32_t num_entries_to_fill = 4; - struct server_lookup_args *lookup_arg; - int i; - - lookup_arg = (struct server_lookup_args *)malloc(sizeof(*lookup_arg) - + (num_entries_to_fill * sizeof(struct msm_ipc_server_info))); - if (!lookup_arg) - { - dbg_time("%s: Malloc failed\n", __func__); - return 0; - } - - lookup_arg->port_name.service = service_id; - lookup_arg->port_name.instance = GET_XPORT_SVC_INSTANCE(version); - lookup_arg->num_entries_in_array = num_entries_to_fill; - lookup_arg->lookup_mask = VERSION_MASK; - lookup_arg->num_entries_found = 0; - if (ioctl(lookup_sock_fd, IPC_ROUTER_IOCTL_LOOKUP_SERVER, lookup_arg) < 0) - { - dbg_time("%s: Lookup failed for %08x: %08x\n", __func__, service_id, version); - free(lookup_arg); - return 0; - } - - dbg_time("%s: num_entries_found %d for type=%d instance=%d", __func__, - lookup_arg->num_entries_found, service_id, version); - num_servers_found = 0; - for (i = 0; ((i < (int)num_entries_to_fill) && (i < lookup_arg->num_entries_found)); i++) - { - QrtrService service_info[1]; - - if (lookup_arg->srv_info[i].node_id != node_modem) - continue; - num_servers_found++; - - service_info[0].service = lookup_arg->srv_info[i].service; - service_info[0].version = GET_VERSION(lookup_arg->srv_info[i].instance); - service_info[0].instance = GET_INSTANCE(lookup_arg->srv_info[i].instance); - service_info[0].node = lookup_arg->srv_info[i].node_id; - service_info[0].port = lookup_arg->srv_info[i].port_id; - - service_list[service_id] = service_info[0]; - qmiclientId[service_id] = get_client(service_id); - } - - free(lookup_arg); - return num_servers_found; -} - -static int xport_send(int sock, uint32_t node, uint32_t port, const void *data, unsigned int sz) -{ - struct sockaddr_msm_ipc addr = {}; - int rc; - - addr.family = AF_MSM_IPC; - addr.address.addrtype = MSM_IPC_ADDR_ID; - addr.address.addr.port_addr.node_id = node; - addr.address.addr.port_addr.port_id = port; - - rc = sendto(sock, data, sz, MSG_DONTWAIT, (void *)&addr, sizeof(addr)); - if (rc < 0) { - dbg_time("xport_send errno: %d (%s)\n", errno, strerror(errno)); - return -1; - } - - return 0; -} - -static int xport_recv(int sock, void *data, unsigned int sz, uint32_t *node, uint32_t *port) -{ - struct sockaddr_msm_ipc addr = {}; - socklen_t addr_size = sizeof(struct sockaddr_msm_ipc); - int rc; - - rc = recvfrom(sock, data, sz, MSG_DONTWAIT, (void *)&addr, &addr_size); - if (rc < 0) { - dbg_time("xport_recv errno: %d (%s)\n", errno, strerror(errno)); - } - else if (addr.address.addrtype != MSM_IPC_ADDR_ID) { - dbg_time("xport_recv addrtype is NOT MSM_IPC_ADDR_ID\n"); - rc = -1; - } - - *node = addr.address.addr.port_addr.node_id; - *port = addr.address.addr.port_addr.port_id; - return rc; -} -#define qmi_recv xport_recv - -static int xport_ctrl_init(void) -{ - int ctrl_sock; - int rc; - uint32_t instance = 1; //modem - uint32_t version; - - ctrl_sock = msm_ipc_socket("ctrl_port"); - if (ctrl_sock == -1) - return -1; - - rc = ioctl(ctrl_sock, IPC_ROUTER_IOCTL_GET_VERSION, &version); - if (rc < 0) { - dbg_time("%s: failed to get ipc version\n", __func__); - goto init_close_ctrl_fd; - } - dbg_time("%s ipc_version = %d", __func__, version); - - rc = ioctl(ctrl_sock, IPC_ROUTER_IOCTL_BIND_CONTROL_PORT, NULL); - if (rc < 0) { - dbg_time("%s: failed to bind as control port\n", __func__); - goto init_close_ctrl_fd; - } - - //cat /sys/kernel/debug/msm_ipc_router/dump_servers - rc = 0; - rc += xport_lookup(ctrl_sock, QMUX_TYPE_WDS, instance); - if (service_list[QMUX_TYPE_WDS].port) { - qmiclientId[QMUX_TYPE_WDS_IPV6] = get_client(QMUX_TYPE_WDS); - } - rc += xport_lookup(ctrl_sock, QMUX_TYPE_NAS, instance); - rc += xport_lookup(ctrl_sock, QMUX_TYPE_UIM, instance); - rc += xport_lookup(ctrl_sock, QMUX_TYPE_DMS, instance); - rc += xport_lookup(ctrl_sock, QMUX_TYPE_WDS_ADMIN, instance); - - if (rc == 0) { - dbg_time("%s: failed to lookup qmi service\n", __func__); - goto init_close_ctrl_fd; - } - - return ctrl_sock; - -init_close_ctrl_fd: - close(ctrl_sock); - return -1; -} - -static void handle_ctrl_pkt(int sock) { - union ctl_msg pkt; - uint32_t type; - int rc; - - rc = recvfrom(sock, &pkt, sizeof(pkt), 0, NULL, NULL); - if (rc < 0) - return; - - type = le32toh(pkt.cmd); - if (CTL_CMD_NEW_SERVER == type || CTL_CMD_REMOVE_SERVER == type) { - QrtrService s; - - s.service = le32toh(pkt.srv.service); - s.version = le32toh(pkt.srv.instance) & 0xff; - s.instance = le32toh(pkt.srv.instance) >> 8; - s.node = le32toh(pkt.srv.node_id); - s.port = le32toh(pkt.srv.port_id); - - if (debug_qmi) - dbg_time ("[qrtr] %s server on %u:%u -> service %u, version %u, instance %u", - CTL_CMD_NEW_SERVER == type ? "add" : "remove", - s.node, s.port, s.service, s.version, s.instance); - - if (CTL_CMD_NEW_SERVER == type) { - if (s.service < QRTR_MAX) { - service_list[s.service] = s; - } - } - else if (CTL_CMD_REMOVE_SERVER == type) { - if (s.service < QRTR_MAX) { - memset(&service_list[s.service], 0, sizeof(QrtrService)); - } - } - } -} -#else -#include -#include "qrtr.h" -#endif - -static int qrtr_socket(void) -{ - struct sockaddr_qrtr sq; - socklen_t sl = sizeof(sq); - int sock; - int rc; - - sock = socket(AF_QIPCRTR, SOCK_DGRAM, 0); - if (sock < 0) { - dbg_time("qrtr_socket errno: %d (%s)\n", errno, strerror(errno)); - return -1; - } - - rc = getsockname(sock, (void *)&sq, &sl); - if (rc || sq.sq_family != AF_QIPCRTR || sl != sizeof(sq)) { - dbg_time("getsockname: %d (%s)\n", errno, strerror(errno)); - close(sock); - return -1; - } - - return sock; -} - -static int qrtr_send(int sock, uint32_t node, uint32_t port, const void *data, unsigned int sz) -{ - struct sockaddr_qrtr sq = {}; - int rc; - - sq.sq_family = AF_QIPCRTR; - sq.sq_node = node; - sq.sq_port = port; - - rc = sendto(sock, data, sz, MSG_DONTWAIT, (void *)&sq, sizeof(sq)); - if (rc < 0) { - dbg_time("sendto errno: %d (%s)\n", errno, strerror(errno)); - return -1; - } - - return 0; -} - -static int qrtr_recv(int sock, void *data, unsigned int sz, uint32_t *node, uint32_t *port) -{ - struct sockaddr_qrtr sq = {}; - socklen_t sl = sizeof(sq); - int rc; - - rc = recvfrom(sock, data, sz, MSG_DONTWAIT, (void *)&sq, &sl); - if (rc < 0) { - dbg_time("qrtr_recv errno: %d (%s)\n", errno, strerror(errno)); - } - - *node = sq.sq_node; - *port = sq.sq_port; - return rc; - } -#define qmi_recv qrtr_recv - -static int qrtr_ctrl_init(void) { - int sock; - int rc; - struct qrtr_ctrl_pkt pkt; - struct sockaddr_qrtr sq; - socklen_t sl = sizeof(sq); - - sock = qrtr_socket(); - if (sock == -1) - return -1; - - memset(&pkt, 0, sizeof(pkt)); - pkt.cmd = htole32(QRTR_TYPE_NEW_LOOKUP); - - getsockname(sock, (void *)&sq, &sl); - rc = qrtr_send(sock, sq.sq_node, QRTR_PORT_CTRL, &pkt, sizeof(pkt)); - if (rc == -1) { - dbg_time("qrtr_send errno: %d (%s)\n", errno, strerror(errno)); - close(sock); - return -1; - } - - return sock; -} - -static void handle_server_change(uint32_t type, struct qrtr_ctrl_pkt *ppkt) { - struct qrtr_ctrl_pkt pkt = *ppkt; - QrtrService s; - - s.service = le32toh(pkt.server.service); - s.version = le32toh(pkt.server.instance) & 0xff; - s.instance = le32toh(pkt.server.instance) >> 8; - s.node = le32toh(pkt.server.node); - s.port = le32toh(pkt.server.port); - - if (debug_qmi) - dbg_time ("[qrtr] %s server on %u:%u -> service %u, version %u, instance %u", - QRTR_TYPE_NEW_SERVER == type ? "add" : "remove", - s.node, s.port, s.service, s.version, s.instance); - - if (s.node != node_modem) - return; //we only care modem - - if (QRTR_TYPE_NEW_SERVER == type) { - if (s.service < QRTR_MAX) { - service_list[s.service] = s; - } - } - else if (QRTR_TYPE_DEL_SERVER == type) { - if (s.service < QRTR_MAX) { - memset(&service_list[s.service], 0, sizeof(QrtrService)); - } - } - } - -static void handle_ctrl_pkt(int sock) { - struct qrtr_ctrl_pkt pkt; - struct sockaddr_qrtr sq; - socklen_t sl = sizeof(sq); - uint32_t type; - int rc; - - rc = recvfrom(sock, &pkt, sizeof(pkt), 0, (void *)&sq, &sl); - if (rc < 0) - return; - - type = le32toh(pkt.cmd); - if (debug_qmi) - dbg_time("type %u, node %u, sq.port %x, len: %d", type, sq.sq_node, sq.sq_port, rc); - - if (sq.sq_port != QRTR_PORT_CTRL) - return; - - if (QRTR_TYPE_NEW_SERVER == type || QRTR_TYPE_DEL_SERVER == type) { - handle_server_change(type, &pkt); - } -} - -static int get_client(UCHAR QMIType) { - int ClientId; - QrtrService *s = &service_list[QMIType]; - - if (!s ->service) { - dbg_time("%s service: %d for QMIType: %d", __func__, s ->service, QMIType); - return -ENODEV; - } - -#ifdef USE_LINUX_MSM_IPC - ClientId = msm_ipc_socket("xport"); -#else - ClientId = qrtr_socket(); -#endif - if (ClientId == -1) { - return 0; - } - - switch (QMIType) { - case QMUX_TYPE_WDS: dbg_time("Get clientWDS = %d", ClientId); break; - case QMUX_TYPE_DMS: dbg_time("Get clientDMS = %d", ClientId); break; - case QMUX_TYPE_NAS: dbg_time("Get clientNAS = %d", ClientId); break; - case QMUX_TYPE_QOS: dbg_time("Get clientQOS = %d", ClientId); break; - case QMUX_TYPE_WMS: dbg_time("Get clientWMS = %d", ClientId); break; - case QMUX_TYPE_PDS: dbg_time("Get clientPDS = %d", ClientId); break; - case QMUX_TYPE_UIM: dbg_time("Get clientUIM = %d", ClientId); break; - case QMUX_TYPE_WDS_ADMIN: dbg_time("Get clientWDA = %d", ClientId); - break; - default: break; - } - - return ClientId; -} - -static void handle_alloc_client(PROFILE_T *profile) { - int srv_list[] = {QMUX_TYPE_WDS, QMUX_TYPE_NAS, QMUX_TYPE_UIM, QMUX_TYPE_DMS, QMUX_TYPE_WDS_ADMIN}; - size_t i = 0, srv_ready = 0; - static int report = -1; - - if (report != -1) - return; - - for(i = 0; i < sizeof(srv_list)/sizeof(srv_list[0]); i++) { - int srv = srv_list[i]; - - if (service_list[srv].service) - srv_ready++; - else - continue; - - if (qmiclientId[srv] == 0) { - qmiclientId[srv] = get_client(srv); - - if (qmiclientId[srv] != 0) { - if (srv == QMUX_TYPE_WDS) { - qmiclientId[QMUX_TYPE_WDS_IPV6] = get_client(QMUX_TYPE_WDS); - } - else if (srv == QMUX_TYPE_WDS_ADMIN) { - profile->wda_client = qmiclientId[QMUX_TYPE_WDS_ADMIN]; - } - } - } - } - - if (srv_ready == sizeof(srv_list)/sizeof(srv_list[0])) { - if (qmiclientId[QMUX_TYPE_WDS]) { - qmidevice_send_event_to_main(RIL_INDICATE_DEVICE_CONNECTED); - } else { - qmidevice_send_event_to_main(RIL_INDICATE_DEVICE_DISCONNECTED); - } - report = 1; - } -} - -static int qmi_send(PQCQMIMSG pRequest) { - uint8_t QMIType = pRequest->QMIHdr.QMIType; - int sock; - QrtrService *s = &service_list[QMIType == QMUX_TYPE_WDS_IPV6 ? QMUX_TYPE_WDS: QMIType]; - sock = qmiclientId[QMIType]; - - pRequest->QMIHdr.ClientId = 0xaa; - if (!s ->service || !sock) { - dbg_time("%s service: %d, sock: %d for QMIType: %d", __func__, s ->service, sock, QMIType); - return -ENODEV; - } - -#ifdef USE_LINUX_MSM_IPC - return xport_send(sock, s->node, s->port, &pRequest->MUXMsg, - le16_to_cpu(pRequest->QMIHdr.Length) + 1 - sizeof(QCQMI_HDR)); -#else - return qrtr_send(sock, s->node, s->port, &pRequest->MUXMsg, - le16_to_cpu(pRequest->QMIHdr.Length) + 1 - sizeof(QCQMI_HDR)); -#endif -} - -static int qmi_deinit(void) { - unsigned int i; - - for (i = 0; i < sizeof(qmiclientId)/sizeof(qmiclientId[0]); i++) - { - if (qmiclientId[i] != 0) - { - close(qmiclientId[i]); - qmiclientId[i] = 0; - } - } - - return 0; -} - -static void * qmi_read(void *pData) { - PROFILE_T *profile = (PROFILE_T *)pData; - int ctrl_sock; - int wait_for_request_quit = 0; - -#ifdef USE_LINUX_MSM_IPC - ctrl_sock = xport_ctrl_init(); - if (ctrl_sock != -1) - qmidevice_send_event_to_main(RIL_INDICATE_DEVICE_CONNECTED); -#else - ctrl_sock = qrtr_ctrl_init(); -#endif - - if (ctrl_sock == -1) - goto _quit; - - while (1) { - struct pollfd pollfds[16] = {{qmidevice_control_fd[1], POLLIN, 0}, {ctrl_sock, POLLIN, 0}}; - int ne, ret, nevents = 2; - unsigned int i; - - for (i = 0; i < sizeof(qmiclientId)/sizeof(qmiclientId[0]); i++) - { - if (qmiclientId[i] != 0) - { - pollfds[nevents].fd = qmiclientId[i]; - pollfds[nevents].events = POLLIN; - pollfds[nevents].revents = 0; - nevents++; - } - } - - do { - ret = poll(pollfds, nevents, wait_for_request_quit ? 1000 : -1); - } while ((ret < 0) && (errno == EINTR)); - - if (ret == 0 && wait_for_request_quit) { - QmiThreadRecvQMI(NULL); //main thread may pending on QmiThreadSendQMI() - continue; - } - - if (ret <= 0) { - dbg_time("%s poll=%d, errno: %d (%s)", __func__, ret, errno, strerror(errno)); - break; - } - - for (ne = 0; ne < nevents; ne++) { - int fd = pollfds[ne].fd; - short revents = pollfds[ne].revents; - - if (revents & (POLLERR | POLLHUP | POLLNVAL)) { - dbg_time("%s poll err/hup/inval", __func__); - dbg_time("epoll fd = %d, events = 0x%04x", fd, revents); - if (fd == qmidevice_control_fd[1]) { - } else { - } - if (revents & (POLLERR | POLLHUP | POLLNVAL)) - goto _quit; - } - - if ((revents & POLLIN) == 0) - continue; - - if (fd == qmidevice_control_fd[1]) { - int triger_event; - if (read(fd, &triger_event, sizeof(triger_event)) == sizeof(triger_event)) { - //DBG("triger_event = 0x%x", triger_event); - switch (triger_event) { - case RIL_REQUEST_QUIT: - goto _quit; - break; - case SIG_EVENT_STOP: - wait_for_request_quit = 1; - break; - default: - break; - } - } - } - else if (fd == ctrl_sock) { - handle_ctrl_pkt(ctrl_sock); - handle_alloc_client(profile); - } - else - { - PQCQMIMSG pResponse = (PQCQMIMSG)cm_recv_buf; - int rc; - uint32_t sq_node = 0; - uint32_t sq_port = 0; - - rc = qmi_recv(fd, &pResponse->MUXMsg, sizeof(cm_recv_buf) - sizeof(QCQMI_HDR), &sq_node, &sq_port); - if (debug_qmi) - dbg_time("fd %d, node %u, port %x, len: %d", fd, sq_node, sq_port, rc); - - if (rc <= 0) - { - dbg_time("%s read=%d errno: %d (%s)", __func__, rc, errno, strerror(errno)); - break; - } - - for (i = 0; i < sizeof(qmiclientId)/sizeof(qmiclientId[0]); i++) - { - if (qmiclientId[i] == fd) - { - pResponse->QMIHdr.QMIType = i; - - if (service_list[i].node != sq_node || service_list[i].port != sq_port) { - continue; - } - } - } - - pResponse->QMIHdr.IFType = USB_CTL_MSG_TYPE_QMI; - pResponse->QMIHdr.Length = cpu_to_le16(rc + sizeof(QCQMI_HDR) - 1); - pResponse->QMIHdr.CtlFlags = 0x00; - pResponse->QMIHdr.ClientId = 0xaa; - - QmiThreadRecvQMI(pResponse); - } - } - } - -_quit: - qmi_deinit(); - close(ctrl_sock); - qmidevice_send_event_to_main(RIL_INDICATE_DEVICE_DISCONNECTED); - QmiThreadRecvQMI(NULL); //main thread may pending on QmiThreadSendQMI() - dbg_time("%s exit", __func__); - pthread_exit(NULL); - return NULL; -} - -const struct qmi_device_ops qrtr_qmidev_ops = { - .deinit = qmi_deinit, - .send = qmi_send, - .read = qmi_read, -}; - diff --git a/quectel_cm_5G/src/qrtr.h b/quectel_cm_5G/src/qrtr.h deleted file mode 100644 index d1727a8..0000000 --- a/quectel_cm_5G/src/qrtr.h +++ /dev/null @@ -1,74 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -#ifndef _LINUX_QRTR_H -#define _LINUX_QRTR_H - -#include -#include - -#ifndef AF_QIPCRTR -#define AF_QIPCRTR 42 -#endif - -#define QRTR_NODE_BCAST 0xffffffffu -#define QRTR_PORT_CTRL 0xfffffffeu - -struct sockaddr_qrtr { - __kernel_sa_family_t sq_family; - __u32 sq_node; - __u32 sq_port; -}; - -enum qrtr_pkt_type { - QRTR_TYPE_DATA = 1, - QRTR_TYPE_HELLO = 2, - QRTR_TYPE_BYE = 3, - QRTR_TYPE_NEW_SERVER = 4, - QRTR_TYPE_DEL_SERVER = 5, - QRTR_TYPE_DEL_CLIENT = 6, - QRTR_TYPE_RESUME_TX = 7, - QRTR_TYPE_EXIT = 8, - QRTR_TYPE_PING = 9, - QRTR_TYPE_NEW_LOOKUP = 10, - QRTR_TYPE_DEL_LOOKUP = 11, -}; - -#define QRTR_TYPE_DEL_PROC 13 - -struct qrtr_ctrl_pkt { - __le32 cmd; - - union { - struct { - __le32 service; - __le32 instance; - __le32 node; - __le32 port; - } server; - - struct { - __le32 node; - __le32 port; - } client; - - struct { - __le32 rsvd; - __le32 node; - } proc; - - }; -} __attribute__ ((packed)); - -#define QRTR_PROTO_VER_1 1 - -struct qrtr_hdr_v1 { - __le32 version; - __le32 type; - __le32 src_node_id; - __le32 src_port_id; - __le32 confirm_rx; - __le32 size; - __le32 dst_node_id; - __le32 dst_port_id; -} __attribute__ ((packed)); - -#endif /* _LINUX_QRTR_H */ diff --git a/quectel_cm_5G/src/quectel-atc-proxy.c b/quectel_cm_5G/src/quectel-atc-proxy.c deleted file mode 100644 index dc929ad..0000000 --- a/quectel_cm_5G/src/quectel-atc-proxy.c +++ /dev/null @@ -1,506 +0,0 @@ -/****************************************************************************** - @file quectel-atc-proxy.c - @brief atc proxy. - - DESCRIPTION - Connectivity Management Tool for USB network adapter of Quectel wireless cellular modules. - - INITIALIZATION AND SEQUENCING REQUIREMENTS - None. - - --------------------------------------------------------------------------- - Copyright (c) 2016 - 2020 Quectel Wireless Solution, Co., Ltd. All Rights Reserved. - Quectel Wireless Solution Proprietary and Confidential. - --------------------------------------------------------------------------- -******************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "qlist.h" -#include "QMIThread.h" -#include "atchannel.h" -#include "at_tok.h" - -#define dprintf(fmt, args...) do { fprintf(stdout, "%s " fmt, get_time(), ##args); } while(0); -#define SYSCHECK(c) do{if((c)<0) {dprintf("%s %d error: '%s' (code: %d)\n", __func__, __LINE__, strerror(errno), errno); return -1;}}while(0) -#define cfmakenoblock(fd) do{fcntl(fd, F_SETFL, fcntl(fd,F_GETFL) | O_NONBLOCK);}while(0) - -#define safe_free(__x) do { if (__x) { free((void *)__x); __x = NULL;}} while(0) -#define safe_at_response_free(__x) { if (__x) { at_response_free(__x); __x = NULL;}} - -#define at_response_error(err, p_response) \ - (err \ - || p_response == NULL \ - || p_response->finalResponse == NULL \ - || p_response->success == 0) - -typedef struct { - struct qlistnode qnode; - int ClientFd; - unsigned AccessTime; -} ATC_PROXY_CONNECTION; - -static int atc_proxy_quit = 0; -static pthread_t thread_id = 0; -static int atc_dev_fd = -1; -static int atc_proxy_server_fd = -1; -static struct qlistnode atc_proxy_connection; -static int verbose_debug = 0; -static int modem_reset_flag = 0; -static uint8_t atc_buf[4096]; -static int asr_style_atc = 0; -extern int asprintf(char **s, const char *fmt, ...); -static ATC_PROXY_CONNECTION *current_client_fd = NULL; - -static void dump_atc(uint8_t *pATC, int fd,int size, const char flag) -{ - if (verbose_debug) { - printf("%c %d:\n", flag, fd); - printf("%.*s\n", size, pATC); - } -} - -static int send_atc_to_client(int clientFd, uint8_t *pATC, int size) { - struct pollfd pollfds[]= {{clientFd, POLLOUT, 0}}; - ssize_t ret = 0; - - do { - ret = poll(pollfds, sizeof(pollfds)/sizeof(pollfds[0]), 5000); - } while (ret == -1 && errno == EINTR && atc_proxy_quit == 0); - - if (pollfds[0].revents & POLLOUT) { - ret = write(clientFd, pATC, size); - } - - return ret; -} - -static void onUnsolicited (const char *s, const char *sms_pdu) -{ - struct qlistnode *con_node; - int ret; - char buf[1024]; - - if(s) { - strcpy(buf, s); - strcat(buf, "\r\n"); - } - if(sms_pdu) { - strcat(buf, sms_pdu); - strcat(buf, "\r\n"); - } - - if(current_client_fd) { - ATC_PROXY_CONNECTION *atc_con = current_client_fd; - ret = send_atc_to_client(atc_con->ClientFd, (uint8_t *)buf, strlen(buf)); - if(ret < 0) { - close(atc_con->ClientFd); - qlist_remove(&atc_con->qnode); - free(atc_con); - } - return; - } - - qlist_for_each(con_node, &atc_proxy_connection) { - ATC_PROXY_CONNECTION *atc_con = qnode_to_item(con_node, ATC_PROXY_CONNECTION, qnode); - if(atc_con && atc_con->ClientFd > 0) { - ret = send_atc_to_client(atc_con->ClientFd, (uint8_t *)buf, strlen(buf)); - if(ret < 0) { - close(atc_con->ClientFd); - con_node = con_node->prev; - qlist_remove(&atc_con->qnode); - free(atc_con); - continue; - } - } - } -} - -static void onTimeout(void) { - dprintf("%s", __func__); - //TODO -} - -static void onClose(void) { - dprintf("%s", __func__); -} - -static int create_local_server(const char *name) { - int sockfd = -1; - int reuse_addr = 1; - struct sockaddr_un sockaddr; - socklen_t alen; - - /*Create server socket*/ - SYSCHECK(sockfd = socket(AF_LOCAL, SOCK_STREAM, 0)); - - memset(&sockaddr, 0, sizeof(sockaddr)); - sockaddr.sun_family = AF_LOCAL; - sockaddr.sun_path[0] = 0; - memcpy(sockaddr.sun_path + 1, name, strlen(name) ); - - alen = strlen(name) + offsetof(struct sockaddr_un, sun_path) + 1; - SYSCHECK(setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &reuse_addr,sizeof(reuse_addr))); - if(bind(sockfd, (struct sockaddr *)&sockaddr, alen) < 0) { - close(sockfd); - dprintf("bind %s errno: %d (%s)\n", name, errno, strerror(errno)); - return -1; - } - - dprintf("local server: %s sockfd = %d\n", name, sockfd); - cfmakenoblock(sockfd); - listen(sockfd, 1); - - return sockfd; -} - -static void accept_atc_connection(int serverfd) { - int clientfd = -1; - unsigned char addr[128]; - socklen_t alen = sizeof(addr); - ATC_PROXY_CONNECTION *atc_con; - - clientfd = accept(serverfd, (struct sockaddr *)addr, &alen); - - atc_con = (ATC_PROXY_CONNECTION *)malloc(sizeof(ATC_PROXY_CONNECTION)); - if (atc_con) { - qlist_init(&atc_con->qnode); - atc_con->ClientFd= clientfd; - atc_con->AccessTime = 0; - dprintf("+++ ClientFd=%d\n", atc_con->ClientFd); - qlist_add_tail(&atc_proxy_connection, &atc_con->qnode); - } - - cfmakenoblock(clientfd); -} - -static void cleanup_atc_connection(int clientfd) { - struct qlistnode *con_node; - - qlist_for_each(con_node, &atc_proxy_connection) { - ATC_PROXY_CONNECTION *atc_con = qnode_to_item(con_node, ATC_PROXY_CONNECTION, qnode); - if (atc_con->ClientFd == clientfd) { - dprintf("--- ClientFd=%d\n", atc_con->ClientFd); - close(atc_con->ClientFd); - qlist_remove(&atc_con->qnode); - free(atc_con); - if (current_client_fd == atc_con) - current_client_fd = NULL; - break; - } - } -} - -static int atc_proxy_init(void) { - int err; - char *cmd; - ATResponse *p_response = NULL; - - err = at_handshake(); - if (err) { - dprintf("handshake fail, TODO ... "); - goto exit; - } - - at_send_command_singleline("AT+QCFG=\"usbnet\"", "+QCFG:", NULL); - at_send_command_multiline("AT+QNETDEVCTL=?", "+QNETDEVCTL:", NULL); - at_send_command("AT+CGREG=2", NULL); //GPRS Network Registration Status - at_send_command("AT+CEREG=2", NULL); //EPS Network Registration Status - at_send_command("AT+C5GREG=2", NULL); //5GS Network Registration Status - - at_send_command_singleline("AT+QNETDEVSTATUS=?", "+QNETDEVSTATUS:", &p_response); - if (at_response_error(err, p_response)) - asr_style_atc = 1; //EC200T/EC100Y do not support this AT, but RG801/RG500U support - - safe_at_response_free(p_response); - - err = at_send_command_singleline("AT+QCFG=\"NAT\"", "+QCFG:", &p_response); - if (!at_response_error(err, p_response)) { - int old_nat, new_nat = asr_style_atc ? 1 : 0; - - err = at_tok_scanf(p_response->p_intermediates->line, "%s%d", NULL, &old_nat); - if (err == 2 && old_nat != new_nat) { - safe_at_response_free(p_response); - asprintf(&cmd, "AT+QCFG=\"NAT\",%d", new_nat); - err = at_send_command(cmd, &p_response); - safe_free(cmd); - if (!at_response_error(err, p_response)) { - err = at_send_command("at+cfun=1,1",NULL); - } - safe_at_response_free(p_response); - } - err = 0; - } - safe_at_response_free(p_response); - -exit: - return err; -} - -static void atc_start_server(const char* servername) { - atc_proxy_server_fd = create_local_server(servername); - dprintf("atc_proxy_server_fd = %d\n", atc_proxy_server_fd); - if (atc_proxy_server_fd == -1) { - dprintf("Failed to create %s, errno: %d (%s)\n", servername, errno, strerror(errno)); - } -} - -static void atc_close_server(const char* servername) { - if (atc_proxy_server_fd != -1) { - dprintf("%s %s close server\n", __func__, servername); - close(atc_proxy_server_fd); - atc_proxy_server_fd = -1; - } -} - -static void *atc_proxy_loop(void *param) -{ - uint8_t *pATC = atc_buf; - struct qlistnode *con_node; - ATC_PROXY_CONNECTION *atc_con; - - (void)param; - dprintf("%s enter thread_id %p\n", __func__, (void *)pthread_self()); - - qlist_init(&atc_proxy_connection); - while (atc_dev_fd > 0 && atc_proxy_quit == 0) { - struct pollfd pollfds[2+64]; - int ne, ret, nevents = 0; - ssize_t nreads; - - pollfds[nevents].fd = atc_dev_fd; - pollfds[nevents].events = POLLIN; - pollfds[nevents].revents= 0; - nevents++; - - if (atc_proxy_server_fd > 0) { - pollfds[nevents].fd = atc_proxy_server_fd; - pollfds[nevents].events = POLLIN; - pollfds[nevents].revents= 0; - nevents++; - } - - qlist_for_each(con_node, &atc_proxy_connection) { - atc_con = qnode_to_item(con_node, ATC_PROXY_CONNECTION, qnode); - - pollfds[nevents].fd = atc_con->ClientFd; - pollfds[nevents].events = POLLIN; - pollfds[nevents].revents= 0; - nevents++; - - if (nevents == (sizeof(pollfds)/sizeof(pollfds[0]))) - break; - } - - do { - ret = poll(pollfds, nevents, (atc_proxy_server_fd > 0) ? -1 : 200); - } while (ret == -1 && errno == EINTR && atc_proxy_quit == 0); - - if (ret < 0) { - dprintf("%s poll=%d, errno: %d (%s)\n", __func__, ret, errno, strerror(errno)); - goto atc_proxy_loop_exit; - } - - for (ne = 0; ne < nevents; ne++) { - int fd = pollfds[ne].fd; - short revents = pollfds[ne].revents; - - if (revents & (POLLERR | POLLHUP | POLLNVAL)) { - dprintf("%s poll fd = %d, revents = %04x\n", __func__, fd, revents); - if (fd == atc_dev_fd) { - goto atc_proxy_loop_exit; - } else if(fd == atc_proxy_server_fd) { - - } else { - cleanup_atc_connection(fd); - } - continue; - } - - if (!(pollfds[ne].revents & POLLIN)) { - continue; - } - - if (fd == atc_proxy_server_fd) { - accept_atc_connection(fd); - } - else if (fd == atc_dev_fd) { - usleep(10*1000); //let atchannel.c read at response. - if (modem_reset_flag) - goto atc_proxy_loop_exit; - } - else { - memset(atc_buf, 0x0, sizeof(atc_buf)); - nreads = read(fd, pATC, sizeof(atc_buf)); - if (nreads <= 0) { - dprintf("%s read=%d errno: %d (%s)", __func__, (int)nreads, errno, strerror(errno)); - cleanup_atc_connection(fd); - break; - } - - dump_atc(pATC, fd, nreads, 'r'); - qlist_for_each(con_node, &atc_proxy_connection) { - atc_con = qnode_to_item(con_node, ATC_PROXY_CONNECTION, qnode); - if (atc_con->ClientFd == pollfds[nevents].fd) { - current_client_fd = atc_con; - break; - } - } - at_send_command ((const char *)pATC, NULL); - current_client_fd = NULL; - } - } - } - -atc_proxy_loop_exit: - at_close(); - while (!qlist_empty(&atc_proxy_connection)) { - ATC_PROXY_CONNECTION *atc_con = qnode_to_item(qlist_head(&atc_proxy_connection), ATC_PROXY_CONNECTION, qnode); - cleanup_atc_connection(atc_con->ClientFd); - } - dprintf("%s exit, thread_id %p\n", __func__, (void *)pthread_self()); - - return NULL; -} - -static void usage(void) { - dprintf(" -d A valid atc device\n" - " default /dev/ttyUSB2, but /dev/ttyUSB2 may be invalid\n" - " -i netcard name\n" - " -v Will show all details\n"); -} - -static void sig_action(int sig) { - if (atc_proxy_quit == 0) { - atc_proxy_quit = 1; - if (thread_id) - pthread_kill(thread_id, sig); - } -} - -int main(int argc, char *argv[]) { - int opt; - char atc_dev[32+1] = "/dev/ttyUSB2"; - int retry_times = 0; - char servername[64] = {0}; - - optind = 1; - signal(SIGINT, sig_action); - - while ( -1 != (opt = getopt(argc, argv, "d:i:vh"))) { - switch (opt) { - case 'd': - strcpy(atc_dev, optarg); - break; - case 'v': - verbose_debug = 1; - break; - default: - usage(); - return 0; - } - } - - if (access(atc_dev, R_OK | W_OK)) { - dprintf("Fail to access %s, errno: %d (%s). break\n", atc_dev, errno, strerror(errno)); - return -1; - } - - sprintf(servername, "quectel-atc-proxy%c", atc_dev[strlen(atc_dev) - 1]); - dprintf("Will use atc-dev='%s', proxy='%s'\n", atc_dev, servername); - - while (atc_proxy_quit == 0) { - if (access(atc_dev, R_OK | W_OK)) { - dprintf("Fail to access %s, errno: %d (%s). continue\n", atc_dev, errno, strerror(errno)); - // wait device - sleep(3); - continue; - } - - atc_dev_fd = open(atc_dev, O_RDWR | O_NONBLOCK | O_NOCTTY); - if (atc_dev_fd == -1) { - dprintf("Failed to open %s, errno: %d (%s). break\n", atc_dev, errno, strerror(errno)); - return -1; - } - cfmakenoblock(atc_dev_fd); - if (at_open(atc_dev_fd, onUnsolicited, 1)) { - close(atc_dev_fd); - atc_dev_fd = -1; - } - at_set_on_timeout(onTimeout); - at_set_on_reader_closed(onClose); - - /* no atc_proxy_loop lives, create one */ - pthread_create(&thread_id, NULL, atc_proxy_loop, NULL); - /* try to redo init if failed, init function must be successfully */ - while (atc_proxy_init() != 0) { - if (retry_times < 5) { - dprintf("fail to init proxy, try again in 2 seconds.\n"); - sleep(2); - retry_times++; - } else { - dprintf("has failed too much times, restart the modem and have a try...\n"); - break; - } - /* break loop if modem is detached */ - if (access(atc_dev, F_OK|R_OK|W_OK)) - break; - } - retry_times = 0; - atc_start_server(servername); - if (atc_proxy_server_fd == -1) - pthread_cancel(thread_id); - pthread_join(thread_id, NULL); - - /* close local server at last */ - atc_close_server(servername); - close(atc_dev_fd); - /* DO RESTART IN 20s IF MODEM RESET ITSELF */ - if (modem_reset_flag) { - unsigned int time_to_wait = 20; - while (time_to_wait) { - time_to_wait = sleep(time_to_wait); - } - modem_reset_flag = 0; - } - } - - return 0; -} \ No newline at end of file diff --git a/quectel_cm_5G/src/quectel-mbim-proxy.c b/quectel_cm_5G/src/quectel-mbim-proxy.c deleted file mode 100644 index 5cf6f41..0000000 --- a/quectel_cm_5G/src/quectel-mbim-proxy.c +++ /dev/null @@ -1,453 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "qendian.h" - -#define QUECTEL_MBIM_PROXY "quectel-mbim-proxy" -#define safe_close(_fd) do { if (_fd > 0) { close(_fd); _fd = -1; } } while(0) - -#define CM_MAX_CLIENT 32 -#define TID_MASK (0xFFFFFF) -#define TID_SHIFT (24) - -typedef enum { - MBIM_OPEN_MSG = 1, - MBIM_CLOSE_MSG = 2, - MBIM_OPEN_DONE = 0x80000001, - MBIM_CLOSE_DONE = 0x80000002, -} MBIM_MSG; - -typedef struct { - unsigned int MessageType; - unsigned int MessageLength; - unsigned int TransactionId; -} MBIM_MESSAGE_HEADER; - -typedef struct { - MBIM_MESSAGE_HEADER MessageHeader; - unsigned int MaxControlTransfer; -} MBIM_OPEN_MSG_T; - -typedef struct { - MBIM_MESSAGE_HEADER MessageHeader; - unsigned int Status; -} MBIM_OPEN_DONE_T; - -typedef struct { - int client_fd; - int client_idx; -} CM_CLIENT_T; - -static unsigned char cm_recv_buffer[4096]; -static CM_CLIENT_T cm_clients[CM_MAX_CLIENT]; -static int verbose = 0; - -const char * get_time(void) { - static char time_buf[128]; - struct timeval tv; - time_t time; - suseconds_t millitm; - struct tm *ti; - - gettimeofday (&tv, NULL); - - time= tv.tv_sec; - millitm = (tv.tv_usec + 500) / 1000; - - if (millitm == 1000) { - ++time; - millitm = 0; - } - - ti = localtime(&time); - sprintf(time_buf, "[%02d-%02d_%02d:%02d:%02d:%03d]", ti->tm_mon+1, ti->tm_mday, ti->tm_hour, ti->tm_min, ti->tm_sec, (int)millitm); - return time_buf; -} - -#define mbim_debug(fmt, args...) do { fprintf(stdout, "%s " fmt, get_time(), ##args); } while(0); - -static int non_block_write(int fd, void *data, int len) -{ - int ret; - struct pollfd pollfd = {fd, POLLOUT, 0}; - ret = poll(&pollfd, 1, 3000); - - if (ret <= 0) { - mbim_debug("%s poll ret=%d, errno: %d(%s)\n", __func__, ret, errno, strerror(errno)); - } - - ret = write (fd, data, len); - if (ret != len) - mbim_debug("%s write ret=%d, errno: %d(%s)\n", __func__, ret, errno, strerror(errno)); - - return len; -} - -static int mbim_send_open_msg(int mbim_dev_fd, uint32_t MaxControlTransfer) { - MBIM_OPEN_MSG_T open_msg; - MBIM_OPEN_MSG_T *pRequest = &open_msg; - - pRequest->MessageHeader.MessageType = htole32(MBIM_OPEN_MSG); - pRequest->MessageHeader.MessageLength = htole32(sizeof(MBIM_OPEN_MSG_T)); - pRequest->MessageHeader.TransactionId = htole32(1); - pRequest->MaxControlTransfer = htole32(MaxControlTransfer); - - mbim_debug("%s()\n", __func__); - return non_block_write(mbim_dev_fd, pRequest, sizeof(MBIM_OPEN_MSG_T)); -} - -/* - * parameter: proxy name - * return: local proxy server fd or -1 -*/ -static int proxy_make_server(const char *proxy_name) -{ - int len, flag; - struct sockaddr_un sockaddr; - int mbim_server_fd; - - mbim_server_fd = socket(AF_LOCAL, SOCK_STREAM, 0); - if (mbim_server_fd < 0) { - mbim_debug("socket failed: %s\n", strerror(errno)); - return -1; - } - if (fcntl(mbim_server_fd, F_SETFL, fcntl(mbim_server_fd, F_GETFL) | O_NONBLOCK) < 0) - mbim_debug("fcntl set server(%d) NONBLOCK attribute failed: %s\n", mbim_server_fd, strerror(errno)); - - memset(&sockaddr, 0, sizeof(sockaddr)); - sockaddr.sun_family = AF_LOCAL; - sockaddr.sun_path[0] = 0; - snprintf(sockaddr.sun_path, UNIX_PATH_MAX, "0%s", proxy_name); - sockaddr.sun_path[0] = '\0'; // string starts with leading '\0' - flag = 1; - if (setsockopt(mbim_server_fd, SOL_SOCKET, SO_REUSEADDR, &flag, sizeof(flag)) < 0) { - safe_close(mbim_server_fd); - mbim_debug("setsockopt failed\n"); - } - - len = strlen(proxy_name) + offsetof(struct sockaddr_un, sun_path) + 1; - if (bind(mbim_server_fd, (struct sockaddr*)&sockaddr, len) < 0) { - safe_close(mbim_server_fd); - mbim_debug("bind failed: %s\n", strerror(errno)); - return -1; - } - - listen(mbim_server_fd, 4); - return mbim_server_fd; -} - -static int handle_client_connect(int server_fd) -{ - int i, client_fd; - struct sockaddr_in cli_addr; - socklen_t len = sizeof(cli_addr); - - client_fd = accept(server_fd, (struct sockaddr *)&cli_addr, &len); - if (client_fd < 0) { - mbim_debug("proxy accept failed: %s\n", strerror(errno)); - return -1; - } - - if (fcntl(client_fd, F_SETFL, fcntl(client_fd, F_GETFL) | O_NONBLOCK) < 0) - mbim_debug("fcntl set client(%d) NONBLOCK attribute failed: %s\n", client_fd, strerror(errno)); - - for (i = 0; i < CM_MAX_CLIENT; i++) { - if (cm_clients[i].client_fd <= 0) { - cm_clients[i].client_fd = client_fd; - cm_clients[i].client_idx= i+1; - mbim_debug("%s client_fd=%d, client_idx=%d\n", __func__, cm_clients[i].client_fd, cm_clients[i].client_idx); - return 0; - } - } - - close(client_fd); - return -1; -} - -static void handle_client_disconnect(int client_fd) -{ - int i; - - for (i = 0; i < CM_MAX_CLIENT; i++) { - if (cm_clients[i].client_fd == client_fd) { - mbim_debug("%s client_fd=%d, client_idx=%d\n", __func__, cm_clients[i].client_fd, cm_clients[i].client_idx); - safe_close(cm_clients[i].client_fd); - return; - } - } -} - -static int handle_client_request(int mbim_dev_fd, int client_fd, void *pdata, int len) -{ - int i; - int client_idx = -1; - int ret; - MBIM_MESSAGE_HEADER *pRequest = (MBIM_MESSAGE_HEADER *)pdata; - unsigned int TransactionId = le32toh(pRequest->TransactionId); - - for (i = 0; i < CM_MAX_CLIENT; i++) { - if (cm_clients[i].client_fd == client_fd) { - client_idx = cm_clients[i].client_idx; - break; - } - } - - if (client_idx == -1) { - goto error; - } - - if (le32toh(pRequest->MessageType) == MBIM_OPEN_MSG - || le32toh(pRequest->MessageType) == MBIM_CLOSE_MSG) { - MBIM_OPEN_DONE_T OpenDone; - OpenDone.MessageHeader.MessageType = htole32(le32toh(pRequest->MessageType) | 0x80000000); - OpenDone.MessageHeader.MessageLength = htole32(sizeof(OpenDone)); - OpenDone.MessageHeader.TransactionId = htole32(TransactionId); - OpenDone.Status = htole32(0); - non_block_write (client_fd, &OpenDone, sizeof(OpenDone)); - return 0; - } - - /* transfer TransicationID to proxy transicationID and record in sender list */ - pRequest->TransactionId = htole32(TransactionId | (client_idx << TID_SHIFT)); - if (verbose) mbim_debug("REQ client_fd=%d, client_idx=%d, tid=%u\n", - cm_clients[client_idx].client_fd, cm_clients[client_idx].client_idx, TransactionId); - ret = non_block_write (mbim_dev_fd, pRequest, len); - if (ret == len) - return 0; - -error: - return -1; -} - -/* - * Will read message from device and transfer it to clients/client - * Notice: - * unsocial message will be send to all clients - */ -static int handle_device_response(void *pdata, int len) -{ - int i; - MBIM_MESSAGE_HEADER *pResponse = (MBIM_MESSAGE_HEADER *)pdata; - unsigned int TransactionId = le32toh(pResponse->TransactionId); - - /* unsocial/function error message */ - if (TransactionId == 0) { - for (i = 0; i < CM_MAX_CLIENT; i++) { - if (cm_clients[i].client_fd > 0) { - non_block_write(cm_clients[i].client_fd, pResponse, len); - } - } - } - else { - /* try to find the sender */ - int client_idx = (TransactionId >> TID_SHIFT); - - for (i = 0; i < CM_MAX_CLIENT; i++) { - if (cm_clients[i].client_idx == client_idx && cm_clients[i].client_fd > 0) { - TransactionId &= TID_MASK; - pResponse->TransactionId = htole32(TransactionId); - if (verbose) mbim_debug("RSP client_fd=%d, client_idx=%d, tid=%u\n", - cm_clients[i].client_fd, cm_clients[i].client_idx, TransactionId); - non_block_write(cm_clients[i].client_fd, pResponse, len); - break; - } - } - - if (i == CM_MAX_CLIENT) { - mbim_debug("%s nobody care tid=%u\n", __func__, TransactionId); - } - } - - return 0; -} - -static int proxy_loop(int mbim_dev_fd) -{ - int i; - int mbim_server_fd = -1; - - while (mbim_dev_fd > 0) { - struct pollfd pollfds[2+CM_MAX_CLIENT]; - int ne, ret, nevents = 0; - - pollfds[nevents].fd = mbim_dev_fd; - pollfds[nevents].events = POLLIN; - pollfds[nevents].revents= 0; - nevents++; - - if (mbim_server_fd > 0) { - pollfds[nevents].fd = mbim_server_fd; - pollfds[nevents].events = POLLIN; - pollfds[nevents].revents= 0; - nevents++; - - for (i = 0; i < CM_MAX_CLIENT; i++) { - if (cm_clients[i].client_fd > 0) { - pollfds[nevents].fd = cm_clients[i].client_fd; - pollfds[nevents].events = POLLIN; - pollfds[nevents].revents= 0; - nevents++; - } - } - } - - ret = poll(pollfds, nevents, (mbim_server_fd > 0) ? -1 : (10*1000)); - if (ret <= 0) { - goto error; - } - - for (ne = 0; ne < nevents; ne++) { - int fd = pollfds[ne].fd; - short revents = pollfds[ne].revents; - - if (revents & (POLLERR | POLLHUP | POLLNVAL)) { - mbim_debug("%s poll fd = %d, revents = %04x\n", __func__, fd, revents); - if (fd == mbim_dev_fd) { - goto error; - } else if(fd == mbim_server_fd) { - - } else { - handle_client_disconnect(fd); - } - continue; - } - - if (!(pollfds[ne].revents & POLLIN)) { - continue; - } - - if (fd == mbim_server_fd) { - handle_client_connect(fd); - } - else { - int len = read(fd, cm_recv_buffer, sizeof(cm_recv_buffer)); - - if (len <= 0) { - mbim_debug("%s read fd=%d, len=%d, errno: %d(%s)\n", __func__, fd, len, errno, strerror(errno)); - if (fd == mbim_dev_fd) - goto error; - else - handle_client_disconnect(fd); - - return len; - } - - if (fd == mbim_dev_fd) { - if (mbim_server_fd == -1) { - MBIM_OPEN_DONE_T *pOpenDone = (MBIM_OPEN_DONE_T *)cm_recv_buffer; - - if (le32toh(pOpenDone->MessageHeader.MessageType) == MBIM_OPEN_DONE) { - mbim_debug("receive MBIM_OPEN_DONE, status=%d\n", htole32(pOpenDone->Status)); - if (htole32(pOpenDone->Status)) - goto error; - mbim_server_fd = proxy_make_server(QUECTEL_MBIM_PROXY); - mbim_debug("mbim_server_fd=%d\n", mbim_server_fd); - } - } - else { - handle_device_response(cm_recv_buffer, len); - } - } - else { - handle_client_request(mbim_dev_fd, fd, cm_recv_buffer, len); - } - } - } - } - -error: - safe_close(mbim_server_fd); - for (i = 0; i < CM_MAX_CLIENT; i++) { - safe_close(cm_clients[i].client_fd); - } - - mbim_debug("%s exit\n", __func__); - return 0; -} - -/* - * How to use this proxy? - * 1. modprobe -a 8021q - * 2. Create network interface for channels: - * ip link add link wwan0 name wwan0.1 type vlan id 1 - * ip link add link wwan0 name wwan0.2 type vlan id 2 - * 3. Start './mbim-proxy' with -d 'device' - * 4. Start Clients: ./quectel-CM -n id1 - * 5. Start Clients: ./quectel-CM -n id2 - * ... - * Notice: - * mbim-proxy can work in backgroud as a daemon - * '-n' sessionID - * The modem may not support multi-PDN mode or how many PDN it supports is undefined. It depends!!! - * Besides, some modem also may not support some sessionID. For instance EC20 doesn't support SessionId 1... - */ -int main(int argc, char **argv) -{ - int optidx = 0; - int opt; - char *optstr = "d:vh"; - const char *device = "/dev/cdc-wdm0"; - - struct option options[] = { - {"verbose", no_argument, NULL, 'v'}, - {"device", required_argument, NULL, 'd'}, - {0, 0, 0, 0}, - }; - while ((opt = getopt_long(argc, argv, optstr, options, &optidx)) != -1) { - switch (opt) { - case 'v': - verbose = 1; - break; - case 'd': - device = optarg; - break; - case 'h': - mbim_debug("-h Show this message\n"); - mbim_debug("-v Verbose\n"); - mbim_debug("-d [device] MBIM device\n"); - return 0; - default: - mbim_debug("illegal argument\n"); - return -1; - } - } - - if (!device) { - mbim_debug("Missing parameter: device\n"); - return -1; - } - - while (1) { - int mbim_dev_fd = open(device, O_RDWR | O_NONBLOCK | O_NOCTTY); - if (mbim_dev_fd < 0) { - mbim_debug("cannot open mbim_device %s: %s\n", device, strerror(errno)); - sleep(2); - continue; - } - mbim_debug ("mbim_dev_fd=%d\n", mbim_dev_fd); - - memset(cm_clients, 0, sizeof(cm_clients)); - mbim_send_open_msg(mbim_dev_fd, sizeof(cm_recv_buffer)); - proxy_loop(mbim_dev_fd); - safe_close(mbim_dev_fd); - } - - return -1; -} diff --git a/quectel_cm_5G/src/quectel-qmi-proxy.c b/quectel_cm_5G/src/quectel-qmi-proxy.c deleted file mode 100644 index e1d28bc..0000000 --- a/quectel_cm_5G/src/quectel-qmi-proxy.c +++ /dev/null @@ -1,694 +0,0 @@ -/****************************************************************************** - @file quectel-qmi-proxy.c - @brief The qmi proxy. - - DESCRIPTION - Connectivity Management Tool for USB network adapter of Quectel wireless cellular modules. - - INITIALIZATION AND SEQUENCING REQUIREMENTS - None. - - --------------------------------------------------------------------------- - Copyright (c) 2016 - 2020 Quectel Wireless Solution, Co., Ltd. All Rights Reserved. - Quectel Wireless Solution Proprietary and Confidential. - --------------------------------------------------------------------------- -******************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "qendian.h" -#include "qlist.h" -#include "MPQMI.h" -#include "MPQCTL.h" -#include "MPQMUX.h" - -#ifndef MIN -#define MIN(a, b) ((a) < (b)? (a): (b)) -#endif - -const char * get_time(void) { - static char time_buf[128]; - struct timeval tv; - time_t time; - suseconds_t millitm; - struct tm *ti; - - gettimeofday (&tv, NULL); - - time= tv.tv_sec; - millitm = (tv.tv_usec + 500) / 1000; - - if (millitm == 1000) { - ++time; - millitm = 0; - } - - ti = localtime(&time); - sprintf(time_buf, "[%02d-%02d_%02d:%02d:%02d:%03d]", ti->tm_mon+1, ti->tm_mday, ti->tm_hour, ti->tm_min, ti->tm_sec, (int)millitm); - return time_buf; -} - -#define dprintf(fmt, args...) do { fprintf(stdout, "%s " fmt, get_time(), ##args); } while(0); -#define SYSCHECK(c) do{if((c)<0) {dprintf("%s %d error: '%s' (code: %d)\n", __func__, __LINE__, strerror(errno), errno); return -1;}}while(0) -#define cfmakenoblock(fd) do{fcntl(fd, F_SETFL, fcntl(fd,F_GETFL) | O_NONBLOCK);}while(0) - -typedef struct { - struct qlistnode qnode; - int ClientFd; - QCQMIMSG qmi[0]; -} QMI_PROXY_MSG; - -typedef struct { - struct qlistnode qnode; - uint8_t QMIType; - uint8_t ClientId; - unsigned AccessTime; -} QMI_PROXY_CLINET; - -typedef struct { - struct qlistnode qnode; - struct qlistnode client_qnode; - int ClientFd; - unsigned AccessTime; -} QMI_PROXY_CONNECTION; - -#ifdef QUECTEL_QMI_MERGE -#define MERGE_PACKET_IDENTITY 0x2c7c -#define MERGE_PACKET_VERSION 0x0001 -#define MERGE_PACKET_MAX_PAYLOAD_SIZE 56 -typedef struct __QMI_MSG_HEADER { - uint16_t idenity; - uint16_t version; - uint16_t cur_len; - uint16_t total_len; -} QMI_MSG_HEADER; - -typedef struct __QMI_MSG_PACKET { - QMI_MSG_HEADER header; - uint16_t len; - char buf[4096]; -} QMI_MSG_PACKET; -#endif - -static int qmi_proxy_quit = 0; -static pthread_t thread_id = 0; -static int cdc_wdm_fd = -1; -static int qmi_proxy_server_fd = -1; -static struct qlistnode qmi_proxy_connection; -static struct qlistnode qmi_proxy_ctl_msg; -static int verbose_debug = 0; -static int modem_reset_flag = 0; -static int qmi_sync_done = 0; -static uint8_t qmi_buf[4096]; - -#ifdef QUECTEL_QMI_MERGE -static int merge_qmi_rsp_packet(void *buf, ssize_t *src_size) { - static QMI_MSG_PACKET s_QMIPacket; - QMI_MSG_HEADER *header = NULL; - ssize_t size = *src_size; - - if((uint16_t)size < sizeof(QMI_MSG_HEADER)) - return -1; - - header = (QMI_MSG_HEADER *)buf; - if(le16toh(header->idenity) != MERGE_PACKET_IDENTITY || le16toh(header->version) != MERGE_PACKET_VERSION || le16toh(header->cur_len) > le16toh(header->total_len)) - return -1; - - if(le16toh(header->cur_len) == le16toh(header->total_len)) { - *src_size = le16toh(header->total_len); - memcpy(buf, buf + sizeof(QMI_MSG_HEADER), *src_size); - s_QMIPacket.len = 0; - return 0; - } - - memcpy(s_QMIPacket.buf + s_QMIPacket.len, buf + sizeof(QMI_MSG_HEADER), le16toh(header->cur_len)); - s_QMIPacket.len += le16toh(header->cur_len); - - if (le16toh(header->cur_len) < MERGE_PACKET_MAX_PAYLOAD_SIZE || s_QMIPacket.len >= le16toh(header->total_len)) { - memcpy(buf, s_QMIPacket.buf, s_QMIPacket.len); - *src_size = s_QMIPacket.len; - s_QMIPacket.len = 0; - return 0; - } - - return -1; -} -#endif - -static int create_local_server(const char *name) { - int sockfd = -1; - int reuse_addr = 1; - struct sockaddr_un sockaddr; - socklen_t alen; - - /*Create server socket*/ - SYSCHECK(sockfd = socket(AF_LOCAL, SOCK_STREAM, 0)); - - memset(&sockaddr, 0, sizeof(sockaddr)); - sockaddr.sun_family = AF_LOCAL; - sockaddr.sun_path[0] = 0; - memcpy(sockaddr.sun_path + 1, name, strlen(name) ); - - alen = strlen(name) + offsetof(struct sockaddr_un, sun_path) + 1; - SYSCHECK(setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &reuse_addr,sizeof(reuse_addr))); - if(bind(sockfd, (struct sockaddr *)&sockaddr, alen) < 0) { - close(sockfd); - dprintf("bind %s errno: %d (%s)\n", name, errno, strerror(errno)); - return -1; - } - - dprintf("local server: %s sockfd = %d\n", name, sockfd); - cfmakenoblock(sockfd); - listen(sockfd, 1); - - return sockfd; -} - -static void accept_qmi_connection(int serverfd) { - int clientfd = -1; - unsigned char addr[128]; - socklen_t alen = sizeof(addr); - QMI_PROXY_CONNECTION *qmi_con; - - clientfd = accept(serverfd, (struct sockaddr *)addr, &alen); - - qmi_con = (QMI_PROXY_CONNECTION *)malloc(sizeof(QMI_PROXY_CONNECTION)); - if (qmi_con) { - qlist_init(&qmi_con->qnode); - qlist_init(&qmi_con->client_qnode); - qmi_con->ClientFd= clientfd; - qmi_con->AccessTime = 0; - dprintf("+++ ClientFd=%d\n", qmi_con->ClientFd); - qlist_add_tail(&qmi_proxy_connection, &qmi_con->qnode); - } - - cfmakenoblock(clientfd); -} - -static void cleanup_qmi_connection(int clientfd) { - struct qlistnode *con_node, *qmi_node; - - qlist_for_each(con_node, &qmi_proxy_connection) { - QMI_PROXY_CONNECTION *qmi_con = qnode_to_item(con_node, QMI_PROXY_CONNECTION, qnode); - - if (qmi_con->ClientFd == clientfd) { - while (!qlist_empty(&qmi_con->client_qnode)) { - QMI_PROXY_CLINET *qmi_client = qnode_to_item(qlist_head(&qmi_con->client_qnode), QMI_PROXY_CLINET, qnode); - - dprintf("xxx ClientFd=%d QMIType=%d ClientId=%d\n", qmi_con->ClientFd, qmi_client->QMIType, qmi_client->ClientId); - - qlist_remove(&qmi_client->qnode); - free(qmi_client); - } - - qlist_for_each(qmi_node, &qmi_proxy_ctl_msg) { - QMI_PROXY_MSG *qmi_msg = qnode_to_item(qmi_node, QMI_PROXY_MSG, qnode); - - if (qmi_msg->ClientFd == qmi_con->ClientFd) { - qlist_remove(&qmi_msg->qnode); - free(qmi_msg); - break; - } - } - - dprintf("--- ClientFd=%d\n", qmi_con->ClientFd); - close(qmi_con->ClientFd); - qlist_remove(&qmi_con->qnode); - free(qmi_con); - break; - } - } -} - -static void get_client_id(QMI_PROXY_CONNECTION *qmi_con, PQMICTL_GET_CLIENT_ID_RESP_MSG pClient) { - if (pClient->QMIResult == 0 && pClient->QMIError == 0) { - QMI_PROXY_CLINET *qmi_client = (QMI_PROXY_CLINET *)malloc(sizeof(QMI_PROXY_CLINET)); - - qlist_init(&qmi_client->qnode); - qmi_client->QMIType = pClient->QMIType; - qmi_client->ClientId = pClient->ClientId; - qmi_client->AccessTime = 0; - - dprintf("+++ ClientFd=%d QMIType=%d ClientId=%d\n", qmi_con->ClientFd, qmi_client->QMIType, qmi_client->ClientId); - qlist_add_tail(&qmi_con->client_qnode, &qmi_client->qnode); - } -} - -static void release_client_id(QMI_PROXY_CONNECTION *qmi_con, PQMICTL_RELEASE_CLIENT_ID_RESP_MSG pClient) { - struct qlistnode *client_node; - - if (pClient->QMIResult == 0 && pClient->QMIError == 0) { - qlist_for_each (client_node, &qmi_con->client_qnode) { - QMI_PROXY_CLINET *qmi_client = qnode_to_item(client_node, QMI_PROXY_CLINET, qnode); - - if (pClient->QMIType == qmi_client->QMIType && pClient->ClientId == qmi_client->ClientId) { - dprintf("--- ClientFd=%d QMIType=%d ClientId=%d\n", qmi_con->ClientFd, qmi_client->QMIType, qmi_client->ClientId); - qlist_remove(&qmi_client->qnode); - free(qmi_client); - break; - } - } - } -} - -static void dump_qmi(PQCQMIMSG pQMI, int fd, const char flag) -{ - if (verbose_debug) - { - unsigned i; - unsigned size = le16toh(pQMI->QMIHdr.Length) + 1; - printf("%c %d %u: ", flag, fd, size); - if (size > 16) - size = 16; - for (i = 0; i < size; i++) - printf("%02x ", ((uint8_t *)pQMI)[i]); - printf("\n"); - } -} - -static int send_qmi_to_cdc_wdm(PQCQMIMSG pQMI) { - struct pollfd pollfds[]= {{cdc_wdm_fd, POLLOUT, 0}}; - ssize_t ret = 0; - - do { - ret = poll(pollfds, sizeof(pollfds)/sizeof(pollfds[0]), 5000); - } while (ret == -1 && errno == EINTR && qmi_proxy_quit == 0); - - if (pollfds[0].revents & POLLOUT) { - ssize_t size = le16toh(pQMI->QMIHdr.Length) + 1; - ret = write(cdc_wdm_fd, pQMI, size); - dump_qmi(pQMI, cdc_wdm_fd, 'w'); - } - - return ret; -} - -static int send_qmi_to_client(PQCQMIMSG pQMI, int clientFd) { - struct pollfd pollfds[]= {{clientFd, POLLOUT, 0}}; - ssize_t ret = 0; - - do { - ret = poll(pollfds, sizeof(pollfds)/sizeof(pollfds[0]), 5000); - } while (ret == -1 && errno == EINTR && qmi_proxy_quit == 0); - - if (pollfds[0].revents & POLLOUT) { - ssize_t size = le16toh(pQMI->QMIHdr.Length) + 1; - ret = write(clientFd, pQMI, size); - dump_qmi(pQMI, clientFd, 'w'); - } - - return ret; -} - -static void recv_qmi_from_dev(PQCQMIMSG pQMI) { - struct qlistnode *con_node, *client_node; - - if (qmi_proxy_server_fd == -1) { - qmi_sync_done = 1; - } - else if (pQMI->QMIHdr.QMIType == QMUX_TYPE_CTL) { - if (pQMI->CTLMsg.QMICTLMsgHdr.CtlFlags == QMICTL_CTL_FLAG_RSP) { - if (!qlist_empty(&qmi_proxy_ctl_msg)) { - QMI_PROXY_MSG *qmi_msg = qnode_to_item(qlist_head(&qmi_proxy_ctl_msg), QMI_PROXY_MSG, qnode); - - qlist_for_each(con_node, &qmi_proxy_connection) { - QMI_PROXY_CONNECTION *qmi_con = qnode_to_item(con_node, QMI_PROXY_CONNECTION, qnode); - - if (qmi_con->ClientFd == qmi_msg->ClientFd) { - send_qmi_to_client(pQMI, qmi_msg->ClientFd); - - if (le16toh(pQMI->CTLMsg.QMICTLMsgHdrRsp.QMICTLType) == QMICTL_GET_CLIENT_ID_RESP) - get_client_id(qmi_con, &pQMI->CTLMsg.GetClientIdRsp); - else if ((le16toh(pQMI->CTLMsg.QMICTLMsgHdrRsp.QMICTLType) == QMICTL_RELEASE_CLIENT_ID_RESP) || - (le16toh(pQMI->CTLMsg.QMICTLMsgHdrRsp.QMICTLType) == QMICTL_REVOKE_CLIENT_ID_IND)) { - release_client_id(qmi_con, &pQMI->CTLMsg.ReleaseClientIdRsp); - if (le16toh(pQMI->CTLMsg.QMICTLMsgHdrRsp.QMICTLType) == QMICTL_REVOKE_CLIENT_ID_IND) - modem_reset_flag = 1; - } - else { - } - } - } - - qlist_remove(&qmi_msg->qnode); - free(qmi_msg); - } - } - - if (!qlist_empty(&qmi_proxy_ctl_msg)) { - QMI_PROXY_MSG *qmi_msg = qnode_to_item(qlist_head(&qmi_proxy_ctl_msg), QMI_PROXY_MSG, qnode); - - qlist_for_each(con_node, &qmi_proxy_connection) { - QMI_PROXY_CONNECTION *qmi_con = qnode_to_item(con_node, QMI_PROXY_CONNECTION, qnode); - - if (qmi_con->ClientFd == qmi_msg->ClientFd) { - send_qmi_to_cdc_wdm(qmi_msg->qmi); - } - } - } - } - else { - qlist_for_each(con_node, &qmi_proxy_connection) { - QMI_PROXY_CONNECTION *qmi_con = qnode_to_item(con_node, QMI_PROXY_CONNECTION, qnode); - - qlist_for_each(client_node, &qmi_con->client_qnode) { - QMI_PROXY_CLINET *qmi_client = qnode_to_item(client_node, QMI_PROXY_CLINET, qnode); - if (pQMI->QMIHdr.QMIType == qmi_client->QMIType) { - if (pQMI->QMIHdr.ClientId == 0 || pQMI->QMIHdr.ClientId == qmi_client->ClientId) { - send_qmi_to_client(pQMI, qmi_con->ClientFd); - } - } - } - } - } -} - -static int recv_qmi_from_client(PQCQMIMSG pQMI, unsigned size, int clientfd) { - if (qmi_proxy_server_fd <= 0) { - send_qmi_to_cdc_wdm(pQMI); - } - else if (pQMI->QMIHdr.QMIType == QMUX_TYPE_CTL) { - QMI_PROXY_MSG *qmi_msg; - - if (pQMI->CTLMsg.QMICTLMsgHdr.QMICTLType == QMICTL_SYNC_REQ) { - dprintf("do not allow client send QMICTL_SYNC_REQ\n"); - return 0; - } - - if (qlist_empty(&qmi_proxy_ctl_msg)) - send_qmi_to_cdc_wdm(pQMI); - - qmi_msg = malloc(sizeof(QMI_PROXY_MSG) + size); - qlist_init(&qmi_msg->qnode); - qmi_msg->ClientFd = clientfd; - memcpy(qmi_msg->qmi, pQMI, size); - qlist_add_tail(&qmi_proxy_ctl_msg, &qmi_msg->qnode); - } - else { - send_qmi_to_cdc_wdm(pQMI); - } - - return 0; -} - -static int qmi_proxy_init(void) { - unsigned i; - QCQMIMSG _QMI; - PQCQMIMSG pQMI = &_QMI; - - dprintf("%s enter\n", __func__); - - pQMI->QMIHdr.IFType = USB_CTL_MSG_TYPE_QMI; - pQMI->QMIHdr.CtlFlags = 0x00; - pQMI->QMIHdr.QMIType = QMUX_TYPE_CTL; - pQMI->QMIHdr.ClientId= 0x00; - - pQMI->CTLMsg.QMICTLMsgHdr.CtlFlags = QMICTL_FLAG_REQUEST; - - qmi_sync_done = 0; - for (i = 0; i < 10; i++) { - pQMI->CTLMsg.SyncReq.TransactionId = i+1; - pQMI->CTLMsg.SyncReq.QMICTLType = QMICTL_SYNC_REQ; - pQMI->CTLMsg.SyncReq.Length = 0; - - pQMI->QMIHdr.Length = - htole16(le16toh(pQMI->CTLMsg.QMICTLMsgHdr.Length) + sizeof(QCQMI_HDR) + sizeof(QCQMICTL_MSG_HDR) - 1); - - if (send_qmi_to_cdc_wdm(pQMI) <= 0) - break; - - sleep(1); - if (qmi_sync_done) - break; - } - - dprintf("%s %s\n", __func__, qmi_sync_done ? "succful" : "fail"); - return qmi_sync_done ? 0 : -1; -} - -static void qmi_start_server(const char* servername) { - qmi_proxy_server_fd = create_local_server(servername); - dprintf("qmi_proxy_server_fd = %d\n", qmi_proxy_server_fd); - if (qmi_proxy_server_fd == -1) { - dprintf("Failed to create %s, errno: %d (%s)\n", servername, errno, strerror(errno)); - } -} - -static void qmi_close_server(const char* servername) { - if (qmi_proxy_server_fd != -1) { - dprintf("%s %s close server\n", __func__, servername); - close(qmi_proxy_server_fd); - qmi_proxy_server_fd = -1; - } -} - -static void *qmi_proxy_loop(void *param) -{ - PQCQMIMSG pQMI = (PQCQMIMSG)qmi_buf; - struct qlistnode *con_node; - QMI_PROXY_CONNECTION *qmi_con; - - (void)param; - dprintf("%s enter thread_id %p\n", __func__, (void *)pthread_self()); - - qlist_init(&qmi_proxy_connection); - qlist_init(&qmi_proxy_ctl_msg); - - while (cdc_wdm_fd > 0 && qmi_proxy_quit == 0) { - struct pollfd pollfds[2+64]; - int ne, ret, nevents = 0; - ssize_t nreads; - - pollfds[nevents].fd = cdc_wdm_fd; - pollfds[nevents].events = POLLIN; - pollfds[nevents].revents= 0; - nevents++; - - if (qmi_proxy_server_fd > 0) { - pollfds[nevents].fd = qmi_proxy_server_fd; - pollfds[nevents].events = POLLIN; - pollfds[nevents].revents= 0; - nevents++; - } - - qlist_for_each(con_node, &qmi_proxy_connection) { - qmi_con = qnode_to_item(con_node, QMI_PROXY_CONNECTION, qnode); - - pollfds[nevents].fd = qmi_con->ClientFd; - pollfds[nevents].events = POLLIN; - pollfds[nevents].revents= 0; - nevents++; - - if (nevents == (sizeof(pollfds)/sizeof(pollfds[0]))) - break; - } - -#if 0 - dprintf("poll "); - for (ne = 0; ne < nevents; ne++) { - dprintf("%d ", pollfds[ne].fd); - } - dprintf("\n"); -#endif - - do { - //ret = poll(pollfds, nevents, -1); - ret = poll(pollfds, nevents, (qmi_proxy_server_fd > 0) ? -1 : 200); - } while (ret == -1 && errno == EINTR && qmi_proxy_quit == 0); - - if (ret < 0) { - dprintf("%s poll=%d, errno: %d (%s)\n", __func__, ret, errno, strerror(errno)); - goto qmi_proxy_loop_exit; - } - - for (ne = 0; ne < nevents; ne++) { - int fd = pollfds[ne].fd; - short revents = pollfds[ne].revents; - - if (revents & (POLLERR | POLLHUP | POLLNVAL)) { - dprintf("%s poll fd = %d, revents = %04x\n", __func__, fd, revents); - if (fd == cdc_wdm_fd) { - goto qmi_proxy_loop_exit; - } else if(fd == qmi_proxy_server_fd) { - - } else { - cleanup_qmi_connection(fd); - } - - continue; - } - - if (!(pollfds[ne].revents & POLLIN)) { - continue; - } - - if (fd == qmi_proxy_server_fd) { - accept_qmi_connection(fd); - } - else if (fd == cdc_wdm_fd) { - nreads = read(fd, pQMI, sizeof(qmi_buf)); - if (nreads <= 0) { - dprintf("%s read=%d errno: %d (%s)\n", __func__, (int)nreads, errno, strerror(errno)); - goto qmi_proxy_loop_exit; - } -#ifdef QUECTEL_QMI_MERGE - if(merge_qmi_rsp_packet(pQMI, &nreads)) - continue; -#endif - if (nreads != (le16toh(pQMI->QMIHdr.Length) + 1)) { - dprintf("%s nreads=%d, pQCQMI->QMIHdr.Length = %d\n", __func__, (int)nreads, le16toh(pQMI->QMIHdr.Length)); - continue; - } - - dump_qmi(pQMI, fd, 'r'); - recv_qmi_from_dev(pQMI); - if (modem_reset_flag) - goto qmi_proxy_loop_exit; - } - else { - nreads = read(fd, pQMI, sizeof(qmi_buf)); - - if (nreads <= 0) { - dprintf("%s read=%d errno: %d (%s)", __func__, (int)nreads, errno, strerror(errno)); - cleanup_qmi_connection(fd); - break; - } - - if (nreads != (le16toh(pQMI->QMIHdr.Length) + 1)) { - dprintf("%s nreads=%d, pQCQMI->QMIHdr.Length = %d\n", __func__, (int)nreads, le16toh(pQMI->QMIHdr.Length)); - continue; - } - - dump_qmi(pQMI, fd, 'r'); - recv_qmi_from_client(pQMI, nreads, fd); - } - } - } - -qmi_proxy_loop_exit: - while (!qlist_empty(&qmi_proxy_connection)) { - QMI_PROXY_CONNECTION *qmi_con = qnode_to_item(qlist_head(&qmi_proxy_connection), QMI_PROXY_CONNECTION, qnode); - - cleanup_qmi_connection(qmi_con->ClientFd); - } - - dprintf("%s exit, thread_id %p\n", __func__, (void *)pthread_self()); - - return NULL; -} - -static void usage(void) { - dprintf(" -d A valid qmi device\n" - " default /dev/cdc-wdm0, but cdc-wdm0 may be invalid\n" - " -i netcard name\n" - " -v Will show all details\n"); -} - -static void sig_action(int sig) { - if (qmi_proxy_quit == 0) { - qmi_proxy_quit = 1; - if (thread_id) - pthread_kill(thread_id, sig); - } -} - -int main(int argc, char *argv[]) { - int opt; - char cdc_wdm[32+1] = "/dev/cdc-wdm0"; - int retry_times = 0; - char servername[64] = {0}; - - optind = 1; - - signal(SIGINT, sig_action); - - while ( -1 != (opt = getopt(argc, argv, "d:i:vh"))) { - switch (opt) { - case 'd': - strcpy(cdc_wdm, optarg); - break; - case 'v': - verbose_debug = 1; - break; - default: - usage(); - return 0; - } - } - - if (access(cdc_wdm, R_OK | W_OK)) { - dprintf("Fail to access %s, errno: %d (%s). break\n", cdc_wdm, errno, strerror(errno)); - return -1; - } - - sprintf(servername, "quectel-qmi-proxy%c", cdc_wdm[strlen(cdc_wdm)-1]); - dprintf("Will use cdc-wdm='%s', proxy='%s'\n", cdc_wdm, servername); - - while (qmi_proxy_quit == 0) { - if (access(cdc_wdm, R_OK | W_OK)) { - dprintf("Fail to access %s, errno: %d (%s). continue\n", cdc_wdm, errno, strerror(errno)); - // wait device - sleep(3); - continue; - } - - cdc_wdm_fd = open(cdc_wdm, O_RDWR | O_NONBLOCK | O_NOCTTY); - if (cdc_wdm_fd == -1) { - dprintf("Failed to open %s, errno: %d (%s). break\n", cdc_wdm, errno, strerror(errno)); - return -1; - } - cfmakenoblock(cdc_wdm_fd); - - /* no qmi_proxy_loop lives, create one */ - pthread_create(&thread_id, NULL, qmi_proxy_loop, NULL); - /* try to redo init if failed, init function must be successfully */ - while (qmi_proxy_init() != 0) { - if (retry_times < 5) { - dprintf("fail to init proxy, try again in 2 seconds.\n"); - sleep(2); - retry_times++; - } else { - dprintf("has failed too much times, restart the modem and have a try...\n"); - break; - } - /* break loop if modem is detached */ - if (access(cdc_wdm, F_OK|R_OK|W_OK)) - break; - } - retry_times = 0; - qmi_start_server(servername); - if (qmi_proxy_server_fd == -1) - pthread_cancel(thread_id); - pthread_join(thread_id, NULL); - - /* close local server at last */ - qmi_close_server(servername); - close(cdc_wdm_fd); - /* DO RESTART IN 20s IF MODEM RESET ITSELF */ - if (modem_reset_flag) { - unsigned int time_to_wait = 20; - while (time_to_wait) { - time_to_wait = sleep(time_to_wait); - } - modem_reset_flag = 0; - } - } - - return 0; -} diff --git a/quectel_cm_5G/src/quectel-qrtr-proxy.c b/quectel_cm_5G/src/quectel-qrtr-proxy.c deleted file mode 100644 index 9404e96..0000000 --- a/quectel_cm_5G/src/quectel-qrtr-proxy.c +++ /dev/null @@ -1,894 +0,0 @@ -/****************************************************************************** - @file quectel-qrtr-proxy.c - @brief The qrtr proxy. - - DESCRIPTION - Connectivity Management Tool for USB/PCIE network adapter of Quectel wireless cellular modules. - - INITIALIZATION AND SEQUENCING REQUIREMENTS - None. - - --------------------------------------------------------------------------- - Copyright (c) 2016 - 2020 Quectel Wireless Solution, Co., Ltd. All Rights Reserved. - Quectel Wireless Solution Proprietary and Confidential. - --------------------------------------------------------------------------- -******************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "qrtr.h" - -#include "qendian.h" -#include "qlist.h" -#include "MPQMI.h" -#include "MPQCTL.h" -#include "MPQMUX.h" - -static const char * get_time(void) { - static char time_buf[128]; - struct timeval tv; - time_t time; - suseconds_t millitm; - struct tm *ti; - - gettimeofday (&tv, NULL); - - time= tv.tv_sec; - millitm = (tv.tv_usec + 500) / 1000; - - if (millitm == 1000) { - ++time; - millitm = 0; - } - - ti = localtime(&time); - sprintf(time_buf, "[%02d-%02d_%02d:%02d:%02d:%03d]", ti->tm_mon+1, ti->tm_mday, ti->tm_hour, ti->tm_min, ti->tm_sec, (int)millitm); - return time_buf; -} - -#define dprintf(fmt, args...) do { fprintf(stdout, "%s " fmt, get_time(), ##args); } while(0); -#define SYSCHECK(c) do{if((c)<0) {dprintf("%s %d error: '%s' (code: %d)\n", __func__, __LINE__, strerror(errno), errno); return -1;}}while(0) -#define cfmakenoblock(fd) do{fcntl(fd, F_SETFL, fcntl(fd,F_GETFL) | O_NONBLOCK);}while(0) -#define align_4(_len) (((_len) + 3) & ~3) - -typedef struct { - struct qlistnode qnode; - int ClientFd; - QCQMIMSG qrtr[0]; -} QRTR_PROXY_MSG; - -typedef struct { - struct qlistnode qnode; - uint8_t QMIType; - uint8_t ClientId; - uint32_t node_id; - uint32_t port_id; - unsigned AccessTime; -} QRTR_PROXY_CLINET; - -typedef struct { - struct qlistnode qnode; - struct qlistnode client_qnode; - int ClientFd; - unsigned AccessTime; -} QRTR_PROXY_CONNECTION; - -typedef struct { - struct qlistnode qnode; - uint32_t service; - uint32_t version; - uint32_t instance; - uint32_t node; - uint32_t port; - - __le32 src_node_id; - __le32 src_port_id; -} QRTR_SERVICE; - -static int qrtr_proxy_quit = 0; -static pthread_t thread_id = 0; -static int cdc_wdm_fd = -1; -static int qrtr_proxy_server_fd = -1; -static struct qlistnode qrtr_proxy_connection; -static struct qlistnode qrtr_server_list; -static int verbose_debug = 0; -static uint32_t node_modem = 3; //IPQ ~ 3, QCM ~ 0 -static uint32_t node_myself = 1; - -static QRTR_SERVICE *find_qrtr_service(uint8_t QMIType) -{ - struct qlistnode *node; - - qlist_for_each (node, &qrtr_server_list) { - QRTR_SERVICE *srv = qnode_to_item(node, QRTR_SERVICE, qnode); - if (srv->service == QMIType) - return srv; - } - - return NULL; -} - -static uint8_t client_bitmap[0xf0]; -static uint8_t port_bitmap[0xff0]; -static int alloc_client_id(void) { - int id = 1; - - for (id = 1; id < (int)sizeof(client_bitmap); id++) { - if (client_bitmap[id] == 0) { - client_bitmap[id] = id; - return id; - } - } - - dprintf("NOT find %s()\n", __func__); - return 0; -} - -static void free_client_id(int id) { - if (id < (int)sizeof(client_bitmap) && client_bitmap[id] == id) { - client_bitmap[id] = 0; - return; - } - dprintf("NOT find %s(id=%d)\n", __func__, id); -} - -static int alloc_port_id(void) { - int id = 1; - - for (id = 1; id < (int)sizeof(port_bitmap); id++) { - if (port_bitmap[id] == 0) { - port_bitmap[id] = id; - return id; - } - } - - dprintf("NOT find %s()\n", __func__); - return 0; -} - -static void free_port_id(int id) { - if (id < (int)sizeof(port_bitmap) && port_bitmap[id] == id) { - port_bitmap[id] = 0; - return; - } - dprintf("NOT find %s(id=%d)\n", __func__, id); -} - -static void dump_qrtr(void *buf, size_t len, char flag) -{ - size_t i; - static char printf_buf[1024]; - int cnt = 0, limit=1024; - unsigned char *d = (unsigned char *)buf; - struct qrtr_hdr_v1 *hdr = (struct qrtr_hdr_v1 *)buf; - const char *ctrl_pkt_strings[] = { - [QRTR_TYPE_DATA] = "data", - [QRTR_TYPE_HELLO] = "hello", - [QRTR_TYPE_BYE] = "bye", - [QRTR_TYPE_NEW_SERVER] = "new-server", - [QRTR_TYPE_DEL_SERVER] = "del-server", - [QRTR_TYPE_DEL_CLIENT] = "del-client", - [QRTR_TYPE_RESUME_TX] = "resume-tx", - [QRTR_TYPE_EXIT] = "exit", - [QRTR_TYPE_PING] = "ping", - [QRTR_TYPE_NEW_LOOKUP] = "new-lookup", - [QRTR_TYPE_DEL_LOOKUP] = "del-lookup", - }; - - for (i = 0; i < len && i < 64; i++) { - if (i%4 == 0) - cnt += snprintf(printf_buf+cnt, limit-cnt, " "); - cnt += snprintf(printf_buf+cnt, limit-cnt, "%02x", d[i]); - } - dprintf("%s\n", printf_buf); - - dprintf("%c ver=%d, type=%d(%s), %x,%x -> %x,%x, confirm_rx=%d, size=%u\n", - flag, - le32toh(hdr->version), le32toh(hdr->type), ctrl_pkt_strings[le32toh(hdr->type)], - le32toh(hdr->src_node_id), le32toh(hdr->src_port_id), le32toh(hdr->dst_node_id), le32toh(hdr->dst_port_id), - le32toh(hdr->confirm_rx), le32toh(hdr->size)); -} - -static int send_qmi_to_client(PQCQMIMSG pQMI, int fd) { - struct pollfd pollfds[]= {{fd, POLLOUT, 0}}; - ssize_t ret = 0; - ssize_t size = le16toh(pQMI->QMIHdr.Length) + 1; - - do { - ret = poll(pollfds, sizeof(pollfds)/sizeof(pollfds[0]), 5000); - } while (ret == -1 && errno == EINTR && qrtr_proxy_quit == 0); - - if (pollfds[0].revents & POLLOUT) { - ret = write(fd, pQMI, size); - } - - return ret == size ? 0 : -1; -} - -static int send_qrtr_to_dev(struct qrtr_hdr_v1 *hdr, int fd) { - struct pollfd pollfds[]= {{fd, POLLOUT, 0}}; - ssize_t ret = 0; - ssize_t size = align_4(le32toh(hdr->size) + sizeof(*hdr)); - - do { - ret = poll(pollfds, sizeof(pollfds)/sizeof(pollfds[0]), 5000); - } while (ret == -1 && errno == EINTR && qrtr_proxy_quit == 0); - - if (pollfds[0].revents & POLLOUT) { - ret = write(fd, hdr, size); - } - - return ret == size ? 0 : -1; -} - -static int qrtr_node_enqueue(const void *data, size_t len, - int type, struct sockaddr_qrtr *from, - struct sockaddr_qrtr *to, unsigned int confirm_rx) -{ - int rc = -1; - size_t size = sizeof(struct qrtr_hdr_v1) + len; - struct qrtr_hdr_v1 *hdr = (struct qrtr_hdr_v1 *)malloc(align_4(size)); - - if (hdr) { - hdr->version = htole32(QRTR_PROTO_VER_1); - hdr->type = htole32(type); - hdr->src_node_id = htole32(from->sq_node); - hdr->src_port_id = htole32(from->sq_port); - hdr->dst_node_id = htole32(to->sq_node); - hdr->dst_port_id = htole32(to->sq_port); - hdr->size = htole32(len); - hdr->confirm_rx = htole32(!!confirm_rx); - - memcpy(hdr + 1, data, len); - dump_qrtr(hdr, size, '>'); - send_qrtr_to_dev(hdr, cdc_wdm_fd); - free(hdr); - } - - return rc; -} - -static int send_ctrl_hello(__u32 sq_node, __u32 sq_port) -{ - struct qrtr_ctrl_pkt pkt; - int rc; - struct sockaddr_qrtr to = {AF_QIPCRTR, sq_node, sq_port}; - struct sockaddr_qrtr from = {AF_QIPCRTR, node_myself, QRTR_PORT_CTRL}; - - memset(&pkt, 0, sizeof(pkt)); - pkt.cmd = htole32(QRTR_TYPE_HELLO); - - rc = qrtr_node_enqueue(&pkt, sizeof(pkt), QRTR_TYPE_HELLO, &from, &to, 0); - if (rc < 0) - return rc; - - return 0; -} - -static int ctrl_cmd_del_client(__u32 sq_node, __u32 sq_port, uint8_t QMIType) -{ - struct qrtr_ctrl_pkt pkt; - int rc; - struct sockaddr_qrtr to = {AF_QIPCRTR, QRTR_NODE_BCAST, QRTR_PORT_CTRL}; - struct sockaddr_qrtr from = {AF_QIPCRTR, sq_node, sq_port}; - QRTR_SERVICE *srv = find_qrtr_service(QMIType); - - if (srv) { - to.sq_node = srv->src_node_id; - } - - memset(&pkt, 0, sizeof(pkt)); - pkt.cmd = htole32(QRTR_TYPE_DEL_CLIENT); - pkt.client.node = htole32(sq_node); - pkt.client.port = htole32(sq_port); - - rc = qrtr_node_enqueue(&pkt, sizeof(pkt), QRTR_TYPE_DATA, &from, &to, 0); - if (rc < 0) - return rc; - - return 0; -} - -static void handle_server_change(struct qrtr_hdr_v1 *hdr) { - struct qrtr_ctrl_pkt *pkt = (struct qrtr_ctrl_pkt *)(hdr + 1); - QRTR_SERVICE *s; - - dprintf ("[qrtr] %s server on %u:%u(%u:%u) -> service %u, instance %x\n", - QRTR_TYPE_NEW_SERVER == hdr->type ? "add" : "remove", - le32toh(pkt->server.node), le32toh(pkt->server.port), - le32toh(hdr->src_node_id), le32toh(hdr->src_port_id), - le32toh(pkt->server.service), le32toh(pkt->server.instance)); - - if (le32toh(pkt->server.node) != node_modem) { - return; //we only care modem - } - - s = (QRTR_SERVICE *)malloc(sizeof(QRTR_SERVICE)); - if (!s) - return; - - qlist_init(&s->qnode); - s->service = le32toh(pkt->server.service); - s->version = le32toh(pkt->server.instance) & 0xff; - s->instance = le32toh(pkt->server.instance) >> 8; - s->node = le32toh(pkt->server.node); - s->port = le32toh(pkt->server.port); - - s->src_node_id = le32toh(hdr->src_node_id); - s->src_port_id = le32toh(hdr->src_port_id); - - if (QRTR_TYPE_NEW_SERVER == hdr->type) { - qlist_add_tail(&qrtr_server_list, &s->qnode); - } - else if (QRTR_TYPE_DEL_SERVER == hdr->type) { - qlist_remove(&s->qnode); - } -} - -static int create_local_server(const char *name) { - int sockfd = -1; - int reuse_addr = 1; - struct sockaddr_un sockaddr; - socklen_t alen; - - /*Create server socket*/ - SYSCHECK(sockfd = socket(AF_LOCAL, SOCK_STREAM, 0)); - - memset(&sockaddr, 0, sizeof(sockaddr)); - sockaddr.sun_family = AF_LOCAL; - sockaddr.sun_path[0] = 0; - memcpy(sockaddr.sun_path + 1, name, strlen(name) ); - - alen = strlen(name) + offsetof(struct sockaddr_un, sun_path) + 1; - SYSCHECK(setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &reuse_addr,sizeof(reuse_addr))); - if(bind(sockfd, (struct sockaddr *)&sockaddr, alen) < 0) { - close(sockfd); - dprintf("bind %s errno: %d (%s)\n", name, errno, strerror(errno)); - return -1; - } - - dprintf("local server: %s sockfd = %d\n", name, sockfd); - cfmakenoblock(sockfd); - listen(sockfd, 1); - - return sockfd; -} - -static uint8_t alloc_qrtr_client_id(QRTR_PROXY_CONNECTION *qrtr_con, uint8_t QMIType) { - QRTR_PROXY_CLINET *qrtr_client = (QRTR_PROXY_CLINET *)malloc(sizeof(QRTR_PROXY_CLINET)); - - qlist_init(&qrtr_client->qnode); - qrtr_client->QMIType = QMIType; - qrtr_client->ClientId = alloc_client_id(); - qrtr_client->node_id = 1; - qrtr_client->port_id = alloc_port_id(); - qrtr_client->AccessTime = 0; - - dprintf("+++ ClientFd=%d QMIType=%d ClientId=%d, node_id=%d, port_id=%d\n", - qrtr_con->ClientFd, qrtr_client->QMIType, qrtr_client->ClientId, - qrtr_client->node_id, qrtr_client->port_id); - qlist_add_tail(&qrtr_con->client_qnode, &qrtr_client->qnode); - - return qrtr_client->ClientId; -} - -static void release_qrtr_client_id(QRTR_PROXY_CONNECTION *qrtr_con, uint8_t QMIType, uint8_t ClientId) { - struct qlistnode *client_node; - int find = 0; - - qlist_for_each (client_node, &qrtr_con->client_qnode) { - QRTR_PROXY_CLINET *qrtr_client = qnode_to_item(client_node, QRTR_PROXY_CLINET, qnode); - - if (QMIType == qrtr_client->QMIType && ClientId == qrtr_client->ClientId) { - dprintf("--- ClientFd=%d QMIType=%d ClientId=%d, node_id=%d, port_id=%d\n", - qrtr_con->ClientFd, qrtr_client->QMIType, qrtr_client->ClientId, - qrtr_client->node_id, qrtr_client->port_id); - ctrl_cmd_del_client(qrtr_client->node_id, qrtr_client->port_id, qrtr_client->QMIType); - free_client_id(qrtr_client->ClientId); - free_port_id(qrtr_client->port_id); - qlist_remove(&qrtr_client->qnode); - free(qrtr_client); - find++; - break; - } - } - - if (!find) { - dprintf("NOT find on %s(ClientFd=%d, QMIType=%d, ClientId=%d)\n", - __func__, qrtr_con->ClientFd, QMIType, ClientId); - } -} - -static void accept_qrtr_connection(int serverfd) { - int clientfd = -1; - unsigned char addr[128]; - socklen_t alen = sizeof(addr); - QRTR_PROXY_CONNECTION *qrtr_con; - - clientfd = accept(serverfd, (struct sockaddr *)addr, &alen); - - qrtr_con = (QRTR_PROXY_CONNECTION *)malloc(sizeof(QRTR_PROXY_CONNECTION)); - if (qrtr_con) { - qlist_init(&qrtr_con->qnode); - qlist_init(&qrtr_con->client_qnode); - qrtr_con->ClientFd= clientfd; - qrtr_con->AccessTime = 0; - dprintf("+++ ClientFd=%d\n", qrtr_con->ClientFd); - qlist_add_tail(&qrtr_proxy_connection, &qrtr_con->qnode); - } - - cfmakenoblock(clientfd); -} - -static void cleanup_qrtr_connection(int clientfd) { - struct qlistnode *con_node; - int find = 0; - - qlist_for_each(con_node, &qrtr_proxy_connection) { - QRTR_PROXY_CONNECTION *qrtr_con = qnode_to_item(con_node, QRTR_PROXY_CONNECTION, qnode); - - if (qrtr_con->ClientFd == clientfd) { - while (!qlist_empty(&qrtr_con->client_qnode)) { - QRTR_PROXY_CLINET *qrtr_client = qnode_to_item(qlist_head(&qrtr_con->client_qnode), QRTR_PROXY_CLINET, qnode); - - release_qrtr_client_id(qrtr_con, qrtr_client->QMIType, qrtr_client->ClientId); - } - - dprintf("--- ClientFd=%d\n", qrtr_con->ClientFd); - close(qrtr_con->ClientFd); - qlist_remove(&qrtr_con->qnode); - free(qrtr_con); - find = 1; - break; - } - } - - if (!find) { - dprintf("NOT find on %s(ClientFd=%d)\n", __func__, clientfd); - } -} - -static void recv_qrtr_from_dev(struct qrtr_hdr_v1 *hdr) { - int find = 0; - uint32_t type = le32toh(hdr->type); - - if (type == QRTR_TYPE_HELLO) { - send_ctrl_hello(le32toh(hdr->src_node_id), le32toh(hdr->src_port_id)); - find++; - } - else if (type == QRTR_TYPE_NEW_SERVER || type == QRTR_TYPE_DEL_SERVER) { - handle_server_change(hdr); - find++; - } - else if (type == QRTR_TYPE_DATA) { - struct qlistnode *con_node, *client_node; - - qlist_for_each(con_node, &qrtr_proxy_connection) { - QRTR_PROXY_CONNECTION *qrtr_con = qnode_to_item(con_node, QRTR_PROXY_CONNECTION, qnode); - - qlist_for_each(client_node, &qrtr_con->client_qnode) { - QRTR_PROXY_CLINET *qrtr_client = qnode_to_item(client_node, QRTR_PROXY_CLINET, qnode); - - if (qrtr_client->node_id == le32toh(hdr->dst_node_id) && qrtr_client->port_id == le32toh(hdr->dst_port_id)) { - PQCQMIMSG pQMI = (PQCQMIMSG)malloc(hdr->size + sizeof(QCQMI_HDR)); - - if (pQMI) { - pQMI->QMIHdr.IFType = USB_CTL_MSG_TYPE_QMI; - pQMI->QMIHdr.Length = htole16(hdr->size + sizeof(QCQMI_HDR) - 1); - pQMI->QMIHdr.CtlFlags = 0x00; - pQMI->QMIHdr.QMIType = qrtr_client->QMIType; - pQMI->QMIHdr.ClientId = qrtr_client->ClientId; - memcpy(&pQMI->MUXMsg, hdr + 1, hdr->size); - send_qmi_to_client(pQMI, qrtr_con->ClientFd); - free(pQMI); - find++; - } - } - } - } - - if (hdr->confirm_rx) { - struct qrtr_ctrl_pkt pkt; - struct sockaddr_qrtr from = {AF_QIPCRTR, le32toh(hdr->dst_node_id), le32toh(hdr->dst_port_id)}; - struct sockaddr_qrtr to = {AF_QIPCRTR, le32toh(hdr->src_node_id), le32toh(hdr->src_port_id)}; - - memset(&pkt, 0, sizeof(pkt)); - pkt.cmd = htole32(QRTR_TYPE_RESUME_TX); - pkt.client.node = hdr->dst_node_id; - pkt.client.port = hdr->dst_port_id; - - qrtr_node_enqueue(&pkt, sizeof(pkt), QRTR_TYPE_RESUME_TX, &from, &to, 0); - } - } - else if (type == QRTR_TYPE_RESUME_TX) { - } - - if (!find) { - dprintf("NOT find on %s()\n", __func__); - } -} - -static int recv_qmi_from_client(PQCQMIMSG pQMI, int clientfd) { - QRTR_PROXY_CONNECTION *qrtr_con; - struct qlistnode *con_node, *client_node; - int find = 0; - - qlist_for_each(con_node, &qrtr_proxy_connection) { - qrtr_con = qnode_to_item(con_node, QRTR_PROXY_CONNECTION, qnode); - if (qrtr_con->ClientFd == clientfd) - break; - qrtr_con = NULL; - } - - if (!qrtr_con) { - return -1; - } - - if (le16toh(pQMI->QMIHdr.QMIType) == QMUX_TYPE_CTL) { - if (pQMI->CTLMsg.QMICTLMsgHdr.QMICTLType == QMICTL_SYNC_REQ) { - dprintf("do not allow client send QMICTL_SYNC_REQ\n"); - return 0; - } - else if (le16toh(pQMI->CTLMsg.QMICTLMsgHdr.QMICTLType) == QMICTL_GET_CLIENT_ID_REQ) { - uint8_t QMIType = pQMI->CTLMsg.GetClientIdReq.QMIType; - PQCQMIMSG pRsp = (PQCQMIMSG)malloc(256); - - if (pRsp) { - uint8_t ClientId = 0; - - if (find_qrtr_service(QMIType)) { - ClientId = alloc_qrtr_client_id(qrtr_con, QMIType); - } - - pRsp->QMIHdr.IFType = USB_CTL_MSG_TYPE_QMI; - pRsp->QMIHdr.Length = htole16(sizeof(pRsp->CTLMsg.GetClientIdRsp) + sizeof(pRsp->QMIHdr) - 1); - pRsp->QMIHdr.CtlFlags = 0x00; - pRsp->QMIHdr.QMIType = QMUX_TYPE_CTL; - pRsp->QMIHdr.ClientId = 0; - - pRsp->CTLMsg.QMICTLMsgHdrRsp.CtlFlags = QMICTL_FLAG_RESPONSE; - pRsp->CTLMsg.QMICTLMsgHdrRsp.TransactionId = pQMI->CTLMsg.QMICTLMsgHdr.TransactionId; - pRsp->CTLMsg.QMICTLMsgHdrRsp.QMICTLType = pQMI->CTLMsg.QMICTLMsgHdr.QMICTLType; - pRsp->CTLMsg.QMICTLMsgHdrRsp.Length = htole16(sizeof(pRsp->CTLMsg.GetClientIdRsp) - sizeof(pRsp->CTLMsg.QMICTLMsgHdr)); - pRsp->CTLMsg.QMICTLMsgHdrRsp.TLVType = QCTLV_TYPE_RESULT_CODE; - pRsp->CTLMsg.QMICTLMsgHdrRsp.TLVLength = htole16(4); - pRsp->CTLMsg.QMICTLMsgHdrRsp.QMUXResult = htole16(ClientId ? 0 : QMI_RESULT_FAILURE); - pRsp->CTLMsg.QMICTLMsgHdrRsp.QMUXError = htole16(ClientId ? 0 : QMI_ERR_INTERNAL); - pRsp->CTLMsg.GetClientIdRsp.TLV2Type = QCTLV_TYPE_REQUIRED_PARAMETER; - pRsp->CTLMsg.GetClientIdRsp.TLV2Length = htole16(2); - pRsp->CTLMsg.GetClientIdRsp.QMIType = QMIType; - pRsp->CTLMsg.GetClientIdRsp.ClientId = ClientId; - - send_qmi_to_client(pRsp, clientfd); - free(pRsp); - find++; - } - } - else if (le16toh(pQMI->CTLMsg.QMICTLMsgHdr.QMICTLType) == QMICTL_RELEASE_CLIENT_ID_REQ) { - PQCQMIMSG pRsp = (PQCQMIMSG)malloc(256); - release_qrtr_client_id(qrtr_con, pQMI->CTLMsg.ReleaseClientIdReq.QMIType, pQMI->CTLMsg.ReleaseClientIdReq.ClientId); - - if (pRsp) { - pRsp->QMIHdr.IFType = USB_CTL_MSG_TYPE_QMI; - pRsp->QMIHdr.Length = htole16(sizeof(pRsp->CTLMsg.ReleaseClientIdRsp) + sizeof(pRsp->QMIHdr) - 1); - pRsp->QMIHdr.CtlFlags = 0x00; - pRsp->QMIHdr.QMIType = QMUX_TYPE_CTL; - pRsp->QMIHdr.ClientId = 0; - - pRsp->CTLMsg.QMICTLMsgHdrRsp.CtlFlags = QMICTL_FLAG_RESPONSE; - pRsp->CTLMsg.QMICTLMsgHdrRsp.TransactionId = pQMI->CTLMsg.QMICTLMsgHdr.TransactionId; - pRsp->CTLMsg.QMICTLMsgHdrRsp.QMICTLType = pQMI->CTLMsg.QMICTLMsgHdr.QMICTLType; - pRsp->CTLMsg.QMICTLMsgHdrRsp.Length = htole16(sizeof(pRsp->CTLMsg.ReleaseClientIdRsp) - sizeof(pRsp->CTLMsg.QMICTLMsgHdr)); - pRsp->CTLMsg.QMICTLMsgHdrRsp.TLVType = QCTLV_TYPE_RESULT_CODE; - pRsp->CTLMsg.QMICTLMsgHdrRsp.TLVLength = htole16(4); - pRsp->CTLMsg.QMICTLMsgHdrRsp.QMUXResult = htole16(0); - pRsp->CTLMsg.QMICTLMsgHdrRsp.QMUXError = htole16(0); - pRsp->CTLMsg.ReleaseClientIdRsp.TLV2Type = QCTLV_TYPE_REQUIRED_PARAMETER; - pRsp->CTLMsg.ReleaseClientIdRsp.TLV2Length = htole16(2); - pRsp->CTLMsg.ReleaseClientIdRsp.QMIType = pQMI->CTLMsg.ReleaseClientIdReq.QMIType; - pRsp->CTLMsg.ReleaseClientIdRsp.ClientId = pQMI->CTLMsg.ReleaseClientIdReq.ClientId; - - send_qmi_to_client(pRsp, clientfd); - free(pRsp); - find++; - } - } - else if (le16toh(pQMI->CTLMsg.QMICTLMsgHdr.QMICTLType) == QMICTL_GET_VERSION_REQ) { - PQCQMIMSG pRsp = (PQCQMIMSG)malloc(256); - - if (pRsp) { - pRsp->QMIHdr.IFType = USB_CTL_MSG_TYPE_QMI; - pRsp->QMIHdr.Length = htole16(sizeof(pRsp->CTLMsg.GetVersionRsp) + sizeof(pRsp->QMIHdr) - 1); - pRsp->QMIHdr.CtlFlags = 0x00; - pRsp->QMIHdr.QMIType = QMUX_TYPE_CTL; - pRsp->QMIHdr.ClientId = 0; - - pRsp->CTLMsg.QMICTLMsgHdrRsp.CtlFlags = QMICTL_FLAG_RESPONSE; - pRsp->CTLMsg.QMICTLMsgHdrRsp.TransactionId = pQMI->CTLMsg.QMICTLMsgHdr.TransactionId; - pRsp->CTLMsg.QMICTLMsgHdrRsp.QMICTLType = pQMI->CTLMsg.QMICTLMsgHdr.QMICTLType; - pRsp->CTLMsg.QMICTLMsgHdrRsp.Length = htole16(sizeof(pRsp->CTLMsg.GetVersionRsp) - sizeof(pRsp->CTLMsg.QMICTLMsgHdr)); - pRsp->CTLMsg.QMICTLMsgHdrRsp.TLVType = QCTLV_TYPE_RESULT_CODE; - pRsp->CTLMsg.QMICTLMsgHdrRsp.TLVLength = htole16(4); - pRsp->CTLMsg.QMICTLMsgHdrRsp.QMUXResult = htole16(0); - pRsp->CTLMsg.QMICTLMsgHdrRsp.QMUXError = htole16(0); - pRsp->CTLMsg.GetVersionRsp.TLV2Type = QCTLV_TYPE_REQUIRED_PARAMETER; - pRsp->CTLMsg.GetVersionRsp.TLV2Length = htole16(1); - pRsp->CTLMsg.GetVersionRsp.NumElements = 0; - - send_qmi_to_client(pRsp, clientfd); - free(pRsp); - find++; - } - } - } - else { - qlist_for_each (client_node, &qrtr_con->client_qnode) { - QRTR_PROXY_CLINET *qrtr_client = qnode_to_item(client_node, QRTR_PROXY_CLINET, qnode); - - if (pQMI->QMIHdr.QMIType == qrtr_client->QMIType && pQMI->QMIHdr.ClientId == qrtr_client->ClientId) { - QRTR_SERVICE *srv = find_qrtr_service(pQMI->QMIHdr.QMIType); - - if (srv && srv->service) { - struct sockaddr_qrtr from = {AF_QIPCRTR, qrtr_client->node_id, qrtr_client->port_id}; - struct sockaddr_qrtr to = {AF_QIPCRTR, srv->node, srv->port}; - - qrtr_node_enqueue(&pQMI->MUXMsg, le16toh(pQMI->QMIHdr.Length) + 1 - sizeof(QCQMI_HDR), - QRTR_TYPE_DATA, &from, &to, 0); - find++; - } - break; - } - } - } - - if (!find) { - dprintf("NOT find on %s()\n", __func__); - } - - return 0; -} - -static int qrtr_proxy_init(void) { - unsigned i; - int qrtr_sync_done = 0; - - dprintf("%s enter\n", __func__); - send_ctrl_hello(QRTR_NODE_BCAST, QRTR_PORT_CTRL); - - for (i = 0; i < 10; i++) { - sleep(1); - qrtr_sync_done = !qlist_empty(&qrtr_server_list); - if (qrtr_sync_done) - break; - } - - dprintf("%s %s\n", __func__, qrtr_sync_done ? "succful" : "fail"); - return qrtr_sync_done ? 0 : -1; -} - -static void qrtr_start_server(const char* servername) { - qrtr_proxy_server_fd = create_local_server(servername); - dprintf("qrtr_proxy_server_fd = %d\n", qrtr_proxy_server_fd); - if (qrtr_proxy_server_fd == -1) { - dprintf("Failed to create %s, errno: %d (%s)\n", servername, errno, strerror(errno)); - } -} - -static void qrtr_close_server(const char* servername) { - if (qrtr_proxy_server_fd != -1) { - dprintf("%s %s\n", __func__, servername); - close(qrtr_proxy_server_fd); - qrtr_proxy_server_fd = -1; - } -} - -static void *qrtr_proxy_loop(void *param) -{ - void *rx_buf; - struct qlistnode *con_node; - QRTR_PROXY_CONNECTION *qrtr_con; - - (void)param; - dprintf("%s enter thread_id %p\n", __func__, (void *)pthread_self()); - - rx_buf = malloc(8192); - if (!rx_buf) - return NULL; - - while (cdc_wdm_fd > 0 && qrtr_proxy_quit == 0) { - struct pollfd pollfds[32]; - int ne, ret, nevents = 0; - ssize_t nreads; - - pollfds[nevents].fd = cdc_wdm_fd; - pollfds[nevents].events = POLLIN; - pollfds[nevents].revents= 0; - nevents++; - - if (qrtr_proxy_server_fd > 0) { - pollfds[nevents].fd = qrtr_proxy_server_fd; - pollfds[nevents].events = POLLIN; - pollfds[nevents].revents= 0; - nevents++; - } - - qlist_for_each(con_node, &qrtr_proxy_connection) { - qrtr_con = qnode_to_item(con_node, QRTR_PROXY_CONNECTION, qnode); - - pollfds[nevents].fd = qrtr_con->ClientFd; - pollfds[nevents].events = POLLIN; - pollfds[nevents].revents= 0; - nevents++; - - if (nevents == (sizeof(pollfds)/sizeof(pollfds[0]))) - break; - } - - do { - //ret = poll(pollfds, nevents, -1); - ret = poll(pollfds, nevents, (qrtr_proxy_server_fd > 0) ? -1 : 200); - } while (ret == -1 && errno == EINTR && qrtr_proxy_quit == 0); - - if (ret < 0) { - dprintf("%s poll=%d, errno: %d (%s)\n", __func__, ret, errno, strerror(errno)); - goto qrtr_proxy_loop_exit; - } - - for (ne = 0; ne < nevents; ne++) { - int fd = pollfds[ne].fd; - short revents = pollfds[ne].revents; - - if (revents & (POLLERR | POLLHUP | POLLNVAL)) { - dprintf("%s poll fd = %d, revents = %04x\n", __func__, fd, revents); - if (fd == cdc_wdm_fd) { - goto qrtr_proxy_loop_exit; - } - else if (fd == qrtr_proxy_server_fd) { - - } - else { - cleanup_qrtr_connection(fd); - } - - continue; - } - - if (!(pollfds[ne].revents & POLLIN)) { - continue; - } - - if (fd == qrtr_proxy_server_fd) { - accept_qrtr_connection(fd); - } - else if (fd == cdc_wdm_fd) { - struct qrtr_hdr_v1 *hdr = (struct qrtr_hdr_v1 *)rx_buf; - - nreads = read(fd, rx_buf, 8192); - if (nreads <= 0) { - dprintf("%s read=%d errno: %d (%s)\n", __func__, (int)nreads, errno, strerror(errno)); - goto qrtr_proxy_loop_exit; - } - else if (nreads != (int)align_4(le32toh(hdr->size) + sizeof(*hdr))) { - dprintf("%s nreads=%d, hdr->size = %d\n", __func__, (int)nreads, le32toh(hdr->size)); - continue; - } - - dump_qrtr(hdr, nreads, '<'); - recv_qrtr_from_dev(hdr); - } - else { - PQCQMIMSG pQMI = (PQCQMIMSG)rx_buf; - - nreads = read(fd, rx_buf, 8192); - if (nreads <= 0) { - dprintf("%s read=%d errno: %d (%s)", __func__, (int)nreads, errno, strerror(errno)); - cleanup_qrtr_connection(fd); - break; - } - else if (nreads != (le16toh(pQMI->QMIHdr.Length) + 1)) { - dprintf("%s nreads=%d, pQCQMI->QMIHdr.Length = %d\n", __func__, (int)nreads, le16toh(pQMI->QMIHdr.Length)); - continue; - } - - recv_qmi_from_client(pQMI, fd); - } - } - } - -qrtr_proxy_loop_exit: - while (!qlist_empty(&qrtr_proxy_connection)) { - QRTR_PROXY_CONNECTION *qrtr_con = qnode_to_item(qlist_head(&qrtr_proxy_connection), QRTR_PROXY_CONNECTION, qnode); - - cleanup_qrtr_connection(qrtr_con->ClientFd); - } - - dprintf("%s exit, thread_id %p\n", __func__, (void *)pthread_self()); - free(rx_buf); - - return NULL; -} - -static void usage(void) { - dprintf(" -d A valid qrtr device\n" - " default /dev/mhi_IPCR, but mhi_IPCR may be invalid\n" - " -i netcard name\n" - " -v Will show all details\n"); -} - -static void sig_action(int sig) { - if (qrtr_proxy_quit == 0) { - qrtr_proxy_quit = 1; - if (thread_id) - pthread_kill(thread_id, sig); - } -} - -int main(int argc, char *argv[]) { - int opt; - char cdc_wdm[32+1] = "/dev/mhi_IPCR"; - char servername[64] = {0}; - - signal(SIGINT, sig_action); - signal(SIGTERM, sig_action); - - optind = 1; - while ( -1 != (opt = getopt(argc, argv, "d:i:vh"))) { - switch (opt) { - case 'd': - strcpy(cdc_wdm, optarg); - break; - case 'v': - verbose_debug = 1; - break; - default: - usage(); - return 0; - } - } - - sprintf(servername, "quectel-qrtr-proxy%c", cdc_wdm[strlen(cdc_wdm)-1]); - dprintf("Will use cdc-wdm='%s', proxy='%s'\n", cdc_wdm, servername); - - while (qrtr_proxy_quit == 0) { - cdc_wdm_fd = open(cdc_wdm, O_RDWR | O_NONBLOCK | O_NOCTTY); - if (cdc_wdm_fd == -1) { - dprintf("Failed to open %s, errno: %d (%s)\n", cdc_wdm, errno, strerror(errno)); - sleep(5); - continue; - } - cfmakenoblock(cdc_wdm_fd); - qlist_init(&qrtr_proxy_connection); - qlist_init(&qrtr_server_list); - pthread_create(&thread_id, NULL, qrtr_proxy_loop, NULL); - - if (qrtr_proxy_init() == 0) { - qrtr_start_server(servername); - pthread_join(thread_id, NULL); - qrtr_close_server(servername); - } - else { - pthread_cancel(thread_id); - pthread_join(thread_id, NULL); - } - - close(cdc_wdm_fd); - } - - return 0; -} diff --git a/quectel_cm_5G/src/rmnetctl.c b/quectel_cm_5G/src/rmnetctl.c deleted file mode 100644 index 5b2fb0f..0000000 --- a/quectel_cm_5G/src/rmnetctl.c +++ /dev/null @@ -1,342 +0,0 @@ -//https://source.codeaurora.org/quic/la/platform/vendor/qcom-opensource/dataservices/tree/rmnetctl -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define RMNETCTL_SUCCESS 0 -#define RMNETCTL_LIB_ERR 1 -#define RMNETCTL_KERNEL_ERR 2 -#define RMNETCTL_INVALID_ARG 3 - -enum rmnetctl_error_codes_e { - RMNETCTL_API_SUCCESS = 0, - - RMNETCTL_API_FIRST_ERR = 1, - RMNETCTL_API_ERR_MESSAGE_SEND = 3, - RMNETCTL_API_ERR_MESSAGE_RECEIVE = 4, - - RMNETCTL_INIT_FIRST_ERR = 5, - RMNETCTL_INIT_ERR_PROCESS_ID = RMNETCTL_INIT_FIRST_ERR, - RMNETCTL_INIT_ERR_NETLINK_FD = 6, - RMNETCTL_INIT_ERR_BIND = 7, - - RMNETCTL_API_SECOND_ERR = 9, - RMNETCTL_API_ERR_HNDL_INVALID = RMNETCTL_API_SECOND_ERR, - RMNETCTL_API_ERR_RETURN_TYPE = 13, -}; - -struct rmnetctl_hndl_s { - uint32_t pid; - uint32_t transaction_id; - int netlink_fd; - struct sockaddr_nl src_addr, dest_addr; -}; -typedef struct rmnetctl_hndl_s rmnetctl_hndl_t; - -#define NLMSG_TAIL(nmsg) \ - ((struct rtattr *) (((char *)(nmsg)) + NLMSG_ALIGN((nmsg)->nlmsg_len))) - -struct nlmsg { - struct nlmsghdr nl_addr; - struct ifinfomsg ifmsg; - char data[500]; -}; - -#define MIN_VALID_PROCESS_ID 0 -#define MIN_VALID_SOCKET_FD 0 -#define KERNEL_PROCESS_ID 0 -#define UNICAST 0 - -enum { - IFLA_RMNET_UL_AGG_PARAMS = __IFLA_RMNET_MAX, - __IFLA_RMNET_EXT_MAX, -}; - -struct rmnet_egress_agg_params { - uint16_t agg_size; - uint16_t agg_count; - uint32_t agg_time; -}; - -static int rmnet_get_ack(rmnetctl_hndl_t *hndl, uint16_t *error_code) -{ - struct nlack { - struct nlmsghdr ackheader; - struct nlmsgerr ackdata; - char data[256]; - - } ack; - int i; - - if (!hndl || !error_code) - return RMNETCTL_INVALID_ARG; - - if ((i = recv(hndl->netlink_fd, &ack, sizeof(ack), 0)) < 0) { - *error_code = errno; - return RMNETCTL_API_ERR_MESSAGE_RECEIVE; - } - - /*Ack should always be NLMSG_ERROR type*/ - if (ack.ackheader.nlmsg_type == NLMSG_ERROR) { - if (ack.ackdata.error == 0) { - *error_code = RMNETCTL_API_SUCCESS; - return RMNETCTL_SUCCESS; - } else { - *error_code = -ack.ackdata.error; - return RMNETCTL_KERNEL_ERR; - } - } - - *error_code = RMNETCTL_API_ERR_RETURN_TYPE; - return RMNETCTL_API_FIRST_ERR; -} - -static int rtrmnet_ctl_init(rmnetctl_hndl_t **hndl, uint16_t *error_code) -{ - struct sockaddr_nl __attribute__((__may_alias__)) *saddr_ptr; - int netlink_fd = -1; - pid_t pid = 0; - - if (!hndl || !error_code) - return RMNETCTL_INVALID_ARG; - - *hndl = (rmnetctl_hndl_t *)malloc(sizeof(rmnetctl_hndl_t)); - if (!*hndl) { - *error_code = RMNETCTL_API_ERR_HNDL_INVALID; - return RMNETCTL_LIB_ERR; - } - - memset(*hndl, 0, sizeof(rmnetctl_hndl_t)); - - pid = getpid(); - if (pid < MIN_VALID_PROCESS_ID) { - free(*hndl); - *error_code = RMNETCTL_INIT_ERR_PROCESS_ID; - return RMNETCTL_LIB_ERR; - } - (*hndl)->pid = KERNEL_PROCESS_ID; - netlink_fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); - if (netlink_fd < MIN_VALID_SOCKET_FD) { - free(*hndl); - *error_code = RMNETCTL_INIT_ERR_NETLINK_FD; - return RMNETCTL_LIB_ERR; - } - - (*hndl)->netlink_fd = netlink_fd; - - memset(&(*hndl)->src_addr, 0, sizeof(struct sockaddr_nl)); - - (*hndl)->src_addr.nl_family = AF_NETLINK; - (*hndl)->src_addr.nl_pid = (*hndl)->pid; - - saddr_ptr = &(*hndl)->src_addr; - if (bind((*hndl)->netlink_fd, - (struct sockaddr *)saddr_ptr, - sizeof(struct sockaddr_nl)) < 0) { - close((*hndl)->netlink_fd); - free(*hndl); - *error_code = RMNETCTL_INIT_ERR_BIND; - return RMNETCTL_LIB_ERR; - } - - memset(&(*hndl)->dest_addr, 0, sizeof(struct sockaddr_nl)); - - (*hndl)->dest_addr.nl_family = AF_NETLINK; - (*hndl)->dest_addr.nl_pid = KERNEL_PROCESS_ID; - (*hndl)->dest_addr.nl_groups = UNICAST; - - return RMNETCTL_SUCCESS; -} - -static int rtrmnet_ctl_deinit(rmnetctl_hndl_t *hndl) -{ - if (!hndl) - return RMNETCTL_SUCCESS; - - close(hndl->netlink_fd); - free(hndl); - - return RMNETCTL_SUCCESS; -} - -static int rtrmnet_ctl_newvnd(rmnetctl_hndl_t *hndl, char *devname, char *vndname, - uint16_t *error_code, uint8_t index, - uint32_t flagconfig, uint32_t ul_agg_cnt, uint32_t ul_agg_size) -{ - struct rtattr *attrinfo, *datainfo, *linkinfo; - struct ifla_vlan_flags flags; - int devindex = 0, val = 0; - char *kind = "rmnet"; - struct nlmsg req; - short id; - - if (!hndl || !devname || !vndname || !error_code) - return RMNETCTL_INVALID_ARG; - - memset(&req, 0, sizeof(req)); - req.nl_addr.nlmsg_type = RTM_NEWLINK; - req.nl_addr.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg)); - req.nl_addr.nlmsg_flags = NLM_F_REQUEST | NLM_F_CREATE | NLM_F_EXCL | - NLM_F_ACK; - req.nl_addr.nlmsg_seq = hndl->transaction_id; - hndl->transaction_id++; - - /* Get index of devname*/ - devindex = if_nametoindex(devname); - if (devindex < 0) { - *error_code = errno; - return RMNETCTL_KERNEL_ERR; - } - - /* Setup link attr with devindex as data */ - val = devindex; - attrinfo = (struct rtattr *)(((char *)&req) + - NLMSG_ALIGN(req.nl_addr.nlmsg_len)); - attrinfo->rta_type = IFLA_LINK; - attrinfo->rta_len = RTA_ALIGN(RTA_LENGTH(sizeof(val))); - memcpy(RTA_DATA(attrinfo), &val, sizeof(val)); - req.nl_addr.nlmsg_len = NLMSG_ALIGN(req.nl_addr.nlmsg_len) + - RTA_ALIGN(RTA_LENGTH(sizeof(val))); - - /* Set up IFLA info kind RMNET that has linkinfo and type */ - attrinfo = (struct rtattr *)(((char *)&req) + - NLMSG_ALIGN(req.nl_addr.nlmsg_len)); - attrinfo->rta_type = IFLA_IFNAME; - attrinfo->rta_len = RTA_ALIGN(RTA_LENGTH(strlen(vndname) + 1)); - memcpy(RTA_DATA(attrinfo), vndname, strlen(vndname) + 1); - req.nl_addr.nlmsg_len = NLMSG_ALIGN(req.nl_addr.nlmsg_len) + - RTA_ALIGN(RTA_LENGTH(strlen(vndname) + 1)); - - linkinfo = (struct rtattr *)(((char *)&req) + - NLMSG_ALIGN(req.nl_addr.nlmsg_len)); - linkinfo->rta_type = IFLA_LINKINFO; - linkinfo->rta_len = RTA_ALIGN(RTA_LENGTH(0)); - req.nl_addr.nlmsg_len = NLMSG_ALIGN(req.nl_addr.nlmsg_len) + - RTA_ALIGN(RTA_LENGTH(0)); - - attrinfo = (struct rtattr *)(((char *)&req) + - NLMSG_ALIGN(req.nl_addr.nlmsg_len)); - attrinfo->rta_type = IFLA_INFO_KIND; - attrinfo->rta_len = RTA_ALIGN(RTA_LENGTH(strlen(kind))); - memcpy(RTA_DATA(attrinfo), kind, strlen(kind)); - req.nl_addr.nlmsg_len = NLMSG_ALIGN(req.nl_addr.nlmsg_len) + - RTA_ALIGN(RTA_LENGTH(strlen(kind))); - - datainfo = (struct rtattr *)(((char *)&req) + - NLMSG_ALIGN(req.nl_addr.nlmsg_len)); - datainfo->rta_type = IFLA_INFO_DATA; - datainfo->rta_len = RTA_ALIGN(RTA_LENGTH(0)); - req.nl_addr.nlmsg_len = NLMSG_ALIGN(req.nl_addr.nlmsg_len) + - RTA_ALIGN(RTA_LENGTH(0)); - - id = index; - attrinfo = (struct rtattr *)(((char *)&req) + - NLMSG_ALIGN(req.nl_addr.nlmsg_len)); - attrinfo->rta_type = IFLA_VLAN_ID; - attrinfo->rta_len = RTA_LENGTH(sizeof(id)); - memcpy(RTA_DATA(attrinfo), &id, sizeof(id)); - req.nl_addr.nlmsg_len = NLMSG_ALIGN(req.nl_addr.nlmsg_len) + - RTA_ALIGN(RTA_LENGTH(sizeof(id))); - - if (flagconfig != 0) { - flags.mask = flagconfig; - flags.flags = flagconfig; - - attrinfo = (struct rtattr *)(((char *)&req) + - NLMSG_ALIGN(req.nl_addr.nlmsg_len)); - attrinfo->rta_type = IFLA_VLAN_FLAGS; - attrinfo->rta_len = RTA_LENGTH(sizeof(flags)); - memcpy(RTA_DATA(attrinfo), &flags, sizeof(flags)); - req.nl_addr.nlmsg_len = NLMSG_ALIGN(req.nl_addr.nlmsg_len) + - RTA_ALIGN(RTA_LENGTH(sizeof(flags))); - } - - if (ul_agg_cnt > 1) { - struct rmnet_egress_agg_params agg_params; - - agg_params.agg_size = ul_agg_size; - agg_params.agg_count = ul_agg_cnt; - agg_params.agg_time = 3000000; - - attrinfo = (struct rtattr *)(((char *)&req) + - NLMSG_ALIGN(req.nl_addr.nlmsg_len)); - attrinfo->rta_type = IFLA_RMNET_UL_AGG_PARAMS; - attrinfo->rta_len = RTA_LENGTH(sizeof(agg_params)); - memcpy(RTA_DATA(attrinfo), &agg_params, sizeof(agg_params)); - req.nl_addr.nlmsg_len = NLMSG_ALIGN(req.nl_addr.nlmsg_len) + - RTA_ALIGN(RTA_LENGTH(sizeof(agg_params))); - } - - datainfo->rta_len = (char *)NLMSG_TAIL(&req.nl_addr) - (char *)datainfo; - - linkinfo->rta_len = (char *)NLMSG_TAIL(&req.nl_addr) - (char *)linkinfo; - - if (send(hndl->netlink_fd, &req, req.nl_addr.nlmsg_len, 0) < 0) { - *error_code = RMNETCTL_API_ERR_MESSAGE_SEND; - return RMNETCTL_LIB_ERR; - } - - return rmnet_get_ack(hndl, error_code); -} - -int rtrmnet_ctl_create_vnd(char *devname, char *vndname, uint8_t muxid, - uint32_t qmap_version, uint32_t ul_agg_cnt, uint32_t ul_agg_size) -{ - struct rmnetctl_hndl_s *handle; - uint16_t error_code; - int return_code; - uint32_t flagconfig = RMNET_FLAGS_INGRESS_DEAGGREGATION; - - printf("%s devname: %s, vndname: %s, muxid: %d, qmap_version: %d\n", - __func__, devname, vndname, muxid, qmap_version); - - ul_agg_cnt = 0; //TODO - - if (ul_agg_cnt > 1) - flagconfig |= RMNET_EGRESS_FORMAT_AGGREGATION; - - if (qmap_version == 9) { //QMAPV5 -#ifdef RMNET_FLAGS_INGRESS_MAP_CKSUMV5 - flagconfig |= RMNET_FLAGS_INGRESS_MAP_CKSUMV5; - flagconfig |= RMNET_FLAGS_EGRESS_MAP_CKSUMV5; -#else - return -1001; -#endif - } - else if (qmap_version == 8) { //QMAPV4 - flagconfig |= RMNET_FLAGS_INGRESS_MAP_CKSUMV4; - flagconfig |= RMNET_FLAGS_EGRESS_MAP_CKSUMV4; - } - else if (qmap_version == 5) { //QMAPV1 - } - else { - flagconfig = 0; - } - - return_code = rtrmnet_ctl_init(&handle, &error_code); - if (return_code) { - printf("rtrmnet_ctl_init error_code: %d, return_code: %d, errno: %d (%s)\n", - error_code, return_code, errno, strerror(errno)); - } - if (return_code == RMNETCTL_SUCCESS) { - return_code = rtrmnet_ctl_newvnd(handle, devname, vndname, &error_code, - muxid, flagconfig, ul_agg_cnt, ul_agg_size); - if (return_code) { - printf("rtrmnet_ctl_newvnd error_code: %d, return_code: %d, errno: %d (%s)\n", - error_code, return_code, errno, strerror(errno)); - } - rtrmnet_ctl_deinit(handle); - } - - return return_code; -} diff --git a/quectel_cm_5G/src/udhcpc.c b/quectel_cm_5G/src/udhcpc.c deleted file mode 100644 index 5601a6e..0000000 --- a/quectel_cm_5G/src/udhcpc.c +++ /dev/null @@ -1,733 +0,0 @@ -/****************************************************************************** - @file udhcpc.c - @brief call DHCP tools to obtain IP address. - - DESCRIPTION - Connectivity Management Tool for USB network adapter of Quectel wireless cellular modules. - - INITIALIZATION AND SEQUENCING REQUIREMENTS - None. - - --------------------------------------------------------------------------- - Copyright (c) 2016 - 2020 Quectel Wireless Solution, Co., Ltd. All Rights Reserved. - Quectel Wireless Solution Proprietary and Confidential. - --------------------------------------------------------------------------- -******************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include - -#include "util.h" -#include "QMIThread.h" -extern int ql_get_netcard_carrier_state(const char *devname); - -static __inline in_addr_t qmi2addr(uint32_t __x) { - return (__x>>24) | (__x>>8&0xff00) | (__x<<8&0xff0000) | (__x<<24); -} - -static int ql_system(const char *shell_cmd) { - dbg_time("%s", shell_cmd); - return system(shell_cmd); -} - -static void ifc_init_ifr(const char *name, struct ifreq *ifr) -{ - memset(ifr, 0, sizeof(struct ifreq)); - no_trunc_strncpy(ifr->ifr_name, name, IFNAMSIZ); - ifr->ifr_name[IFNAMSIZ - 1] = 0; -} - -static void ql_set_mtu(const char *ifname, int ifru_mtu) { - int inet_sock; - struct ifreq ifr; - - inet_sock = socket(AF_INET, SOCK_DGRAM, 0); - - if (inet_sock > 0) { - ifc_init_ifr(ifname, &ifr); - - if (!ioctl(inet_sock, SIOCGIFMTU, &ifr)) { - if (ifr.ifr_ifru.ifru_mtu != ifru_mtu) { - dbg_time("change mtu %d -> %d", ifr.ifr_ifru.ifru_mtu , ifru_mtu); - ifr.ifr_ifru.ifru_mtu = ifru_mtu; - ioctl(inet_sock, SIOCSIFMTU, &ifr); - } - } - - close(inet_sock); - } -} - -static int ifc_get_addr(const char *name, in_addr_t *addr) -{ - int inet_sock; - struct ifreq ifr; - int ret = 0; - - inet_sock = socket(AF_INET, SOCK_DGRAM, 0); - - ifc_init_ifr(name, &ifr); - if (addr != NULL) { - ret = ioctl(inet_sock, SIOCGIFADDR, &ifr); - if (ret < 0) { - *addr = 0; - } else { - *addr = ((struct sockaddr_in*) &ifr.ifr_addr)->sin_addr.s_addr; - } - } - close(inet_sock); - return ret; -} - -static short ifc_get_flags(const char *ifname) -{ - int inet_sock; - struct ifreq ifr; - int ret = 0; - - inet_sock = socket(AF_INET, SOCK_DGRAM, 0); - - if (inet_sock > 0) { - ifc_init_ifr(ifname, &ifr); - - if (!ioctl(inet_sock, SIOCGIFFLAGS, &ifr)) { - ret = ifr.ifr_ifru.ifru_flags; - } - - close(inet_sock); - } - - return ret; -} - -static int ql_netcard_ipv4_address_check(const char *ifname, in_addr_t ip) { - in_addr_t addr = 0; - - ifc_get_addr(ifname, &addr); - return addr == ip; -} - -static int ql_raw_ip_mode_check(const char *ifname, uint32_t ip) { - int fd; - char raw_ip[128]; - char shell_cmd[128]; - char mode[2] = "X"; - int mode_change = 0; - - if (ql_netcard_ipv4_address_check(ifname, qmi2addr(ip))) - return 0; - - snprintf(raw_ip, sizeof(raw_ip), "/sys/class/net/%s/qmi/raw_ip", ifname); - if (access(raw_ip, F_OK)) - return 0; - - fd = open(raw_ip, O_RDWR | O_NONBLOCK | O_NOCTTY); - if (fd < 0) { - dbg_time("%s %d fail to open(%s), errno:%d (%s)", __FILE__, __LINE__, raw_ip, errno, strerror(errno)); - return 0; - } - - if (read(fd, mode, 2) == -1) {}; - if (mode[0] == '0' || mode[0] == 'N') { - dbg_time("File:%s Line:%d udhcpc fail to get ip address, try next:", __func__, __LINE__); - snprintf(shell_cmd, sizeof(shell_cmd), "ifconfig %s down", ifname); - ql_system(shell_cmd); - dbg_time("echo Y > /sys/class/net/%s/qmi/raw_ip", ifname); - mode[0] = 'Y'; - if (write(fd, mode, 2) == -1) {}; - mode_change = 1; - snprintf(shell_cmd, sizeof(shell_cmd), "ifconfig %s up", ifname); - ql_system(shell_cmd); - } - - close(fd); - return mode_change; -} - -static void* udhcpc_thread_function(void* arg) { - FILE * udhcpc_fp; - char *udhcpc_cmd = (char *)arg; - - if (udhcpc_cmd == NULL) - return NULL; - - dbg_time("%s", udhcpc_cmd); - udhcpc_fp = popen(udhcpc_cmd, "r"); - free(udhcpc_cmd); - if (udhcpc_fp) { - char buf[0xff]; - - buf[sizeof(buf)-1] = '\0'; - while((fgets(buf, sizeof(buf)-1, udhcpc_fp)) != NULL) { - if ((strlen(buf) > 1) && (buf[strlen(buf) - 1] == '\n')) - buf[strlen(buf) - 1] = '\0'; - dbg_time("%s", buf); - } - - pclose(udhcpc_fp); - } - - return NULL; -} - -//#define USE_DHCLIENT -#ifdef USE_DHCLIENT -static int dhclient_alive = 0; -#endif -static int dibbler_client_alive = 0; - -void ql_set_driver_link_state(PROFILE_T *profile, int link_state) { - char link_file[128]; - int fd; - int new_state = 0; - - snprintf(link_file, sizeof(link_file), "/sys/class/net/%s/link_state", profile->usbnet_adapter); - fd = open(link_file, O_RDWR | O_NONBLOCK | O_NOCTTY); - if (fd == -1) { - if (errno != ENOENT) - dbg_time("Fail to access %s, errno: %d (%s)", link_file, errno, strerror(errno)); - return; - } - - if (profile->qmap_mode <= 1) - new_state = !!link_state; - else { - //0x80 means link off this pdp - new_state = (link_state ? 0x00 : 0x80) + (profile->muxid & 0x7F); - } - - snprintf(link_file, sizeof(link_file), "%d\n", new_state); - if (write(fd, link_file, sizeof(link_file)) == -1) {}; - - if (link_state == 0 && profile->qmapnet_adapter[0] - && strcmp(profile->qmapnet_adapter, profile->usbnet_adapter)) { - size_t rc; - - lseek(fd, 0, SEEK_SET); - rc = read(fd, link_file, sizeof(link_file)); - if (rc > 1 && (!strncasecmp(link_file, "0\n", 2) || !strncasecmp(link_file, "0x0\n", 4))) { - snprintf(link_file, sizeof(link_file), "ifconfig %s down", profile->usbnet_adapter); - ql_system(link_file); - } - } - - close(fd); -} - -static const char *ipv4Str(const uint32_t Address) { - static char str[] = {"255.225.255.255"}; - uint8_t *ip = (uint8_t *)&Address; - - snprintf(str, sizeof(str), "%d.%d.%d.%d", ip[3], ip[2], ip[1], ip[0]); - return str; -} - -static const char *ipv6Str(const UCHAR Address[16]) { - static char str[64]; - uint16_t ip[8]; - int i; - for (i = 0; i < 8; i++) { - ip[i] = (Address[i*2]<<8) + Address[i*2+1]; - } - - snprintf(str, sizeof(str), "%x:%x:%x:%x:%x:%x:%x:%x", - ip[0], ip[1], ip[2], ip[3], ip[4], ip[5], ip[6], ip[7]); - - return str; -} - -void update_ipv4_address(const char *ifname, const char *ip, const char *gw, unsigned prefix) -{ - char shell_cmd[128]; - - if (!ifname) - return; - - if (!access("/sbin/ip", X_OK)) { - snprintf(shell_cmd, sizeof(shell_cmd), "ip -%d address flush dev %s", 4, ifname); - ql_system(shell_cmd); - - snprintf(shell_cmd, sizeof(shell_cmd), "ip -%d address add %s/%u dev %s", 4, ip, prefix, ifname); - ql_system(shell_cmd); - - //ping6 www.qq.com - snprintf(shell_cmd, sizeof(shell_cmd), "ip -%d route add default via %s dev %s", 4, gw, ifname); - ql_system(shell_cmd); - } else { - unsigned n = (0xFFFFFFFF >> (32 - prefix)) << (32 - prefix); - // n = (n>>24) | (n>>8&0xff00) | (n<<8&0xff0000) | (n<<24); - - snprintf(shell_cmd, sizeof(shell_cmd), "ifconfig %s %s netmask %s", ifname, ip, ipv4Str(n)); - ql_system(shell_cmd); - - //Resetting default routes - snprintf(shell_cmd, sizeof(shell_cmd), "route del default dev %s", ifname); - while(!system(shell_cmd)); - - snprintf(shell_cmd, sizeof(shell_cmd), "route add default gw %s dev %s", gw, ifname); - ql_system(shell_cmd); - } -} - -void update_ipv6_address(const char *ifname, const char *ip, const char *gw, unsigned prefix) { - char shell_cmd[128]; - - (void)gw; - if (!access("/sbin/ip", X_OK)) { - snprintf(shell_cmd, sizeof(shell_cmd), "ip -%d address flush dev %s", 6, ifname); - ql_system(shell_cmd); - - snprintf(shell_cmd, sizeof(shell_cmd), "ip -%d address add %s/%u dev %s", 6, ip, prefix, ifname); - ql_system(shell_cmd); - - //ping6 www.qq.com - snprintf(shell_cmd, sizeof(shell_cmd), "ip -%d route add default dev %s", 6, ifname); - ql_system(shell_cmd); - } else { - snprintf(shell_cmd, sizeof(shell_cmd), "ifconfig %s %s/%d", ifname, ip, prefix); - ql_system(shell_cmd); - - snprintf(shell_cmd, sizeof(shell_cmd), "route -A inet6 add default dev %s", ifname); - ql_system(shell_cmd); - } -} - -static void update_ip_address_by_qmi(const char *ifname, const IPV4_T *ipv4, const IPV6_T *ipv6) { - char *d1, *d2; - - if (ipv4 && ipv4->Address) { - d1 = strdup(ipv4Str(ipv4->Address)); - d2 = strdup(ipv4Str(ipv4->Gateway)); - unsigned prefix = 0; - unsigned n = 0; - - for (n = 0; n < 32; n++) { - if (ipv4->SubnetMask&((unsigned)1<DnsPrimary) { - d1 = strdup(ipv4Str(ipv4->DnsPrimary)); - d2 = strdup(ipv4Str(ipv4->DnsSecondary ? ipv4->DnsSecondary : ipv4->DnsPrimary)); - update_resolv_conf(4, ifname, d1, d2); - free(d1); free(d2); - } - } - - if (ipv6 && ipv6->Address[0] && ipv6->PrefixLengthIPAddr) { - d1 = strdup(ipv6Str(ipv6->Address)); - d2 = strdup(ipv6Str(ipv6->Gateway)); - - update_ipv6_address(ifname, d1, d2, ipv6->PrefixLengthIPAddr); - free(d1); free(d2); - - //Adding DNS - if (ipv6->DnsPrimary[0]) { - d1 = strdup(ipv6Str(ipv6->DnsPrimary)); - d2 = strdup(ipv6Str(ipv6->DnsSecondary[0] ? ipv6->DnsSecondary : ipv6->DnsPrimary)); - update_resolv_conf(6, ifname, d1, d2); - free(d1); free(d2); - } - } -} - -//#define QL_OPENWER_NETWORK_SETUP -#ifdef QL_OPENWER_NETWORK_SETUP -static const char *openwrt_lan = "br-lan"; -static const char *openwrt_wan = "wwan0"; - -static int ql_openwrt_system(const char *cmd) { - int i; - int ret = 1; - char shell_cmd[128]; - - snprintf(shell_cmd, sizeof(shell_cmd), "%s 2>1 > /dev/null", cmd); - - for (i = 0; i < 15; i++) { - dbg_time("%s", cmd); - ret = system(shell_cmd); - if (!ret) - break; - sleep(1); - } - - return ret; -} - -static int ql_openwrt_is_wan(const char *ifname) { - if (openwrt_lan == NULL) { - system("uci show network.wan.ifname"); - } - - if (strcmp(ifname, openwrt_wan)) - return 0; - - return 1; -} - -static void ql_openwrt_setup_wan(const char *ifname, const IPV4_T *ipv4) { - FILE *fp = NULL; - char config[64]; - - snprintf(config, sizeof(config), "/tmp/rmnet_%s_ipv4config", ifname); - - if (ipv4 == NULL) { - if (ql_openwrt_is_wan(ifname)) - ql_openwrt_system("ifdown wan"); - return; - } - - fp = fopen(config, "w"); - if (fp == NULL) - return; - - fprintf(fp, "IFNAME=\"%s\"\n", ifname); - fprintf(fp, "PUBLIC_IP=\"%s\"\n", ipv4Str(ipv4->Address)); - fprintf(fp, "NETMASK=\"%s\"\n", ipv4Str(ipv4->SubnetMask)); - fprintf(fp, "GATEWAY=\"%s\"\n", ipv4Str(ipv4->Gateway)); - fprintf(fp, "DNSSERVERS=\"%s", ipv4Str(ipv4->DnsPrimary)); - if (ipv4->DnsSecondary != 0) - fprintf(fp, " %s", ipv4Str(ipv4->DnsSecondary)); - fprintf(fp, "\"\n"); - - fclose(fp); - - if (!ql_openwrt_is_wan(ifname)) - return; - - ql_openwrt_system("ifup wan"); -} - -static void ql_openwrt_setup_wan6(const char *ifname, const IPV6_T *ipv6) { - FILE *fp = NULL; - char config[64]; - int first_ifup; - - snprintf(config, sizeof(config), "/tmp/rmnet_%s_ipv6config", ifname); - - if (ipv6 == NULL) { - if (ql_openwrt_is_wan(ifname)) - ql_openwrt_system("ifdown wan6"); - return; - } - - first_ifup = (access(config, F_OK) != 0); - - fp = fopen(config, "w"); - if (fp == NULL) - return; - - fprintf(fp, "IFNAME=\"%s\"\n", ifname); - fprintf(fp, "PUBLIC_IP=\"%s\"\n", ipv6Str(ipv6->Address)); - fprintf(fp, "NETMASK=\"%s\"\n", ipv6Str(ipv6->SubnetMask)); - fprintf(fp, "GATEWAY=\"%s\"\n", ipv6Str(ipv6->Gateway)); - fprintf(fp, "PrefixLength=\"%d\"\n", ipv6->PrefixLengthIPAddr); - fprintf(fp, "DNSSERVERS=\"%s", ipv6Str(ipv6->DnsPrimary)); - if (ipv6->DnsSecondary[0]) - fprintf(fp, " %s", ipv6Str(ipv6->DnsSecondary)); - fprintf(fp, "\"\n"); - - fclose(fp); - - if (!ql_openwrt_is_wan(ifname)) - return; - - if (first_ifup) - ql_openwrt_system("ifup wan6"); - else - ql_openwrt_system("/etc/init.d/network restart"); //make PC to release old IPV6 address, and RS new IPV6 address - -#if 1 //TODO? why need this? - if (openwrt_lan) { - int i; - char shell_cmd[128]; - UCHAR Address[16] = {0}; - - ql_openwrt_system(("ifstatus lan")); - - for (i = 0; i < (ipv6->PrefixLengthIPAddr/8); i++) - Address[i] = ipv6->Address[i]; - - snprintf(shell_cmd, sizeof(shell_cmd), "ip route del %s/%u dev %s", ipv6Str(Address), ipv6->PrefixLengthIPAddr, ifname); - ql_openwrt_system(shell_cmd); - - snprintf(shell_cmd, sizeof(shell_cmd), "ip route add %s/%u dev %s", ipv6Str(Address), ipv6->PrefixLengthIPAddr, openwrt_lan); - ql_system(shell_cmd); - } -#endif -} -#endif - -void udhcpc_start(PROFILE_T *profile) { - char *ifname = profile->usbnet_adapter; - char shell_cmd[128]; - - ql_set_driver_link_state(profile, 1); - - if (profile->qmapnet_adapter[0]) { - ifname = profile->qmapnet_adapter; - } - - if (profile->rawIP && profile->ipv4.Address && profile->ipv4.Mtu) { - ql_set_mtu(ifname, (profile->ipv4.Mtu)); - } - - if (strcmp(ifname, profile->usbnet_adapter)) { - snprintf(shell_cmd, sizeof(shell_cmd), "ifconfig %s up", profile->usbnet_adapter); - ql_system(shell_cmd); - if (ifc_get_flags(ifname)&IFF_UP) { - snprintf(shell_cmd, sizeof(shell_cmd), "ifconfig %s down", ifname); - ql_system(shell_cmd); - } - } - - snprintf(shell_cmd, sizeof(shell_cmd), "ifconfig %s up", ifname); - ql_system(shell_cmd); - - if (profile->ipv4.Address) { - if (profile->PCSCFIpv4Addr1) - dbg_time("pcscf1: %s", ipv4Str(profile->PCSCFIpv4Addr1)); - if (profile->PCSCFIpv4Addr2) - dbg_time("pcscf2: %s", ipv4Str(profile->PCSCFIpv4Addr2)); - } - - if (profile->ipv6.Address[0] && profile->ipv6.PrefixLengthIPAddr) { - if (profile->PCSCFIpv6Addr1[0]) - dbg_time("pcscf1: %s", ipv6Str(profile->PCSCFIpv6Addr1)); - if (profile->PCSCFIpv6Addr2[0]) - dbg_time("pcscf2: %s", ipv6Str(profile->PCSCFIpv6Addr2)); - } - -#if 1 //for bridge mode, only one public IP, so do udhcpc manually - if (ql_bridge_mode_detect(profile)) { - return; - } -#endif - -//because must use udhcpc to obtain IP when working on ETH mode, -//so it is better also use udhcpc to obtain IP when working on IP mode. -//use the same policy for all modules -#if 0 - if (profile->rawIP != 0) //mdm9x07/ec25,ec20 R2.0 - { - update_ip_address_by_qmi(ifname, &profile->ipv4, &profile->ipv6); - return; - } -#endif - - if (profile->ipv4.Address == 0) - goto set_ipv6; - - if (profile->request_ops == &mbim_request_ops) { //lots of mbim modem do not support DHCP - update_ip_address_by_qmi(ifname, &profile->ipv4, NULL); - } - else -/* Do DHCP using busybox tools */ - { - char udhcpc_cmd[128]; - pthread_attr_t udhcpc_thread_attr; - pthread_t udhcpc_thread_id; - - pthread_attr_init(&udhcpc_thread_attr); - pthread_attr_setdetachstate(&udhcpc_thread_attr, PTHREAD_CREATE_DETACHED); - -#ifdef USE_DHCLIENT - snprintf(udhcpc_cmd, sizeof(udhcpc_cmd), "dhclient -4 -d --no-pid %s", ifname); - dhclient_alive++; -#else - if (access("/usr/share/udhcpc/default.script", X_OK) - && access("/etc//udhcpc/default.script", X_OK)) { - dbg_time("No default.script found, it should be in '/usr/share/udhcpc/' or '/etc//udhcpc' depend on your udhcpc version!"); - } - - //-f,--foreground Run in foreground - //-b,--background Background if lease is not obtained - //-n,--now Exit if lease is not obtained - //-q,--quit Exit after obtaining lease - //-t,--retries N Send up to N discover packets (default 3) - snprintf(udhcpc_cmd, sizeof(udhcpc_cmd), "busybox udhcpc -f -n -q -t 5 -i %s", ifname); -#endif - -#if 1 //for OpenWrt - if (!access("/lib/netifd/dhcp.script", X_OK) && !access("/sbin/ifup", X_OK) && !access("/sbin/ifstatus", X_OK)) { -#if 0 //20210415 do not promot these message - dbg_time("you are use OpenWrt?"); - dbg_time("should not calling udhcpc manually?"); - dbg_time("should modify /etc/config/network as below?"); - dbg_time("config interface wan"); - dbg_time("\toption ifname %s", ifname); - dbg_time("\toption proto dhcp"); - dbg_time("should use \"/sbin/ifstaus wan\" to check %s 's status?", ifname); -#endif - } -#endif - -#ifdef USE_DHCLIENT - pthread_create(&udhcpc_thread_id, &udhcpc_thread_attr, udhcpc_thread_function, (void*)strdup(udhcpc_cmd)); - sleep(1); -#else - pthread_create(&udhcpc_thread_id, NULL, udhcpc_thread_function, (void*)strdup(udhcpc_cmd)); - pthread_join(udhcpc_thread_id, NULL); - - if (profile->request_ops == &atc_request_ops - && !ql_netcard_ipv4_address_check(ifname, qmi2addr(profile->ipv4.Address))) { - ql_get_netcard_carrier_state(ifname); - } - - if (profile->request_ops != &qmi_request_ops) { //only QMI modem support next fixup! - goto set_ipv6; - } - - if (ql_raw_ip_mode_check(ifname, profile->ipv4.Address)) { - pthread_create(&udhcpc_thread_id, NULL, udhcpc_thread_function, (void*)strdup(udhcpc_cmd)); - pthread_join(udhcpc_thread_id, NULL); - } - - if (!ql_netcard_ipv4_address_check(ifname, qmi2addr(profile->ipv4.Address))) { - //no udhcpc's default.script exist, directly set ip and dns - update_ip_address_by_qmi(ifname, &profile->ipv4, NULL); - } - //Add by Demon. check default route - FILE *rt_fp = NULL; - char rt_cmd[128] = {0}; - - //Check if there is a default route. - snprintf(rt_cmd, sizeof(rt_cmd), "route -n | grep %s | awk '{print $1}' | grep 0.0.0.0", ifname); - rt_fp = popen((const char *)rt_cmd, "r"); - if (rt_fp != NULL) { - char buf[20] = {0}; - int found_default_rt = 0; - - if (fgets(buf, sizeof(buf), rt_fp) != NULL) { - //Find the specified interface - found_default_rt = 1; - } - - if (1 == found_default_rt) { - //dbg_time("Route items found for %s", ifname); - } - else { - dbg_time("Warning: No route items found for %s", ifname); - } - - pclose(rt_fp); - } - //End by Demon. -#endif - } - -#ifdef QL_OPENWER_NETWORK_SETUP - ql_openwrt_setup_wan(ifname, &profile->ipv4); -#endif - -set_ipv6: - if (profile->ipv6.Address[0] && profile->ipv6.PrefixLengthIPAddr) { -#if 1 - //module do not support DHCPv6, only support 'Router Solicit' - //and it seem if enable /proc/sys/net/ipv6/conf/all/forwarding, Kernel do not send RS - const char *forward_file = "/proc/sys/net/ipv6/conf/all/forwarding"; - int forward_fd = open(forward_file, O_RDONLY); - if (forward_fd > 0) { - char forward_state[2]; - if (read(forward_fd, forward_state, 2) == -1) {}; - if (forward_state[0] == '1') { - //dbg_time("%s enabled, kernel maybe donot send 'Router Solicit'", forward_file); - } - close(forward_fd); - } - - update_ip_address_by_qmi(ifname, NULL, &profile->ipv6); - - if (profile->ipv6.DnsPrimary[0] || profile->ipv6.DnsSecondary[0]) { - char dns1str[64], dns2str[64]; - - if (profile->ipv6.DnsPrimary[0]) { - strcpy(dns1str, ipv6Str(profile->ipv6.DnsPrimary)); - } - - if (profile->ipv6.DnsSecondary[0]) { - strcpy(dns2str, ipv6Str(profile->ipv6.DnsSecondary)); - } - - update_resolv_conf(6, ifname, profile->ipv6.DnsPrimary[0] ? dns1str : NULL, - profile->ipv6.DnsSecondary[0] != '\0' ? dns2str : NULL); - } - -#ifdef QL_OPENWER_NETWORK_SETUP - ql_openwrt_setup_wan6(ifname, &profile->ipv6); -#endif -#else -#ifdef USE_DHCLIENT - snprintf(udhcpc_cmd, sizeof(udhcpc_cmd), "dhclient -6 -d --no-pid %s", ifname); - dhclient_alive++; -#else - /* - DHCPv6: Dibbler - a portable DHCPv6 - 1. download from http://klub.com.pl/dhcpv6/ - 2. cross-compile - 2.1 ./configure --host=arm-linux-gnueabihf - 2.2 copy dibbler-client to your board - 3. mkdir -p /var/log/dibbler/ /var/lib/ on your board - 4. create /etc/dibbler/client.conf on your board, the content is - log-mode short - log-level 7 - iface wwan0 { - ia - option dns-server - } - 5. run "dibbler-client start" to get ipV6 address - 6. run "route -A inet6 add default dev wwan0" to add default route - */ - snprintf(shell_cmd, sizeof(shell_cmd), "route -A inet6 add default %s", ifname); - ql_system(shell_cmd); - snprintf(udhcpc_cmd, sizeof(udhcpc_cmd), "dibbler-client run"); - dibbler_client_alive++; -#endif - - pthread_create(&udhcpc_thread_id, &udhcpc_thread_attr, udhcpc_thread_function, (void*)strdup(udhcpc_cmd)); -#endif - } -} - -void udhcpc_stop(PROFILE_T *profile) { - char *ifname = profile->usbnet_adapter; - char shell_cmd[128]; - - ql_set_driver_link_state(profile, 0); - - if (profile->qmapnet_adapter[0]) { - ifname = profile->qmapnet_adapter; - } - -#ifdef USE_DHCLIENT - if (dhclient_alive) { - system("killall dhclient"); - dhclient_alive = 0; - } -#endif - if (dibbler_client_alive) { - if (system("killall dibbler-client")) {}; - dibbler_client_alive = 0; - } - -//it seems when call netif_carrier_on(), and netcard 's IP is "0.0.0.0", will cause netif_queue_stopped() - snprintf(shell_cmd, sizeof(shell_cmd), "ifconfig %s 0.0.0.0", ifname); - ql_system(shell_cmd); - snprintf(shell_cmd, sizeof(shell_cmd), "ifconfig %s down", ifname); - ql_system(shell_cmd); - -#ifdef QL_OPENWER_NETWORK_SETUP - ql_openwrt_setup_wan(ifname, NULL); - ql_openwrt_setup_wan6(ifname, NULL); -#endif -} diff --git a/quectel_cm_5G/src/udhcpc_netlink.c b/quectel_cm_5G/src/udhcpc_netlink.c deleted file mode 100644 index 56209f8..0000000 --- a/quectel_cm_5G/src/udhcpc_netlink.c +++ /dev/null @@ -1,179 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -#include "libmnl/ifutils.h" -#include "libmnl/dhcp/dhcp.h" -#include "util.h" -#include "QMIThread.h" - -static int ql_raw_ip_mode_check(const char *ifname) -{ - int fd; - char raw_ip[128]; - char mode[2] = "X"; - int mode_change = 0; - - snprintf(raw_ip, sizeof(raw_ip), "/sys/class/net/%s/qmi/raw_ip", ifname); - if (access(raw_ip, F_OK)) - return 0; - - fd = open(raw_ip, O_RDWR | O_NONBLOCK | O_NOCTTY); - if (fd < 0) - { - dbg_time("%s %d fail to open(%s), errno:%d (%s)", __FILE__, __LINE__, raw_ip, errno, strerror(errno)); - return 0; - } - - read(fd, mode, 2); - if (mode[0] == '0' || mode[0] == 'N') - { - if_link_down(ifname); - dbg_time("echo Y > /sys/class/net/%s/qmi/raw_ip", ifname); - mode[0] = 'Y'; - write(fd, mode, 2); - mode_change = 1; - if_link_up(ifname); - } - - close(fd); - return mode_change; -} - -void ql_set_driver_link_state(PROFILE_T *profile, int link_state) -{ - char link_file[128]; - int fd; - int new_state = 0; - - snprintf(link_file, sizeof(link_file), "/sys/class/net/%s/link_state", profile->usbnet_adapter); - fd = open(link_file, O_RDWR | O_NONBLOCK | O_NOCTTY); - if (fd == -1) - { - if (errno != ENOENT) - dbg_time("Fail to access %s, errno: %d (%s)", link_file, errno, strerror(errno)); - return; - } - - if (profile->qmap_mode <= 1) - new_state = !!link_state; - else - { - //0x80 means link off this pdp - new_state = (link_state ? 0x00 : 0x80) + profile->pdp; - } - - snprintf(link_file, sizeof(link_file), "%d\n", new_state); - write(fd, link_file, sizeof(link_file)); - - if (link_state == 0 && profile->qmap_mode > 1) - { - size_t rc; - - lseek(fd, 0, SEEK_SET); - rc = read(fd, link_file, sizeof(link_file)); - if (rc > 1 && (!strcasecmp(link_file, "0\n") || !strcasecmp(link_file, "0x0\n"))) - { - if_link_down(profile->usbnet_adapter); - } - } - - close(fd); -} - -void udhcpc_start(PROFILE_T *profile) -{ - char *ifname = profile->usbnet_adapter; - - ql_set_driver_link_state(profile, 1); - ql_raw_ip_mode_check(ifname); - - if (profile->qmapnet_adapter) - { - ifname = profile->qmapnet_adapter; - } - if (profile->rawIP && profile->ipv4.Address && profile->ipv4.Mtu) - { - if_set_mtu(ifname, (profile->ipv4.Mtu)); - } - - if (strcmp(ifname, profile->usbnet_adapter)) - { - if_link_up(profile->usbnet_adapter); - } - - if_link_up(ifname); - -#if 1 //for bridge mode, only one public IP, so do udhcpc manually - if (ql_bridge_mode_detect(profile)) - { - return; - } -#endif - // if use DHCP(should make with ${DHCP} src files) - // do_dhcp(ifname); - // return 0; - /* IPv4 Addr Info */ - if (profile->ipv4.Address) - { - dbg_time("IPv4 MTU: %d", profile->ipv4.Mtu); - dbg_time("IPv4 Address: %s", ipaddr_to_string_v4(ntohl(profile->ipv4.Address))); - dbg_time("IPv4 Netmask: %d", mask_to_prefix_v4(ntohl(profile->ipv4.SubnetMask))); - dbg_time("IPv4 Gateway: %s", ipaddr_to_string_v4(ntohl(profile->ipv4.Gateway))); - dbg_time("IPv4 DNS1: %s", ipaddr_to_string_v4(ntohl(profile->ipv4.DnsPrimary))); - dbg_time("IPv4 DNS2: %s", ipaddr_to_string_v4(ntohl(profile->ipv4.DnsSecondary))); - if_set_network_v4(ifname, ntohl(profile->ipv4.Address), - mask_to_prefix_v4(profile->ipv4.SubnetMask), - ntohl(profile->ipv4.Gateway), - ntohl(profile->ipv4.DnsPrimary), - ntohl(profile->ipv4.DnsSecondary)); - } - - if (profile->ipv6.Address[0] && profile->ipv6.PrefixLengthIPAddr) - { - //module do not support DHCPv6, only support 'Router Solicit' - //and it seem if enable /proc/sys/net/ipv6/conf/all/forwarding, Kernel do not send RS - const char *forward_file = "/proc/sys/net/ipv6/conf/all/forwarding"; - int forward_fd = open(forward_file, O_RDONLY); - if (forward_fd > 0) - { - char forward_state[2]; - read(forward_fd, forward_state, 2); - if (forward_state[0] == '1') - { - dbg_time("%s enabled, kernel maybe donot send 'Router Solicit'", forward_file); - } - close(forward_fd); - } - - dbg_time("IPv6 MTU: %d", profile->ipv6.Mtu); - dbg_time("IPv6 Address: %s", ipaddr_to_string_v6(profile->ipv6.Address)); - dbg_time("IPv6 Netmask: %d", profile->ipv6.PrefixLengthIPAddr); - dbg_time("IPv6 Gateway: %s", ipaddr_to_string_v6(profile->ipv6.Gateway)); - dbg_time("IPv6 DNS1: %s", ipaddr_to_string_v6(profile->ipv6.DnsPrimary)); - dbg_time("IPv6 DNS2: %s", ipaddr_to_string_v6(profile->ipv6.DnsSecondary)); - if_set_network_v6(ifname, profile->ipv6.Address, profile->ipv6.PrefixLengthIPAddr, - profile->ipv6.Gateway, profile->ipv6.DnsPrimary, profile->ipv6.DnsSecondary); - } -} - -void udhcpc_stop(PROFILE_T *profile) -{ - char *ifname = profile->usbnet_adapter; - - ql_set_driver_link_state(profile, 0); - - if (profile->qmapnet_adapter) - { - ifname = profile->qmapnet_adapter; - } - - if_link_down(ifname); - if_flush_v4_addr(ifname); - if_flush_v6_addr(ifname); -} diff --git a/quectel_cm_5G/src/udhcpc_script.c b/quectel_cm_5G/src/udhcpc_script.c deleted file mode 100644 index 5e32ae3..0000000 --- a/quectel_cm_5G/src/udhcpc_script.c +++ /dev/null @@ -1,132 +0,0 @@ -/****************************************************************************** - @file udhcpc.c - @brief call DHCP tools to obtain IP address. - - DESCRIPTION - Connectivity Management Tool for USB network adapter of Quectel wireless cellular modules. - - INITIALIZATION AND SEQUENCING REQUIREMENTS - None. - - --------------------------------------------------------------------------- - Copyright (c) 2016 - 2020 Quectel Wireless Solution, Co., Ltd. All Rights Reserved. - Quectel Wireless Solution Proprietary and Confidential. - --------------------------------------------------------------------------- -******************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include - -#include "util.h" -#include "QMIThread.h" - -#define IFDOWN_SCRIPT "/etc/quectel/ifdown.sh" -#define IFUP_SCRIPT "/etc/quectel/ifup.sh" - -static int ql_system(const char *shell_cmd) -{ - dbg_time("%s", shell_cmd); - return system(shell_cmd); -} - -uint32_t mask_to_prefix_v4(uint32_t mask) -{ - uint32_t prefix = 0; - while (mask) - { - mask = mask & (mask - 1); - prefix++; - } - return prefix; -} - -uint32_t mask_from_prefix_v4(uint32_t prefix) -{ - return ~((1 << (32 - prefix)) - 1); -} - -/* mask in int */ -uint32_t broadcast_from_mask(uint32_t ip, uint32_t mask) -{ - return (ip & mask) | (~mask); -} - -const char *ipaddr_to_string_v4(in_addr_t ipaddr, char *buf, size_t size) -{ - // static char buf[INET6_ADDRSTRLEN] = {'\0'}; - buf[0] = '\0'; - uint32_t addr = ipaddr; - return inet_ntop(AF_INET, &addr, buf, size); -} - -const char *ipaddr_to_string_v6(uint8_t *ipaddr, char *buf, size_t size) -{ - buf[0] = '\0'; - return inet_ntop(AF_INET6, ipaddr, buf, size); -} - -/** - * For more details see default.script - * - * The main aim of this function is offload ip management to script, CM has not interest in manage IP address. - * just tell script all the info about ip, mask, router, dns... - */ -void udhcpc_start(PROFILE_T *profile) -{ - char shell_cmd[1024]; - char ip[128]; - char subnet[128]; - char broadcast[128]; - char router[128]; - char domain1[128]; - char domain2[128]; - - if (NULL == getenv(IFUP_SCRIPT)) - return; - - // manage IPv4??? - // check rawip ??? - snprintf(shell_cmd, sizeof(shell_cmd), - " netiface=%s interface=%s mtu=%u ip=%s subnet=%s broadcast=%s router=%s" - " domain=\"%s %s\" %s", - profile->usbnet_adapter, - profile->qmapnet_adapter ? profile->qmapnet_adapter : profile->usbnet_adapter, - profile->ipv4.Mtu, - ipaddr_to_string_v4(ntohl(profile->ipv4.Address), ip, sizeof(ip)), - ipaddr_to_string_v4(ntohl(profile->ipv4.SubnetMask), subnet, sizeof(subnet)), - ipaddr_to_string_v4(ntohl(broadcast_from_mask(profile->ipv4.Address, profile->ipv4.SubnetMask)), - broadcast, sizeof(broadcast)), - ipaddr_to_string_v4(ntohl(profile->ipv4.Gateway), router, sizeof(router)), - ipaddr_to_string_v4(ntohl(profile->ipv4.DnsPrimary), domain1, sizeof(domain1)), - ipaddr_to_string_v4(ntohl(profile->ipv4.DnsSecondary), domain2, sizeof(domain2)), - getenv(IFUP_SCRIPT)); - ql_system(shell_cmd); - - // manage IPv6??? -} - -/** - * For more details see default.script - * - * The main aim of this function is offload ip management to script, CM has not interest in manage IP address. - * just tell script all the info about ip, mask, router, dns... - */ -void udhcpc_stop(PROFILE_T *profile) -{ - char shell_cmd[1024]; - - if (NULL == getenv(IFDOWN_SCRIPT)) - return; - - snprintf(shell_cmd, sizeof(shell_cmd), - "netiface=%s interface=%s %s", - profile->usbnet_adapter, - profile->qmapnet_adapter ? profile->qmapnet_adapter : profile->usbnet_adapter, - getenv(IFDOWN_SCRIPT)); - ql_system(shell_cmd); -} diff --git a/quectel_cm_5G/src/util.c b/quectel_cm_5G/src/util.c deleted file mode 100644 index dbf2162..0000000 --- a/quectel_cm_5G/src/util.c +++ /dev/null @@ -1,361 +0,0 @@ -/****************************************************************************** - @file util.c - @brief some utils for this QCM tool. - - DESCRIPTION - Connectivity Management Tool for USB network adapter of Quectel wireless cellular modules. - - INITIALIZATION AND SEQUENCING REQUIREMENTS - None. - - --------------------------------------------------------------------------- - Copyright (c) 2016 - 2020 Quectel Wireless Solution, Co., Ltd. All Rights Reserved. - Quectel Wireless Solution Proprietary and Confidential. - --------------------------------------------------------------------------- -******************************************************************************/ - -#include -#include -typedef unsigned short sa_family_t; -#include - -#if defined(__STDC__) -#include -#define __V(x) x -#else -#include -#define __V(x) (va_alist) va_dcl -#define const -#define volatile -#endif - -#include - -#include "QMIThread.h" - -pthread_mutex_t cm_command_mutex = PTHREAD_MUTEX_INITIALIZER; -pthread_cond_t cm_command_cond = PTHREAD_COND_INITIALIZER; -unsigned int cm_recv_buf[1024]; - -int cm_open_dev(const char *dev) { - int fd; - - fd = open(dev, O_RDWR | O_NONBLOCK | O_NOCTTY); - if (fd != -1) { - fcntl(fd, F_SETFL, fcntl(fd,F_GETFL) | O_NONBLOCK); - fcntl(fd, F_SETFD, FD_CLOEXEC); - - if (!strncmp(dev, "/dev/tty", strlen("/dev/tty"))) - { - //disable echo on serial ports - struct termios ios; - - memset(&ios, 0, sizeof(ios)); - tcgetattr( fd, &ios ); - cfmakeraw(&ios); - cfsetispeed(&ios, B115200); - cfsetospeed(&ios, B115200); - tcsetattr( fd, TCSANOW, &ios ); - tcflush(fd, TCIOFLUSH); - } - } else { - dbg_time("Failed to open %s, errno: %d (%s)", dev, errno, strerror(errno)); - } - - return fd; -} - -int cm_open_proxy(const char *name) { - int sockfd = -1; - int reuse_addr = 1; - struct sockaddr_un sockaddr; - socklen_t alen; - - /*Create server socket*/ - sockfd = socket(AF_LOCAL, SOCK_STREAM, 0); - if (sockfd < 0) - return sockfd; - - memset(&sockaddr, 0, sizeof(sockaddr)); - sockaddr.sun_family = AF_LOCAL; - sockaddr.sun_path[0] = 0; - memcpy(sockaddr.sun_path + 1, name, strlen(name) ); - - alen = strlen(name) + offsetof(struct sockaddr_un, sun_path) + 1; - if(connect(sockfd, (struct sockaddr *)&sockaddr, alen) < 0) { - close(sockfd); - dbg_time("connect %s errno: %d (%s)", name, errno, strerror(errno)); - return -1; - } - setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &reuse_addr,sizeof(reuse_addr)); - fcntl(sockfd, F_SETFL, fcntl(sockfd,F_GETFL) | O_NONBLOCK); - fcntl(sockfd, F_SETFD, FD_CLOEXEC); - - dbg_time("connect to %s sockfd = %d", name, sockfd); - - return sockfd; -} - -static void setTimespecRelative(struct timespec *p_ts, long long msec) -{ - struct timeval tv; - - gettimeofday(&tv, (struct timezone *) NULL); - - /* what's really funny about this is that I know - pthread_cond_timedwait just turns around and makes this - a relative time again */ - p_ts->tv_sec = tv.tv_sec + (msec / 1000); - p_ts->tv_nsec = (tv.tv_usec + (msec % 1000) * 1000L ) * 1000L; - if ((unsigned long)p_ts->tv_nsec >= 1000000000UL) { - p_ts->tv_sec += 1; - p_ts->tv_nsec -= 1000000000UL; - } -} - -int pthread_cond_timeout_np(pthread_cond_t *cond, pthread_mutex_t * mutex, unsigned msecs) { - if (msecs != 0) { - unsigned i; - unsigned t = msecs/4; - int ret = 0; - - if (t == 0) - t = 1; - - for (i = 0; i < msecs; i += t) { - struct timespec ts; - setTimespecRelative(&ts, t); -//very old uclibc do not support pthread_condattr_setclock(CLOCK_MONOTONIC) - ret = pthread_cond_timedwait(cond, mutex, &ts); //to advoid system time change - if (ret != ETIMEDOUT) { - if(ret) dbg_time("ret=%d, msecs=%u, t=%u", ret, msecs, t); - break; - } - } - - return ret; - } else { - return pthread_cond_wait(cond, mutex); - } -} - -const char * get_time(void) { - static char time_buf[128]; - struct timeval tv; - time_t time; - suseconds_t millitm; - struct tm *ti; - - gettimeofday (&tv, NULL); - - time= tv.tv_sec; - millitm = (tv.tv_usec + 500) / 1000; - - if (millitm == 1000) { - ++time; - millitm = 0; - } - - ti = localtime(&time); - sprintf(time_buf, "%02d-%02d_%02d:%02d:%02d:%03d", ti->tm_mon+1, ti->tm_mday, ti->tm_hour, ti->tm_min, ti->tm_sec, (int)millitm); - return time_buf; -} - -unsigned long clock_msec(void) -{ - struct timespec tm; - clock_gettime( CLOCK_MONOTONIC, &tm); - return (unsigned long)(tm.tv_sec*1000 + (tm.tv_nsec/1000000)); -} - -FILE *logfilefp = NULL; - -void update_resolv_conf(int iptype, const char *ifname, const char *dns1, const char *dns2) { - const char *dns_file = "/etc/resolv.conf"; - FILE *dns_fp; - char dns_line[256]; - #define MAX_DNS 16 - char *dns_info[MAX_DNS]; - char dns_tag[64]; - int dns_match = 0; - int i; - - snprintf(dns_tag, sizeof(dns_tag), "# IPV%d %s", iptype, ifname); - - for (i = 0; i < MAX_DNS; i++) - dns_info[i] = NULL; - - dns_fp = fopen(dns_file, "r"); - if (dns_fp) { - i = 0; - dns_line[sizeof(dns_line)-1] = '\0'; - - while((fgets(dns_line, sizeof(dns_line)-1, dns_fp)) != NULL) { - if ((strlen(dns_line) > 1) && (dns_line[strlen(dns_line) - 1] == '\n')) - dns_line[strlen(dns_line) - 1] = '\0'; - //dbg_time("%s", dns_line); - if (strstr(dns_line, dns_tag)) { - dns_match++; - continue; - } - dns_info[i++] = strdup(dns_line); - if (i == MAX_DNS) - break; - } - - fclose(dns_fp); - } - else if (errno != ENOENT) { - dbg_time("fopen %s fail, errno:%d (%s)", dns_file, errno, strerror(errno)); - return; - } - - if (dns1 == NULL && dns_match == 0) - return; - - dns_fp = fopen(dns_file, "w"); - if (dns_fp) { - if (dns1) - fprintf(dns_fp, "nameserver %s %s\n", dns1, dns_tag); - if (dns2) - fprintf(dns_fp, "nameserver %s %s\n", dns2, dns_tag); - - for (i = 0; i < MAX_DNS && dns_info[i]; i++) - fprintf(dns_fp, "%s\n", dns_info[i]); - fclose(dns_fp); - } - else { - dbg_time("fopen %s fail, errno:%d (%s)", dns_file, errno, strerror(errno)); - } - - for (i = 0; i < MAX_DNS && dns_info[i]; i++) - free(dns_info[i]); -} - -pid_t getpid_by_pdp(int pdp, const char* program_name) -{ - glob_t gt; - int ret; - char filter[16]; - pid_t pid; - - snprintf(filter, sizeof(filter), "-n %d", pdp); - ret = glob("/proc/*/cmdline", GLOB_NOSORT, NULL, >); - if (ret != 0) { - dbg_time("glob error, errno = %d(%s)", errno, strerror(errno)); - return -1; - } else { - int i = 0, fd = -1; - ssize_t nreads; - char cmdline[512] = {0}; - - for (i = 0; i < (int)gt.gl_pathc; i++) { - fd = open(gt.gl_pathv[i], O_RDONLY); - if (fd == -1) { - dbg_time("open %s failed, errno = %d(%s)", gt.gl_pathv[i], errno, strerror(errno)); - globfree(>); - return -1; - } - - nreads = read(fd, cmdline, sizeof(cmdline)); - if (nreads > 0) { - int pos = 0; - while (pos < nreads-1) { - if (cmdline[pos] == '\0') - cmdline[pos] = ' '; // space - pos++; - } - // printf("%s\n", cmdline); - } - - if (strstr(cmdline, program_name) && strstr(cmdline, filter)) { - char path[64] = {0}; - char pidstr[64] = {0}; - char *p; - - dbg_time("%s: %s", gt.gl_pathv[i], cmdline); - strcpy(path, gt.gl_pathv[i]); - p = strstr(gt.gl_pathv[i], "/cmdline"); - *p = '\0'; - while (*(--p) != '/') ; - - strcpy(pidstr, p+1); - pid = atoi(pidstr); - globfree(>); - - return pid; - } - } - } - - globfree(>); - return -1; -} - -void ql_get_driver_rmnet_info(PROFILE_T *profile, RMNET_INFO *rmnet_info) { - int ifc_ctl_sock; - struct ifreq ifr; - int rc; - int request = 0x89F3; - unsigned char data[512]; - - memset(rmnet_info, 0x00, sizeof(*rmnet_info)); - - ifc_ctl_sock = socket(AF_INET, SOCK_DGRAM, 0); - if (ifc_ctl_sock <= 0) { - dbg_time("socket() failed: %s\n", strerror(errno)); - return; - } - - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_name, profile->usbnet_adapter, IFNAMSIZ); - ifr.ifr_name[IFNAMSIZ - 1] = 0; - ifr.ifr_ifru.ifru_data = (void *)data; - - rc = ioctl(ifc_ctl_sock, request, &ifr); - if (rc < 0) { - if (errno != ENOTSUP) - dbg_time("ioctl(0x%x, qmap_settings) errno:%d (%s), rc=%d", request, errno, strerror(errno), rc); - } - else { - memcpy(rmnet_info, data, sizeof(*rmnet_info)); - } - - close(ifc_ctl_sock); -} - -void ql_set_driver_qmap_setting(PROFILE_T *profile, QMAP_SETTING *qmap_settings) { - int ifc_ctl_sock; - struct ifreq ifr; - int rc; - int request = 0x89F2; - - ifc_ctl_sock = socket(AF_INET, SOCK_DGRAM, 0); - if (ifc_ctl_sock <= 0) { - dbg_time("socket() failed: %s\n", strerror(errno)); - return; - } - - memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_name, profile->usbnet_adapter, IFNAMSIZ); - ifr.ifr_name[IFNAMSIZ - 1] = 0; - ifr.ifr_ifru.ifru_data = (void *)qmap_settings; - - rc = ioctl(ifc_ctl_sock, request, &ifr); - if (rc < 0) { - dbg_time("ioctl(0x%x, qmap_settings) failed: %s, rc=%d", request, strerror(errno), rc); - } - - close(ifc_ctl_sock); -} - -void no_trunc_strncpy(char *dest, const char *src, size_t dest_size) -{ - size_t i = 0; - - for (i = 0; i < dest_size && *src; i++) { - *dest++ = *src++; - } - - *dest = 0; -} diff --git a/quectel_cm_5G/src/util.h b/quectel_cm_5G/src/util.h deleted file mode 100644 index 4354bbc..0000000 --- a/quectel_cm_5G/src/util.h +++ /dev/null @@ -1,52 +0,0 @@ -/** - @file - util.h - - @brief - This file provides the definitions, and declares some common APIs for list-algorithm. - - */ - -#ifndef _UTILS_H_ -#define _UTILS_H_ - -#include -#include - -struct listnode -{ - struct listnode *next; - struct listnode *prev; -}; - -#define node_to_item(node, container, member) \ - (container *) (((char*) (node)) - offsetof(container, member)) - -#define list_declare(name) \ - struct listnode name = { \ - .next = &name, \ - .prev = &name, \ - } - -#define list_for_each(node, list) \ - for (node = (list)->next; node != (list); node = node->next) - -#define list_for_each_reverse(node, list) \ - for (node = (list)->prev; node != (list); node = node->prev) - -void list_init(struct listnode *list); -void list_add_tail(struct listnode *list, struct listnode *item); -void list_add_head(struct listnode *head, struct listnode *item); -void list_remove(struct listnode *item); - -#define list_empty(list) ((list) == (list)->next) -#define list_head(list) ((list)->next) -#define list_tail(list) ((list)->prev) - -int epoll_register(int epoll_fd, int fd, unsigned int events); -int epoll_deregister(int epoll_fd, int fd); -const char * get_time(void); -unsigned long clock_msec(void); -pid_t getpid_by_pdp(int, const char*); - -#endif diff --git a/rooter/0basicapps/ext-command/Makefile b/rooter/0basicapps/ext-command/Makefile deleted file mode 100644 index 828e77a..0000000 --- a/rooter/0basicapps/ext-command/Makefile +++ /dev/null @@ -1,33 +0,0 @@ -#Owned by DairyMan@Whirlpool -# -#Copyright GNU act. -include $(TOPDIR)/rules.mk - -PKG_NAME:=ext-command -PKG_VERSION:=4.500 -PKG_RELEASE:=1 - -PKG_MAINTAINER:=Created by DM/makefile by Cobia@whirlpool -include $(INCLUDE_DIR)/package.mk - -define Package/ext-command - SECTION:=utils - CATEGORY:=ROOter - SUBMENU:=Basic Applications - TITLE:=support for Command - PKGARCH:=all -endef - -define Package/ext-command/description - Helper scripts to enable command -endef - - -define Build/Compile -endef - -define Package/ext-command/install - $(CP) ./files/* $(1)/ -endef - -$(eval $(call BuildPackage,ext-command)) diff --git a/rooter/0basicapps/ext-command/files/usr/lib/lua/luci/controller/commands.lua b/rooter/0basicapps/ext-command/files/usr/lib/lua/luci/controller/commands.lua deleted file mode 100644 index a9f0640..0000000 --- a/rooter/0basicapps/ext-command/files/usr/lib/lua/luci/controller/commands.lua +++ /dev/null @@ -1,296 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2012 Jo-Philipp Wich - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -]]-- - -module("luci.controller.commands", package.seeall) - -I18N = require "luci.i18n" -translate = I18N.translate - -function index() - local multilock = luci.model.uci.cursor():get("custom", "multiuser", "multi") or "0" - local rootlock = luci.model.uci.cursor():get("custom", "multiuser", "root") or "0" - if (multilock == "0") or (multilock == "1" and rootlock == "1") then - entry({"admin", "system", "commands"}, firstchild(), _(translate("Custom Commands")), 80) - entry({"admin", "system", "commands", "dashboard"}, template("commands"), _(translate("Dashboard")), 1) - entry({"admin", "system", "commands", "config"}, cbi("commands"), _(translate("Configure")), 2) - entry({"admin", "system", "commands", "script"}, template("cmdedit"), _(translate("Scripts")), 3) - entry({"admin", "system", "commands", "run"}, call("action_run"), nil, 3).leaf = true - entry({"admin", "system", "commands", "download"}, call("action_download"), nil, 3).leaf = true - end - - entry({"admin", "system", "load_script"}, call("action_load_script")) - entry({"admin", "system", "save_script"}, call("action_save_script")) - entry({"admin", "system", "del_script"}, call("action_del_script")) - - entry({"command"}, call("action_public"), nil, 1).leaf = true -end - ---- Decode a given string into arguments following shell quoting rules ---- [[abc \def "foo\"bar" abc'def']] -> [[abc def]] [[foo"bar]] [[abcdef]] -local function parse_args(str) - local args = { } - - local function isspace(c) - if c == 9 or c == 10 or c == 11 or c == 12 or c == 13 or c == 32 then - return c - end - end - - local function isquote(c) - if c == 34 or c == 39 or c == 96 then - return c - end - end - - local function isescape(c) - if c == 92 then - return c - end - end - - local function ismeta(c) - if c == 36 or c == 92 or c == 96 then - return c - end - end - - --- Convert given table of byte values into a Lua string and append it to - --- the "args" table. Segment byte value sequence into chunks of 256 values - --- to not trip over the parameter limit for string.char() - local function putstr(bytes) - local chunks = { } - local csz = 256 - local upk = unpack - local chr = string.char - local min = math.min - local len = #bytes - local off - - for off = 1, len, csz do - chunks[#chunks+1] = chr(upk(bytes, off, min(off + csz - 1, len))) - end - - args[#args+1] = table.concat(chunks) - end - - --- Scan substring defined by the indexes [s, e] of the string "str", - --- perform unquoting and de-escaping on the fly and store the result in - --- a table of byte values which is passed to putstr() - local function unquote(s, e) - local off, esc, quote - local res = { } - - for off = s, e do - local byte = str:byte(off) - local q = isquote(byte) - local e = isescape(byte) - local m = ismeta(byte) - - if e then - esc = true - elseif esc then - if m then res[#res+1] = 92 end - res[#res+1] = byte - esc = false - elseif q and quote and q == quote then - quote = nil - elseif q and not quote then - quote = q - else - if m then res[#res+1] = 92 end - res[#res+1] = byte - end - end - - putstr(res) - end - - --- Find substring boundaries in "str". Ignore escaped or quoted - --- whitespace, pass found start- and end-index for each substring - --- to unquote() - local off, esc, start, quote - for off = 1, #str + 1 do - local byte = str:byte(off) - local q = isquote(byte) - local s = isspace(byte) or (off > #str) - local e = isescape(byte) - - if esc then - esc = false - elseif e then - esc = true - elseif q and quote and q == quote then - quote = nil - elseif q and not quote then - start = start or off - quote = q - elseif s and not quote then - if start then - unquote(start, off - 1) - start = nil - end - else - start = start or off - end - end - - --- If the "quote" is still set we encountered an unfinished string - if quote then - unquote(start, #str) - end - - return args -end - -local function parse_cmdline(cmdid, args) - local uci = require "luci.model.uci".cursor() - if uci:get("luci", cmdid) == "command" then - local cmd = uci:get_all("luci", cmdid) - local argv = parse_args(cmd.command) - local i, v - - if cmd.param == "1" and args then - for i, v in ipairs(parse_args(luci.http.urldecode(args))) do - argv[#argv+1] = v - end - end - - for i, v in ipairs(argv) do - if v:match("[^%w%.%-i/]") then - argv[i] = '"%s"' % v:gsub('"', '\\"') - end - end - - return argv - end -end - -function action_run(...) - local fs = require "nixio.fs" - local argv = parse_cmdline(...) - if argv then - local outfile = os.tmpname() - local errfile = os.tmpname() - - local rv = os.execute(table.concat(argv, " ") .. " >%s 2>%s" %{ outfile, errfile }) - local stdout = fs.readfile(outfile, 1024 * 512) or "" - local stderr = fs.readfile(errfile, 1024 * 512) or "" - - fs.unlink(outfile) - fs.unlink(errfile) - - local binary = not not (stdout:match("[%z\1-\8\14-\31]")) - - luci.http.prepare_content("application/json") - luci.http.write_json({ - command = table.concat(argv, " "), - stdout = not binary and stdout, - stderr = stderr, - exitcode = rv, - binary = binary - }) - else - luci.http.status(404, translate("No such command")) - end -end - -function action_download(...) - local fs = require "nixio.fs" - local argv = parse_cmdline(...) - if argv then - local fd = io.popen(table.concat(argv, " ") .. " 2>/dev/null") - if fd then - local chunk = fd:read(4096) or "" - local name - if chunk:match("[%z\1-\8\14-\31]") then - luci.http.header("Content-Disposition", "attachment; filename=%s" - % fs.basename(argv[1]):gsub("%W+", ".") .. ".bin") - luci.http.prepare_content("application/octet-stream") - else - luci.http.header("Content-Disposition", "attachment; filename=%s" - % fs.basename(argv[1]):gsub("%W+", ".") .. ".txt") - luci.http.prepare_content("text/plain") - end - - while chunk do - luci.http.write(chunk) - chunk = fd:read(4096) - end - - fd:close() - else - luci.http.status(500, translate("Failed to execute command")) - end - else - luci.http.status(404, "No such command") - end -end - -function action_public(cmdid, args) - local uci = require "luci.model.uci".cursor() - if cmdid and - uci:get("luci", cmdid) == "command" and - uci:get("luci", cmdid, "public") == "1" - then - action_download(cmdid, args) - else - luci.http.status(403, translate("Access to command denied")) - end -end - -function action_load_script() - local set = luci.http.formvalue("set") - local rv ={} - local file - - file = io.open(set, "r") - if file ~= nil then - local tmp = file:read("*all") - rv["text"] = tmp - file:close() - else - rv["text"] = translate("No file found") - end - - luci.http.prepare_content("application/json") - luci.http.write_json(rv) -end - -function action_save_script() - local line = luci.http.formvalue("set") - local rv ={} - local file - - s, e = line:find("|") - name = line:sub(1,s-1) - text = line:sub(e+1) - - file = io.open(name, "w") - file:write(text) - file:close() - os.execute("chmod 777 " .. name) - - rv["name"] = name - luci.http.prepare_content("application/json") - luci.http.write_json(rv) -end - -function action_del_script() - local name = luci.http.formvalue("set") - local rv ={} - os.remove(name) - - rv["name"] = name - luci.http.prepare_content("application/json") - luci.http.write_json(rv) -end \ No newline at end of file diff --git a/rooter/0basicapps/ext-command/files/usr/lib/lua/luci/model/cbi/commands.lua b/rooter/0basicapps/ext-command/files/usr/lib/lua/luci/model/cbi/commands.lua deleted file mode 100644 index 1359eb2..0000000 --- a/rooter/0basicapps/ext-command/files/usr/lib/lua/luci/model/cbi/commands.lua +++ /dev/null @@ -1,37 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2012 Jo-Philipp Wich - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -]]-- - -local m, s - -m = Map("luci", translate("Custom Commands"), - translate("This page allows you to configure custom shell commands which can be easily invoked from the web interface.")) - -s = m:section(TypedSection, "command", "") -s.template = "cbi/tblsection" -s.anonymous = true -s.addremove = true - - -s:option(Value, "name", translate("Description"), - translate("A short textual description of the configured command")) - -s:option(Value, "command", translate("Command"), - translate("Command line to execute")) - -s:option(Flag, "param", translate("Custom arguments"), - translate("Allow the user to provide additional command line arguments")) - -s:option(Flag, "public", translate("Public access"), - translate("Allow executing the command and downloading its output without prior authentication")) - -return m diff --git a/rooter/0basicapps/ext-command/files/usr/lib/lua/luci/view/cmdedit.htm b/rooter/0basicapps/ext-command/files/usr/lib/lua/luci/view/cmdedit.htm deleted file mode 100644 index cfd8a53..0000000 --- a/rooter/0basicapps/ext-command/files/usr/lib/lua/luci/view/cmdedit.htm +++ /dev/null @@ -1,186 +0,0 @@ -<%+header%> - - - - -
      -
      -

      <%:Script Editing%>

      -
      <%:Create, Edit and Save Scripts%>
      -
      - - - - - - -
      <%:Script Name :%>
       
      - - - - - - -
      <%:Path to Script :%>
       
      - - - - - -
      - -
      - - - - - - - - - -
       
      - -
      - -
      -
      -<%+footer%> \ No newline at end of file diff --git a/rooter/0basicapps/ext-command/files/usr/lib/lua/luci/view/commands.htm b/rooter/0basicapps/ext-command/files/usr/lib/lua/luci/view/commands.htm deleted file mode 100644 index 83792a9..0000000 --- a/rooter/0basicapps/ext-command/files/usr/lib/lua/luci/view/commands.htm +++ /dev/null @@ -1,176 +0,0 @@ -<%# -LuCI - Lua Configuration Interface -Copyright 2012 Jo-Philipp Wich - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - --%> - -<% css = [[ - -.commandbox { - height: 12em; - width: 30%; - float: left; - height: 12em; - margin: 5px; - position: relative; -} - -.commandbox h3 { - font-size: 1.5em !important; - line-height: 2em !important; - margin: 0 !important; -} - -.commandbox input[type="text"] { - width: 50% !important; -} - -.commandbox div { - position: absolute; - left: 0; - bottom: 1.5em; -} - -]] -%> - -<%+header%> - - - - -<% - local uci = require "luci.model.uci".cursor() - local commands = { } - - uci:foreach("luci", "command", function(s) commands[#commands+1] = s end) -%> - -
      "> -
      -

      <%:Custom Commands%>

      - -
      - <% local _, command; for _, command in ipairs(commands) do %> -
      -

      <%=pcdata(command.name)%>

      -

      <%:Command:%> <%=pcdata(command.command)%>

      - <% if command.param == "1" then %> -

      <%:Arguments:%>

      - <% end %> -
      - - - <% if command.public == "1" then %> - - <% end %> -
      -
      - <% end %> - -

      - -
      -
      - - -
      - -<%+footer%> diff --git a/rooter/0basicapps/ext-command/files/usr/lib/scripts/dummy b/rooter/0basicapps/ext-command/files/usr/lib/scripts/dummy deleted file mode 100644 index c227083..0000000 --- a/rooter/0basicapps/ext-command/files/usr/lib/scripts/dummy +++ /dev/null @@ -1 +0,0 @@ -0 \ No newline at end of file diff --git a/rooter/0basicapps/ext-extra/Makefile b/rooter/0basicapps/ext-extra/Makefile deleted file mode 100644 index 07a6c59..0000000 --- a/rooter/0basicapps/ext-extra/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -#Owned by DairyMan@Whirlpool -# -#Copyright GNU act. -include $(TOPDIR)/rules.mk - -PKG_NAME:=ext-extra -PKG_VERSION:=1.000 -PKG_RELEASE:=1 - -PKG_MAINTAINER:=Created by DM/makefile by Cobia@whirlpool -include $(INCLUDE_DIR)/package.mk - -define Package/ext-extra - SECTION:=utils - CATEGORY:=ROOter - SUBMENU:=Basic Applications - TITLE:=Add Scheduled Reboot - PKGARCH:=all -endef - -define Package/ext-extra/description - Helper scripts to install Scheduled Reboot -endef - - -define Build/Compile -endef - -define Package/ext-extra/install - $(CP) ./files/* $(1)/ - - -endef - -$(eval $(call BuildPackage,ext-extra)) diff --git a/rooter/0basicapps/ext-extra/files/etc/config/schedule b/rooter/0basicapps/ext-extra/files/etc/config/schedule deleted file mode 100644 index 95c1155..0000000 --- a/rooter/0basicapps/ext-extra/files/etc/config/schedule +++ /dev/null @@ -1,7 +0,0 @@ - -config reboot 'reboot' - option enable '0' - -config timezone 'timezone' - option zonename 'UTC' - diff --git a/rooter/0basicapps/ext-extra/files/usr/lib/lua/luci/controller/schedule.lua b/rooter/0basicapps/ext-extra/files/usr/lib/lua/luci/controller/schedule.lua deleted file mode 100644 index 8c1bda3..0000000 --- a/rooter/0basicapps/ext-extra/files/usr/lib/lua/luci/controller/schedule.lua +++ /dev/null @@ -1,9 +0,0 @@ --- Licensed to the public under the Apache License 2.0. - -module("luci.controller.schedule", package.seeall) - -function index() - local page - page = entry({"admin", "services", "schedule"}, cbi("schedule"), _("Scheduled Reboot"), 61) - page.dependent = true -end diff --git a/rooter/0basicapps/ext-extra/files/usr/lib/lua/luci/model/cbi/admin_system/cronnew.lua b/rooter/0basicapps/ext-extra/files/usr/lib/lua/luci/model/cbi/admin_system/cronnew.lua deleted file mode 100644 index 0de690c..0000000 --- a/rooter/0basicapps/ext-extra/files/usr/lib/lua/luci/model/cbi/admin_system/cronnew.lua +++ /dev/null @@ -1,29 +0,0 @@ --- Copyright 2008 Steven Barth --- Copyright 2008-2013 Jo-Philipp Wich --- Licensed to the public under the Apache License 2.0. - -local fs = require "nixio.fs" -local cronfile = "/etc/cronuser" - -f = SimpleForm("crontab", translate("Scheduled Tasks"), translate("This is the system crontab in which scheduled tasks can be defined.")) - -t = f:field(TextValue, "crons") -t.rmempty = true -t.rows = 10 -function t.cfgvalue() - return fs.readfile(cronfile) or "" -end - -function f.handle(self, state, data) - if state == FORM_VALID then - if data.crons then - fs.writefile(cronfile, data.crons:gsub("\r\n", "\n")) - else - fs.writefile(cronfile, "") - end - luci.sys.call("/usr/lib/rooter/luci/croncat.sh") - end - return true -end - -return f diff --git a/rooter/0basicapps/ext-extra/files/usr/lib/lua/luci/model/cbi/schedule.lua b/rooter/0basicapps/ext-extra/files/usr/lib/lua/luci/model/cbi/schedule.lua deleted file mode 100644 index e6cbf29..0000000 --- a/rooter/0basicapps/ext-extra/files/usr/lib/lua/luci/model/cbi/schedule.lua +++ /dev/null @@ -1,133 +0,0 @@ -local utl = require "luci.util" - -local sys = require "luci.sys" -local zones = require "luci.sys.zoneinfo" -local fs = require "nixio.fs" -local conf = require "luci.config" - -os.execute("/usr/lib/rooter/luci/reboot.sh 0") - -m = Map("schedule", translate("Scheduled Reboot"), translate("Schedule a Router Reboot at a Specified Time")) - -m.on_after_save = function(self) - luci.sys.call("/usr/lib/rooter/luci/reboot.sh 1 &") -end - -d1 = m:section(TypedSection, "timezone", " ") - ---o1 = d1:option(DummyValue, "_systime", translate("Local Time : ")) ---o1.template = "admin_system/clock_status" - -o = d1:option(DummyValue, "zonename", translate("Timezone : "), translate("Be sure to set your Timezone correctly in System->System")) - -d = m:section(TypedSection, "reboot", " ") - -c1 = d:option(ListValue, "enable", " "); -c1:value("0", "Disabled") -c1:value("1", "Enabled") -c1.default=0 - -sdhour = d:option(ListValue, "sdhour", translate("Reboot Time :")) -sdhour.rmempty = true -sdhour:value("0", "12:00 AM") -sdhour:value("1", "12:15 AM") -sdhour:value("2", "12:30 AM") -sdhour:value("3", "12:45 AM") -sdhour:value("4", "01:00 AM") -sdhour:value("5", "01:15 AM") -sdhour:value("6", "01:30 AM") -sdhour:value("7", "01:45 AM") -sdhour:value("8", "02:00 AM") -sdhour:value("9", "02:15 AM") -sdhour:value("10", "02:30 AM") -sdhour:value("11", "02:45 AM") -sdhour:value("12", "03:00 AM") -sdhour:value("13", "03:15 AM") -sdhour:value("14", "03:30 AM") -sdhour:value("15", "03:45 AM") -sdhour:value("16", "04:00 AM") -sdhour:value("17", "04:15 AM") -sdhour:value("18", "04:30 AM") -sdhour:value("19", "04:45 AM") -sdhour:value("20", "05:00 AM") -sdhour:value("21", "05:15 AM") -sdhour:value("22", "05:30 AM") -sdhour:value("23", "05:45 AM") -sdhour:value("24", "06:00 AM") -sdhour:value("25", "06:15 AM") -sdhour:value("26", "06:30 AM") -sdhour:value("27", "06:45 AM") -sdhour:value("28", "07:00 AM") -sdhour:value("29", "07:15 AM") -sdhour:value("30", "07:30 AM") -sdhour:value("31", "07:45 AM") -sdhour:value("32", "08:00 AM") -sdhour:value("33", "08:15 AM") -sdhour:value("34", "08:30 AM") -sdhour:value("35", "08:45 AM") -sdhour:value("36", "09:00 AM") -sdhour:value("37", "09:15 AM") -sdhour:value("38", "09:30 AM") -sdhour:value("39", "09:45 AM") -sdhour:value("40", "10:00 AM") -sdhour:value("41", "10:15 AM") -sdhour:value("42", "10:30 AM") -sdhour:value("43", "10:45 AM") -sdhour:value("44", "11:00 AM") -sdhour:value("45", "11:15 AM") -sdhour:value("46", "11:30 AM") -sdhour:value("47", "11:45 AM") -sdhour:value("48", "12:00 PM") -sdhour:value("49", "12:15 PM") -sdhour:value("50", "12:30 PM") -sdhour:value("51", "12:45 PM") -sdhour:value("52", "01:00 PM") -sdhour:value("53", "01:15 PM") -sdhour:value("54", "01:30 PM") -sdhour:value("55", "01:45 PM") -sdhour:value("56", "02:00 PM") -sdhour:value("57", "02:15 PM") -sdhour:value("58", "02:30 PM") -sdhour:value("59", "02:45 PM") -sdhour:value("60", "03:00 PM") -sdhour:value("61", "03:15 PM") -sdhour:value("62", "03:30 PM") -sdhour:value("63", "03:45 PM") -sdhour:value("64", "04:00 PM") -sdhour:value("65", "04:15 PM") -sdhour:value("66", "04:30 PM") -sdhour:value("67", "04:45 PM") -sdhour:value("68", "05:00 PM") -sdhour:value("69", "05:15 PM") -sdhour:value("70", "05:30 PM") -sdhour:value("71", "05:45 PM") -sdhour:value("72", "06:00 PM") -sdhour:value("73", "06:15 PM") -sdhour:value("74", "06:30 PM") -sdhour:value("75", "06:45 PM") -sdhour:value("76", "07:00 PM") -sdhour:value("77", "07:15 PM") -sdhour:value("78", "07:30 PM") -sdhour:value("79", "07:45 PM") -sdhour:value("80", "08:00 PM") -sdhour:value("81", "08:15 PM") -sdhour:value("82", "08:30 PM") -sdhour:value("83", "08:45 PM") -sdhour:value("84", "09:00 PM") -sdhour:value("85", "09:15 PM") -sdhour:value("86", "09:30 PM") -sdhour:value("87", "09:45 PM") -sdhour:value("88", "10:00 PM") -sdhour:value("89", "10:15 PM") -sdhour:value("90", "10:30 PM") -sdhour:value("91", "10:45 PM") -sdhour:value("92", "11:00 PM") -sdhour:value("93", "11:15 PM") -sdhour:value("94", "11:30 PM") -sdhour:value("95", "11:45 PM") - -sdhour:depends("enable", "1") -sdhour.default = "0" - -return m - diff --git a/rooter/0basicapps/ext-extra/files/usr/lib/rooter/luci/croncat.sh b/rooter/0basicapps/ext-extra/files/usr/lib/rooter/luci/croncat.sh deleted file mode 100644 index 842f648..0000000 --- a/rooter/0basicapps/ext-extra/files/usr/lib/rooter/luci/croncat.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh - -log() { - logger -t "Croncat" "$@" -} - -> /tmp/crontmp -if [ -e /etc/crontabs/root ]; then - while read -r line; do - if [ -n "$line" ]; then - if [ ${line: -1} == ";" ]; then - echo "$line" >> /tmp/crontmp - fi - fi - done < /etc/crontabs/root -fi - -if [ -f /etc/cronuser ]; then - if [ -f /etc/cronbase ]; then - cat /etc/cronbase /etc/cronuser > /etc/crontabs/root - else - cp /etc/cronuser /etc/crontabs/root - fi -else - if [ -f /etc/cronbase ]; then - cp /etc/cronbase /etc/crontabs/root - else - > /etc/crontabs/root - fi -fi -cat /tmp/crontmp /etc/crontabs/root > /tmp/cronroot -cp /tmp/cronroot /etc/crontabs/root -rm /tmp/crontmp -rm /tmp/cronroot - -/etc/init.d/cron restart diff --git a/rooter/0basicapps/ext-extra/files/usr/lib/rooter/luci/reboot.sh b/rooter/0basicapps/ext-extra/files/usr/lib/rooter/luci/reboot.sh deleted file mode 100644 index eac8962..0000000 --- a/rooter/0basicapps/ext-extra/files/usr/lib/rooter/luci/reboot.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh - -log() { - logger -t "Schedule Reboot" "$@" -} - -PARM=$1 - -if [ $PARM = "0" ]; then - HO=$(uci get system.@system[-1].zonename) - if [ -z $HO ]; then - HO="UTC" - fi - uci set schedule.timezone.zonename="$HO" - uci commit schedule -fi - -if [ $PARM = "1" ]; then - sleep 5 - EN=$(uci get schedule.reboot.enable) - if [ $EN = "1" ]; then - SDHOUR=$(uci get schedule.reboot.sdhour) - HOUR=`expr $SDHOUR / 4` - let "TH = $HOUR * 4" - let "TMP1 = $SDHOUR - $TH" - let "MIN = $TMP1 * 15" - echo "$MIN $HOUR * * * sleep 70 && touch /etc/banner && reboot -f" > /etc/cronbase - else - rm -f /etc/cronbase - fi - /usr/lib/rooter/luci/croncat.sh -fi diff --git a/rooter/0basicapps/ext-p910nd/Makefile b/rooter/0basicapps/ext-p910nd/Makefile deleted file mode 100644 index 9f7dc57..0000000 --- a/rooter/0basicapps/ext-p910nd/Makefile +++ /dev/null @@ -1,36 +0,0 @@ -#Owned by DairyMan@Whirlpool -# -#Copyright GNU act. -include $(TOPDIR)/rules.mk - -PKG_NAME:=ext-p910nd -PKG_VERSION:=1.000 -PKG_RELEASE:=1 - -PKG_MAINTAINER:=Created by DM/makefile by Cobia@whirlpool -include $(INCLUDE_DIR)/package.mk - -define Package/ext-p910nd - SECTION:=utils - CATEGORY:=ROOter - SUBMENU:=Basic Applications - DEPENDS:=+p910nd +kmod-usb-printer +kmod-usb-ohci - TITLE:=Install Print Server - PKGARCH:=all -endef - -define Package/ext-p910nd/description - Helper scripts to install print Server -endef - - -define Build/Compile -endef - -define Package/ext-p910nd/install - $(CP) ./files/* $(1)/ - - -endef - -$(eval $(call BuildPackage,ext-p910nd)) diff --git a/rooter/0basicapps/ext-p910nd/files/etc/uci-defaults/40_luci-p910ndx b/rooter/0basicapps/ext-p910nd/files/etc/uci-defaults/40_luci-p910ndx deleted file mode 100644 index 80f6d62..0000000 --- a/rooter/0basicapps/ext-p910nd/files/etc/uci-defaults/40_luci-p910ndx +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -uci -q batch <<-EOF >/dev/null - delete ucitrack.@p910nd[-1] - add ucitrack p910nd - set ucitrack.@p910nd[-1].init=p910nd - commit ucitrack -EOF - -rm -f /tmp/luci-indexcache -exit 0 diff --git a/rooter/0basicapps/ext-p910nd/files/usr/lib/lua/luci/controller/p910ndx.lua b/rooter/0basicapps/ext-p910nd/files/usr/lib/lua/luci/controller/p910ndx.lua deleted file mode 100644 index 2fc941f..0000000 --- a/rooter/0basicapps/ext-p910nd/files/usr/lib/lua/luci/controller/p910ndx.lua +++ /dev/null @@ -1,15 +0,0 @@ --- Copyright 2008 Yanira --- Licensed to the public under the Apache License 2.0. - -module("luci.controller.p910ndx", package.seeall) - -function index() - if not nixio.fs.access("/etc/config/p910nd") then - return - end - - local page - - page = entry({"admin", "services", "p910ndx"}, cbi("p910ndx"), _("Print Server"), 60) - page.dependent = true -end diff --git a/rooter/0basicapps/ext-p910nd/files/usr/lib/lua/luci/model/cbi/p910ndx.lua b/rooter/0basicapps/ext-p910nd/files/usr/lib/lua/luci/model/cbi/p910ndx.lua deleted file mode 100644 index 12c4a58..0000000 --- a/rooter/0basicapps/ext-p910nd/files/usr/lib/lua/luci/model/cbi/p910ndx.lua +++ /dev/null @@ -1,59 +0,0 @@ ---[[ - -LuCI p910nd -(c) 2008 Yanira -(c) 2012 Jo-Philipp Wich - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -]]-- - -local uci = luci.model.uci.cursor_state() -local net = require "luci.model.network" -local m, s, p, b - -m = Map("p910nd", translate("Print Server"), - translatef("Support for USB Printers.")) - -net = net.init(m.uci) - -s = m:section(TypedSection, "p910nd", translate("Settings")) -s.addremove = true -s.anonymous = true - -s:option(Flag, "enabled", translate("enable")) - -s:option(Value, "device", translate("Device")).rmempty = true - -b = s:option(Value, "bind", translate("Interface"), translate("Specifies the interface to listen on.")) -b.template = "cbi/network_netlist" -b.nocreate = true -b.unspecified = true - -function b.cfgvalue(...) - local v = Value.cfgvalue(...) - if v then - return (net:get_status_by_address(v)) - end -end - -function b.write(self, section, value) - local n = net:get_network(value) - if n and n:ipaddr() then - Value.write(self, section, n:ipaddr()) - end -end - -p = s:option(ListValue, "port", translate("Port"), translate("TCP listener port.")) -p.rmempty = true -for i=0,9 do - p:value(i, 9100+i) -end - -s:option(Flag, "bidirectional", translate("Bidirectional mode")) - -return m diff --git a/rooter/0basicapps/usb-storage/Makefile b/rooter/0basicapps/usb-storage/Makefile deleted file mode 100644 index e2b95c2..0000000 --- a/rooter/0basicapps/usb-storage/Makefile +++ /dev/null @@ -1,38 +0,0 @@ -#Owned by DairyMan@Whirlpool -# -#Copyright GNU act. -include $(TOPDIR)/rules.mk - -PKG_NAME:=usb-storage -PKG_VERSION:=1.000 -PKG_RELEASE:=1 - -PKG_MAINTAINER:=Created by DM/makefile by Cobia@whirlpool -include $(INCLUDE_DIR)/package.mk - -define Package/usb-storage - SECTION:=utils - CATEGORY:=ROOter - SUBMENU:=Basic Applications - DEPENDS:= +ntfs-3g +fdisk +kmod-usb-storage \ - +kmod-fs-ext4 +kmod-fs-vfat +kmod-nls-cp437 +kmod-nls-iso8859-1 +kmod-nls-utf8 \ - +block-mount +kmod-fs-exfat +kmod-fs-hfs +hd-idle - TITLE:=Install USB Storage - PKGARCH:=all -endef - -define Package/usb-storage/description - Helper scripts to install USB Storage -endef - - -define Build/Compile -endef - -define Package/usb-storage/install - $(CP) ./files/* $(1)/ - - -endef - -$(eval $(call BuildPackage,usb-storage)) diff --git a/rooter/0basicapps/usb-storage/files/etc/config/umount b/rooter/0basicapps/usb-storage/files/etc/config/umount deleted file mode 100644 index ca8f428..0000000 --- a/rooter/0basicapps/usb-storage/files/etc/config/umount +++ /dev/null @@ -1,2 +0,0 @@ -config umount 'umount' - option drive '' diff --git a/rooter/0basicapps/usb-storage/files/etc/hotplug.d/block/20-mount b/rooter/0basicapps/usb-storage/files/etc/hotplug.d/block/20-mount deleted file mode 100644 index 961a219..0000000 --- a/rooter/0basicapps/usb-storage/files/etc/hotplug.d/block/20-mount +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/sh /etc/rc.common -. /lib/functions.sh - -log() { - logger -t "20-mount" "$@" -} - -blkdev=`dirname $DEVPATH` -if [ `basename $blkdev` != "block" ]; then - device=`basename $DEVPATH` - if echo $device | grep -q "mtdblock"; then - exit 0 - fi - if [ -e /etc/sda_drop ]; then - source /etc/sda_drop - if echo $device | grep -q "$SDA"; then - exit 0 - fi - fi - if [ ! -e /usr/lib/sdcard/sdcard.sh ]; then - /usr/lib/sdcard/sdcard.sh detect - source /tmp/detect.file - if [ $detect = "1" ]; then - if echo $device | grep -q "mmcblk"; then - exit 0 - fi - fi - fi - if echo $device | grep -q "mmcblk"; then - device1="SDCard"${device:8:2} - else - device1=$device - fi - - case "$ACTION" in - add) - mkdir -p /mnt/$device1 - # vfat & ntfs-3g check - if [ `which fdisk` ]; then - isntfs=`fdisk -l | grep $device | grep NTFS` - isvfat=`fdisk -l | grep $device | grep FAT` - isfuse=`lsmod | grep fuse` - isntfs3g=`which ntfs-3g` - else - isntfs="" - isvfat="" - fi - # mount with ntfs-3g if possible, else with default mount - if [ "$isntfs" -a "$isfuse" -a "$isntfs3g" ]; then - ntfs-3g -o nls=utf8 /dev/$device /mnt/$device1 - log "Mount /mnt/$device as NTFS" - elif [ "$isvfat" ]; then - mount -o rw,sync,umask=002,codepage=437,iocharset=iso8859-1 /dev/$device /mnt/$device1 - log "Mount /mnt/$device as FAT" - else - mount -o rw,sync /dev/$device /mnt/$device1 - log "Mount /mnt/$device as other" - fi - - chmod 777 /mnt/$device1 - chown nobody /mnt/$device1 - - if [ -e /usr/lib/sdcard/sdcard.sh ]; then - /usr/lib/sdcard/sdcard.sh add - fi - ;; - esac -fi \ No newline at end of file diff --git a/rooter/0basicapps/usb-storage/files/etc/hotplug.d/block/30-mount b/rooter/0basicapps/usb-storage/files/etc/hotplug.d/block/30-mount deleted file mode 100644 index 7a1f933..0000000 --- a/rooter/0basicapps/usb-storage/files/etc/hotplug.d/block/30-mount +++ /dev/null @@ -1,88 +0,0 @@ -#!/bin/sh /etc/rc.common -. /lib/functions.sh -# Copyright (C) 2011 OpenWrt.org - -log() { - logger -t "30-mount" "$@" -} - -sanitize() { - sed -e 's/[[:space:]]\+$//; s/[[:space:]]\+/_/g' "$@" -} - -blkdev=`dirname $DEVPATH` -if [ `basename $blkdev` != "block" ]; then - device=`basename $DEVPATH` - if echo $device | grep -q "mtdblock"; then - exit 0 - fi - if [ ! -e /usr/lib/sdcard/sdcard.sh ]; then - /usr/lib/sdcard/sdcard.sh detect - source /tmp/detect.file - if [ $detect = "1" ]; then - if echo $device | grep -q "mmcblk"; then - exit 0 - fi - fi - fi - if echo $device | grep -q "mmcblk"; then - device1="SDCard"${device:8:2} - else - device1=$device - fi - - if [ -e /etc/sda_drop ]; then - source /etc/sda_drop - if echo $device | grep -q "$SDA"; then - exit 0 - fi - fi - - case "$ACTION" in - add) - MT=$(cat /proc/mounts | grep "$device") - if [ -z $MT ]; then - exit 0 - fi - DEVN=${DEVNAME:0:3} - MODEL=$(sanitize "/sys/block/$DEVN/device/model") - if [ -d /etc/ksmbd ]; then - uci delete ksmbd.$device1 - uci set ksmbd.$device1=share - uci set ksmbd.$device1.name=$device1 - uci set ksmbd.$device1.path=/mnt/$device1 - uci set ksmbd.$device1.read_only=no - uci set ksmbd.$device1.guest_ok=yes - uci set ksmbd.$device1.create_mask='0666' - uci set ksmbd.$device1.dir_mask='0777' - uci commit ksmbd - /etc/init.d/ksmbd restart - log "/mnt/$device1 shared as $device1" - else - if [ -d /etc/samba ]; then - uci delete samba.$device1 - uci set samba.$device1=sambashare - uci set samba.$device1.name=$device1 - uci set samba.$device1.path=/mnt/$device1 - uci set samba.$device1.read_only=no - uci set samba.$device1.guest_ok=yes - uci commit samba - /etc/init.d/samba restart - log "/mnt/$device1 shared as $device1" - fi - fi - ;; - remove) - log "remove /mnt/$device1" - if [ -d /etc/ksmbd ]; then - uci delete ksmbd.$device1 - uci commit ksmbd - else - if [ -d /etc/samba ]; then - uci delete samba.$device1 - uci commit samba - fi - fi - ;; - esac -fi diff --git a/rooter/0basicapps/usb-storage/files/etc/hotplug.d/block/99-mount b/rooter/0basicapps/usb-storage/files/etc/hotplug.d/block/99-mount deleted file mode 100644 index 5594607..0000000 --- a/rooter/0basicapps/usb-storage/files/etc/hotplug.d/block/99-mount +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh /etc/rc.common -. /lib/functions.sh - -log() { - logger -t "99-mount" "$@" -} - - -blkdev=`dirname $DEVPATH` -if [ `basename $blkdev` != "block" ]; then - device=`basename $DEVPATH` - if echo $device | grep -q "mtdblock"; then - exit 0 - fi - - if [ ! -e /usr/lib/sdcard/sdcard.sh ]; then - /usr/lib/sdcard/sdcard.sh detect - source /tmp/detect.file - if [ $detect = "1" ]; then - if echo $device | grep -q "mmcblk"; then - exit 0 - fi - fi - fi - if echo $device | grep -q "mmcblk"; then - device1="SDCard"${device:8:2} - else - device1=$device - fi - - case "$ACTION" in - remove) - log "remove /mnt/$device1" - umount -l /mnt/$device1 - rm -rf /mnt/$device1 - if [ -e /usr/lib/sdcard/sdcard.sh ]; then - /usr/lib/sdcard/sdcard.sh remove - fi - ;; - esac -fi \ No newline at end of file diff --git a/rooter/0basicapps/usb-storage/files/etc/uci-defaults/40_luci-hd_idle b/rooter/0basicapps/usb-storage/files/etc/uci-defaults/40_luci-hd_idle deleted file mode 100644 index 92f4356..0000000 --- a/rooter/0basicapps/usb-storage/files/etc/uci-defaults/40_luci-hd_idle +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -uci -q batch <<-EOF >/dev/null - delete ucitrack.@hd-idle[-1] - add ucitrack hd-idle - set ucitrack.@hd-idle[-1].init=hd-idle - commit ucitrack -EOF - -rm -f /tmp/luci-indexcache -exit 0 diff --git a/rooter/0basicapps/usb-storage/files/etc/umount b/rooter/0basicapps/usb-storage/files/etc/umount deleted file mode 100644 index 8292a0f..0000000 --- a/rooter/0basicapps/usb-storage/files/etc/umount +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -log() { - logger -t "Umount" "$@" -} - -sleep 5 -DRV=$(uci get umount.umount.drive) -if [ -z $DRV ]; then - exit 0 -fi - -umount -l /mnt/$DRV - -rm -rf /mnt/$DRV - -uci set umount.umount.drive='' -uci commit umount diff --git a/rooter/0basicapps/usb-storage/files/usr/lib/lua/luci/controller/hd_idle.lua b/rooter/0basicapps/usb-storage/files/usr/lib/lua/luci/controller/hd_idle.lua deleted file mode 100644 index 3e99da2..0000000 --- a/rooter/0basicapps/usb-storage/files/usr/lib/lua/luci/controller/hd_idle.lua +++ /dev/null @@ -1,15 +0,0 @@ --- Copyright 2008 Yanira --- Licensed to the public under the Apache License 2.0. - -module("luci.controller.hd_idle", package.seeall) - -function index() - if not nixio.fs.access("/etc/config/hd-idle") then - return - end - - local page - - page = entry({"admin", "services", "hd_idle"}, cbi("hd_idle"), _("Hard Drive Idle"), 60) - page.dependent = true -end diff --git a/rooter/0basicapps/usb-storage/files/usr/lib/lua/luci/controller/umount.lua b/rooter/0basicapps/usb-storage/files/usr/lib/lua/luci/controller/umount.lua deleted file mode 100644 index dbc085c..0000000 --- a/rooter/0basicapps/usb-storage/files/usr/lib/lua/luci/controller/umount.lua +++ /dev/null @@ -1,8 +0,0 @@ -module("luci.controller.umount", package.seeall) - -function index() - local page - - page = entry({"admin", "services", "umount"}, cbi("umount", {hidesavebtn=true, hideresetbtn=true}), "Safely Eject Drive", 25) - page.dependent = true -end diff --git a/rooter/0basicapps/usb-storage/files/usr/lib/lua/luci/model/cbi/hd_idle.lua b/rooter/0basicapps/usb-storage/files/usr/lib/lua/luci/model/cbi/hd_idle.lua deleted file mode 100644 index 272e926..0000000 --- a/rooter/0basicapps/usb-storage/files/usr/lib/lua/luci/model/cbi/hd_idle.lua +++ /dev/null @@ -1,29 +0,0 @@ --- Copyright 2008 Yanira --- Licensed to the public under the Apache License 2.0. - -require("nixio.fs") - -m = Map("hd-idle", "Hard Drive Idle", - translate("This is a utility program for spinning-down external " .. - "disks after a period of idle time.")) - -s = m:section(TypedSection, "hd-idle", translate("Settings")) -s.anonymous = true - -s:option(Flag, "enabled", translate("Enable")) - -disk = s:option(Value, "disk", translate("Disk")) -disk.rmempty = true -for dev in nixio.fs.glob("/dev/[sh]d[a-z]") do - disk:value(nixio.fs.basename(dev)) -end - -s:option(Value, "idle_time_interval", translate("Idle-time")).default = 10 -s.rmempty = true -unit = s:option(ListValue, "idle_time_unit", translate("Idle-time unit")) -unit.default = "minutes" -unit:value("minutes", translate("min")) -unit:value("hours", translate("h")) -unit.rmempty = true - -return m diff --git a/rooter/0basicapps/usb-storage/files/usr/lib/lua/luci/model/cbi/umount.lua b/rooter/0basicapps/usb-storage/files/usr/lib/lua/luci/model/cbi/umount.lua deleted file mode 100644 index 334fe7f..0000000 --- a/rooter/0basicapps/usb-storage/files/usr/lib/lua/luci/model/cbi/umount.lua +++ /dev/null @@ -1,20 +0,0 @@ -require("nixio.fs") - -m = Map("umount", "Safely Eject a Drive", - translate("Safely eject a drive from the router")) - -m.on_after_save = function(self) - luci.sys.call("/etc/umount &") -end - -drv = m:section(TypedSection, "umount", translate("Currently Mounted Drives")) -drv.anonymous = true - -disk = drv:option(Value, "drive", translate(" "), translate("Click Save and Apply to eject drive")) -disk.rmempty = true -for dev in nixio.fs.glob("/mnt/[sh]d[a-z][1-9]") do - dv = nixio.fs.basename(dev) - disk:value(nixio.fs.basename(dev)) -end - -return m \ No newline at end of file diff --git a/rooter/0basicapps/usb-storage/files/usr/lib/sdcard/sdcard.sh b/rooter/0basicapps/usb-storage/files/usr/lib/sdcard/sdcard.sh deleted file mode 100644 index 257d915..0000000 --- a/rooter/0basicapps/usb-storage/files/usr/lib/sdcard/sdcard.sh +++ /dev/null @@ -1,88 +0,0 @@ -#!/bin/sh - -log() { - logger -t "sdcard" "$@" -} - -h721() { - if [ $1 = "add" ]; then - echo "17" > /sys/class/gpio/export - echo "out" > /sys/class/gpio/gpio17/direction - echo 0 > /sys/class/gpio/gpio17/value - else - echo "17" > /sys/class/gpio/export - echo "out" > /sys/class/gpio/gpio17/direction - echo 1 > /sys/class/gpio/gpio17/value -fi -} - -wg1608() { - if [ $1 = "add" ]; then - echo timer > /sys/class/leds/zbt-wg3526:green:signal/trigger - echo 1000 > /sys/class/leds/zbt-wg3526:green:signal/delay_on - echo 0 > /sys/class/leds/zbt-wg3526:green:signal/delay_off - else - echo timer > /sys/class/leds/zbt-wg3526:green:signal/trigger - echo 0 > /sys/class/leds/zbt-wg3526:green:signal/delay_on - echo 1000 > /sys/class/leds/zbt-wg3526:green:signal/delay_off - fi -} - -ws7915() { - if [ $1 = "add" ]; then - echo timer > /sys/class/leds/sys/trigger - echo 1000 > /sys/class/leds/sys/delay_on - echo 0 > /sys/class/leds/sys/delay_off - else - echo timer > /sys/class/leds/sys/trigger - echo 0 > /sys/class/leds/sys/delay_on - echo 1000 > /sys/class/leds/sys/delay_off - fi -} - -ws1688() { - if [ $1 = "add" ]; then - echo timer > /sys/class/leds/usb/trigger - echo 1000 > /sys/class/leds/usb/delay_on - echo 0 > /sys/class/leds/usb/delay_off - else - echo timer > /sys/class/leds/usb/trigger - echo 0 > /sys/class/leds/usb/delay_on - echo 1000 > /sys/class/leds/usb/delay_off - fi -} - -ACTION=$1 -model=$(cat /tmp/sysinfo/model) - -case $ACTION in - "add"|"remove" ) - mod=$(echo $model | grep "H721") - if [ $mod ]; then - h721 $ACTION - fi - mod=$(echo $model | grep "WG1608") - if [ $mod ]; then - wg1608 $ACTION - fi - mod=$(echo $model | grep "WS7915") - if [ $mod ]; then - ws7915 $ACTION - fi - - mod=$(echo $model | grep "WS1688") - if [ $mod ]; then - ws1688 $ACTION - fi - ;; - "detect" ) - mod=$(echo $model | grep "Raspberry") - if [ $mod ]; then - echo 'detect="'"1"'"' > /tmp/detect.file - else - echo 'detect="'"0"'"' > /tmp/detect.file - fi - ;; -esac - - diff --git a/rooter/0basicsupport/ext-buttons/Makefile b/rooter/0basicsupport/ext-buttons/Makefile deleted file mode 100644 index d4ae835..0000000 --- a/rooter/0basicsupport/ext-buttons/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -#Owned by DairyMan@Whirlpool -# -#Copyright GNU act. -include $(TOPDIR)/rules.mk - -PKG_NAME:=ext-buttons -PKG_VERSION:=1.000 -PKG_RELEASE:=1 - -PKG_MAINTAINER:=Created by DM/makefile by Cobia@whirlpool -include $(INCLUDE_DIR)/package.mk - -define Package/ext-buttons - SECTION:=utils - CATEGORY:=ROOter - SUBMENU:=Basic Support - TITLE:=Install button support - PKGARCH:=all -endef - -define Package/ext-buttons/description - Helper scripts to install button support -endef - - -define Build/Compile -endef - -define Package/ext-buttons/install - $(CP) ./files/* $(1)/ - - -endef - -$(eval $(call BuildPackage,ext-buttons)) diff --git a/rooter/0basicsupport/ext-buttons/files/etc/btnaction.sh b/rooter/0basicsupport/ext-buttons/files/etc/btnaction.sh deleted file mode 100644 index 82a4e4e..0000000 --- a/rooter/0basicsupport/ext-buttons/files/etc/btnaction.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/sh - -FUNC=$1 - -reset_short() { - passwd -d root - reboot -f -} - -reset_long() { - mtd -r erase rootfs_data -} - -wifi() { - STATEFILE="/tmp/wifionoff.state" - - if [ $# -eq 1 ]; then - case $1 in - "up"|"on") - STATE=off - ;; - "down"|"off") - STATE=on - ;; - esac - else - if [ ! -e ${STATEFILE} ]; then - STATE=on - else - . ${STATEFILE} - fi - fi - if [ -z ${STATE} ]; then - STATE=on - fi - - if [ ${STATE} == "on" ]; then - /sbin/wifi down - STATE=off - else - /sbin/wifi up - STATE=on - fi - - echo "STATE=${STATE}" > ${STATEFILE} -} - -if [ $FUNC = "reset_short" ]; then - reset_short -fi -if [ $FUNC = "reset_long" ]; then - reset_long -fi -if [ $FUNC = "wifi" ]; then - wifi $2 -fi diff --git a/rooter/0basicsupport/ext-buttons/files/etc/hotplug.d/button/00-button b/rooter/0basicsupport/ext-buttons/files/etc/hotplug.d/button/00-button deleted file mode 100644 index 0efab99..0000000 --- a/rooter/0basicsupport/ext-buttons/files/etc/hotplug.d/button/00-button +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh -. /lib/functions.sh - -do_button () { - local button - local action - local handler - local min - local max - - config_get button $1 button - config_get action $1 action - config_get handler $1 handler - config_get min $1 min - config_get max $1 max - - [ "$ACTION" = "$action" -a "$BUTTON" = "$button" -a -n "$handler" ] && { - [ -z "$min" -o -z "$max" ] && eval $handler - [ -n "$min" -a -n "$max" ] && { - [ $min -le $SEEN -a $max -ge $SEEN ] && eval $handler - } - } -} - -config_load system -config_foreach do_button button \ No newline at end of file diff --git a/rooter/0basicsupport/ext-buttons/files/etc/hotplug.d/button/10-buttonchk b/rooter/0basicsupport/ext-buttons/files/etc/hotplug.d/button/10-buttonchk deleted file mode 100644 index ea4f499..0000000 --- a/rooter/0basicsupport/ext-buttons/files/etc/hotplug.d/button/10-buttonchk +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -log() { - logger -t "Button Checker " "$@" -} - -log "Button Name : $BUTTON Action : $ACTION" - -log "$ACTION $SEEN" - diff --git a/rooter/0basicsupport/ext-buttons/files/etc/init.d/buttons b/rooter/0basicsupport/ext-buttons/files/etc/init.d/buttons deleted file mode 100644 index 1901e61..0000000 --- a/rooter/0basicsupport/ext-buttons/files/etc/init.d/buttons +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh /etc/rc.common -# Copyright (C) 2006 OpenWrt.org - -log() { - logger -t "Buttons" "$@" -} - -START=98 - -start() { - local BTN=$(uci -q get system.@button[-1].button) -} - -stop() { - log "Stopping Buttons" -} diff --git a/rooter/0basicsupport/ext-buttons/files/usr/lib/lua/luci/controller/buttons.lua b/rooter/0basicsupport/ext-buttons/files/usr/lib/lua/luci/controller/buttons.lua deleted file mode 100644 index 70fa838..0000000 --- a/rooter/0basicsupport/ext-buttons/files/usr/lib/lua/luci/controller/buttons.lua +++ /dev/null @@ -1,14 +0,0 @@ -module("luci.controller.buttons", package.seeall) - -I18N = require "luci.i18n" -translate = I18N.translate - -function index() - local page - local multilock = luci.model.uci.cursor():get("custom", "multiuser", "multi") or "0" - local rootlock = luci.model.uci.cursor():get("custom", "multiuser", "root") or "0" - if (multilock == "0") or (multilock == "1" and rootlock == "1") then - page = entry({"admin", "system", "buttons"}, cbi("buttons/buttons"), _(translate("Buttons")), 65) - page.dependent = true - end -end diff --git a/rooter/0basicsupport/ext-buttons/files/usr/lib/lua/luci/model/cbi/buttons/buttons.lua b/rooter/0basicsupport/ext-buttons/files/usr/lib/lua/luci/model/cbi/buttons/buttons.lua deleted file mode 100644 index 4f37569..0000000 --- a/rooter/0basicsupport/ext-buttons/files/usr/lib/lua/luci/model/cbi/buttons/buttons.lua +++ /dev/null @@ -1,44 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2008 Steven Barth - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -$Id$ -]]-- - -m = Map("system", translate("Buttons"), - translate("This page allows the configuration of custom button actions")) - -s = m:section(TypedSection, "button", "") -s.anonymous = true -s.addremove = true - -s:option(Value, "button", translate("Name")) - -act = s:option(ListValue, "action", - translate("Action"), - translate("Specifies the button state to handle")) - -act:value("released") -act:value("pressed") -act.default = "released" - -s:option(Value, "handler", - translate("Handler"), - translate("Path to executable which handles the button event")) - -min = s:option(Value, "min", translate("Minimum hold time")) -min.rmempty = true -min:depends("action", "released") - -max = s:option(Value, "max", translate("Maximum hold time")) -max.rmempty = true -max:depends("action", "released") - -return m \ No newline at end of file diff --git a/rooter/0basicsupport/ext-sms/Makefile b/rooter/0basicsupport/ext-sms/Makefile deleted file mode 100644 index 3315be2..0000000 --- a/rooter/0basicsupport/ext-sms/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -#Owned by DairyMan@Whirlpool -# -#Copyright GNU act. -include $(TOPDIR)/rules.mk - -PKG_NAME:=ext-sms -PKG_VERSION:=1.000 -PKG_RELEASE:=1 - -PKG_MAINTAINER:=Created by DM/makefile by Cobia@whirlpool -include $(INCLUDE_DIR)/package.mk - -define Package/ext-sms - SECTION:=utils - CATEGORY:=ROOter - SUBMENU:=Basic Support - TITLE:=Install SMS support - PKGARCH:=all -endef - -define Package/ext-sms/description - Helper scripts to install SMS on ROOter -endef - - -define Build/Compile -endef - -define Package/ext-sms/install - $(CP) ./files/* $(1)/ - - -endef - -$(eval $(call BuildPackage,ext-sms)) diff --git a/rooter/0basicsupport/ext-sms/files/usr/lib/lua/luci/controller/sms.lua b/rooter/0basicsupport/ext-sms/files/usr/lib/lua/luci/controller/sms.lua deleted file mode 100644 index e17e2ee..0000000 --- a/rooter/0basicsupport/ext-sms/files/usr/lib/lua/luci/controller/sms.lua +++ /dev/null @@ -1,162 +0,0 @@ -module("luci.controller.sms", package.seeall) - -I18N = require "luci.i18n" -translate = I18N.translate - -function index() - local fs = require "nixio.fs" - if not fs.stat("/etc/nosms") then - local page - page = entry({"admin", "modem", "sms"}, template("rooter/sms"), translate("短信功能"), 35) - page.dependent = true - - end - - - entry({"admin", "modem", "check_read"}, call("action_check_read")) - entry({"admin", "modem", "del_sms"}, call("action_del_sms")) - entry({"admin", "modem", "send_sms"}, call("action_send_sms")) - entry({"admin", "modem", "change_sms"}, call("action_change_sms")) - entry({"admin", "modem", "change_smsdn"}, call("action_change_smsdn")) - entry({"admin", "modem", "change_smsflag"}, call("action_change_smsflag")) - entry({"admin", "modem", "delall_sms"}, call("action_delall_sms")) -end - -function trim(s) - return (s:gsub("^%s*(.-)%s*$", "%1")) -end - -function action_send_sms() - if package.path:find(";/usr/lib/sms/?.lua") == nil then - package.path = package.path .. ";/usr/lib/sms/?.lua" - end - smsnum = luci.model.uci.cursor():get("modem", "general", "smsnum") - local set = luci.http.formvalue("set") - local number = trim(string.sub(set, 1, 20)) - local txt = string.sub(set, 21) - local utf8togsm = require "utf8togsm" - utf8togsm.chktxt(txt) - local msg = utf8togsm["msg"] - local dcs = utf8togsm["dcs"] - txt = utf8togsm["txt"] - local rv = {} - local file = nil - local k = 1 - local status - local rfname = "/tmp/smssendstatus0000" - if msg == nil then - os.execute("if [ -e " .. rfname .. " ]; then rm " ..rfname .. "; fi") - os.execute("lua /usr/lib/sms/sendsms.lua " .. smsnum .. " " .. number .. " " .. dcs .. " " .. txt .. " 0000") - os.execute("sleep 3") - repeat - file = io.open(rfname, "r") - if file == nil then - os.execute("sleep 1") - end - k = k + 1 - until k > 25 or file ~=nil - if file == nil then - status = translate('Sending attempt timed out (fail)') - else - status = file:read("*line") - file:close() - os.remove (rfname) - end - else - status = msg - end - rv["status"] = status - luci.http.prepare_content("application/json") - luci.http.write_json(rv) -end - -function action_delall_sms() - smsnum = luci.model.uci.cursor():get("modem", "general", "smsnum") - os.execute("/usr/lib/sms/delall.sh " .. smsnum) -end - -function action_del_sms() - local set = luci.http.formvalue("set") - if set ~= nil then - smsnum = luci.model.uci.cursor():get("modem", "general", "smsnum") - os.execute("/usr/lib/sms/delsms.sh " .. smsnum .. " " .. set) - os.execute("touch /tmp/smswakeup" .. smsnum) - end -end - -function action_check_read() - local rv ={} - local file - local line - smsnum = luci.model.uci.cursor():get("modem", "general", "smsnum") - conn = "Modem #" .. smsnum - rv["conntype"] = conn - support = luci.model.uci.cursor():get("modem", "modem" .. smsnum, "sms") - rv["ready"] = "0" - rv["menable"] = "0" - rv["mslots"] = "0" - if support == "1" then - rv["ready"] = "1" - result = "/tmp/smsresult" .. smsnum .. ".at" - file = io.open(result, "r") - if file ~= nil then - file:close() - file = io.open("/tmp/smstext" .. smsnum, "r") - if file == nil then - rv["ready"] = "3" - else - rv["menable"] = luci.model.uci.cursor():get("modem", "sms", "menable") - rv["mslots"] = luci.model.uci.cursor():get("modem", "sms", "slots") - rv["ready"] = "2" - local tmp = file:read("*line") - rv["used"] = tmp - tmp = file:read("*line") - rv["max"] = tmp - full = nil - - repeat - for j = 1, 4 do - line = file:read("*line") - if line ~= nil then - if j == 3 then - full = full .. string.char(29) - local i = tonumber(line) - for k = 1, i do - line = file:read("*line") - full = full .. line - if k < i then - full = full .. '\n' - end - end - else - if full == nil then - full = line - else - full = full .. string.char(29) .. line - end - end - end - end - until line == nil - file:close() - rv["line"] = full - end - end - end - - luci.http.prepare_content("application/json") - luci.http.write_json(rv) -end - -function action_change_sms() - os.execute("/usr/lib/rooter/luci/modemchge.sh sms 1") -end - -function action_change_smsdn() - os.execute("/usr/lib/rooter/luci/modemchge.sh sms 0") -end - -function action_change_smsflag() - local set = tonumber(luci.http.formvalue("set")) - os.execute("/usr/lib/sms/toggle.sh " .. set) -end diff --git a/rooter/0basicsupport/ext-sms/files/usr/lib/lua/luci/view/rooter/sms.htm b/rooter/0basicsupport/ext-sms/files/usr/lib/lua/luci/view/rooter/sms.htm deleted file mode 100644 index 6b4c787..0000000 --- a/rooter/0basicsupport/ext-sms/files/usr/lib/lua/luci/view/rooter/sms.htm +++ /dev/null @@ -1,556 +0,0 @@ -<%+header%> - - - - -
      -
      -

      <%:短信收发页面%>

      -
      <%:通过模块发送和接收文本消息%>
      -
      - <%:通信模块信息%> - - - - - - - -
        - - - -
        - <%:收到的短信%> - - - - - - - - - - - - -
        <%:SIM可存放的短信空间 (条)%>
        <%:已使用的SIM短信空间 (条)%>
         
             
            - - - - - - - - - - - - - - - - -
             
            <%:启用模块到SIM卡的短信传输%>
            - -
            <%:模块上的未读信息数量%>
             
               
               
              - - - - - - - -
                
              - - - - - - - - - - - -
              <%:已读状态%>
              <%:发件人%>
              <%:Date%>
              <%:时间%>
              <%:短信%>
              - - - - - -
              - -
              - - - - - - - - -
              <%:短信内容 :%>
              - -  
              - - - - - - - - -
               
              - - <%:短信会话%> - - - - - - - -
              <%:收件人 :%>
               
              - - - - - -
              - -
              - - - - - - - -
                
              - - - - - - - -
              <%:短信发送状态 :%>
                 
                - -
                - -
                -
                -<%+footer%> diff --git a/rooter/0basicsupport/ext-sms/files/usr/lib/sms/delall.sh b/rooter/0basicsupport/ext-sms/files/usr/lib/sms/delall.sh deleted file mode 100644 index aa0c50b..0000000 --- a/rooter/0basicsupport/ext-sms/files/usr/lib/sms/delall.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -log() { - modlog "Delete SMS" "$@" -} - -CURRMODEM=$1 -COMMPORT="/dev/ttyUSB"$(uci get modem.modem$CURRMODEM.commport) -SMSLOC=$(uci -q get modem.modem$CURRMODEM.smsloc) - -LOCKDIR="/tmp/smslock$CURRMODEM" -PIDFILE="${LOCKDIR}/PID" - -while [ 1 -lt 6 ]; do - if mkdir "${LOCKDIR}" &>/dev/null; then - echo "$$" > "${PIDFILE}" - ATCMDD="AT+CPMS=\"$SMSLOC\";+CMGD=1,4" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - log "$OX" - uci set modem.modem$CURRMODEM.smsnum=999 - uci commit modem - break - else - OTHERPID="$(cat "${PIDFILE}")" - if [ $? = 0 ]; then - if ! kill -0 $OTHERPID &>/dev/null; then - rm -rf "${LOCKDIR}" - fi - fi - sleep 1 - fi -done -rm -rf "${LOCKDIR}" \ No newline at end of file diff --git a/rooter/0basicsupport/ext-sms/files/usr/lib/sms/delsms.sh b/rooter/0basicsupport/ext-sms/files/usr/lib/sms/delsms.sh deleted file mode 100644 index a8ccfc8..0000000 --- a/rooter/0basicsupport/ext-sms/files/usr/lib/sms/delsms.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -log() { - modlog "Delete SMS" "$@" -} - -CURRMODEM=$1 -shift 1 -SLOTS="$@" -log "$SLOTS" - -COMMPORT="/dev/ttyUSB"$(uci get modem.modem$CURRMODEM.commport) - -SMSLOC=$(uci -q get modem.modem$CURRMODEM.smsloc) - -LOCKDIR="/tmp/smslock$CURRMODEM" -PIDFILE="${LOCKDIR}/PID" - -while [ true ]; do - if mkdir "${LOCKDIR}" &>/dev/null; then - echo "$$" > "${PIDFILE}" - for SLOT in $SLOTS - do - ATCMDD="AT+CPMS=\"$SMSLOC\";+CMGD=$SLOT" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - log "$OX" - done - uci set modem.modem$CURRMODEM.smsnum=999 - uci commit modem - break - else - OTHERPID="$(cat "${PIDFILE}")" - if [ $? = 0 ]; then - if ! kill -0 $OTHERPID &>/dev/null; then - rm -rf "${LOCKDIR}" - fi - fi - sleep 1 - fi -done -rm -rf "${LOCKDIR}" diff --git a/rooter/0basicsupport/ext-sms/files/usr/lib/sms/merge.lua b/rooter/0basicsupport/ext-sms/files/usr/lib/sms/merge.lua deleted file mode 100644 index 4a7442c..0000000 --- a/rooter/0basicsupport/ext-sms/files/usr/lib/sms/merge.lua +++ /dev/null @@ -1,165 +0,0 @@ -#!/usr/bin/lua - -function ltrim(s) - return s:match'^%s*(.*)' -end - -file=arg[1] -filet=arg[1] - -overall = {} - -cntr = 1 -filein = io.open(file, "r") -maxslot = -1 -repeat - message = {} - local line = filein:read("*line") - if line == nil then - break - end - if cntr < 2 then - maxused = line - line = filein:read("*line") - maxslots = line - cntr=2 - else - message['slot'] = line - message['phone'] = filein:read("*line") - nline = filein:read("*line") - message['nline'] = nline - ncntr = 1 - msg="" - message['msgnum'] = "xxx" - message['msgord'] = "xxx" - message['msgmax'] = "xxx" - lines = filein:read("*line") - s, e = lines:find("Msg# ") - if s ~= nil then - bs, be = lines:find(",", e+1) - msgnum = lines:sub(e+1, be-1) - message['msgnum'] = msgnum - s, e = lines:find("/", be+1) - msgord = lines:sub(be+1, e-1) - message['msgord'] = msgord - message['msgmax'] = lines:sub(e+1) - lines = filein:read("*line") - end - msg = lines - nc = tonumber(nline) - if nc > 2 then - for i=1,nc-2,1 - do - lines = filein:read("*line") - if lines ~= "" then - msg = msg .. "\n" .. lines - else - if i == nc-2 then - if msgord == message['msgmax'] then - msg = msg .. "\n\n" - else - msg = msg .. "\n\n" - end - else - msg = msg .. "\n" - - end - end - end - --print(nln, msg) - --msg = msg .. "\n" - end - message['msg'] = msg - message['numlines'] = nc - 1 - sht = filein:read("*line") - s, e = sht:find("Msg#") - if s ~= nil then - shtt = sht:sub(1, s-1) - bs, be = sht:find("/", e) - sht = shtt .. sht:sub(be+2) - end - message['short'] = sht - overall[message['slot']] = message - if maxslot < tonumber(message['slot']) then - maxslot = tonumber(message['slot']) - end - end -until 1==0 -filein:close() - -fileout = io.open(filet, "w") -fileout:write(maxused, "\n") -fileout:write(maxslots, "\n") - -for i=0,maxslot,1 -do - msgbuild = {} - shortmsg = {} - if overall[tostring(i)] ~= nil then - --print(i, overall[tostring(i)]['msgnum']) - if overall[tostring(i)]['msgnum'] == "xxx" then - fileout:write(overall[tostring(i)]['slot'], "\n") - fileout:write(overall[tostring(i)]['phone'], "\n") - fileout:write(overall[tostring(i)]['nline'], "\n") - fileout:write(overall[tostring(i)]['msg'], "\n") - fileout:write(overall[tostring(i)]['short'], "\n") - else - msgnum = overall[tostring(i)]['msgnum'] - msgtmp = overall[tostring(i)]['slot'] - msgord = overall[tostring(i)]['msgord'] - msgmax = tonumber(overall[tostring(i)]['msgmax']) - msg = overall[tostring(i)]['msg'] - numlines = overall[tostring(i)]['numlines'] - --print(numlines) - msgbuild[overall[tostring(i)]['msgord']] = overall[tostring(i)]['msg'] - shortmsg[overall[tostring(i)]['msgord']] = overall[tostring(i)]['short'] - for j=i+1,maxslot,1 - do - if overall[tostring(j)] ~= nil then - if overall[tostring(j)]['msgnum'] == msgnum then - numlines = numlines + (overall[tostring(j)]['numlines']) - --print(overall[tostring(j)]['numlines']) - msgtmp = msgtmp .. " " .. overall[tostring(j)]['slot'] - msgbuild[overall[tostring(j)]['msgord']] = overall[tostring(j)]['msg'] - shortmsg[overall[tostring(j)]['msgord']] = overall[tostring(j)]['short'] - overall[tostring(j)] = nil - end - end - end - msg="" - mflg = 0 - short = nil - for j=1,msgmax,1 - do - if msgbuild[tostring(j)] ~= nil then - msg = msg .. msgbuild[tostring(j)] - if short == nil then - short = shortmsg[tostring(j)] - end - else - mflg = 1 - end - end - fileout:write(msgtmp, "\n") - fileout:write(overall[tostring(i)]['phone'], "\n") - - if mflg ~= 0 then - msg = "Partial Message : " .. msg - t = short:gsub("%s+", " ") - short = "Partial Message " .. t - end - endc = string.sub(msg, -2) - if endc == "\n\n" then - mlen = msg:len() - 2 - msg = string.sub(msg,1,mlen) - end - local _,n = msg:gsub("\n","") - fileout:write(tostring(n+1), "\n") - fileout:write(msg, "\n") - fileout:write(short, "\n") - end - end -end -fileout:close() - - diff --git a/rooter/0basicsupport/ext-sms/files/usr/lib/sms/pack7bit.lua b/rooter/0basicsupport/ext-sms/files/usr/lib/sms/pack7bit.lua deleted file mode 100644 index bbd5661..0000000 --- a/rooter/0basicsupport/ext-sms/files/usr/lib/sms/pack7bit.lua +++ /dev/null @@ -1,79 +0,0 @@ -local pack7bit = {} - -function hasbit(x, p) - return x % (p + p) >= p -end - -function bitand(x, y) - local p = 1; local z = 0; local limit = x > y and x or y - while p <= limit do - if hasbit(x, p) and hasbit(y, p) then - z = z + p - end - p = p + p - end - return z -end - -function bitor(x, y) - local p = 1; local z = 0; local limit = x > y and x or y - while p <= limit do - if hasbit(x, p) or hasbit(y, p) then - z = z + p - end - p = p + p - end - return z -end - -function bitright(x, y) - return math.floor(x / 2 ^ y) -end - -function bitleft(x, y) - return x * 2 ^ y -end - -function pack7bit.pack(udl, txt) - maxb = math.ceil((tonumber(udl, 16) / 8) * 7) - udtab = {} - ii = 1 - jj = 1 - kk = 0 - repeat - ch = tonumber(txt:sub(jj, jj + 1), 16) - if ii == 1 then - udtab[kk + 1] = ch - elseif ii == 2 then - udtab[kk] = bitor(bitleft(bitand(ch, 1), 7), udtab[kk]) - udtab[kk + 1] = bitright(bitand(ch, 126), 1) - elseif ii == 3 then - udtab[kk] = bitor(bitleft(bitand(ch, 3), 6), udtab[kk]) - udtab[kk + 1] = bitright(bitand(ch, 124), 2) - elseif ii == 4 then - udtab[kk] = bitor(bitleft(bitand(ch, 7), 5), udtab[kk]) - udtab[kk + 1] = bitright(bitand(ch, 120), 3) - elseif ii == 5 then - udtab[kk] = bitor(bitleft((bitand(ch, 15)), 4), udtab[kk]) - udtab[kk + 1] = bitright(bitand(ch, 112), 4) - elseif ii == 6 then - udtab[kk] = bitor(bitleft(bitand(ch, 31), 3), udtab[kk]) - udtab[kk + 1] = bitright(bitand(ch, 96), 5) - elseif ii == 7 then - udtab[kk] = bitor(bitleft(bitand(ch, 63), 2), udtab[kk]) - udtab[kk + 1] = bitright(bitand(ch, 64), 6) - else - udtab[kk] = bitor(bitleft(ch, 1), udtab[kk]) - ii = 0 - kk = kk - 1 - end - ii = ii + 1 - jj = jj + 2 - kk = kk + 1 - until jj > #txt - for jj = 1, maxb do - udtab[jj] = string.format("%02X", udtab[jj]) - end - pack7bit["pdu"] = table.concat(udtab) -end -return pack7bit diff --git a/rooter/0basicsupport/ext-sms/files/usr/lib/sms/processsms b/rooter/0basicsupport/ext-sms/files/usr/lib/sms/processsms deleted file mode 100644 index 8826bb2..0000000 --- a/rooter/0basicsupport/ext-sms/files/usr/lib/sms/processsms +++ /dev/null @@ -1,168 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -log() { - logger -t "sms process" "$@" -} - -CURRMODEM=$1 - -log "SMS Supported Modem$CURRMODEM" - -COMMPORT="/dev/ttyUSB"$(uci get modem.modem$CURRMODEM.commport) - -LOCKDIR="/tmp/smslock$CURRMODEM" -PIDFILE="${LOCKDIR}/PID" -rm -rf "${LOCKDIR}" - -idV=$(uci -q get modem.modem$CURRMODEM.idV) -idP=$(uci -q get modem.modem$CURRMODEM.idP) -MODEMID="$idV${idP:0:3}" - -ATCMDD="AT+CMGF=0" -OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") -sleep 1 -ATCMDD="AT+CPMS=\"SM\",\"SM\",\"SM\"" -OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") -MAXED=$(echo "$OX" | cut -d, -f2 | grep -o "[0-9]\{1,3\}") -if [ "$MAXED" == "0" -a "$MODEMID" != "119968a" ]; then - ATCMDD="AT+CPMS=\"ME\",\"ME\",\"ME\"" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - uci set modem.modem$CURRMODEM.smsloc="ME" - SMSLOC="ME" - MEM3="ME" -else - uci set modem.modem$CURRMODEM.smsloc="SM" - SMSLOC="SM" - MEM3="SM" -fi -sleep 1 -uci set modem.modem$CURRMODEM.smsnum=999 -uci commit modem -ATCMDD="AT+CPMS=\"ME\"" -OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") -MESC=$(echo "$OX" | grep -o "+CPMS:.*" | awk -F, '{print $1}' | grep -o "[0-9]\{1,3\}") -METC=$(echo "$OX" | grep -o "+CPMS:.*" | awk -F, '{print $2}' | grep -o "[0-9]\{1,3\}") -MESLOT="0" -MESCc="" -if [ "x$MESC" = "x" ]; then - MESC="0" -fi -if [ "x$METC" = "x" ]; then - METC="0" - MESC="0" - SMSLOC="SM" -fi -uci set modem.sms.slots=$MESC -uci commit modem -sleep 1 - -rm -f /tmp/smsresult$CURRMODEM".at" -> /tmp/smsslots$CURRMODEM -HH=$(date +%H) - -while true; do - SLEEP="20" - while true; do - if mkdir "${LOCKDIR}" &>/dev/null; then - echo "$$" > "${PIDFILE}" - if [ "$METC" != "0" ]; then - ATCMDD="AT+CPMS=\"ME\",\"$SMSLOC\",\"$MEM3\"" - SX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - USED=$(echo "$SX" | cut -d, -f1 | grep -o "[0-9]\{1,3\}") - MESCc="$USED" - MAXED=$(echo "$SX" | cut -d, -f2 | grep -o "[0-9]\{1,3\}") - fi - if [ $SMSLOC == "SM" ]; then - ATCMDD="AT+CPMS=\"SM\",\"$SMSLOC\",\"$MEM3\"" - SX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - USED=$(echo "$SX" | cut -d, -f1 | grep -o "[0-9]\{1,3\}") - MAXED=$(echo "$SX" | cut -d, -f2 | grep -o "[0-9]\{1,3\}") - if [ -n "$MESCc" -a "$MESCc" != "$MESC" ]; then - MESC=$MESCc - uci set modem.sms.slots=$MESC - uci commit modem - fi - if [ $USED == $MAXED -a $MEM3 == "SM" ]; then - ATCMDD="AT+CPMS=\"SM\",\"SM\",\"ME\"" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - MEM3="ME" - else - if [ $USED != $MAXED -a $MEM3 == "ME" ]; then - ATCMDD="AT+CPMS=\"SM\",\"SM\",\"SM\"" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - MEM3="SM" - fi - fi - fi - if [ $MAXED -eq 0 ]; then - SLEEP="900" - fi - if [ $USED -eq $(uci get modem.modem$CURRMODEM.smsnum) ] && [ $HH -eq $(date +%H) ]; then - if [ $MEM3 == "SM" -a $USED -lt $MAXED -a $MESC -gt 0 -a $(uci -q get modem.sms.menable) == 1 ]; then - ATCMDD="AT+CPMS=\"ME\";+CMGR=$MESLOT;+CPMS=\"SM\"" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - Rstat=$(echo "$OX" | grep -o "+CMGR:[^,]\+" | grep -o "[0-3]") - PDU=$(echo "$OX" | grep -o "[0-9A-F]\{30,\}") - PDUL=$(echo "$OX" | grep -o "+CMGR:.*" | grep -o ",[0-9]\{1,\}" | grep -o "[0-9]\{1,3\}") - if [ -n "$PDU" -a -n "$PDUL" -a -n "$Rstat" ]; then - if [ ${#PDUL} -eq 2 ]; then - PDUL="0$PDUL" - fi - ATCMDD="$PDUL,SM,$Rstat,$PDU" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "smswrite.gcom" "$CURRMODEM" "$ATCMDD") - MREF=$(echo "$OX" | grep -o "[0-9]\{1,3\}") - if [ ${#MREF} -gt 0 ]; then - echo "$MREF" >> /tmp/smsslots$CURRMODEM - ATCMDD="AT+CPMS=\"ME\";+CMGD=$MESLOT;+CPMS=\"SM\"" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - fi - MESC=$(($MESC - 1)) - uci set modem.sms.slots=$MESC - uci commit modem - SLEEP="5" - fi - MESLOT=$(($MESLOT + 1)) - if [ $MESLOT -gt $METC -o $MESC == "0" ]; then - MESLOT="0" - fi - fi - else - log "Reread SMS Messages on Modem $CURRMODEM" - echo "$SX" > /tmp/smstemp$CURRMODEM - ATCMDD="AT+CMGL=4" - SX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - SX=$(echo "$SX" | sed -e "s/+CMGL:/+CMGL: /g") - echo "$SX" >> /tmp/smstemp$CURRMODEM - uci set modem.modem$CURRMODEM.smsnum=$USED - uci commit modem - mv /tmp/smstemp$CURRMODEM /tmp/smsresult$CURRMODEM.at - lua /usr/lib/sms/smsread.lua $CURRMODEM - HH=$(date +%H) - SLEEP="5" - fi - break - else - OTHERPID="$(cat "${PIDFILE}")" - if [ $? = 0 ]; then - if ! kill -0 $OTHERPID &>/dev/null; then - rm -rf "${LOCKDIR}" - fi - fi - sleep 1 - fi - done - rm -rf "${LOCKDIR}" - n=1 - until [ $n -ge $SLEEP ] - do - sleep 1 - if [ -e /tmp/smswakeup$CURRMODEM ]; then - rm /tmp/smswakeup$CURRMODEM - n=$(( $n + $SLEEP )) - else - n=$(( $n + 1 )) - fi - done -done diff --git a/rooter/0basicsupport/ext-sms/files/usr/lib/sms/sendsms.lua b/rooter/0basicsupport/ext-sms/files/usr/lib/sms/sendsms.lua deleted file mode 100644 index baee895..0000000 --- a/rooter/0basicsupport/ext-sms/files/usr/lib/sms/sendsms.lua +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/lua - -modem = arg[1] -addr = arg[2] -dcs = arg[3] -txt = arg[4] -suffix = arg[5] - -if package.path:find(";/usr/lib/sms/?.lua") == nil then - package.path = package.path .. ";/usr/lib/sms/?.lua" -end - -local pack7bit = require "pack7bit" - -udl = string.format("%02X", math.floor(#txt / 2)) -da = "81" -if addr:sub(1, 1) == "+" then - da = "91" - addr = addr:sub(2) -elseif addr:sub(1, 1) == "-" then - addr = addr:sub(2) -end -da = string.format("%02X", #addr) .. da -if (#addr % 2) > 0 then - addr = addr .. "F" -end -k = #addr -j = 1 -repeat - da = da .. addr:sub(j + 1, j + 1) .. addr:sub(j, j) - j = j + 2 -until j > k -if dcs == "00" then - pack7bit.pack(udl, txt) - ud = pack7bit["pdu"] -else - ud = txt -end -pdu = "001100" .. da .. "00" .. dcs .. "AD" .. udl .. ud -pdul = string.format("%03d", (math.floor(#pdu / 2) - 1)) -os.execute("/usr/lib/sms/sendsms.sh " .. modem .. " " .. pdul .. "," .. suffix .. "," .. pdu .. " &") diff --git a/rooter/0basicsupport/ext-sms/files/usr/lib/sms/sendsms.sh b/rooter/0basicsupport/ext-sms/files/usr/lib/sms/sendsms.sh deleted file mode 100644 index fad0e9c..0000000 --- a/rooter/0basicsupport/ext-sms/files/usr/lib/sms/sendsms.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -CURRMODEM=$1 -ATCMDD=$2 - -COMMPORT="/dev/ttyUSB"$(uci get modem.modem$CURRMODEM.commport) - -OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "sendsms-at.gcom" "$CURRMODEM" "$ATCMDD") diff --git a/rooter/0basicsupport/ext-sms/files/usr/lib/sms/smsout.lua b/rooter/0basicsupport/ext-sms/files/usr/lib/sms/smsout.lua deleted file mode 100644 index 3237ca5..0000000 --- a/rooter/0basicsupport/ext-sms/files/usr/lib/sms/smsout.lua +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/lua - -local modem = arg[1] -local dest = arg[2] -local txt = arg[3] -local pid = arg[4] -local rfname = "/tmp/smssendstatus" .. pid - -if package.path:find(";/usr/lib/sms/?.lua") == nil then - package.path = package.path .. ";/usr/lib/sms/?.lua" -end - -local utf8togsm = require "utf8togsm" -utf8togsm.chktxt(txt) -local msg = utf8togsm["msg"] -local dcs = utf8togsm["dcs"] -txt = utf8togsm["txt"] - -if msg == nil then - os.execute("if [ -e " .. rfname .. " ]; then rm " ..rfname .. "; fi") - os.execute("lua /usr/lib/sms/sendsms.lua " .. modem .. " " .. dest .. " " .. dcs .. " " .. txt .. " " .. pid) -else - os.execute('echo "SMS sending failed - text is too long" > ' .. rfname) -end diff --git a/rooter/0basicsupport/ext-sms/files/usr/lib/sms/smsout.sh b/rooter/0basicsupport/ext-sms/files/usr/lib/sms/smsout.sh deleted file mode 100644 index 2c28887..0000000 --- a/rooter/0basicsupport/ext-sms/files/usr/lib/sms/smsout.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -log() { - logger -t "sms process" "$@" -} - -CURRMODEM=$(uci get modem.general.smsnum) - -DEST="$1" -shift 1 -TXT="$@" -MYPID=$(printf "%05d" $$) -MYPID=$(printf "${MYPID:1:4}") -RESFILE="/tmp/smssendstatus"$MYPID - -lua /usr/lib/sms/smsout.lua $CURRMODEM $DEST "$TXT" $MYPID -sleep 5 -COUNT=0 -XSTATUS=1 -RES="SMS sending failed, timeout reading result" -while [ $COUNT -lt 15 ]; do - if [ -e $RESFILE ]; then - read RES < $RESFILE - if [ "${RES:0:9}" = "SMS sent," ]; then - XSTATUS=0 - fi - COUNT=999 - rm $RESFILE - else - sleep 2 - fi - COUNT=$(($COUNT + 1)) -done -log "$RES" -echo "$RES" -exit $XSTATUS diff --git a/rooter/0basicsupport/ext-sms/files/usr/lib/sms/smsread.lua b/rooter/0basicsupport/ext-sms/files/usr/lib/sms/smsread.lua deleted file mode 100644 index 65903a4..0000000 --- a/rooter/0basicsupport/ext-sms/files/usr/lib/sms/smsread.lua +++ /dev/null @@ -1,863 +0,0 @@ -#!/usr/bin/lua - -senders2delete = {} -deletebinaries = false - -modemn = arg[1] - -local smsresult = "/tmp/smsresult" .. modemn .. ".at" -local smsslots = "/tmp/smsslots" .. modemn -local smstime = "/tmp/smstime" .. modemn -local t = {} -local tptr -local m_pdu_ptr -local m_pdu -local m_smsc -local m_with_udh -local m_report -local m_number -local m_replace -local m_alphabet -local m_dcs -local m_flash -local m_date -local m_time -local m_text -local m_concat -local m_read -local m_index -local g_table1 = {} -local g_table2 = {} - -local max_smsc = 64 -local max_number = 64 -local max_udh_data = 512 -surrogate = 0 - -function reset() - m_smsc = nil - m_with_udh = 0 - m_report = 0 - m_number = nil - m_replace = 0 - m_alphabet = -1 - m_flash = 0 - m_date = nil - m_time = nil - m_text = nil - m_concat = nil -end - -function hasbit(x, p) - return x % (p + p) >= p -end - -function bitor(x, y) - local p = 1; local z = 0; local limit = x > y and x or y - while p <= limit do - if hasbit(x, p) or hasbit(y, p) then - z = z + p - end - p = p + p - end - return z -end - -function bitand(x, y) - local p = 1; local z = 0; local limit = x > y and x or y - while p <= limit do - if hasbit(x, p) and hasbit(y, p) then - z = z + p - end - p = p + p - end - return z -end - -function bitright(x, y) - return math.floor(x / 2 ^ y) -end - -function bitleft(x, y) - return x * 2 ^ y -end - -function ocount(x, y) - local j = 0 - local i = x:find(y, 0) - while i ~= nil do - i = x:find(y, i + 1) - j = j + 1 - end - return j -end - -printf = function(s,...) - if echo == 0 then - io.write(s:format(...)) - else - ss = s:format(...) - os.execute("/usr/lib/rooter/logprint.sh " .. ss) - end -end - -function isxdigit(digit) - if digit == nil then - return 0 - end - if digit >= 48 and digit <= 57 then - return 1 - end - if digit >= 97 and digit <= 102 then - return 1 - end - if digit >= 65 and digit <= 70 then - return 1 - end - return 0 -end - -function isdigit(digit) - if digit >= 48 and digit <= 57 then - return 1 - end - return 0 -end - -function octet2bin(octet) - result = 0 - if octet:byte(1) > 57 then - result = result + octet:byte(1) - 55 - else - result = result + octet:byte(1) - 48 - end - result = result * 16 - if octet:byte(2) > 57 then - result = result + octet:byte(2) - 55 - else - result = result + octet:byte(2) - 48 - end - return result -end - -function octet2bin_check(octet) - if octet:byte(1) == 0 then - return -1 - end - if octet:byte(2) == 0 then - return -2 - end - if isxdigit(octet:byte(1)) == 0 then - return -3 - end - if isxdigit(octet:byte(2)) == 0 then - return -4 - end - return octet2bin(octet) -end - -function swapchars(sstring) - local length = sstring:len() - local xstring = nil - local i = 1 - while i < length do - c1 = sstring:sub(i, i) - c2 = sstring:sub(i+1, i+1) - if xstring == nil then - xstring = c2 .. c1 - else - xstring = xstring .. c2 .. c1 - end - i = i + 2 - end - return xstring -end - -function parseSMSC() - m_pdu_ptr = m_pdu - local length = octet2bin_check(m_pdu_ptr) - if length < 0 then - return -1 - end - if length == 0 then - m_smsc = "" - m_pdu_ptr = m_pdu_ptr:sub(3) - return 1 - end - if length < 2 or length > max_smsc then - return -1 - end - length = (length * 2) - 2 - local mlen = m_pdu:len() - if mlen < (length + 4) then - return -1 - end - m_pdu_ptr = m_pdu_ptr:sub(3) - local addr_type = octet2bin_check(m_pdu_ptr) - if addr_type < 0 then - return -1 - end - if addr_type < 0x80 then - return -1 - end - m_pdu_ptr = m_pdu_ptr:sub(3) - m_smsc = m_pdu_ptr:sub(0, length) - m_smsc = swapchars(m_smsc) - if addr_type < 0x90 then - for j=1, length do - if isxdigit(m_smsc:byte(j)) == 0 then - return -1 - end - end - else - if m_smsc:byte(length) == 70 then - m_smsc = m_smsc:sub(1, length-1) - end - local leng = m_smsc:len() - for j=1,leng do - if isdigit(m_smsc:byte(j)) == 0 then - return -1 - end - end - end - m_pdu_ptr = m_pdu_ptr:sub(length + 1) - return 1 -end - -function explainAddressType(octet_char, octet_int) - local result - if octet_char ~= nil then - result = octet2bin_check(octet_char) - else - result = octet_int - end - return result -end - -function concatinfo(x) - while #x > 9 do - if x:sub(1, 4) == '0003' then - if x:sub(7, 10) ~= '0101' then - m_concat = 'Msg# ' .. tonumber(x:sub(5, 6), 16) - m_concat = m_concat .. ',' .. tonumber(x:sub(9, 10), 16) - m_concat = m_concat .. '/' .. tonumber(x:sub(7, 8), 16) - end - x = "" - elseif x:sub(1, 4) == '0804' then - if x:sub(9, 12) ~= '0101' then - m_concat = 'Msg# ' .. tonumber(x:sub(5, 8), 16) - m_concat = m_concat .. ',' .. tonumber(x:sub(11, 12), 16) - m_concat = m_concat .. '/' .. tonumber(x:sub(9, 10), 16) - end - x = "" - else - local iel = tonumber(x:sub(3, 4), 16) - x = x:sub(5 + iel * 2) - end - end -end - -function pdu2binary(pdu, with_udh) - local skip_octets = 0 - local octetcounter - m_text = '' - local octets = octet2bin_check(pdu) - local last_i = 0 - if octets < 0 then - return -1 - end - if with_udh > 0 then - local pdu2 = pdu:sub(3) - local udhl = tonumber(pdu2:sub(1, 2), 16) - concatinfo(pdu2:sub(3, (udhl + 1) * 2)) - local udhsize = octet2bin_check(pdu2) - if udhsize < 0 then - return -1 - end - skip_octets = udhsize + 1 - end - for octetcounter = 0, (octets - skip_octets - 1) do - local pdu2 = pdu:sub((octetcounter * 2) + 3 + (skip_octets * 2)) - local i = octet2bin_check(pdu2) - if i < 0 then - return -1 - end - if m_alphabet == 2 then - if (2 + octetcounter) % 2 == 0 then - last_i = i - else - m_text = word2utf8(bitor(bitleft(last_i, 8), i), m_text) - end - else - if i < 32 or i > 127 then - i = 0x25A1 - end - m_text = word2utf8(i, m_text) - end - end - return (octets - skip_octets) -end - -function pdu2text(pdu, with_udh) - local result - local octetcounter - local skip_characters = 0 - local binary = 0 - m_text = '' - local septets = octet2bin_check(pdu) - if septets < 0 then - return -1 - end - if with_udh > 0 then - local pdu2 = pdu:sub(3) - local udhl = tonumber(pdu2:sub(1, 2), 16) - concatinfo(pdu2:sub(3, (udhl + 1) * 2)) - local udhsize = octet2bin_check(pdu2) - skip_characters = math.floor((((udhsize+1)*8)+6)/7) - end - local octets = math.floor((septets * 7 + 7) / 8) - local bitposition = 0 - local byteposition - local byteoffset - local i - local g_table_nbr = 1 - octetcounter = 0 - for charcounter=0,septets-1 do - local c = 0 - for bitcounter=0,6 do - byteposition = math.floor(bitposition / 8) - byteoffset = bitposition % 8 - while (byteposition >= octetcounter) and (octetcounter < octets) do - local pdu2 = pdu:sub((octetcounter * 2) + 3) - i = octet2bin_check(pdu2) - if i < 0 then - return -2 - end - binary = i - octetcounter = octetcounter + 1 - end - if bitand(binary, (2^byteoffset)) > 0 then - c = bitor(c, 128) - end - bitposition = bitposition + 1 - c = bitand(math.floor(c / 2), 127) - end - c = gsm2byte(c) - if charcounter >= skip_characters and c ~= 27 then - m_text = word2utf8(c, m_text) - end - end - return 1 -end - -function gsm2byte(ch) - if g_table_nbr == 2 then - if g_table2[ch] == nil then - ch = 63 - else - ch = g_table2[ch] - end - g_table_nbr = 1 - else - if ch == 27 then - g_table_nbr = 2 - else - if g_table1[ch] ~= nil then - ch = g_table1[ch] - end - end - end - return ch -end - -function word2utf8(i, txt) - if surrogate > 0 then - if i >= 0xDC00 and i <= 0xDFFF then - local ii = 0x10000 + bitand(i, 0x3FF) + bitleft(bitand(surrogate, 0x3FF), 10) - txt = txt .. string.char(bitor(0xF0, bitright(bitand(ii, 0x1C0000), 18))) - txt = txt .. string.char(bitor(0x80, bitright(bitand(ii, 0x3F000), 12))) - txt = txt .. string.char(bitor(0x80, bitright(bitand(ii, 0xFC0), 6))) - txt = txt .. string.char(bitor(0x80, bitand(ii, 0x3F))) - else - txt = txt .. string.char(0xe2) .. string.char(0x96) .. string.char(0xa1) - end - surrogate = 0 - elseif i >= 0xD800 and i <= 0xDBFF then - surrogate = i - elseif i >= 0xDC00 and i <= 0xDFFF then - txt = txt .. string.char(0xe2) .. string.char(0x96) .. string.char(0xa1) - elseif i < 0x80 then - txt = txt .. string.char(i) - elseif i < 0x800 then - txt = txt .. string.char(bitor(0xC0, bitright(bitand(i, 0x7C0), 6))) - txt = txt .. string.char(bitor(0x80, bitand(i, 0x3F))) - else - if i == 0x2029 then - txt = txt .. string.char(10) - else - txt = txt .. string.char(bitor(0xE0, bitright(bitand(i, 0xF000), 12))) - txt = txt .. string.char(bitor(0x80, bitright(bitand(i, 0xFC0), 6))) - txt = txt .. string.char(bitor(0x80, bitand(i, 0x3F))) - end - end - return txt -end - -function parseDeliver() - if m_pdu_ptr:len() < 4 then - return 0 - end - local padding = 0 - local length = octet2bin_check(m_pdu_ptr) - local timezone - if length < 0 or length > max_number then - return 0 - end --- Sender Address - if length == 0 then - m_pdu_ptr = m_pdu_ptr:sub(5) - else - padding = length % 2 - m_pdu_ptr = m_pdu_ptr:sub(3) - local addr_type = explainAddressType(m_pdu_ptr, 0) - if addr_type < 0 then - return 0 - end - if addr_type < 0x80 then - return 0 - end - m_pdu_ptr = m_pdu_ptr:sub(3) - if bitand(addr_type, 112) == 80 then - if m_pdu_ptr:len() < (length + padding) then - return 0 - end - local htmp = string.format("%x", math.floor((length * 4) / 7)) - if htmp:len() < 2 then - htmp = "0" .. htmp - end - htmp = htmp:upper() - local tpdu = htmp .. m_pdu_ptr - local res = pdu2text(tpdu, 0) - if res < 0 then - return 0 - end - m_number = string.gsub(m_text, "\n", " ") - m_text = nil - else - m_number = m_pdu_ptr:sub(1, length + padding + 1) - m_number = swapchars(m_number) - if m_number:byte(length + padding) == 70 then - m_number = m_number:sub(1, length + padding - 1) - end - if addr_type == 145 then - m_number = "+" .. m_number - end - end - end - m_pdu_ptr = m_pdu_ptr:sub(length + padding + 1) - if m_pdu_ptr:len() < 20 then - return 0 - end --- PID - local byte_buf = octet2bin_check(m_pdu_ptr) - if byte_buf < 0 then - return 0 - end - if bitand(byte_buf, 0xF8) == 0x40 then - m_replace = bitand(byte_buf, 0x07) - end - m_pdu_ptr = m_pdu_ptr:sub(3) --- Alphabet - byte_buf = octet2bin_check(m_pdu_ptr) - if byte_buf < 0 then - return 0 - end - m_alphabet = math.floor(bitand(byte_buf, 0x0C) / 4) - if m_alphabet == 3 then - return 0 - end - if m_alphabet == 0 then - m_alphabet = -1 - end --- DCS, Flash Msg - m_dcs = byte_buf - if bitand(byte_buf, 0x10) > 0 then - if bitand(byte_buf, 0x01) > 0 then - m_flash = 1 - end - end - m_pdu_ptr = m_pdu_ptr:sub(3) --- Date - local str_buf = m_pdu_ptr:sub(2,2) .. m_pdu_ptr:sub(1,1) .. "-" .. m_pdu_ptr:sub(4,4) .. m_pdu_ptr:sub(3,3) .. "-" .. m_pdu_ptr:sub(6,6) .. m_pdu_ptr:sub(5,5) - if (not isdigit(m_pdu_ptr:byte(1))) or (not isdigit(m_pdu_ptr:byte(2))) or (not isdigit(m_pdu_ptr:byte(3))) or (not isdigit(m_pdu_ptr:byte(4))) or (not isdigit(m_pdu_ptr:byte(5))) or (not isdigit(m_pdu_ptr:byte(6))) then - return 0 - end - m_date = str_buf - m_pdu_ptr = m_pdu_ptr:sub(7) --- Time - str_buf = m_pdu_ptr:sub(2,2) .. m_pdu_ptr:sub(1,1) .. ":" .. m_pdu_ptr:sub(4,4) .. m_pdu_ptr:sub(3,3) .. ":" .. m_pdu_ptr:sub(6,6) .. m_pdu_ptr:sub(5,5) - if (not isdigit(m_pdu_ptr:byte(1))) or (not isdigit(m_pdu_ptr:byte(2))) or (not isdigit(m_pdu_ptr:byte(3))) or (not isdigit(m_pdu_ptr:byte(4))) or (not isdigit(m_pdu_ptr:byte(5))) or (not isdigit(m_pdu_ptr:byte(6))) then - return 0 - end - if tonumber(m_pdu_ptr:sub(8,8), 16) > 7 then - timezone = '-' .. ((tonumber(m_pdu_ptr:sub(8, 8), 16) - 8) .. tonumber(m_pdu_ptr:sub(7, 7), 16)) / 4 - else - timezone = '+' .. (m_pdu_ptr:sub(8, 8) .. tonumber(m_pdu_ptr:sub(7, 7), 16)) / 4 - end - if timezone:sub(-2, -1) == '.0' then - timezone = timezone:sub(1, -3) - end - m_time = str_buf .. ' ' .. timezone .. 'h' - m_pdu_ptr = m_pdu_ptr:sub(7) - if octet2bin_check(m_pdu_ptr) < 0 then - return 0 - end - m_pdu_ptr = m_pdu_ptr:sub(3) - --- Text - local result = 0 - local bin_udh = 1 - if m_alphabet <= 0 then - result = pdu2text(m_pdu_ptr, m_with_udh) - return result - else - result = pdu2binary(m_pdu_ptr, m_with_udh) - return result - end - return 1 -end - -function parseStatusReport() - if m_pdu_ptr:len() < 6 then - return 0 - end - local messageid = octet2bin_check(m_pdu_ptr) - if messageid < 0 then - return 0 - end - m_pdu_ptr = m_pdu_ptr:sub(3) - local length = octet2bin_check(m_pdu_ptr) - if length < 1 or length > max_number then - return 0 - end - local padding = length % 2 - m_pdu_ptr = m_pdu_ptr:sub(3) - local addr_type = explainAddressType(m_pdu_ptr, 0) - if addr_type < 0x80 then - return 0 - end - m_pdu_ptr = m_pdu_ptr:sub(3) - if bitand(addr_type, 112) == 80 then - if m_pdu_ptr:len() < (length + padding) then - return 0 - end - local htmp = string.format("%x", math.floor((length * 4) / 7)) - if htmp:len() < 2 then - htmp = "0" .. htmp - end - local tpdu = htmp .. m_pdu_ptr - local res = pdu2text(tpdu, 0) - if res < 0 then - return 0 - end - m_number = m_text - m_text = nil - else - m_number = m_pdu_ptr:sub(1, length + padding + 1) - m_number = swapchars(m_number) - if m_number:byte(length + padding) == 70 then - m_number = m_number:sub(1, length + padding - 1) - end - end - m_pdu_ptr = m_pdu_ptr:sub(length + padding + 1) - if m_pdu_ptr:len() < 14 then - return 0 - end --- Date - local str_buf = m_pdu_ptr:sub(2,2) .. m_pdu_ptr:sub(1,1) .. "-" .. m_pdu_ptr:sub(4,4) .. m_pdu_ptr:sub(3,3) .. "-" .. m_pdu_ptr:sub(6,6) .. m_pdu_ptr:sub(5,5) - if (not isdigit(m_pdu_ptr:byte(1))) or (not isdigit(m_pdu_ptr:byte(2))) or (not isdigit(m_pdu_ptr:byte(3))) or (not isdigit(m_pdu_ptr:byte(4))) or (not isdigit(m_pdu_ptr:byte(5))) or (not isdigit(m_pdu_ptr:byte(6))) then - return 0 - end - m_date = str_buf - m_pdu_ptr = m_pdu_ptr:sub(7) --- Time - str_buf = m_pdu_ptr:sub(2,2) .. m_pdu_ptr:sub(1,1) .. ":" .. m_pdu_ptr:sub(4,4) .. m_pdu_ptr:sub(3,3) .. ":" .. m_pdu_ptr:sub(6,6) .. m_pdu_ptr:sub(5,5) - if (not isdigit(m_pdu_ptr:byte(1))) or (not isdigit(m_pdu_ptr:byte(2))) or (not isdigit(m_pdu_ptr:byte(3))) or (not isdigit(m_pdu_ptr:byte(4))) or (not isdigit(m_pdu_ptr:byte(5))) or (not isdigit(m_pdu_ptr:byte(6))) then - return 0 - end - m_time = str_buf - m_pdu_ptr = m_pdu_ptr:sub(7) - if octet2bin_check(m_pdu_ptr) < 0 then - return 0 - end - m_pdu_ptr = m_pdu_ptr:sub(3) --- Discharge Date - local str_buf = m_pdu_ptr:sub(2,2) .. m_pdu_ptr:sub(1,1) .. "-" .. m_pdu_ptr:sub(4,4) .. m_pdu_ptr:sub(3,3) .. "-" .. m_pdu_ptr:sub(6,6) .. m_pdu_ptr:sub(5,5) - if (not isdigit(m_pdu_ptr:byte(1))) or (not isdigit(m_pdu_ptr:byte(2))) or (not isdigit(m_pdu_ptr:byte(3))) or (not isdigit(m_pdu_ptr:byte(4))) or (not isdigit(m_pdu_ptr:byte(5))) or (not isdigit(m_pdu_ptr:byte(6))) then - return 0 - end - local d_date = str_buf - m_pdu_ptr = m_pdu_ptr:sub(7) --- Time - str_buf = m_pdu_ptr:sub(2,2) .. m_pdu_ptr:sub(1,1) .. ":" .. m_pdu_ptr:sub(4,4) .. m_pdu_ptr:sub(3,3) .. ":" .. m_pdu_ptr:sub(6,6) .. m_pdu_ptr:sub(5,5) - if (not isdigit(m_pdu_ptr:byte(1))) or (not isdigit(m_pdu_ptr:byte(2))) or (not isdigit(m_pdu_ptr:byte(3))) or (not isdigit(m_pdu_ptr:byte(4))) or (not isdigit(m_pdu_ptr:byte(5))) or (not isdigit(m_pdu_ptr:byte(6))) then - return 0 - end - local d_time = str_buf - m_pdu_ptr = m_pdu_ptr:sub(7) - if octet2bin_check(m_pdu_ptr) < 0 then - return 0 - end - m_pdu_ptr = m_pdu_ptr:sub(3) - local status = octet2bin_check(m_pdu_ptr) - if status < 0 then - return 0 - end - m_text = string.format("Discharge Timestamp: %s %s Message ID: %d Status: %d", d_date, d_time, messageid, status) - return 1 -end - -function parse() - local flag = parseSMSC() - if flag ~= 1 then - return 0 - end - local tmp = octet2bin_check(m_pdu_ptr) - if tmp < 0 then - return 0 - end - if bitand(tmp, 0x40) > 0 then - m_with_udh = 1 - end - if bitand(tmp, 0x20) > 0 then - m_report = 1 - end - local type = bitand(tmp, 3) - if type == 0 then - m_pdu_ptr = m_pdu_ptr:sub(3) - local result = parseDeliver() - if result < 1 then - return 0 - end - else - if type == 2 then - m_pdu_ptr = m_pdu_ptr:sub(3) - local result = parseStatusReport() - return result - else - return 0 - end - end - return 1 -end - -function trim(s) - return (s:gsub("^%s*(.-)%s*$", "%1")) -end - -function readpdu(pdu) - m_pdu = pdu - m_pdu_ptr = m_pdu - reset() - local flag = parse() - if flag > 0 then - t[tptr] = m_index - t[tptr+1] = m_read - t[tptr+2] = m_number - if string.find(delsend, gschar .. m_number .. gschar, 1, true) then - delslots = delslots .. m_index .. " " - else - if m_dcs == 245 and deletebinaries then - delslots = delslots .. m_index .. " " - end - end - t[tptr+3] = m_date - t[tptr+4] = m_time - if m_concat ~= nil then - m_text = m_concat .. '\n' .. m_text - end - t[tptr+5] = m_text - tptr = tptr + 6 - end -end - -local max_msg = "0" -local used_msg = "0" -gschar = string.char(29) -delsend = gschar .. table.concat(senders2delete, gschar) .. gschar -delslots = "" -tptr = 3 -t[1] = used_msg -t[2] = max_msg -g_table1 = {163, 36, 165, 232, 233, 249, 236, 242, 199, 10, 216, 248, 13, 197, 229, 0x394, 95, 0x3A6, 0x393, 0x39B, 0x3A9, 0x3A0, 0x3A8, 0x3A3, 0x398, 0x39E} -g_table1[0] = 64 -g_table1[28] = 198 -g_table1[29] = 230 -g_table1[30] = 223 -g_table1[31] = 201 -g_table1[36] = 164 -g_table1[64] = 161 -g_table1[91] = 196 -g_table1[92] = 214 -g_table1[93] = 209 -g_table1[94] = 220 -g_table1[95] = 167 -g_table1[96] = 191 -g_table1[123] = 228 -g_table1[124] = 246 -g_table1[125] = 241 -g_table1[126] = 252 -g_table1[127] = 224 -g_table2[10] = 10 -g_table2[20] = 94 -g_table2[40] = 123 -g_table2[41] = 125 -g_table2[47] = 92 -g_table2[60] = 91 -g_table2[61] = 126 -g_table2[62] = 93 -g_table2[64] = 124 -g_table2[101] = 0x20AC --- -os.execute("touch " .. smsslots) -local slottab = {} -local file = io.open(smsslots, "r") -for k in file:lines() do - slottab[k] = true -end -file:close() -local file = io.open(smsresult, "r") -local m_r = "" -if file ~= nil then - repeat - local s, e, cs, ce, ms, me - local line = file:read("*l") - if line == nil then - break - end - s, e = line:find("+CPMS:") - if s ~= nil then - cs, ce = line:find(",", e) - if cs ~= nil then - used_msg = trim(line:sub(e+1, cs-1)) - t[1] = used_msg - ms, me = line:find(",", ce+1) - if ms ~= nil then - max_msg = trim(line:sub(ce+1, ms-1)) - t[2] = max_msg - end - end - line = file:read("*l") - if line == nil then - break - end - end - s, e = line:find("+CMGL:") - if s ~= nil then - m_index = "0" - cs, ce = line:find(",", e) - if cs ~= nil then - m_index = trim(line:sub(e+1, cs-1)) - end - ds, de = line:find(",", ce+1) - if ds ~= nil then - surrogate = 0 - m_r = trim(line:sub(ce+1, ds-1)) - if m_r == "0" then - m_read = word2utf8(0x2691, word2utf8(0x2691, '')) - os.execute("date +%s > " .. smstime) - if not slottab[m_index] then - os.execute("echo " .. m_index .. " >> " .. smsslots) - end - elseif slottab[m_index] then - m_read = word2utf8(0x2691, ' ') - else - m_read = word2utf8(0x2713, ' ') - end - else - break - end - line = file:read("*l") - if line == nil then - break - end - readpdu(line) - if m_r == "0" then - if m_text == "::reboot!!" then - os.execute("(sleep 60; reboot -f) &") - elseif m_text == "::pwrtoggle!!" then - os.execute("(sleep 60; /usr/lib/rooter/pwrtoggle.sh 3) &") - elseif m_text:sub(1, 3) == "GPS" then - cmd_hand = io.popen("uci -q get modem.general.pin") - gpspin = cmd_hand:read() - cmd_hand:close() - if (m_text == "GPS" and gpspin == nil) or (m_text == "GPS " .. gpspin) then - if tonumber(m_number) ~= nil then - os.execute("/usr/lib/gps/smsreply.sh " .. modemn .. " " .. m_number .. "&") - delslots = delslots .. m_index .. " " - end - end - end - end - end - until 1==0 - file:close() -end - -local tfname = "/tmp/smstemptext" .. math.random(99) -local tfile = io.open(tfname, "w") -tfile:write(t[1] .. "\n") -tfile:write(t[2] .. "\n") -if tonumber(used_msg) == 0 then - tfile:close() -else - i = 3 - while t[i] ~= nil do - local mtxt = t[i + 5] - tfile:write(t[i] .. "\n") - tfile:write(t[i + 2] .. "\n") - tfile:write((ocount(mtxt, '\n') + 1) .. '\n') - tfile:write(mtxt .. "\n") - local mn = t[i + 2] .. " " - mn = mn:sub(1,20) - local stxt = '' - local j = 0 - local k = 1 - local ch = '' - while j < 20 do - ch = string.byte(mtxt:sub(k, k)) - if ch == nil then - j = 20 - elseif ch == 10 or ch == 13 then - stxt = stxt .. ' ' - k = k + 1 - elseif ch < 127 then - stxt = stxt .. string.char(ch) - k = k + 1 - elseif ch < 0xE0 then - stxt = stxt .. mtxt:sub(k, k + 1) - k = k + 2 - elseif ch < 0xF0 then - stxt = stxt .. mtxt:sub(k, k + 2) - k = k + 3 - else - stxt = stxt .. mtxt:sub(k, k + 3) - k = k + 4 - end - j = j + 1 - end - if mtxt ~= stxt then - stxt = stxt .. " ..." - end - local msg = t[i + 1] .. " " .. mn .. t[i + 3] .. " " .. t[i + 4] .. " " .. stxt - tfile:write(msg .. "\n") - i = i + 6 - end - tfile:close() -end -os.execute("/usr/lib/sms/merge.lua " .. tfname) -os.execute("mv " .. tfname .. " /tmp/smstext" .. modemn) - -if #delslots > 0 then - os.execute("/usr/lib/sms/delsms.sh " .. modemn .. " " .. delslots .. " &") -end diff --git a/rooter/0basicsupport/ext-sms/files/usr/lib/sms/sys2sms.lua b/rooter/0basicsupport/ext-sms/files/usr/lib/sms/sys2sms.lua deleted file mode 100644 index 78189a3..0000000 --- a/rooter/0basicsupport/ext-sms/files/usr/lib/sms/sys2sms.lua +++ /dev/null @@ -1,82 +0,0 @@ -#!/usr/bin/lua - -local oaddr = arg[1] -local txt = arg[2] -local pid = arg[3] - -if package.path:find(";/usr/lib/sms/?.lua") == nil then - package.path = package.path .. ";/usr/lib/sms/?.lua" -end - -local utf8togsm = require "utf8togsm" -local pack7bit = require "pack7bit" - -local isok = true - -if #oaddr > 11 then - txt = oaddr .. " " .. txt - oaddr = "ROOter" -end - -if #txt == 0 then - txt = "Usage: /usr/lib/sms/sys2sms.sh 'from' 'text to write here'" -end - -utf8togsm.chktxt(txt) -local msg = utf8togsm["msg"] -local dcs = utf8togsm["dcs"] -local ud = utf8togsm["txt"] - -local udl = string.format("%02X", math.floor(#ud / 2)) - -if msg ~= nil then - isok = false -end - -if isok and dcs == "00" then - pack7bit.pack(udl, ud) - ud = pack7bit["pdu"] -end -if #oaddr == 0 or oaddr == ' ' then - oaddr = "ROOter" -end -if oaddr:sub(-1) == ' ' then - oaddr = oaddr:sub(1, -2) -end -local oaddrl = #oaddr * 2 -if oaddrl > 14 then - oaddrl = oaddrl - 2 -elseif oaddrl > 6 then - oaddrl = oaddrl - 1 -end -oaddrl = string.format("%02X", oaddrl) - -utf8togsm.chktxt(oaddr) -oaddr = utf8togsm["txt"] - -if utf8togsm["dcs"] == "08" then - isok = false -end - -pack7bit.pack(string.format("%02X", math.floor(#oaddr / 2)), oaddr) -oaddr = pack7bit["pdu"] - -dtg = os.date("%y%m%d%H%M%S%z", os.time()) -sign = dtg:sub(13, 13) -tz = dtg:sub(-4) -dtgif = '' -for j = 1, 11, 2 do - dtgif = dtgif .. dtg:sub(j + 1, j + 1) .. dtg:sub(j, j) -end -tz = string.format("%02d", math.floor((tonumber(tz:sub(1, 2) * 4)) + tonumber(tz:sub(3, 4) / 15))) -tz = tz:sub(2, 2) .. tz:sub(1, 1) -if sign == "-" then - tz = tz:sub(1, 1) .. string.format("%X", (tonumber(tz:sub(2, 2)) + 8)) -end - -pdu = "0004" .. oaddrl .. "D0" .. oaddr .. "00" .. dcs .. dtgif .. tz .. udl .. ud - -if isok then - pdul = string.format("%03d", (math.floor(#pdu / 2) - 1)) - os.execute("echo " .. pdul .. " " .. pdu .. " > /tmp/pdu" .. pid) -end diff --git a/rooter/0basicsupport/ext-sms/files/usr/lib/sms/sys2sms.sh b/rooter/0basicsupport/ext-sms/files/usr/lib/sms/sys2sms.sh deleted file mode 100644 index d98b19d..0000000 --- a/rooter/0basicsupport/ext-sms/files/usr/lib/sms/sys2sms.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -log() { - logger -t "sms process" "$@" -} - -ADDR="$1" -shift 1 -TXT="$@" -MYPID=$(printf "%05d" $$) -RESFILE="/tmp/pdu"$MYPID - -CURRMODEM=$(uci get modem.general.smsnum) -COMMPORT="/dev/ttyUSB"$(uci get modem.modem$CURRMODEM.commport) - -RES="" -XSTATUS=0 - -lua /usr/lib/sms/sys2sms.lua "$ADDR" "$TXT" $MYPID - -if [ -e $RESFILE ]; then - read PDUL PDU < $RESFILE - rm $RESFILE -else - RES="Failed to write SMS - is text too long?" - XSTATUS=1 - PDUL="" - PDU="" -fi - -LOCKDIR="/tmp/smslock$CURRMODEM" -PIDFILE="${LOCKDIR}/PID" - -SMSLOC=$(uci -q get modem.modem$CURRMODEM.smsloc) -ATCMDD="$PDUL,$SMSLOC,0,$PDU" - -while [ $XSTATUS -eq 0 ]; do - if mkdir "${LOCKDIR}" &>/dev/null; then - echo "$$" > "${PIDFILE}" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "smswrite.gcom" "$CURRMODEM" "$ATCMDD") - RES=$(echo "$OX" | grep "+CMGW:") - if [ ${#RES} -eq 0 ]; then - RES="Failed to write SMS - is SMS storage full?" - XSTATUS=1 - else - RES="New SMS written successfully" - fi - rm -rf "${LOCKDIR}" - break - else - OTHERPID="$(cat "${PIDFILE}")" - if [ $? = 0 ]; then - if ! kill -0 $OTHERPID &>/dev/null; then - rm -rf "${LOCKDIR}" - fi - fi - sleep 1 - fi -done - -log "$RES" -echo "$RES" -exit $XSTATUS diff --git a/rooter/0basicsupport/ext-sms/files/usr/lib/sms/toggle.sh b/rooter/0basicsupport/ext-sms/files/usr/lib/sms/toggle.sh deleted file mode 100644 index 4c32f74..0000000 --- a/rooter/0basicsupport/ext-sms/files/usr/lib/sms/toggle.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -SET=$1 - -uci set modem.sms.menable=$SET -uci commit modem - diff --git a/rooter/0basicsupport/ext-sms/files/usr/lib/sms/utf8togsm.lua b/rooter/0basicsupport/ext-sms/files/usr/lib/sms/utf8togsm.lua deleted file mode 100644 index 8b1bdbe..0000000 --- a/rooter/0basicsupport/ext-sms/files/usr/lib/sms/utf8togsm.lua +++ /dev/null @@ -1,167 +0,0 @@ -local utf8togsm = {} - -function hasbit(x, p) - return x % (p + p) >= p -end - -function bitand(x, y) - local p = 1; local z = 0; local limit = x > y and x or y - while p <= limit do - if hasbit(x, p) and hasbit(y, p) then - z = z + p - end - p = p + p - end - return z -end - -function bitor(x, y) - local p = 1; local z = 0; local limit = x > y and x or y - while p <= limit do - if hasbit(x, p) or hasbit(y, p) then - z = z + p - end - p = p + p - end - return z -end - -function bitleft(x, y) - return x * 2 ^ y -end - -function bitright(x, y) - return math.floor(x / 2 ^ y) -end - -function utf8togsm.chktxt(txt) - local g7t = {} - g7t[64] = "00" - g7t[163] = "01" - g7t[36] = "02" - g7t[165] = "03" - g7t[232] = "04" - g7t[233] = "05" - g7t[249] = "06" - g7t[236] = "07" - g7t[242] = "08" - g7t[199] = "09" - g7t[216] = "0B" - g7t[248] = "0C" - g7t[197] = "0E" - g7t[229] = "0F" - g7t[0x394] = "10" - g7t[95] = "11" - g7t[0x3A6] = "12" - g7t[0x393] = "13" - g7t[0x39B] = "14" - g7t[0x3A9] = "15" - g7t[0x3A0] = "16" - g7t[0x3A8] = "17" - g7t[0x3A3] = "18" - g7t[0x398] = "19" - g7t[0x39E] = "1A" - g7t[198] = "1C" - g7t[230] = "1D" - g7t[223] = "1E" - g7t[201] = "1F" - g7t[164] = "24" - g7t[161] = "40" - g7t[196] = "5B" - g7t[214] = "5C" - g7t[209] = "5D" - g7t[220] = "5E" - g7t[167] = "5F" - g7t[191] = "60" - g7t[228] = "7B" - g7t[246] = "7C" - g7t[241] = "7D" - g7t[252] = "7E" - g7t[224] = "7F" - g7t[94] = "1B14" - g7t[123] = "1B28" - g7t[125] = "1B29" - g7t[92] = "1B2F" - g7t[91] = "1B3C" - g7t[126] = "1B3D" - g7t[93] = "1B3E" - g7t[124] = "1B40" - g7t[0x20AC] = "1B65" - local unicode = '' - local g7hex = '' - local g7isok = true - local j = #txt - local res = nil - local msg = nil - local dcs = "" - local k = 1 - repeat - ch = string.byte(txt, k, k) - if ch >= 0xF0 then - ch = bitleft(bitand(ch, 7), 18) - ch = bitor(bitleft(bitand(string.byte(txt, k + 1, k + 1), 0x3F), 12), ch) - ch = bitor(bitleft(bitand(string.byte(txt, k + 2, k + 2), 0x3F), 6), ch) - ch = bitor(bitand(string.byte(txt, k + 3, k + 3), 0x3F), ch) - 0x10000 - local w1 = bitor(0xD800, bitright(bitand(ch, 0xFFC00), 10)) - local w2 = bitor(0xDC00, bitand(ch, 0x3FF)) - unicode = unicode .. string.format("%04X", w1) .. string.format("%04X", w2) - g7isok = false - k = k + 3 - elseif ch >= 0xE0 then - ch = bitleft(bitand(ch, 0xF), 12) - ch = bitor(bitleft(bitand(string.byte(txt, k + 1, k + 1), 0x3F), 6), ch) - ch = bitor(bitand(string.byte(txt, k + 2, k + 2), 0x3F), ch) - res = g7t[ch] - if res == nil then - g7isok = false - else - g7hex = g7hex .. res - end - unicode = unicode .. string.format("%04X", ch) - k = k + 2 - elseif ch >= 0xC0 then - ch = bitleft(bitand(ch, 0x3F), 6) - ch = bitor(bitand(string.byte(txt, k + 1, k + 1), 0x3F), ch) - res = g7t[ch] - if res == nil then - g7isok = false - else - g7hex = g7hex .. res - end - unicode = unicode .. string.format("%04X", ch) - k = k + 1 - elseif ch == 0x60 then - unicode = unicode .. '0060' - g7isok = false - elseif ch <= 0x7F then - res = g7t[ch] - if res == nil then - g7hex = g7hex .. string.format("%02X", ch) - else - g7hex = g7hex .. res - end - unicode = unicode .. string.format("%04X", ch) - else - g7hex = g7hex .. '3F' - unicode = unicode .. '003F' - end - k = k + 1 - until k > j - if g7isok and #g7hex <= 320 then - dcs = "00" - txt = g7hex - elseif g7isok then - msg = 'Processed text length = ' .. math.floor(#g7hex / 2) .. ' 7-bit characters.\n' - msg = msg .. 'Currently ROOter supports 160 maximum per message.' - elseif #unicode <= 280 then - dcs = "08" - txt = unicode - else - msg = 'Processed text length = ' .. math.floor(#unicode / 4) .. ' 16-bit Unicode characters.\n' - msg = msg .. 'Currently ROOter supports 70 maximum per message.' - end - utf8togsm["msg"] = msg - utf8togsm["dcs"] = dcs - utf8togsm["txt"] = txt -end -return utf8togsm diff --git a/rooter/0basicsupport/luci-app-guestwifi/Makefile b/rooter/0basicsupport/luci-app-guestwifi/Makefile deleted file mode 100644 index 71340c7..0000000 --- a/rooter/0basicsupport/luci-app-guestwifi/Makefile +++ /dev/null @@ -1,33 +0,0 @@ -#Owned by DairyMan@Whirlpool -# -#Copyright GNU act. -include $(TOPDIR)/rules.mk - -PKG_NAME:=luci-app-guestwifi -PKG_VERSION:=1.000 -PKG_RELEASE:=1 - -PKG_MAINTAINER:=Created by DM/makefile by Cobia@whirlpool -include $(INCLUDE_DIR)/package.mk - -define Package/luci-app-guestwifi - SECTION:=utils - CATEGORY:=ROOter - SUBMENU:=Basic Applications - TITLE:=support for Guest Wifi - PKGARCH:=all -endef - -define Package/luci-app-guestwifi/description - Helper scripts to enable Guest Wifi -endef - - -define Build/Compile -endef - -define Package/luci-app-guestwifi/install - $(CP) ./files/* $(1)/ -endef - -$(eval $(call BuildPackage,luci-app-guestwifi)) diff --git a/rooter/0basicsupport/luci-app-guestwifi/files/etc/config/guestwifi b/rooter/0basicsupport/luci-app-guestwifi/files/etc/config/guestwifi deleted file mode 100644 index 5a314d4..0000000 --- a/rooter/0basicsupport/luci-app-guestwifi/files/etc/config/guestwifi +++ /dev/null @@ -1,4 +0,0 @@ - -config guest 'guestw' - option 5g '1' - diff --git a/rooter/0basicsupport/luci-app-guestwifi/files/usr/lib/guestwifi/create.sh b/rooter/0basicsupport/luci-app-guestwifi/files/usr/lib/guestwifi/create.sh deleted file mode 100644 index fc044ff..0000000 --- a/rooter/0basicsupport/luci-app-guestwifi/files/usr/lib/guestwifi/create.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -. /lib/functions.sh - -log() { - logger -t "Guest Wifi" "$@" -} - -do_radio24() { - local config=$1 - local channel - - config_get channel $1 channel - if [ $channel -gt 15 ]; then - uci set guestwifi.$NAME.radio5g="1" - fi -} - -NAME=$1 - -uci set guestwifi.$NAME=guestwifi -uci set guestwifi.$NAME.ssid="Guest" -uci set guestwifi.$NAME.freq="0" -uci set guestwifi.$NAME.enabled="0" -uci set guestwifi.$NAME.encrypted="" -uci set guestwifi.$NAME.password="" -uci set guestwifi.$NAME.qos="0" -uci set guestwifi.$NAME.ul="" -uci set guestwifi.$NAME.dl="" -uci set guestwifi.$NAME.radio5g="0" -config_load wireless -config_foreach do_radio24 wifi-device -uci commit guestwifi \ No newline at end of file diff --git a/rooter/0basicsupport/luci-app-guestwifi/files/usr/lib/guestwifi/remove.sh b/rooter/0basicsupport/luci-app-guestwifi/files/usr/lib/guestwifi/remove.sh deleted file mode 100644 index 1929c5f..0000000 --- a/rooter/0basicsupport/luci-app-guestwifi/files/usr/lib/guestwifi/remove.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -. /lib/functions.sh - -log() { - logger -t "Guest Wifi" "$@" -} - -NAME=$1 diff --git a/rooter/0basicsupport/luci-app-guestwifi/files/usr/lib/guestwifi/start.sh b/rooter/0basicsupport/luci-app-guestwifi/files/usr/lib/guestwifi/start.sh deleted file mode 100644 index e5b7646..0000000 --- a/rooter/0basicsupport/luci-app-guestwifi/files/usr/lib/guestwifi/start.sh +++ /dev/null @@ -1,200 +0,0 @@ -#!/bin/sh -. /lib/functions.sh - -log() { - logger -t "Guest Wifi" "$@" -} - -do_radio() { - local config=$1 - local freq=$2 - local channel - - config_get channel $1 channel - if [ $freq = "0" ]; then - if [ $channel -lt 15 ]; then - RADIO=$config - fi - else - if [ $channel -gt 15 ]; then - RADIO=$config - fi - fi -} - -do_check() { - local config=$1 - local wfreq=$2 - local enabled - local freq - - config_get enabled $1 enabled - if [ $enabled = "1" ]; then - config_get freq $1 freq - if [ $freq = $wfreq ]; then - CHECK=1 - fi - fi -} - -NAME=$1 -RAD=$(uci -q get guestwifi.$NAME.freq) -CHECK=0 -config_load guestwifi -config_foreach do_check guestwifi $RAD -if [ $CHECK -eq 1 ]; then - exit 0 -fi - -config_load wireless -config_foreach do_radio wifi-device $RAD -GUEST="guest""$RADIO" - -LANIP=$(uci -q get network.lan.ipaddr) -L1=$(echo $LANIP | cut -d. -f1) -L2=$(echo $LANIP | cut -d. -f2) -L3=$(echo $LANIP | cut -d. -f3) -L4=$(echo $LANIP | cut -d. -f4) -NL3="254" -if [ $RAD = "0" ]; then - NL3="253" -fi -if [ $L3 = "254" ]; then - NL3="1" -fi -if [ $L3 = "253" ]; then - NL3="2" -fi -IP="$L1"."$L2"."$NL3"."$L4" - -ifname1="ifname" -if [ -e /etc/newstyle ]; then - ifname1="device" -fi - -WW=$(uci get -q network.$GUEST) -if [ -z $WW ]; then -# Configure guest network - uci delete network.${GUEST}_dev - uci set network.${GUEST}_dev=device - uci set network.${GUEST}_dev.type=bridge - uci set network.${GUEST}_dev.name="br-"$GUEST - - uci delete network.$GUEST - uci set network.$GUEST=interface - uci set network.$GUEST.proto=static - uci set network.$GUEST.ipaddr=$IP - uci set network.$GUEST.$ifname1=br-${GUEST} - uci set network.$GUEST.netmask=255.255.255.0 - -# Configure DHCP for guest network - uci delete dhcp.$GUEST - uci set dhcp.$GUEST=dhcp - uci set dhcp.$GUEST.interface=$GUEST - uci set dhcp.$GUEST.start=50 - uci set dhcp.$GUEST.limit=200 - uci set dhcp.$GUEST.leasetime=1h - -# Configure firewall for guest network - ## Configure guest zone - uci delete firewall.$GUEST"_zone" - uci set firewall.$GUEST"_zone"=zone - uci set firewall.$GUEST"_zone".name=$GUEST - uci set firewall.$GUEST"_zone".network=$GUEST - uci set firewall.$GUEST"_zone".input=REJECT - uci set firewall.$GUEST"_zone".forward=REJECT - uci set firewall.$GUEST"_zone".output=ACCEPT - ## Allow Guest -> Internet - uci delete firewall.$GUEST"_forwarding" - uci set firewall.$GUEST"_forwarding"=forwarding - uci set firewall.$GUEST"_forwarding".src=$GUEST - uci set firewall.$GUEST"_forwarding".dest=wan - ## Allow DNS Guest -> Router - uci delete firewall.$GUEST"_rule_dns" - uci set firewall.$GUEST"_rule_dns"=rule - uci set firewall.$GUEST"_rule_dns".name="Allow "$GUEST" DNS Queries" - uci set firewall.$GUEST"_rule_dns".src=$GUEST - uci set firewall.$GUEST"_rule_dns".dest_port=53 - uci set firewall.$GUEST"_rule_dns".proto=tcpudp - uci set firewall.$GUEST"_rule_dns".target=ACCEPT - ## Allow DHCP Guest -> Router - uci delete firewall.$GUEST"_rule_dhcp" - uci set firewall.$GUEST"_rule_dhcp"=rule - uci set firewall.$GUEST"_rule_dhcp".name="Allow "$GUEST" DHCP request" - uci set firewall.$GUEST"_rule_dhcp".src=$GUEST - uci set firewall.$GUEST"_rule_dhcp".src_port=68 - uci set firewall.$GUEST"_rule_dhcp".dest_port=67 - uci set firewall.$GUEST"_rule_dhcp".proto=udp - uci set firewall.$GUEST"_rule_dhcp".target=ACCEPT - - uci commit -fi - -# Configure guest Wi-Fi -SSID=$(uci -q get guestwifi.$NAME.ssid) -ENCR=$(uci -q get guestwifi.$NAME.encrypted) - -uci delete wireless.$NAME -uci set wireless.$NAME=wifi-iface -uci set wireless.$NAME.device=$RADIO -uci set wireless.$NAME.mode=ap -uci set wireless.$NAME.network=$GUEST -uci set wireless.$NAME.ssid=$SSID -case $ENCR in - "0" ) - uci set wireless.$NAME.encryption="none" - uci set wireless.$NAME.key="" - ;; - "1" ) - uci set wireless.$NAME.encryption="psk" - uci set wireless.$NAME.key=$(uci get guestwifi.$NAME.password) - ;; - "2" ) - uci set wireless.$NAME.encryption="psk2" - uci set wireless.$NAME.key=$(uci get guestwifi.$NAME.password) - ;; -esac -uci commit wireless - -QOS=$(uci -q get guestwifi.$NAME.qos) - -if [ $QOS = "1" ]; then - DL=$(uci -q get guestwifi.$NAME.dl) - let "DL=$DL * 1000" - UL=$(uci -q get guestwifi.$NAME.ul) - let "UL=$UL * 1000" - IFACE="$(iwinfo | grep "ESSID" | grep $SSID)" - WI=${IFACE% *} - WI=${WI% *} - uci delete sqm.$NAME - uci set sqm.$NAME=queue - uci set sqm.$NAME.interface=$WI - uci set sqm.$NAME.enabled='1' - uci set sqm.$NAME.upload=$DL - uci set sqm.$NAME.download=$UL - uci set sqm.$NAME.qdisc='cake' - uci set sqm.$NAME.script='piece_of_cake.qos' - uci set sqm.$NAME.qdisc_advanced='1' - uci set sqm.$NAME.linklayer='none' - uci set sqm.$NAME.ingress_ecn='ECN' - uci set sqm.$NAME.egress_ecn='ECN' - uci set sqm.$NAME.debug_logging='0' - uci set sqm.$NAME.verbosity='5' - uci set sqm.$NAME.squash_dscp='1' - uci set sqm.$NAME.squash_ingress ='1' - uci commit sqm - /etc/init.d/sqm start - /etc/init.d/sqm enable -fi - - -if [ -z $WW ]; then - /etc/init.d/dnsmasq restart - /etc/init.d/firewall restart - /etc/init.d/network restart -fi - - - -uci set guestwifi.$NAME.enabled="1" -uci commit guestwifi \ No newline at end of file diff --git a/rooter/0basicsupport/luci-app-guestwifi/files/usr/lib/guestwifi/stop.sh b/rooter/0basicsupport/luci-app-guestwifi/files/usr/lib/guestwifi/stop.sh deleted file mode 100644 index 3313ed0..0000000 --- a/rooter/0basicsupport/luci-app-guestwifi/files/usr/lib/guestwifi/stop.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -log() { - logger -t "Guest Wifi" "$@" -} - -NAME=$1 - -uci delete wireless.$NAME -uci commit wireless -QOS=$(uci get guestwifi.$NAME.qos) -if [ $QOS = "1" ]; then - uci delete sqm.$NAME - uci commit sqm - /etc/init.d/sqm start - /etc/init.d/sqm enable -fi -uci set guestwifi.$NAME.enabled="0" -uci commit guestwifi \ No newline at end of file diff --git a/rooter/0basicsupport/luci-app-guestwifi/files/usr/lib/lua/luci/controller/guestwifi.lua b/rooter/0basicsupport/luci-app-guestwifi/files/usr/lib/lua/luci/controller/guestwifi.lua deleted file mode 100644 index a4cabce..0000000 --- a/rooter/0basicsupport/luci-app-guestwifi/files/usr/lib/lua/luci/controller/guestwifi.lua +++ /dev/null @@ -1,19 +0,0 @@ -module("luci.controller.guestwifi", package.seeall) - -function index() - local page - if not nixio.fs.access("/etc/config/wireless") then - return - end - - page = entry({"admin", "network", "guestwifi"}, cbi("guestwifi", {hidesavebtn=true, hideresetbtn=true}), "Guest Wifi", 22) - page.dependent = true - entry( {"admin", "network", "guestwifi", "edit"}, cbi("guestwifi-edit"), nil ).leaf = true - - entry({"admin", "network", "createwifi"}, call("action_createwifi")) -end - -function action_createwifi() - local set = luci.http.formvalue("set") - os.execute("/usr/lib/guestwifi/create.sh " .. set) -end \ No newline at end of file diff --git a/rooter/0basicsupport/luci-app-guestwifi/files/usr/lib/lua/luci/model/cbi/guestwifi-edit.lua b/rooter/0basicsupport/luci-app-guestwifi/files/usr/lib/lua/luci/model/cbi/guestwifi-edit.lua deleted file mode 100644 index 982ee85..0000000 --- a/rooter/0basicsupport/luci-app-guestwifi/files/usr/lib/lua/luci/model/cbi/guestwifi-edit.lua +++ /dev/null @@ -1,72 +0,0 @@ -require("luci.ip") -local uci = require "luci.model.uci".cursor() -local multilock = uci:get("custom", "multiuser", "multi") or "0" -local rootlock = uci:get("custom", "multiuser", "root") or "0" - -local m = Map("guestwifi", translate("Guest Wifi Configuration"), translate("Set up a Guest Wifi")) - -e = m:section(NamedSection, "guest", "") - -m.on_init = function(self) - --luci.sys.call("/usr/lib/wireguard/keygen.sh " .. arg[1]) -end - -btn = e:option(Button, "_btn", translate(" ")) -btn.inputtitle = translate("Back to Main Page") -btn.inputstyle = "apply" -btn.redirect = luci.dispatcher.build_url( - "admin", "network", "guestwifi" -) -function btn.write(self, section, value) - luci.http.redirect( self.redirect ) -end - -local s = m:section( NamedSection, arg[1], "guestwifi", translate("Instance Name : " .. arg[1]) ) - -ssid = s:option(Value, "ssid", translate("SSID :")); -ssid.rmempty = true; -ssid.optional=false; -ssid.default="Guest"; - -bl = s:option(ListValue, "freq", translate("Frequency :")); -bl:value("0", "2.4Ghz") -bl.rmempty = true; -bl.optional=false; -wifi5g = uci:get("guestwifi", arg[1], "radio5g") -if wifi5g == "1" then - bl:value("1", "5.0Ghz") -end - -el = s:option(ListValue, "encrypted", translate("Encryption :")); -el:value("0", translate("None")) -el:value("1", translate("WPA-PSK (Medium Security)")) -el:value("2", translate("WPA2-PSK (Strong Security)")) -el.default=0 - -pass = s:option(Value, "password", translate("Password :")); -pass.rmempty = true; -pass.optional=false; -pass.default=""; -pass.datatype="wpakey"; -pass.password = true - -if (multilock == "0") then - ql = s:option(ListValue, "qos", translate("Bandwidth Limited :")); - ql:value("0", "Disabled") - ql:value("1", "Enabled") - ql.default=0 - - dl = s:option(Value, "dl", translate("Download Speed (Mbit/s) :")); - dl.optional=false; - dl.rmempty = true; - dl.datatype = "and(uinteger,min(1))" - dl.default=10 - - ul = s:option(Value, "ul", translate("Upload Speed (Mbit/s) :")); - ul.optional=false; - ul.rmempty = true; - ul.datatype = "and(uinteger,min(1))" - ul.default=2 -end - -return m \ No newline at end of file diff --git a/rooter/0basicsupport/luci-app-guestwifi/files/usr/lib/lua/luci/model/cbi/guestwifi.lua b/rooter/0basicsupport/luci-app-guestwifi/files/usr/lib/lua/luci/model/cbi/guestwifi.lua deleted file mode 100644 index 6ec09c2..0000000 --- a/rooter/0basicsupport/luci-app-guestwifi/files/usr/lib/lua/luci/model/cbi/guestwifi.lua +++ /dev/null @@ -1,128 +0,0 @@ -local fs = require "nixio.fs" -local sys = require "luci.sys" -local uci = require "luci.model.uci".cursor() -local testfullps = sys.exec("ps --help 2>&1 | grep BusyBox") --check which ps do we have -local psstring = (string.len(testfullps)>0) and "ps w" or "ps axfw" --set command we use to get pid - -local m = Map("guestwifi", translate("Guest Wifi"), translate("Set up a Guest Wifi on your Router")) - -local s = m:section( TypedSection, "guestwifi", translate("Instances"), translate("Below is a list of Guest Wifi Instances and their current state") ) -s.template = "cbi/tblsection" -s.template_addremove = "guestwifi/cbi-select-input-add" -s.addremove = true -s.add_select_options = { } - -s.extedit = luci.dispatcher.build_url("admin", "network", "guestwifi", "edit", "%s") - -function s.parse(self, section) - local recipe = luci.http.formvalue( - luci.cbi.CREATE_PREFIX .. self.config .. "." .. - self.sectiontype .. ".select" - ) - - if recipe and not s.add_select_options[recipe] then - self.invalid_cts = true - else - TypedSection.parse( self, section ) - end -end - -function s.create(self, name) - local recipe = luci.http.formvalue( - luci.cbi.CREATE_PREFIX .. self.config .. "." .. - self.sectiontype .. ".select" - ) - local name = luci.http.formvalue( - luci.cbi.CREATE_PREFIX .. self.config .. "." .. - self.sectiontype .. ".text" - ) - return 0 -end - -function s.remove(self, name) - sys.call("/usr/lib/guestwifi/stop.sh %s" % name) - uci:delete("guestwifi", name) - uci:save("guestwifi") - uci:commit("guestwifi") -end - - - -local updown = s:option( Button, "_updown", translate("Start/Stop") ) -updown._state = false -updown.redirect = luci.dispatcher.build_url( - "admin", "network", "guestwifi" -) -function updown.cbid(self, section) - local file_cfg = self.map:get(section, "enabled") - if file_cfg == "1" then - pid = 1 - else - pid = nil - end - self._state = pid ~= nil - self.option = self._state and "stop" or "start" - return AbstractValue.cbid(self, section) -end -function updown.cfgvalue(self, section) - self.title = self._state and "stop" or "start" - self.inputstyle = self._state and "reset" or "reload" -end -function updown.write(self, section, value) - if self.option == "stop" then - sys.call("/usr/lib/guestwifi/stop.sh %s" % section) - else - sys.call("/usr/lib/guestwifi/start.sh %s" % section) - end - luci.http.redirect( self.redirect ) -end - -local port = s:option( DummyValue, "ssid", translate("SSID") ) - -local freq = s:option( DummyValue, "freq", translate("Frequency") ) -function freq.cfgvalue(self, section) - local val = AbstractValue.cfgvalue(self, section) - if val == nil then - val = "0" - end - if val == "1" then - return "5.0Ghz" - else - return "2.4Ghz" - end -end - -local auto = s:option( DummyValue, "encrypted", translate("Encryption") ) -function auto.cfgvalue(self, section) - local val = AbstractValue.cfgvalue(self, section) - if val == nil then - val = 0 - end - if val == "1" then - return "WPA-PSK (Medium Security)" - else - if val == "2" then - return "WPA2-PSK (Strong Security)" - else - return "None" - end - end -end - -local qos = s:option( DummyValue, "qos", translate("Bandwidth Limiting") ) -function qos.cfgvalue(self, section) - local val = AbstractValue.cfgvalue(self, section) - if val == nil then - val = 0 - end - if val == "1" then - dl_cfg = self.map:get(section, "dl") - ul_cfg = self.map:get(section, "ul") - return "Download : " .. dl_cfg .. " Mbit/s / Upload : " .. ul_cfg .. " Mbit/s" - else - return "Disabled" - end -end - - -return m \ No newline at end of file diff --git a/rooter/0basicsupport/luci-app-guestwifi/files/usr/lib/lua/luci/view/guestwifi/cbi-select-input-add.htm b/rooter/0basicsupport/luci-app-guestwifi/files/usr/lib/lua/luci/view/guestwifi/cbi-select-input-add.htm deleted file mode 100644 index a99adf8..0000000 --- a/rooter/0basicsupport/luci-app-guestwifi/files/usr/lib/lua/luci/view/guestwifi/cbi-select-input-add.htm +++ /dev/null @@ -1,60 +0,0 @@ - - - - -<%+guestwifi/ovpn_css%> - -
                -
                -
                - - - - -
                 
                -

                <%:New Guest Wifi%>

                - - - - - - -
                -
                -
                -
                \ No newline at end of file diff --git a/rooter/0basicsupport/luci-app-guestwifi/files/usr/lib/lua/luci/view/guestwifi/ovpn_css.htm b/rooter/0basicsupport/luci-app-guestwifi/files/usr/lib/lua/luci/view/guestwifi/ovpn_css.htm deleted file mode 100644 index 55c0a54..0000000 --- a/rooter/0basicsupport/luci-app-guestwifi/files/usr/lib/lua/luci/view/guestwifi/ovpn_css.htm +++ /dev/null @@ -1,38 +0,0 @@ - diff --git a/rooter/0drivers/rmbim/.svn/entries b/rooter/0drivers/rmbim/.svn/entries deleted file mode 100644 index 358eda1..0000000 --- a/rooter/0drivers/rmbim/.svn/entries +++ /dev/null @@ -1,65 +0,0 @@ -10 - -dir -42347 -svn://svn.openwrt.org/openwrt/trunk/package/network/utils/umbim -svn://svn.openwrt.org/openwrt - - - -2014-08-26T09:36:59.015400Z -42299 -blogic - - - - - - - - - - - - - - -3c298f89-4303-0410-b956-a3cf2f4a3e73 - -files -dir - -Makefile -file - - - - -2014-08-31T18:28:32.000000Z -47329758b279f0cfd6073b11ec66d486 -2014-08-26T09:36:59.015400Z -42299 -blogic - - - - - - - - - - - - - - - - - - - - - -1141 - diff --git a/rooter/0drivers/rmbim/.svn/text-base/Makefile.svn-base b/rooter/0drivers/rmbim/.svn/text-base/Makefile.svn-base deleted file mode 100644 index f0868ce..0000000 --- a/rooter/0drivers/rmbim/.svn/text-base/Makefile.svn-base +++ /dev/null @@ -1,45 +0,0 @@ -include $(TOPDIR)/rules.mk - -PKG_NAME:=umbim -PKG_VERSION:=2014-08-26 -PKG_RELEASE=$(PKG_SOURCE_VERSION) - -PKG_SOURCE_PROTO:=git -PKG_SOURCE_URL:=git://git.openwrt.org/project/umbim.git -PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) -PKG_SOURCE_VERSION:=7741d88cdfd36f0c4380f660a9ad7109df76b432 -PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz -PKG_MAINTAINER:=John Crispin - -PKG_LICENSE:=GPLv2 -PKG_LICENSE_FILES:= - -PKG_BUILD_PARALLEL:=1 - -include $(INCLUDE_DIR)/package.mk -include $(INCLUDE_DIR)/cmake.mk - -define Package/umbim - SECTION:=net - CATEGORY:=Network - DEPENDS:=+libubox +kmod-usb-net +kmod-usb-net-cdc-mbim - TITLE:=Control utility for mobile broadband modems -endef - -define Package/umbim/description - umbim is a command line tool for controlling mobile broadband modems using - the MBIM-protocol. -endef - -TARGET_CFLAGS += \ - -I$(STAGING_DIR)/usr/include -ffunction-sections -fdata-sections - -TARGET_LDFLAGS += -Wl,--gc-sections - -define Package/umbim/install - $(INSTALL_DIR) $(1)/sbin - $(INSTALL_BIN) $(PKG_BUILD_DIR)/umbim $(1)/sbin/ - $(CP) ./files/* $(1)/ -endef - -$(eval $(call BuildPackage,umbim)) diff --git a/rooter/0drivers/rmbim/Makefile b/rooter/0drivers/rmbim/Makefile deleted file mode 100644 index e35f0b2..0000000 --- a/rooter/0drivers/rmbim/Makefile +++ /dev/null @@ -1,45 +0,0 @@ -include $(TOPDIR)/rules.mk - -PKG_NAME:=umbim -PKG_RELEASE:=$(AUTORELEASE) - -PKG_SOURCE_PROTO:=git -PKG_SOURCE_URL=$(PROJECT_GIT)/project/umbim.git -PKG_SOURCE_DATE:=2021-08-18 -PKG_SOURCE_VERSION:=de5623104baee6e0c13c92f05c15bf4b4145c0b1 -PKG_MIRROR_HASH:=2d4a75d2b53c8413521a2fd138895e327bff3f4b4d29a540342b2d2e1e009852 -PKG_MAINTAINER:=John Crispin - -PKG_LICENSE:=GPL-2.0 -PKG_LICENSE_FILES:= - -PKG_FLAGS:=nonshared - -include $(INCLUDE_DIR)/package.mk -include $(INCLUDE_DIR)/cmake.mk - -define Package/rmbim - SECTION:=net - CATEGORY:=ROOter - SUBMENU:=Drivers - DEPENDS:=+libubox +kmod-usb-net +kmod-usb-net-cdc-mbim +luci-proto-mbim - TITLE:=Control utility for mobile broadband modems -endef - -define Package/rmbim/description - rmbim is a command line tool for controlling mobile broadband modems using - the MBIM-protocol. -endef - -TARGET_CFLAGS += \ - -I$(STAGING_DIR)/usr/include -ffunction-sections -fdata-sections - -TARGET_LDFLAGS += -Wl,--gc-sections - -define Package/rmbim/install - $(INSTALL_DIR) $(1)/sbin - $(INSTALL_BIN) $(PKG_BUILD_DIR)/umbim $(1)/sbin/ - $(CP) ./files/* $(1)/ -endef - -$(eval $(call BuildPackage,rmbim)) diff --git a/rooter/0drivers/rmbim/files/lib/netifd/proto/mbim.sh b/rooter/0drivers/rmbim/files/lib/netifd/proto/mbim.sh deleted file mode 100644 index 67e48fd..0000000 --- a/rooter/0drivers/rmbim/files/lib/netifd/proto/mbim.sh +++ /dev/null @@ -1,627 +0,0 @@ -#!/bin/sh - -[ -n "$INCLUDE_ONLY" ] || { - . /lib/functions.sh - . ../netifd-proto.sh - init_proto "$@" -} -# DBG=-v - -ROOTER=/usr/lib/rooter -ROOTER_LINK="/tmp/links" - -log() { - modlog "MBIM Connect $CURRMODEM" "$@" -} - -enb=$(uci -q get custom.connect.ipv6) -if [ -z $enb ]; then - enb="1" -fi - -ifname1="ifname" -if [ -e /etc/newstyle ]; then - ifname1="device" -fi - -get_connect() { - NAPN=$(uci -q get modem.modeminfo$CURRMODEM.apn) - NAPN2=$(uci -q get modem.modeminfo$CURRMODEM.apn2) - NUSER=$(uci -q get modem.modeminfo$CURRMODEM.user) - NPASS=$(uci -q get modem.modeminfo$CURRMODEM.passw) - NAUTH=$(uci -q get modem.modeminfo$CURRMODEM.auth) - PINC=$(uci -q get modem.modeminfo$CURRMODEM.pincode) - PDPT=$(uci -q get modem.modeminfo$CURRMODEM.pdptype) - isplist=$(uci -q get modem.modeminfo$CURRMODEM.isplist) - - apn=$NAPN - apn2=$NAPN2 - username="$NUSER" - password="$NPASS" - auth=$NAUTH - pincode=$PINC - - if [ "$PDPT" = 0 ]; then - ipt="" - else - IPVAR=$(uci -q get modem.modem$CURRMODEM.pdptype) - case "$IPVAR" in - "IP" ) - ipt="ipv4:" - ;; - "IPV6" ) - ipt="ipv6:" - ;; - "IPV4V6" ) - ipt="ipv4v6:" - ;; - esac - fi -} - -get_sub() { - log "Checking subscriber" - tid=$((tid + 1)) - SUB=$(umbim $DBG -n -t $tid -d $device subscriber) - retq=$? - if [ $retq -ne 0 ]; then - log "Subscriber init failed" - proto_notify_error "$interface" NO_SUBSCRIBER - return 1 - fi - CNUM=$(echo "$SUB" | awk '/number:/ {print $2}') - IMSI=$(echo "$SUB" | awk '/subscriberid:/ {print $2}') - uci set modem.modem$CURRMODEM.imsi=$IMSI - ICCID=$(echo "$SUB" | awk '/simiccid:/ {print $2}') - uci set modem.modem$CURRMODEM.iccid=$ICCID - uci commit modem -} - -proto_mbim_init_config() { - available=1 - no_device=1 - proto_config_add_string "device:device" - proto_config_add_string apn - proto_config_add_string apn2 - proto_config_add_string pincode - proto_config_add_string delay - proto_config_add_string auth - proto_config_add_string username - proto_config_add_string password -} - -_proto_mbim_setup() { - local interface="$1" - local tid=2 - local ret v6cap pdns v4dns v6dns - - if [ ! -f /tmp/bootend.file ]; then - return 0 - fi - - CURRMODEM=$(uci -q get network.$interface.currmodem) - uci set modem.modem$CURRMODEM.connected=0 - uci commit modem - rm -f $ROOTER_LINK/reconnect$CURRMODEM - jkillall getsignal$CURRMODEM - rm -f $ROOTER_LINK/getsignal$CURRMODEM - jkillall con_monitor$CURRMODEM - rm -f $ROOTER_LINK/con_monitor$CURRMODEM - jkillall mbim_monitor$CURRMODEM - rm -f $ROOTER_LINK/mbim_monitor$CURRMODEM - - local device apn pincode delay - json_get_vars device apn apn2 pincode delay auth username password - - case $auth in - "0" ) - auth= - ;; - "1" ) - auth="pap" - ;; - "2" ) - auth="chap" - ;; - "*" ) - auth= - ;; - esac - - IMEI="Unknown" - IMSI="Unknown" - ICCID="Unknown" - CNUM="*" - CNUMx="*" - - [ -n "$ctl_device" ] && device=$ctl_device - - [ -n "$device" ] || { - log "No control device specified" - proto_notify_error "$interface" NO_DEVICE - proto_set_available "$interface" 0 - return 1 - } - [ -c "$device" ] || { - log "The specified control device does not exist" - proto_notify_error "$interface" NO_DEVICE - proto_set_available "$interface" 0 - return 1 - } - - devname="$(basename "$device")" - devpath="$(readlink -f /sys/class/usbmisc/$devname/device/)" - ifname="$( ls "$devpath"/net )" - - [ -n "$ifname" ] || { - log "Failed to find matching interface" - proto_notify_error "$interface" NO_IFNAME - proto_set_available "$interface" 0 - return 1 - } - - [ -n "$delay" ] && sleep "$delay" - - log "Query radio state" - umbim $DBG -n -d $device radio | grep "off" - STATUS=$? - - [ "$STATUS" -ne 0 ] || { - sleep 1 - log "Setting FCC Auth" - uqmi $DBG -s -m -d $device --fcc-auth - sleep 1 - } - - log "Reading capabilities" - tid=$((tid + 1)) - DCAPS=$(umbim $DBG -n -t $tid -d $device caps) - retq=$? - if [ $retq -ne 0 ]; then - - log "Failed to read modem caps" - tid=$((tid + 1)) - umbim $DBG -t $tid -d "$device" disconnect - proto_notify_error "$interface" PIN_FAILED - return 1 - fi - CUSTOM=$(echo "$DCAPS" | awk '/customdataclass:/ {print $2}') - IMEI=$(echo "$DCAPS" | awk '/deviceid:/ {print $2}') - uci set modem.modem$CURRMODEM.imei=$IMEI - echo 'CUSTOM="'"$CUSTOM"'"' > /tmp/mbimcustom$CURRMODEM - - get_sub - - if [ ! -f /tmp/profile$CURRMODEM ]; then - $ROOTER/connect/get_profile.sh $CURRMODEM - fi - - get_connect - - log "Checking PIN state" - tid=$((tid + 1)) - umbim $DBG -n -t $tid -d $device pinstate - retq=$? - if [ $retq -eq 2 ]; then - log "PIN is required" - if [ ! -z $pincode ]; then - log "Sending PIN" - tid=$((tid + 1)) - umbim $DBG -n -t $tid -d $device unlock "$pincode" 2>/dev/null - retq=$? - if [ $retq -ne 0 ]; then - log "PIN unlock failed" - exit 1 - else - log "PIN unlocked" - sleep 3 - CHKPORT=$(uci get modem.modem$CURRMODEM.commport) - if [ ! -z $CHKPORT ]; then - $ROOTER/common/gettype.sh $CURRMODEM - else - get_sub - fi - fi - else - log "PIN is missing in the profile" - exit 1 - fi - else - log "PIN is not required" - fi - - log "Register with network" - for i in $(seq 30); do - tid=$((tid + 1)) - REG=$(umbim $DBG -n -t $tid -d $device registration) - retq=$? - [ $retq -ne 2 ] && break - sleep 2 - done - if [ $retq != 0 ]; then - if [ $retq != 4 ]; then - log "Subscriber registration failed" - proto_notify_error "$interface" NO_REGISTRATION - return 1 - fi - fi - MCCMNC=$(echo "$REG" | awk '/provider_id:/ {print $2}') - PROV=$(echo "$REG" | awk '/provider_name:/ {print $2}') - MCC=${MCCMNC:0:3} - MNC=${MCCMNC:3} - - tid=$((tid + 1)) - - log "Attach to network" - ATTACH=$(umbim $DBG -n -t $tid -d $device attach) - retq=$? - if [ $retq != 0 ]; then - log "Failed to attach to network" - proto_notify_error "$interface" ATTACH_FAILED - return 1 - fi - UP=$(echo "$ATTACH" | awk '/uplinkspeed:/ {print $2}') - DOWN=$(echo "$ATTACH" | awk '/downlinkspeed:/ {print $2}') - - tid=$((tid + 1)) - - for isp in $isplist - do - NAPN=$(echo $isp | cut -d, -f2) - NPASS=$(echo $isp | cut -d, -f4) - CID=$(echo $isp | cut -d, -f5) - NUSER=$(echo $isp | cut -d, -f6) - NAUTH=$(echo $isp | cut -d, -f7) - if [ "$NPASS" = "nil" ]; then - NPASS="NIL" - fi - if [ "$NUSER" = "nil" ]; then - NUSER="NIL" - fi - if [ "$NAUTH" = "nil" ]; then - NAUTH="0" - fi - apn=$NAPN - username="$NUSER" - password="$NPASS" - auth=$NAUTH - case $auth in - "0" ) - auth="none" - ;; - "1" ) - auth="pap" - ;; - "2" ) - auth="chap" - ;; - "*" ) - auth="none" - ;; - esac - - if [ ! -e /etc/config/isp ]; then - log "Connect to network using $apn" - else - log "Connect to network" - fi - - if [ ! -e /etc/config/isp ]; then - log "$ipt $apn $auth $username $password" - fi - - tidd=0 - tcnt=4 - while ! umbim $DBG -n -t $tid -d $device connect "$ipt""$apn" "$auth" "$username" "$password"; do - tid=$((tid + 1)) - sleep 1; - tidd=$((tidd + 1)) - if [ $tidd -gt $tcnt ]; then - break; - fi - done - if [ $tidd -le $tcnt ]; then - break - fi - done - if [ $tidd -gt $tcnt ]; then - log "Failed to connect to network" - return 1 - fi - log "Save Connect Data" - uci set modem.modem$CURRMODEM.mdevice=$device - uci set modem.modem$CURRMODEM.mapn=$apn - uci set modem.modem$CURRMODEM.mipt=$itp - uci set modem.modem$CURRMODEM.mauth=$auth - uci set modem.modem$CURRMODEM.musername=$username - uci set modem.modem$CURRMODEM.mpassword=$password - uci commit modem - - tid=$((tid + 1)) - - log "Get IP config" - CONFIG=$(umbim $DBG -n -t $tid -d $device config) || { - log "config failed" - return 1 - } - - IP=$(echo -e "$CONFIG"|grep "ipv4address"|grep -E -o "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)") - GATE=$(echo -e "$CONFIG"|grep "ipv4gateway"|grep -E -o "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)") - DNS1=$(echo -e "$CONFIG"|grep "ipv4dnsserver"|grep -E -o "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)" |sed -n 1p) - DNS2=$(echo -e "$CONFIG"|grep "ipv4dnsserver"|grep -E -o "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)" |sed -n 2p) - if [ $enb = "1" ]; then - IP6=$(echo "$CONFIG" | awk '/ipv6address:/ {print $2}' | cut -d / -f 1) - DNS3=$(echo "$CONFIG" | awk '/ipv6dnsserver:/ {print $2}' | sed -n 1p) - DNS4=$(echo "$CONFIG" | awk '/ipv6dnsserver:/ {print $2}' | sed -n 2p) - fi - echo "$GATE" > /tmp/mbimgateway - - [ -n "$IP" ] && echo "IP: $IP" - [ -n "$DNS1" ] && echo "DNS1: $DNS1" - [ -n "$DNS2" ] && echo "DNS2: $DNS2" - if [ $enb = "1" ]; then - [ -n "$IP6" ] && echo "IPv6: $IP6" - [ -n "$DNS3" ] && echo "DNS3: $DNS3" - [ -n "$DNS4" ] && echo "DNS4: $DNS4" - fi - - log "Connected, setting IP" - - if [ $enb = "1" ]; then - if [ -n "$IP6" -a -z "$IP" ]; then - log "Running IPv6-only mode" - nat46=1 - fi - - if [[ $(echo "$IP6" | grep -o "^[23]") ]]; then - # Global unicast IP acquired - v6cap=1 - elif - [[ $(echo "$IP6" | grep -o "^[0-9a-fA-F]\{1,4\}:") ]]; then - # non-routable address - v6cap=2 - else - v6cap=0 - fi - fi - - INTER=$(uci get modem.modem$CURRMODEM.inter) - if [ -e /tmp/v4dns$INTER -o -e /tmp/v6dns$INTER ]; then - pdns=1 - if [ -e /tmp/v4dns$INTER ]; then - v4dns=$(cat /tmp/v4dns$INTER 2>/dev/null) - fi - if [ $enb = "1" ]; then - if [ -e /tmp/v6dns$INTER ]; then - v6dns=$(cat /tmp/v6dns$INTER 2>/dev/null) - fi - fi - else - v4dns="$DNS1 $DNS2" - if [ $enb = "1" ]; then - v6dns="$DNS3 $DNS4" - fi - fi - - proto_init_update "$ifname" 1 - - if [ -n "$IP" ]; then - proto_add_ipv4_address $IP "255.255.255.255" - proto_add_ipv4_route "0.0.0.0" 0 - fi - - for DNSV in $(echo "$v4dns"); do - proto_add_dns_server "$DNSV" - done - - if [ $enb = "1" ]; then - if [ "$v6cap" -gt 0 ]; then - # RFC 7278: Extend an IPv6 /64 Prefix to LAN - proto_add_ipv6_address $IP6 128 - if [ "$v6cap" = 1 ]; then - proto_add_ipv6_prefix $IP6/64 - proto_add_ipv6_route "::0" 0 "" "" "" $IP6/64 - for DNSV in $(echo "$v6dns"); do - proto_add_dns_server "$DNSV" - done - fi - fi - fi - - proto_add_data - json_add_string zone wan - proto_close_data - - proto_send_update "$interface" - - if [ $enb = "1" ]; then - if [ "$v6cap" -gt 0 ]; then - local zone="$(fw3 -q network "$interface" 2>/dev/null)" - fi - if [ "$v6cap" = 2 ]; then - log "Adding IPv6 dynamic interface" - json_init - json_add_string name "${interface}_6" - json_add_string ${ifname1} "@$interface" - json_add_string proto "dhcpv6" - json_add_string extendprefix 1 - [ -n "$zone" ] && json_add_string zone "$zone" - [ "$nat46" = 1 ] || json_add_string iface_464xlat 0 - json_add_boolean peerdns 0 - json_add_array dns - for DNSV in $(echo "$v6dns"); do - json_add_string "" "$DNSV" - done - json_close_array - proto_add_dynamic_defaults - json_close_object - ubus call network add_dynamic "$(json_dump)" - elif - [ "$v6cap" = 1 -a "$nat46" = 1 ]; then - log "Adding 464XLAT (CLAT) dynamic interface" - json_init - json_add_string name "CLAT$INTER" - json_add_string proto "464xlat" - json_add_string tunlink "${interface}" - [ -n "$zone" ] && json_add_string zone "$zone" - proto_add_dynamic_defaults - json_close_object - ubus call network add_dynamic "$(json_dump)" - fi - fi - - tid=$((tid + 1)) - uci_set_state network $interface tid "$tid" -# SIGNAL=$(umbim $DBG -n -t $tid -d $device signal) -# CSQ=$(echo "$SIGNAL" | awk '/rssi:/ {print $2}') - - if [ -e $ROOTER/modem-led.sh ]; then - $ROOTER/modem-led.sh $CURRMODEM 3 - fi - - $ROOTER/log/logger "Modem #$CURRMODEM Connected" - log "Modem $CURRMODEM Connected" - - IDP=$(uci get modem.modem$CURRMODEM.idP) - IDV=$(uci get modem.modem$CURRMODEM.idV) - - if [ ! -s /tmp/msimdata$CURRMODEM ]; then - echo $IDV" : "$IDP > /tmp/msimdatax$CURRMODEM - echo "$IMEI" >> /tmp/msimdatax$CURRMODEM - echo "$IMSI" >> /tmp/msimdatax$CURRMODEM - echo "$ICCID" >> /tmp/msimdatax$CURRMODEM - echo "1" >> /tmp/msimdatax$CURRMODEM - mv -f /tmp/msimdatax$CURRMODEM /tmp/msimdata$CURRMODEM - fi - - if [ ! -s /tmp/msimnum$CURRMODEM ]; then - echo "$CNUM" > /tmp/msimnumx$CURRMODEM - echo "$CNUMx" >> /tmp/msimnumx$CURRMODEM - mv -f /tmp/msimnumx$CURRMODEM /tmp/msimnum$CURRMODEM - fi - - uci set modem.modem$CURRMODEM.custom=$CUSTOM - uci set modem.modem$CURRMODEM.provider=$PROV - uci set modem.modem$CURRMODEM.down=$DOWN" kbps Down | " - uci set modem.modem$CURRMODEM.up=$UP" kbps Up" - uci set modem.modem$CURRMODEM.mcc=$MCC - uci set modem.modem$CURRMODEM.mnc=" "$MNC - uci set modem.modem$CURRMODEM.sig="--" - uci set modem.modem$CURRMODEM.sms=0 - uci commit modem - - COMMPORT=$(uci get modem.modem$CURRMODEM.commport) - if [ -z $COMMPORT ]; then - ln -s $ROOTER/mbim/mbimdata.sh $ROOTER_LINK/getsignal$CURRMODEM - else - $ROOTER/sms/check_sms.sh $CURRMODEM & - ln -s $ROOTER/signal/modemsignal.sh $ROOTER_LINK/getsignal$CURRMODEM - # send custom AT startup command - if [ $(uci -q get modem.modeminfo$CURRMODEM.at) -eq "1" ]; then - ATCMDD=$(uci -q get modem.modeminfo$CURRMODEM.atc) - if [ ! -z "${ATCMDD}" ]; then - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - OX=$($ROOTER/common/processat.sh "$OX") - ERROR="ERROR" - if `echo ${OX} | grep "${ERROR}" 1>/dev/null 2>&1` - then - log "Error sending custom AT command: $ATCMDD with result: $OX" - else - log "Sent custom AT command: $ATCMDD with result: $OX" - fi - fi - fi - fi - ln -s $ROOTER/connect/reconnect.sh $ROOTER_LINK/reconnect$CURRMODEM - $ROOTER_LINK/getsignal$CURRMODEM $CURRMODEM $PROT & - ln -s $ROOTER/connect/conmon.sh $ROOTER_LINK/con_monitor$CURRMODEM - $ROOTER_LINK/con_monitor$CURRMODEM $CURRMODEM & - #ln -s $ROOTER/mbim/monitor.sh $ROOTER_LINK/mbim_monitor$CURRMODEM - #$ROOTER_LINK/mbim_monitor$CURRMODEM $CURRMODEM $device & - - uci set modem.modem$CURRMODEM.connected=1 - uci commit modem - - if [ -e $ROOTER/connect/postconnect.sh ]; then - $ROOTER/connect/postconnect.sh $CURRMODEM - fi - - if [ -e $ROOTER/timezone.sh ]; then - TZ=$(uci -q get modem.modeminfo$CURRMODEM.tzone) - if [ "$TZ" = "1" ]; then - $ROOTER/timezone.sh & - fi - fi - #CLB=$(uci -q get modem.modeminfo$CURRMODEM.lb) - CLB=1 - if [ -e /etc/config/mwan3 ]; then - INTER=$(uci get modem.modeminfo$CURRMODEM.inter) - if [ -z $INTER ]; then - INTER=0 - else - if [ $INTER = 0 ]; then - INTER=$CURRMODEM - fi - fi - ENB=$(uci -q get mwan3.wan$CURRMODEM.enabled) - if [ ! -z $ENB ]; then - if [ $CLB = "1" ]; then - uci set mwan3.wan$INTER.enabled=1 - else - uci set mwan3.wan$INTER.enabled=0 - fi - uci commit mwan3 - /usr/sbin/mwan3 restart - fi - fi - rm -f /tmp/usbwait - - return 0 -} - -proto_mbim_setup() { - - local ret - _proto_mbim_setup $@ - ret=$? - - [ "$ret" = 0 ] || { - log "MBIM bringup failed, retry in 5s" - CPORT=$(uci get modem.modem$CURRMODEM.commport) - ATCMDD="AT+COPS=0" - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - #log "Restart Modem" - #/usr/lib/rooter/luci/restart.sh $CURRMODEM - sleep 5 - } - - exit 0 - return $ret -} - -proto_mbim_teardown() { - local interface="$1" - - local device - json_get_vars device - local tid=$(uci_get_state network $interface tid) - - [ -n "$ctl_device" ] && device=$ctl_device - - if [ -n "$device" ]; then - log "Stopping network" - if [ -n "$tid" ]; then - tid=$((tid + 1)) - umbim $DBG -t $tid -d "$device" disconnect - uci_revert_state network $interface tid - else - umbim $DBG -d "$device" disconnect - fi - fi - - proto_init_update "*" 0 - proto_send_update "$interface" - -} - -[ -n "$INCLUDE_ONLY" ] || add_protocol mbim diff --git a/rooter/0drivers/rmbim/files/usr/lib/rooter/mbim/mbimdata.sh b/rooter/0drivers/rmbim/files/usr/lib/rooter/mbim/mbimdata.sh deleted file mode 100644 index 41f6f10..0000000 --- a/rooter/0drivers/rmbim/files/usr/lib/rooter/mbim/mbimdata.sh +++ /dev/null @@ -1,115 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter -ROOTER_LINK=$ROOTER"/links" - -log() { - logger -t "MBIM Data" "$@" -} - -STARTIMEX=$(date +%s) -MONSTAT= -rm -f /tmp/monstat$CURRMODEM - -build_status() { - CSQ=$signal - if [ $CSQ -ge 0 -a $CSQ -le 31 ]; then - CSQ_PER=$(($CSQ * 100/31)) - CSQ_RSSI=$((2 * CSQ - 113)) - CSQX=$CSQ_RSSI - [ $CSQ -eq 0 ] && CSQ_RSSI="<= "$CSQ_RSSI - [ $CSQ -eq 31 ] && CSQ_RSSI=">= "$CSQ_RSSI - CSQ_PER=$CSQ_PER"%" - CSQ_RSSI=$CSQ_RSSI" dBm" - else - CSQ="-" - CSQ_PER="-" - CSQ_RSSI="-" - fi - echo "-" > /tmp/status$CURRMODEM.file - echo "$CSQ" >> /tmp/status$CURRMODEM.file - echo "$CSQ_PER" >> /tmp/status$CURRMODEM.file - echo "$CSQ_RSSI" >> /tmp/status$CURRMODEM.file - echo "$manuf" >> /tmp/status$CURRMODEM.file - echo "$provider" >> /tmp/status$CURRMODEM.file - echo "$cellmode" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "$mcc" >> /tmp/status$CURRMODEM.file - echo "$mnc" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "$down" >> /tmp/status$CURRMODEM.file - echo "$up" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo " " >> /tmp/status$CURRMODEM.file - echo " " >> /tmp/status$CURRMODEM.file - echo "$MONSTAT" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "$conn" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "MBIM" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file -} - -CURRMODEM=$1 - -conn="Modem #"$CURRMODEM -custom=$(uci get modem.modem$CURRMODEM.custom) -port=$(uci get modem.modem$CURRMODEM.wdm) -netd=$(uci get modem.modem$CURRMODEM.wwan) -manuf=$(uci get modem.modem$CURRMODEM.manuf) -model=$(uci get modem.modem$CURRMODEM.model) -mcc=$(uci get modem.modem$CURRMODEM.mcc) -mnc=$(uci get modem.modem$CURRMODEM.mnc) -up=$(uci get modem.modem$CURRMODEM.up) -down=$(uci get modem.modem$CURRMODEM.down) -provider=$(uci get modem.modem$CURRMODEM.provider) -cellmode=$(uci get modem.modem$CURRMODEM.mode) -if [ $cellmode = "CUSTOM" ]; then - cellmode=$custom -fi -signal=$(uci get modem.modem$CURRMODEM.sig) - -device="/dev/cdc-wdm"$port -netdev="wwan"$netd -manuf=$manuf" "$model - -tid=2 -while [ 1 -eq 1 ]; do - tid=2 - #SIGNAL=$(umbim -n -t $tid -d $device signal) - tid=$((tid + 1)) - #SIGNAL=$(umbim -n -t $tid -d $device signal) - signal=0 - if [ -e /tmp/monstat$CURRMODEM ]; then - source /tmp/monstat$CURRMODEM - fi - if [ -z $MONSTAT ]; then - MONSTAT="Unknown" - fi - build_status - if [ -e /etc/netspeed ]; then - NETSPEED=60 - else - NETSPEED=10 - fi - CURRTIME=$(date +%s) - let ELAPSE=CURRTIME-STARTIMEX - while [ $ELAPSE -lt $NETSPEED ]; do - sleep 2 - CURRTIME=$(date +%s) - let ELAPSE=CURRTIME-STARTIMEX - done - STARTIMEX=$CURRTIME -done diff --git a/rooter/0drivers/rmbim/files/usr/lib/rooter/mbim/monitor.sh b/rooter/0drivers/rmbim/files/usr/lib/rooter/mbim/monitor.sh deleted file mode 100644 index 0e84aec..0000000 --- a/rooter/0drivers/rmbim/files/usr/lib/rooter/mbim/monitor.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/sh - -. /lib/functions.sh - -ROOTER_LINK="/tmp/links" - -log() { - logger -t "MBIM Monitor" "$@" -} - -CURRMODEM=$1 -DEVICE=$2 - -while :; do - tid=$(uci_get_state network wan$CURRMODEM tid) - tid=$((tid + 1)) - umbim -d $DEVICE -n -t $tid status >/dev/null - retq=$? - uci_toggle_state network wan$CURRMODEM tid $tid - [ $retq -ne 0 ] && break - sleep 10 -done - -case $retq in -2) - error="activation state: activating" - ;; -3) - error="activation state: deactivated" - ;; -4) - error="activation state: deactivating" - ;; -255) - error="MBIM message not long enough" - ;; -esac - -log "Modem $CURRMODEM Connection is Down ($error)" -if [ -f $ROOTER_LINK/reconnect$CURRMODEM ]; then - $ROOTER_LINK/reconnect$CURRMODEM $CURRMODEM & -fi - -# wait to be killed by mbim.sh -sleep 60 diff --git a/rooter/0drivers/rqmi/Makefile b/rooter/0drivers/rqmi/Makefile deleted file mode 100644 index a69b892..0000000 --- a/rooter/0drivers/rqmi/Makefile +++ /dev/null @@ -1,48 +0,0 @@ -include $(TOPDIR)/rules.mk - -PKG_NAME:=uqmi -PKG_RELEASE:=$(AUTORELEASE) - -PKG_SOURCE_PROTO:=git -PKG_SOURCE_URL=$(PROJECT_GIT)/project/uqmi.git -PKG_SOURCE_DATE:=2021-11-06 -PKG_SOURCE_VERSION:=6f956265167945267d676c99f123a8c822f0a77b -PKG_MIRROR_HASH:=1dbe14a28ec59b364dbde5dea9e10ed1c5c3eda274b6c7690c793a06643acf3e -PKG_MAINTAINER:=Matti Laakso - -PKG_LICENSE:=GPL-2.0 -PKG_LICENSE_FILES:= - -PKG_FLAGS:=nonshared - -include $(INCLUDE_DIR)/package.mk -include $(INCLUDE_DIR)/cmake.mk - -define Package/rqmi - SECTION:=net - CATEGORY:=ROOter - SUBMENU:=Drivers - DEPENDS:=+libubox +libblobmsg-json +kmod-usb-net +kmod-usb-net-qmi-wwan +wwan - TITLE:=Control utility for mobile broadband modems -endef - -define Package/rqmi/description - uqmi is a command line tool for controlling mobile broadband modems using - the QMI-protocol. -endef - -TARGET_CFLAGS += \ - -I$(STAGING_DIR)/usr/include -ffunction-sections -fdata-sections - -TARGET_LDFLAGS += -Wl,--gc-sections - -CMAKE_OPTIONS += \ - -DDEBUG=1 - -define Package/rqmi/install - $(INSTALL_DIR) $(1)/sbin - $(INSTALL_BIN) $(PKG_BUILD_DIR)/uqmi $(1)/sbin/ - $(CP) ./files/* $(1)/ -endef - -$(eval $(call BuildPackage,rqmi)) diff --git a/rooter/0drivers/rqmi/files/usr/lib/rooter/qmi/connectqmi.sh b/rooter/0drivers/rqmi/files/usr/lib/rooter/qmi/connectqmi.sh deleted file mode 100644 index e3c4cbf..0000000 --- a/rooter/0drivers/rqmi/files/usr/lib/rooter/qmi/connectqmi.sh +++ /dev/null @@ -1,301 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -log() { - modlog "QMI Connect $CURRMODEM" "$@" -} - - . /lib/functions.sh - . /lib/netifd/netifd-proto.sh - -CURRMODEM=$1 -devname=$2 -device=/dev/$2 -auth=$3 -NAPN=$4 -username=$5 -password=$6 -RAW=$7 -DHCP=$8 -pincode=$9 - -enb=$(uci -q get custom.connect.ipv6) -if [ -z $enb ]; then - enb="1" -fi - -ifname1="ifname" -if [ -e /etc/newstyle ]; then - ifname1="device" -fi - -INTER=$(uci -q get modem.modem$CURRMODEM.inter) -interface="wan"$INTER - -case $auth in - "0" ) - auth="none" - ;; - "1" ) - auth="pap" - ;; - "2" ) - auth="chap" - ;; - *) - auth="none" - ;; -esac - -if [ $username = NIL ]; then - username= -fi -if [ $password = NIL ]; then - password= -fi - -ifname="$(ls /sys/class/usbmisc/$devname/device/net/)" - -#while uqmi -s -d "$device" --get-pin-status | grep '"UIM uninitialized"' > /dev/null; do -# sleep 1; -#done - -[ -n "$pincode" ] && { - uqmi -s -d "$device" --verify-pin1 "$pincode" || { - log "Unable to verify PIN" - ret=1 - } -} - -uqmi -s -d "$device" --stop-network 0xffffffff --autoconnect > /dev/null & sleep 5 ; kill -9 $! -uqmi -s -d "$device" --set-device-operating-mode online > /dev/null 2>&1 & sleep 5 ; kill -9 $! - -if [ $RAW -eq 1 ]; then - DATAFORM='"raw-ip"' -else - if [ $idV = 1199 -a $idP = 9055 ]; then - $ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "reset.gcom" "$CURRMODEM" - DATAFORM='"802.3"' - uqmi -s -d "$device" --set-data-format 802.3 - uqmi -s -d "$device" --wda-set-data-format 802.3 - else - log "getting data format" - DATAFORM=$(uqmi -s -d "$device" --wda-get-data-format) - fi -fi - -log "WDA-GET-DATA-FORMAT is $DATAFORM" -if [ "$DATAFORM" = '"raw-ip"' ]; then - [ -f /sys/class/net/$ifname/qmi/raw_ip ] || { - log "Device only supports raw-ip mode but is missing this required driver attribute: /sys/class/net/$ifname/qmi/raw_ip" - ret=1 - } - echo "Y" > /sys/class/net/$ifname/qmi/raw_ip -fi - -log "Query radio state" -uqmi -s -d "$device" --get-signal-info | grep -q "Information unavailable" & sleep 5 ; kill -9 $! -STATUS=$? - -[ "$STATUS" -ne 0 ] || { - sleep 1 - log "Setting FCC Auth" - uqmi -s -d "$device" --fcc-auth & sleep 5 ; kill -9 $! - sleep 1 - } - -uqmi -s -d "$device" --sync > /dev/null 2>&1 & sleep 5 ; kill -9 $! - -#uqmi -s -d "$device" --network-register > /dev/null 2>&1 - -log "Waiting for network registration" -td=0 -while uqmi -s -d "$device" --get-serving-system | grep '"searching"' > /dev/null; do - sleep 5; - tid=$((tid + 1)) - if [ $tid -gt 2 ]; then - uqmi -s -d "$device" --stop-network 0xffffffff --autoconnect > /dev/null & sleep 10 ; kill -9 $! - exit 1 - fi -done - -cid=`uqmi -s -d "$device" --get-client-id wds` -[ $? -ne 0 ] && { - log "Unable to obtain client ID" - ret=1 -} - -uqmi -s -d "$device" --set-client-id wds,"$cid" --set-ip-family ipv4 > /dev/null - -isplist=$(uci -q get modem.modeminfo$CURRMODEM.isplist) -apn2=$(uci -q get modem.modeminfo$CURRMODEM.apn2) -for isp in $isplist - do - NAPN=$(echo $isp | cut -d, -f2) - NPASS=$(echo $isp | cut -d, -f4) - CID=$(echo $isp | cut -d, -f5) - NUSER=$(echo $isp | cut -d, -f6) - NAUTH=$(echo $isp | cut -d, -f7) - if [ "$NPASS" = "nil" ]; then - NPASS="NIL" - fi - if [ "$NUSER" = "nil" ]; then - NUSER="NIL" - fi - if [ "$NAUTH" = "nil" ]; then - NAUTH="0" - fi - username="$NUSER" - password="$NPASS" - auth=$NAUTH - case $auth in - "0" ) - auth="none" - ;; - "1" ) - auth="pap" - ;; - "2" ) - auth="chap" - ;; - "*" ) - auth="none" - ;; - esac - - if [ ! -e /etc/config/isp ]; then - log "Connect to network using $NAPN" - else - log "Connect to network" - fi - - if [ ! -e /etc/config/isp ]; then - log "$NAPN $auth $username $password" - fi - - conn=0 - tidd=0 - tcnt=4 - while true; do - ST=$(uqmi -s -d "$device" --set-client-id wds,"$cid" --start-network ${NAPN:+--apn $NAPN} ${auth:+--auth-type $auth} \ - ${username:+--username $username} ${password:+--password $password}) - log "Connection returned : $ST" - CONN=$(uqmi -s -d "$device" --get-data-status) - log "Status is $CONN" - if [[ $(echo "$CONN" | grep -o "disconnected") ]]; then - sleep 1 - tidd=$((tidd + 1)) - if [ $tidd -gt $tcnt ]; then - break - fi - else - conn=1 - break - fi - done - if [ $conn -eq 1 ]; then - break; - fi - done - -if [[ -z $(echo "$CONN" | grep -o "disconnected") ]]; then - ret=0 - - uci set modem.modem$CURRMODEM.mdevice=$device - uci set modem.modem$CURRMODEM.mcid=$cid - uci set modem.modem$CURRMODEM.mapn=$NAPN - uci set modem.modem$CURRMODEM.mauth=$auth - uci set modem.modem$CURRMODEM.musername=$username - uci set modem.modem$CURRMODEM.mpassword=$password - uci commit modem - - CONN4=$(uqmi -s -d "$device" --set-client-id wds,"$cid" --get-current-settings) - log "GET-CURRENT-SETTINGS is $CONN4" - - if [ $enb = "1" ]; then - cid6=`uqmi -s -d "$device" --get-client-id wds` - [ $? -ne 0 ] && { - log "Unable to obtain client ID" - ret=1 - } - - uqmi -s -d "$device" --set-client-id wds,"$cid6" --set-ip-family ipv6 > /dev/null - ST6=$(uqmi -s -d "$device" --set-client-id wds,"$cid6" --start-network ${NAPN:+--apn $NAPN} ${auth:+--auth-type $auth} \ - ${username:+--username $username} ${password:+--password $password}) - log "IPv6 Connection returned : $ST6" - CONN6=$(uqmi -s -d "$device" --set-client-id wds,"$cid6" --get-current-settings) - CONF6=$(jsonfilter -s $CONN6 -e '@.ipv6') - if [ -n "$CONF6" ];then - log "IPv6 settings are $CONF6" - touch /tmp/ipv6supp$INTER - else - rm -f /tmp/ipv6supp$INTER - fi - fi - - if [ $DATAFORM = '"raw-ip"' ]; then - log "Handle raw-ip" - json_load "$CONN4" - json_select ipv4 - json_get_vars ip subnet gateway dns1 dns2 - if [ $enb = "1" ]; then - if [ -n "$CONF6" ]; then - json_load "$CONN6" - json_select ipv6 - json_get_var ip_6 ip - json_get_var gateway_6 gateway - json_get_var dns1_6 dns1 - json_get_var dns2_6 dns2 - json_get_var ip_prefix_length ip-prefix-length - fi - fi - - if [ -s /tmp/v4dns$INTER -o -s /tmp/v6dns$INTER ]; then - pdns=1 - if [ -s /tmp/v4dns$INTER ]; then - v4dns=$(cat /tmp/v4dns$INTER 2>/dev/null) - fi - if [ $enb = "1" ]; then - if [ -s /tmp/v6dns$INTER ]; then - v6dns=$(cat /tmp/v6dns$INTER 2>/dev/null) - fi - fi - else - v4dns="$dns1 $dns2" - if [ $enb = "1" ]; then - v6dns="$dns1_6 $dns2_6" - echo "$v6dns" > /tmp/v6dns$INTER - fi - fi - - if [ $DHCP -eq 0 ]; then - log Applying IP settings to wan$INTER - uci delete network.wan$INTER - uci set network.wan$INTER=interface - uci set network.wan$INTER.proto=static - uci set network.wan$INTER.${ifname1}=$ifname - uci set network.wan$INTER.metric=$INTER"0" - uci set network.wan$INTER.ipaddr=$ip/$subnet - uci set network.wan$INTER.gateway='0.0.0.0' - uci set network.wan$INTER.dns="$v4dns" - uci commit network - uci set modem.modem$CURRMODEM.interface=$ifname - uci commit modem - else - proto_init_update "$ifname" 1 - proto_set_keep 1 - proto_add_ipv4_address "$ip" "$subnet" - proto_add_ipv4_route "0.0.0.0" 0 - for DNSV in $(echo "$v4dns"); do - proto_add_dns_server "$DNSV" - done - proto_send_update "$interface" - fi - fi -else - uqmi -s -d "$device" --stop-network 0xffffffff --autoconnect > /dev/null & sleep 10 ; kill -9 $! - ret=1 -fi - -exit $ret diff --git a/rooter/0optionalapps/bwallocate/Makefile b/rooter/0optionalapps/bwallocate/Makefile deleted file mode 100644 index 183c85d..0000000 --- a/rooter/0optionalapps/bwallocate/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -#Owned by DairyMan@Whirlpool -# -#Copyright GNU act. -include $(TOPDIR)/rules.mk - -PKG_NAME:=bwallocate -PKG_VERSION:=4.500 -PKG_RELEASE:=1 - -PKG_MAINTAINER:=Created by DM/makefile by Cobia@whirlpool -include $(INCLUDE_DIR)/package.mk - -define Package/bwallocate - SECTION:=utils - CATEGORY:=ROOter - SUBMENU:=Optional Applications - DEPENDS:=+ext-throttle +msmtp - TITLE:=Install scripts for Bandwidth Allocation - PKGARCH:=all -endef - -define Package/bwallocate/description - Install scripts for Bandwidth Allocation -endef - - -define Build/Compile -endef - -define Package/bwallocate/install - $(CP) ./files/* $(1)/ -endef - -$(eval $(call BuildPackage,bwallocate)) diff --git a/rooter/0optionalapps/bwallocate/files/etc/init.d/textbwint b/rooter/0optionalapps/bwallocate/files/etc/init.d/textbwint deleted file mode 100644 index b74e85a..0000000 --- a/rooter/0optionalapps/bwallocate/files/etc/init.d/textbwint +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh /etc/rc.common - -START=88 - -log() { - logger -t "TEXTING" "$@" -} - -start() -{ - uci set bwmon.general.enabled="1" - uci commit bwmon - /usr/lib/bwmon/textbw.sh & -} diff --git a/rooter/0optionalapps/bwallocate/files/usr/lib/lua/luci/controller/bwallocate.lua b/rooter/0optionalapps/bwallocate/files/usr/lib/lua/luci/controller/bwallocate.lua deleted file mode 100644 index a26d6fd..0000000 --- a/rooter/0optionalapps/bwallocate/files/usr/lib/lua/luci/controller/bwallocate.lua +++ /dev/null @@ -1,22 +0,0 @@ -module("luci.controller.bwallocate", package.seeall) - -I18N = require "luci.i18n" -translate = I18N.translate - -function index() - local lock = luci.model.uci.cursor():get("custom", "menu", "full") - local multilock = luci.model.uci.cursor():get("custom", "multiuser", "multi") or "0" - local rootlock = luci.model.uci.cursor():get("custom", "multiuser", "root") or "0" - if (multilock == "0") or (multilock == "1" and rootlock == "1") then - if lock == "1" then - local lock1 = luci.model.uci.cursor():get("custom", "bwallocate", "lock") - if lock1 == "1" then - if (multilock == "1" and rootlock == "1") then - entry({"admin", "adminmenu", "bwmenu"}, cbi("fullmenu/bwmenu"), translate("Bandwidth Allocation"), 6) - else - entry({"admin", "adminmenu", "bwmenu"}, cbi("fullmenu/bwmenu"), translate("---Bandwidth Allocation"), 6) - end - end - end - end -end \ No newline at end of file diff --git a/rooter/0optionalapps/bwallocate/files/usr/lib/lua/luci/model/cbi/fullmenu/bwmenu.lua b/rooter/0optionalapps/bwallocate/files/usr/lib/lua/luci/model/cbi/fullmenu/bwmenu.lua deleted file mode 100644 index 9fcc8d9..0000000 --- a/rooter/0optionalapps/bwallocate/files/usr/lib/lua/luci/model/cbi/fullmenu/bwmenu.lua +++ /dev/null @@ -1,267 +0,0 @@ -local utl = require "luci.util" - -m = Map("custom", translate("Bandwidth Allocation"), translate("Set Maximum Bandwidth Usage before Internet blockage")) - -m.on_after_save = function(self) - luci.sys.call("/usr/lib/bwmon/allocate.sh 0 &") -end - -s = m:section(TypedSection, "bwallocate", translate("Allocation Settings")) -s.anonymous = true -s.addremove = false - -s:option(Flag, "enabled", translate("Allocation Enabled : ")) - -maxim = s:option(Value, "allocate", translate("Maximum Bandwidth in GB : "), translate("Maximum amount of bandwidth that can be used before Internet is affected")); -maxim.rmempty = true; -maxim.optional=false; -maxim.default="1000"; -maxim.datatype = "and(uinteger,min(1))" - -rollover = s:option(ListValue, "rollover", translate("Rollover Day : "), translate("Day of the month when bandwidth usage resets")) -rollover.rmempty = true -rollover:value("1", "1st") -rollover:value("2", "2nd") -rollover:value("3", "3rd") -rollover:value("4", "4th") -rollover:value("5", "5th") -rollover:value("6", "6th") -rollover:value("7", "7th") -rollover:value("8", "8th") -rollover:value("9", "9th") -rollover:value("10", "10th") -rollover:value("11", "11th") -rollover:value("12", "12th") -rollover:value("13", "13th") -rollover:value("14", "14th") -rollover:value("15", "15th") -rollover:value("16", "16th") -rollover:value("17", "17th") -rollover:value("18", "18th") -rollover:value("19", "19th") -rollover:value("20", "20th") -rollover:value("21", "21th") -rollover:value("22", "22th") -rollover:value("23", "23th") -rollover:value("24", "24th") -rollover:value("25", "25th") -rollover:value("26", "26th") -rollover:value("27", "27th") -rollover:value("28", "28th") -rollover.default = "1" - -act = s:option(ListValue, "action", translate("Internet Action : "), translate("Action taken when allocation is exceeded")) -act.rmempty = true -act:value("0", "Internet Blocked") -act:value("1", "Internet Throttled") -act.default = "0" - -down = s:option(Value, "down", translate("Download Speed in Mbps :")); -down.optional=false; -down.rmempty = true; -down.datatype = "and(uinteger,min(1),max(999))" -down:depends("action", "1") -down.default = "5" - -up = s:option(Value, "up", translate("Upload Speed in Mbps :")); -up.optional=false; -up.rmempty = true; -up.datatype = "and(uinteger,min(1),max(999))" -up:depends("action", "1") -up.default = "2" - -s = m:section(TypedSection, "texting", translate("Text/Email Settings")) -s.anonymous = true -s.addremove = false - -aact = s:option(ListValue, "text", translate("Enable : "), translate("Enable Sending Text or Email Information")) -aact.rmempty = true -aact:value("0", "No") -aact:value("1", "Yes") -aact.default = "0" - - -pph = s:option(Value, "ident", translate("Identifier :")); -pph.optional=false; -pph.rmempty = true; -pph:depends("text", "1") -pph.default = "xxx" - - - -ct = s:option(ListValue, "method", translate("Criteria : "), translate("Criteria used to determine when to send information")) -ct.rmempty = true -ct:value("0", translate("By Specified Time Interval")) -ct:value("1", translate("By Amount Used")) -ct:value("2", translate("By Percentage Used")) -ct.default = "0" -ct:depends("text", "1") - -sdhour = s:option(ListValue, "time", translate("Sending Time :"), translate("Time to send information")) -sdhour.rmempty = true -sdhour:value("0", "12:00 AM") -sdhour:value("1", "12:15 AM") -sdhour:value("2", "12:30 AM") -sdhour:value("3", "12:45 AM") -sdhour:value("4", "01:00 AM") -sdhour:value("5", "01:15 AM") -sdhour:value("6", "01:30 AM") -sdhour:value("7", "01:45 AM") -sdhour:value("8", "02:00 AM") -sdhour:value("9", "02:15 AM") -sdhour:value("10", "02:30 AM") -sdhour:value("11", "02:45 AM") -sdhour:value("12", "03:00 AM") -sdhour:value("13", "03:15 AM") -sdhour:value("14", "03:30 AM") -sdhour:value("15", "03:45 AM") -sdhour:value("16", "04:00 AM") -sdhour:value("17", "04:15 AM") -sdhour:value("18", "04:30 AM") -sdhour:value("19", "04:45 AM") -sdhour:value("20", "05:00 AM") -sdhour:value("21", "05:15 AM") -sdhour:value("22", "05:30 AM") -sdhour:value("23", "05:45 AM") -sdhour:value("24", "06:00 AM") -sdhour:value("25", "06:15 AM") -sdhour:value("26", "06:30 AM") -sdhour:value("27", "06:45 AM") -sdhour:value("28", "07:00 AM") -sdhour:value("29", "07:15 AM") -sdhour:value("30", "07:30 AM") -sdhour:value("31", "07:45 AM") -sdhour:value("32", "08:00 AM") -sdhour:value("33", "08:15 AM") -sdhour:value("34", "08:30 AM") -sdhour:value("35", "08:45 AM") -sdhour:value("36", "09:00 AM") -sdhour:value("37", "09:15 AM") -sdhour:value("38", "09:30 AM") -sdhour:value("39", "09:45 AM") -sdhour:value("40", "10:00 AM") -sdhour:value("41", "10:15 AM") -sdhour:value("42", "10:30 AM") -sdhour:value("43", "10:45 AM") -sdhour:value("44", "11:00 AM") -sdhour:value("45", "11:15 AM") -sdhour:value("46", "11:30 AM") -sdhour:value("47", "11:45 AM") -sdhour:value("48", "12:00 PM") -sdhour:value("49", "12:15 PM") -sdhour:value("50", "12:30 PM") -sdhour:value("51", "12:45 PM") -sdhour:value("52", "01:00 PM") -sdhour:value("53", "01:15 PM") -sdhour:value("54", "01:30 PM") -sdhour:value("55", "01:45 PM") -sdhour:value("56", "02:00 PM") -sdhour:value("57", "02:15 PM") -sdhour:value("58", "02:30 PM") -sdhour:value("59", "02:45 PM") -sdhour:value("60", "03:00 PM") -sdhour:value("61", "03:15 PM") -sdhour:value("62", "03:30 PM") -sdhour:value("63", "03:45 PM") -sdhour:value("64", "04:00 PM") -sdhour:value("65", "04:15 PM") -sdhour:value("66", "04:30 PM") -sdhour:value("67", "04:45 PM") -sdhour:value("68", "05:00 PM") -sdhour:value("69", "05:15 PM") -sdhour:value("70", "05:30 PM") -sdhour:value("71", "05:45 PM") -sdhour:value("72", "06:00 PM") -sdhour:value("73", "06:15 PM") -sdhour:value("74", "06:30 PM") -sdhour:value("75", "06:45 PM") -sdhour:value("76", "07:00 PM") -sdhour:value("77", "07:15 PM") -sdhour:value("78", "07:30 PM") -sdhour:value("79", "07:45 PM") -sdhour:value("80", "08:00 PM") -sdhour:value("81", "08:15 PM") -sdhour:value("82", "08:30 PM") -sdhour:value("83", "08:45 PM") -sdhour:value("84", "09:00 PM") -sdhour:value("85", "09:15 PM") -sdhour:value("86", "09:30 PM") -sdhour:value("87", "09:45 PM") -sdhour:value("88", "10:00 PM") -sdhour:value("89", "10:15 PM") -sdhour:value("90", "10:30 PM") -sdhour:value("91", "10:45 PM") -sdhour:value("92", "11:00 PM") -sdhour:value("93", "11:15 PM") -sdhour:value("94", "11:30 PM") -sdhour:value("95", "11:45 PM") -sdhour:depends("text", "1") -sdhour.default = "48" - -xct = s:option(ListValue, "days", translate("Interval : "), translate("Number of days between sending information")) -xct.rmempty = true -xct:value("1", translate("Every Day")) -xct:value("2", translate("Every 2 Days")) -xct:value("5", translate("Every 5 Days")) -xct:value("10", translate("Every 10 Days")) -xct:value("15", translate("Every 15 Days")) -xct.default = "5" -xct:depends("method", "0") - -xxct = s:option(ListValue, "increment", translate("Increment : "), translate("Amount Used between sending information")) -xxct.rmempty = true -xxct:value("50", translate("Every 50 GB")) -xxct:value("75", translate("Every 75 GB")) -xxct:value("100", translate("Every 100 GB")) -xxct.default = "50" -xxct:depends("method", "1") - -ph1 = s:option(ListValue, "percent", translate("Percentage Used :")); -ph1.optional=false; -ph1.rmempty = true; -ph1:value("10", translate("10%")) -ph1:value("20", translate("20%")) -ph1:value("30", translate("30%")) -ph1:value("40", translate("40%")) -ph1:value("50", translate("50%")) -ph1:value("60", translate("60%")) -ph1:value("70", translate("70%")) -ph1:value("80", translate("80%")) -ph1:value("90", translate("90%")) -ph1:depends("method", "2") -ph1.default = "90" - ---b3 = s:option(DummyValue, "blank", " "); - -btn = s:option(Button, "_btn", translate(" ")) -btn.inputtitle = translate("Send Test of Text or Email") -btn.inputstyle = "apply" -btn:depends("text", "1") -function btn.write() - luci.sys.call("/usr/lib/bwmon/dotext.sh &") -end - -b4 = s:option(DummyValue, "blank", " "); - -ct = s:option(ListValue, "tore", translate("Sending Method : "), translate("Method used to send information")) -ct.rmempty = true -ct:value("0", translate("By Text")) -ct:value("1", translate("By Email")) -ct.default = "0" -ct:depends("text", "1") - -ph = s:option(Value, "phone", translate("Phone Number :")); -ph.optional=false; -ph.rmempty = true; -ph.datatype = "phonedigit" -ph:depends("tore", "0") -ph.default = "12223334444" - -ph1 = s:option(Value, "email", translate("Email Address :")); -ph1.optional=false; -ph1.rmempty = true; -ph1:depends("tore", "1") -ph1.default = "jdoe@domain.com" - - -return m \ No newline at end of file diff --git a/rooter/0optionalapps/bwmon/Makefile b/rooter/0optionalapps/bwmon/Makefile deleted file mode 100644 index c413b2f..0000000 --- a/rooter/0optionalapps/bwmon/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -#Owned by DairyMan@Whirlpool -# -#Copyright GNU act. -include $(TOPDIR)/rules.mk - -PKG_NAME:=bwmon -PKG_VERSION:=1.000 -PKG_RELEASE:=1 - -PKG_MAINTAINER:=Created by DM/makefile by Cobia@whirlpool -include $(INCLUDE_DIR)/package.mk - -define Package/bwmon - SECTION:=utils - CATEGORY:=ROOter - SUBMENU:=Optional Applications - TITLE:=Install Bandwidth Monitor - PKGARCH:=all -endef - -define Package/bwmon/description - Helper scripts to install Bandwidth Monitor on ROOter -endef - - -define Build/Compile -endef - -define Package/bwmon/install - $(CP) ./files/* $(1)/ - - -endef - -$(eval $(call BuildPackage,bwmon)) diff --git a/rooter/0optionalapps/bwmon/files/etc/config/bwmon b/rooter/0optionalapps/bwmon/files/etc/config/bwmon deleted file mode 100644 index 9d45a80..0000000 --- a/rooter/0optionalapps/bwmon/files/etc/config/bwmon +++ /dev/null @@ -1,9 +0,0 @@ - -config general 'general' - option external '0' - option backup '30' - option enabled '1' - - -config bwwan 'bwwan' - option wan '0' \ No newline at end of file diff --git a/rooter/0optionalapps/bwmon/files/etc/init.d/bwmon b/rooter/0optionalapps/bwmon/files/etc/init.d/bwmon deleted file mode 100644 index 0dc2498..0000000 --- a/rooter/0optionalapps/bwmon/files/etc/init.d/bwmon +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh /etc/rc.common -# Copyright (C) 2006 OpenWrt.org - -START=60 - -start() { - WX=$(uci -q get custom.bwallocate.lock) - if [ "$WX" = "1" ]; then - uci set bwmon.general.enabled=1 - uci commit bwmon - fi - /usr/lib/bwmon/wrtbwmon.sh & - /usr/lib/bwmon/create.sh & -} - -stop() { - rmdir -f /tmp/WRTbmon -} \ No newline at end of file diff --git a/rooter/0optionalapps/bwmon/files/lib/upgrade/keep.d/bwmon b/rooter/0optionalapps/bwmon/files/lib/upgrade/keep.d/bwmon deleted file mode 100644 index c664559..0000000 --- a/rooter/0optionalapps/bwmon/files/lib/upgrade/keep.d/bwmon +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/bwmon/data/ diff --git a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/allocate.sh b/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/allocate.sh deleted file mode 100644 index 58b4c22..0000000 --- a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/allocate.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -log() { - logger -t "allocate" "$@" -} - -amount=$1 - -if [ $amount != "0" ]; then - uci set custom.bwallocate.allocate=$amount - uci commit custom -else - sleep 3 -fi -result=`ps | grep -i "create_data.lua" | grep -v "grep" | wc -l` -while [ $result -ge 1 ]; do - sleep 2 - result=`ps | grep -i "create_data.lua" | grep -v "grep" | wc -l` -done - -lua /usr/lib/bwmon/create_data.lua diff --git a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/amtleft.lua b/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/amtleft.lua deleted file mode 100644 index f2f8a17..0000000 --- a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/amtleft.lua +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/lua - -function ltrim(s) - return s:match'^%s*(.*)' -end - -function calc(total) - if total < 1000 then - tstr = string.format("%.2f", total) - tfm = " K" - else - if total < 1000000 then - tstr = string.format("%.2f", total/1000) - tfm = " MB" - else - tstr = string.format("%.2f", total/1000000) - tfm = " GB" - end - end - str = tstr .. tfm - return ltrim(str) -end - -aamt = arg[1] -uamt = arg[2] -if uamt > aamt then - amt = uamt - aamt - amts = calc(amt) - amts = "-" .. amts -else - amt = aamt - uamt - amts = calc(math.abs(amt)) -end -tfile = io.open("/tmp/amtleft", "w") -tfile:write(amts, "\n") -tfile:close() \ No newline at end of file diff --git a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/backup-daily.lua b/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/backup-daily.lua deleted file mode 100644 index c9f579e..0000000 --- a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/backup-daily.lua +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/lua - -dailyUsageDB = arg[1] - -bw = {} -maclist = {} - -file = io.open(dailyUsageDB, "r") -i = 0 -repeat - line = file:read("*line") - if line == nil then - break - end - s, e = line:find("\"mac\":\"") - bs, be = line:find("\"", e+1) - mac = line:sub(e+1, bs-1) - if bw[mac] == nil then - maclist[i] = mac - i = i + 1 - bw[mac] = {} - bw[mac]['down'] = 0 - bw[mac]['offdown'] = 0 - bw[mac]['up'] = 0 - bw[mac]['offup'] = 0 - end - s, e = line:find("\"down\":\"") - bs, be = line:find("\"", e+1) - down = tonumber(line:sub(e+1, bs-1)) - bw[mac]['down'] = bw[mac]['down'] + down - s, e = line:find("\"up\":\"") - bs, be = line:find("\"", e+1) - up = tonumber(line:sub(e+1, bs-1)) - bw[mac]['up'] = bw[mac]['up'] + up - s, e = line:find("\"offdown\":\"") - bs, be = line:find("\"", e+1) - offdown = tonumber(line:sub(e+1, bs-1)) - bw[mac]['offdown'] = bw[mac]['offdown'] + offdown - s, e = line:find("\"offup\":\"") - bs, be = line:find("\"", e+1) - offup = tonumber(line:sub(e+1, bs-1)) - bw[mac]['offup'] = bw[mac]['offup'] + offup - s, e = line:find("\"ip\":\"") - bs, be = line:find("\"", e+1) - bw[mac]['ip'] = line:sub(e+1, bs-1) - s, e = line:find("\"name\":\"") - bs, be = line:find("\"", e+1) - bw[mac]['name'] = line:sub(e+1, bs-1) -until 1==0 -file:close() - -j=0 -file = io.open(dailyUsageDB .. ".bk", "w") -while maclist[j] ~= nil do - mac = maclist[j] - dline = "\"mac\":\"" .. mac .. "\",\"down\":\"" .. bw[mac]['down'] .. "\",\"up\":\"" .. bw[mac]['up'] .. "\",\"offdown\":\"0\",\"offup\":\"0\",\"ip\":\"" .. bw[mac]['ip'] .. "\",\"name\":\"" .. bw[mac]['name'] .. "\"" - file:write(dline, "\n") - j = j + 1 -end -file:close() - diff --git a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/backup-mon.lua b/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/backup-mon.lua deleted file mode 100644 index 5d8e883..0000000 --- a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/backup-mon.lua +++ /dev/null @@ -1,81 +0,0 @@ -#!/usr/bin/lua - -monthUsageDB = arg[1] - -tfile = io.open(monthUsageDB .. ".bk", "w") -tfile:close() - -file = io.open(monthUsageDB, "r") - -repeat - line = file:read("*line") - if line == nil then - break - end - s, e = line:find("start day") - if s ~= nil then - maclist = {} - bw = {} - i = 0 - startday = line - repeat - line = file:read("*line") - if line == nil then - break - end - s, e = line:find("end day") - if s ~= nil then - endday = line - break - end - s, e = line:find("\"mac\":\"") - bs, be = line:find("\"", e+1) - mac = line:sub(e+1, bs-1) - if bw[mac] == nil then - maclist[i] = mac - i = i + 1 - bw[mac] = {} - bw[mac]['down'] = 0 - bw[mac]['offdown'] = 0 - bw[mac]['up'] = 0 - bw[mac]['offup'] = 0 - end - s, e = line:find("\"down\":\"") - bs, be = line:find("\"", e+1) - down = tonumber(line:sub(e+1, bs-1)) - bw[mac]['down'] = bw[mac]['down'] + down - s, e = line:find("\"up\":\"") - bs, be = line:find("\"", e+1) - up = tonumber(line:sub(e+1, bs-1)) - bw[mac]['up'] = bw[mac]['up'] + up - s, e = line:find("\"offdown\":\"") - bs, be = line:find("\"", e+1) - offdown = tonumber(line:sub(e+1, bs-1)) - bw[mac]['offdown'] = bw[mac]['offdown'] + offdown - s, e = line:find("\"offup\":\"") - bs, be = line:find("\"", e+1) - offup = tonumber(line:sub(e+1, bs-1)) - bw[mac]['offup'] = bw[mac]['offup'] + offup - s, e = line:find("\"ip\":\"") - bs, be = line:find("\"", e+1) - bw[mac]['ip'] = line:sub(e+1, bs-1) - s, e = line:find("\"name\":\"") - bs, be = line:find("\"", e+1) - bw[mac]['name'] = line:sub(e+1, bs-1) - until 1==0 - -- day data - j=0 - tfile = io.open(monthUsageDB .. ".bk", "a") - tfile:write(startday, "\n") - while maclist[j] ~= nil do - mac = maclist[j] - dline = "\"mac\":\"" .. mac .. "\",\"down\":\"" .. bw[mac]['down'] .. "\",\"up\":\"" .. bw[mac]['up'] .. "\",\"offdown\":\"0\",\"offup\":\"0\",\"ip\":\"" .. bw[mac]['ip'] .. "\",\"name\":\"" .. bw[mac]['name'] .. "\"" - tfile:write(dline, "\n") - j = j + 1 - end - tfile:write(endday, "\n") - tfile:close() - end - -until 1==0 -file:close() \ No newline at end of file diff --git a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/backup.sh b/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/backup.sh deleted file mode 100644 index dba2368..0000000 --- a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/backup.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/sh - -log() { - logger -t "wrtbwmon" "$@" -} - -# parameters -# -btype=$1 -cDay=$2 -monthlyUsageDB=$3 -dailyUsageDB=$4 -monthlyUsageBack=$5 -dailyUsageBack=$6 -pDay=$7 - -/usr/lib/bwmon/backup-daily.lua $dailyUsageDB -/usr/lib/bwmon/backup-mon.lua $monthlyUsageDB -cp -f $monthlyUsageDB".bk" $monthlyUsageDB -cp -f $dailyUsageDB".bk" $dailyUsageDB - -echo "start day $cDay" >> $monthlyUsageDB".bk" -cat $dailyUsageDB".bk" >> $monthlyUsageDB".bk" -echo "end day $cDay" >> $monthlyUsageDB".bk" - -enb=$(uci -q get bwmon.general.enabled) - -if [ $btype = "backup" ]; then - if [ "$enb" = "1" ]; then - cp -f $monthlyUsageDB".bk" $monthlyUsageBack - cp -f $dailyUsageDB".bk" $dailyUsageBack - fi -else - if [ $btype = "daily" ]; then - cp -f $monthlyUsageDB".bk" $monthlyUsageDB - if [ "$enb" = "1" ]; then - cp -f $monthlyUsageDB".bk" $monthlyUsageBack - fi - fi -fi - -rm -f $dailyUsageDB".bk" - -bwday=$(uci -q get modem.modeminfo1.bwday) -if [ ! -z "$bwday" ]; then - if [ $bwday = $pDay -a $bwday != "0" ]; then - if [ -e /usr/lib/bwmon/sendsms ]; then - /usr/lib/bwmon/sendsms.sh - fi - fi -fi \ No newline at end of file diff --git a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/block b/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/block deleted file mode 100644 index ba7fb02..0000000 --- a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/block +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh - -internet_block() -{ - enable=$1 - iptables -w -S ACCOUNTING_BLOCK > /tmp/iptables.block.$$ - if [ "$enable" = 1 ] - then - # insert the block rule - check=$(cat /tmp/iptables.block.$$ | grep -e "-m comment --comment internet_block -j DROP") - if [ -z "$check" ] - then - iptables -w -I ACCOUNTING_BLOCK -m comment --comment internet_block -j DROP 2>/dev/null - fi - else - # remove the block rule - count=$(cat /tmp/iptables.block.$$ | grep -e "-m comment --comment internet_block -j DROP" | wc -l) - for i in $(seq 1 $count) - do - iptables -w -D ACCOUNTING_BLOCK -m comment --comment internet_block -j DROP 2>/dev/null - done - fi - - rm -rf /tmp/iptables.block.$$ -} - -internet_block $1 - diff --git a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/change.sh b/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/change.sh deleted file mode 100644 index 003fec7..0000000 --- a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/change.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -log() { - logger -t "wrtbwmon" "$@" -} - -enable=$1 - -WX=$(uci -q get custom.bwallocate.lock) -if [ "$WX" = "1" ]; then - enable="1" -fi -uci set bwmon.general.enabled=$enable -uci commit bwmon diff --git a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/chksms.sh b/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/chksms.sh deleted file mode 100644 index 20b3376..0000000 --- a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/chksms.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter -ROOTER_LINK="/tmp/links" - -CURRMODEM=1 - -rm -f /tmp/texting -CPORT=$(uci -q get modem.modem$CURRMODEM.commport) -if [ -z $CPORT ]; then - return -fi -OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "smschk.gcom" "$CURRMODEM") -ERROR="ERROR" -if `echo ${OX} | grep "${ERROR}" 1>/dev/null 2>&1` -then - return -fi -echo "0" > /tmp/texting -uci set modem.general.smsnum='1' -uci commit modem \ No newline at end of file diff --git a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/cleanup.lua b/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/cleanup.lua deleted file mode 100644 index 2c5d764..0000000 --- a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/cleanup.lua +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/lua - -filepost = "-mac_data.js" -dirname = '/usr/lib/bwmon/data' - -function clean() - nummon = 0 - months = {} - f = io.popen('/bin/ls ' .. dirname) - for name in f:lines() do - s, e = name:find(filepost) - if s ~= nil then - nummon = nummon + 1 - months[nummon] = dirname .. "/" .. name - end - end - f:close() - - count = 1 - if nummon > 0 then - for i=nummon,1,-1 do - if count > 3 then - os.execute("rm -f " .. months[i]) - end - count = count + 1 - end - end -end - -clean() -dirname = '/tmp/bwmon/data' -clean() \ No newline at end of file diff --git a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/create.sh b/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/create.sh deleted file mode 100644 index 348d873..0000000 --- a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/create.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh - -log() { - logger -t "createdata" "$@" -} - -lua /usr/lib/bwmon/create_data.lua -sleep 60 -while [ true ] -do - result=`ps | grep -i "create_data.lua" | grep -v "grep" | wc -l` - if [ $result -lt 1 ]; then - lua /usr/lib/bwmon/create_data.lua - fi - sleep 60 -done \ No newline at end of file diff --git a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/create_data.lua b/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/create_data.lua deleted file mode 100644 index fc3fba8..0000000 --- a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/create_data.lua +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/bin/lua - -dirname = '/tmp/bwmon/data' -filepost = "-mac_data.js.bk" -bw = {} -maclist = {} -devices = {} -totaldevices = 0 -totaldown = 0 -totalup = 0 -total = 0 - -printf = function(s,...) - local ss = s:format(...) - os.execute("/usr/lib/rooter/logprint.sh " .. ss) -end - -function ltrim(s) - return s:match'^%s*(.*)' -end - -function calc(total) - if total < 1000 then - tstr = string.format("%.2f", total) - tfm = " K" - else - if total < 1000000 then - tstr = string.format("%.2f", total/1000) - tfm = " MB" - else - tstr = string.format("%.2f", total/1000000) - tfm = " GB" - end - end - str = tstr .. tfm - return ltrim(str) -end - -function monthly(datafile) - file = io.open(datafile, "r") - i = 0 - dayx = 0 - repeat - line = file:read("*line") - if line == nil then - break - end - s, e = line:find("start day") - if s ~= nil then - dayx = dayx + 1 - repeat - line = file:read("*line") - s, e = line:find("end day") - if s ~= nil then - break - end - s, e = line:find("\"mac\":\"") - bs, be = line:find("\"", e+1) - mac = line:sub(e+1, bs-1) - if bw[mac] == nil then - maclist[i] = mac - i = i + 1 - bw[mac] = {} - bw[mac]['down'] = 0 - bw[mac]['offdown'] = 0 - bw[mac]['up'] = 0 - bw[mac]['offup'] = 0 - end - s, e = line:find("\"down\":\"") - bs, be = line:find("\"", e+1) - down = tonumber(line:sub(e+1, bs-1)) - bw[mac]['down'] = bw[mac]['down'] + down - s, e = line:find("\"up\":\"") - bs, be = line:find("\"", e+1) - up = tonumber(line:sub(e+1, bs-1)) - bw[mac]['up'] = bw[mac]['up'] + up - s, e = line:find("\"offdown\":\"") - bs, be = line:find("\"", e+1) - offdown = tonumber(line:sub(e+1, bs-1)) - bw[mac]['offdown'] = bw[mac]['offdown'] + offdown - s, e = line:find("\"offup\":\"") - bs, be = line:find("\"", e+1) - offup = tonumber(line:sub(e+1, bs-1)) - bw[mac]['offup'] = bw[mac]['offup'] + offup - s, e = line:find("\"ip\":\"") - bs, be = line:find("\"", e+1) - bw[mac]['ip'] = line:sub(e+1, bs-1) - s, e = line:find("\"name\":\"") - bs, be = line:find("\"", e+1) - bw[mac]['name'] = line:sub(e+1, bs-1) - until 1==0 - end - until 1==0 - file:close() - return dayx -end - -function totals(bw, maclist, dayz) - totaldown = 0 - totalup = 0 - utotaldown = 0 - utotalup = 0 - j=0 - while maclist[j] ~= nil do - totaldown = totaldown + bw[maclist[j]]['down'] - totalup = totalup + bw[maclist[j]]['up'] - utotaldown = utotaldown + bw[maclist[j]]['offdown'] - utotalup = utotalup + bw[maclist[j]]['offup'] - j = j + 1 - end - total = totalup + totaldown - ptotal = (total / dayz) * 30 -end - -function showdevices(bw, maclist) - k = 0 - while maclist[k] ~= nil do - k = k + 1 - end - if k > 0 then - j = 0 - while maclist[j] ~= nil do - dtot = bw[maclist[j]]['down'] + bw[maclist[j]]['up'] - devices[j] = bw[maclist[j]]['ip'] .."|" .. maclist[j] - devices[j] = devices[j] .. "|" .. calc(bw[maclist[j]]['down']) .. "|" .. calc(bw[maclist[j]]['up']) - devices[j] = devices[j] .. "|" .. calc(dtot) .. "|" .. bw[maclist[j]]['name'] - j = j + 1 - end - end - totaldevices = j -end - -os.execute("echo 0 > /tmp/lockbw") -dataname = nil -f = io.popen('/bin/ls ' .. dirname) -for name in f:lines() do - s, e = name:find(filepost) - if s ~= nil then - dataname = dirname .. "/" .. name - end -end -f:close() - -if dataname ~= nil then - days = monthly(dataname) - totals(bw, maclist, days) - tfile = io.open("/tmp/bwdata", "w") - tfile:write(days, "\n") - tfile:write(tostring(total), "\n") - tfile:write(calc(total), "\n") - tfile:write(tostring(totaldown), "\n") - tfile:write(calc(totaldown), "\n") - tfile:write(tostring(totalup), "\n") - tfile:write(calc(totalup), "\n") - tfile:write(tostring(ptotal), "\n") - tfile:write(calc(ptotal), "\n") - -- - -- allocated bandwidth in K - -- - bwallo='rm -f /tmp/bwallo; x=$(uci -q get custom.bwallocate.allocate); echo $x >> /tmp/bwallo; x=$(uci -q get custom.bwallocate.password); echo $x >> /tmp/bwallo' - os.execute(bwallo) - file = io.open("/tmp/bwallo", "r") - if file == nil then - allo = 1000000000 - passw = "password" - else - allos = file:read("*line") - allo = tonumber(allos) * 1000000 - passw = file:read("*line") - file:close() - end - tfile:write(tostring(allo), "\n") - tfile:write(calc(allo), "\n") - tfile:write(passw, "\n") - - showdevices(bw, maclist) - tfile:write(tostring(totaldevices), "\n") - if totaldevices > 0 then - for i=0, totaldevices-1 do - tfile:write(devices[i], "\n") - end - end - tfile:close() -else - tfile = io.open("/tmp/bwdata", "w") - tfile:write("0\n") - tfile:write("0\n") - tfile:close() -end -os.execute("rm -f /tmp/lockbw") -os.execute("/usr/lib/bwmon/excede.sh " .. tostring(total) .. " " .. tostring(allo) .. " " .. tostring(ptotal)) -os.execute("/usr/lib/bwmon/savetot.sh \"" .. calc(total) .. "\"") -os.execute("/usr/lib/bwmon/perday.lua") diff --git a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/data/placeholder b/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/data/placeholder deleted file mode 100644 index c227083..0000000 --- a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/data/placeholder +++ /dev/null @@ -1 +0,0 @@ -0 \ No newline at end of file diff --git a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/datainc.lua b/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/datainc.lua deleted file mode 100644 index 6ef57c4..0000000 --- a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/datainc.lua +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/lua - -prev = arg[1] -- previous increment in GB -incr = arg[2] -- fixed increment in GB -used = arg[3] -- amt used in Kb - -used = used / 1000000 -- used in GB -current = prev + incr -running = "0" -if used >= current then - while used >= (current + incr) do - current = current + incr - end - prev = current - running = "1" -end - -tfile = io.open("/tmp/bwinc", "w") -tfile:write("prev=\"", prev, "\"\n") -tfile:write("runn=\"", running, "\"") -tfile:close() \ No newline at end of file diff --git a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/dataper.lua b/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/dataper.lua deleted file mode 100644 index a287094..0000000 --- a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/dataper.lua +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/lua - -alloc = arg[1] -- allocate increment in GB -per = arg[2] -- fixed percentage in GB -used = arg[3] -- amt used in Kb - ---used = used / 10000 -- used in GB -percent = (used / alloc) * 100 - -running = "0" -if percent >= tonumber(per) then - running = "1" -end - -tfile = io.open("/tmp/bwper", "w") -tfile:write("runn=\"", running, "\"") -tfile:close() \ No newline at end of file diff --git a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/dotext.sh b/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/dotext.sh deleted file mode 100644 index 651c410..0000000 --- a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/dotext.sh +++ /dev/null @@ -1,82 +0,0 @@ -#!/bin/sh -. /lib/functions.sh - -log() { - logger -t "TEXTING" "$@" -} - -getbw() { - alloc=$(uci -q get custom.bwallocate.allocate)"000000" - if [ -e /tmp/bwdata ]; then - while IFS= read -r line; do - days=$line - if [ $days = '0' ]; then - used="0" - return - fi - read -r line - used=$line - read -r line - useda=$line - return - done < /tmp/bwdata - else - used="0" - useda="0.00 K" - fi -} - -sendmsg() { - getbw - /usr/lib/bwmon/amtleft.lua $alloc $used - bwleft=$(cat /tmp/amtleft) - - #ident=$(uci -q get custom.texting.ident) - ident=$(uci -q get modem.modem1.iccid) - if [ -z "$ident" ]; then - ident="Unknown User" - fi - message="$ident has used $useda bandwidth and has $bwleft of bandwidth left" - - tore=$(uci -q get custom.texting.tore) - if [ $tore = '0' ]; then - phone=$(uci -q get custom.texting.phone) - /usr/lib/bwmon/chksms.sh - if [ -e /tmp/texting ]; then - /usr/lib/sms/smsout.sh "$phone" "$message" - log "$phone $message" - else - log "$message not sent. No SMS." - fi - else - email=$(uci -q get custom.texting.email) - - host=$(uci -q get custom.texting.smtp) - user=$(uci -q get custom.texting.euser) - pass=$(uci -q get custom.texting.epass) - - STEMP="/tmp/eemail" - MSG="/usr/lib/bwmon/msmtprc" - DST="/etc/msmtprc" - rm -f $STEMP - cp $MSG $STEMP - sed -i -e "s!#HOST#!$host!g" $STEMP - sed -i -e "s!#USER#!$user!g" $STEMP - sed -i -e "s!#PASS#!$pass!g" $STEMP - mv $STEMP $DST - - STEMP="/tmp/emailmsg" - MSG="/usr/lib/bwmon/message" - rm -f $STEMP - cp $MSG $STEMP - sed -i -e "s!#EMAIL#!$email!g" $STEMP - sed -i -e "s!#MESSAGE#!$message!g" $STEMP - sed -i -e "s!#IDENT#!$ident!g" $STEMP - mess=$(cat /tmp/emailmsg) - echo -e "$mess" | msmtp --read-envelope-from --read-recipients - log "$email $message" - fi - -} - -sendmsg \ No newline at end of file diff --git a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/editemail.sh b/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/editemail.sh deleted file mode 100644 index 61c4ec3..0000000 --- a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/editemail.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh - -log() { - logger -t "edit email" "$@" -} - -host=$(uci -q get custom.texting.smtp) -if [ -z $host ]; then - exit 0 -fi -user=$(uci -q get custom.texting.euser) -if [ -z $user ]; then - exit 0 -fi -pass=$(uci -q get custom.texting.epass) -if [ -z $pass ]; then - exit 0 -fi - -STEMP="/tmp/eemail" -MSG="/usr/lib/bwmon/msmtprc" -DST="/etc/msmtprc" -rm -f $STEMP -cp $MSG $STEMP -sed -i -e "s!#HOST#!$host!g" $STEMP -sed -i -e "s!#USER#!$user!g" $STEMP -sed -i -e "s!#PASS#!$pass!g" $STEMP -mv $STEMP $DST - \ No newline at end of file diff --git a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/excede.sh b/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/excede.sh deleted file mode 100644 index 5c9af09..0000000 --- a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/excede.sh +++ /dev/null @@ -1,94 +0,0 @@ -#!/bin/sh -. /lib/functions.sh - -log() { - logger -t "excede BW " "$@" -} - -do_throttle() { - local config=$1 - local limit - - config_get name $1 name - config_get limit $1 limit - config_get throttle $1 throttle - let kamt=limit*1000000 - if [ $amt -gt $kamt ]; then - if [ $limit -gt $baselimit ]; then - speed=$throttle - level=$name - baselimit=$limit - fi - fi -} - -lock=$(uci -q get custom.bwallocate.lock) -if [ $lock = "1" ]; then - enb=$(uci -q get custom.bwallocate.enabled) - if [ $enb = '1' ]; then - allocate=$2 - total=$1 - /usr/lib/bwmon/block 0 - action=$(uci -q get custom.bwallocate.action) - if [ -z $action ]; then - action=0 - fi - if [ ! -e /usr/lib/throttle/throttle.sh ]; then - action=0 - fi - if [ $action != "2" ]; then - if [ $total -gt $allocate ]; then - if [ $action = "0" ]; then - if [ -e /etc/nodogsplash/control ]; then - /etc/nodogsplash/control block - else - /usr/lib/bwmon/block 1 - fi - else - down=$(uci -q get custom.bwallocate.down) - if [ -z $down ]; then - down=5 - fi - up=$(uci -q get custom.bwallocate.up) - if [ -z $up ]; then - up=2 - fi - /usr/lib/throttle/throttle.sh start $down $up - fi - else - if [ -e /usr/lib/throttle/throttle.sh ]; then - /usr/lib/throttle/throttle.sh stop - fi - if [ -e /etc/nodogsplash/control ]; then - /etc/nodogsplash/control unblock - fi - /usr/lib/bwmon/block 0 - fi - else - meth=$(uci -q get custom.bwallocate.meth) - if [ -z $meth ]; then - meth="0" - fi - if [ $meth = "0" ]; then - amt=$total - else - amt=$3 - fi - speed="0" - baselimit="0" - config_load custom - config_foreach do_throttle throttle - if [ $speed != "0" ]; then - /usr/lib/bwmon/float.lua "$speed" - source /tmp/float - /usr/lib/throttle/throttle.sh start $SPEED $SPEED 1 - log "Throttled to $speed Mbps" - else - if [ -e /usr/lib/throttle/throttle.sh ]; then - /usr/lib/throttle/throttle.sh stop - fi - fi - - fi - fi -fi \ No newline at end of file diff --git a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/external.sh b/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/external.sh deleted file mode 100644 index 9b11296..0000000 --- a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/external.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh - -log() { - logger -t "wrtbwmon" "$@" -} - -external=$1 - -ext=$(uci -q get bwmon.general.external) - -if [ "$ext" = "$external" ]; then - exit 0 -else - uci set bwmon.general.external=$external - uci commit bwmon - PID=$(ps |grep "wrtbwmon.sh" | grep -v grep |head -n 1 | awk '{print $1}') - PID1=$(ps |grep "create.sh" | grep -v grep |head -n 1 | awk '{print $1}') - if [ ! -z "$PID" ]; then - kill -9 $PID - kill -9 $PID1 - fi - /usr/lib/bwmon/wrtbwmon.sh & - /usr/lib/bwmon/create.sh & -fi \ No newline at end of file diff --git a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/float.lua b/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/float.lua deleted file mode 100644 index 4c40f3e..0000000 --- a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/float.lua +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/lua - -val = arg[1] - -retval = val * 1000 - -local tfile = io.open("/tmp/float", "w") -tfile:write("SPEED=\"", retval, "\"") -tfile:close() \ No newline at end of file diff --git a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/message b/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/message deleted file mode 100644 index 509a0e4..0000000 --- a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/message +++ /dev/null @@ -1,4 +0,0 @@ -From: Broadband Usage -To: #EMAIL# -Subject: Broadband Usage -#MESSAGE# diff --git a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/msmtprc b/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/msmtprc deleted file mode 100644 index 4b8a3f8..0000000 --- a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/msmtprc +++ /dev/null @@ -1,12 +0,0 @@ -account default -host #HOST# -port 587 -auto_from off -from #USER# -aliases /etc/aliases -tls on -tls_starttls on -tls_trust_file /etc/ssl/certs/ca-certificates.crt -auth on -user #USER# -password #PASS# \ No newline at end of file diff --git a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/perday.lua b/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/perday.lua deleted file mode 100644 index 1f133ef..0000000 --- a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/perday.lua +++ /dev/null @@ -1,204 +0,0 @@ -#!/usr/bin/lua - -function ltrim(s) - return s:match'^%s*(.*)' -end - -function calc(total) - if total < 1000 then - tstr = string.format("%.2f", total) - tfm = " K" - else - if total < 1000000 then - tstr = string.format("%.2f", total/1000) - tfm = " MB" - else - tstr = string.format("%.2f", total/1000000) - tfm = " GB" - end - end - str = tstr .. tfm - return ltrim(str) -end - -local function bubblesort(a) - repeat - local swapped = false - for i = 1, table.getn(a) do - if a[i - 1] < a[i] then - a[i], a[i - 1] = a[i - 1], a[i] - swapped = true - end -- if - end -- for - until swapped == false -end - -function ConBytes(line) - local s, e, bs, be - s, e = line:find(" ") - bs, be = line:find("K", e+1) - if bs == nil then - bs, be = line:find("MB", e+1) - if bs == nil then - val = tonumber(line:sub(1, e-1)) * 1000000 - else - val = tonumber(line:sub(1, e-1)) * 1000 - end - else - val = tonumber(line:sub(1, e-1)) - end - return val -end - -dirname = '/usr/lib/bwmon/data' -filepost = "-mac_data.js" -monthly = dirname .. "/monthly.data" -daylist = {} -dayline = {} -monlist = {} -monline = {} - -dataname = nil -f = io.popen('/bin/ls ' .. dirname) -for name in f:lines() do - s, e = name:find(filepost) - if s ~= nil then - dataname = name - end -end -f:close() - -if dataname ~= nil then - yearmon = dataname:sub(1, 7) - datafile = dirname .. "/" .. dataname - file = io.open(datafile, "r") - i = 0 - repeat - line = file:read("*line") - if line == nil then - break - end - s, e = line:find("start day") - if s ~= nil then - day = line:sub(e+1) - nday = tonumber(day) - day= tostring(nday) - if nday < 10 then - day = "0" .. day - end - yearmonday = yearmon .. "-" .. day - - daydwn = 0 - dayup = 0 - repeat - line = file:read("*line") - s, e = line:find("end day") - if s ~= nil then - dayt = dayup + daydwn - if dayt > 0 then - daylist[i] = yearmonday - i = i + 1 - dayline[yearmonday] = {} - dayline[yearmonday]['down'] = daydwn - dayline[yearmonday]['up'] = dayup - dayline[yearmonday]['total'] = dayup + daydwn - end - break - end - s, e = line:find("\"down\":\"") - bs, be = line:find("\"", e+1) - daydwn = daydwn + tonumber(line:sub(e+1, bs-1)) - s, e = line:find("\"up\":\"") - bs, be = line:find("\"", e+1) - dayup = dayup + tonumber(line:sub(e+1, bs-1)) - until 1==0 - end - until 1==0 - - if i > 0 then - tfile = io.open(monthly, "r") - if tfile == nil then - for j = 0,i-1 - do - lin = daylist[j] - monlist[j] = lin - monline[lin] = {} - dwn = calc(dayline[lin]['down']) - up = calc(dayline[lin]['up']) - total = calc(dayline[lin]['total']) - dataline = lin .. "|" .. dwn .. "|" .. up .. "|" .. total - monline[lin]['data'] = dataline - end - k = i - else - k = 0 - ksize = tfile:read("*line") - kdwn = tfile:read("*line") - kup = tfile:read("*line") - ktotal = tfile:read("*line") - repeat - line = tfile:read("*line") - if line == nil then - break - end - ymd = line:sub(1,10) - monlist[k] = ymd - k = k + 1 - monline[ymd] = {} - monline[ymd]['data'] = line - until 1==0 - tfile:close() - - for j = 0,i-1 - do - lin = daylist[j] - if monline[lin] == nil then - monlist[k] = lin - k = k + 1 - monline[lin] = {} - end - dwn = calc(dayline[lin]['down']) - up = calc(dayline[lin]['up']) - total = calc(dayline[lin]['total']) - dataline = lin .. "|" .. dwn .. "|" .. up .. "|" .. total - monline[lin]['data'] = dataline - end - end - - bubblesort(monlist) - - tfile = io.open(monthly, "w") - if k > 30 then - k = 30 - end - tfile:write(tostring(k), "\n") - fdown = 0 - fup = 0 - ftotal = 0 - for j = 0,k-1 - do - lin = monlist[j] - dataline = monline[lin]['data'] - s, e = dataline:find("|") - if s ~= nil then - bs, be = dataline:find("|", e+1) - fdown = ConBytes(dataline:sub(e+1, be-1)) + fdown - s, e = dataline:find("|", be+1) - fup = ConBytes(dataline:sub(be+1, e-1)) + fup - ftotal = ConBytes(dataline:sub(e+1)) + ftotal - end - end - tfile:write(calc(fdown), "\n") - tfile:write(calc(fup), "\n") - tfile:write(calc(ftotal), "\n") - for j = 0,k-1 - do - lin = monlist[j] - dataline = monline[lin]['data'] - tfile:write(dataline, "\n") - end - tfile:close() - end - - file:close() -end \ No newline at end of file diff --git a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/process.sh b/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/process.sh deleted file mode 100644 index 42e38b6..0000000 --- a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/process.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh - -log() { - logger -t "BWmon Process" "$@" -} - -running=0 -if [ -e "/tmp/WRTbmon" ]; then - running=1 -fi - -sleep 5 - -if [ $running = 0 ]; then - log "Enable BandWidthMonitor" - /usr/lib/bwmon/wrtbwmon.sh & -fi - - - diff --git a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/rollover.sh b/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/rollover.sh deleted file mode 100644 index 648b9d6..0000000 --- a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/rollover.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -log() { - logger -t "Rollover" "$@" -} - -amount=$1 - -uci set custom.bwallocate.rollover=$amount -uci set custom.bwallocate.persent="0" -uci commit custom diff --git a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/savetot.sh b/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/savetot.sh deleted file mode 100644 index 1a780ba..0000000 --- a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/savetot.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -log() { - logger -t "save total" "$@" -} - -total=$1 - -uci set custom.bwday.bwday="$total" -uci commit custom \ No newline at end of file diff --git a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/sendsms.sh b/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/sendsms.sh deleted file mode 100644 index 3fc4ff4..0000000 --- a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/sendsms.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh - -log() { - logger -t "sendsms" "$@" -} - -chksms() { - CURRMODEM=1 - rm -f /tmp/texting - CPORT=$(uci -q get modem.modem$CURRMODEM.commport) - if [ -z $CPORT ]; then - return - fi - SMS_OK=$(uci -q get modem.modem$CURRMODEM.sms) - if [ "$SMS_OK" != "1" ]; then - return - fi - echo "0" > /tmp/texting -} - -delay=$(uci -q get modem.modeminfo$CURRMODEM.delay) -if [ "$delay" -gt 0 ]; then - cnt=1 - while true; do - sleep 3600 - let cnt=cnt+1 - if [ $cnt -gt $delay ]; then - break - fi - done -fi -total=$(uci -q get.custom.bwday.bwday) -chksms -phone=$(uci -q get modem.modeminfo$CURRMODEM.bwphone) -if [ (! -z "$phone") -o ("$phone" != "0") ]; then - if [ -e /tmp/texting ]; then - /usr/lib/sms/smsout.sh "$phone" "$total" - fi -fi diff --git a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/textbw.sh b/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/textbw.sh deleted file mode 100644 index ed85caa..0000000 --- a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/textbw.sh +++ /dev/null @@ -1,153 +0,0 @@ -#!/bin/sh -. /lib/functions.sh - -log() { - modlog "TEXTING" "$@" -} - -checktime() { - SHOUR=$(uci -q get custom.texting.time) - EHOUR=`expr $SHOUR + 1` - if [ $EHOUR -gt 95 ]; then - EHOUR=0 - fi - HOUR=`expr $SHOUR / 4` - let "TH = $HOUR * 4" - let "TMP1 = $SHOUR - $TH" - let "MIN = $TMP1 * 15" - shour=$HOUR - smin=$MIN - - HOUR=`expr $EHOUR / 4` - let "TH = $HOUR * 4" - let "TMP1 = $EHOUR - $TH" - let "MIN = $TMP1 * 15" - ehour=$HOUR - emin=$MIN - - chour=$(date +%H) - cmin=$(date +%M) - if [ $shour -gt $chour ]; then - flag="0" - else - if [ $shour -eq $chour ]; then - if [ $smin -le $cmin ]; then - flag="1" - else - flag="0" - fi - else - flag="1" - fi - fi - - if [ $flag = "1" ]; then - if [ $ehour -lt $chour ]; then - flag="0" - else - if [ $ehour -eq $chour ]; then - if [ $emin -lt $cmin ]; then - flag="0" - else - flag="1" - fi - else - flag="1" - fi - fi - fi - echo $flag -} - -getbw() { - alloc=$(uci -q get custom.bwallocate.allocate)"000000" - if [ -e /tmp/bwdata ]; then - while IFS= read -r line; do - days=$line - if [ $days = '0' ]; then - used="0" - return - fi - read -r line - used=$line - return - done < /tmp/bwdata - else - used="0" - fi -} - -checkamt() { - istime=$(checktime) - if [ $istime = '1' ]; then - incr=$(uci -q get custom.texting.increment) - getbw - /usr/lib/bwmon/datainc.lua $prev $incr $used - source /tmp/bwinc - uci set custom.texting.used=$prev - uci commit custom - echo $runn - else - echo "0" - fi -} - -checkper() { - istime=$(checktime) - if [ $istime = '1' ]; then - prev=$(uci -q get custom.texting.used) - per=$(uci -q get custom.texting.percent) - persent=$(uci -q get custom.bwallocate.persent) - if [ "$persent" != "1" ]; then - getbw - /usr/lib/bwmon/dataper.lua $alloc $per $used - source /tmp/bwper - if [ $runn = "1" ]; then - uci set custom.bwallocate.persent="1" - uci commit custom - fi - echo $runn - else - echo "0" - fi - else - echo "0" - fi -} - -delay=900 -while true -do - EN=$(uci -q get custom.bwallocate.enabled) - if [ $EN = "1" ]; then - MT=$(uci -q get custom.texting.method) - if [ $MT = '0' ]; then - days=$(uci -q get custom.texting.days) - daysdate=$( date +%d ) - daysdate="${daysdate#"${daysdate%%[!0]*}"}" - remain=$((daysdate % days)) - if [ $remain -eq 0 ]; then - running=$(checktime) - else - running="0" - fi - else - if [ $MT = '1' ]; then - running=$(checkamt) - else - running=$(checkper) - fi - fi - if [ $running = "1" ]; then - EN=$(uci -q get custom.texting.text) - if [ $EN = "1" ]; then - /usr/lib/bwmon/dotext.sh & - sleep $delay - fi - else - sleep $delay - fi - else - sleep $delay - fi -done \ No newline at end of file diff --git a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/wrtbwmon.sh b/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/wrtbwmon.sh deleted file mode 100644 index 55e3924..0000000 --- a/rooter/0optionalapps/bwmon/files/usr/lib/bwmon/wrtbwmon.sh +++ /dev/null @@ -1,508 +0,0 @@ -#!/bin/sh - -setbackup() { - extn=$(uci -q get bwmon.general.external) - if [ "$extn" = "0" ]; then - backPath=/usr/lib/bwmon/data/ - else - if [ -e "$extn""/" ]; then - backPath=$extn"/data/" - else - backPath=/usr/lib/bwmon/data/ - uci set bwmon.general.external="0" - uci commit bwmon - fi - fi - if [ ! -e "$backpath" ]; then - mkdir -p $backPath - fi -} - -LAN_TYPE=$(uci get network.lan.ipaddr | awk -F. ' { print $1"."$2 }') -LEASES_FILE=/tmp/dhcp.leases -lockDir=/tmp/WRTbmon - -ifname="ifname" -source /etc/openwrt_release -twone=$(echo "$DISTRIB_RELEASE" | grep "21.02") -if [ ! -z "$twone" ]; then - ifname="device" -fi - - -[ ! -d "$lockDir" ] && mkdir "$lockDir" -basePath="/tmp/bwmon/" -mkdir -p $basePath"data" -dataPath=$basePath"data/" -setbackup -lockDir1=/tmp/wrtbwmon1.lock -lockDir=/tmp/wrtbwmon.lock -mkdir -p "$lockDir" -pidFile=$lockDir/pid -STARTIMEX=$(date +%s) -STARTIMEY=$(date +%s) -STARTIMEZ=$(date +%s) -cYear=$(date +%Y) -cDay=$(date +%d) -cMonth=$(date +%m) -setup_time=60 -update_time=60 -bs=$(uci -q get bwmon.general.backup) -let "bs=$bs*60" -backup_time=$bs -pause=30 -unlimited="peak" - -networkFuncs=/lib/functions/network.sh -uci=`which uci 2>/dev/null` -nslookup=`which nslookup 2>/dev/null` -nvram=`which nvram 2>/dev/null` -binDir=/usr/sbin -chains='INPUT OUTPUT FORWARD' -DEBUG= -interfaces='eth0' # in addition to detected WAN -DB="/tmp/usage.db" -mode= - -log() { - logger -t "wrtbwmon" "$@" -} - -header="#mac,ip,iface,in,out,total,first_date,last_date" - -createDbIfMissing() -{ - [ ! -f "$DB" ] && rm -f $DB;echo $header > "$DB" -} - -checkWAN() -{ - [ -z "$wan" ] && return -} - -lookup() -{ - MAC=$1 - IP=$2 - userDB=$3 - for USERSFILE in $userDB /tmp/dhcp.leases /tmp/dnsmasq.conf /etc/dnsmasq.conf /etc/hosts; do - [ -e "$USERSFILE" ] || continue - case $USERSFILE in - /tmp/dhcp.leases ) - USER=$(grep -i "$MAC" $USERSFILE | cut -f4 -s -d' ') - ;; - /etc/hosts ) - USER=$(grep "^$IP " $USERSFILE | cut -f2 -s -d' ') - ;; - * ) - USER=$(grep -i "$MAC" "$USERSFILE" | cut -f2 -s -d,) - ;; - esac - [ "$USER" = "*" ] && USER= - [ -n "$USER" ] && break - done - if [ -n "$DO_RDNS" -a -z "$USER" -a "$IP" != "NA" -a -n "$nslookup" ]; then - USER=`$nslookup $IP $DNS | awk '!/server can/{if($4){print $4; exit}}' | sed -re 's/[.]$//'` - fi - [ -z "$USER" ] && USER=${MAC} - echo $USER -} - -detectIF() -{ - if [ -f "$networkFuncs" ]; then - IF=`. $networkFuncs; network_get_device netdev $1; echo $netdev` - [ -n "$IF" ] && echo $IF && return - fi - - if [ -n "$uci" -a -x "$uci" ]; then - IF=`$uci get network.${1}.$ifname 2>/dev/null` - [ $? -eq 0 -a -n "$IF" ] && echo $IF && return - fi - - if [ -n "$nvram" -a -x "$nvram" ]; then - IF=`$nvram get ${1}_$ifname 2>/dev/null` - [ $? -eq 0 -a -n "$IF" ] && echo $IF && return - fi -} - -detectLAN() -{ - [ -e /sys/class/net/br-lan ] && echo br-lan && return - lan=$(detectIF lan) - [ -n "$lan" ] && echo $lan && return -} - -detectWAN() -{ - [ -n "$WAN_IF" ] && echo $WAN_IF && return - wan=$(detectIF wan) - [ -n "$wan" ] && echo $wan && return - wan=$(ip route show 2>/dev/null | grep default | sed -re '/^default/ s/default.*dev +([^ ]+).*/\1/') - [ -n "$wan" ] && echo $wan && return - [ -f "$networkFuncs" ] && wan=$(. $networkFuncs; network_find_wan wan; echo $wan) - [ -n "$wan" ] && echo $wan && return -} - -lock() -{ - attempts=0 - while [ $attempts -lt 10 ]; do - mkdir $lockDir1 2>/dev/null && break - attempts=$((attempts+1)) - pid=`cat $pidFile 2>/dev/null` - if [ -n "$pid" ]; then - if [ -d "/proc/$pid" ]; then - [ -n "$DEBUG" ] && echo "WARNING: Lockfile detected but process $(cat $pidFile) does not exist !" - rm -rf $lockDir1 - else - sleep 1 - fi - fi - done - mkdir $lockDir1 2>/dev/null - echo $$ > $pidFile - [ -n "$DEBUG" ] && echo $$ "got lock after $attempts attempts" - trap '' INT -} - -unlock() -{ - rm -rf $lockDir1 - [ -n "$DEBUG" ] && echo $$ "released lock" - trap "rm -f /tmp/*_$$.tmp; kill $$" INT -} - -# chain -newChain() -{ - chain=$1 - # Create the RRDIPT_$chain chain (it doesn't matter if it already exists). - iptables -t mangle -N RRDIPT_$chain 2> /dev/null - - # Add the RRDIPT_$chain CHAIN to the $chain chain if not present - iptables -t mangle -C $chain -j RRDIPT_$chain 2>/dev/null - if [ $? -ne 0 ]; then - [ -n "$DEBUG" ] && echo "DEBUG: iptables chain misplaced, recreating it..." - iptables -t mangle -I $chain -j RRDIPT_$chain - fi -} - -# chain tun -newRuleIF() -{ - chain=$1 - IF=$2 - - #!@todo test - if [ "$chain" = "OUTPUT" ]; then - cmd="iptables -t mangle -o $IF -j RETURN" - eval $cmd " -C RRDIPT_$chain 2>/dev/null" || eval $cmd " -A RRDIPT_$chain" - elif [ "$chain" = "INPUT" ]; then - cmd="iptables -t mangle -i $IF -j RETURN" - eval $cmd " -C RRDIPT_$chain 2>/dev/null" || eval $cmd " -A RRDIPT_$chain" - fi -} - -accounting(){ - LAN_IFACE="br-lan" - WAN_IFACE=$1 - LAN_IP=$(uci -q get network.lan.ipaddr) - SERVER_IP=$(echo $LAN_IP | cut -d . -f 1,2,3).0 - INTERNAL_NETMASK="$SERVER_IP/24" - - # create the ACCOUNTING chains - iptables -w -N ACCOUNTING_BLOCK 2> /dev/null - iptables -w -N ACCOUNTING_IN 2> /dev/null - iptables -w -N ACCOUNTING_OUT 2> /dev/null - check=0 - # check if accounting rule for ethernet wan not exist, add it - checks=$(iptables -w -L FORWARD -v -n | grep "ACCOUNTING" | grep "$WAN_IFACE") - [ -z "$checks" ] && check=1 - - # check if jumps to the ACCOUNTING chains are still at the start of the FORWARD chain - iptables -w -L FORWARD --line-numbers -n | grep "ACCOUNTING" | grep "^1 " - if [ $? -ne 0 -o "$check" = "1" ]; then - # remove old jump rules - iptables -w -D FORWARD $(iptables -w -L FORWARD --line-numbers | grep ACCOUNTING | grep -m 1 -o "[0-9]*") - while [ $? -eq 0 ]; do - iptables -w -D FORWARD $(iptables -w -L FORWARD --line-numbers | grep ACCOUNTING | grep -m 1 -o "[0-9]*") - done - # insert new jump rules at start of FORWARD chain - if [ -n "$WAN_IFACE" ] - then - iptables -w -I FORWARD -i ${WAN_IFACE} -j ACCOUNTING_IN - iptables -w -I FORWARD -o ${WAN_IFACE} -j ACCOUNTING_OUT - fi - iptables -w -I FORWARD -j ACCOUNTING_BLOCK - fi - - #For each host in the ARP table - grep ${LAN_IFACE} /proc/net/arp | while read IP TYPE FLAGS MAC MASK IFACE - do - #Add iptables rules (if non existing). - iptables -w -nL ACCOUNTING_IN | grep "${IP} " > /dev/null - if [ $? -ne 0 ]; then - iptables -w -I ACCOUNTING_IN -d ${IP} -s ${INTERNAL_NETMASK} -j RETURN - iptables -w -I ACCOUNTING_IN -d ${IP} ! -s ${INTERNAL_NETMASK} -j RETURN - fi - - iptables -w -nL ACCOUNTING_OUT | grep "${IP} " > /dev/null - if [ $? -ne 0 ]; then - iptables -w -I ACCOUNTING_OUT -s ${IP} -d ${INTERNAL_NETMASK} -j RETURN - iptables -w -I ACCOUNTING_OUT -s ${IP} ! -d ${INTERNAL_NETMASK} -j RETURN - fi - done -} - -setup() -{ - for chain in $chains; do - newChain $chain - done - - wan=$(detectWAN) - checkWAN - wan1=$(detectIF wan1) - wan2=$(detectIF wan2) - C1=$(uci -q get modem.modem1.connected) - C2=$(uci -q get modem.modem2.connected)$C1 - if [ ! -z $C2 ]; then - interfaces="$wan1 $wan2" - WW=$(uci -q get bwmon.bwwan.wan) - if [ "$WW" = "1" ]; then - interfaces=$interfaces $wan" wwan" - fi - else - WW=$(uci -q get bwmon.bwwan.wan) - if [ "$WW" = "1" ]; then - interfaces="$wan wwan" - else - return - fi - fi - - # track local data - for chain in INPUT OUTPUT; do - for interface in $interfaces; do - [ -n "$interface" ] && [ -e "/sys/class/net/$interface" ] && newRuleIF $chain $interface - #if [ -e /etc/bwlock ]; then - accounting $interface - #fi - done - done - - # this will add rules for hosts in arp table - update $dailyUsageDB - - rm -f /tmp/*_$$.tmp -} - -update() -{ - createDbIfMissing - checkWAN - PERTOTAL=0 - - > /tmp/iptables_$$.tmp - lock - # only zero our own chains - for chain in $chains; do - iptables -nvxL RRDIPT_$chain -t mangle -Z >> /tmp/iptables_$$.tmp - done - # the iptables and readDB commands have to be separate. Otherwise, - # they will fight over iptables locks - awk -v mode="$mode" -v interfaces=\""$interfaces"\" -f $binDir/readDB.awk \ - $DB \ - /proc/net/arp \ - /tmp/iptables_$$.tmp - - while read L1 - do - MAC=$(echo ${L1} | cut -f1 -d, ) - if [ $MAC != "#mac" ]; then - MAC=$(echo ${L1} | cut -f1 -d, ) - IP=$(echo ${L1} | cut -f2 -d, ) - IN=$(echo ${L1} | cut -f4 -d, ) - IN=$((${IN}/1000)) - OUT=$(echo ${L1} | cut -f5 -d, ) - OUT=$((${OUT}/1000)) - TOTAL=$(echo ${L1} | cut -f6 -d, ) - TOTAL=$((${TOTAL}/1000)) - let PERTOTAL=PERTOTAL+TOTAL - if [ $TOTAL -gt 0 -a $IP != "NA" ]; then - for USERSFILE in /tmp/dhcp.leases /tmp/dnsmasq.conf /etc/dnsmasq.conf /etc/hosts; do - [ -e "$USERSFILE" ] || continue - case $USERSFILE in - /tmp/dhcp.leases ) - NAME=$(grep -i "$MAC" $USERSFILE | cut -f4 -s -d' ') - ;; - /etc/hosts ) - NAME=$(grep "^$IP " $USERSFILE | cut -f2 -s -d' ') - ;; - * ) - NAME=$(grep -i "$MAC" "$USERSFILE" | cut -f2 -s -d,) - ;; - esac - [ "$NAME" = "*" ] && NAME= - [ -n "$NAME" ] && break - done - if [ -z $NAME ]; then - NAME="*" - fi - - echo "\"mac\":\""${MAC}"\"","\"down\":\""${IN}"\"","\"up\":\""${OUT}"\"","\"offdown\":\""0"\"","\"offup\":\""0"\"","\"ip\":\""${IP}"\"","\"name\":\""${NAME}"\"" >> ${1} - fi - fi - done < $DB - if [ -e /usr/lib/bwmon/period.sh ]; then - /usr/lib/bwmon/period.sh "$PERTOTAL" - fi - unlock -} - - -createFiles() -{ - while [ -e /tmp/lockbw ]; do - sleep 1 - done - echo "0" > /tmp/lockbw - while [ ! -e $backPath*"mac_data.js" ]; do - valid=$(cat /var/state/dnsmasqsec) - st=$(echo "$valid" | grep "ntpd says time is valid") - if [ ! -z "$st" ]; then - break - fi - sleep 10 - done - dailyUsageDB="$dataPath$cYear-$cMonth-$cDay-daily_data.js" - dailyUsageBack="$backPath$cYear-$cMonth-$cDay-daily_data.js" - if [ ! -f $dailyUsageBack ]; then - rm -f $backPath*"daily_data.js" - touch $dailyUsageDB - touch $dailyUsageBack - else - cp -f $dailyUsageBack $dailyUsageDB - fi - monthlyUsageDB="$dataPath$cYear-$cMonth-mac_data.js" - monthlyUsageBack="$backPath$cYear-$cMonth-mac_data.js" - if [ -f $monthlyUsageBack ]; then - cp -f $monthlyUsageBack $monthlyUsageDB".bk" - sed "/start day $cDay/,/end day $cDay/d" $monthlyUsageDB".bk" > $monthlyUsageDB - cp -f $monthlyUsageBack $monthlyUsageDB".bk" - else - rm -f $backPath*"mac_data.js" - touch $monthlyUsageDB - touch $monthlyUsageBack - /usr/lib/bwmon/backup.sh "backup" $cDay $monthlyUsageDB $dailyUsageDB $monthlyUsageBack $dailyUsageBack - fi - rm -f /tmp/lockbw -} - -shutDown() -{ - while [ -e /tmplockbw ]; do - sleep 1 - done - echo "0" > /tmp/lockbw - /usr/lib/bwmon/backup.sh "backup" $cDay $monthlyUsageDB $dailyUsageDB $monthlyUsageBack $dailyUsageBack - lua /usr/lib/bwmon/cleanup.lua - rm -f /tmp/lockbw -} - -checkSetup() -{ - CURRTIME=$(date +%s) - let ELAPSE=CURRTIME-STARTIMEX - if [ $ELAPSE -gt $setup_time ]; then - STARTIMEX=$CURRTIME - setup - /usr/lib/bwmon/backup.sh "setup" $cDay $monthlyUsageDB $dailyUsageDB $monthlyUsageBack $dailyUsageBack - fi -} - -checkUpdate() -{ - CURRTIME=$(date +%s) - let ELAPSE=CURRTIME-STARTIMEY - if [ $ELAPSE -gt $update_time ]; then - STARTIMEY=$CURRTIME - update $dailyUsageDB $unlimited - fi -} - -checkBackup() -{ - CURRTIME=$(date +%s) - let ELAPSE=CURRTIME-STARTIMEZ - bs=$(uci -q get bwmon.general.backup) - let "bs=$bs*60" - backup_time=$bs - if [ $ELAPSE -gt $backup_time ]; then - STARTIMEZ=$CURRTIME - shutDown - fi -} - -checkTime() -{ - while [ -e /tmplockbw ]; do - sleep 1 - done - echo "0" > /tmp/lockbw - pDay=$(date +%d) - pYear=$(date +%Y) - pMonth=$(date +%m) - if [ "$cDay" -ne "$pDay" ]; then - /usr/lib/bwmon/backup.sh "daily" $cDay $monthlyUsageDB $dailyUsageDB $monthlyUsageBack $dailyUsageBack - - cDay=$pDay - cMonth=$pMonth - cYear=$pYear - monthlyUsageBack="$backPath$cYear-$cMonth-mac_data.js" - if [ ! -e $monthlyUsageBack ]; then - rm -f $backPath*"mac_data.js" - fi - rm -f $dataPath[[:digit:]][[:digit:]][[:digit:]][[:digit:]]"-"[[:digit:]][[:digit:]]"-"[[:digit:]][[:digit:]]-daily_data.js - rm -f $backPath[[:digit:]][[:digit:]][[:digit:]][[:digit:]]"-"[[:digit:]][[:digit:]]"-"[[:digit:]][[:digit:]]-daily_data.js - roll=$(uci -q get custom.bwallocate.rollover) - [ -z $roll ] && roll=1 - if [ "$roll" -eq "$pDay" ]; then - rm -f $monthlyUsageDB - rm -f $backPath*"mac_data.js" - monthlyUsageDB="$dataPath$cYear-$cMonth-mac_data.js" - monthlyUsageBack="$backPath$cYear-$cMonth-mac_data.js" - touch $monthlyUsageDB - uci set custom.texting.used='0' - uci commit custom - if [ -e /usr/lib/bwmon/periodreset.sh ]; then - /usr/lib/bwmon/periodreset.sh - fi - fi - rm -f $dailyUsageDB - rm -f $backPath*"daily_data.js" - dailyUsageDB="$dataPath$cYear-$cMonth-$cDay-daily_data.js" - touch $dailyUsageDB - dailyUsageBack="$backPath$cYear-$cMonth-$cDay-daily_data.js" - fi - rm -f /tmp/lockbw -} - -createFiles -setup -while [ -d $lockDir ]; do - checkSetup - checkTime - checkBackup - n=0 - while [ true ] ; do - n=$(($n + 1)) - if [ ! -d "$lockDir" ]; then - shutDown - exit 0 - fi - [ "$n" -gt "$pause" ] && break; - sleep 1 - done -done diff --git a/rooter/0optionalapps/bwmon/files/usr/lib/lua/luci/controller/bwmon.lua b/rooter/0optionalapps/bwmon/files/usr/lib/lua/luci/controller/bwmon.lua deleted file mode 100644 index ac269e8..0000000 --- a/rooter/0optionalapps/bwmon/files/usr/lib/lua/luci/controller/bwmon.lua +++ /dev/null @@ -1,119 +0,0 @@ -module("luci.controller.bwmon", package.seeall) - -I18N = require "luci.i18n" -translate = I18N.translate - -function index() - local page - entry({"admin", "nlbw"}, firstchild(), translate("Bandwidth Monitor"), 80).dependent=false - page = entry({"admin", "nlbw", "bwmon"}, template("bwmon/bwmon"), translate("ROOter Bandwidth Monitor"), 70) - page.dependent = true - - entry({"admin", "nlbw", "check_bw"}, call("action_check_bw")) - entry({"admin", "nlbw", "change_bw"}, call("action_change_bw")) - entry({"admin", "nlbw", "change_roll"}, call("action_change_roll")) - entry({"admin", "nlbw", "change_enable"}, call("action_change_enable")) - entry({"admin", "nlbw", "change_bwenable"}, call("action_change_bwenable")) - entry({"admin", "nlbw", "change_backup"}, call("action_change_backup")) - entry({"admin", "nlbw", "change_external"}, call("action_change_external")) - entry({"admin", "nlbw", "change_bwwan"}, call("action_change_bwwan")) -end - -function action_check_bw() - local rv = {} - local maclist = {} - - file = io.open("/tmp/bwdata", "r") - if file ~= nil then - rv['days'] = file:read("*line") - if rv['days'] ~= "0" then - rv['total'] = file:read("*line") - rv['ctotal'] = file:read("*line") - rv['totaldown'] = file:read("*line") - rv['ctotaldown'] = file:read("*line") - rv['totalup'] = file:read("*line") - rv['ctotalup'] = file:read("*line") - rv['ptotal'] = file:read("*line") - rv['cptotal'] = file:read("*line") - rv['atotal'] = file:read("*line") - rv['catotal'] = file:read("*line") - rv['password'] = file:read("*line") - j = file:read("*line") - if j == nil then - j = 0 - end - rv['macsize'] = j - if j ~=0 then - for i=0, j-1 do - maclist[i] = file:read("*line") - end - rv['maclist'] = maclist - end - end - file:close() - else - rv['days'] = 0 - end - local multilock = luci.model.uci.cursor():get("custom", "multiuser", "multi") or "0" - local rootlock = luci.model.uci.cursor():get("custom", "multiuser", "root") or "0" - if multilock == "0" then - rv['lock'] = luci.model.uci.cursor():get("custom", "bwallocate", "lock") - else - if rootlock == "0" then - rv['lock'] = "1" - else - rv['lock'] = "0" - end - end - rv['rollover'] = luci.model.uci.cursor():get("custom", "bwallocate", "rollover") - rv['enabled'] = luci.model.uci.cursor():get("custom", "bwallocate", "enabled") - rv['bwenabled'] = luci.model.uci.cursor():get("bwmon", "general", "enabled") - rv['backup'] = luci.model.uci.cursor():get("bwmon", "general", "backup") - rv['external'] = luci.model.uci.cursor():get("bwmon", "general", "external") - rv['bwwan'] = luci.model.uci.cursor():get("bwmon", "bwwan", "wan") - - luci.http.prepare_content("application/json") - luci.http.write_json(rv) -end - -function action_change_bw() - local set = luci.http.formvalue("set") - os.execute("/usr/lib/bwmon/allocate.sh " .. set) - -end - -function action_change_roll() - local set = luci.http.formvalue("set") - os.execute("/usr/lib/bwmon/rollover.sh " .. set) - -end - -function action_change_enable() - local set = luci.http.formvalue("set") - os.execute("uci set custom.bwallocate.enabled=" .. set .. "; uci commit custom") - -end - -function action_change_bwenable() - local set = luci.http.formvalue("set") - os.execute("/usr/lib/bwmon/change.sh " .. set) - -end - -function action_change_backup() - local set = luci.http.formvalue("set") - os.execute("uci set bwmon.general.backup=" .. set .. "; uci commit bwmon") - -end - -function action_change_external() - local set = luci.http.formvalue("set") - os.execute("/usr/lib/bwmon/external.sh " .. set) - -end - -function action_change_bwwan() - local set = luci.http.formvalue("set") - os.execute("uci set bwmon.bwwan.wan=" .. set .. "; uci commit bwmon") - -end \ No newline at end of file diff --git a/rooter/0optionalapps/bwmon/files/usr/lib/lua/luci/view/bwmon/bwmon.htm b/rooter/0optionalapps/bwmon/files/usr/lib/lua/luci/view/bwmon/bwmon.htm deleted file mode 100644 index 2664efd..0000000 --- a/rooter/0optionalapps/bwmon/files/usr/lib/lua/luci/view/bwmon/bwmon.htm +++ /dev/null @@ -1,610 +0,0 @@ -<%+header%> -<% -local sys = require "luci.sys" -local utl = require "luci.util" -local fs = require "nixio.fs" - -function showicon(lck) - if lck == 0 then - return resource .. "/icons/unlock1.png" - else - return resource .. "/icons/lock1.png" - end -end - --%> - - - - -
                -
                -

                <%:Bandwidth Monitor%>

                -
                -

                <%:Note : Bandwidth Monitor will not turn on until there is Internet Available%>

                - - - -
                - <%:Extra Internet Sources%> - - - - - - - - -
                <%:Include WAN and Hotspot%>
                -
                - -
                - <%:Data Backup Configuration%> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                <%:Enable Data Backup%>
                <%:Backup Interval in Minutes%>
                -
                <%:Backup Storage Location%>
                - -
                - -
                - <%:Total Bandwidth%> - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                <%:Total Amount of Bandwidth used this Month : %>
                <%:Estimated Bandwidth to be used this Month : %>
                <%:Rollover Day : %>
                -
                - - - - - -
                - -
                - <%:Report%> - - - - - - - - - - - - - - - - - -
                <%:Number of Days in Reporting Period : %>
                <%:Total Amount of Download Bandwidth : %>
                <%:Total Amount of Upload Bandwidth : %>
                - - - - - - -
                - -
                - - - - - - - - - -
                <%:IP Address%>
                <%:Name%>
                <%:MAC Address%>
                <%:Bandwidth Down%>
                <%:Bandwidth Up%>
                <%:Bandwidth Total%>
                - - - -
                -
                - -
                -
                -<%+footer%> \ No newline at end of file diff --git a/rooter/0optionalapps/bwmon/files/usr/sbin/readDB.awk b/rooter/0optionalapps/bwmon/files/usr/sbin/readDB.awk deleted file mode 100644 index cb57377..0000000 --- a/rooter/0optionalapps/bwmon/files/usr/sbin/readDB.awk +++ /dev/null @@ -1,157 +0,0 @@ -#!/usr/bin/awk - -function inInterfaces(host){ - return(interfaces ~ "(^| )"host"($| )") -} - -function newRule(arp_ip, - ipt_cmd){ - # checking for existing rules shouldn't be necessary if newRule is - # always called after db is read, arp table is read, and existing - # iptables rules are read. - ipt_cmd="iptables -t mangle -j RETURN -s " arp_ip - system(ipt_cmd " -C RRDIPT_FORWARD 2>/dev/null || " ipt_cmd " -A RRDIPT_FORWARD") - ipt_cmd="iptables -t mangle -j RETURN -d " arp_ip - system(ipt_cmd " -C RRDIPT_FORWARD 2>/dev/null || " ipt_cmd " -A RRDIPT_FORWARD") -} - -function total(i){ - return(bw[i "/in"] + bw[i "/out"]) -} - -function date( cmd, d){ - cmd="date +%d-%m-%Y_%H:%M:%S" - cmd | getline d - close(cmd) - #!@todo could start a process with "while true; do date ...; done" - return(d) -} - -BEGIN { - od="" - fid=1 - debug=0 - rrd=0 -} - -/^#/ { # get DB filename - FS="," - dbFile=FILENAME - next -} - -# data from database; first file -FNR==NR { #!@todo this doesn't help if the DB file is empty. - if($2 == "NA") - #!@todo could get interface IP here - n=$1 - else - n=$2 - - hosts[n] = "" # add this host/interface to hosts - mac[n] = $1 - ip[n] = $2 - inter[n] = $3 - bw[n "/in"] = $4 - bw[n "/out"] = $5 - firstDate[n] = $7 - lastDate[n] = $8 - next -} - -# not triggered on the first file -FNR==1 { - FS=" " - fid++ #!@todo use fid for all files; may be problematic for empty files - next -} - -# arp: ip hw flags hw_addr mask device -fid==2 { - #!@todo regex match IPs and MACs for sanity - arp_ip = $1 - arp_flags = $3 - arp_mac = $4 - arp_dev = $6 - if(arp_flags != "0x0" && !(arp_ip in ip)){ - if(debug) - print "new host:", arp_ip, arp_flags > "/dev/stderr" - hosts[arp_ip] = "" - mac[arp_ip] = arp_mac - ip[arp_ip] = arp_ip - inter[arp_ip] = arp_dev - bw[arp_ip "/in"] = bw[arp_ip "/out"] = 0 - firstDate[arp_ip] = lastDate[arp_ip] = date() - } - next -} - -#!@todo could use mangle chain totals or tailing "unnact" rules to -# account for data for new hosts from their first presence on the -# network to rule creation. The "unnact" rules would have to be -# maintained at the end of the list, and new rules would be inserted -# at the top. - -# skip line -# read the chain name and deal with the data accordingly -fid==3 && $1 == "Chain"{ - rrd=$2 ~ /RRDIPT_.*/ - next -} - -fid==3 && rrd && (NF < 9 || $1=="pkts"){ next } - -fid==3 && rrd { # iptables input - if($6 != "*"){ - m=$6 - n=m "/out" - } else if($7 != "*"){ - m=$7 - n=m "/in" - } else if($8 != "0.0.0.0/0"){ - m=$8 - n=m "/out" - } else { # $9 != "0.0.0.0/0" - m=$9 - n=m "/in" - } - - # remove host from array; any hosts left in array at END get new - # iptables rules - - #!@todo this deletes a host if any rule exists; if only one - # directional rule is removed, this will not remedy the situation - delete hosts[m] - - if($2 > 0){ # counted some bytes - if(mode == "diff" || mode == "noUpdate") - print n, $2 - if(mode!="noUpdate"){ - if(inInterfaces(m)){ # if label is an interface - if(!(m in mac)){ # if label was not in db (also not in - # arp table, but interfaces won't be - # there anyway) - firstDate[m] = date() - mac[m] = inter[m] = m - ip[m] = "NA" - bw[m "/in"]=bw[m "/out"]= 0 - } - } - bw[n]+=$2 - lastDate[m] = date() - } - } -} - -END { - if(mode=="noUpdate") exit - close(dbFile) - system("rm -f " dbFile) - print "#mac,ip,iface,in,out,total,first_date,last_date" > dbFile - OFS="," - for(i in mac) - print mac[i], ip[i], inter[i], bw[i "/in"], bw[i "/out"], total(i), firstDate[i], lastDate[i] > dbFile - close(dbFile) - # for hosts without rules - for(host in hosts) if(!inInterfaces(host)) newRule(host) -} \ No newline at end of file diff --git a/rooter/0optionalapps/ext-autoapn/Makefile b/rooter/0optionalapps/ext-autoapn/Makefile deleted file mode 100644 index ef5fbc4..0000000 --- a/rooter/0optionalapps/ext-autoapn/Makefile +++ /dev/null @@ -1,33 +0,0 @@ -#Owned by DairyMan@Whirlpool -# -#Copyright GNU act. -include $(TOPDIR)/rules.mk - -PKG_NAME:=ext-autoapn -PKG_VERSION:=1.000 -PKG_RELEASE:=1 - -PKG_MAINTAINER:=Created by DM/makefile by Cobia@whirlpool -include $(INCLUDE_DIR)/package.mk - -define Package/ext-autoapn - SECTION:=utils - CATEGORY:=ROOter - SUBMENU:=Optional Applications - TITLE:=support for Automatic APN - PKGARCH:=all -endef - -define Package/ext-autoapn/description - Helper scripts to enable Automatic APN -endef - - -define Build/Compile -endef - -define Package/ext-autoapn/install - $(CP) ./files/* $(1)/ -endef - -$(eval $(call BuildPackage,ext-autoapn)) diff --git a/rooter/0optionalapps/ext-autoapn/files/usr/lib/autoapn/apn.data b/rooter/0optionalapps/ext-autoapn/files/usr/lib/autoapn/apn.data deleted file mode 100644 index 88afe61..0000000 --- a/rooter/0optionalapps/ext-autoapn/files/usr/lib/autoapn/apn.data +++ /dev/null @@ -1,2198 +0,0 @@ -00101,phone,AT&TPHONETESTSIM,nil,1,nil,nil -001010,VZWINTERNET,TestInternet,nil,1,nil,nil -20201,internet,CosmoteWirelessInternet,nil,1,nil,nil -20205,internet.vodafone.gr,VfMobileInternet,nil,1,nil,nil -20209,myq,QInternet,nil,1,nil,nil -20210,gint.b-online.gr,WindInternet,nil,1,nil,nil -20402,internet.tele2.nl,Tele2GPRS,nil,1,nil,nil -20403,internet.mvno.mobi,MVNONL,mvno,1,mvno,1 -20404,mobiledata,JumpRoam,nil,1,nil,0 -20404,iot.truphone.com,Truphone,nil,1,nil,nil -20404,live.vodafone.com,VodafoneNL,vodafone,1,vodafone,1 -20404,VZWINTERNET,EHRPD-VZWRoamingInternet,nil,3,nil,nil -20408,iot.truphone.com,Truphone,nil,1,nil,nil -20404,internet.cs4glte.com,CSpireinternational,cs3g,1,Uniroam@inet.cs.com,3 -20404,admin.cs4glte.com,CSpireinternational,nil,1,nil,nil -20404,tethering.cs4glte.com,CSpireinternational,nil,1,nil,nil -20408,KPN4G.nl,KPN/Hi4GLTEMobielinternet,nil,1,nil,nil -20408,portalmmm.nl,KPN/HiMobielInternet,nil,1,nil,nil -20408,internet.mvno.mobi,MVNONL,mvno,1,mvno,1 -20408,rabo,RaboMobielInt.,nil,1,nil,nil -20404,net.hotm,HOTmobileInternet,nil,1,nil,nil -20412,internet,TelfortInternet,nil,1,nil,nil -20416,internet,T-MobileInternet,nil,1,nil,1 -20416,internet.ben,BenInternetAbonnee,nil,1,nil,nil -20416,basic.internet.ben.data,BenInternetPrePaid,nil,1,nil,nil -20420,internet,T-MobileInternet,nil,1,nil,1 -20433,iot.truphone.com,Truphone,nil,1,nil,nil -20601,INTERNET.PROXIMUS.BE,PxInternet,nil,1,nil,nil -20601,telenetwap.be,TelenetInternet,nil,1,nil,nil -20601,iijmio.jp,IIJmio(TypeI/Roaming),iij,1,mio@iij,3 -20601,vmobile.jp,vmobile.jp(Roaming),vmobile,1,vmobile@jp,3 -20605,telenetwap.be,TelenetInternet,nil,1,nil,nil -20610,mworld.be,MobistarInternet,nil,1,nil,nil -20610,netgprs.com,netgprs.com,tsl,1,tsl,nil -20620,gprs.base.be,BASEWAP,base,1,base,1 -20628,bicsapn,BICSInternet,nil,1,nil,nil -20801,orange,OrangeWorld,orange,1,orange,1 -20801,orange-mib,OrangeEntreprise,orange,1,orange,2 -20801,orange.fr,OrangeInternet,orange,1,orange,0 -20801,ofnew.fr,CarrefourWAP,orange,1,orange,1 -20801,coriolis,Coriolis,nil,1,nil,nil -20809,sl2sfr,SFRwebphone,nil,1,nil,nil -20809,websfr,SFRoptionmodem,nil,1,nil,nil -20809,pda.newcomobile.com,BeAliv,nil,1,nil,nil -20809,iot.truphone.com,Truphone,nil,1,nil,nil -20809,coriolis,Coriolis,nil,1,nil,nil -20810,sl2sfr,SFRwebphone,nil,1,nil,nil -20810,websfr,SFRoptionModem,nil,1,nil,0 -20810,fnetnrj,NRJWEB,nil,1,nil,nil -20810,internetnrj,INTERNETNRJ,nil,1,nil,0 -20810,wap65,AuchanWAP,nil,1,nil,nil -20810,wap66,WAPLeclercMobile,nil,1,nil,nil -20810,fnetcoriolis,CoriolisWAP,nil,1,nil,nil -20810,internetcoriolis,CoriolisWEB,nil,1,nil,0 -20810,wapdebitel,WEBLaPosteMobile,nil,1,nil,nil -20810,wap68,DartySurf&Mails,nil,1,nil,nil -20810,internet68,KeyyoMobileInternet,nil,1,nil,0 -20810,wap68,KeyyoMobileWap,nil,1,nil,0 -20810,wap66,WAPRegloMobile,nil,1,nil,0 -20812,iot.truphone.com,Truphone,nil,1,nil,nil -20815,free,Free,nil,1,nil,nil -20815,free.re,FreeReInt,nil,1,nil,nil -20815,iliad,IliadInt,nil,1,nil,nil -20817,bornsip,Legos,nil,1,nil,nil -20820,mmsbouygtel.com,BouyguesTelecom,nil,1,nil,nil -20822,mobiledata,mobiledata,nil,1,nil,nil -20822,netgprs.com,netgprs.com,tsl,1,tsl,nil -20823,virgin-mobile.fr,Virginmobile,nil,1,nil,nil -20826,fnetnrj,NRJWEB,nil,1,nil,nil -20827,coriolis,Coriolis,nil,1,nil,nil -21401,airtelwap.es,Internetmóvil,wap125,1,wap@wap,1 -21401,airtelnet.es,INTERNET,vodafone,1,vodafone,1 -21402,altecom.net,ALTECOM,nil,1,nil,nil -21402,fibracat.cat,FIBRACAT,nil,1,nil,nil -21403,orangeworld,OrangeInternetMóvil,orange,1,orange,1 -21403,internet,OrangeInternetPC,orange,1,orange,0 -21403,internet.euskaltel.mobi,EuskaltelInternet,EUSKALTEL,1,CLIENTE,1 -21403,CARREFOURINTERNET,Carrefour,nil,1,nil,1 -21403,internettph,HappyInternet,nil,1,nil,nil -21403,internet.racc.net,RACCINTERNET,RACC,1,CLIENTERACC,nil -21403,internetmas,MASMovilInternet,nil,1,nil,nil -21403,ibercominternet,IbercomInternet,nil,1,nil,nil -21403,jazzinternet,jazzinternet,nil,1,nil,nil -21404,internet,YoigoInternet,nil,1,nil,nil -21405,tuenti.com,Tuenti,tuenti,1,tuenti,1 -21405,inet.es,INETRoaming,nil,1,nil,nil -21406,airtelnet.es,INTERNETGPRS,vodafone,1,vodafone,nil -21406,internet.euskaltel.mobi,EuskaltelInternet,EUSKALTEL,1,CLIENTE,1 -21406,internet.mundo-r.com,InternetR,nil,1,nil,1 -21406,internet.telecable.es,TeleCableInternet,telecable,1,telecable,1 -21406,gprs.eroskimovil.es,EroskiMovilGPRS,wap125,1,wap@wap,1 -21406,gprs.pepephone.com,DUN,nil,1,nil,0 -21406,gprsmov.pepephone.com,Internet,nil,1,nil,0 -21407,telefonica.es,Movistar,telefonica,1,telefonica,1 -21407,jazzinternet,JazztelInternet,nil,1,nil,nil -21407,movistar.es,Conexióompartida,MOVISTAR,1,MOVISTAR,1 -21407,internet.t-2.net,T-2,nil,1,nil,nil -21408,internet.euskaltel.mobi,EuskaltelInternet,EUSKALTEL,1,CLIENTE,1 -21416,internet.telecable.es,TeleCableInternet,telecable,1,telecable,nil -21418,internet.ono.com,ONOInternet,nil,1,nil,nil -21419,orangeworld,internetsimyo,orange,1,orange,1 -21421,jazzinternet,jazzinternet,nil,1,nil,nil -21427,iot.truphone.com,Truphone,nil,1,nil,nil -21432,tuenti.com,Tuenti,tuenti,1,tuenti,3 -21434,inet.es,INETInternet,nil,1,nil,nil -21601,online,TelenorOnline,nil,1,nil,nil -21601,net,DjuiceNET,nil,1,nil,0 -21601,wap,DjuiceWAP,nil,1,nil,0 -21630,internet.telekom,T-MobileH,nil,1,nil,1 -21670,internet.vodafone.net,VodafoneInternet,nil,1,nil,0 -21670,wap.vodafone.net,VodafoneLive!,vodawap,1,vodawap,1 -21670,vitamax.internet.vodafone.net,VodafoneInternetVitaMAX,nil,1,nil,nil -21670,vitamax.wap.vodafone.net,VodafoneLive!VitaMAX,vodawap,1,vodawap,1 -21803,wap.eronet.ba,HTEronetWAP,nil,1,nil,nil -21803,gprs.eronet.ba,HTEronetGPRS,nil,1,nil,nil -21805,3g1,m,nil,1,nil,nil -21890,active.bhmobile.ba,BHMobileInternet,nil,1,nil,nil -21901,internet.ht.hr,T-MobileInternet,nil,1,nil,1 -21901,web.htgprs,bonbonInternet,nil,1,nil,1 -21902,internet.tele2.hr,Tele2,nil,1,nil,nil -21910,data.vip.hr,Broadband,38591,1,38591,1 -22001,internet,Telenorinternet,gprs,1,telenor,1 -22002,internet,TelenorMNEinternet,gprs,1,gprs,nil -22003,gprswap,mt,064,1,mts,1 -22003,gprsinternet,MTSInternetRS,064,1,mts,0 -22004,tmcg-wnw,T-MobileInternet,38267,1,38267,nil -20404,pda.stm.sk.ca,SaskTel,nil,1,nil,nil -20465,agms,agms,nil,1,nil,nil -22005,vipmobile,VipGPRS,vipmobile,1,vipmobile,1 -22201,wap.tim.it,TIMWAP,nil,1,nil,nil -22201,ibox.tim.it,TIMDUN(IT),nil,1,nil,0 -22201,internet.windmobile.ca,Internet,nil,1,nil,nil -22201,modem.iusacellgsm.mx,Modem,iusacellgsm,1,iusacellgsm,0 -22201,web.iusacellgsm.mx,Internet,iusacellgsm,1,iusacellgsm,0 -22201,web.noverca.it,NOVERCAWEB,nil,1,nil,0 -22210,mobile.vodafone.it,Acc.Internetdacell,nil,1,nil,nil -22210,web.omnitel.it,TetheringInternet,nil,1,nil,0 -22210,wap.postemobile.it,PosteMobile,nil,1,nil,0 -22210,internet.postemobile.it,PosteMobile(DUN),nil,1,nil,0 -22210,mobile.erg.it,ErgMobileWAP,nil,1,nil,0 -22250,iliad,Iliad,nil,1,nil,nil -22254,data.plintron.it,Plintron,nil,1,nil,1 -22288,internet.wind,WINDWEB,nil,1,nil,nil -22288,internet.windmobile.ca,Internet,nil,1,nil,nil -22299,tre.it,3,nil,1,nil,nil -22299,apn.fastweb.it,FastwebWEB,nil,1,nil,nil -22601,live.vodafone.com,Vodafonelive!,vodafone,1,live,1 -22601,live.pre.vodafone.com,Vodafonelive!PRE,vodafone,1,live,0 -22603,broadband,CosmoteConnectMobile,nil,1,nil,nil -22603,wnw,web'n'walk,wnw,1,wnw,1 -22605,internet,Digi.Mobil,nil,1,nil,1 -22606,broadband,CosmoteConnectMobile,nil,1,nil,nil -22606,wnw,web'n'walk,wnw,1,wnw,nil -22610,net,OrangeInternet,nil,1,nil,nil -22801,gprs.swisscom.ch,SwisscomServices,nil,1,nil,nil -22802,internet,Sunriselive,nil,1,nil,nil -22803,internet,OrangeInternet,nil,1,nil,nil -22803,netgprs.com,netgprs.com,tsl,1,tsl,nil -23001,internet.t-mobile.cz,T-MobileCZ,wap,1,wap,1 -23002,internet,O2internet,nil,1,nil,nil -23003,internet,Internet,nil,1,nil,nil -23101,internet,OrangeSK,nil,1,nil,nil -23101,orangewap,OrangeWorld,wap,1,wap,1 -23102,internet,T-Mobileinternet,nil,1,nil,1 -23106,o2internet,O2internet,nil,1,nil,nil -23201,a1.net,live!,ppp,1,ppp@a1plus.at,1 -23203,internet.t-mobile.at,T-MobileLTE,tm,1,t-mobile,1 -23205,drei.at,Planet3,nil,1,nil,nil -23207,web,tele.ringweb,web,1,web@telering.at,1 -23210,drei.at,Planet3,nil,1,nil,nil -23211,bob.at,data.bob,ppp,1,data@bob.at,1 -23212,web.yesss.at,yesss!,nil,1,nil,nil -23222,data.plintron.at,Plintron,nil,1,nil,1 -23401,internet,UBIQUISYS,nil,1,nil,nil -23402,mobile.o2.co.uk,O2MOBILEWEB,O2web,1,O2web,nil -23408,internet.btonephone.com,BTOnePhoneInternet,nil,1,nil,nil -23410,mobile.o2.co.uk,O2MobileWeb,password,1,o2web,nil -23410,payandgo.o2.co.uk,O2Pay&Go,password,1,payandgo,nil -23410,prepay.tesco-mobile.com,TESCO,password,1,tescowap,1 -23410,giffgaff.com,giffgaff,password,1,giffgaff,1 -23410,mobiledata,JumpUK,nil,1,nil,0 -23411,mobile.o2.co.uk,O2MOBILEWEB,O2web,1,O2web,nil -23415,wap.vodafone.co.uk,VodafoneUK,wap,1,wap,1 -23415,pp.vodafone.co.uk,VodafoneUKPrepay,wap,1,wap,1 -23415,asdamobiles.co.uk,ASDAWAP,wap,1,wap,1 -23415,payg.talkmobile.co.uk,TalkmobPAYGWAP,wap,1,wap,1 -23415,talkmobile.co.uk,TalkmobWAP,wap,1,wap,1 -23415,mobile.talktalk.co.uk,TalkTalkWAP,nil,1,nil,nil -23415,payg.mobilebysainsburys.co.uk,Sainsbury'sPAYG,nil,1,nil,1 -23415,uk.lebara.mobi,LebaraInternet,wap,1,wap,1 -23420,three.co.uk,3,nil,1,nil,nil -23420,3hotspot,3Hotspot,nil,1,nil,0 -23426,data.lycamobile.co.uk,Lycamobile,plus,1,lmuk,1 -23430,goto.virginmobile.uk,VirginMediaMobileInternet,nil,1,user,1 -23430,everywhere,EEInternet,secure,1,eesecure,1 -23430,internet.btonephone.com,BTOnePhoneInternet,nil,1,nil,nil -23433,tslpaygnet,Internet,nil,1,nil,0 -23433,everywhere,EEInternet,secure,1,eesecure,1 -23425,iot.truphone.com,Truphone,nil,1,nil,nil -23439,Jump,Jump,nil,1,nil,nil -23439,gamma.co.uk,GammaData,nil,1,nil,nil -23450,pepper,pepperWEB(Jersey),nil,1,nil,nil -23455,internet,C&WGuernseyInternet,nil,1,nil,nil -23458,3gpronto,3GHSDPA,nil,1,nil,nil -23458,web.manxpronto.net,ManxTelecomContractWEB,gprs,1,gprs,nil -23486,everywhere,EEInternet,secure,1,eesecure,1 -23594,3hotspot,3hotspot,nil,1,nil,0 -23594,three.co.uk,3,nil,1,nil,nil -23801,internet,DKTDC,nil,1,nil,0 -23801,internet,TDCInternet,nil,1,nil,nil -23801,wap,TELMOREWAP,nil,1,nil,0 -23802,Internet,TelenorInternet,nil,1,nil,nil -23806,data.tre.dk,3,nil,1,nil,nil -23820,www.internet.mtelia.dk,TeliaSurfPort,nil,1,nil,nil -23820,webSP,CallmeInternet,nil,1,nil,nil -23830,web.orange.dk,OrangeDE,nil,1,nil,nil -23877,Internet,TelenorInternet,nil,1,nil,nil -24001,online.telia.se,Telia,nil,1,nil,nil -24001,halebop.telia.se,HalebopInternet,nil,1,nil,nil -24002,data.tre.se,3,nil,1,nil,nil -24004,data.tre.se,3,nil,1,nil,nil -24005,4g.tele2.se,Tele2Internet,nil,1,nil,nil -24005,internet.tele2.se,Tele2Internet3G,nil,1,nil,nil -24005,online.telia.se,Telia,nil,1,nil,nil -24005,halebop.telia.se,HalebopInternet,nil,1,nil,nil -24006,internet,Internet,nil,1,nil,nil -24007,4g.tele2.se,Tele2Internet,nil,1,nil,nil -24007,internet.tele2.se,Tele2Internet3G,nil,1,nil,nil -24007,internet.tele2.no,Tele2Internet,wap,1,wap,1 -24007,Jump,Jump,nil,1,nil,nil -24007,gamma.co.uk,GammaData,nil,1,nil,nil -24008,internet.telenor.se,TelenorSE,nil,1,nil,nil -24009,com4,Com4,nil,1,nil,nil -24010,data.springmobil.se,Springdata,nil,1,nil,nil -240017,halebop.telia.se,HalebopInternet,nil,1,nil,nil -24024,4g.tele2.se,Tele2Internet,nil,1,nil,nil -24024,internet.tele2.se,Tele2Internet3G,nil,1,nil,nil -24201,internet.ventelo.no,VenteloInternett,nil,1,nil,nil -24201,telenor,Telenor,nil,1,nil,nil -24202,netcom,NetCom,nil,1,nil,nil -24204,internet.tele2.no,Tele2Internet,nil,1,nil,nil -24205,internet,NwNInternet,nil,1,nil,nil -24209,com4,Com4,nil,1,nil,nil -24403,internet,DNAInternet,nil,1,nil,nil -24404,internet,DNAInternet,nil,1,nil,nil -24405,internet,ElisaInternet,nil,1,nil,nil -24405,internet.saunalahti,SaunalahtiInternet,nil,1,nil,nil -24410,internet.song.fi,TDCInternet,songnet,1,song@internet,nil -24412,internet,DNAInternet,nil,1,nil,nil -24412,dnapro.fi,DNAProInternet,nil,1,nil,1 -24412,inet.tdc.fi,TDCInternetFinland,nil,1,nil,1 -24413,internet,DNAInternet,nil,1,nil,nil -24421,internet.saunalahti,SaunalahtiInternet,nil,1,nil,nil -24491,internet,SONERAInternet,nil,1,nil,nil -24601,omnitel,OmnitelInternet,omni,1,omni,1 -24602,wap,BiteInternet,nil,1,nil,nil -24608,mezon,Mezon,nil,1,nil,nil -24603,internet.tele2.lt,Tele2InternetLT,nil,1,nil,nil -246081,VZW800,Test800,nil,3,nil,nil -246081,VZWINTERNET,TestInternet,nil,3,nil,3 -246081,VZWINTERNET,TestInternet,nil,3,nil,nil -24681,VZW800,Test800,nil,3,nil,nil -24681,VZWINTERNET,TestInternet,nil,3,nil,3 -24681,VZWINTERNET,TestInternet,nil,3,nil,nil -24701,internet.lmt.lv,LMTInternet,nil,1,nil,nil -24702,internet.tele2.lv,Tele2LVInternet,nil,1,nil,nil -24705,internet,BiteLVInternet,nil,1,nil,nil -24705,wap,BiteLVWAP,nil,1,nil,nil -24801,internet.emt.ee,EMTInternet,nil,1,nil,nil -24801,wap.emt.ee,EMTWAP,nil,1,nil,nil -24801,send.ee,Send,nil,1,nil,nil -24802,internet,ElisaInternet,nil,1,nil,nil -24802,wap,ElisaWAP,nil,1,nil,nil -24803,internet.tele2.ee,Tele2Internet,nil,1,nil,nil -25001,internet.mts.ru,MTSInternet,mts,1,mts,1 -25002,internet,MegafonInternet,nil,1,nil,nil -25011,yota.ru,YOTAInternet,nil,1,nil,nil -25020,internet.tele2.ru,TELE2Internet,nil,1,nil,nil -25028,vodalte.ru,VODAinternet,nil,1,nil,nil -25062,m.tinkoff,TinkoffMobile,nil,1,nil,nil -25099,internet.beeline.ru,BeelineInternet,beeline,1,beeline,1 -25501,internet,MTS-internet,nil,1,nil,nil -25502,internet.beeline.ua,Beeline-internet,nil,1,nil,nil -25503,www.kyivstar.net,KyivstarInternet,internet,1,igprs,1 -25503,www.djuice.com.ua,DjuiceInternet,nil,1,nil,nil -25506,internet,Life,nil,1,nil,nil -25507,3g.utel.ua,UtelInternet,nil,1,nil,nil -25701,web.velcom.by,VelcomInternet,nil,1,nil,1 -25702,mts,MTSInternet,mts,1,mts,1 -25704,internet.life.com.by,life,nil,1,nil,1 -25901,wap.orange.md,Orange_Internet_GPRS,nil,1,nil,nil -25902,internet,MoldcellInternet,nil,1,nil,nil -25905,internet3g.unite.md,UniteInternetPrePay,nil,1,nil,nil -25905,internet.unite.md,UniteInternetPostPay,nil,1,nil,nil -26001,plus,PlusInternet,nil,1,nil,nil -26002,internet,T-mobile.pl,nil,1,nil,nil -26002,heyah.pl,heyahinternet,nil,1,nil,nil -26003,Internet,OrangeInternet,internet,1,internet,1 -26006,internet,PlayInternet,nil,1,nil,nil -26033,iot.truphone.com,Truphone,nil,1,nil,nil -26044,rebtel,Rebtel,nil,1,nil,nil -26201,internet.telekom,TelekomInternet,telekom,1,telekom,1 -26202,web.vodafone.de,VodafoneDE,nil,1,nil,nil -26202,home.vodafone.de,VodafoneDE,nil,1,nil,nil -26203,internet.eplus.de,E-PlusInternet,internet,1,eplus,1 -26207,internet,o2Internet,nil,1,nil,nil -26207,pinternet.interkom.de,o2InternetPrepaid,nil,1,nil,nil -26207,webmobil1,TchiboInternet,nil,1,nil,nil -26242,iot.truphone.com,Truphone,nil,1,nil,nil -26801,net2.vodafone.pt,VodafoneNet2,vodafone,1,vodafone,1 -26801,internet.vodafone.pt,vodafonePdun,nil,1,nil,0 -26803,umts,PortalOptimus,nil,1,nil,nil -26803,modem,OptimusHotSpot,nil,1,nil,nil -26806,internet,tmninternet,nil,1,nil,nil -27001,wap.pt.lu,LUXGSMWAP,wap,1,wap,nil -27002,internet,MTXC,nil,1,nil,nil -27077,internet,TangoWAP,tango,1,tango,nil -27077,netgprs.com,netgprs.com,tsl,1,tsl,nil -27099,orange.lu,Orange,nil,1,nil,nil -27201,live.vodafone.com,VodafoneIE,nil,1,nil,nil -27201,hs.vodafone.ie,VodafoneMISP,vodafone,1,vodafone,0 -27202,3iot.com,3Ireland,nil,1,nil,nil -27202,internet,3Ireland,nil,1,nil,0 -27203,data.mymeteor.ie,MeteorData,wap,1,my,1 -27205,3ireland.ie,3Ireland,nil,1,nil,nil -27211,tescomobile.liffeytelecom.com,Tesco,nil,1,nil,nil -27401,internet,SiminnInternet,nil,1,nil,nil -27402,gprs.is,VodafoneInternet,nil,1,nil,nil -27403,gprs.is,VodafoneInternet,nil,1,nil,0 -27411,net.nova.is,NetNova,nil,1,nil,nil -27801,internet,VodafoneMT,internet,1,internet,nil -28001,cytamobile,CYTA,nil,1,nil,nil -28010,internet,MTNInternet,nil,1,nil,nil -28020,ip.primetel,PrimeTel,nil,1,nil,nil -28401,inet-gprs.mtel.bg,MTel,nil,1,nil,nil -28403,internet.vivacom.bg,VIVACOMInternet,vivacom,1,vivacom,1 -28405,telenorbg,TelenorInternet,nil,1,nil,0 -28411,bulsat.com,bulsatcom,nil,1,nil,nil -28413,apn.maxtelecom.bg,MAXTELECOM,nil,1,nil,nil -28601,internet,TURKCELLINTERNET,nil,1,nil,nil -28602,internet,Vodafoneinternet,nil,1,nil,1 -28603,internet,AVEAINTERNET,nil,1,nil,1 -29001,internet,TeleInternet,nil,1,nil,nil -29340,internet.simobil.si,Si.mobilGPRS,internet,1,simobil,1 -29341,internet,MobilniInternet,internet,1,mobitel,1 -29364,internet.t-2.net,T2,nil,1,nil,nil -29370,internet.tusmobil.si,TusmobilInternet,internet,1,tusmobil,1 -29370,telemach.net,TelemachInternet,nil,1,nil,nil -29401,internet,T-MobileMKInternet,t-mobile,1,internet,nil -29402,Internet,Cosmofon,Internet,1,Internet,nil -29403,vipoperator,Internet,vipoperator,1,vipoperator,nil -29505,em,EMnify,nil,1,nil,nil -29509,em,EMnify,nil,1,nil,nil -29509,bicsapn,BICS,nil,1,nil,nil -29702,tmcg-wnw,T-MobileInternet,38267,1,38267,nil -302220,sp.telus.com,TELUS,nil,1,nil,nil -302220,isp.telus.com,TELUSTether,nil,1,nil,nil -302220,sp.koodo.com,Koodo,nil,1,nil,nil -302220,sp.mb.com,MobileInternet,nil,1,nil,nil -302220,isp.mb.com,TetheredMobileInternet,nil,1,nil,nil -302221,isp.telus.com,TELUSISP,nil,1,nil,nil -302221,sp.koodo.com,Koodo,nil,1,nil,nil -302221,isp.mb.com,TetheredPCMobile,nil,1,nil,nil -302320,wap.davewireless.com,MOWAP,nil,1,nil,nil -302270,wisp.mobi.eastlink.ca,Internet,nil,1,nil,nil -302370,ltedata.apn,FidoTethering,nil,1,nil,nil -302370,ltemobile.apn,FidoInternet,nil,1,nil,nil -302370,sp.mts,MTS,nil,1,nil,nil -302370,internet.mts,MTSTetheringS,nil,1,nil,nil -302490,internet.windmobile.ca,Internet,nil,1,nil,nil -302500,media.ng,Media,nil,1,nil,nil -302510,media.ng,Media,nil,1,nil,nil -302520,media.ng,Media,nil,1,nil,nil -302610,pda.bell.ca,BellMobility,nil,1,nil,nil -302610,ota.bell.ca,BellMobility,nil,1,nil,nil -302660,sp.mts,MTS,nil,1,nil,nil -302660,internet.mts,MTSTethering,nil,1,nil,nil -302720,ltemobile.apn,RogersLTE,nil,1,nil,nil -302720,chatrweb.apn,chatr,nil,1,nil,nil -302720,chatrisp.apn,ChatrTethering,nil,1,nil,nil -302720,ltedata.apn,TbaytelTethering,nil,1,nil,nil -302780,pda.stm.sk.ca,SaskTel,nil,1,nil,nil -310000,VZWINTERNET,Bluewire,nil,3,nil,nil -310020,union.wap.com,UnionWirelessData,nil,1,nil,nil -310004,internet,Verizon,nil,3,nil,3 -310028,VZWINTERNET,ALUTest-SIMInternet,nil,3,nil,nil -310030,private.centennialwireless.com,Internet,priv,1,privuser,nil -310032,VZWINTERNET,Itewire,nil,3,nil,nil -310035,VZWINTERNET,Etex,nil,3,nil,nil -310040,VZWINTERNET,Mta,nil,3,nil,nil -310050,VZWINTERNET,Alaskacomm,nil,3,nil,nil -310066,internet,U.S.Cellular,*,1,*,nil -310080,corrgprs,CorrWap,nil,1,nil,nil -310090,isp,Internet,nil,1,nil,nil -310100,isp.plateau,PLATWEB,nil,1,nil,nil -310120,sprint,Sprint,nil,1,nil,nil -310120,otasn,OTA,nil,1,nil,nil -310120,cinet.spcs,SPCSGlobal,nil,1,nil,nil -310130,VZWINTERNET,Carolinawest,nil,3,nil,nil -310150,ndo,internet,nil,1,nil,nil -310160,fast.t-mobile.com,T-MobileUS160,nil,1,nil,nil -310160,pcweb.tmobile.com,T-MobileUS160DUN,none,1,none,nil -310160,fast.metropcs.com,MetroPCS160,nil,1,nil,nil -310170,isp.cingular,DataConnect,nil,1,nil,nil -310180,internet.wcc.net,WCW-INTERNET,mmsc,1,13257630000,nil -310200,fast.t-mobile.com,T-MobileUS200,nil,1,nil,nil -310200,pcweb.tmobile.com,T-MobileUS200DUN,none,1,none,nil -310200,fast.metropcs.com,MetroPCS200,nil,1,nil,nil -310210,fast.t-mobile.com,T-MobileUS210,nil,1,nil,nil -310210,pcweb.tmobile.com,T-MobileUS210DUN,none,1,none,nil -310210,fast.metropcs.com,MetroPCS210,nil,1,nil,nil -310220,fast.t-mobile.com,T-MobileUS220,nil,1,nil,nil -310220,pcweb.tmobile.com,T-MobileUS220DUN,none,1,none,nil -310220,fast.metropcs.com,MetroPCS220,nil,1,nil,nil -310230,fast.t-mobile.com,T-MobileUS230,nil,1,nil,nil -310230,pcweb.tmobile.com,T-MobileUS230DUN,none,1,none,nil -310230,fast.metropcs.com,MetroPCS230,nil,1,nil,nil -310240,fast.t-mobile.com,T-MobileUS240,nil,1,nil,nil -310240,pcweb.tmobile.com,T-MobileUS240DUN,none,1,none,nil -310240,fast.metropcs.com,MetroPCS240,nil,1,nil,nil -310250,fast.t-mobile.com,T-MobileUS250,nil,1,nil,nil -310250,pcweb.tmobile.com,T-MobileUS250DUN,none,1,none,nil -310250,fast.metropcs.com,MetroPCS250,nil,1,nil,nil -310260,fast.t-mobile.com,T-MobileGPRS,nil,1,nil,nil -310260,h2g2,ProjectFi-T,none,1,none,nil -310260,fast.metropcs.com,MetroPCS260,nil,1,nil,nil -310260,simple,SIMPLE,nil,1,nil,nil -310260,wap.tracfone,TFWAP,nil,1,nil,nil -310260,wholesale,ConsumerCellular,nil,1,nil,nil -310270,fast.t-mobile.com,T-MobileUS270,nil,1,nil,nil -310270,pcweb.tmobile.com,T-MobileUS270DUN,none,1,none,nil -310270,fast.metropcs.com,MetroPCS270,nil,1,nil,nil -310280,agms,agms,nil,1,nil,nil -310300,fast.t-mobile.com,T-MobileUS300,nil,1,nil,nil -310300,pcweb.tmobile.com,T-MobileUS300DUN,none,1,none,nil -310300,fast.metropcs.com,MetroPCS300,nil,1,nil,nil -310310,fast.t-mobile.com,T-MobileUS310,nil,1,nil,nil -310310,pcweb.tmobile.com,T-MobileUS310DUN,none,1,none,nil -310310,fast.metropcs.com,MetroPCS310,nil,1,nil,nil -310320,isp.cellularoneaz.net,CellularOneNEAZISP,nil,1,nil,nil -310330,VZWINTERNET,Alltel2,nil,3,nil,nil -310360,VZWINTERNET,Pioneer,nil,3,nil,nil -310380,proxy,Cingular380ATT,nil,1,nil,nil -310380,agms.nl.gmm,AGMSGlobal,nil,1,nil,nil -310410,broadband,ATTNextgenphone,nil,1,nil,nil -310410,phone,ATTPhone,nil,1,nil,nil -310410,wap.cingular,ATTWAP,nil,1,nil,nil -310410,PRODATA,DefenseMobile,nil,1,nil,nil -310410,tfdata,TFDATA,nil,1,nil,nil -310420,wap.gocbw.com,CBWData,nil,1,nil,nil -310430,VZWINTERNET,Gci,nil,3,nil,nil -310450,internet.vedge.com,ViaeroConnect,nil,1,nil,nil -310470,isp.cingular,DataConnect,nil,1,nil,nil -310470,wap.cingular,MediaNet,CINGULAR1,1,WAP@CINGULARGPRS.COM,nil -310470,admin.4g.ntelos.com,nTelosOta,nil,1,nil,nil -310470,internet.4g.ntelos.com,nTelosWireless,nil,1,nil,nil -310470,tethering.4g.ntelos.com,nTelosTether,nil,1,nil,nil -310480,isp.cingular,DataConnect,nil,1,nil,nil -310480,wap.cingular,MediaNet,CINGULAR1,1,WAP@CINGULARGPRS.COM,nil -310490,fast.t-mobile.com,T-MobileUS490,nil,1,nil,nil -310490,pcweb.tmobile.com,T-MobileUS490DUN,none,1,none,nil -310490,fast.metropcs.com,MetroPCS490,nil,1,nil,nil -310530,fast.t-mobile.com,T-MobileUS530,nil,1,nil,nil -310530,pcweb.tmobile.com,T-MobileUS530DUN,none,1,none,nil -310530,fast.metropcs.com,MetroPCS530,nil,1,nil,nil -310560,nxtgenphone,ATTNextgenphone,nil,1,nil,nil -310570,internet,CellularOneSmartphone,nil,1,nil,nil -310580,VZWINTERNET,Inland,nil,3,nil,nil -310590,fast.t-mobile.com,T-MobileUS590,nil,1,nil,nil -310590,pcweb.tmobile.com,T-MobileUS590DUN,none,1,none,nil -310590,fast.metropcs.com,MetroPCS590,nil,1,nil,nil -310600,VZWINTERNET,Cellcom,nil,3,nil,nil -310610,internet.epictouch,EpicINT,nil,1,nil,nil -310640,fast.t-mobile.com,T-MobileUS640,nil,1,nil,nil -310640,pcweb.tmobile.com,T-MobileUS640DUN,none,1,none,nil -310640,fast.metropcs.com,MetroPCS640,nil,1,nil,nil -310660,fast.t-mobile.com,T-MobileUS660,nil,1,nil,nil -310660,pcweb.tmobile.com,T-MobileUS660DUN,none,1,none,nil -310660,fast.metropcs.com,MetroPCS660,nil,1,nil,nil -31069,iot.truphone.com,Truphone,nil,1,nil,nil -310720,internet.com,RogersInternet,nil,1,nil,nil -310750,VZWINTERNET,Appalachian,nil,3,nil,nil -310770,i2.iwireless.com,Web2,nil,1,nil,nil -310770,wap1.iwireless.com,Web1,nil,1,nil,nil -310800,fast.t-mobile.com,T-MobileUS800,nil,1,nil,nil -310800,pcweb.tmobile.com,T-MobileUS800DUN,none,1,none,nil -310800,fast.metropcs.com,MetroPCS800,nil,1,nil,nil -310840,isp,Internet,nil,1,nil,nil -310880,wapdtcw.com,DTCdtcwap,nil,1,nil,nil -310900,VZWINTERNET,Midrivers,nil,3,nil,nil -310910,wap.firstcellular.com,WOW_WAP,nil,1,nil,nil -310920,VZWINTERNET,Jamesvalley,nil,3,nil,nil -310930,VZWINTERNET,CopperValley,nil,3,nil,nil -310960,VZWINTERNET,Nntcwire,nil,3,nil,nil -311050,VZWINTERNET,Thumbcellular,nil,3,nil,nil -311070,VZWINTERNET,Elementmobile,nil,3,nil,nil -311080,PINE,PINEWAP,nil,1,nil,nil -311140,VZWINTERNET,Sprocket,nil,3,nil,nil -311190,isp.cellular1.net,ISP,nil,1,nil,nil -311190,broadband.cellular1.net,Tether,nil,1,nil,nil -311210,internet.farmerswireless.com,FarmersGPRS,nil,1,nil,nil -311220,usccinternet,U.S.Cellular,nil,1,nil,nil -311221,usccinternet,U.S.Cellular,nil,1,nil,nil -311222,usccinternet,U.S.Cellular,nil,1,nil,nil -311223,usccinternet,U.S.Cellular,nil,1,nil,nil -311224,usccinternet,U.S.Cellular,nil,1,nil,nil -311225,usccinternet,U.S.Cellular,nil,1,nil,nil -311226,usccinternet,U.S.Cellular,nil,1,nil,nil -311227,usccinternet,U.S.Cellular,nil,1,nil,nil -311228,usccinternet,U.S.Cellular,nil,1,nil,nil -311229,usccinternet,U.S.Cellular,nil,1,nil,nil -311230,admin.cs4glte.com,CSpireota,nil,1,nil,nil -311230,internet.cs4glte.com,CSpireinternet,nil,1,nil,nil -311230,tethering.cs4glte.com,CSpiretether,nil,1,nil,nil -311310,VZWINTERNET,Leaco,nil,3,nil,nil -311340,VZWINTERNET,Illinoisvalley,nil,3,nil,nil -311350,VZWINTERNET,Nemont,nil,3,nil,nil -311370,web.gci,GCIWEB,nil,1,nil,nil -311370,web.acs,ACSWEB,nil,1,nil,nil -311410,VZWINTERNET,Chatmobrsa2,nil,3,nil,nil -311420,VZWINTERNET,Northwestcell,nil,3,nil,nil -311430,VZWINTERNET,Chatmobrsa1,nil,3,nil,nil -311440,VZWINTERNET,Bluegrass,nil,3,nil,nil -311450,VZWINTERNET,Ptci,nil,3,nil,nil -311500,wap,24-7WAP,nil,1,nil,nil -311530,mms.mymobiletxt.com,Blaze,nil,1,nil,nil -311530,wap.mymobiletxt.com,DuetInternet,nil,1,nil,nil -311580,usccinternet,U.S.Cellular,nil,1,nil,nil -311581,usccinternet,U.S.Cellular,nil,1,nil,nil -311582,usccinternet,U.S.Cellular,nil,1,nil,nil -311583,usccinternet,U.S.Cellular,nil,1,nil,nil -311584,usccinternet,U.S.Cellular,nil,1,nil,nil -311585,usccinternet,U.S.Cellular,nil,1,nil,nil -311586,usccinternet,U.S.Cellular,nil,1,nil,nil -311587,usccinternet,U.S.Cellular,nil,1,nil,nil -311588,usccinternet,U.S.Cellular,nil,1,nil,nil -311589,usccinternet,U.S.Cellular,nil,1,nil,nil -311600,VZWINTERNET,Cox,nil,3,nil,nil -311610,VZWINTERNET,Srtcomm,nil,3,nil,nil -311650,VZWINTERNET,Unitedwireless,nil,3,nil,nil -311670,VZWINTERNET,Pinebelt,nil,3,nil,nil -311740,akcell.mobi,TelAlaskaCellular,nil,1,nil,nil -311750,CdmaNai,Cleartalk,nil,1,nil,3 -311750,home.netamerica.com,ClearTalkLTE,nil,1,nil,nil -311910,mymn4g.net,MobileNation,nil,1,nil,nil -311920,VZWINTERNET,Charitonvalley,nil,3,nil,nil -311930,internet.syringawireless.com,SyringaWireless,nil,1,nil,nil -312420,admin.lte.ntwls.com,NexTechOta,nil,1,nil,nil -312420,internet.lte.ntwls.com,NexTechWireless,nil,1,nil,nil -312420,modem.lte.ntwls.com,NexTechTether,nil,1,nil,nil -312570,BlueHotspot,BlueWireless,wirelessblue,1,%M@dun.bluehandset.com,nil -330000,VZWINTERNET,Openmobile,nil,3,nil,nil -330110,lte.claropr.com,PuertoRico,nil,1,nil,1 -334020,internet.itelcel.com,Internet,webgprs2002,1,webgprs,1 -33403,internet.movistar.mx,MovistarINTERNET,movistar,1,movistar,1 -334030,internet.movistar.mx,MovistarINTERNET,movistar,1,movistar,1 -334050,web.iusacellgsm.mx,IusacellInternet,iusacellgsm,1,iusacellgsm,nil -33450,modem.iusacellgsm.mx,Modem,iusacellgsm,1,iusacellgsm,1 -334090,location.nexteldata.com.mx,Localización,nil,1,nil,0 -334090,modem.nexteldata.com.mx,Internet,nil,1,nil,0 -334090,wap.nexteldata.com.mx,Navegación,nil,1,nil,0 -33805,web,INTERNETDigicel,nil,1,nil,nil -338050,web,INTERNETDigicel,nil,1,nil,nil -33818,internet,LimeInternetPostpaid,nil,1,nil,nil -33818,ppinternet,LimeInternetPrepaid,nil,1,nil,nil -338180,internet,LimeInternetPostpaid,nil,1,nil,nil -338180,ppinternet,LimeInternetPrepaid,nil,1,nil,nil -338070,internet.ideasclaro.com.jm,ClaroWeb,nil,1,nil,1 -338180,internet,LimeInternetPostpaid,nil,1,nil,1 -34001,orangeweb,OrangeWorldCaraïbe,orange,1,orange,nil -34001,orangeweb,Orangeweb,orange,1,orange,1 -34020,web.digicelfr.com,DigicelWeb,nil,1,nil,nil -34260,internet,LimeInternetPostpaid,nil,1,nil,nil -342600,internet,Barbado,nil,1,nil,1 -34492,internet,LimeInternetPostpaid,nil,1,nil,nil -344920,internet,Antigua,nil,1,nil,1 -34614,internet,LimeInternetPostpaid,nil,1,nil,nil -346140,internet,CaymanIslands,nil,1,nil,1 -34817,internet,LimeInternetPostpaid,nil,1,nil,nil -34877,wap.digicelbvi.com,Bvi,nil,1,nil,1 -34877,wap.digicelbvi.com,Bvi,wapbvi,1,wapbvi,1 -348170,internet,Bvi,nil,1,nil,1 -35211,internet,LimeInternetPostpaid,nil,1,nil,nil -352110,internet,Grenada,nil,1,nil,1 -35486,internet,LimeInternetPostpaid,nil,1,nil,nil -354860,internet,Monserrat,nil,1,nil,1 -35611,internet,LimeInternetPostpaid,nil,1,nil,nil -356110,internet,StKittsAndNevis,nil,1,nil,1 -35811,internet,LimeInternetPostpaid,nil,1,nil,nil -36011,internet,LimeInternetPostpaid,nil,1,nil,nil -358110,internet,StLucia,nil,1,nil,1 -360110,internet,StVincent,nil,1,nil,1 -36269,web.digicelcuracao.com,Curacao,nil,1,nil,1 -36269,wap,Curacao,nil,1,nil,1 -36302,web.digicelaruba.com,INTERNETAruba,nil,1,nil,1 -363020,web.digicelaruba.com,INTERNETAruba,nil,1,nil,1 -36449,pda.newcomobile.com,BeAliv,nil,1,nil,nil -36584,internet,LimeInternetPostpaid,nil,1,nil,nil -365840,internet,Anguilla,nil,1,nil,1 -36611,internet,LimeInternetPostpaid,nil,1,nil,nil -366110,internet,Dominica,nil,1,nil,1 -36801,internet,Internet,nil,1,nil,nil -37001,orangeinternet,OrangeInternet(LTE),nil,1,nil,nil -37001,orangenet.com.do,Orangenet(3G),nil,1,nil,nil -37002,internet.ideasclaro.com.do,InternetMóvilClaro,nil,1,nil,nil -370020,internet.ideasclaro.com.do,InternetMóvilClaro,nil,1,nil,nil -37004,edge.viva.net.do,VivaEdge(GSM),viva,1,viva,1 -37202,wap.digicelha.com,Haiti,nil,1,nil,1 -37202,wap.digicelha.com,Haiti,wap01ha,1,wapha,1 -37203,natcom,NATCOMINTERNET,nil,1,nil,nil -37412,internet,Bmobileinternet,nil,1,nil,1 -374120,internet,Bmobileinternet,nil,1,nil,1 -374121,internet,Bmobileinternet,nil,1,nil,1 -374122,internet,Bmobileinternet,nil,1,nil,1 -374123,internet,Bmobileinternet,nil,1,nil,1 -374124,internet,Bmobileinternet,nil,1,nil,1 -374125,internet,Bmobileinternet,nil,1,nil,1 -374126,internet,Bmobileinternet,nil,1,nil,1 -374127,internet,Bmobileinternet,nil,1,nil,1 -374128,internet,Bmobileinternet,nil,1,nil,1 -374129,internet,Bmobileinternet,nil,1,nil,1 -37413,web.digiceltt.com,INTERNETTrinidad,nil,1,nil,1 -374130,web.digiceltt.com,INTERNETTrinidad,nil,1,nil,1 -37635,internet,LimeInternetPostpaid,nil,1,nil,nil -376350,internet,TurksAndCaicos,nil,1,nil,1 -40001,default,Azercell,nil,1,nil,nil -40002,default,Bakcell,nil,1,nil,nil -40003,default,FONEX,nil,1,nil,nil -40004,default,NarMobile,nil,1,nil,nil -40101,internet.beeline.kz,BeelineInternet,beeline,1,@internet.beeline,1 -40101,internet.dos.kz,DOSInternet,nil,1,nil,nil -40102,internet,KcellInternet,nil,1,nil,nil -40107,internet,ALTELINTERNET,nil,1,nil,nil -40177,internet,Tele2Internet,nil,1,nil,nil -40211,default,B-Mobile,nil,1,nil,nil -40277,ticlnet,TashiCell,nil,1,nil,nil -40401,portalnmms,Vodafonelive,nil,1,nil,nil -40401,www,Vodafonemobileconnect,nil,1,nil,nil -40402,airtelfun.com,AIRTELLIVE,nil,1,nil,nil -40402,airtelgprs.com,MobileOffice,nil,1,nil,nil -40403,airtelgprs.com,MobileOffice,nil,1,nil,nil -40403,airtelfun.com,AIRTELLIVE,nil,1,nil,nil -40404,internet,Idea_Internet,nil,1,nil,nil -40404,imis,IDEAGPRS,nil,1,nil,nil -40405,www,Vodafonemobileconnect,nil,1,nil,nil -40405,portalnmms,Vodafonelive,nil,1,nil,nil -40407,internet,Idea_Internet,nil,1,nil,nil -40407,imis,IDEAGPRS,nil,1,nil,nil -40409,smartnet,RelianceNet,nil,1,nil,nil -40409,smartwap,RelianceWAP,nil,1,nil,1 -40410,airtelgprs.com,MobileOffice,nil,1,nil,nil -40410,airtelfun.com,AIRTELLIVE,nil,1,nil,nil -40411,www,Vodafonemobileconnect,nil,1,nil,nil -40411,portalnmms,Vodafonelive,nil,1,nil,nil -40412,internet,Idea_Internet,nil,1,nil,nil -40412,imis,IDEAGPRS,nil,1,nil,nil -40413,www,Vodafonemobileconnect,nil,1,nil,nil -40413,portalnmms,Vodafonelive,nil,1,nil,nil -40414,internet,Idea_Internet,nil,1,nil,nil -40414,imis,IDEAGPRS,nil,1,nil,nil -40415,www,Vodafonemobileconnect,nil,1,nil,nil -40415,portalnmms,Vodafonelive,nil,1,nil,nil -40416,airtelgprs.com,MobileOffice,nil,1,nil,nil -40416,airtelfun.com,AIRTELLIVE,nil,1,nil,nil -40417,aircelwebpost,Aircel-GPRS-Postpaid,nil,1,nil,nil -40417,aircelwappost,PocketInternet-Postpaid,nil,1,nil,nil -40417,aircelwap,PocketInternet-Prepaid,nil,1,nil,nil -40417,aircelweb,Aircel-GPRS-Prepaid,nil,1,nil,nil -40417,aircelgprs,AircelInternet(40417),nil,1,nil,nil -40418,smartnet,RelianceNet,nil,1,nil,nil -40418,smartwap,RelianceWAP,nil,1,nil,1 -40418,rcomnet,RelianceInternet(40418),nil,1,nil,nil -40419,internet,Idea_Internet,nil,1,nil,nil -40419,imis,IDEAGPRS,nil,1,nil,nil -40420,www,Vodafonemobileconnect,nil,1,nil,nil -40420,portalnmms,Vodafonelive,nil,1,nil,nil -40421,www,LoopMobile,nil,1,nil,nil -40422,internet,Idea_Internet,nil,1,nil,nil -40422,imis,IDEAGPRS,nil,1,nil,nil -40424,internet,Idea_Internet,nil,1,nil,nil -40424,imis,IDEAGPRS,nil,1,nil,nil -40425,aircelwebpost,Aircel-GPRS-Postpaid,nil,1,nil,nil -40425,aircelwappost,PocketInternet-Postpaid,nil,1,nil,nil -40425,aircelwap,PocketInternet-Prepaid,nil,1,nil,nil -40425,aircelweb,Aircel-GPRS-Prepaid,nil,1,nil,nil -40425,aircelgprs,AircelInternet(40425),nil,1,nil,nil -40427,www,Vodafonemobileconnect,nil,1,nil,nil -40427,portalnmms,Vodafonelive,nil,1,nil,nil -40428,aircelwebpost,Aircel-GPRS-Postpaid,nil,1,nil,nil -40428,aircelwappost,PocketInternet-Postpaid,nil,1,nil,nil -40428,aircelwap,PocketInternet-Prepaid,nil,1,nil,nil -40428,aircelweb,Aircel-GPRS-Prepaid,nil,1,nil,nil -40428,aircelgprs,AircelInternet(40428),nil,1,nil,nil -40429,aircelwebpost,Aircel-GPRS-Postpaid,nil,1,nil,nil -40429,myaircelpost,PocketInternet-Postpaid,nil,1,nil,nil -40429,myaircel,PocketInternet-Prepaid,nil,1,nil,nil -40429,aircelweb,Aircel-GPRS-Prepaid,nil,1,nil,nil -40429,aircelgprs,AircelInternet(40429),nil,1,nil,nil -40429,aircelwap,AircelWAP(40429),nil,1,nil,nil -40430,www,Vodafonemobileconnect,nil,1,nil,nil -40430,portalnmms,Vodafonelive,nil,1,nil,nil -40431,airtelgprs.com,MobileOffice,nil,1,nil,nil -40431,airtelfun.com,AIRTELLIVE,nil,1,nil,nil -40433,aircelwebpost,Aircel-GPRS-Postpaid,nil,1,nil,nil -40433,myaircelpost,PocketInternet-Postpaid,nil,1,nil,nil -40433,myaircel,PocketInternet-Prepaid,nil,1,nil,nil -40433,aircelweb,Aircel-GPRS-Prepaid,nil,1,nil,nil -40433,aircelgprs,AircelInternet(40433),nil,1,nil,nil -40433,aircelwap,AircelWAP(40433),nil,1,nil,nil -40434,bsnlnet,bsnlnet,nil,1,nil,1 -40434,bsnllive,bsnllive,nil,1,nil,nil -40435,aircelwebpost,Aircel-GPRS-Postpaid,nil,1,nil,nil -40435,aircelwappost,PocketInternet-Postpaid,nil,1,nil,nil -40435,aircelwap,PocketInternet-Prepaid,nil,1,nil,nil -40435,aircelweb,Aircel-GPRS-Prepaid,nil,1,nil,nil -40435,aircelgprs,AircelInternet(40435),nil,1,nil,nil -40436,smartnet,RelianceNet,nil,1,nil,nil -40436,smartwap,RelianceWAP,nil,1,nil,1 -40436,rcomnet,RelianceInternet(40436),nil,1,nil,nil -40437,aircelwebpost,Aircel-GPRS-Postpaid,nil,1,nil,nil -40437,aircelwappost,PocketInternet-Postpaid,nil,1,nil,nil -40437,aircelwap,PocketInternet-Prepaid,nil,1,nil,nil -40437,aircelweb,Aircel-GPRS-Prepaid,nil,1,nil,nil -40437,aircelgprs,AircelInternet(40437),nil,1,nil,nil -40438,bsnlnet,bsnlnet,nil,1,nil,nil -40438,bsnllive,bsnllive,nil,1,nil,nil -40440,airtelgprs.com,MobileOffice,nil,1,nil,nil -40440,airtelfun.com,AIRTELLIVE,nil,1,nil,nil -40441,aircelgprs.po,Aircel-GPRS-Postpaid,nil,1,nil,nil -40441,aircelgprs.pr,Aircel-GPRS-Prepaid,nil,1,nil,nil -40441,aircelwap.po,PocketInternet-Postpaid,nil,1,nil,nil -40441,aircelwap.pr,PocketInternet-Prepaid,nil,1,nil,nil -40441,aircelgprs,AircelInternet(40441),nil,1,nil,nil -40441,aircelwap,AircelWAP(40441),nil,1,nil,nil -40442,aircelgprs.po,Aircel-GPRS-Postpaid,nil,1,nil,nil -40442,aircelgprs.pr,Aircel-GPRS-Prepaid,nil,1,nil,nil -40442,aircelwap.po,PocketInternet-Postpaid,nil,1,nil,nil -40442,aircelwap.pr,PocketInternet-Prepaid,nil,1,nil,nil -40442,aircelgprs,AircelInternet(40442),nil,1,nil,nil -40443,www,Vodafonemobileconnect,nil,1,nil,nil -40443,portalnmms,Vodafonelive,nil,1,nil,nil -40444,internet,Idea_Internet,nil,1,nil,nil -40444,imis,IDEAGPRS,nil,1,nil,nil -40445,airtelgprs.com,MobileOffice,nil,1,nil,nil -40445,airtelfun.com,AIRTELLIVE,nil,1,nil,nil -40446,www,Vodafonemobileconnect,nil,1,nil,nil -40446,portalnmms,Vodafonelive,nil,1,nil,nil -40449,airtelgprs.com,MobileOffice,nil,1,nil,nil -40449,airtelfun.com,AIRTELLIVE,nil,1,nil,nil -40450,smartnet,RelianceNet,nil,1,nil,nil -40450,smartwap,RelianceWAP,nil,1,nil,1 -40451,bsnlnet,bsnlnet,nil,1,nil,nil -40451,bsnllive,bsnllive,nil,1,nil,nil -40452,smartnet,RelianceNet,nil,1,nil,nil -40452,smartwap,RelianceWAP,nil,1,nil,1 -40453,bsnlnet,bsnlnet,nil,1,nil,nil -40453,bsnllive,bsnllive,nil,1,nil,nil -40454,bsnlnet,bsnlnet,nil,1,nil,nil -40454,bsnllive,bsnllive,nil,1,nil,nil -40455,bsnlnet,bsnlnet,nil,1,nil,nil -40455,bsnllive,bsnllive,nil,1,nil,nil -40456,internet,Idea_Internet,nil,1,nil,nil -40456,imis,IDEAGPRS,nil,1,nil,nil -40457,bsnlnet,bsnlnet,nil,1,nil,nil -40457,bsnllive,bsnllive,nil,1,nil,nil -40458,bsnlnet,bsnlnet,nil,1,nil,nil -40458,bsnllive,bsnllive,nil,1,nil,nil -40459,bsnlnet,bsnlnet,nil,1,nil,nil -40459,bsnllive,bsnllive,nil,1,nil,nil -40460,www,Vodafonemobileconnect,nil,1,nil,nil -40460,portalnmms,Vodafonelive,nil,1,nil,nil -40462,bsnlnet,bsnlnet,nil,1,nil,nil -40462,bsnllive,bsnllive,nil,1,nil,nil -40464,bsnlnet,bsnlnet,nil,1,nil,nil -40464,bsnllive,bsnllive,nil,1,nil,nil -40466,bsnlnet,bsnlnet,nil,1,nil,nil -40466,bsnllive,bsnllive,nil,1,nil,nil -40467,smartnet,RelianceNet,nil,1,nil,nil -40467,smartwap,RelianceWAP,nil,1,nil,1 -40468,mtnl.net,MTNL,mtnl123,1,mtnl,0 -40469,mtnl.net,MTNL,mtnl123,1,mtnl,0 -40470,airtelgprs.com,MobileOffice,nil,1,nil,nil -40470,airtelfun.com,AIRTELLIVE,nil,1,nil,nil -40471,bsnlnet,bsnlnet,nil,1,nil,nil -40471,bsnllive,bsnllive,nil,1,nil,nil -40472,bsnlnet,bsnlnet,nil,1,nil,nil -40472,bsnllive,bsnllive,nil,1,nil,nil -40473,bsnlnet,bsnlnet,nil,1,nil,nil -40473,bsnllive,bsnllive,nil,1,nil,nil -40474,bsnlnet,bsnlnet,nil,1,nil,nil -40474,bsnllive,bsnllive,nil,1,nil,nil -40475,bsnlnet,bsnlnet,nil,1,nil,nil -40475,bsnllive,bsnllive,nil,1,nil,nil -40476,bsnlnet,bsnlnet,nil,1,nil,nil -40476,bsnllive,bsnllive,nil,1,nil,nil -40477,bsnlnet,bsnlnet,nil,1,nil,nil -40477,bsnllive,bsnllive,nil,1,nil,nil -40478,internet,Idea_Internet,nil,1,nil,nil -40478,imis,IDEAGPRS,nil,1,nil,nil -40479,bsnlnet,bsnlnet,nil,1,nil,nil -40479,bsnllive,bsnllive,nil,1,nil,nil -40480,bsnlnet,bsnlnet,nil,1,nil,nil -40480,bsnllive,bsnllive,nil,1,nil,nil -40481,bsnlnet,bsnlnet,nil,1,nil,nil -40481,bsnllive,bsnllive,nil,1,nil,nil -40482,internet,Idea_Internet,nil,1,nil,nil -40482,imis,IDEAGPRS,nil,1,nil,nil -40483,smartnet,RelianceNet,nil,1,nil,nil -40483,smartwap,RelianceWAP,nil,1,nil,1 -40484,www,Vodafonemobileconnect,nil,1,nil,nil -40484,portalnmms,Vodafonelive,nil,1,nil,nil -40485,smartnet,RelianceNet,nil,1,nil,nil -40485,smartwap,RelianceWAP,nil,1,nil,1 -40486,www,Vodafonemobileconnect,nil,1,nil,nil -40486,portalnmms,Vodafonelive,nil,1,nil,nil -40487,internet,Idea_Internet,nil,1,nil,nil -40487,imis,IDEAGPRS,nil,1,nil,nil -40488,www,Vodafonemobileconnect,nil,1,nil,nil -40488,portalnmms,Vodafonelive,nil,1,nil,nil -40489,internet,Idea_Internet,nil,1,nil,nil -40489,imis,IDEAGPRS,nil,1,nil,nil -40490,airtelgprs.com,MobileOffice,nil,1,nil,nil -40490,airtelfun.com,AIRTELLIVE,nil,1,nil,nil -40491,aircelwebpost,Aircel-GPRS-Postpaid,nil,1,nil,nil -40491,aircelwappost,PocketInternet-Postpaid,nil,1,nil,nil -40491,aircelwap,PocketInternet-Prepaid,nil,1,nil,nil -40491,aircelweb,Aircel-GPRS-Prepaid,nil,1,nil,nil -40492,airtelgprs.com,MobileOffice,nil,1,nil,nil -40492,airtelfun.com,AIRTELLIVE,nil,1,nil,nil -40493,airtelgprs.com,MobileOffice,nil,1,nil,nil -40493,airtelfun.com,AIRTELLIVE,nil,1,nil,nil -40494,airtelgprs.com,MobileOffice,nil,1,nil,nil -40494,airtelfun.com,AIRTELLIVE,nil,1,nil,nil -40495,airtelgprs.com,MobileOffice,nil,1,nil,nil -40495,airtelfun.com,AIRTELLIVE,nil,1,nil,nil -40496,airtelgprs.com,MobileOffice,nil,1,nil,nil -40496,airtelfun.com,AIRTELLIVE,nil,1,nil,nil -40497,airtelgprs.com,MobileOffice,nil,1,nil,nil -40497,airtelfun.com,AIRTELLIVE,nil,1,nil,nil -40498,airtelgprs.com,MobileOffice,nil,1,nil,nil -40498,airtelfun.com,AIRTELLIVE,nil,1,nil,nil -40501,rcomnet,Netconnect,nil,1,nil,nil -40501,rcomwap,RelianceMbWorld,nil,1,nil,nil -40503,rcomnet,Netconnect,nil,1,nil,nil -40503,rcomwap,RelianceMbWorld,nil,1,nil,nil -40504,rcomnet,Netconnect,nil,1,nil,nil -40504,rcomwap,RelianceMbWorld,nil,1,nil,nil -40505,rcomnet,Netconnect,nil,1,nil,nil -40505,rcomwap,RelianceMbWorld,nil,1,nil,nil -40506,rcomnet,Netconnect,nil,1,nil,nil -40506,rcomwap,RelianceMbWorld,nil,1,nil,nil -40507,rcomnet,Netconnect,nil,1,nil,nil -40507,rcomwap,RelianceMbWorld,nil,1,nil,nil -40508,rcomnet,Netconnect,nil,1,nil,nil -40508,rcomwap,RelianceMbWorld,nil,1,nil,nil -40509,rcomnet,Netconnect,nil,1,nil,nil -40509,rcomwap,RelianceMbWorld,nil,1,nil,nil -40510,rcomnet,Netconnect,nil,1,nil,nil -40510,rcomwap,RelianceMbWorld,nil,1,nil,nil -40511,rcomnet,Netconnect,nil,1,nil,nil -40511,rcomwap,RelianceMbWorld,nil,1,nil,nil -40512,rcomnet,Netconnect,nil,1,nil,nil -40512,rcomwap,RelianceMbWorld,nil,1,nil,nil -40513,rcomnet,Netconnect,nil,1,nil,nil -40513,rcomwap,RelianceMbWorld,nil,1,nil,nil -40514,rcomnet,Netconnect,nil,1,nil,nil -40514,rcomwap,RelianceMbWorld,nil,1,nil,nil -40515,rcomnet,Netconnect,nil,1,nil,nil -40515,rcomwap,RelianceMbWorld,nil,1,nil,nil -40517,rcomnet,Netconnect,nil,1,nil,nil -40517,rcomwap,RelianceMbWorld,nil,1,nil,nil -40518,rcomnet,Netconnect,nil,1,nil,nil -40518,rcomwap,RelianceMbWorld,nil,1,nil,nil -40519,rcomnet,Netconnect,nil,1,nil,nil -40519,rcomwap,RelianceMbWorld,nil,1,nil,nil -40520,rcomnet,Netconnect,nil,1,nil,nil -40520,rcomwap,RelianceMbWorld,nil,1,nil,nil -40521,rcomnet,Netconnect,nil,1,nil,nil -40521,rcomwap,RelianceMbWorld,nil,1,nil,nil -40522,rcomnet,Netconnect,nil,1,nil,nil -40522,rcomwap,RelianceMbWorld,nil,1,nil,nil -40523,rcomnet,Netconnect,nil,1,nil,nil -40523,rcomwap,RelianceMbWorld,nil,1,nil,nil -405025,TATA.DOCOMO.DIVE.IN,TATADOCOMODIVE-IN,nil,1,nil,nil -405025,TATA.DOCOMO.INTERNET,TATADOCOMOINTERNET,nil,1,nil,nil -405026,TATA.DOCOMO.INTERNET,TATADOCOMOINTERNET,nil,1,nil,nil -405026,TATA.DOCOMO.DIVE.IN,TATADOCOMODIVE-IN,nil,1,nil,nil -405027,TATA.DOCOMO.INTERNET,TATADOCOMOINTERNET,nil,1,nil,nil -405027,TATA.DOCOMO.DIVE.IN,TATADOCOMODIVE-IN,nil,1,nil,nil -405028,TATA.DOCOMO.INTERNET,TATADOCOMOINTERNET,nil,1,nil,nil -405028,TATA.DOCOMO.DIVE.IN,TATADOCOMODIVE-IN,nil,1,nil,nil -405029,TATA.DOCOMO.INTERNET,TATADOCOMOINTERNET,nil,1,nil,nil -405029,TATA.DOCOMO.DIVE.IN,TATADOCOMODIVE-IN,nil,1,nil,nil -405030,TATA.DOCOMO.INTERNET,TATADOCOMOINTERNET,nil,1,nil,nil -405030,TATA.DOCOMO.DIVE.IN,TATADOCOMODIVE-IN,nil,1,nil,nil -405031,TATA.DOCOMO.INTERNET,TATADOCOMOINTERNET,nil,1,nil,nil -405031,TATA.DOCOMO.DIVE.IN,TATADOCOMODIVE-IN,nil,1,nil,nil -405032,TATA.DOCOMO.INTERNET,TATADOCOMOINTERNET,nil,1,nil,nil -405032,TATA.DOCOMO.DIVE.IN,TATADOCOMODIVE-IN,nil,1,nil,nil -405033,TATA.DOCOMO.INTERNET,TATADOCOMOINTERNET,nil,1,nil,nil -405033,TATA.DOCOMO.DIVE.IN,TATADOCOMODIVE-IN,nil,1,nil,nil -405034,TATA.DOCOMO.INTERNET,TATADOCOMOINTERNET,nil,1,nil,nil -405034,TATA.DOCOMO.DIVE.IN,TATADOCOMODIVE-IN,nil,1,nil,nil -405035,TATA.DOCOMO.INTERNET,TATADOCOMOINTERNET,nil,1,nil,nil -405035,TATA.DOCOMO.DIVE.IN,TATADOCOMODIVE-IN,nil,1,nil,nil -405036,TATA.DOCOMO.INTERNET,TATADOCOMOINTERNET,nil,1,nil,nil -405036,TATA.DOCOMO.DIVE.IN,TATADOCOMODIVE-IN,nil,1,nil,nil -405037,TATA.DOCOMO.INTERNET,TATADOCOMOINTERNET,nil,1,nil,nil -405037,TATA.DOCOMO.DIVE.IN,TATADOCOMODIVE-IN,nil,1,nil,nil -405038,TATA.DOCOMO.INTERNET,TATADOCOMOINTERNET,nil,1,nil,nil -405038,TATA.DOCOMO.DIVE.IN,TATADOCOMODIVE-IN,nil,1,nil,nil -405039,TATA.DOCOMO.INTERNET,TATADOCOMOINTERNET,nil,1,nil,nil -405039,TATA.DOCOMO.DIVE.IN,TATADOCOMODIVE-IN,nil,1,nil,nil -405040,TATA.DOCOMO.INTERNET,TATADOCOMOINTERNET,nil,1,nil,nil -405040,TATA.DOCOMO.DIVE.IN,TATADOCOMODIVE-IN,nil,1,nil,nil -405041,TATA.DOCOMO.INTERNET,TATADOCOMOINTERNET,nil,1,nil,nil -405041,TATA.DOCOMO.DIVE.IN,TATADOCOMODIVE-IN,nil,1,nil,nil -405042,TATA.DOCOMO.INTERNET,TATADOCOMOINTERNET,nil,1,nil,nil -405042,TATA.DOCOMO.DIVE.IN,TATADOCOMODIVE-IN,nil,1,nil,nil -405043,TATA.DOCOMO.INTERNET,TATADOCOMOINTERNET,nil,1,nil,nil -405043,TATA.DOCOMO.DIVE.IN,TATADOCOMODIVE-IN,nil,1,nil,nil -405044,TATA.DOCOMO.INTERNET,TATADOCOMOINTERNET,nil,1,nil,nil -405044,TATA.DOCOMO.DIVE.IN,TATADOCOMODIVE-IN,nil,1,nil,nil -405045,TATA.DOCOMO.INTERNET,TATADOCOMOINTERNET,nil,1,nil,nil -405045,TATA.DOCOMO.DIVE.IN,TATADOCOMODIVE-IN,nil,1,nil,nil -405046,TATA.DOCOMO.INTERNET,TATADOCOMOINTERNET,nil,1,nil,nil -405046,TATA.DOCOMO.DIVE.IN,TATADOCOMODIVE-IN,nil,1,nil,nil -405047,TATA.DOCOMO.INTERNET,TATADOCOMOINTERNET,nil,1,nil,nil -405047,TATA.DOCOMO.DIVE.IN,TATADOCOMODIVE-IN,nil,1,nil,nil -40551,airtelgprs.com,MobileOffice,nil,1,nil,nil -40551,airtelfun.com,AIRTELLIVE,nil,1,nil,nil -40552,airtelgprs.com,MobileOffice,nil,1,nil,nil -40552,airtelfun.com,AIRTELLIVE,nil,1,nil,nil -40553,airtelgprs.com,MobileOffice,nil,1,nil,nil -40553,airtelfun.com,AIRTELLIVE,nil,1,nil,nil -40554,airtelgprs.com,MobileOffice,nil,1,nil,nil -40554,airtelfun.com,AIRTELLIVE,nil,1,nil,nil -40555,airtelgprs.com,MobileOffice,nil,1,nil,nil -40555,airtelfun.com,AIRTELLIVE,nil,1,nil,nil -40556,airtelgprs.com,MobileOffice,nil,1,nil,nil -40556,airtelfun.com,AIRTELLIVE,nil,1,nil,nil -40566,www,Vodafonemobileconnect,nil,1,nil,nil -40566,portalnmms,Vodafonelive,nil,1,nil,nil -40567,www,Vodafonemobileconnect,nil,1,nil,nil -40567,portalnmms,Vodafonelive,nil,1,nil,nil -40570,internet,Idea_Internet,nil,1,nil,nil -40570,imis,IDEAGPRS,nil,1,nil,nil -405750,www,Vodafonemobileconnect,nil,1,nil,nil -405750,portalnmms,Vodafonelive,nil,1,nil,nil -405751,www,Vodafonemobileconnect,nil,1,nil,nil -405751,portalnmms,Vodafonelive,nil,1,nil,nil -405752,www,Vodafonemobileconnect,nil,1,nil,nil -405752,portalnmms,Vodafonelive,nil,1,nil,nil -405753,www,Vodafonemobileconnect,nil,1,nil,nil -405753,portalnmms,Vodafonelive,nil,1,nil,nil -405754,www,Vodafonemobileconnect,nil,1,nil,nil -405754,portalnmms,Vodafonelive,nil,1,nil,nil -405755,www,Vodafonemobileconnect,nil,1,nil,nil -405755,portalnmms,Vodafonelive,nil,1,nil,nil -405756,www,Vodafonemobileconnect,nil,1,nil,nil -405756,portalnmms,Vodafonelive,nil,1,nil,nil -405799,internet,Idea_Internet,nil,1,nil,nil -405799,imis,IDEAGPRS,nil,1,nil,nil -405800,aircelgprs,Aircel-GPRS,nil,1,nil,nil -405800,aircelwap,PocketInternet,nil,1,nil,nil -405801,aircelgprs,Aircel-GPRS,nil,1,nil,nil -405801,aircelwap,PocketInternet,nil,1,nil,nil -405802,aircelgprs,Aircel-GPRS,nil,1,nil,nil -405802,aircelwap,PocketInternet,nil,1,nil,nil -405803,aircelgprs,Aircel-GPRS,nil,1,nil,nil -405803,aircelwap,PocketInternet,nil,1,nil,nil -405804,aircelgprs,Aircel-GPRS,nil,1,nil,nil -405804,aircelwap,PocketInternet,nil,1,nil,nil -405805,aircelgprs,Aircel-GPRS,nil,1,nil,nil -405805,aircelwap,PocketInternet,nil,1,nil,nil -405806,aircelgprs,Aircel-GPRS,nil,1,nil,nil -405806,aircelwap,PocketInternet,nil,1,nil,nil -405807,aircelgprs,Aircel-GPRS,nil,1,nil,nil -405807,aircelwap,PocketInternet,nil,1,nil,nil -405808,aircelgprs,Aircel-GPRS,nil,1,nil,nil -405808,aircelwap,PocketInternet,nil,1,nil,nil -405809,aircelgprs,Aircel-GPRS,nil,1,nil,nil -405809,aircelwap,PocketInternet,nil,1,nil,nil -405810,aircelgprs,Aircel-GPRS,nil,1,nil,nil -405810,aircelwap,PocketInternet,nil,1,nil,nil -405811,aircelgprs,Aircel-GPRS,nil,1,nil,nil -405811,aircelwap,PocketInternet,nil,1,nil,nil -405812,aircelgprs,Aircel-GPRS,nil,1,nil,nil -405812,aircelwap,PocketInternet,nil,1,nil,nil -405813,uninor,UninorInternet,nil,1,nil,1 -405813,uninor,UninorWap,nil,1,nil,nil -405814,uninor,UninorInternet,nil,1,nil,1 -405814,uninor,UninorWap,nil,1,nil,nil -405815,uninor,UninorInternet,nil,1,nil,1 -405815,uninor,UninorWap,nil,1,nil,nil -405816,uninor,UninorInternet,nil,1,nil,1 -405816,uninor,UninorWap,nil,1,nil,nil -405817,uninor,UninorInternet,nil,1,nil,1 -405817,uninor,UninorWap,nil,1,nil,nil -405818,uninor,UninorInternet,nil,1,nil,1 -405818,uninor,UninorWap,nil,1,nil,nil -405819,uninor,UninorInternet,nil,1,nil,1 -405819,uninor,UninorWap,nil,1,nil,nil -405820,uninor,UninorInternet,nil,1,nil,1 -405820,uninor,UninorWap,nil,1,nil,nil -405821,uninor,UninorInternet,nil,1,nil,1 -405821,uninor,UninorWap,nil,1,nil,nil -405822,uninor,UninorInternet,nil,1,nil,1 -405822,uninor,UninorWap,nil,1,nil,nil -405823,vinternet.com,Videocon,nil,1,nil,nil -405824,vinternet.com,Videocon,nil,1,nil,nil -405825,vinternet.com,Videocon,nil,1,nil,nil -405826,vinternet.com,Videocon,nil,1,nil,nil -405827,vinternet.com,Videocon,nil,1,nil,nil -405828,vinternet.com,Videocon,nil,1,nil,nil -405829,vinternet.com,Videocon,nil,1,nil,nil -405830,vinternet.com,Videocon,nil,1,nil,nil -405831,vinternet.com,Videocon,nil,1,nil,nil -405832,vinternet.com,Videocon,nil,1,nil,nil -405833,vinternet.com,Videocon,nil,1,nil,nil -405834,vinternet.com,Videocon,nil,1,nil,nil -405835,vinternet.com,Videocon,nil,1,nil,nil -405836,vinternet.com,Videocon,nil,1,nil,nil -405837,vinternet.com,Videocon,nil,1,nil,nil -405838,vinternet.com,Videocon,nil,1,nil,nil -405839,vinternet.com,Videocon,nil,1,nil,nil -405840,vinternet.com,Videocon,nil,1,nil,nil -405841,vinternet.com,Videocon,nil,1,nil,nil -405842,vinternet.com,Videocon,nil,1,nil,nil -405843,vinternet.com,Videocon,nil,1,nil,nil -405844,uninor,UninorInternet,nil,1,nil,1 -405844,uninor,UninorWap,nil,1,nil,nil -405845,internet,Idea_Internet,nil,1,nil,nil -405845,imis,IDEAGPRS,nil,1,nil,nil -405846,internet,Idea_Internet,nil,1,nil,nil -405846,imis,IDEAGPRS,nil,1,nil,nil -405847,internet,Idea_Internet,nil,1,nil,nil -405847,imis,IDEAGPRS,nil,1,nil,nil -405848,internet,Idea_Internet,nil,1,nil,nil -405848,imis,IDEAGPRS,nil,1,nil,nil -405849,internet,Idea_Internet,nil,1,nil,nil -405849,imis,IDEAGPRS,nil,1,nil,nil -405850,internet,Idea_Internet,nil,1,nil,nil -405850,imis,IDEAGPRS,nil,1,nil,nil -405851,internet,Idea_Internet,nil,1,nil,nil -405851,imis,IDEAGPRS,nil,1,nil,nil -405852,internet,Idea_Internet,nil,1,nil,nil -405852,imis,IDEAGPRS,nil,1,nil,nil -405853,internet,Idea_Internet,nil,1,nil,nil -405853,imis,IDEAGPRS,nil,1,nil,nil -405854,www,LoopInternet(405854),nil,1,nil,nil -405855,www,LoopInternet(405855),nil,1,nil,nil -405856,www,LoopInternet(405856),nil,1,nil,nil -405857,www,LoopInternet(405857),nil,1,nil,nil -405858,www,LoopInternet(405858),nil,1,nil,nil -405859,www,LoopInternet(405859),nil,1,nil,nil -405860,www,LoopInternet(405860),nil,1,nil,nil -405861,www,LoopInternet(405861),nil,1,nil,nil -405862,www,LoopInternet(405862),nil,1,nil,nil -405863,www,LoopInternet(405863),nil,1,nil,nil -405864,www,LoopInternet(405864),nil,1,nil,nil -405865,www,LoopInternet(405865),nil,1,nil,nil -405866,www,LoopInternet(405866),nil,1,nil,nil -405867,www,LoopInternet(405867),nil,1,nil,nil -405868,www,LoopInternet(405868),nil,1,nil,nil -405869,www,LoopInternet(405869),nil,1,nil,nil -405870,www,LoopInternet(405870),nil,1,nil,nil -405871,www,LoopInternet(405871),nil,1,nil,nil -405872,www,LoopInternet(405872),nil,1,nil,nil -405873,www,LoopInternet(405873),nil,1,nil,nil -405874,www,LoopInternet(405874),nil,1,nil,nil -405875,uninor,UninorInternet,nil,1,nil,1 -405875,uninor,UninorWap,nil,1,nil,nil -405876,uninor,UninorInternet,nil,1,nil,1 -405876,uninor,UninorWap,nil,1,nil,nil -405877,uninor,UninorInternet,nil,1,nil,1 -405877,uninor,UninorWap,nil,1,nil,nil -405878,uninor,UninorInternet,nil,1,nil,1 -405878,uninor,UninorWap,nil,1,nil,nil -405879,uninor,UninorInternet,nil,1,nil,1 -405879,uninor,UninorWap,nil,1,nil,nil -405880,uninor,UninorInternet,nil,1,nil,1 -405880,uninor,UninorWap,nil,1,nil,nil -405881,gprs.stel.in,STEL,nil,1,nil,nil -405882,gprs.stel.in,STEL,nil,1,nil,nil -405883,gprs.stel.in,STEL,nil,1,nil,nil -405884,gprs.stel.in,STEL,nil,1,nil,nil -405885,gprs.stel.in,STEL,nil,1,nil,nil -405886,gprs.stel.in,STEL,nil,1,nil,nil -405908,internet,IDEA,nil,1,nil,nil -405909,internet,IDEA,nil,1,nil,nil -405910,internet,IDEA,nil,1,nil,nil -405911,internet,IDEA,nil,1,nil,nil -405912,internet,Cheers,nil,1,nil,nil -405913,internet,Cheers,nil,1,nil,nil -405914,internet,Cheers,nil,1,nil,nil -405915,internet,Cheers,nil,1,nil,nil -405916,internet,Cheers,nil,1,nil,nil -405917,internet,Cheers,nil,1,nil,nil -405918,internet,Cheers,nil,1,nil,nil -405919,internet,Cheers,nil,1,nil,nil -405920,internet,Cheers,nil,1,nil,nil -405921,internet,Cheers,nil,1,nil,nil -405922,internet,Cheers,nil,1,nil,nil -405923,internet,Cheers,nil,1,nil,nil -405924,internet,Cheers,nil,1,nil,nil -405925,uninor,UninorInternet,nil,1,nil,1 -405925,uninor,UninorWap,nil,1,nil,nil -405926,uninor,UninorInternet,nil,1,nil,1 -405926,uninor,UninorWap,nil,1,nil,nil -405927,uninor,UninorInternet,nil,1,nil,1 -405927,uninor,UninorWap,nil,1,nil,nil -405928,uninor,UninorInternet,nil,1,nil,1 -405928,uninor,UninorWap,nil,1,nil,nil -405929,uninor,UninorInternet,nil,1,nil,1 -405929,uninor,UninorWap,nil,1,nil,nil -405930,internet,Cheers,nil,1,nil,nil -405931,internet,Cheers,nil,1,nil,nil -405932,vinternet.com,Videocon,nil,1,nil,nil -41001,connect.mobilinkworld.com,MobilinkWAPGPRS,Mobilink,1,Mobilink,nil -41003,Ufone.internet,UfoneWAP,nil,1,nil,nil -41004,zonginternet,ZONGWAP,nil,1,nil,nil -41006,internet,TelenorWAP,nil,1,nil,nil -41007,Wap.warid,WaridWAP,nil,1,nil,nil -410310,att.mvno,ConsumerCellular,nil,1,nil,nil -41201,default,AWCC,nil,1,nil,nil -41220,default,Roshan,nil,1,nil,nil -41240,default,MTN,nil,1,nil,nil -41250,default,Etisalat,nil,1,nil,nil -41301,default,Mobitel,nil,1,nil,nil -41302,default,Dialog,nil,1,nil,nil -41303,default,Etisalat,nil,1,nil,nil -41305,default,Airtel,nil,1,nil,nil -41308,default,Hutch,nil,1,nil,nil -41401,default,MPT,nil,1,nil,nil -41405,Internet,OoredooInternet,nil,1,nil,nil -41501,internet.mic1.com.lb,AlfaInternet,mic1,1,mic1,nil -41501,wap.mic1.com.lb,Alfawap,mic1,1,mic1,nil -41503,touch,touch,nil,1,nil,nil -41503,wap,touch_WAP,nil,1,nil,nil -41601,zain,ZainJOInternet,zain,1,zain,1 -41601,Zain,ZainJOStreaming,zain,1,zain,1 -41603,net,Umniahinternet,nil,1,nil,nil -41603,wap,UmniahWAP,nil,1,nil,nil -416770,net.orange.jo,OrangeInternet,net,1,net,1 -416770,wap.orange.jo,OrangeWAP,wap,1,wap,1 -41677,net.orange.jo,OrangeInternet,net,1,net,1 -41677,wap.orange.jo,OrangeWAP,wap,1,wap,1 -41701,net.syriatel.com,SyriatelNet,nil,1,nil,nil -41702,internet,MTNWAP,nil,1,nil,nil -41805,net.asiacell.com,AsiacellInternet,nil,1,nil,nil -41808,default,SanaTel,nil,1,nil,nil -41820,internet,ZAIN-GPRS,atheer,1,atheer,1 -41830,internet,ZAIN-GPRS,atheer,1,atheer,1 -41840,internet.korek.com,Korek9595,nil,1,nil,nil -41840,net.korek.com,Korek9191,korek,1,korek,nil -41845,default,Mobitel,nil,1,nil,nil -41862,default,Itisaluna,nil,1,nil,nil -41892,default,Omnnea,nil,1,nil,nil -41902,pps,MI,pps,1,pps,nil -41902,pps,ZainWAP,pps,1,pps,3 -41903,action.ooredoo.com,OoredooAction,nil,1,nil,1 -41903,mms.ooredoo.com,OoredooMMS,nil,1,nil,1 -41904,viva,VIVA-KW,nil,1,nil,0 -42001,jawalnet.com.sa,STC-GPRS,nil,1,nil,nil -42003,web1,MobilyWEB,nil,1,nil,nil -42003,wap2,Mobilyprepaid-GPRS,nil,1,nil,nil -42003,wap1,Mobilypostpaid-GPRS,nil,1,nil,nil -42003,web2,MobilyWEB2,nil,1,nil,nil -42004,zain,zain-InternetWap,nil,1,nil,0 -42101,default,SabaFon,nil,1,nil,nil -42102,default,MTN,nil,1,nil,nil -42103,default,YemenMobile,nil,1,nil,nil -42104,default,HiTS-UNITEL,nil,1,nil,nil -42202,taif,OmanMobileInternet,taif,1,taif,1 -42203,isp.nawras.com.om,NawrasInternet,test,1,test,1 -42402,etisalat.ae,EtisalatDataPackage,nil,1,nil,1 -42402,etisalat,WeyakWap,nil,1,nil,1 -42403,du,duInternet,nil,1,nil,nil -42501,uwap.orange.co.il,3GPortal,nil,1,nil,nil -42502,sphone,CellcomInternet,nil,1,nil,nil -42503,sphone.pelephone.net.il,SphonePelephone,pcl,1,pcl@3g,2 -42505,wap,JawwalWAP,nil,1,nil,nil -42506,internet,Internet,nil,1,nil,nil -42507,net.hotm,InternetHOTmobile,nil,1,nil,nil -42507,pc.hotm,PCHOTmobile,nil,1,nil,0 -42508,internet.golantelecom.net.il,GolanTelecomInternet,nil,1,nil,nil -42510,uwap.orange.co.il,3GPortal,nil,1,nil,nil -42514,data.youphone.co.il,YouPhone,nil,1,nil,nil -42515,hcminternet,HomeCellularInternet,nil,1,nil,nil -42516,internet.rl,RamiLevi3G,nil,1,nil,nil -42601,internet.batelco.com,BatelcoInternet,nil,1,nil,nil -42601,wap.batelco.com,BatelcoWAP,wap,1,wap,0 -42602,internet,ZainBHInternet,internet,1,internet,0 -42602,wap,ZainBHWAP,wap,1,wap,0 -42604,viva.bh,VIVAGPRS,nil,1,nil,nil -42604,vivawap.bh,VIVAWAP,nil,1,nil,nil -42701,data,Internet,nil,1,nil,1 -42702,web.vodafone.com.qa,Vodainternet,nil,1,nil,nil -42888,default,Unitel,nil,1,nil,nil -42891,default,Skytel,nil,1,nil,nil -42898,default,G.Mobile,nil,1,nil,nil -42899,default,MobiCom,nil,1,nil,nil -42901,default,Namaste/NTMobile,nil,1,nil,nil -42902,default,Ncell,nil,1,nil,nil -42903,default,Sky/C-Phone,nil,1,nil,nil -42904,default,SmartCell,nil,1,nil,nil -43211,mcinet,MCI-GPRS,nil,1,nil,nil -43214,mcinet,MCI-GPRS,nil,1,nil,nil -43219,mcinet,MCI-GPRS,nil,1,nil,nil -43220,rightel,rightel,nil,1,nil,nil -43235,mtnirancell,Irancell-GPRS,nil,1,nil,nil -43270,mcinet,MCI-GPRS,nil,1,nil,nil -43293,mcinet,MCI-GPRS,nil,1,nil,nil -43404,internet.beeline.uz,Beeline-UZBInternet,beeline,1,beeline,1 -43405,internet,UCELLInternet,nil,1,nil,nil -43406,default,PerfectumMobile,nil,1,nil,nil -43407,net.mts.uz,MTS-UZBInternet,mts,1,mts,1 -43601,default,Tcell,nil,1,nil,nil -43602,default,Tcell,nil,1,nil,nil -43603,default,Megafon,nil,1,nil,nil -43604,default,Babilon-M,nil,1,nil,nil -43605,default,Tacom,nil,1,nil,nil -43612,default,Tcell,nil,1,nil,nil -43701,default,Beeline,nil,1,nil,nil -43703,default,Fonex,nil,1,nil,nil -43705,default,MegaCom,nil,1,nil,nil -43709,default,O!,nil,1,nil,nil -43801,default,MTS(BARASHCommunication),nil,1,nil,nil -43802,default,TM-Cell,nil,1,nil,nil -44003,iijmio.jp,IIJmio(TypeI),iij,1,mio@iij,3 -44003,vmobile.jp,vmobile.jp,vmobile,1,vmobile@jp,3 -44010,spmode.ne.jp,sp-mode,nil,1,nil,nil -44010,mopera.net,moperaU,nil,1,nil,nil -44010,bmobile.ne.jp,b-mobileforNexus,bmobile,1,bmobile@nx,3 -44010,iijmio.jp,IIJmio,iij,1,mio@iij,3 -44010,3g-d-2.ocn.ne.jp,OCNモバイルONE(3G),mobile,1,mobileid@ocn,2 -44010,lte-d.ocn.ne.jp,OCNモバイルONE(LTE),mobile,1,mobileid@ocn,2 -44010,ratel.com,RATEL,ratel,1,ratel@ratel.com,3 -44020,plus.acs.jp,Application,ym,1,ym,2 -44020,ratel.com,RATEL,ratel,1,ratel@ratel.com,3 -44051,ratel.com,RATEL,ratel,1,ratel@ratel.com,3 -44051,a.rmobile.jp,Rakuten,0000,1,rakuten@vdm,3 -45005,lte.sktelecom.com,SKTLTEINTERNET,nil,1,nil,nil -45005,web.sktelecom.com,SKT3GINTERNET,nil,1,nil,nil -45005,lte-roaming.sktelecom.com,SKTLTERoaming,nil,1,nil,nil -45005,roaming.sktelecom.com,SKT3GRoaming,nil,1,nil,nil -45011,web.sktelecom.com,SKT3GINTERNET,nil,1,nil,nil -45011,lte-roaming.sktelecom.com,SKTLTERoaming,nil,1,nil,nil -45011,roaming.sktelecom.com,SKT3GRoaming,nil,1,nil,nil -45006,internet.lguplus.co.kr,LGuplus,nil,1,nil,nil -45006,lte-roaming.lguplus.co.kr,LGuplusLTERoaming,nil,1,nil,0 -45006,wroaming.lguplus.co.kr,LGuplusRoaming,nil,1,nil,0 -45008,lte.ktfwing.com,KT,nil,1,nil,nil -45201,m-wap,Mobi-wap-gprs2,mms,1,mms,1 -45202,m3-world,Vina-wap-gprs,mms,1,mms,1 -45204,v-internet,Viettel-wap-gprs1,nil,1,nil,nil -45204,v-wap,Viettel-wap-gprs2,nil,1,nil,nil -45205,internet,Vietnamobile_GPRS3,nil,1,nil,nil -45205,wap,Vietnamobile_GPRS1,nil,1,nil,nil -45207,internet,Gmobile-wap-gprs2,nil,1,nil,nil -45208,e-internet,e-internet,nil,1,nil,nil -45208,e-wap,e-wap,nil,1,nil,nil -45400,mobile,1O1O,nil,1,nil,3 -45400,NWMOBILE,NWMOBILE,nil,1,nil,3 -45402,mobile,1O1O,nil,1,nil,3 -45402,NWMOBILE,NWMOBILE,nil,1,nil,3 -45403,mobile.lte.three.com.hk,3LTE,nil,1,nil,1 -45403,mobile.three.com.hk,3,nil,1,nil,1 -45404,web-g.three.com.hk,3(2G)GPRS,nil,1,nil,nil -45406,SmarTone,SmarTone,nil,1,nil,3 -45408,iot.truphone.com,Truphone,nil,1,nil,nil -45410,hkcsl,one2free,nil,1,nil,3 -45412,cmhk,CMHKData,nil,1,nil,nil -45413,cmhk,CMHKData,nil,1,nil,nil -45415,SmarTone,SmarTone,nil,1,nil,3 -45416,pccw,PCCW-HKT,nil,1,nil,1 -45417,SmarTone,SmarTone,nil,1,nil,3 -45418,mobile,1O1O,nil,1,nil,3 -45418,NWMOBILE,NWMOBILE,nil,1,nil,3 -45419,pccw,PCCW-HKT,nil,1,nil,1 -45500,smartgprs,SmarToneMacau,nil,1,nil,3 -45501,ctm-mobile,CTMData,nil,1,nil,nil -45501,ctmprepaid,CTM(Prepaid),nil,1,nil,nil -45503,mobile.three.com.mo,3Macau,nil,1,nil,1 -45504,ctm-mobile,CTMData,nil,1,nil,nil -45504,ctmprepaid,CTM(Prepaid),nil,1,nil,nil -45505,mobile.three.com.mo,3Macau,nil,1,nil,1 -45601,default,Cellcard,nil,1,nil,nil -45602,default,Smart,nil,1,nil,nil -45604,default,qb,nil,1,nil,nil -45605,default,Star-Cell,nil,1,nil,nil -45606,default,Smart,nil,1,nil,nil -45608,default,Metfone,nil,1,nil,nil -45609,default,Beeline,nil,1,nil,nil -45611,default,Excell,nil,1,nil,nil -45618,default,Cellcard,nil,1,nil,nil -45701,default,LTC,nil,1,nil,nil -45702,default,ETL,nil,1,nil,nil -45703,default,Unitel,nil,1,nil,nil -45708,default,Beeline,nil,1,nil,nil -46000,cmnet,中国移动(ChinaMobile)GPRS,nil,1,nil,nil -46000,cmwap,中国移动(ChinaMobile)WAP,nil,1,nil,nil -46001,3gnet,沃3G连接互联网(ChinaUnicom),nil,1,nil,nil -46001,3gwap,沃3G手机上网(ChinaUnicom),nil,1,nil,nil -46001,uninet,联通2GNET上网(ChinaUnicom),nil,1,nil,nil -46002,cmnet,中国移动(ChinaMobile)GPRS,nil,1,nil,nil -46002,cmwap,中国移动(ChinaMobile)WAP,nil,1,nil,nil -46007,cmnet,中国移动(ChinaMobile)GPRS,nil,1,nil,nil -46008,cmnet,中国移动(ChinaMobile)GPRS,nil,1,nil,nil -46007,cmwap,中国移动(ChinaMobile)WAP,nil,1,nil,nil -46008,cmwap,中国移动(ChinaMobile)WAP,nil,1,nil,nil -46009,3gnet,ChinaUnicom3G,nil,1,nil,nil -46009,3gwap,ChinaUnicomwap,nil,1,nil,nil -46011,ctlte,ctlte,nil,1,nil,0 -46003,ctnet,CTNET,vnet.mobi,1,ctnet@mycdma.cn,3 -46003,ctwap,CTWAP,vnet.mobi,1,ctwap@mycdma.cn,3 -20404,ctnet,CTNET,nil,1,nil,0 -46601,internet,遠傳電信(FarEasTone)(Internet),nil,1,nil,nil -46688,internet,和信電訊(KGT-Online)(Internet),nil,1,nil,nil -46689,vibo,VIBO-vibo,nil,1,nil,nil -46689,internet,TStar-internet,nil,1,nil,nil -46689,viboone,VIBOONE,nil,1,nil,nil -46692,internet,中華電信(Chunghwa)(Internet),nil,1,nil,nil -46693,Internet,台灣大哥大(TWMobile)(Internet),nil,1,nil,nil -46697,Internet,台灣大哥大(TWMobile)(Internet),nil,1,nil,nil -46699,Internet,台灣大哥大(TWMobile)(Internet),nil,1,nil,nil -47001,gpinternet,GP-INTERNET,nil,1,nil,0 -47201,default,Dhiraagu,nil,1,nil,nil -47202,OoredooData,OoredooData,nil,1,nil,nil -50210,diginet,DiGiInternet,nil,1,nil,nil -50212,max4g,MaxisInternet,wap,1,maxis,1 -50213,celcom4g,CelcomInternet,nil,1,nil,nil -502143,diginet,DiGiInternet,nil,1,nil,nil -502145,celcom4g,CelcomInternet,nil,1,nil,nil -502146,diginet,DiGiInternet,nil,1,nil,nil -502148,celcom4g,CelcomInternet,nil,1,nil,nil -50216,diginet,DiGiInternet,nil,1,nil,nil -50217,max4g,MaxisInternet,wap,1,maxis,1 -50218,my3g,UMobileInternet,nil,1,nil,nil -50219,celcom4g,CelcomInternet,nil,1,nil,nil -50501,telstra.wap,TelstraInternet,nil,1,nil,nil -50501,telstra.internet,TelstraTethering,nil,1,nil,nil -50502,yesinternet,OptusYesInternet,nil,1,nil,nil -50503,live.vodafone.com,Vodafonelive!,nil,1,nil,nil -50506,3services,Planet3,nil,1,nil,0 -50507,vfinternet.au,VFInternet,nil,1,nil,nil -50511,Telstra.wap,TelstraInternet,nil,1,nil,nil -50512,3netaccess,3Internet,nil,1,nil,nil -50512,3services,3,nil,1,nil,nil -50538,iot.truphone.com,Truphone,nil,1,nil,nil -50571,Telstra.wap,TelstraInternet,nil,1,nil,nil -50572,Telstra.wap,TelstraInternet,nil,1,nil,nil -50588,vfinternet.au,VFInternet,nil,1,nil,nil -50590,internet,OptusInternet,nil,1,nil,nil -50599,live.vodafone.com,VodafoneLive!,nil,1,nil,nil -51001,indosatgprs,indosatgprs,nil,1,nil,1 -51008,AXIS,AXIS-SNS,nil,1,nil,1 -51008,AXIS,AXISwap,123456,1,axis,1 -51010,internet,internet,nil,1,nil,nil -51010,telkomsel,TSEL-WAP,wap123,1,wap,1 -51011,internet,Internet,nil,1,nil,1 -51021,indosatgprs,Indosat-SNS,nil,1,nil,1 -51021,indosatgprs,IndosatGPRS,indosat,1,indosat,1 -51089,3gprs,3-SNS,nil,1,nil,1 -51089,3gprs,3GPRS,3gprs,1,3gprs,1 -51401,default,Telin,nil,1,nil,nil -51402,default,TimorTelecom,nil,1,nil,nil -51403,default,ViettelTimor-Leste,nil,1,nil,nil -51502,internet.globe.com.ph,myGlobeInternet,nil,1,nil,nil -51502,http.globe.com.ph,myGlobeINET,nil,1,nil,nil -51502,www.globe.com.ph,myGlobeConnect,nil,1,nil,nil -51503,smartlte,SMARTLTE,nil,1,nil,nil -51503,internet,SMARTINTERNET,nil,1,nil,nil -51503,Smart1,SmartGPRS,nil,1,nil,nil -51505,minternet,SunInternet,nil,1,nil,nil -51505,wap,SUNWAPGPRS,nil,1,nil,nil -51505,fbband,SunSBW,nil,1,nil,nil -51518,redinternet,Redinternet,nil,1,nil,nil -52000,internet,CAT3GINTERNET,nil,1,nil,nil -52000,internet,TRUE-HINTERNET,true,1,true,1 -52001,internet,AISInternet,nil,1,nil,0 -52003,internet,AISInternet,nil,1,nil,0 -52004,internet,TRUE-HINTERNET,true,1,true,1 -52005,www.dtac.co.th,dtacInternet,nil,1,nil,nil -52015,internet,TOT3GInternet,nil,1,nil,nil -52018,www.dtac.co.th,dtacInternet,nil,1,nil,nil -52099,internet,TRUEINTERNET,true,1,true,1 -52501,e-ideas,SingTel(PostPaid),nil,1,nil,nil -52501,hicard,SingTel(PrePaid),nil,1,nil,nil -52502,e-ideas,SingTel(PostPaid),nil,1,nil,nil -52502,hicard,SingTel(PrePaid),nil,1,nil,nil -52503,sunsurf,SunsurfMobile,nil,1,nil,nil -52504,sunsurf,SunsurfMobile,nil,1,nil,nil -52505,shwap,SHDataPostpaid,nil,1,nil,nil -52802,default,B-Mobile,nil,1,nil,nil -52811,default,DSTCom,nil,1,nil,nil -53001,vodafone,VFNZInternet,nil,1,nil,nil -53005,Internet,Data,nil,1,nil,nil -53005,wapaccess.co.nz,Default,nil,1,nil,nil -53024,internet,2DegreesInternet,nil,1,nil,nil -53602,default,Digicel,nil,1,nil,nil -53701,default,BeMobile,nil,1,nil,nil -53703,wap.digicelpng.com,PNGWAP,nil,1,nil,nil -53703,internet.digicelpng.com,PNGWEB,nil,1,nil,nil -53703,wap.digicel.com.pg,PapuaNewGuinea,nil,1,nil,1 -53703,em,EMnify,nil,1,nil,nil -53901,default,U-Call,nil,1,nil,nil -53943,default,ShorelineCommunication,nil,1,nil,nil -53988,default,Digicel,nil,1,nil,nil -53988,wap,Tonga,nil,1,nil,1 -54001,default,BREEZE,nil,1,nil,nil -54002,default,BeMobile,nil,1,nil,nil -54100,default,AIL,nil,1,nil,nil -54101,default,SMILE,nil,1,nil,nil -54105,default,Digicel,nil,1,nil,nil -54105,wap,Vanatu,nil,1,nil,1 -54201,default,Vodafone,nil,1,nil,nil -54202,default,Digicel,nil,1,nil,nil -54202,wap,Fiji,nil,1,nil,1 -54411,default,Bluesky,nil,1,nil,nil -54501,default,Kiribati-TSKL,nil,1,nil,nil -54509,default,Kiribati-FrigateNet,nil,1,nil,nil -54601,default,Mobilis,nil,1,nil,nil -54720,default,Vini,nil,1,nil,nil -54801,default,TelecomCook,nil,1,nil,nil -54901,default,Digicel,nil,1,nil,nil -54927,default,Bluesky,nil,1,nil,nil -55001,default,FSMTC,nil,1,nil,nil -55101,default,MINTA,nil,1,nil,nil -55201,default,PNCC,nil,1,nil,nil -55280,default,PalauMobile,nil,1,nil,nil -60201,mobinilweb,MobinilWeb,nil,1,nil,nil -60201,mobinilwap,MobinilWAP,nil,1,nil,nil -60202,internet.vodafone.net,vodafoneinternet,internet,1,internet,3 -60202,wap.vodafone.com.eg,VodafoneWAP,wap,1,wap,3 -60203,etisalat,EtisalatWAP,nil,1,nil,nil -60301,wap,mobiliswap,wap,1,wap,1 -60301,internet,Mobilisinternet,internet,1,internet,1 -60302,djezzy.internet,djezzy.internet,nil,1,nil,nil -60303,internet,Ooredoointernet,nil,1,nil,1 -60400,internet.orange.ma,Internet,nil,1,nil,1 -60400,wap.meditel.ma,Imedia,MEDIWAP,1,MEDIWAP,1 -60401,wap.iamgprs.ma,MobileZone,nil,1,nil,nil -60401,www.iamgprs1.ma,InternetMobile,nil,1,nil,nil -60402,www.wana.ma,WEB,nil,1,nil,nil -60501,weborange,weborange,nil,1,nil,nil -60502,internet.tn,Internet,nil,1,nil,nil -60502,gprs.tn,InternetPortail,gprs,1,gprs,1 -60503,internet.ooredoo.tn,OoredooTNInternet,nil,1,nil,nil -60600,default,Libyana,nil,1,nil,nil -60601,default,Madar,nil,1,nil,nil -60602,default,Al-JeelPhone,nil,1,nil,nil -60603,default,LibyaPhone,nil,1,nil,nil -60606,default,HatefLibya,nil,1,nil,nil -60701,default,Gamcel,nil,1,nil,nil -60702,default,Africel,nil,1,nil,nil -60703,default,Comium,nil,1,nil,nil -60704,default,QCell,nil,1,nil,nil -60801,wap,OrangeWapSN,wap,1,wap,nil -60801,internet,OrangeWebSN,internet,1,internet,nil -60802,web.sentel.com,TigoInternetSN,nil,1,nil,nil -60803,expresso,ExpressoInternetSN,wap,1,wap,nil -60901,default,Mattel,nil,1,nil,nil -60902,default,Chinguitel,nil,1,nil,nil -60910,default,Mauritel,nil,1,nil,nil -61002,internet,Orange3G/4G,internet,1,internet,1 -61002,wap,OrangeWapML,wap,1,wap,nil -61101,default,OrangeS.A.,nil,1,nil,nil -61102,default,Sotelgui,nil,1,nil,nil -61103,default,TelecelGuinee,nil,1,nil,nil -61104,default,MTN,nil,1,nil,nil -61105,default,Cellcom,nil,1,nil,nil -61202,moov,MoovInternetCI,web,1,web,nil -61203,orangeciweb,Oweb,web,1,web,1 -61203,orangeciwap,OWORLDCI,wap,1,wap,nil -61204,gprs.koz.ci,KozInternetCI,web,1,web,nil -61205,web.mtn.ci,MTNInternetCI,vide,1,vide,nil -61301,default,Telmob,nil,1,nil,nil -61302,default,Airtel,nil,1,nil,nil -61303,default,TelecelFaso,nil,1,nil,nil -61404,orange.ne,OrangeInternet,nil,1,nil,nil -61501,default,TogoCell,nil,1,nil,nil -61503,default,Moov,nil,1,nil,nil -61601,default,Libercom,nil,1,nil,nil -61602,default,Moov,nil,1,nil,nil -61603,default,MTN,nil,1,nil,nil -61604,default,BBCOM,nil,1,nil,nil -61605,default,Glo,nil,1,nil,nil -61701,orange,OrangeInternet,nil,1,nil,nil -61801,default,LonestarCell,nil,1,nil,nil -61802,default,Libercell,nil,1,nil,nil -61804,default,Comium,nil,1,nil,nil -61807,Orange,Orange,nil,1,nil,nil -61820,default,LIBTELCO,nil,1,nil,nil -61901,default,Airtel,nil,1,nil,nil -61902,default,Tigo,nil,1,nil,nil -61903,default,Africell,nil,1,nil,nil -61904,default,Comium,nil,1,nil,nil -61905,default,Africell,nil,1,nil,nil -61925,default,Mobitel,nil,1,nil,nil -6200,glowap,Glo,nil,1,nil,0 -62001,internet,MTNInternetGH,nil,1,nil,nil -62002,browse,VodafoneInternetGH,nil,1,nil,nil -62003,web.tigo.com.gh,TigoInternetGH,nil,1,nil,nil -62006,wap,AirtelInternetGH,nil,1,nil,nil -62007,glowap,GloInternetGH,glo,1,glo,1 -62120,internet.ng.zain.com,AirtelInternet,internet,1,internet,1 -62120,wap.ng.zain.com,AirtelWAP,wap,1,wap,1 -62130,web.gprs.mtnnigeria.net,MTNWAP,web,1,web,1 -62150,glosecure,GloDirect,gprs,1,gprs,1 -62160,etisalat,etisalatWAP,nil,1,nil,nil -62201,default,Airtel,nil,1,nil,nil -62202,default,Tawali,nil,1,nil,nil -62203,default,Tigo,nil,1,nil,nil -62204,default,Salam,nil,1,nil,nil -62301,default,CTP,nil,1,nil,nil -62302,default,TC,nil,1,nil,nil -62303,orangeca3g,Internetbrowsing,nil,1,nil,nil -62304,default,Nationlink,nil,1,nil,nil -62501,default,CVMOVEL,nil,1,nil,nil -62502,default,T+,nil,1,nil,nil -62601,default,CSTmovel,nil,1,nil,nil -62701,default,OrangeGQ,nil,1,nil,nil -62703,default,HitsGQ,nil,1,nil,nil -62801,default,Libertis,nil,1,nil,nil -62802,default,Moov,nil,1,nil,nil -62803,default,Airtel,nil,1,nil,nil -62804,default,Azur,nil,1,nil,nil -62901,default,Airtel,nil,1,nil,nil -62910,default,LibertisTelecom,nil,1,nil,nil -63001,vodanet,VodacomInternetCD,nil,1,nil,nil -63089,tigo.web,TigoInternetCD,nil,1,nil,nil -63102,default,UNITEL,nil,1,nil,nil -63104,default,MOVICEL,nil,1,nil,nil -63202,default,Areeba,nil,1,nil,nil -63203,4Gogb,OrangeBissau,nil,1,nil,nil -63207,default,Guinetel,nil,1,nil,nil -63301,default,Cable&Wireless,nil,1,nil,nil -63302,default,MediatechInternational,nil,1,nil,nil -63310,default,Airtel,nil,1,nil,nil -63401,default,ZainSD,nil,1,nil,nil -63402,default,MTN,nil,1,nil,nil -63407,default,SudaniOne,nil,1,nil,nil -63409,default,PrivetNetwork,nil,1,nil,nil -63510,default,MTN,nil,1,nil,nil -63512,default,Rwandatel,nil,1,nil,nil -63513,default,Tigo,nil,1,nil,nil -63514,default,Airtel,nil,1,nil,nil -63601,default,ETH-MTN,nil,1,nil,nil -63701,default,Telesom,nil,1,nil,nil -63704,default,Somafone,nil,1,nil,nil -63710,default,Nationlink,nil,1,nil,nil -63725,default,Hormuud,nil,1,nil,nil -63730,default,Golis,nil,1,nil,nil -63757,default,Unittel,nil,1,nil,nil -63760,default,NationlinkTelecom,nil,1,nil,nil -63771,default,Somtel,nil,1,nil,nil -63782,default,Telcom,nil,1,nil,nil -63801,default,Evatis,nil,1,nil,nil -63902,safaricom,safaricomGPRS,data,1,saf,1 -63903,internet,AirtelInternet,nil,1,nil,nil -63903,ke.celtel.com,Airtel,nil,1,nil,nil -63905,Internet,YuInternet,nil,1,nil,nil -63905,Yuinternet,YuWAP,nil,1,nil,nil -63907,bew.orange.co.ke,OrangeInternet,nil,1,nil,nil -64004,Wap,VodacomWAP,nil,1,nil,nil -64101,internet,AirtelInternetUG,nil,1,nil,nil -64110,yellopix.mtn.co.ug,MTNInternetUG,nil,1,nil,nil -64111,utweb,UTLInternetUG,nil,1,nil,nil -64114,orange.ug,OrangeInternetUG,nil,1,nil,nil -64122,web.waridtel.co.ug,WaridTelecomInternetUG,nil,1,nil,nil -64201,default,Spacetel,nil,1,nil,nil -64202,default,Tempo,nil,1,nil,nil -64203,default,Onatel,nil,1,nil,nil -64207,default,SmartMobile,nil,1,nil,nil -64208,default,HiTsTelecom,nil,1,nil,nil -64282,default,Leo,nil,1,nil,nil -64301,default,mCel,nil,1,nil,nil -64303,default,Movitel,nil,1,nil,nil -64304,default,Vodacom,nil,1,nil,nil -64501,default,Airtel,nil,1,nil,nil -64502,default,MTN,nil,1,nil,nil -64503,default,ZAMTEL,nil,1,nil,nil -64602,orangenet,OrangeMGInternet,nil,1,nil,0 -64700,orangerun,OrangeWorldre,orange,1,orange,nil -64702,onlywap,OnlyWap,only,1,only,1 -64703,free.re,FreeRe,nil,1,nil,nil -64710,sl2sfr,FullInternetSRR,nil,1,nil,nil -64710,wapsfr,GPRSSRR,wap,1,wap,nil -64710,fnetcoriolis,CoriolisWAP,nil,1,nil,nil -64803,default,Telecel,nil,1,nil,nil -64804,default,Econet,nil,1,nil,nil -64901,default,MTC,nil,1,nil,nil -64902,default,switch,nil,1,nil,nil -64903,default,Leo,nil,1,nil,nil -65001,default,TNM,nil,1,nil,nil -65010,default,Airtel,nil,1,nil,nil -65101,internet,VCLInternetGPRS,nil,1,nil,nil -65310,default,SwaziMTN,nil,1,nil,nil -65401,default,HURI-SNPT,nil,1,nil,nil -65501,lte.vodacom.za,LTE.Vodacom,nil,1,nil,nil -65501,internet,Smart.Vodacom,nil,1,nil,nil -65502,internet,TelkomMobileInternet,nil,1,nil,nil -65507,internet,CellCGPRS,nil,1,nil,nil -65507,vdata,VIRGIN_INTERNET_1,nil,1,nil,nil -65510,myMTN,MTNGPRS,mtnwap,1,mtnwap,1 -65701,default,Eritel,nil,1,nil,nil -70267,default,DigiCell,nil,1,nil,nil -70299,default,Smart,nil,1,nil,nil -70401,internet.ideasclaro,InternetCLARO,nil,1,nil,nil -70402,broadband.tigo.gt,BroadbandTIGO,nil,1,nil,nil -70403,internet.movistar.gt,MovistarINTERNET,movistargt,1,movistargt,1 -704030,internet.movistar.gt,MovistarINTERNET,movistargt,1,movistargt,1 -70601,internet.ideasclaro,InternetCLARO,nil,1,nil,nil -70602,web.digicelsv.com,DigicelInternet,nil,1,nil,nil -70603,internet.tigo.sv,InternetTigo,nil,1,nil,nil -70604,internet.movistar.sv,MovistarINTERNET,movistarsv,1,movistarsv,1 -706040,internet.movistar.sv,MovistarINTERNET,movistarsv,1,movistarsv,1 -708001,internet.ideasclaro,InternetClaro,nil,1,nil,nil -70802,internet.tigo.hn,INTERNETTIGO,nil,1,nil,nil -70804,web.digicelhn.com,Honduras,nil,1,nil,1 -70804,wap.digicelhn.com,Honduras,nil,1,nil,1 -708020,internet.tigo.hn,INTERNETTIGO,nil,1,nil,nil -708040,web.digicelhn.com,Honduras,nil,1,nil,1 -71021,internet.ideasalo.ni,EnitelWEB,internet,1,internet,1 -71030,internet.movistar.ni,MovistarINTERNET,movistarni,1,movistarni,1 -710300,internet.movistar.ni,MovistarINTERNET,movistarni,1,movistarni,1 -71073,internet.ideasalo.ni,EnitelWEB,internet,1,internet,1 -710730,internet.ideasalo.ni,EnitelWEB,internet,1,internet,1 -71201,kolbi3g,KOLBI3G,nil,1,nil,nil -71201,kolbi,CostarRica,nil,1,nil,1 -71202,kolbi3g,KOLBI3G,nil,1,nil,nil -71203,internet.ideasclaro,InternetCLAROCR,nil,1,nil,nil -71204,internet.movistar.cr,MovistarINTERNET,movistarcr,1,movistarcr,1 -712019,tm7datos,InternetTuyo,nil,1,nil,nil -712190,tm7datos,InternetTuyo,nil,1,nil,nil -71220,datos.fullmovil.cr,InternetFullmovil,nil,1,nil,nil -71401,apn01.cwpanama.com.pa,Internet,nil,1,nil,nil -71402,internet.movistar.pa,MovistarINTERNET,movistarpa,1,movistarpa,1 -714020,internet.movistar.pa,MovistarINTERNET,movistarpa,1,movistarpa,1 -71403,web.claro.com.pa,WEBClaro,CLAROWEB,1,CLAROWEB,1 -71404,web.digicelpanama.com,DigicelInternet,nil,1,nil,nil -714040,web.digicelpanama.com,Panama,nil,1,nil,1 -71606,movistar.pe,MovistarINTERNET,movistar,1,movistar@datos,1 -71610,claro.pe,CLARODATOS,claro,1,claro,1 -71615,bitel,Bitel-Internet,nil,1,nil,1 -71617,entel.pe,EntelPE,nil,1,nil,0 -71617,location.entel.pe,EntelLocation,nil,1,nil,0 -72201,internet.movil,Quam_WEB,internet,1,internet,1 -72207,wap.gprs.unifon.com.ar,MovistarWAP,wap,1,wap,1 -72207,internet.gprs.unifon.com.ar,Argentina,internet,1,internet,1 -72231,igprs.claro.com.ar,ClaroAR,nil,1,nil,nil -722310,igprs.claro.com.ar,ClaroAR,nil,1,nil,nil -72234,datos.personal.com,PersonalDatos,datos,1,datos,1 -72234,internet.personal.com,Argentina,internet,1,internet,0 -72236,gprs.nuestro.com.ar,Argentina,nil,1,gprs,0 -722340,datos.personal.com,Argentina,adgj,1,gprs,0 -722340,internet.personal.com,Argentina,internet,1,internet,0 -722341,datos.personal.com,PersonalDatos,datos,1,datos,1 -722341,internet.personal.com,Argentina,internet,1,internet,0 -72402,timbrasil.br,TIMConnect,tim,1,tim,1 -72403,timbrasil.br,TIMConnect,tim,1,tim,1 -72404,timbrasil.br,TIMConnect,tim,1,tim,1 -72405,java.claro.com.br,JavaSession,claro,1,claro,nil -72406,zap.vivo.com.br,VivoInternet,vivo,1,vivo,1 -72407,sercomtel.com.br,SCTLGPRS,sercomtel,1,sercomtel,nil -72410,zap.vivo.com.br,VivoInternet,vivo,1,vivo,1 -72411,zap.vivo.com.br,VivoInternet,vivo,1,vivo,1 -72415,sercomtel.com.br,Sercomtel,sercomtel,1,sercomtel,1 -72416,gprs.oi.com.br,OiGPRSInternet,nil,1,nil,nil -72417,internet.br,Surf,nil,1,nil,1 -72419,gprs.telemigcelular.com.br,TelemigCGPRS,celular,1,celular,nil -72423,zap.vivo.com.br,VivoInternet,vivo,1,vivo,1 -72424,gprs.oi.com.br,OI,oi,1,oi,1 -72431,gprs.oi.com.br,OiGPRSInternet,nil,1,nil,nil -72432,ctbc.br,CTBC,1212,1,CTBC,1 -72433,ctbc.br,CTBC,1212,1,CTBC,1 -72434,ctbc.br,CTBC,1212,1,CTBC,1 -72439,wap.nextel3g.net.br,NextelWAP,nil,1,nil,0 -72454,portoconecta.br,PortoSeguroConecta,nil,1,nil,0 -73001,bam.entelpcs.cl,InternetMovil,entelpcs,1,entelpcs,1 -73009,wap.nextelmovil.cl,InternetNextel,nil,1,nil,0 -73010,bam.entelpcs.cl,InternetMovil,entelpcs,1,entelpcs,1 -73002,wap.tmovil.cl,MovistarAPLICACIONES,wap,1,wap,1 -73003,bam.clarochile.cl,BandaAnchaMovil,clarochile,1,clarochile,1 -73007,web.gtdmovil.cl,web,webgtd,1,webgtd,1 -73008,movil.vtr.com,Internet,vtrmovil,1,vtrmovil,2 -73008,wap.vtr.com,Wap,nil,1,nil,0 -73212,internet.movistar.com.co,MovistarINTERNET,movistar,1,movistar,1 -732101,internet.comcel.com.co,COMCEL,COMCELWEB,1,COMCELWEB,1 -732103,web.colombiamovil.com.co,TIGOWEB,nil,1,nil,1 -732103,moviletb.net.co,InternetETB,etb,1,etb,0 -732103,movilexito.net.co,InternetÉxito,nil,1,nil,1 -732103,www.une.net.co,UNE,une,1,une,0 -732111,web.colombiamovil.com.co,TIGOWEB,nil,1,nil,1 -732111,moviletb.net.co,InternetETB,etb,1,etb,0 -732111,movilexito.net.co,InternetÉxito,nil,1,nil,1 -732111,www.une.net.co,UNE,une,1,une,0 -732123,internet.movistar.com.co,MovistarINTERNET,movistar,1,movistar,1 -732123,web.vmc.net.co,VirginMobile,nil,1,nil,1 -732130,lte.avantel.com.co,Avantel,nil,1,nil,0 -732187,internetmovil.etb.net.co,ETB4G,nil,1,nil,0 -73401,internet.digitel.ve,Digitel412,nil,1,nil,nil -73401,gprsweb.digitel.ve,Venezuela,nil,1,nil,1 -73402,internet.digitel.ve,Digitel412,nil,1,nil,nil -73402,gprsweb.digitel.ve,Venezuela,nil,1,nil,1 -73403,internet.digitel.ve,Digitel412,nil,1,nil,nil -73403,gprsweb.digitel.ve,Venezuela,nil,1,nil,1 -73404,internet.movistar.ve,MovistarINTERNET,nil,1,nil,nil -73404,wap.movistar.ve,MovistarWAP,nil,1,nil,nil -73406,int.movilnet.com.ve,MODEM,nil,1,nil,nil -73601,internet.nuevatel.com,VIVA3G,nil,1,nil,1 -73602,wap.movil.com.bo,ENTELWAPGPRS,nil,1,nil,1 -73603,wap.tigo.bo,WAPTIGO,nil,1,nil,1 -73801,default,Digicel,nil,1,nil,nil -73801,wap.digicelgy.com,Guyana,wap,1,wap,1 -73802,default,GT&TCellinkPlus,nil,1,nil,nil -74000,internet.movistar.com.ec,MovistarINTERNET,movistar,1,movistar,1 -74001,internet.claro.com.ec,InternetClaro,nil,1,nil,nil -740010,internet.claro.com.ec,InternetClaro,nil,1,nil,nil -74002,internet3gsp.alegro.net.ec,CNT3G,nil,1,nil,nil -74401,vox.internet,VOXINTERNET,nil,1,nil,1 -74401,vox.wap,Paraguay,nil,1,nil,1 -74402,igprs.claro.com.py,ClaroPY,ctigprs999,1,ctigprs,1 -74404,internet.tigo.py,TIGOPY,nil,1,nil,1 -74405,internet,PersonalDatosPy,personal,1,personal,1 -74602,default,Telesur,nil,1,nil,nil -74603,web.digicelsr.com,Suriname,nil,1,nil,1 -74603,wap.digicelsr.com,Suriname,wap,1,wap,1 -74801,wap,wapANCEL,nil,1,nil,1 -74801,gprs.ancel,gprsANCEL,nil,1,nil,1 -74807,webapn.movistar.com.uy,MovistarINTERNET,movistar,1,movistar,1 -74810,igprs.claro.com.uy,ClaroUY,ctigprs999,1,ctigprs,1 -28310,Internet,OrangeArmeniaInternet,nil,1,nil,1 -65202,internet.orange.co.bw,OrangeWAPBW,nil,1,nil,nil -62402,orangecmgprs,OrangeCM,orange,1,orange,nil -64602,orangeworld,OrangeWorldMG,orange,1,world,nil -90128,ciot.vodafone.com,CIOTVodafone,vodafone,1,vodafone,nil -90137,mobiledata,mobiledata,nil,1,nil,nil -90143,em,EMnify,nil,1,nil,nil -90158,bicsapn,BICSInternet,nil,1,nil,nil -25050,internet.sberbank-tele.com,Sberbank-TelecomInternet,nil,1,nil,nil -20630,web.be,Unleashed,nil,1,nil,nil -22207,web.kenamobile.it,KenaMobileWeb,nil,1,nil,nil -50519,data.lycamobile.com.au,Lycamobile,nil,1,nil,1 -24223,data.lyca-mobile.no,Lycamobile,nil,1,nil,1 -22854,data.lycamobile.ch,Lycamobile,nil,1,nil,1 -23208,data.lycamobile.at,Lycamobile,nil,1,nil,1 -20606,data.lycamobile.be,Lycamobile,nil,1,nil,1 -26243,data.lycamobile.de,Lycamobile,nil,1,nil,1 -23812,data.lycamobile.dk,Lycamobile,nil,1,nil,1 -21425,data.lycamobile.es,Lycamobile,nil,1,nil,1 -20825,data.lycamobile.fr,Lycamobile,nil,1,nil,1 -27213,data.lycamobile.ie,Lycamobile,nil,1,nil,1 -20409,data.lycamobile.nl,Lycamobile,nil,1,nil,1 -26009,data.lycamobile.pl,Lycamobile,nil,1,nil,1 -26804,data.lycamobile.pt,Lycamobile,nil,1,nil,1 -22616,data.lycamobile.ro,Lycamobile,nil,1,nil,1 -24012,data.lycamobile.se,Lycamobile,nil,1,nil,1 -22235,data.lycamobile.it,Lycamobile,nil,1,nil,1 -311960,data.lycamobile.com,Lycamobile,nil,1,nil,1 -64126,data.lycamobile.ug,Lycamobile,nil,1,nil,1 -29404,data.lycamobile.mk,Lycamobile,nil,1,nil,1 -65553,data.lycamobile.co.za,Lycamobile,nil,1,nil,1 -23457,mobile.sky,Internet,nil,1,nil,0 -29701,flat,Internet,nil,1,nil,3 -29701,internet,Internet,nil,1,nil,3 -29702,tmcg-4g,TelekomInternet,38267,1,38267,1 -29703,mtelinternet,mTelInternet,068,1,internet,2 -40421,jionet,Jio,nil,1,nil,3 -404854,jionet,Jio,nil,1,nil,3 -404855,jionet,Jio,nil,1,nil,3 -404856,jionet,Jio,nil,1,nil,3 -404857,jionet,Jio,nil,1,nil,3 -404858,jionet,Jio,nil,1,nil,3 -404859,jionet,Jio,nil,1,nil,3 -404860,jionet,Jio,nil,1,nil,3 -404861,jionet,Jio,nil,1,nil,3 -404862,jionet,Jio,nil,1,nil,3 -404863,jionet,Jio,nil,1,nil,3 -404864,jionet,Jio,nil,1,nil,3 -404865,jionet,Jio,nil,1,nil,3 -404866,jionet,Jio,nil,1,nil,3 -404867,jionet,Jio,nil,1,nil,3 -404868,jionet,Jio,nil,1,nil,3 -404869,jionet,Jio,nil,1,nil,3 -404870,jionet,Jio,nil,1,nil,3 -404871,jionet,Jio,nil,1,nil,3 -404872,jionet,Jio,nil,1,nil,3 -404873,jionet,Jio,nil,1,nil,3 -404874,jionet,Jio,nil,1,nil,3 -22801,shared.m2m.ch,SwisscomM2M,nil,1,nil,0 -27202,Open.internet,3Ireland,nil,1,nil,nil -24008,services.telenor.se,TelenorMobilsurf,nil,1,nil,nil -310410,accessrgn.net,AT&T,nil,1,nil,nil -24603,static.tele2.lt,Tele2,nil,1,nil,nil -24602,bangapro,Bite,nil,1,nil,nil -24601,gprs.fix-ip.omnitel1.net,Telia,nil,1,nil,nil -20404,truphone.com,Truphone,nil,1,nil,nil -20433,truphone.com,Truphone,nil,1,nil,nil -20809,truphone.com,Truphone,nil,1,nil,nil -20812,truphone.com,Truphone,nil,1,nil,nil -21427,truphone.com,Truphone,nil,1,nil,nil -23425,truphone.com,Truphone,nil,1,nil,nil -26033,truphone.com,Truphone,nil,1,nil,nil -26242,truphone.com,Truphone,nil,1,nil,nil -31030,truphone.com,Truphone,nil,1,nil,nil -310300,truphone.com,Truphone,nil,1,nil,nil -45408,truphone.com,Truphone,nil,1,nil,nil -50538,truphone.com,Truphone,nil,1,nil,nil -50502,truphone.com,Truphone,nil,1,nil,nil -20828,datapro,AIF,nil,1,nil,nil -90140,iot.1nce.net,1NCE,nil,1,nil,nil -00101,internet,Amarisoft,nil,1,nil,nil -00101,default,Amarisoft,nil,1,nil,nil -40001,internet,Azercell,nil,1,nil,nil -310004,VZWINTERNET,Verizon,nil,3,nil,nil -310010,VZWINTERNET,Verizon,nil,3,nil,nil -310012,VZWINTERNET,Verizon,nil,3,nil,nil -310013,VZWINTERNET,Verizon,nil,3,nil,nil -310350,VZWINTERNET,Verizon,nil,3,nil,nil -310590,VZWINTERNET,Verizon,nil,3,nil,nil -310591,VZWINTERNET,Verizon,nil,3,nil,nil -310592,VZWINTERNET,Verizon,nil,3,nil,nil -310593,VZWINTERNET,Verizon,nil,3,nil,nil -310594,VZWINTERNET,Verizon,nil,3,nil,nil -310595,VZWINTERNET,Verizon,nil,3,nil,nil -310596,VZWINTERNET,Verizon,nil,3,nil,nil -310597,VZWINTERNET,Verizon,nil,3,nil,nil -310598,VZWINTERNET,Verizon,nil,3,nil,nil -310599,VZWINTERNET,Verizon,nil,3,nil,nil -310820,VZWINTERNET,Verizon,nil,3,nil,nil -310890,VZWINTERNET,Verizon,nil,3,nil,nil -310891,VZWINTERNET,Verizon,nil,3,nil,nil -310892,VZWINTERNET,Verizon,nil,3,nil,nil -310893,VZWINTERNET,Verizon,nil,3,nil,nil -310894,VZWINTERNET,Verizon,nil,3,nil,nil -310895,VZWINTERNET,Verizon,nil,3,nil,nil -310896,VZWINTERNET,Verizon,nil,3,nil,nil -310897,VZWINTERNET,Verizon,nil,3,nil,nil -310898,VZWINTERNET,Verizon,nil,3,nil,nil -310899,VZWINTERNET,Verizon,nil,3,nil,nil -310910,VZWINTERNET,Verizon,nil,3,nil,nil -311110,VZWINTERNET,Verizon,nil,3,nil,nil -311270,VZWINTERNET,Verizon,nil,3,nil,nil -311271,VZWINTERNET,Verizon,nil,3,nil,nil -311272,VZWINTERNET,Verizon,nil,3,nil,nil -311273,VZWINTERNET,Verizon,nil,3,nil,nil -311274,VZWINTERNET,Verizon,nil,3,nil,nil -311275,VZWINTERNET,Verizon,nil,3,nil,nil -311276,VZWINTERNET,Verizon,nil,3,nil,nil -311277,VZWINTERNET,Verizon,nil,3,nil,nil -311278,VZWINTERNET,Verizon,nil,3,nil,nil -311279,VZWINTERNET,Verizon,nil,3,nil,nil -311280,VZWINTERNET,Verizon,nil,3,nil,nil -311281,VZWINTERNET,Verizon,nil,3,nil,nil -311282,VZWINTERNET,Verizon,nil,3,nil,nil -311283,VZWINTERNET,Verizon,nil,3,nil,nil -311284,VZWINTERNET,Verizon,nil,3,nil,nil -311285,VZWINTERNET,Verizon,nil,3,nil,nil -311286,VZWINTERNET,Verizon,nil,3,nil,nil -311287,VZWINTERNET,Verizon,nil,3,nil,nil -311288,VZWINTERNET,Verizon,nil,3,nil,nil -311289,VZWINTERNET,Verizon,nil,3,nil,nil -311390,VZWINTERNET,Verizon,nil,3,nil,nil -311480,VZWINTERNET,Verizon,nil,3,nil,nil -311481,VZWINTERNET,Verizon,nil,3,nil,nil -311482,VZWINTERNET,Verizon,nil,3,nil,nil -311483,VZWINTERNET,Verizon,nil,3,nil,nil -311484,VZWINTERNET,Verizon,nil,3,nil,nil -311485,VZWINTERNET,Verizon,nil,3,nil,nil -311486,VZWINTERNET,Verizon,nil,3,nil,nil -311487,VZWINTERNET,Verizon,nil,3,nil,nil -311488,VZWINTERNET,Verizon,nil,3,nil,nil -311489,VZWINTERNET,Verizon,nil,3,nil,nil -311590,VZWINTERNET,Verizon,nil,3,nil,nil -312040,VZWINTERNET,Verizon,nil,3,nil,nil -312160,VZWINTERNET,Verizon,nil,3,nil,nil -312770,VZWINTERNET,Verizon,nil,3,nil,nil -310010,VZWINTERNET,Verizon,nil,3,nil,nil -310012,VZWINTERNET,Verizon,nil,3,nil,nil -310004,ne01.vzwstatic,Verizon,nil,3,nil,nil -310010,ne01.vzwstatic,Verizon,nil,3,nil,nil -310012,ne01.vzwstatic,Verizon,nil,3,nil,nil -310013,ne01.vzwstatic,Verizon,nil,3,nil,nil -310350,ne01.vzwstatic,Verizon,nil,3,nil,nil -310590,ne01.vzwstatic,Verizon,nil,3,nil,nil -310591,ne01.vzwstatic,Verizon,nil,3,nil,nil -310592,ne01.vzwstatic,Verizon,nil,3,nil,nil -310593,ne01.vzwstatic,Verizon,nil,3,nil,nil -310594,ne01.vzwstatic,Verizon,nil,3,nil,nil -310595,ne01.vzwstatic,Verizon,nil,3,nil,nil -310596,ne01.vzwstatic,Verizon,nil,3,nil,nil -310597,ne01.vzwstatic,Verizon,nil,3,nil,nil -310598,ne01.vzwstatic,Verizon,nil,3,nil,nil -310599,ne01.vzwstatic,Verizon,nil,3,nil,nil -310820,ne01.vzwstatic,Verizon,nil,3,nil,nil -310890,ne01.vzwstatic,Verizon,nil,3,nil,nil -310891,ne01.vzwstatic,Verizon,nil,3,nil,nil -310892,ne01.vzwstatic,Verizon,nil,3,nil,nil -310893,ne01.vzwstatic,Verizon,nil,3,nil,nil -310894,ne01.vzwstatic,Verizon,nil,3,nil,nil -310895,ne01.vzwstatic,Verizon,nil,3,nil,nil -310896,ne01.vzwstatic,Verizon,nil,3,nil,nil -310897,ne01.vzwstatic,Verizon,nil,3,nil,nil -310898,ne01.vzwstatic,Verizon,nil,3,nil,nil -310899,ne01.vzwstatic,Verizon,nil,3,nil,nil -310910,ne01.vzwstatic,Verizon,nil,3,nil,nil -311110,ne01.vzwstatic,Verizon,nil,3,nil,nil -311270,ne01.vzwstatic,Verizon,nil,3,nil,nil -311271,ne01.vzwstatic,Verizon,nil,3,nil,nil -311272,ne01.vzwstatic,Verizon,nil,3,nil,nil -311273,ne01.vzwstatic,Verizon,nil,3,nil,nil -311274,ne01.vzwstatic,Verizon,nil,3,nil,nil -311275,ne01.vzwstatic,Verizon,nil,3,nil,nil -311276,ne01.vzwstatic,Verizon,nil,3,nil,nil -311277,ne01.vzwstatic,Verizon,nil,3,nil,nil -311278,ne01.vzwstatic,Verizon,nil,3,nil,nil -311279,ne01.vzwstatic,Verizon,nil,3,nil,nil -311280,ne01.vzwstatic,Verizon,nil,3,nil,nil -311281,ne01.vzwstatic,Verizon,nil,3,nil,nil -311282,ne01.vzwstatic,Verizon,nil,3,nil,nil -311283,ne01.vzwstatic,Verizon,nil,3,nil,nil -311284,ne01.vzwstatic,Verizon,nil,3,nil,nil -311285,ne01.vzwstatic,Verizon,nil,3,nil,nil -311286,ne01.vzwstatic,Verizon,nil,3,nil,nil -311287,ne01.vzwstatic,Verizon,nil,3,nil,nil -311288,ne01.vzwstatic,Verizon,nil,3,nil,nil -311289,ne01.vzwstatic,Verizon,nil,3,nil,nil -311390,ne01.vzwstatic,Verizon,nil,3,nil,nil -311480,ne01.vzwstatic,Verizon,nil,3,nil,nil -311481,ne01.vzwstatic,Verizon,nil,3,nil,nil -311482,ne01.vzwstatic,Verizon,nil,3,nil,nil -311483,ne01.vzwstatic,Verizon,nil,3,nil,nil -311484,ne01.vzwstatic,Verizon,nil,3,nil,nil -311485,ne01.vzwstatic,Verizon,nil,3,nil,nil -311486,ne01.vzwstatic,Verizon,nil,3,nil,nil -311487,ne01.vzwstatic,Verizon,nil,3,nil,nil -311488,ne01.vzwstatic,Verizon,nil,3,nil,nil -311489,ne01.vzwstatic,Verizon,nil,3,nil,nil -311590,ne01.vzwstatic,Verizon,nil,3,nil,nil -312040,ne01.vzwstatic,Verizon,nil,3,nil,nil -312160,ne01.vzwstatic,Verizon,nil,3,nil,nil -312770,ne01.vzwstatic,Verizon,nil,3,nil,nil -310004,nw01.vzwstatic,Verizon,nil,3,nil,nil -310010,nw01.vzwstatic,Verizon,nil,3,nil,nil -310012,nw01.vzwstatic,Verizon,nil,3,nil,nil -310013,nw01.vzwstatic,Verizon,nil,3,nil,nil -310350,nw01.vzwstatic,Verizon,nil,3,nil,nil -310590,nw01.vzwstatic,Verizon,nil,3,nil,nil -310591,nw01.vzwstatic,Verizon,nil,3,nil,nil -310592,nw01.vzwstatic,Verizon,nil,3,nil,nil -310593,nw01.vzwstatic,Verizon,nil,3,nil,nil -310594,nw01.vzwstatic,Verizon,nil,3,nil,nil -310595,nw01.vzwstatic,Verizon,nil,3,nil,nil -310596,nw01.vzwstatic,Verizon,nil,3,nil,nil -310597,nw01.vzwstatic,Verizon,nil,3,nil,nil -310598,nw01.vzwstatic,Verizon,nil,3,nil,nil -310599,nw01.vzwstatic,Verizon,nil,3,nil,nil -310820,nw01.vzwstatic,Verizon,nil,3,nil,nil -310890,nw01.vzwstatic,Verizon,nil,3,nil,nil -310891,nw01.vzwstatic,Verizon,nil,3,nil,nil -310892,nw01.vzwstatic,Verizon,nil,3,nil,nil -310893,nw01.vzwstatic,Verizon,nil,3,nil,nil -310894,nw01.vzwstatic,Verizon,nil,3,nil,nil -310895,nw01.vzwstatic,Verizon,nil,3,nil,nil -310896,nw01.vzwstatic,Verizon,nil,3,nil,nil -310897,nw01.vzwstatic,Verizon,nil,3,nil,nil -310898,nw01.vzwstatic,Verizon,nil,3,nil,nil -310899,nw01.vzwstatic,Verizon,nil,3,nil,nil -310910,nw01.vzwstatic,Verizon,nil,3,nil,nil -311110,nw01.vzwstatic,Verizon,nil,3,nil,nil -311270,nw01.vzwstatic,Verizon,nil,3,nil,nil -311271,nw01.vzwstatic,Verizon,nil,3,nil,nil -311272,nw01.vzwstatic,Verizon,nil,3,nil,nil -311273,nw01.vzwstatic,Verizon,nil,3,nil,nil -311274,nw01.vzwstatic,Verizon,nil,3,nil,nil -311275,nw01.vzwstatic,Verizon,nil,3,nil,nil -311276,nw01.vzwstatic,Verizon,nil,3,nil,nil -311277,nw01.vzwstatic,Verizon,nil,3,nil,nil -311278,nw01.vzwstatic,Verizon,nil,3,nil,nil -311279,nw01.vzwstatic,Verizon,nil,3,nil,nil -311280,nw01.vzwstatic,Verizon,nil,3,nil,nil -311281,nw01.vzwstatic,Verizon,nil,3,nil,nil -311282,nw01.vzwstatic,Verizon,nil,3,nil,nil -311283,nw01.vzwstatic,Verizon,nil,3,nil,nil -311284,nw01.vzwstatic,Verizon,nil,3,nil,nil -311285,nw01.vzwstatic,Verizon,nil,3,nil,nil -311286,nw01.vzwstatic,Verizon,nil,3,nil,nil -311287,nw01.vzwstatic,Verizon,nil,3,nil,nil -311288,nw01.vzwstatic,Verizon,nil,3,nil,nil -311289,nw01.vzwstatic,Verizon,nil,3,nil,nil -311390,nw01.vzwstatic,Verizon,nil,3,nil,nil -311480,nw01.vzwstatic,Verizon,nil,3,nil,nil -311481,nw01.vzwstatic,Verizon,nil,3,nil,nil -311482,nw01.vzwstatic,Verizon,nil,3,nil,nil -311483,nw01.vzwstatic,Verizon,nil,3,nil,nil -311484,nw01.vzwstatic,Verizon,nil,3,nil,nil -311485,nw01.vzwstatic,Verizon,nil,3,nil,nil -311486,nw01.vzwstatic,Verizon,nil,3,nil,nil -311487,nw01.vzwstatic,Verizon,nil,3,nil,nil -311488,nw01.vzwstatic,Verizon,nil,3,nil,nil -311489,nw01.vzwstatic,Verizon,nil,3,nil,nil -311590,nw01.vzwstatic,Verizon,nil,3,nil,nil -312040,nw01.vzwstatic,Verizon,nil,3,nil,nil -312160,nw01.vzwstatic,Verizon,nil,3,nil,nil -312770,nw01.vzwstatic,Verizon,nil,3,nil,nil -310004,so01.vzwstatic,Verizon,nil,3,nil,nil -310010,so01.vzwstatic,Verizon,nil,3,nil,nil -310012,so01.vzwstatic,Verizon,nil,3,nil,nil -310013,so01.vzwstatic,Verizon,nil,3,nil,nil -310350,so01.vzwstatic,Verizon,nil,3,nil,nil -310590,so01.vzwstatic,Verizon,nil,3,nil,nil -310591,so01.vzwstatic,Verizon,nil,3,nil,nil -310592,so01.vzwstatic,Verizon,nil,3,nil,nil -310593,so01.vzwstatic,Verizon,nil,3,nil,nil -310594,so01.vzwstatic,Verizon,nil,3,nil,nil -310595,so01.vzwstatic,Verizon,nil,3,nil,nil -310596,so01.vzwstatic,Verizon,nil,3,nil,nil -310597,so01.vzwstatic,Verizon,nil,3,nil,nil -310598,so01.vzwstatic,Verizon,nil,3,nil,nil -310599,so01.vzwstatic,Verizon,nil,3,nil,nil -310820,so01.vzwstatic,Verizon,nil,3,nil,nil -310890,so01.vzwstatic,Verizon,nil,3,nil,nil -310891,so01.vzwstatic,Verizon,nil,3,nil,nil -310892,so01.vzwstatic,Verizon,nil,3,nil,nil -310893,so01.vzwstatic,Verizon,nil,3,nil,nil -310894,so01.vzwstatic,Verizon,nil,3,nil,nil -310895,so01.vzwstatic,Verizon,nil,3,nil,nil -310896,so01.vzwstatic,Verizon,nil,3,nil,nil -310897,so01.vzwstatic,Verizon,nil,3,nil,nil -310898,so01.vzwstatic,Verizon,nil,3,nil,nil -310899,so01.vzwstatic,Verizon,nil,3,nil,nil -310910,so01.vzwstatic,Verizon,nil,3,nil,nil -311110,so01.vzwstatic,Verizon,nil,3,nil,nil -311270,so01.vzwstatic,Verizon,nil,3,nil,nil -311271,so01.vzwstatic,Verizon,nil,3,nil,nil -311272,so01.vzwstatic,Verizon,nil,3,nil,nil -311273,so01.vzwstatic,Verizon,nil,3,nil,nil -311274,so01.vzwstatic,Verizon,nil,3,nil,nil -311275,so01.vzwstatic,Verizon,nil,3,nil,nil -311276,so01.vzwstatic,Verizon,nil,3,nil,nil -311277,so01.vzwstatic,Verizon,nil,3,nil,nil -311278,so01.vzwstatic,Verizon,nil,3,nil,nil -311279,so01.vzwstatic,Verizon,nil,3,nil,nil -311280,so01.vzwstatic,Verizon,nil,3,nil,nil -311281,so01.vzwstatic,Verizon,nil,3,nil,nil -311282,so01.vzwstatic,Verizon,nil,3,nil,nil -311283,so01.vzwstatic,Verizon,nil,3,nil,nil -311284,so01.vzwstatic,Verizon,nil,3,nil,nil -311285,so01.vzwstatic,Verizon,nil,3,nil,nil -311286,so01.vzwstatic,Verizon,nil,3,nil,nil -311287,so01.vzwstatic,Verizon,nil,3,nil,nil -311288,so01.vzwstatic,Verizon,nil,3,nil,nil -311289,so01.vzwstatic,Verizon,nil,3,nil,nil -311390,so01.vzwstatic,Verizon,nil,3,nil,nil -311480,so01.vzwstatic,Verizon,nil,3,nil,nil -311481,so01.vzwstatic,Verizon,nil,3,nil,nil -311482,so01.vzwstatic,Verizon,nil,3,nil,nil -311483,so01.vzwstatic,Verizon,nil,3,nil,nil -311484,so01.vzwstatic,Verizon,nil,3,nil,nil -311485,so01.vzwstatic,Verizon,nil,3,nil,nil -311486,so01.vzwstatic,Verizon,nil,3,nil,nil -311487,so01.vzwstatic,Verizon,nil,3,nil,nil -311488,so01.vzwstatic,Verizon,nil,3,nil,nil -311489,so01.vzwstatic,Verizon,nil,3,nil,nil -311590,so01.vzwstatic,Verizon,nil,3,nil,nil -312040,so01.vzwstatic,Verizon,nil,3,nil,nil -312160,so01.vzwstatic,Verizon,nil,3,nil,nil -312770,so01.vzwstatic,Verizon,nil,3,nil,nil -310004,mw01.vzwstatic,Verizon,nil,3,nil,nil -310010,mw01.vzwstatic,Verizon,nil,3,nil,nil -310012,mw01.vzwstatic,Verizon,nil,3,nil,nil -310013,mw01.vzwstatic,Verizon,nil,3,nil,nil -310350,mw01.vzwstatic,Verizon,nil,3,nil,nil -310590,mw01.vzwstatic,Verizon,nil,3,nil,nil -310591,mw01.vzwstatic,Verizon,nil,3,nil,nil -310592,mw01.vzwstatic,Verizon,nil,3,nil,nil -310593,mw01.vzwstatic,Verizon,nil,3,nil,nil -310594,mw01.vzwstatic,Verizon,nil,3,nil,nil -310595,mw01.vzwstatic,Verizon,nil,3,nil,nil -310596,mw01.vzwstatic,Verizon,nil,3,nil,nil -310597,mw01.vzwstatic,Verizon,nil,3,nil,nil -310598,mw01.vzwstatic,Verizon,nil,3,nil,nil -310599,mw01.vzwstatic,Verizon,nil,3,nil,nil -310820,mw01.vzwstatic,Verizon,nil,3,nil,nil -310890,mw01.vzwstatic,Verizon,nil,3,nil,nil -310891,mw01.vzwstatic,Verizon,nil,3,nil,nil -310892,mw01.vzwstatic,Verizon,nil,3,nil,nil -310893,mw01.vzwstatic,Verizon,nil,3,nil,nil -310894,mw01.vzwstatic,Verizon,nil,3,nil,nil -310895,mw01.vzwstatic,Verizon,nil,3,nil,nil -310896,mw01.vzwstatic,Verizon,nil,3,nil,nil -310897,mw01.vzwstatic,Verizon,nil,3,nil,nil -310898,mw01.vzwstatic,Verizon,nil,3,nil,nil -310899,mw01.vzwstatic,Verizon,nil,3,nil,nil -310910,mw01.vzwstatic,Verizon,nil,3,nil,nil -311110,mw01.vzwstatic,Verizon,nil,3,nil,nil -311270,mw01.vzwstatic,Verizon,nil,3,nil,nil -311271,mw01.vzwstatic,Verizon,nil,3,nil,nil -311272,mw01.vzwstatic,Verizon,nil,3,nil,nil -311273,mw01.vzwstatic,Verizon,nil,3,nil,nil -311274,mw01.vzwstatic,Verizon,nil,3,nil,nil -311275,mw01.vzwstatic,Verizon,nil,3,nil,nil -311276,mw01.vzwstatic,Verizon,nil,3,nil,nil -311277,mw01.vzwstatic,Verizon,nil,3,nil,nil -311278,mw01.vzwstatic,Verizon,nil,3,nil,nil -311279,mw01.vzwstatic,Verizon,nil,3,nil,nil -311280,mw01.vzwstatic,Verizon,nil,3,nil,nil -311281,mw01.vzwstatic,Verizon,nil,3,nil,nil -311282,mw01.vzwstatic,Verizon,nil,3,nil,nil -311283,mw01.vzwstatic,Verizon,nil,3,nil,nil -311284,mw01.vzwstatic,Verizon,nil,3,nil,nil -311285,mw01.vzwstatic,Verizon,nil,3,nil,nil -311286,mw01.vzwstatic,Verizon,nil,3,nil,nil -311287,mw01.vzwstatic,Verizon,nil,3,nil,nil -311288,mw01.vzwstatic,Verizon,nil,3,nil,nil -311289,mw01.vzwstatic,Verizon,nil,3,nil,nil -311390,mw01.vzwstatic,Verizon,nil,3,nil,nil -311480,mw01.vzwstatic,Verizon,nil,3,nil,nil -311481,mw01.vzwstatic,Verizon,nil,3,nil,nil -311482,mw01.vzwstatic,Verizon,nil,3,nil,nil -311483,mw01.vzwstatic,Verizon,nil,3,nil,nil -311484,mw01.vzwstatic,Verizon,nil,3,nil,nil -311485,mw01.vzwstatic,Verizon,nil,3,nil,nil -311486,mw01.vzwstatic,Verizon,nil,3,nil,nil -311487,mw01.vzwstatic,Verizon,nil,3,nil,nil -311488,mw01.vzwstatic,Verizon,nil,3,nil,nil -311489,mw01.vzwstatic,Verizon,nil,3,nil,nil -311590,mw01.vzwstatic,Verizon,nil,3,nil,nil -312040,mw01.vzwstatic,Verizon,nil,3,nil,nil -312160,mw01.vzwstatic,Verizon,nil,3,nil,nil -312770,mw01.vzwstatic,Verizon,nil,3,nil,nil -310004,we01.vzwstatic,Verizon,nil,3,nil,nil -310010,we01.vzwstatic,Verizon,nil,3,nil,nil -310012,we01.vzwstatic,Verizon,nil,3,nil,nil -310013,we01.vzwstatic,Verizon,nil,3,nil,nil -310350,we01.vzwstatic,Verizon,nil,3,nil,nil -310590,we01.vzwstatic,Verizon,nil,3,nil,nil -310591,we01.vzwstatic,Verizon,nil,3,nil,nil -310592,we01.vzwstatic,Verizon,nil,3,nil,nil -310593,we01.vzwstatic,Verizon,nil,3,nil,nil -310594,we01.vzwstatic,Verizon,nil,3,nil,nil -310595,we01.vzwstatic,Verizon,nil,3,nil,nil -310596,we01.vzwstatic,Verizon,nil,3,nil,nil -310597,we01.vzwstatic,Verizon,nil,3,nil,nil -310598,we01.vzwstatic,Verizon,nil,3,nil,nil -310599,we01.vzwstatic,Verizon,nil,3,nil,nil -310820,we01.vzwstatic,Verizon,nil,3,nil,nil -310890,we01.vzwstatic,Verizon,nil,3,nil,nil -310891,we01.vzwstatic,Verizon,nil,3,nil,nil -310892,we01.vzwstatic,Verizon,nil,3,nil,nil -310893,we01.vzwstatic,Verizon,nil,3,nil,nil -310894,we01.vzwstatic,Verizon,nil,3,nil,nil -310895,we01.vzwstatic,Verizon,nil,3,nil,nil -310896,we01.vzwstatic,Verizon,nil,3,nil,nil -310897,we01.vzwstatic,Verizon,nil,3,nil,nil -310898,we01.vzwstatic,Verizon,nil,3,nil,nil -310899,we01.vzwstatic,Verizon,nil,3,nil,nil -310910,we01.vzwstatic,Verizon,nil,3,nil,nil -311110,we01.vzwstatic,Verizon,nil,3,nil,nil -311270,we01.vzwstatic,Verizon,nil,3,nil,nil -311271,we01.vzwstatic,Verizon,nil,3,nil,nil -311272,we01.vzwstatic,Verizon,nil,3,nil,nil -311273,we01.vzwstatic,Verizon,nil,3,nil,nil -311274,we01.vzwstatic,Verizon,nil,3,nil,nil -311275,we01.vzwstatic,Verizon,nil,3,nil,nil -311276,we01.vzwstatic,Verizon,nil,3,nil,nil -311277,we01.vzwstatic,Verizon,nil,3,nil,nil -311278,we01.vzwstatic,Verizon,nil,3,nil,nil -311279,we01.vzwstatic,Verizon,nil,3,nil,nil -311280,we01.vzwstatic,Verizon,nil,3,nil,nil -311281,we01.vzwstatic,Verizon,nil,3,nil,nil -311282,we01.vzwstatic,Verizon,nil,3,nil,nil -311283,we01.vzwstatic,Verizon,nil,3,nil,nil -311284,we01.vzwstatic,Verizon,nil,3,nil,nil -311285,we01.vzwstatic,Verizon,nil,3,nil,nil -311286,we01.vzwstatic,Verizon,nil,3,nil,nil -311287,we01.vzwstatic,Verizon,nil,3,nil,nil -311288,we01.vzwstatic,Verizon,nil,3,nil,nil -311289,we01.vzwstatic,Verizon,nil,3,nil,nil -311390,we01.vzwstatic,Verizon,nil,3,nil,nil -311480,we01.vzwstatic,Verizon,nil,3,nil,nil -311481,we01.vzwstatic,Verizon,nil,3,nil,nil -311482,we01.vzwstatic,Verizon,nil,3,nil,nil -311483,we01.vzwstatic,Verizon,nil,3,nil,nil -311484,we01.vzwstatic,Verizon,nil,3,nil,nil -311485,we01.vzwstatic,Verizon,nil,3,nil,nil -311486,we01.vzwstatic,Verizon,nil,3,nil,nil -311487,we01.vzwstatic,Verizon,nil,3,nil,nil -311488,we01.vzwstatic,Verizon,nil,3,nil,nil -311489,we01.vzwstatic,Verizon,nil,3,nil,nil -311590,we01.vzwstatic,Verizon,nil,3,nil,nil -312040,we01.vzwstatic,Verizon,nil,3,nil,nil -312160,we01.vzwstatic,Verizon,nil,3,nil,nil -312770,we01.vzwstatic,Verizon,nil,3,nil,nil -302490,internet.freedommobile.ca,FreedomMobile,nil,1,nil,nil \ No newline at end of file diff --git a/rooter/0optionalapps/ext-blacklist/Makefile b/rooter/0optionalapps/ext-blacklist/Makefile deleted file mode 100644 index 0c156e8..0000000 --- a/rooter/0optionalapps/ext-blacklist/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -#Owned by DairyMan@Whirlpool -# -#Copyright GNU act. -include $(TOPDIR)/rules.mk - -PKG_NAME:=ext-blacklist -PKG_VERSION:=1.000 -PKG_RELEASE:=1 - -PKG_MAINTAINER:=Created by DM/makefile by Cobia@whirlpool -include $(INCLUDE_DIR)/package.mk - -define Package/ext-blacklist - SECTION:=utils - CATEGORY:=ROOter - SUBMENU:=Optional Applications - TITLE:=Install Mac Blacklisting - PKGARCH:=all -endef - -define Package/ext-blacklistdescription - Helper scripts to install Mac Blacklisting -endef - - -define Build/Compile -endef - -define Package/ext-blacklist/install - $(CP) ./files/* $(1)/ - - -endef - -$(eval $(call BuildPackage,ext-blacklist)) diff --git a/rooter/0optionalapps/ext-blacklist/files/etc/config/blacklist b/rooter/0optionalapps/ext-blacklist/files/etc/config/blacklist deleted file mode 100644 index 00fb552..0000000 --- a/rooter/0optionalapps/ext-blacklist/files/etc/config/blacklist +++ /dev/null @@ -1,4 +0,0 @@ - -config blacklist 'blacklist' - - diff --git a/rooter/0optionalapps/ext-blacklist/files/usr/lib/blacklist/blacklist.sh b/rooter/0optionalapps/ext-blacklist/files/usr/lib/blacklist/blacklist.sh deleted file mode 100644 index 6775a95..0000000 --- a/rooter/0optionalapps/ext-blacklist/files/usr/lib/blacklist/blacklist.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -. /lib/functions.sh - -log() { - logger -t "Blacklist" "$@" -} - -getmac() { - local config=$1 - config_get src_mac $1 src_mac - if [ ! -z $src_mac ]; then - if [ $create = "0" ]; then - uci set firewall.blacklist=rule - uci set firewall.blacklist.src='lan' - uci set firewall.blacklist.target='REJECT' - uci set firewall.blacklist.dest='wan' - uci set firewall.blacklist.name='Blacklist' - create=1 - fi - uci add_list firewall.blacklist.src_mac=$src_mac - fi -} - -sleep 8 -create="0" -uci -q delete firewall.blacklist -config_load blacklist -config_foreach getmac devices -uci commit firewall -/etc/init.d/firewall restart - -exit 0 diff --git a/rooter/0optionalapps/ext-blacklist/files/usr/lib/blacklist/chkblack.sh b/rooter/0optionalapps/ext-blacklist/files/usr/lib/blacklist/chkblack.sh deleted file mode 100644 index 4b13613..0000000 --- a/rooter/0optionalapps/ext-blacklist/files/usr/lib/blacklist/chkblack.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -log() { - logger -t "Blacklist" "$@" -} - - -result=`ps | grep -i "blacklist.sh" | grep -v "grep" | wc -l` -if [ $result -eq 0 ]; then - /usr/lib/blacklist/blacklist.sh & -fi \ No newline at end of file diff --git a/rooter/0optionalapps/ext-blacklist/files/usr/lib/lua/luci/controller/blacklist.lua b/rooter/0optionalapps/ext-blacklist/files/usr/lib/lua/luci/controller/blacklist.lua deleted file mode 100644 index 5797a2d..0000000 --- a/rooter/0optionalapps/ext-blacklist/files/usr/lib/lua/luci/controller/blacklist.lua +++ /dev/null @@ -1,10 +0,0 @@ -module("luci.controller.blacklist", package.seeall) - -function index() - local page - local lock = luci.model.uci.cursor():get("custom", "menu", "full") - if lock == "1" then - page = entry({"admin", "adminmenu", "blacklist"}, cbi("blacklist"), "---Blacklist by Mac", 10) - page.dependent = true - end -end diff --git a/rooter/0optionalapps/ext-blacklist/files/usr/lib/lua/luci/model/cbi/blacklist.lua b/rooter/0optionalapps/ext-blacklist/files/usr/lib/lua/luci/model/cbi/blacklist.lua deleted file mode 100644 index 91fa4e7..0000000 --- a/rooter/0optionalapps/ext-blacklist/files/usr/lib/lua/luci/model/cbi/blacklist.lua +++ /dev/null @@ -1,21 +0,0 @@ -require("nixio.fs") - -m = Map("blacklist", translate("Blacklist Devices by Mac Address")) - -m.on_after_save = function(self) - luci.sys.call("/usr/lib/blacklist/chkblack.sh &") -end - -s = m:section(TypedSection, "devices", translate("Blacklisted Devices"), translate("Block these devices from using the Internet")) -s.anonymous = true -s.addremove = true - -o = s:option(Value, "src_mac", translate("Device MAC address")) - o.datatype = "list(macaddr)" - o.placeholder = translate("any") - - luci.sys.net.mac_hints(function(mac, name) - o:value(mac, "%s (%s)" %{ mac, name }) - end) - -return m \ No newline at end of file diff --git a/rooter/0optionalapps/ext-blockport/Makefile b/rooter/0optionalapps/ext-blockport/Makefile deleted file mode 100644 index 103fa98..0000000 --- a/rooter/0optionalapps/ext-blockport/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -#Owned by DairyMan@Whirlpool -# -#Copyright GNU act. -include $(TOPDIR)/rules.mk - -PKG_NAME:=ext-blockport -PKG_VERSION:=1.000 -PKG_RELEASE:=1 - -PKG_MAINTAINER:=Created by DM/makefile by Cobia@whirlpool -include $(INCLUDE_DIR)/package.mk - -define Package/ext-blockport - SECTION:=utils - CATEGORY:=ROOter - SUBMENU:=Optional Applications - TITLE:=Install Port Blocking - PKGARCH:=all -endef - -define Package/ext-blockport/description - Helper scripts to install Port Blocking -endef - - -define Build/Compile -endef - -define Package/ext-blockport/install - $(CP) ./files/* $(1)/ - - -endef - -$(eval $(call BuildPackage,ext-blockport)) diff --git a/rooter/0optionalapps/ext-blockport/files/etc/config/blockport b/rooter/0optionalapps/ext-blockport/files/etc/config/blockport deleted file mode 100644 index 8e69716..0000000 --- a/rooter/0optionalapps/ext-blockport/files/etc/config/blockport +++ /dev/null @@ -1,4 +0,0 @@ - -config port 'port' - - diff --git a/rooter/0optionalapps/ext-blockport/files/usr/lib/blockport/blockport.sh b/rooter/0optionalapps/ext-blockport/files/usr/lib/blockport/blockport.sh deleted file mode 100644 index 6965bc0..0000000 --- a/rooter/0optionalapps/ext-blockport/files/usr/lib/blockport/blockport.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh -. /lib/functions.sh - -config="firewall" - -do_block_remove() { - config_get name $1 name - if [ "$name" = "Block_src" ]; then - uci delete $config".""$1" - fi -} - -handle_port() { - echo $1 - uci add $config rule - uci set $config.@rule[-1].src='lan' - uci set $config.@rule[-1].family='ipv4' - uci set $config.@rule[-1].dest='wan' - uci set $config.@rule[-1].target='DROP' - uci set $config.@rule[-1].proto='tcp' - uci set $config.@rule[-1].src_port="$1" - uci set $config.@rule[-1].name='Block_src' -} - -do_port() { - config_list_foreach "$1" block handle_port -} - -sleep 8 -config_load $config -config_foreach do_block_remove rule - -config_load blockport -config_foreach do_port port -uci commit $config -/etc/init.d/firewall restart 2>/dev/null - diff --git a/rooter/0optionalapps/ext-blockport/files/usr/lib/lua/luci/controller/blockport.lua b/rooter/0optionalapps/ext-blockport/files/usr/lib/lua/luci/controller/blockport.lua deleted file mode 100644 index 57bd9ff..0000000 --- a/rooter/0optionalapps/ext-blockport/files/usr/lib/lua/luci/controller/blockport.lua +++ /dev/null @@ -1,15 +0,0 @@ --- Licensed to the public under the Apache License 2.0. - -module("luci.controller.blockport", package.seeall) - -I18N = require "luci.i18n" -translate = I18N.translate - -function index() - local lock = luci.model.uci.cursor():get("custom", "menu", "full") - --if lock == "1" then - local page - page = entry({"admin", "adminmenu", "blockport"}, cbi("portblk"), _(translate("Port Blocking")), 11) - page.dependent = true - --end -end diff --git a/rooter/0optionalapps/ext-blockport/files/usr/lib/lua/luci/model/cbi/portblk.lua b/rooter/0optionalapps/ext-blockport/files/usr/lib/lua/luci/model/cbi/portblk.lua deleted file mode 100644 index 73cd1ea..0000000 --- a/rooter/0optionalapps/ext-blockport/files/usr/lib/lua/luci/model/cbi/portblk.lua +++ /dev/null @@ -1,21 +0,0 @@ -local utl = require "luci.util" - -local sys = require "luci.sys" -local zones = require "luci.sys.zoneinfo" -local fs = require "nixio.fs" -local conf = require "luci.config" - -m = Map("blockport", translate("Port Blocking"), translate("Block traffic using specific ports")) - -m.on_after_save = function(self) - luci.sys.call("/usr/lib/blockport/blockport.sh &") -end - -s = m:section(TypedSection, "port", translate("Block Port List")) -s.anonymous = true -s.addremove = false - -s:option(DynamicList, "block", translate("Ports")) - - -return m \ No newline at end of file diff --git a/rooter/0optionalapps/ext-domain/Makefile b/rooter/0optionalapps/ext-domain/Makefile deleted file mode 100644 index 103fa98..0000000 --- a/rooter/0optionalapps/ext-domain/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -#Owned by DairyMan@Whirlpool -# -#Copyright GNU act. -include $(TOPDIR)/rules.mk - -PKG_NAME:=ext-blockport -PKG_VERSION:=1.000 -PKG_RELEASE:=1 - -PKG_MAINTAINER:=Created by DM/makefile by Cobia@whirlpool -include $(INCLUDE_DIR)/package.mk - -define Package/ext-blockport - SECTION:=utils - CATEGORY:=ROOter - SUBMENU:=Optional Applications - TITLE:=Install Port Blocking - PKGARCH:=all -endef - -define Package/ext-blockport/description - Helper scripts to install Port Blocking -endef - - -define Build/Compile -endef - -define Package/ext-blockport/install - $(CP) ./files/* $(1)/ - - -endef - -$(eval $(call BuildPackage,ext-blockport)) diff --git a/rooter/0optionalapps/ext-domain/files/etc/config/blockport b/rooter/0optionalapps/ext-domain/files/etc/config/blockport deleted file mode 100644 index 8e69716..0000000 --- a/rooter/0optionalapps/ext-domain/files/etc/config/blockport +++ /dev/null @@ -1,4 +0,0 @@ - -config port 'port' - - diff --git a/rooter/0optionalapps/ext-domain/files/usr/lib/blockport/blockport.sh b/rooter/0optionalapps/ext-domain/files/usr/lib/blockport/blockport.sh deleted file mode 100644 index 6965bc0..0000000 --- a/rooter/0optionalapps/ext-domain/files/usr/lib/blockport/blockport.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh -. /lib/functions.sh - -config="firewall" - -do_block_remove() { - config_get name $1 name - if [ "$name" = "Block_src" ]; then - uci delete $config".""$1" - fi -} - -handle_port() { - echo $1 - uci add $config rule - uci set $config.@rule[-1].src='lan' - uci set $config.@rule[-1].family='ipv4' - uci set $config.@rule[-1].dest='wan' - uci set $config.@rule[-1].target='DROP' - uci set $config.@rule[-1].proto='tcp' - uci set $config.@rule[-1].src_port="$1" - uci set $config.@rule[-1].name='Block_src' -} - -do_port() { - config_list_foreach "$1" block handle_port -} - -sleep 8 -config_load $config -config_foreach do_block_remove rule - -config_load blockport -config_foreach do_port port -uci commit $config -/etc/init.d/firewall restart 2>/dev/null - diff --git a/rooter/0optionalapps/ext-domain/files/usr/lib/lua/luci/controller/blockport.lua b/rooter/0optionalapps/ext-domain/files/usr/lib/lua/luci/controller/blockport.lua deleted file mode 100644 index fca343d..0000000 --- a/rooter/0optionalapps/ext-domain/files/usr/lib/lua/luci/controller/blockport.lua +++ /dev/null @@ -1,12 +0,0 @@ --- Licensed to the public under the Apache License 2.0. - -module("luci.controller.blockport", package.seeall) - -function index() - local lock = luci.model.uci.cursor():get("custom", "menu", "full") - if lock == "1" then - local page - page = entry({"admin", "adminmenu", "blockport"}, cbi("portblk"), _("---Port Blocking"), 10) - page.dependent = true - end -end diff --git a/rooter/0optionalapps/ext-domain/files/usr/lib/lua/luci/model/cbi/portblk.lua b/rooter/0optionalapps/ext-domain/files/usr/lib/lua/luci/model/cbi/portblk.lua deleted file mode 100644 index 73cd1ea..0000000 --- a/rooter/0optionalapps/ext-domain/files/usr/lib/lua/luci/model/cbi/portblk.lua +++ /dev/null @@ -1,21 +0,0 @@ -local utl = require "luci.util" - -local sys = require "luci.sys" -local zones = require "luci.sys.zoneinfo" -local fs = require "nixio.fs" -local conf = require "luci.config" - -m = Map("blockport", translate("Port Blocking"), translate("Block traffic using specific ports")) - -m.on_after_save = function(self) - luci.sys.call("/usr/lib/blockport/blockport.sh &") -end - -s = m:section(TypedSection, "port", translate("Block Port List")) -s.anonymous = true -s.addremove = false - -s:option(DynamicList, "block", translate("Ports")) - - -return m \ No newline at end of file diff --git a/rooter/0optionalapps/ext-rspeedtest/Makefile b/rooter/0optionalapps/ext-rspeedtest/Makefile deleted file mode 100644 index 5dee477..0000000 --- a/rooter/0optionalapps/ext-rspeedtest/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -#Owned by DairyMan@Whirlpool -# -#Copyright GNU act. -include $(TOPDIR)/rules.mk - -PKG_NAME:=ext-rspeedtest -PKG_VERSION:=1.000 -PKG_RELEASE:=1 - -PKG_MAINTAINER:=Created by DM/makefile by Cobia@whirlpool -include $(INCLUDE_DIR)/package.mk - -define Package/ext-rspeedtest - SECTION:=utils - CATEGORY:=ROOter - DEPENDS:=+httping +curl +coreutils +coreutils-date +speedtestpp - SUBMENU:=Optional Applications - TITLE:=support for ROOter SpeedTest - PKGARCH:=all -endef - -define Package/ext-rspeedtest/description - Helper scripts to enable ROOter SpeedTest -endef - - -define Build/Compile -endef - -define Package/ext-rspeedtest/install - $(CP) ./files/* $(1)/ -endef - -$(eval $(call BuildPackage,ext-rspeedtest)) diff --git a/rooter/0optionalapps/ext-rspeedtest/files/usr/lib/lua/luci/controller/rspeedtest.lua b/rooter/0optionalapps/ext-rspeedtest/files/usr/lib/lua/luci/controller/rspeedtest.lua deleted file mode 100644 index 6ac5628..0000000 --- a/rooter/0optionalapps/ext-rspeedtest/files/usr/lib/lua/luci/controller/rspeedtest.lua +++ /dev/null @@ -1,79 +0,0 @@ -module("luci.controller.rspeedtest", package.seeall) - -I18N = require "luci.i18n" -translate = I18N.translate - -function index() - local page - page = entry({"admin", "speed", "rspeedtest"}, template("speedtest/rspeedtest"), translate("SpeedTest by Ookla"), 72) - page.dependent = true - - entry({"admin", "speed", "closeserver"}, call("action_closeserver")) - entry({"admin", "speed", "stoptest"}, call("action_stoptest")) - entry({"admin", "speed", "getspeed"}, call("action_getspeed")) - entry({"admin", "speed", "getspeeddata"}, call("action_getspeeddata")) -end - -function action_closeserver() - local rv = {} - - os.execute("/usr/lib/speedtest/info.sh") - result = "/tmp/sinfo" - file = io.open(result, "r") - if file ~= nil then - rv["status"] = file:read("*line") - if rv["status"] ~= "0" then - rv["ip"] = file:read("*line") - rv["isp"] = file:read("*line") - rv["city"] = file:read("*line") - rv["prov"] = file:read("*line") - end - file:close() - else - rv["status"] = "0" - end - - luci.http.prepare_content("application/json") - luci.http.write_json(rv) -end - -function action_stoptest() - os.execute("/usr/lib/speedtest/stop.sh") -end - -function action_getspeed() - local rv = {} - - os.execute("/usr/lib/speedtest/getspeed.sh ") - - luci.http.prepare_content("application/json") - luci.http.write_json(rv) -end - -function action_getspeeddata() - local rv = {} - - result = "/tmp/getspeed" - file = io.open(result, "r") - if file ~= nil then - rv["dlsize"] = file:read("*line") - rv["dlelapse"] = file:read("*line") - rv["ulsize"] = file:read("*line") - rv["ulelapse"] = file:read("*line") - file:close() - else - rv["dlsize"] = "0" - rv["ulsize"] = "0" - end - result = "/tmp/spworking" - file = io.open(result, "r") - if file ~= nil then - rv["working"] = file:read("*line") - file:close() - else - rv["working"] = "0" - end - - luci.http.prepare_content("application/json") - luci.http.write_json(rv) -end diff --git a/rooter/0optionalapps/ext-rspeedtest/files/usr/lib/lua/luci/view/speedtest/rspeedtest.htm b/rooter/0optionalapps/ext-rspeedtest/files/usr/lib/lua/luci/view/speedtest/rspeedtest.htm deleted file mode 100644 index a35eaa4..0000000 --- a/rooter/0optionalapps/ext-rspeedtest/files/usr/lib/lua/luci/view/speedtest/rspeedtest.htm +++ /dev/null @@ -1,259 +0,0 @@ -<%+header%> -<% - user_icon = resource .. "/img/user.png" - prov_icon = resource .. "/img/prov.png" - load_icon = resource .. "/icons/loading.gif" -%> - - - - -
                - -
                -

                <%:Speed Test by Ookla%>

                -
                <%:An Internet speed test that runs from the router%>
                - - - -
                - - - - - - -
                <%:***Finding Optimal Server***%>
                 
                - - - - - - - - - - -
                 
                 
                - - - - - - - - -
                 
                 
                - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                 
                - - - - - - - - - - - - - - - - - - -
                - -
                - -<%+footer%> \ No newline at end of file diff --git a/rooter/0optionalapps/ext-rspeedtest/files/usr/lib/speedtest/closest.lua b/rooter/0optionalapps/ext-rspeedtest/files/usr/lib/speedtest/closest.lua deleted file mode 100644 index 5544048..0000000 --- a/rooter/0optionalapps/ext-rspeedtest/files/usr/lib/speedtest/closest.lua +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/lua - -function trim(s) - return (s:gsub("^%s*(.-)%s*$", "%1")) -end - -ulat = arg[1] -ulon = arg[2] - -url = {} -slat = {} -slon = {} -city = {} -dist = {} -prov = {} - -radius = 6371 - -cnt = 0 -clos = 99999999.99 -index = 0 -file = io.open("/tmp/slist", "r") -if file ~= nil then - repeat - line = file:read("*line") - if line == nil then - break - end - cnt = cnt + 1 - s, e = line:find(" ") - if s ~= nil then - url[cnt] = trim(line:sub(0, s-1)) - cs, ce = line:find(" ", e+1) - slat[cnt] = trim(line:sub(e, cs-1)) - s, e = line:find(" ", ce+1) - slon[cnt] = trim(line:sub(ce, s-1)) - cs, ce = line:find("\"", e+1) - s, e = line:find("\"", ce+1) - city[cnt] = trim(line:sub(ce+1, s-1)) - prov[cnt] = trim(line:sub(e+1)) - - dlat = math.rad(slat[cnt] - ulat) - dlon = math.rad(slon[cnt] - ulon) - a = (math.sin(dlat / 2) * math.sin(dlat / 2) + math.cos(math.rad(ulat)) * math.cos(math.rad(slat[cnt])) * math.sin(dlon / 2) * math.sin(dlon / 2)) - c = 2 * math.atan(math.sqrt(a), math.sqrt(1 - a)) - dist[cnt] = radius * c - - if dist[cnt] < clos then - clos = dist[cnt] - index = cnt - end - end - until 1==0 - file:close() - tfile = io.open("/tmp/close", "w") - tfile:write("CURL=\"", url[index], "\"\n") - tfile:write("CITY=\"", city[index], "\"\n") - tfile:write("PROV=\"", prov[index], "\"") - tfile:close() -end - - diff --git a/rooter/0optionalapps/ext-rspeedtest/files/usr/lib/speedtest/getspeed.sh b/rooter/0optionalapps/ext-rspeedtest/files/usr/lib/speedtest/getspeed.sh deleted file mode 100644 index 7583f5b..0000000 --- a/rooter/0optionalapps/ext-rspeedtest/files/usr/lib/speedtest/getspeed.sh +++ /dev/null @@ -1,83 +0,0 @@ -#!/bin/sh - -log() { - logger -t "Getspeed " "$@" -} - -fixspeed() { - sed 's/\(PROVIDER=[[:blank:]]*\)\(.*\)/\1'\''\2'\''/' /tmp/speed > /tmp/tspeed -} - -echo "0" > /tmp/getspeed -echo "0" >> /tmp/getspeed -echo "0" >> /tmp/getspeed -echo "0" >> /tmp/getspeed -echo "1" > /tmp/spworking - -JITTER="" -LATENCY="" -DOWNLOAD_SPEED="" -UPLOAD_SPEED="" - -while IFS= read -r line -do - read -r line - read -r line - read -r line - read -r line - read -r line - break -done < /tmp/sinfo -url=${line:7:100} -url=$(echo $url" " | tr "/" ",") -url=$(echo "$url" | cut -d, -f1) -rm -f /tmp/speed -speedtest --test-server $url --output text > /tmp/speed & -while [ -z "$JITTER" ] -do - if [ -e /tmp/speed ]; then - fixspeed - if [ -e /tmp/tspeed ]; then - source /tmp/tspeed - fi - fi - sleep 1 -done -echo "$LATENCY" > /tmp/getspeed -echo "$JITTER" >> /tmp/getspeed -echo "0" >> /tmp/getspeed -echo "0" >> /tmp/getspeed -echo "2" > /tmp/spworking - -while [ -z "$DOWNLOAD_SPEED" ] -do - if [ -e /tmp/speed ]; then - fixspeed - if [ -e /tmp/tspeed ]; then - source /tmp/tspeed - fi - fi - sleep 1 -done -echo "$LATENCY" > /tmp/getspeed -echo "$JITTER" >> /tmp/getspeed -echo "$DOWNLOAD_SPEED" >> /tmp/getspeed -echo "0" >> /tmp/getspeed -echo "3" > /tmp/spworking - -while [ -z "$UPLOAD_SPEED" ] -do - if [ -e /tmp/speed ]; then - fixspeed - if [ -e /tmp/tspeed ]; then - source /tmp/tspeed - fi - fi - sleep 1 -done -echo "$LATENCY" > /tmp/getspeed -echo "$JITTER" >> /tmp/getspeed -echo "$DOWNLOAD_SPEED" >> /tmp/getspeed -echo "$UPLOAD_SPEED" >> /tmp/getspeed -echo "0" > /tmp/spworking - diff --git a/rooter/0optionalapps/ext-rspeedtest/files/usr/lib/speedtest/info.sh b/rooter/0optionalapps/ext-rspeedtest/files/usr/lib/speedtest/info.sh deleted file mode 100644 index 1232246..0000000 --- a/rooter/0optionalapps/ext-rspeedtest/files/usr/lib/speedtest/info.sh +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/sh - -killprocess() { - proc=$1 - PID=$(ps |grep "$proc" | grep -v grep |head -n 1 | awk '{print $1}') - if [ ! -z $PID ]; then - kill -9 $PID - fi -} - -killprocess "speedtest --test-server" -killprocess "/speedtest/closest.lua" -killprocess "/speedtest/getspeed.sh" -killprocess "/speedtest/servers.lua" - -rm -f /tmp/speed -rm -f /tmp/sinfo -rm -f /tmp/close -rm -f /tmp/getspeed -rm -f /tmp/jpg -rm -f /tmp/pinfo -rm -f /tmp/sinfo -rm -f /tmp/slist -echo "0" > /tmp/getspeed -echo "0" >> /tmp/getspeed -echo "0" >> /tmp/getspeed -echo "0" >> /tmp/getspeed -echo "0" >> /tmp/getspeed -echo "0" > /tmp/spworking -wget -q -O /tmp/client http://speedtest.net/speedtest-config.php -if [ $? = "0" ]; then - RAW=$(cat /tmp/client) - clid=$(echo $RAW" " | grep -o " " | tr -d '"' | tr " " "," | tr "/" "," | tr "=" ",") - ip=$(echo $clid | cut -d, -f3) - ulat=$(echo $clid | cut -d, -f5) - ulon=$(echo $clid | cut -d, -f7) - isp=$(echo $clid | cut -d, -f9) - rm -f /tmp/client - echo "1" > /tmp/sinfo - echo "$ip" >> /tmp/sinfo - echo "$isp" >> /tmp/sinfo - - wget -q -O /tmp/servers http://www.speedtest.net/speedtest-servers-static.php - if [ $? != "0" ]; then - wget -q -O /tmp/servers http://c.speedtest.net/speedtest-servers.php - if [ $? != "0" ]; then - echo "0" > /tmp/sinfo - exit 0 - fi - fi - rm -f /tmp/slist - while IFS= read -r line - do - read -r line - /usr/lib/speedtest/servers.lua "$line" - if [ -e /tmp/server ]; then - source /tmp/server - echo "$URL $LAT $LON "\""$NAME"\"" $SPONSOR" >> /tmp/slist - rm -f /tmp/server - fi - done < /tmp/servers - rm -f /tmp/servers - - /usr/lib/speedtest/closest.lua $ulat $ulon - source /tmp/close - echo "$CITY" >> /tmp/sinfo - echo "$PROV" >> /tmp/sinfo - echo "$CURL" >> /tmp/sinfo - rm -f /tmp/slist - rm -f /tmp/close -else - echo "0" > /tmp/sinfo - exit 0 -fi - diff --git a/rooter/0optionalapps/ext-rspeedtest/files/usr/lib/speedtest/ping.sh b/rooter/0optionalapps/ext-rspeedtest/files/usr/lib/speedtest/ping.sh deleted file mode 100644 index 7ec502c..0000000 --- a/rooter/0optionalapps/ext-rspeedtest/files/usr/lib/speedtest/ping.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh - -rm -f /tmp/pinfo - -echo "0" > /tmp/getspeed -echo "0" >> /tmp/getspeed -echo "0" >> /tmp/getspeed -echo "0" >> /tmp/getspeed -echo "1" > /tmp/spworking -while IFS= read -r line -do - read -r line - read -r line - read -r line - read -r line - read -r line - break -done < /tmp/sinfo - -hp=$(httping -c 3 $line) -pingg=$(echo $hp" " | grep -o "round-trip .\+ ms " | tr " " "," | tr "/" ",") -latency=$(echo $pingg | cut -d, -f7) - -echo "$latency" > /tmp/pinfo -echo "2" > /tmp/spworking - diff --git a/rooter/0optionalapps/ext-rspeedtest/files/usr/lib/speedtest/servers.lua b/rooter/0optionalapps/ext-rspeedtest/files/usr/lib/speedtest/servers.lua deleted file mode 100644 index abc3962..0000000 --- a/rooter/0optionalapps/ext-rspeedtest/files/usr/lib/speedtest/servers.lua +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/lua - -function trim(s) - return (s:gsub("^%s*(.-)%s*$", "%1")) -end - -line = arg[1] -if line == nil then - return -end - -s, e = line:find("url=\"") -if s ~= nil then - cs, ce = line:find("\"", e+1) - url = trim(line:sub(e+1, cs-1)) -else - return -end -s, e = line:find("lat=\"") -if s ~= nil then - cs, ce = line:find("\"", e+1) - lat = trim(line:sub(e+1, cs-1)) -end -s, e = line:find("lon=\"") -if s ~= nil then - cs, ce = line:find("\"", e+1) - lon = trim(line:sub(e+1, cs-1)) -end -s, e = line:find("name=\"") -if s ~= nil then - cs, ce = line:find("\"", e+1) - name = trim(line:sub(e+1, cs-1)) -end -s, e = line:find("sponsor=\"") -if s ~= nil then - cs, ce = line:find("\"", e+1) - sponsor = trim(line:sub(e+1, cs-1)) -end - -tfile = io.open("/tmp/server", "w") -tfile:write("URL=\"", url, "\"\n") -tfile:write("LAT=\"", lat, "\"\n") -tfile:write("LON=\"", lon, "\"\n") -tfile:write("NAME=\"", name, "\"\n") -tfile:write("SPONSOR=\"", sponsor, "\"") -tfile:close() \ No newline at end of file diff --git a/rooter/0optionalapps/ext-rspeedtest/files/usr/lib/speedtest/stop.sh b/rooter/0optionalapps/ext-rspeedtest/files/usr/lib/speedtest/stop.sh deleted file mode 100644 index c95dec0..0000000 --- a/rooter/0optionalapps/ext-rspeedtest/files/usr/lib/speedtest/stop.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh - -killprocess() { - proc=$1 - PID=$(pgrep -f "$proc") - if [ ! -z $PID ]; then - kill -9 $PID - fi -} - -killprocess "speedtest --test-server" -killprocess "/speedtest/closest.lua" -killprocess "/speedtest/getspeed.sh" -killprocess "/speedtest/servers.lua" - -flist="/tmp/speed /tmp/sinfo /tmp/close /tmp/getspeed /tmp/jpg /tmp/pinfo /tmp/sinfo /tmp/slist" - -for val in $flist; do - rm -f $val -done - -echo "0" > /tmp/getspeed -echo "0" >> /tmp/getspeed -echo "0" >> /tmp/getspeed -echo "0" >> /tmp/getspeed -echo "0" >> /tmp/getspeed -echo "0" > /tmp/spworking - diff --git a/rooter/0optionalapps/ext-rspeedtest/files/www/luci-static/resources/img/prov.png b/rooter/0optionalapps/ext-rspeedtest/files/www/luci-static/resources/img/prov.png deleted file mode 100644 index 715618c..0000000 Binary files a/rooter/0optionalapps/ext-rspeedtest/files/www/luci-static/resources/img/prov.png and /dev/null differ diff --git a/rooter/0optionalapps/ext-rspeedtest/files/www/luci-static/resources/img/user.png b/rooter/0optionalapps/ext-rspeedtest/files/www/luci-static/resources/img/user.png deleted file mode 100644 index a557423..0000000 Binary files a/rooter/0optionalapps/ext-rspeedtest/files/www/luci-static/resources/img/user.png and /dev/null differ diff --git a/rooter/0optionalapps/ext-speedtest/Makefile b/rooter/0optionalapps/ext-speedtest/Makefile deleted file mode 100644 index 68a6e47..0000000 --- a/rooter/0optionalapps/ext-speedtest/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -#Owned by DairyMan@Whirlpool -# -#Copyright GNU act. -include $(TOPDIR)/rules.mk - -PKG_NAME:=ext-speedtest -PKG_VERSION:=1.000 -PKG_RELEASE:=1 - -PKG_MAINTAINER:=Created by DM/makefile by Cobia@whirlpool -include $(INCLUDE_DIR)/package.mk - -define Package/ext-speedtest - SECTION:=utils - CATEGORY:=ROOter - DEPENDS:=+ext-rspeedtest - SUBMENU:=Optional Applications - TITLE:=support for OpenSpeedTest - PKGARCH:=all -endef - -define Package/ext-speedtest/description - Helper scripts to enable OpenSpeedTest -endef - - -define Build/Compile -endef - -define Package/ext-speedtest/install - $(CP) ./files/* $(1)/ -endef - -$(eval $(call BuildPackage,ext-speedtest)) diff --git a/rooter/0optionalapps/ext-speedtest/files/usr/lib/lua/luci/controller/speedtest.lua b/rooter/0optionalapps/ext-speedtest/files/usr/lib/lua/luci/controller/speedtest.lua deleted file mode 100644 index 0a70363..0000000 --- a/rooter/0optionalapps/ext-speedtest/files/usr/lib/lua/luci/controller/speedtest.lua +++ /dev/null @@ -1,7 +0,0 @@ -module("luci.controller.speedtest", package.seeall) -function index() - local page - entry({"admin", "speed"}, firstchild(), "Speed Test", 81).dependent=false - page = entry({"admin", "speed", "speedtest"}, template("speedtest/speedtest"), "OpenSpeedTest", 71) - page.dependent = true -end diff --git a/rooter/0optionalapps/ext-speedtest/files/usr/lib/lua/luci/view/speedtest/speedtest.htm b/rooter/0optionalapps/ext-speedtest/files/usr/lib/lua/luci/view/speedtest/speedtest.htm deleted file mode 100644 index 53317d1..0000000 --- a/rooter/0optionalapps/ext-speedtest/files/usr/lib/lua/luci/view/speedtest/speedtest.htm +++ /dev/null @@ -1,45 +0,0 @@ -<%+header%> - - - -
                -
                -

                Browser Speed Test

                -
                A Speed Test using OpenSpeedTest that runs in the browser
                - - - - - - - - - -
                - -
                - - - - - -
                - - - -
                -
                -<%+footer%> diff --git a/rooter/0optionalapps/ext-speedtest/files/www/luci-static/speed/css/iconmoon_splash.css b/rooter/0optionalapps/ext-speedtest/files/www/luci-static/speed/css/iconmoon_splash.css deleted file mode 100644 index 5254b92..0000000 --- a/rooter/0optionalapps/ext-speedtest/files/www/luci-static/speed/css/iconmoon_splash.css +++ /dev/null @@ -1,69 +0,0 @@ -@font-face { - font-family: 'icomoon_splash'; - src: url('../fonts/icomoon_splash.eot?vja16g'); - src: url('../fonts/icomoon_splash.eot?vja16g#iefix') format('embedded-opentype'), - url('../fonts/icomoon_splash.ttf?vja16g') format('truetype'), - url('../fonts/icomoon_splash.woff?vja16g') format('woff'), - url('../fonts/icomoon_splash.svg?vja16g#icomoon_splash') format('svg'); - font-weight: normal; - font-style: normal; -} - -[class^="icon-"], [class*=" icon-"] { - /* use !important to prevent issues with browser extensions that change fonts */ - font-family: 'icomoon_splash' !important; - speak: none; - font-style: normal; - font-weight: normal; - font-variant: normal; - text-transform: none; - line-height: 1; - - /* Better Font Rendering =========== */ - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - - -.icon-power-off:before { - content: "\f011"; -} -.icon-signal:before { - content: "\f012"; -} -.icon-cog:before { - content: "\f013"; -} -.icon-gear:before { - content: "\f013"; -} -.icon-home:before { - content: "\f015"; -} -.icon-exclamation-triangle:before { - content: "\f071"; -} -.icon-warning:before { - content: "\f071"; -} -.icon-comments:before { - content: "\f086"; -} -.icon-hdd-o:before { - content: "\f0a0"; -} -.icon-plug:before { - content: "\f1e6"; -} -.icon-wifi:before { - content: "\f1eb"; -} -.icon-connection:before { - content: "\e91b"; -} -.icon-podcast:before { - content: "\e91c"; -} -.icon-earth:before { - content: "\e9ca"; -} diff --git a/rooter/0optionalapps/ext-speedtest/files/www/luci-static/speed/css/splash.css b/rooter/0optionalapps/ext-speedtest/files/www/luci-static/speed/css/splash.css deleted file mode 100644 index 85af002..0000000 --- a/rooter/0optionalapps/ext-speedtest/files/www/luci-static/speed/css/splash.css +++ /dev/null @@ -1,341 +0,0 @@ -/* @override http://src.dev.lo.lo/ROOter/www/luci-static/rooter/css/splash.css */ - -/* - CSS for ROOter splash pages - Copyright Francois Dechery - https://github.com/soif -*/ - -/* @group Splash Pages ---------------------------------------------------*/ - -.rooterSplash{ - padding: 0; - background: #F0F0F0; -} -.rooterPageHead{ - background: #55F; - padding: 10px 5px; - background: rgb(140,140,255); - background: -moz-linear-gradient(top, rgba(140,140,255,1) 0%, rgba(85,85,255,1) 100%); - background: -webkit-linear-gradient(top, rgba(140,140,255,1) 0%,rgba(85,85,255,1) 100%); - background: linear-gradient(to bottom, rgba(140,140,255,1) 0%,rgba(85,85,255,1) 100%); - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#8c8cff', endColorstr='#5555ff',GradientType=0 ); - border-bottom: 1px solid rgba(0,0,0,0.7); - -} -.rooterPageContent{ - border-top: 1px solid rgba(255,255,255,0.8); - border-bottom: 1px solid rgba(0,0,0, 0.1); - padding: 25px 10px; - max-width: 1200px; - margin: auto; -} - -.rooterPageContentBut{ - border-top: 1px solid rgba(255,255,255,0.8); - border-bottom: 1px solid rgba(0,0,0, 0.1); - padding: 25px 10px; - max-width: 600px; - margin: auto; -} - -.rooterHeadTitle{ - color: #fff; - text-align: center; - font-family: Georgia, "Times New Roman", Times, serif; - font-size: 32px; - line-height: 120%; - text-shadow: -1px -1px 2px rgba(0,0,0,0.5); -} -.rooterPageFoot{ - border-top: 1px solid rgba(255,255,255,0.8); - margin-top: 20px; - padding: 10px 10px; - max-width: 950px; - margin: auto; - font-size: 16px; -} -.rooterFootMenu{ - float: left; - margin-bottom: 10px; -} -.rooterFootMenu A{ - text-decoration: none; -} -.rooterFootMenu A:hover{ - color: #000; -} -.rooterFootMenu UL{ - padding: 0; - margin: 0; - overflow: hidden; - display: inline-block; -} -.rooterFootMenu LI{ - float: left; - padding: 0; - margin: 0; - list-style: none; -} -.rooterFootMenu LI A{ - padding: 0 10px; - color: #555; -} -.rooterFootMenu LI:first-child A{ - padding-left: 0; -} -.rooterFootCredits{ - float: right; - padding: 0; - margin: 0; - color: #999; - text-align: right; -} -.rooterFootCredits A{ - color: #777; -} -/* @end */ - - - - -/* @group Page: Home ---------------------------------------------------*/ - - -/* @group Logo -++++++++++++++++++ */ -.rooterHeadBox{ - font-size: 50px; - font-family: Georgia, "Times New Roman", Times, serif; - color: #fff; - line-height: 100%; - overflow: hidden; - width: 700px; - margin: auto; - padding-top: 10px; - opacity: 0; -} -.rooterLogo{ - background: url("../img/kangaroo_800.png") no-repeat; - background-size: 100%; - float: left; - height: 110px; - width: 250px; - opacity: 0.4; -} -.rooterTagline{ - margin-left: 100px; - padding-left: 10px; - text-shadow: 2px 2px 3px rgba(0,0,0,0.3); -} - -/* @end */ - -@media only screen and (max-width: 600px) { - .rooterHeadBox{ - text-align: center; - width: auto; - } - .rooterLogo{ - display: inline-block; - float: none; - } - .rooterTagline { - display: none; - } - .rooterFootCredits, - .rooterFootMenu{ - float: none; - text-align: center; - } -} - -#rooterItems{ - clear: both; - max-width: 600px ; - margin: auto; -} - -#rooterItemss{ - clear: both; - max-width: 350px ; - margin: auto; -} -.rooterItem{ - overflow: hidden; - border: 5px solid #00; - border-color: #00 #DDD #DDD #00; - padding: 20px 15px; - margin-bottom: 20px; - border-radius: 8px; - background-color: #AFAFAF; -} -.rooterItem:hover{ - background-color: #CFCFCF; - border-color: #AAA; -} -.rooterItemTitle{ - float: left; - font-size: 18px; - font-weight: bold; - padding-right: 10px; - color: #000; - line-height: 2em; -} -.rooterItemTitle .icon{ - color: #55F; - margin-right: 8px; - font-size: 2em; - vertical-align: middle; -} - -.rooterItemsp{ - overflow: hidden; - border: 5px solid #00; - border-color: #00 #DDD #DDD #00; - padding: 5px 15px; - margin-bottom: 5px; - border-radius: 8px; - background-color: #AFAFAF; -} -.rooterItemsp:hover{ - background-color: #CFCFCF; - border-color: #AAA; -} - -#rooterItems A{ - text-decoration: none; -} -.rooterItemDesc{ - font-size: 18px; - color: #777; - margin-left: 220px; - margin-top: 0.7em; -} -/* @end */ - - - -/* @group Page: Status ---------------------------------------------------*/ - -.modemStatusBlock{ - margin-bottom: 30px; -} -#rooterSplashStatus h3{ - clear:both; - font-size: 18px; - color: #55F; -} -#rooterSplashStatus h3 .icon{ - margin-right: 3px; -} -#rooterSplashStatus h3 .msCell{ - color: #666; -} -.modemStatusRow{ - clear:both; - padding-bottom: 20px; - overflow: hidden; -} -.modemStatusRow .msTitle{ - border-radius: 2px 2px 0 0; - padding: 5px 5px ; - background: #484848; - color: #fff; - background: rgb(99,99,99); - background: -moz-linear-gradient(top, rgba(99,99,99,1) 0%, rgba(72,72,72,1) 100%); - background: -webkit-linear-gradient(top, rgba(99,99,99,1) 0%,rgba(72,72,72,1) 100%); - background: linear-gradient(to bottom, rgba(99,99,99,1) 0%,rgba(72,72,72,1) 100%); - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#636363', endColorstr='#484848',GradientType=0 ); -} -.modemStatusRow .msCell{ - border-radius: 10px; - display: inline-block; - margin-top: 10px; - float:left; - border: 1px solid #ccc; - padding-bottom: 5px; - background: #fff; - -} -.modemStatusRow1 .msCell{ - width: 176px; - margin: 10px 5px 0 5px; - text-align: center; -} -.modemStatusRow1 SPAN B{ - font-weight: bold; - font-size: 35px; - line-height: 110%; - text-shadow: 1px 1px 1px rgba(0,0,0,0.4); -} -.modemStatusRow1 .msDesc{ - color: #000; - font-size: 12px; -} -.modemStatusRow2 .msCell{ - margin: 10px 5px; - text-align: center; -} -.modemStatusRow2 SPAN{ - display: inline-block; - padding: 5px 5px ; - font-size: 14px; -} -#counter_div{ - color: #000; - font-weight: normal; - font-size: 14px; -} -#counter_val{ - color: #F00; - font-size: 32px; - font-weight: bold; - text-shadow: 1px 1px 1px rgba(0,0,0,0.1); -} -#msCell_per{} -#msCell_csq{} -#msCell_rssi{} -#msCell_rscp{} -#msCell_ecio{} - -#rooterSplashStatus .level_0{ - color: #0F0; // green -} -#rooterSplashStatus .level_1{ - color: #0CB; // green blue -} -#rooterSplashStatus .level_2{ - color: #00F; // blue -} -#rooterSplashStatus .level_3{ - color: #F0F; // violet -} -#rooterSplashStatus .level_4{ - color: #F80; // orange -} -#rooterSplashStatus .level_5{ - color: #F00; // red -} -#rooterSplashStatus .level_6{ - color: #FF0; // yellow -} - -/* @end */ - - -/* Easy Color changer ------------- */ - -.rooterPageHead{ - /*background: #55F;*/ -} -.rooterItemTitle .icon, -#rooterSplashStatus h3{ - color: #55F; -} - - - diff --git a/rooter/0optionalapps/ext-speedtest/files/www/luci-static/speed/fonts/icomoon_splash.eot b/rooter/0optionalapps/ext-speedtest/files/www/luci-static/speed/fonts/icomoon_splash.eot deleted file mode 100644 index 29cd4d1..0000000 Binary files a/rooter/0optionalapps/ext-speedtest/files/www/luci-static/speed/fonts/icomoon_splash.eot and /dev/null differ diff --git a/rooter/0optionalapps/ext-speedtest/files/www/luci-static/speed/fonts/icomoon_splash.svg b/rooter/0optionalapps/ext-speedtest/files/www/luci-static/speed/fonts/icomoon_splash.svg deleted file mode 100644 index dc2127b..0000000 --- a/rooter/0optionalapps/ext-speedtest/files/www/luci-static/speed/fonts/icomoon_splash.svg +++ /dev/null @@ -1,22 +0,0 @@ - - - -Generated by IcoMoon - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/rooter/0optionalapps/ext-speedtest/files/www/luci-static/speed/fonts/icomoon_splash.ttf b/rooter/0optionalapps/ext-speedtest/files/www/luci-static/speed/fonts/icomoon_splash.ttf deleted file mode 100644 index 4e27645..0000000 Binary files a/rooter/0optionalapps/ext-speedtest/files/www/luci-static/speed/fonts/icomoon_splash.ttf and /dev/null differ diff --git a/rooter/0optionalapps/ext-speedtest/files/www/luci-static/speed/fonts/icomoon_splash.woff b/rooter/0optionalapps/ext-speedtest/files/www/luci-static/speed/fonts/icomoon_splash.woff deleted file mode 100644 index 63f5413..0000000 Binary files a/rooter/0optionalapps/ext-speedtest/files/www/luci-static/speed/fonts/icomoon_splash.woff and /dev/null differ diff --git a/rooter/0optionalapps/ext-speedtest/files/www/luci-static/speed/img/favicon.gif b/rooter/0optionalapps/ext-speedtest/files/www/luci-static/speed/img/favicon.gif deleted file mode 100644 index bfbe292..0000000 Binary files a/rooter/0optionalapps/ext-speedtest/files/www/luci-static/speed/img/favicon.gif and /dev/null differ diff --git a/rooter/0optionalapps/ext-speedtest/files/www/luci-static/speed/img/kangaroo_800.png b/rooter/0optionalapps/ext-speedtest/files/www/luci-static/speed/img/kangaroo_800.png deleted file mode 100644 index 478fa6d..0000000 Binary files a/rooter/0optionalapps/ext-speedtest/files/www/luci-static/speed/img/kangaroo_800.png and /dev/null differ diff --git a/rooter/0optionalapps/ext-texting/Makefile b/rooter/0optionalapps/ext-texting/Makefile deleted file mode 100644 index 313d024..0000000 --- a/rooter/0optionalapps/ext-texting/Makefile +++ /dev/null @@ -1,33 +0,0 @@ -#Owned by DairyMan@Whirlpool -# -#Copyright GNU act. -include $(TOPDIR)/rules.mk - -PKG_NAME:=ext-texting -PKG_VERSION:=1.000 -PKG_RELEASE:=1 - -PKG_MAINTAINER:=Created by DM/makefile by Cobia@whirlpool -include $(INCLUDE_DIR)/package.mk - -define Package/ext-texting - SECTION:=utils - CATEGORY:=ROOter - SUBMENU:=Optional Applications - TITLE:=support for Random Texting - PKGARCH:=all -endef - -define Package/ext-texting/description - Helper scripts to enable Random Texting -endef - - -define Build/Compile -endef - -define Package/ext-texting/install - $(CP) ./files/* $(1)/ -endef - -$(eval $(call BuildPackage,ext-texting)) diff --git a/rooter/0optionalapps/ext-texting/files/etc/config/texting b/rooter/0optionalapps/ext-texting/files/etc/config/texting deleted file mode 100644 index f3dd29d..0000000 --- a/rooter/0optionalapps/ext-texting/files/etc/config/texting +++ /dev/null @@ -1,32 +0,0 @@ - -config setting 'setting' - option start '32' - option end '68' - option times '20' - option enabled '0' - -config texting 'texting' - option startmin '0' - option endmin '0' - option starthour '8' - option endhour '17' - option numbers '15' - option messages '10' - option interval '1620' - -config numbers 'numbers' - list number '1112223333' - - -config messages 'messages' - list message 'Hey what’s going on?' - list message 'When are week meeting up?' - list message 'Who is attending the party?' - list message 'Not sure, what about you?' - list message 'Hey can you take the dogs out? I won’t be home for a while ' - list message 'Are you going to the party this weekend?' - list message 'Send me a text whenever your available.' - list message 'Your mom told me to get a hold of you' - list message 'Let’s leave early on the morning.' - list message 'Cool that sounds awesome. Let’s chat tmrw. ' - diff --git a/rooter/0optionalapps/ext-texting/files/etc/init.d/texting b/rooter/0optionalapps/ext-texting/files/etc/init.d/texting deleted file mode 100644 index 8b8687d..0000000 --- a/rooter/0optionalapps/ext-texting/files/etc/init.d/texting +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh /etc/rc.common - -START=88 - -log() { - logger -t "TEXTING" "$@" -} - -start() -{ - /usr/lib/fullmenu/text-setup.sh -} diff --git a/rooter/0optionalapps/ext-texting/files/usr/lib/fullmenu/chksms.sh b/rooter/0optionalapps/ext-texting/files/usr/lib/fullmenu/chksms.sh deleted file mode 100644 index 20b3376..0000000 --- a/rooter/0optionalapps/ext-texting/files/usr/lib/fullmenu/chksms.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter -ROOTER_LINK="/tmp/links" - -CURRMODEM=1 - -rm -f /tmp/texting -CPORT=$(uci -q get modem.modem$CURRMODEM.commport) -if [ -z $CPORT ]; then - return -fi -OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "smschk.gcom" "$CURRMODEM") -ERROR="ERROR" -if `echo ${OX} | grep "${ERROR}" 1>/dev/null 2>&1` -then - return -fi -echo "0" > /tmp/texting -uci set modem.general.smsnum='1' -uci commit modem \ No newline at end of file diff --git a/rooter/0optionalapps/ext-texting/files/usr/lib/fullmenu/dotext.sh b/rooter/0optionalapps/ext-texting/files/usr/lib/fullmenu/dotext.sh deleted file mode 100644 index 5767c1f..0000000 --- a/rooter/0optionalapps/ext-texting/files/usr/lib/fullmenu/dotext.sh +++ /dev/null @@ -1,123 +0,0 @@ -#!/bin/sh -. /lib/functions.sh - -log() { - logger -t "TEXTING" "$@" -} - -handle_numbers() { - let "NUMBERS = $NUMBERS + 1" - if [ $NUMBERS -eq $nindex ]; then - numch=$1 - fi -} - -do_numbers() { - local config=$1 - config_list_foreach "$config" number handle_numbers -} - -handle_messages() { - let "NUMBERS = $NUMBERS + 1" - if [ $NUMBERS -eq $nindex ]; then - numch=$1 - fi -} - -do_messages() { - local config=$1 - config_list_foreach "$config" message handle_messages -} - -sendmsg() { - nnum=$(uci -q get texting.texting.numbers) - mnum=$(uci -q get texting.texting.messages) - delay=$(uci -q get texting.texting.interval) - NUMBERS=0 - RANDOM=$(date +%s%N | cut -b10-19) - RAN=$RANDOM - RAN1=${RAN:0:1} - if [ $RAN1 = "0" ]; then - RAN="1"$RAN - rlen=${#RAN} - if [ $rlen -gt 9 ]; then - RAN=${RAN:0:8} - fi - fi - nindex=$(( $RAN % $nnum + 1 )) - config_load texting - config_foreach do_numbers numbers - Phone=$numch - NUMBERS=0 - RANDOM=$(date +%s%N | cut -b10-19) - RAN=$RANDOM - RAN1=${RAN:0:1} - if [ $RAN1 = "0" ]; then - RAN="1"$RAN - rlen=${#RAN} - if [ $rlen -gt 9 ]; then - RAN=${RAN:0:8} - fi - fi - nindex=$(( $RAN % $mnum + 1 )) - config_foreach do_messages messages - Message=$numch - /usr/lib/fullmenu/chksms.sh - if [ -e /tmp/texting ]; then - /usr/lib/sms/smsout.sh "$Phone" "$Message" - fi -} - -checktime() { - shour=$(uci -q get texting.texting.starthour) - smin=$(uci -q get texting.texting.startmin) - ehour=$(uci -q get texting.texting.endhour) - emin=$(uci -q get texting.texting.endmin) - chour=$(date +%H) - cmin=$(date +%M) - if [ $shour -gt $chour ]; then - flag="0" - else - if [ $shour -eq $chour ]; then - if [ $smin -le $cmin ]; then - flag="1" - else - flag="0" - fi - else - flag="1" - fi - fi - - if [ $flag = "1" ]; then - if [ $ehour -lt $chour ]; then - flag="0" - else - if [ $ehour -eq $chour ]; then - if [ $emin -lt $cmin ]; then - flag="0" - else - flag="1" - fi - else - flag="1" - fi - fi - fi - - echo $flag -} - -while true -do - running=$(checktime) - if [ $running = "1" ]; then - EN=$(uci -q get texting.setting.enabled) - if [ $EN = "1" ]; then - sendmsg - sleep $delay - fi - else - sleep 900 - fi -done \ No newline at end of file diff --git a/rooter/0optionalapps/ext-texting/files/usr/lib/fullmenu/text-setup.sh b/rooter/0optionalapps/ext-texting/files/usr/lib/fullmenu/text-setup.sh deleted file mode 100644 index 5d57226..0000000 --- a/rooter/0optionalapps/ext-texting/files/usr/lib/fullmenu/text-setup.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/sh -. /lib/functions.sh - -log() { - logger -t "TEXTING" "$@" -} - -sleep 3 - -handle_numbers() { - let "NUMBERS = $NUMBERS + 1" -} - -do_numbers() { - local config=$1 - config_list_foreach "$config" number handle_numbers -} - -handle_messages() { - let "NUMBERS = $NUMBERS + 1" -} - -do_messages() { - local config=$1 - config_list_foreach "$config" message handle_numbers -} - -SHOUR=$(uci -q get texting.setting.start) -HOUR=`expr $SHOUR / 4` -let "TH = $HOUR * 4" -let "TMP1 = $SHOUR - $TH" -let "MIN = $TMP1 * 15" -uci set texting.texting.starthour=$HOUR -uci set texting.texting.startmin=$MIN -EHOUR=$(uci -q get texting.setting.end) -HOUR=`expr $EHOUR / 4` -let "TH = $HOUR * 4" -let "TMP1 = $EHOUR - $TH" -let "MIN = $TMP1 * 15" -uci set texting.texting.endhour=$HOUR -uci set texting.texting.endmin=$MIN - -NUMBERS=0 -config_load texting -config_foreach do_numbers numbers -uci set texting.texting.numbers=$NUMBERS -NUMBERS=0 -config_foreach do_messages messages -uci set texting.texting.messages=$NUMBERS - -TIMES=$(uci -q get texting.setting.times) -let "TH = $EHOUR - $SHOUR" -let "TMIN = $TH * 15" -let "INTERVAL = $TMIN / $TIMES" -let "INTERVAL = $INTERVAL * 60" -uci set texting.texting.interval=$INTERVAL -uci commit texting - -result=`ps | grep -i "dotext.sh" | grep -v "grep" | wc -l` -if [ $result -lt 1 ]; then - /usr/lib/fullmenu/dotext.sh & -fi - diff --git a/rooter/0optionalapps/ext-texting/files/usr/lib/lua/luci/controller/texting.lua b/rooter/0optionalapps/ext-texting/files/usr/lib/lua/luci/controller/texting.lua deleted file mode 100644 index c0c5585..0000000 --- a/rooter/0optionalapps/ext-texting/files/usr/lib/lua/luci/controller/texting.lua +++ /dev/null @@ -1,24 +0,0 @@ -module("luci.controller.texting", package.seeall) -function index() - local lock = luci.model.uci.cursor():get("custom", "menu", "full") - if lock == "1" then - entry({"admin", "adminmenu", "texting"}, cbi("fullmenu/texting"), "---Random Texting", 8) - end - - entry({"admin", "services", "chksms"}, call("action_chksms")) -end - -function action_chksms() - local rv = {} - os.execute("/usr/lib/fullmenu/chksms.sh") - file = io.open("/tmp/texting", "r") - if file ~= nil then - rv["sms"] = "1" - file:close() - else - rv["sms"] = "0" - end - - luci.http.prepare_content("application/json") - luci.http.write_json(rv) -end \ No newline at end of file diff --git a/rooter/0optionalapps/ext-texting/files/usr/lib/lua/luci/model/cbi/fullmenu/texting.lua b/rooter/0optionalapps/ext-texting/files/usr/lib/lua/luci/model/cbi/fullmenu/texting.lua deleted file mode 100644 index d689c0b..0000000 --- a/rooter/0optionalapps/ext-texting/files/usr/lib/lua/luci/model/cbi/fullmenu/texting.lua +++ /dev/null @@ -1,254 +0,0 @@ -local utl = require "luci.util" - -m = Map("texting", translate("Random Texting"), translate("Send random message to number at random times")) - -m.on_after_save = function(self) - luci.sys.call("/usr/lib/fullmenu/text-setup.sh &") -end - -s = m:section(TypedSection, "setting", "Global Settings") -s.anonymous = true -s.addremove = false - -s:option(Flag, "enabled", translate("Enabled : ")) - -sdhour = s:option(ListValue, "start", translate("Starting Time :")) -sdhour.rmempty = true -sdhour:value("0", "12:00 AM") -sdhour:value("1", "12:15 AM") -sdhour:value("2", "12:30 AM") -sdhour:value("3", "12:45 AM") -sdhour:value("4", "01:00 AM") -sdhour:value("5", "01:15 AM") -sdhour:value("6", "01:30 AM") -sdhour:value("7", "01:45 AM") -sdhour:value("8", "02:00 AM") -sdhour:value("9", "02:15 AM") -sdhour:value("10", "02:30 AM") -sdhour:value("11", "02:45 AM") -sdhour:value("12", "03:00 AM") -sdhour:value("13", "03:15 AM") -sdhour:value("14", "03:30 AM") -sdhour:value("15", "03:45 AM") -sdhour:value("16", "04:00 AM") -sdhour:value("17", "04:15 AM") -sdhour:value("18", "04:30 AM") -sdhour:value("19", "04:45 AM") -sdhour:value("20", "05:00 AM") -sdhour:value("21", "05:15 AM") -sdhour:value("22", "05:30 AM") -sdhour:value("23", "05:45 AM") -sdhour:value("24", "06:00 AM") -sdhour:value("25", "06:15 AM") -sdhour:value("26", "06:30 AM") -sdhour:value("27", "06:45 AM") -sdhour:value("28", "07:00 AM") -sdhour:value("29", "07:15 AM") -sdhour:value("30", "07:30 AM") -sdhour:value("31", "07:45 AM") -sdhour:value("32", "08:00 AM") -sdhour:value("33", "08:15 AM") -sdhour:value("34", "08:30 AM") -sdhour:value("35", "08:45 AM") -sdhour:value("36", "09:00 AM") -sdhour:value("37", "09:15 AM") -sdhour:value("38", "09:30 AM") -sdhour:value("39", "09:45 AM") -sdhour:value("40", "10:00 AM") -sdhour:value("41", "10:15 AM") -sdhour:value("42", "10:30 AM") -sdhour:value("43", "10:45 AM") -sdhour:value("44", "11:00 AM") -sdhour:value("45", "11:15 AM") -sdhour:value("46", "11:30 AM") -sdhour:value("47", "11:45 AM") -sdhour:value("48", "12:00 PM") -sdhour:value("49", "12:15 PM") -sdhour:value("50", "12:30 PM") -sdhour:value("51", "12:45 PM") -sdhour:value("52", "01:00 PM") -sdhour:value("53", "01:15 PM") -sdhour:value("54", "01:30 PM") -sdhour:value("55", "01:45 PM") -sdhour:value("56", "02:00 PM") -sdhour:value("57", "02:15 PM") -sdhour:value("58", "02:30 PM") -sdhour:value("59", "02:45 PM") -sdhour:value("60", "03:00 PM") -sdhour:value("61", "03:15 PM") -sdhour:value("62", "03:30 PM") -sdhour:value("63", "03:45 PM") -sdhour:value("64", "04:00 PM") -sdhour:value("65", "04:15 PM") -sdhour:value("66", "04:30 PM") -sdhour:value("67", "04:45 PM") -sdhour:value("68", "05:00 PM") -sdhour:value("69", "05:15 PM") -sdhour:value("70", "05:30 PM") -sdhour:value("71", "05:45 PM") -sdhour:value("72", "06:00 PM") -sdhour:value("73", "06:15 PM") -sdhour:value("74", "06:30 PM") -sdhour:value("75", "06:45 PM") -sdhour:value("76", "07:00 PM") -sdhour:value("77", "07:15 PM") -sdhour:value("78", "07:30 PM") -sdhour:value("79", "07:45 PM") -sdhour:value("80", "08:00 PM") -sdhour:value("81", "08:15 PM") -sdhour:value("82", "08:30 PM") -sdhour:value("83", "08:45 PM") -sdhour:value("84", "09:00 PM") -sdhour:value("85", "09:15 PM") -sdhour:value("86", "09:30 PM") -sdhour:value("87", "09:45 PM") -sdhour:value("88", "10:00 PM") -sdhour:value("89", "10:15 PM") -sdhour:value("90", "10:30 PM") -sdhour:value("91", "10:45 PM") -sdhour:value("92", "11:00 PM") -sdhour:value("93", "11:15 PM") -sdhour:value("94", "11:30 PM") -sdhour:value("95", "11:45 PM") -sdhour.default = "32" - -sdhour = s:option(ListValue, "end", translate("Ending Time :")) -sdhour.rmempty = true -sdhour:value("0", "12:00 AM") -sdhour:value("1", "12:15 AM") -sdhour:value("2", "12:30 AM") -sdhour:value("3", "12:45 AM") -sdhour:value("4", "01:00 AM") -sdhour:value("5", "01:15 AM") -sdhour:value("6", "01:30 AM") -sdhour:value("7", "01:45 AM") -sdhour:value("8", "02:00 AM") -sdhour:value("9", "02:15 AM") -sdhour:value("10", "02:30 AM") -sdhour:value("11", "02:45 AM") -sdhour:value("12", "03:00 AM") -sdhour:value("13", "03:15 AM") -sdhour:value("14", "03:30 AM") -sdhour:value("15", "03:45 AM") -sdhour:value("16", "04:00 AM") -sdhour:value("17", "04:15 AM") -sdhour:value("18", "04:30 AM") -sdhour:value("19", "04:45 AM") -sdhour:value("20", "05:00 AM") -sdhour:value("21", "05:15 AM") -sdhour:value("22", "05:30 AM") -sdhour:value("23", "05:45 AM") -sdhour:value("24", "06:00 AM") -sdhour:value("25", "06:15 AM") -sdhour:value("26", "06:30 AM") -sdhour:value("27", "06:45 AM") -sdhour:value("28", "07:00 AM") -sdhour:value("29", "07:15 AM") -sdhour:value("30", "07:30 AM") -sdhour:value("31", "07:45 AM") -sdhour:value("32", "08:00 AM") -sdhour:value("33", "08:15 AM") -sdhour:value("34", "08:30 AM") -sdhour:value("35", "08:45 AM") -sdhour:value("36", "09:00 AM") -sdhour:value("37", "09:15 AM") -sdhour:value("38", "09:30 AM") -sdhour:value("39", "09:45 AM") -sdhour:value("40", "10:00 AM") -sdhour:value("41", "10:15 AM") -sdhour:value("42", "10:30 AM") -sdhour:value("43", "10:45 AM") -sdhour:value("44", "11:00 AM") -sdhour:value("45", "11:15 AM") -sdhour:value("46", "11:30 AM") -sdhour:value("47", "11:45 AM") -sdhour:value("48", "12:00 PM") -sdhour:value("49", "12:15 PM") -sdhour:value("50", "12:30 PM") -sdhour:value("51", "12:45 PM") -sdhour:value("52", "01:00 PM") -sdhour:value("53", "01:15 PM") -sdhour:value("54", "01:30 PM") -sdhour:value("55", "01:45 PM") -sdhour:value("56", "02:00 PM") -sdhour:value("57", "02:15 PM") -sdhour:value("58", "02:30 PM") -sdhour:value("59", "02:45 PM") -sdhour:value("60", "03:00 PM") -sdhour:value("61", "03:15 PM") -sdhour:value("62", "03:30 PM") -sdhour:value("63", "03:45 PM") -sdhour:value("64", "04:00 PM") -sdhour:value("65", "04:15 PM") -sdhour:value("66", "04:30 PM") -sdhour:value("67", "04:45 PM") -sdhour:value("68", "05:00 PM") -sdhour:value("69", "05:15 PM") -sdhour:value("70", "05:30 PM") -sdhour:value("71", "05:45 PM") -sdhour:value("72", "06:00 PM") -sdhour:value("73", "06:15 PM") -sdhour:value("74", "06:30 PM") -sdhour:value("75", "06:45 PM") -sdhour:value("76", "07:00 PM") -sdhour:value("77", "07:15 PM") -sdhour:value("78", "07:30 PM") -sdhour:value("79", "07:45 PM") -sdhour:value("80", "08:00 PM") -sdhour:value("81", "08:15 PM") -sdhour:value("82", "08:30 PM") -sdhour:value("83", "08:45 PM") -sdhour:value("84", "09:00 PM") -sdhour:value("85", "09:15 PM") -sdhour:value("86", "09:30 PM") -sdhour:value("87", "09:45 PM") -sdhour:value("88", "10:00 PM") -sdhour:value("89", "10:15 PM") -sdhour:value("90", "10:30 PM") -sdhour:value("91", "10:45 PM") -sdhour:value("92", "11:00 PM") -sdhour:value("93", "11:15 PM") -sdhour:value("94", "11:30 PM") -sdhour:value("95", "11:45 PM") -sdhour.default = "68" - -sdhour = s:option(ListValue, "times", translate("Times per Day :")) -sdhour.rmempty = true -sdhour:value("2", "2") -sdhour:value("4", "4") -sdhour:value("6", "6") -sdhour:value("8", "8") -sdhour:value("10", "10") -sdhour:value("12", "12") -sdhour:value("14", "14") -sdhour:value("16", "16") -sdhour:value("18", "18") -sdhour:value("20", "20") -sdhour:value("22", "22") -sdhour:value("24", "24") -sdhour:value("26", "26") -sdhour:value("28", "28") -sdhour:value("30", "30") -sdhour:value("32", "32") -sdhour:value("34", "34") -sdhour:value("36", "36") -sdhour:value("38", "38") -sdhour:value("40", "40") -sdhour.default = "10" - - -s = m:section(TypedSection, "numbers", "Phone Numbers") -s.anonymous = true -s.addremove = false - -o = s:option(DynamicList, "number", translate("List of Phone Numbers : ")) - -s = m:section(TypedSection, "messages", "Messages") -s.anonymous = true -s.addremove = false - -o = s:option(DynamicList, "message", translate("List of Messages : ")) - -m:section(SimpleSection).template = "fullmenu/textarea" - -return m \ No newline at end of file diff --git a/rooter/0optionalapps/ext-texting/files/usr/lib/lua/luci/view/fullmenu/textarea.htm b/rooter/0optionalapps/ext-texting/files/usr/lib/lua/luci/view/fullmenu/textarea.htm deleted file mode 100644 index fd7c69f..0000000 --- a/rooter/0optionalapps/ext-texting/files/usr/lib/lua/luci/view/fullmenu/textarea.htm +++ /dev/null @@ -1,103 +0,0 @@ -<% - load_icon = resource .. "/icons/loading.gif" -%> - - - - -
                - <%:Manual Texting%> - - - - - - - - - -
                Phone Number :
                Message :
                 
                - - - - - - - - - -
                diff --git a/rooter/0optionalapps/ext-throttle/files/usr/lib/throttle/throttle.sh b/rooter/0optionalapps/ext-throttle/files/usr/lib/throttle/throttle.sh deleted file mode 100644 index 6178cdb..0000000 --- a/rooter/0optionalapps/ext-throttle/files/usr/lib/throttle/throttle.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/sh -. /lib/functions.sh - -stop_interface() { - INTER=$1 - DEVICE=$(uci -q get sqm.$INTER.interface) - uci set sqm.$INTER.enabled='0' - uci commit sqm - if [ $DEVICE != "0" ]; then - /usr/lib/sqm/run.sh stop ${DEVICE} - fi -} - -start_interface() { - INTER=$1 - sdown=$2 - sup=$3 - uci set sqm.$INTER.enabled='1' - uci set sqm.$INTER.download=$sdown - uci set sqm.$INTER.upload=$sup - uci commit sqm - DEVICE=$(uci -q get sqm.$INTER.interface) - if [ $DEVICE != "0" ]; then - /usr/lib/sqm/run.sh stop ${DEVICE} - /usr/lib/sqm/run.sh start ${DEVICE} - fi -} - -cmd=$1 -if [ $cmd = 'start' ]; then - mult=$4 - if [ -z $mult ]; then - down=$2"000" - up=$3"000" - else - down=$2 - up=$3 - fi - /etc/init.d/sqm enabled - start_interface wan $down $up - start_interface wan1 $down $up - start_interface wan2 $down $up -else - stop_interface wan - stop_interface wan1 - stop_interface wan2 -fi \ No newline at end of file diff --git a/rooter/0optionalapps/ext-wireguard/Makefile b/rooter/0optionalapps/ext-wireguard/Makefile deleted file mode 100644 index e46e0df..0000000 --- a/rooter/0optionalapps/ext-wireguard/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -#Owned by DairyMan@Whirlpool -# -#Copyright GNU act. -include $(TOPDIR)/rules.mk - -PKG_NAME:=ext-wireguard -PKG_VERSION:=4.500 -PKG_RELEASE:=1 - -PKG_MAINTAINER:=Created by DM/makefile by Cobia@whirlpool -include $(INCLUDE_DIR)/package.mk - -define Package/ext-wireguard - SECTION:=utils - CATEGORY:=ROOter - SUBMENU:=Optional Applications - DEPENDS:=+wireguard-tools +kmod-wireguard \ - +luci-proto-wireguard +udp-tunnel +eoip - TITLE:=Install scripts for Wireguard - PKGARCH:=all -endef - -define Package/ext-wireguard/description - Install scripts for Wireguard -endef - - -define Build/Compile -endef - -define Package/ext-wireguard/install - $(CP) ./files/* $(1)/ -endef - -$(eval $(call BuildPackage,ext-wireguard)) diff --git a/rooter/0optionalapps/ext-wireguard/files/etc/config/wireguard b/rooter/0optionalapps/ext-wireguard/files/etc/config/wireguard deleted file mode 100644 index 77908d4..0000000 --- a/rooter/0optionalapps/ext-wireguard/files/etc/config/wireguard +++ /dev/null @@ -1,5 +0,0 @@ - -config settings 'settings' - option enabled '0' - option client '0' - option server '0' diff --git a/rooter/0optionalapps/ext-wireguard/files/etc/config/wireguard_recipes b/rooter/0optionalapps/ext-wireguard/files/etc/config/wireguard_recipes deleted file mode 100644 index 52a6b2b..0000000 --- a/rooter/0optionalapps/ext-wireguard/files/etc/config/wireguard_recipes +++ /dev/null @@ -1,36 +0,0 @@ -config wireguard_recipe b_client - option _description "Wireguard Client" - option _role "client" - option client "1" - option port "51280" - option auto '0' - option addresses '' - option dns '' - option privatekey '' - option name '' - option keepalive '25' - option publickey '' - option presharedkey '' - option ips '' - option ra_ips '1' - option endpoint_host '' - option sport '51280' - option active '0' - option udptunnel '0' - option mtu '1280' - -config wireguard_recipe b_server - option _description "Wireguard Server" - option _role "server" - option client "0" - option port "51280" - option auto '0' - option addresses '' - option publickey '' - option privatekey '' - option usepre '0' - option presharedkey '' - option active '0' - option udptunnel '0' - option udpport '54321' - option mtu '1280' \ No newline at end of file diff --git a/rooter/0optionalapps/ext-wireguard/files/etc/init.d/wireguard b/rooter/0optionalapps/ext-wireguard/files/etc/init.d/wireguard deleted file mode 100644 index 16a34ce..0000000 --- a/rooter/0optionalapps/ext-wireguard/files/etc/init.d/wireguard +++ /dev/null @@ -1,92 +0,0 @@ -#!/bin/sh /etc/rc.common -. /lib/functions.sh -# Copyright (C) 2006 OpenWrt.org - -START=99 - -log() { - logger -t "WireGuard Init.d : " "$@" -} - -chk_zone() { - local config=$1 - - config_get src $config src - config_get dest $config dest - if [ $src = "lan" -a $dest = "wg" ]; then - uci set firewall."$config".dest="wan" - uci commit firewall - fi -} - -check_config () { - log "Check Client Interfaces" - uci delete network.wg0 - uci delete network.wg1 - uci commit network - uci set network.wg0=interface - uci set network.wg0.proto="wireguard" - uci set network.wg0.auto="0" - uci set network.wg0.private_key="" - uci set network.wg0.listen_port="" - uci add_list network.wg0.addresses="" - uci set network.wg1=interface - uci set network.wg1.proto="wireguard" - uci set network.wg1.auto="0" - uci set network.wg1.private_key="" - uci set network.wg1.listen_port="" - uci add_list network.wg1.addresses="" - uci commit network - - uci delete firewall.wgzone - uci delete firewall.wgwforward - uci delete firewall.wwgforward - uci delete firewall.lwgforward - uci delete firewall.wglforward - uci commit firewall - uci set firewall.wgzone=zone - uci set firewall.wgzone.name="wg" - uci set firewall.wgzone.forward="ACCEPT" - uci set firewall.wgzone.output="ACCEPT" - uci set firewall.wgzone.network="wg0 wg1" - uci set firewall.wgzone.input="ACCEPT" - uci set firewall.wgzone.masq="1" - uci set firewall.wgzone.mtu_fix="1" - uci commit firewall - - config_load firewall - config_foreach chk_zone forwarding - - /etc/init.d/firewall restart -} - -chk_start() { - local config=$1 - - config_get auto $config auto - uci set wireguard."$config".active="0" - uci commit wireguard - if [ $auto = '1' ]; then - /usr/lib/wireguard/startvpn.sh $config - else - /usr/lib/wireguard/stopvpn.sh $config - fi -} - -start() { - uci set wireguard.settings.client="0" - uci set wireguard.settings.server="0" - uci commit wireguard - if [ ! -e /etc/openvpn ]; then - mkdir /etc/openvpn - fi - check_config - - config_load wireguard - config_foreach chk_start wireguard - if [ -e /etc/crontabs/root ]; then - sed -i '/wireguard_watchdog/d' /etc/crontabs/root - fi - echo '* * * * * /usr/bin/wireguard_watchdog' >> /etc/crontabs/root - /etc/init.d/cron restart -} \ No newline at end of file diff --git a/rooter/0optionalapps/ext-wireguard/files/usr/lib/lua/luci/controller/wireguard.lua b/rooter/0optionalapps/ext-wireguard/files/usr/lib/lua/luci/controller/wireguard.lua deleted file mode 100644 index 48ea3c3..0000000 --- a/rooter/0optionalapps/ext-wireguard/files/usr/lib/lua/luci/controller/wireguard.lua +++ /dev/null @@ -1,111 +0,0 @@ --- Copyright 2016-2017 Dan Luedtke --- Licensed to the public under the Apache License 2.0. - -module("luci.controller.wireguard", package.seeall) - -I18N = require "luci.i18n" -translate = I18N.translate - -function index() - local multilock = luci.model.uci.cursor():get("custom", "multiuser", "multi") or "0" - local rootlock = luci.model.uci.cursor():get("custom", "multiuser", "root") or "0" - if (multilock == "0") or (multilock == "1" and rootlock == "1") then - entry({"admin", "vpn", "wireguard"}, cbi("wireguard"), _("Wireguard"), 63) - entry( {"admin", "vpn", "wireguard", "client"}, cbi("wireguard-client"), nil ).leaf = true - entry( {"admin", "vpn", "wireguard", "server"}, cbi("wireguard-server"), nil ).leaf = true - end - - entry( {"admin", "vpn", "wireguard", "wupload"}, call("conf_upload")) - entry( {"admin", "vpn", "generateconf"}, call("conf_gen")) - entry( {"admin", "vpn", "textconf"}, call("text_gen")) - entry( {"admin", "vpn", "wirestatus"}, call("wirestatus")) -end - -function conf_upload() - local fs = require("nixio.fs") - local http = require("luci.http") - local util = require("luci.util") - local uci = require("luci.model.uci").cursor() - local upload = http.formvalue("ovpn_file") - local name = http.formvalue("instance_name2") - local file = "/etc/openvpn/" ..name.. ".conf" - - if name and upload then - local fp - - http.setfilehandler( - function(meta, chunk, eof) - local data = util.trim(chunk:gsub("\r\n", "\n")) .. "\n" - data = util.trim(data:gsub("[\128-\255]", "")) - - if not fp and meta and meta.name == "ovpn_file" then - fp = io.open(file, "w") - end - if fp and data then - fp:write(data) - end - if fp and eof then - fp:close() - end - end - ) - - if fs.access(file) then - os.execute("/usr/lib/wireguard/conf.sh " .. name .. " " .. file) - end - end - http.redirect(luci.dispatcher.build_url('admin/vpn/wireguard')) -end - -function conf_gen() - os.execute("/usr/lib/wireguard/create.sh") -end - -function text_gen() - local set = luci.http.formvalue("set") - os.execute("/usr/lib/wireguard/text.sh " .. "\"" .. set .. "\"") -end - -function wirestatus() - local data = { } - local last_device = "" - - local wg_dump = io.popen("wg show all dump") - if wg_dump then - local line - for line in wg_dump:lines() do - local line = string.split(line, "\t") - if not (last_device == line[1]) then - last_device = line[1] - data[line[1]] = { - name = line[1], - public_key = line[3], - listen_port = line[4], - fwmark = line[5], - peers = { } - } - else - local peer = { - public_key = line[2], - endpoint = line[4], - allowed_ips = { }, - latest_handshake = line[6], - transfer_rx = line[7], - transfer_tx = line[8], - persistent_keepalive = line[9] - } - if not (line[4] == '(none)') then - for ipkey, ipvalue in pairs(string.split(line[5], ",")) do - if #ipvalue > 0 then - table.insert(peer['allowed_ips'], ipvalue) - end - end - end - table.insert(data[line[1]].peers, peer) - end - end - end - - luci.http.prepare_content("application/json") - luci.http.write_json(data) -end \ No newline at end of file diff --git a/rooter/0optionalapps/ext-wireguard/files/usr/lib/lua/luci/model/cbi/wireguard-client.lua b/rooter/0optionalapps/ext-wireguard/files/usr/lib/lua/luci/model/cbi/wireguard-client.lua deleted file mode 100644 index 45e2216..0000000 --- a/rooter/0optionalapps/ext-wireguard/files/usr/lib/lua/luci/model/cbi/wireguard-client.lua +++ /dev/null @@ -1,104 +0,0 @@ -require("luci.ip") -require("luci.model.uci") - ---luci.sys.call("/usr/lib/wireguard/keygen.sh " .. arg[1]) - -local m = Map("wireguard", translate("Wireguard Client"), translate("Set up a Wireguard Client")) - -e = m:section(NamedSection, "settings", "") - -m.on_init = function(self) - --luci.sys.call("/usr/lib/wireguard/keygen.sh " .. arg[1]) -end - -btn = e:option(Button, "_btn", translate(" ")) -btn.inputtitle = translate("Back to Main Page") -btn.inputstyle = "apply" -btn.redirect = luci.dispatcher.build_url( - "admin", "vpn", "wireguard" -) -function btn.write(self, section, value) - luci.http.redirect( self.redirect ) -end - - -local s = m:section( NamedSection, arg[1], "wireguard", translate("Client") ) - -ip = s:option(Value, "addresses", translate("IP Addresses :"), translate("Comma separated list of IP Addresses that server will accept from this client")); -ip.rmempty = true; -ip.optional=false; -ip.default="10.14.0.2/24"; - -port = s:option(Value, "port", translate("Listen Port :"), translate("Client Listen Port")); -port.rmempty = true; -port.optional=false; -port.default="51820"; - -ul = s:option(ListValue, "udptunnel", translate("Enable UDP over TCP :")); -ul:value("0", translate("No")) -ul:value("1", translate("Yes")) -ul.default=0 - -dns = s:option(Value, "dns", translate("DNS Servers :"), translate("Comma separated list of DNS Servers.")); -dns.rmempty = true; -dns.optional=false; - -mtu = s:option(Value, "mtu", translate("MTU :"), translate("Maximum MTU")); -mtu.rmempty = true; -mtu.optional=false; -mtu.datatype = 'range(1280,1420)'; -mtu.default="1280"; - -pka = s:option(Value, "persistent_keepalive", translate("Persistent Keep Alive :"), translate("Seconds between keep alive messages")); -pka.rmempty = true; -pka.optional=false; -pka.datatype = 'range(1,100)'; -pka.default="25"; - -pkey = s:option(Value, "privatekey", translate("Private Key :"), translate("Private Key supplied by the Server")); -pkey.rmempty = true; -pkey.optional=false; - -il = s:option(ListValue, "wginter", translate("Interface to Use :")); -il:value("0", translate("WG0")) -il:value("1", translate("WG1")) -il.default="0" - -bl = s:option(ListValue, "auto", translate("Start on Boot :")); -bl:value("0", translate("No")) -bl:value("1", translate("Yes")) -bl.default="0" - -xbl = s:option(ListValue, "forward", translate("All Traffic Through Tunnel :")); -xbl:value("0", translate("No")) -xbl:value("1", translate("Yes")) -xbl.default="1" - -s = m:section( NamedSection, arg[1], "wireguard", translate("Server") ) - -name = s:option( Value, "name", translate("Server Name :"), translate("Optional Server name")) - -pukey = s:option(Value, "publickey", translate("Public Key :"), translate("Public Key of the Server")); -pukey.rmempty = true; -pukey.optional=false; - -prkey = s:option(Value, "presharedkey", translate("Presharedkey :"), translate("PreShared Key from the Server")); -prkey.rmempty = true; -prkey.optional=false; - -host = s:option(Value, "endpoint_host", translate("Server Address :"), translate("URL or IP Address of Server")); -host.rmempty = true; -host.optional=false; -host.default=""; - -sport = s:option(Value, "sport", translate("Listen Port :"), translate("Server Listen Port")); -sport.rmempty = true; -sport.optional=false; -sport.default="51820"; - -sip = s:option(Value, "ips", translate("Allowed IP Addresses :"), translate("Comma separated list of IP Addresses that server will accept")); -sip.rmempty = true; -sip.optional=false; -sip.default="10.14.0.0/24"; - -return m \ No newline at end of file diff --git a/rooter/0optionalapps/ext-wireguard/files/usr/lib/lua/luci/model/cbi/wireguard-server.lua b/rooter/0optionalapps/ext-wireguard/files/usr/lib/lua/luci/model/cbi/wireguard-server.lua deleted file mode 100644 index 5fb15ee..0000000 --- a/rooter/0optionalapps/ext-wireguard/files/usr/lib/lua/luci/model/cbi/wireguard-server.lua +++ /dev/null @@ -1,130 +0,0 @@ -require("luci.ip") -require("luci.model.uci") - ---luci.sys.call("/usr/lib/wireguard/keygen.sh " .. arg[1]) - -local m = Map("wireguard", translate("Wireguard Server"), translate("Set up a Wireguard Server")) - -e = m:section(NamedSection, "settings", "") - -m.on_init = function(self) - luci.sys.call("/usr/lib/wireguard/keygen.sh " .. arg[1]) -end - -m.on_after_save = function(self) - luci.sys.call("/usr/lib/wireguard/keygen.sh " .. arg[1] .. "&") -end - -btn = e:option(Button, "_btn", translate(" ")) -btn.inputtitle = translate("Back to Main Page") -btn.inputstyle = "apply" -btn.redirect = luci.dispatcher.build_url( - "admin", "vpn", "wireguard" -) -function btn.write(self, section, value) - luci.http.redirect( self.redirect ) -end - - -local s = m:section( NamedSection, arg[1], "wireguard", translate("Server") ) - -ip = s:option(Value, "addresses", translate("Internal IP Address :")); -ip.rmempty = true; -ip.optional=false; -ip.default="10.14.0.1/32"; -ip.datatype = "ipaddr" - -host = s:option(Value, "endpoint_host", translate("Server Address :"), translate("URL or IP Address of Server")); -host.rmempty = true; -host.optional=false; -host.default="example.wireguard.org"; - -port = s:option(Value, "port", translate("Port :"), translate("Server Listen Port. Default is 51280")); -port.rmempty = true; -port.optional=false; -port.default="51280"; - -ul = s:option(ListValue, "udptunnel", "Enable UDP over TCP :"); -ul:value("0", translate("No")) -ul:value("1", translate("Yes")) -ul.default=0 - -uport = s:option(Value, "udpport", translate("UDP over TCP Port :"), translate("Server Local TCP Port. Default is 54321")); -uport.rmempty = true; -uport.optional=false; -uport.default="54321"; -uport:depends("udptunnel", "1") - -pkey = s:option(DummyValue, "privatekey", translate("Private Key :")); -pkey.optional=false; - -pukey = s:option(DummyValue, "publickey", translate("Public Key :"), translate("Server Public key sent to Clients")); -pukey.optional=false; - -pl = s:option(ListValue, "usepre", "Use PreSharedKey :"); -pl:value("0", translate("No")) -pl:value("1", translate("Yes")) -pl.default=0 - -prkey = s:option(DummyValue, "presharedkey", translate("PreShared Key :"), translate("PreShared Key sent to Client")); -prkey.optional=false; -prkey:depends("usepre", "1") - -bl = s:option(ListValue, "auto", translate("Start on Boot :")); -bl:value("0", translate("No")) -bl:value("1", translate("Yes")) -bl.default="0" - -xbl = s:option(ListValue, "forward", translate("All Traffic Through Tunnel :")); -xbl:value("0", translate("No")) -xbl:value("1", translate("Yes")) -xbl.default="1" - - -b3 = s:option(DummyValue, "blank", " "); - -sx = s:option(Value, "_dmy1", translate(" ")) -sx.template = "wireguard/conf" - -ss = m:section(TypedSection, "custom" .. arg[1], translate("Clients"), translate("Clients of this server")) -ss.anonymous = true -ss.addremove = true - -name = ss:option(Value, "name", translate("Client Name")) -name.optional=false; - -cport = ss:option(Value, "endpoint_port", translate("Listen Port :"), translate("Port sent to Client. Default is 51280")); -cport.rmempty = true; -cport.optional=false; -cport.default=""; - -aip = ss:option(Value, "address", translate("Assigned IP Address :"), translate("IP Address assigned to Client")); -aip.rmempty = true; -aip.optional=false; -aip.default="10.14.0.2/32"; - -dns = ss:option(Value, "dns", translate("DNS Servers :"), translate("Comma separated list of DNS Servers sent to Client")); -dns.rmempty = true; -dns.optional=false; -dns.default=""; - -mtu = ss:option(Value, "mtu", translate("MTU :"), translate("Maximum MTU")); -mtu.rmempty = true; -mtu.optional=false; -mtu.datatype = 'range(1280,1420)'; -mtu.default="1280"; - -aip = ss:option(Value, "allowed_ips", translate("Allowed IP Address :"), translate("Comma separated list of IP Addresses allowed from Client")); -aip.rmempty = true; -aip.optional=false; -aip.default="0.0.0.0/0,::/0"; - -pukey = ss:option(DummyValue, "publickey", translate("Public Key :"), translate("Client Public Key")); -pukey.optional=false; - -pikey = ss:option(DummyValue, "privatekey", translate("Private Key :"), translate("Private Key sent to Client")); -pikey.optional=false; - -b3 = ss:option(DummyValue, "blank", " "); - -return m \ No newline at end of file diff --git a/rooter/0optionalapps/ext-wireguard/files/usr/lib/lua/luci/model/cbi/wireguard.lua b/rooter/0optionalapps/ext-wireguard/files/usr/lib/lua/luci/model/cbi/wireguard.lua deleted file mode 100644 index 0aab305..0000000 --- a/rooter/0optionalapps/ext-wireguard/files/usr/lib/lua/luci/model/cbi/wireguard.lua +++ /dev/null @@ -1,182 +0,0 @@ -local fs = require "nixio.fs" -local sys = require "luci.sys" -local uci = require "luci.model.uci".cursor() -local testfullps = sys.exec("ps --help 2>&1 | grep BusyBox") --check which ps do we have -local psstring = (string.len(testfullps)>0) and "ps w" or "ps axfw" --set command we use to get pid - -local m = Map("wireguard", translate("Wireguard"), translate("Set up a Wireguard VPN Tunnel on your Router")) - -local s = m:section( TypedSection, "wireguard", translate("Instances"), translate("Below is a list of configured Wireguard Instances and their current state") ) -s.template = "cbi/tblsection" -s.template_addremove = "wireguard/cbi-select-input-add" -s.addremove = true -s.add_select_options = { } - -local cfg = s:option(DummyValue, "config") -function cfg.cfgvalue(self, section) - local file_cfg = self.map:get(section, "client") - if file_cfg == "1" then - s.extedit = luci.dispatcher.build_url("admin", "vpn", "wireguard", "client", "%s") - else - s.extedit = luci.dispatcher.build_url("admin", "vpn", "wireguard", "server", "%s") - end -end - -uci:load("wireguard_recipes") -uci:foreach( "wireguard_recipes", "wireguard_recipe", - function(section) - s.add_select_options[section['.name']] = - section['_description'] or section['.name'] - end -) - -function s.parse(self, section) - local recipe = luci.http.formvalue( - luci.cbi.CREATE_PREFIX .. self.config .. "." .. - self.sectiontype .. ".select" - ) - - if recipe and not s.add_select_options[recipe] then - self.invalid_cts = true - else - TypedSection.parse( self, section ) - end -end - -function s.create(self, name) - local recipe = luci.http.formvalue( - luci.cbi.CREATE_PREFIX .. self.config .. "." .. - self.sectiontype .. ".select" - ) - local name = luci.http.formvalue( - luci.cbi.CREATE_PREFIX .. self.config .. "." .. - self.sectiontype .. ".text" - ) - if #name > 3 and not name:match("[^a-zA-Z0-9_]") then - local s = uci:section("wireguard", "wireguard", name) - if s then - local options = uci:get_all("wireguard_recipes", recipe) - for k, v in pairs(options) do - if k ~= "_role" and k ~= "_description" then - if type(v) == "boolean" then - v = v and "1" or "0" - end - uci:set("wireguard", name, k, v) - end - end - uci:save("wireguard") - uci:commit("wireguard") - if extedit then - luci.http.redirect( self.extedit:format(name) ) - end - end - elseif #name > 0 then - self.invalid_cts = true - end - return 0 -end - -function s.remove(self, name) - local cfg_file = "/etc/openvpn/" ..name.. ".conf" - local auth_file = "/etc/openvpn/" ..name.. ".auth" - if fs.access(cfg_file) then - fs.unlink(cfg_file) - end - if fs.access(auth_file) then - fs.unlink(auth_file) - end - uci:delete("wireguard", name) - uci:save("wireguard") - uci:commit("wireguard") -end - -local port = s:option( DummyValue, "client", translate("Type") ) -function port.cfgvalue(self, section) - local val = AbstractValue.cfgvalue(self, section) - if val == nil then - val = 0 - end - if val == "1" then - return "Client" - else - return "Server" - end -end - -local addr = s:option( DummyValue, "addresses", translate("IP Addresses") ) -function addr.cfgvalue(self, section) - local val = AbstractValue.cfgvalue(self, section) - return val or "----" -end - -local auto = s:option( DummyValue, "udptunnel", translate("UDP over TCP") ) -function auto.cfgvalue(self, section) - local val = AbstractValue.cfgvalue(self, section) - if val == nil then - val = 0 - end - if val == "1" then - return "Yes" - else - return "No" - end -end - -local auto = s:option( DummyValue, "auto", translate("Start on Boot") ) -function auto.cfgvalue(self, section) - local val = AbstractValue.cfgvalue(self, section) - if val == nil then - val = 0 - end - if val == "1" then - return "Yes" - else - return "No" - end -end - -local active = s:option( DummyValue, "active", translate("Started") ) -function active.cfgvalue(self, section) - local val = AbstractValue.cfgvalue(self, section) - if val == nil then - val = 0 - end - if val == "1" then - return "Yes" - else - return "No" - end -end - -local updown = s:option( Button, "_updown", translate("Start/Stop") ) -updown._state = false -updown.redirect = luci.dispatcher.build_url( - "admin", "vpn", "wireguard" -) -function updown.cbid(self, section) - local file_cfg = self.map:get(section, "active") - if file_cfg == "1" then - pid = 1 - else - pid = nil - end - self._state = pid ~= nil - self.option = self._state and "stop" or "start" - return AbstractValue.cbid(self, section) -end -function updown.cfgvalue(self, section) - self.title = self._state and "stop" or "start" - self.inputstyle = self._state and "reset" or "reload" -end -function updown.write(self, section, value) - if self.option == "stop" then - sys.call("/usr/lib/wireguard/stopvpn.sh %s" % section) - else - sys.call("/usr/lib/wireguard/startvpn.sh %s" % section) - end - luci.http.redirect( self.redirect ) -end - -m:section(SimpleSection).template = "wireguard/wireguard" - -return m \ No newline at end of file diff --git a/rooter/0optionalapps/ext-wireguard/files/usr/lib/lua/luci/view/wireguard/cbi-select-input-add.htm b/rooter/0optionalapps/ext-wireguard/files/usr/lib/lua/luci/view/wireguard/cbi-select-input-add.htm deleted file mode 100644 index c6cb8ac..0000000 --- a/rooter/0optionalapps/ext-wireguard/files/usr/lib/lua/luci/view/wireguard/cbi-select-input-add.htm +++ /dev/null @@ -1,111 +0,0 @@ - - - -<%+wireguard/ovpn_css%> - -
                -
                -

                <%:Template based configuration%>

                -
                -
                - -
                -
                - -
                -
                -
                -
                -
                -

                <%:Conf configuration file upload%>

                -
                -
                - -
                -
                - -
                -
                - -
                -
                -
                -
                - -
                -
                diff --git a/rooter/0optionalapps/ext-wireguard/files/usr/lib/lua/luci/view/wireguard/conf.htm b/rooter/0optionalapps/ext-wireguard/files/usr/lib/lua/luci/view/wireguard/conf.htm deleted file mode 100644 index e75e88f..0000000 --- a/rooter/0optionalapps/ext-wireguard/files/usr/lib/lua/luci/view/wireguard/conf.htm +++ /dev/null @@ -1,27 +0,0 @@ - - - -
                - - - - - - - -
                   
                -
                diff --git a/rooter/0optionalapps/ext-wireguard/files/usr/lib/lua/luci/view/wireguard/ovpn_css.htm b/rooter/0optionalapps/ext-wireguard/files/usr/lib/lua/luci/view/wireguard/ovpn_css.htm deleted file mode 100644 index 55c0a54..0000000 --- a/rooter/0optionalapps/ext-wireguard/files/usr/lib/lua/luci/view/wireguard/ovpn_css.htm +++ /dev/null @@ -1,38 +0,0 @@ - diff --git a/rooter/0optionalapps/ext-wireguard/files/usr/lib/lua/luci/view/wireguard/pageswitch.htm b/rooter/0optionalapps/ext-wireguard/files/usr/lib/lua/luci/view/wireguard/pageswitch.htm deleted file mode 100644 index 47056fa..0000000 --- a/rooter/0optionalapps/ext-wireguard/files/usr/lib/lua/luci/view/wireguard/pageswitch.htm +++ /dev/null @@ -1,30 +0,0 @@ -<%# - Copyright 2008 Steven Barth - Copyright 2008 Jo-Philipp Wich - Licensed to the public under the Apache License 2.0. --%> - -<%+openvpn/ovpn_css%> - -
                -

                - <%:Overview%> » - <%=luci.i18n.translatef("Instance \"%s\"", self.instance)%> -

                - <% if self.mode == "basic" then %> - "><%:Switch to advanced configuration%> »

                -


                - <% elseif self.mode == "advanced" then %> - <%:Switch to basic configuration%> »

                -


                - <%:Configuration category%>: - <% for i, c in ipairs(self.categories) do %> - <% if c == self.category then %> - <%=translate(c)%> - <% else %> - "><%=translate(c)%> - <% end %> - <% if next(self.categories, i) then %>|<% end %> - <% end %> - <% end %> -
                diff --git a/rooter/0optionalapps/ext-wireguard/files/usr/lib/lua/luci/view/wireguard/text_conf.htm b/rooter/0optionalapps/ext-wireguard/files/usr/lib/lua/luci/view/wireguard/text_conf.htm deleted file mode 100644 index 2a1a4b5..0000000 --- a/rooter/0optionalapps/ext-wireguard/files/usr/lib/lua/luci/view/wireguard/text_conf.htm +++ /dev/null @@ -1,61 +0,0 @@ -<% - -%> - - - -
                - <%:Paste Configuration File Here%> - - - - -
                - -
                - - - - - - - - - - -
                <%:Instance Name : %>
                <%:Start on Boot : %>
                - -  
                -
                diff --git a/rooter/0optionalapps/ext-wireguard/files/usr/lib/lua/luci/view/wireguard/wireguard.htm b/rooter/0optionalapps/ext-wireguard/files/usr/lib/lua/luci/view/wireguard/wireguard.htm deleted file mode 100644 index cf7544e..0000000 --- a/rooter/0optionalapps/ext-wireguard/files/usr/lib/lua/luci/view/wireguard/wireguard.htm +++ /dev/null @@ -1,228 +0,0 @@ -<%# - Copyright 2016-2017 Dan Luedtke - Licensed to the public under the Apache License 2.0. --%> - -<% - --%> - - - -

                <%:WireGuard Status%>

                - -
                - -
                - - - - - - -
                -
                <%:Interface %>
                -
                  
                - - - - - - - - - - - - - - - -
                  -
                <%:Configuration%>
                -
                   -
                - <%:Collecting data...%> -
                -
                  -
                <%:Peer%>
                -
                   -
                - <%:Collecting data...%> -
                -
                - - - - - - - -
                -
                <%:Interface %>
                -
                  
                - - - - - - - - - - - - - - - -
                  -
                <%:Configuration%>
                -
                   -
                - <%:Collecting data...%> -
                -
                  -
                <%:Peer%>
                -
                   -
                - <%:Collecting data...%> -
                -
                - -
                - -
                - diff --git a/rooter/0optionalapps/ext-wireguard/files/usr/lib/wireguard/conf.sh b/rooter/0optionalapps/ext-wireguard/files/usr/lib/wireguard/conf.sh deleted file mode 100644 index 5c36ca2..0000000 --- a/rooter/0optionalapps/ext-wireguard/files/usr/lib/wireguard/conf.sh +++ /dev/null @@ -1,134 +0,0 @@ -#!/bin/sh - -log() { - modlog "Wireguard Conf" "$@" -} - -name=$1 -file=$2 -auto=$3 -if [ -z $auto ]; then - auto="0" -fi - -extract() { - line=$1 - PD=$(echo "$line" | grep "#") - if [ ! -z "$PD" ]; then - return - fi - PRK=$(echo "$line" | grep "PrivateKey" | tr " " ",") - if [ ! -z "$PRK" ]; then - PrivateKey=$(echo $PRK | cut -d, -f3) - fi - PRK=$(echo "$line" | grep "PublicKey" | tr " " ",") - if [ ! -z "$PRK" ]; then - PublicKey=$(echo $PRK | cut -d, -f3) - fi - PRK=$(echo "$line" | grep "PresharedKey" | tr " " ",") - if [ ! -z "$PRK" ]; then - PreSharedKey=$(echo $PRK | cut -d, -f3) - fi - INTER=$(echo "$line" | grep "WGinterface" | tr " " ",") - if [ ! -z "$INTER" ]; then - wginter=$(echo $INTER | cut -d, -f3) - if [ "$wginter" -gt 1 ]; then - wginter="1" - fi - fi - PRK=$(echo "$line" | grep "Address" | tr " " "#") - if [ ! -z "$PRK" ]; then - if [ -z $Address ]; then - Address=$(echo $PRK | cut -d# -f3) - else - Address=$Address","$(echo $PRK | cut -d# -f3) - fi - fi - PRK=$(echo "$line" | grep "dns" | tr " " "#") - if [ ! -z "$PRK" ]; then - dns=$(echo $PRK | cut -d# -f3) - fi - PRK=$(echo "$line" | grep "DNS" | tr " " "#") - if [ ! -z "$PRK" ]; then - dns=$(echo $PRK | cut -d# -f3) - fi - PRK=$(echo "$line" | grep "ListenPort" | tr " " ",") - if [ ! -z "$PRK" ]; then - listenport=$(echo $PRK | cut -d, -f3) - fi - PRK=$(echo "$line" | grep "AllowedIPs" | tr " " "#") - if [ ! -z "$PRK" ]; then - if [ -z $allowedips ]; then - allowedips=$(echo $PRK | cut -d# -f3) - else - allowedips=$allowedips","$(echo $PRK | cut -d# -f3) - fi - fi - PRK=$(echo "$line" | grep "Endpoint" | tr " " ",") - if [ ! -z "$PRK" ]; then - endpoint=$(echo $PRK | cut -d, -f3) - fi - MTU=$(echo "$line" | grep "MTU" | tr " " ",") - if [ ! -z "$MTU" ]; then - mtu=$(echo $MTU | cut -d, -f3) - fi -} - -listenport="51280" -dns="" -sed -i -e "s!PrivateKey= !PrivateKey=!g" $file -sed -i -e "s!PrivateKey=!PrivateKey = !g" $file -sed -i -e "s!PublicKey= !PublicKey=!g" $file -sed -i -e "s!PublicKey=!PublicKey = !g" $file -sed -i -e "s!PresharedKey= !PresharedKey=!g" $file -sed -i -e "s!PresharedKey=!PresharedKey = !g" $file -sed -i -e "s!Address= !Address=!g" $file -sed -i -e "s!Address=!Address = !g" $file -sed -i -e "s!WGinterface=!WGinterface = !g" $file -sed -i -e "s!WGinterface= !WGinterface = !g" $file -sed -i -e "s!dns= !dns=!g" $file -sed -i -e "s!dns=!dns = !g" $file -sed -i -e "s!DNS= !DNS=!g" $file -sed -i -e "s!DNS=!DNS = !g" $file -sed -i -e "s!ListenPort= !ListenPort=!g" $file -sed -i -e "s!ListenPort=!ListenPort = !g" $file -sed -i -e "s!AllowedIPs= !AllowedIPs=!g" $file -sed -i -e "s!AllowedIPs=!AllowedIPs = !g" $file -sed -i -e "s!Endpoint= !Endpoint=!g" $file -sed -i -e "s!Endpoint=!Endpoint = !g" $file -sed -i -e "s!MTU= !MTU=!g" $file -sed -i -e "s!MTU=!MTU = !g" $file - -while IFS= read -r linex -do - extract "$linex" -done < $file -extract "$linex" -PRK=$(echo "$endpoint" | tr ":" ",") -endpoint=$(echo $PRK | cut -d, -f1) -sport=$(echo $PRK | cut -d, -f2) -if [ -z "$wginter" ]; then - wginter="0" -fi -uci delete wireguard.$name -uci set wireguard.$name=wireguard -uci set wireguard.$name.auto=$auto -uci set wireguard.$name.client="1" -uci set wireguard.$name.active="0" -uci set wireguard.$name.privatekey="$PrivateKey" -uci set wireguard.$name.presharedkey="$PreSharedKey" -uci set wireguard.$name.port="$listenport" -uci set wireguard.$name.addresses="$Address" -uci set wireguard.$name.dns="$dns" -uci set wireguard.$name.wginter="$wginter" -uci set wireguard.$name.publickey="$PublicKey" -uci set wireguard.$name.endpoint_host="$endpoint" -uci set wireguard.$name.ips="$allowedips" -uci set wireguard.$name.name="$name" -uci set wireguard.$name.sport="$sport" -uci set wireguard.$name.mtu="$mtu" -uci set wireguard.$name.persistent_keepalive='25' -uci commit wireguard - -rm -f $file - \ No newline at end of file diff --git a/rooter/0optionalapps/ext-wireguard/files/usr/lib/wireguard/create.sh b/rooter/0optionalapps/ext-wireguard/files/usr/lib/wireguard/create.sh deleted file mode 100644 index 143abe6..0000000 --- a/rooter/0optionalapps/ext-wireguard/files/usr/lib/wireguard/create.sh +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/sh -. /lib/functions.sh - -log() { - logger -t "Wireguard Conf" "$@" -} - -WG=$(cat /tmp/wginst) - -do_create() { - local config=$1 - - config_get name $config name - if [ -z $name ]; then - name=$config - fi - - echo "----Start Conf File for "$name" ----" >> ${PKI_DIR}/package/wg.conf - echo "[Interface]" >> ${PKI_DIR}/package/wg.conf - config_get privatekey $config privatekey - echo "PrivateKey = "$privatekey >> ${PKI_DIR}/package/wg.conf - config_get address $config address - echo "Address = "$address >> ${PKI_DIR}/package/wg.conf - config_get endpoint_port $config endpoint_port - if [ ! -z $endpoint_port ]; then - echo "ListenPort = "$endpoint_port >> ${PKI_DIR}/package/wg.conf - fi - config_get dns $config dns - if [ ! -z $dns ]; then - echo "DNS = "$dns >> ${PKI_DIR}/package/wg.conf - fi - config_get mtu $config mtu - if [ ! -z $mtu ]; then - echo "MTU = "$mtu >> ${PKI_DIR}/package/wg.conf - fi - config_get wginter $config wginter - if [ -z"$wginter"]; then - wginter=0 - fi - echo "PrivateKey = "$wginter >> ${PKI_DIR}/package/wg.conf - echo " " >> ${PKI_DIR}/package/wg.conf - echo "[Peer]" >> ${PKI_DIR}/package/wg.conf - PUB=$(uci get wireguard."$WG".publickey) - echo "PublicKey = "$PUB >> ${PKI_DIR}/package/wg.conf - USE=$(uci get wireguard."$WG".usepre) - if [ $USE = "1" ]; then - PRE=$(uci get wireguard."$WG".presharedkey) - echo "PresharedKey = "$PRE >> ${PKI_DIR}/package/wg.conf - fi - HOST=$(uci get wireguard."$WG".endpoint_host) - PORT=$(uci get wireguard."$WG".port) - if [ ! -z $PORT ]; then - HOST=$HOST":"$PORT - fi - echo "Endpoint = "$HOST >> ${PKI_DIR}/package/wg.conf - config_get allowed_ips $config allowed_ips - echo "AllowedIPs = "$allowed_ips >> ${PKI_DIR}/package/wg.conf - echo "----EndConf File for "$name" ----" >> ${PKI_DIR}/package/wg.conf - echo " " >> ${PKI_DIR}/package/wg.conf -} - -#PKI_DIR="/tmp/wireguard" -PKI_DIR="/www" -#rm -rfv "$PKI_DIR" -#mkdir -p ${PKI_DIR} -#chmod -R 0777 ${PKI_DIR} -cd ${PKI_DIR} -mkdir -p package -cd .. -chmod -R 0777 ${PKI_DIR}/package -#rm -rfv "/www/package" -#ln -s ${PKI_DIR}/package /www/package - - -rm -f ${PKI_DIR}/package/wg.conf -config_load wireguard -config_foreach do_create custom$WG - -cd ${PKI_DIR}/package - -tar -czf wgconf.tar.gz wg.conf diff --git a/rooter/0optionalapps/ext-wireguard/files/usr/lib/wireguard/keygen.sh b/rooter/0optionalapps/ext-wireguard/files/usr/lib/wireguard/keygen.sh deleted file mode 100644 index 3b30f61..0000000 --- a/rooter/0optionalapps/ext-wireguard/files/usr/lib/wireguard/keygen.sh +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/sh -. /lib/functions.sh - -log() { - logger -t "Wireguard KeyGen" "$@" -} - -WG=$1 -echo "$WG" > /tmp/wginst - -sleep 5 - -EXST=$(uci get wireguard."$WG") -if [ -z $EXST ]; then - uci set wireguard."$WG"="wireguard" - uci commit wireguard -fi - -PRIV=$(uci get wireguard."$WG".privatekey) -if [ -z $PRIV ]; then - umask u=rw,g=,o= - wg genkey | tee /tmp/wgserver.key | wg pubkey > /tmp/wgclient.pub - wg genpsk > /tmp/wg.psk - - WG_KEY="$(cat /tmp/wgserver.key)" # private key - WG_PSK="$(cat /tmp/wg.psk)" # shared key - WG_PUB="$(cat /tmp/wgclient.pub)" # public key to be used on other end - rm -f /tmp/wgserver.key - rm -f /tmp/wg.psk - rm -f /tmp/wgclient.pub - uci set wireguard."$WG".privatekey=$WG_KEY - uci set wireguard."$WG".publickey=$WG_PUB - uci set wireguard."$WG".presharedkey=$WG_PSK - uci commit wireguard -fi - -do_custom() { - local config=$1 - - config_get privatekey $config privatekey - if [ -z "$privatekey" ]; then - umask u=rw,g=,o= - wg genkey | tee /tmp/wgserver.key | wg pubkey > /tmp/wgclient.pub - wg genpsk > /tmp/wg.psk - - WG_KEY="$(cat /tmp/wgserver.key)" # private key - WG_PSK="$(cat /tmp/wg.psk)" # shared key - WG_PUB="$(cat /tmp/wgclient.pub)" # public key to be used on other end - rm -f /tmp/wgserver.key - rm -f /tmp/wg.psk - rm -f /tmp/wgclient.pub - log "$WG_KEY" - uci set wireguard."$config".privatekey=$WG_KEY - uci set wireguard."$config".publickey=$WG_PUB - uci set wireguard."$config".presharedkey=$WG_PSK - uci set wireguard."$config".persistent_keepalive='25' - uci set wireguard."$config".route_allowed_ips='1' - fi -} - -config_load wireguard -config_foreach do_custom custom$WG -uci commit wireguard \ No newline at end of file diff --git a/rooter/0optionalapps/ext-wireguard/files/usr/lib/wireguard/startvpn.sh b/rooter/0optionalapps/ext-wireguard/files/usr/lib/wireguard/startvpn.sh deleted file mode 100644 index 3e00972..0000000 --- a/rooter/0optionalapps/ext-wireguard/files/usr/lib/wireguard/startvpn.sh +++ /dev/null @@ -1,323 +0,0 @@ -#!/bin/sh -. /lib/functions.sh - -log() { - logger -t "Wireguard Start" "$@" -} - -WG=$1 - -chk_zone() { - local config=$1 - - config_get src $config src - config_get dest $config dest - if [ $src = "lan" -a $dest = "wan" ]; then - uci set firewall."$config".dest="wg" - uci commit firewall - fi -} - -do_dns() { - cdns=$1 - local ifce=$2 - ldns=$(uci -q get network.wg$ifce.dns) - ex=$(echo "$ldns" | grep "$cdns") - if [ -z $ex ]; then - log "Add DNS $cdns to WG$ifce" - uci add_list network.wg$ifce.dns="$cdns" - uci commit network - /etc/init.d/network reload - fi -} - -do_port() { - PORT=$1 - udp=$2 - # look for rule for this port - INB="inbound"$PORT$udp - RULE=$(uci -q get firewall.$INB) - if [ -z $RULE ]; then - uci set firewall.$INB=rule - uci set firewall.$INB.name=$INB - uci set firewall.$INB.target=ACCEPT - uci set firewall.$INB.src=* - uci set firewall.$INB.proto=$udp - uci set firewall.$INB.dest_port=$PORT - uci commit firewall - /etc/init.d/firewall reload - fi -} - -do_delete() { - local config=$1 - - uci delete network.$1 -} - -create_speer() { - local config=$1 - - uci set network.$config="wireguard_wg1" - - config_get persistent_keepalive $config persistent_keepalive - uci set network.$config.persistent_keepalive="$persistent_keepalive" - config_get route_allowed_ips $config route_allowed_ips - uci set network.$config.route_allowed_ips="$route_allowed_ips" - config_get publickey $config publickey - uci set network.$config.public_key="$publickey" - usepre=$(uci -q get wireguard.$WG.usepre) - log "$usepre" - if [ $usepre = "1" ]; then - presharedkey=$(uci -q get wireguard.$WG.presharedkey) - log "$presharedkey" - uci set network.$config.preshared_key="$presharedkey" - fi - config_get allowed_ips $config allowed_ips - allowed_ips=$allowed_ips"," - ips=$(echo $allowed_ips | cut -d, -f1) - i=1 - while [ ! -z $ips ] - do - uci add_list network.$config.allowed_ips="$ips" - i=$((i+1)) - ips=$(echo $allowed_ips | cut -d, -f$i) - done - -} - -create_cpeer() { - local config=$1 - local ifce=$2 - - uci set network.$config="wireguard_wg$ifce" - - publickey=$(uci -q get wireguard."$config".publickey) - uci set network.$config.public_key="$publickey" - presharedkey=$(uci -q get wireguard."$WG".presharedkey) - if [ ! -z $presharedkey ]; then - uci set network.$config.preshared_key="$presharedkey" - fi - persistent_keepalive=$(uci -q get wireguard."$config".persistent_keepalive) - if [ -z $persistent_keepalive ]; then - persistent_keepalive=25 - fi - uci set network.$config.persistent_keepalive="$persistent_keepalive" - route_allowed_ips=1 - uci set network.$config.route_allowed_ips="$route_allowed_ips" - - if [ $UDP = 1 ]; then - endpoint_host="127.0.0.1" - uci set network.$config.endpoint_host="$endpoint_host" - sport=$(uci -q get wireguard."$config".port) - if [ -z $sport ]; then - sport="54321" - fi - uci set network.$config.endpoint_port="$sport" - else - endpoint_host=$(uci -q get wireguard."$config".endpoint_host) - uci set network.$config.endpoint_host="$endpoint_host" - sport=$(uci -q get wireguard."$config".sport) - if [ -z $sport ]; then - sport="51280" - fi - uci set network.$config.endpoint_port="$sport" - fi - - ips=$(uci -q get wireguard."$config".ips)"," - cips=$(echo $ips | cut -d, -f1) - i=1 - while [ ! -z $cips ] - do - uci add_list network.$config.allowed_ips="$cips" - i=$((i+1)) - cips=$(echo $ips | cut -d, -f$i) - done -} - -handle_server() { - config_foreach do_delete wireguard_wg1 - - uci delete network.wg1 - uci set network.wg1="interface" - uci set network.wg1.proto="wireguard" - - auto=$(uci -q get wireguard."$WG".auto) - if [ -z $auto ]; then - auto="0" - fi - uci set network.wg1.auto="$auto" - - port=$(uci -q get wireguard."$WG".port) - if [ -z $port ]; then - port="51280" - fi - uci set network.wg1.listen_port="$port" - do_port $port udp - - privatekey=$(uci -q get wireguard."$WG".privatekey) - uci set network.wg1.private_key="$privatekey" - - ips=$(uci -q get wireguard."$WG".addresses)"," - cips=$(echo $ips | cut -d, -f1) - i=1 - while [ ! -z $cips ] - do - uci add_list network.wg1.addresses="$cips" - i=$((i+1)) - cips=$(echo $ips | cut -d, -f"$i") - if [ -z $cips ]; then - break - fi - done - - config_load wireguard - config_foreach create_speer custom$WG - - uci commit network -} - -handle_client() { - ifce=$1 - config_foreach do_delete wireguard_wg$ifce - - uci delete network.wg$ifce - uci set network.wg$ifce="interface" - uci set network.wg$ifce.proto="wireguard" - - auto=$(uci -q get wireguard."$WG".auto) - if [ -z $auto ]; then - auto="0" - fi - uci set network.wg$ifce.auto="$auto" - mtu=$(uci -q get wireguard."$WG".mtu) - if [ ! -z $mtu ]; then - uci set network.wg$ifce.mtu="$mtu" - fi - dns=$(uci -q get wireguard."$WG".dns) - if [ ! -z $dns ]; then - do_dns $dns $ifce - fi - port=$(uci -q get wireguard."$WG".port) - if [ -z $port ]; then - port="51280" - fi - uci set network.wg$ifce.listen_port="$port" - do_port $port udp - - privatekey=$(uci -q get wireguard."$WG".privatekey) - uci set network.wg$ifce.private_key="$privatekey" - - ips=$(uci -q get wireguard."$WG".addresses)"," - cips=$(echo $ips | cut -d, -f1) - i=1 - while [ ! -z "$cips" ] - do - uci add_list network.wg$ifce.addresses="$cips" - i=$((i+1)) - cips=$(echo "$ips" | cut -d, -f"$i") - if [ -z "$cips" ]; then - break - fi - done - uci add_list network.wg$ifce.addresses="::/0" - - create_cpeer $WG $ifce - - uci commit network -} - -udp_server() { - local config=$1 - udpport=$(uci -q get wireguard."$WG".udpport) - if [ -z $udpport ]; then - udpport="54321" - fi - port=$(uci -q get wireguard."$WG".port) - if [ -z $port ]; then - port="54321" - fi - do_port $udpport tcp - udptunnel -s -v "0.0.0.0:"$udpport "127.0.0.1:"$port & - #log "udptunnel -s -v 0.0.0.0:$udpport 127.0.0.1:$port" -} - -udp_client() { - local config=$1 - port=$(uci -q get wireguard."$WG".port) - if [ -z $port ]; then - port="54321" - fi - endpoint_host=$(uci -q get wireguard.$WG.endpoint_host) - sport=$(uci -q get wireguard.$WG.sport) - if [ -z $sport ]; then - sport="51280" - fi - - udptunnel "127.0.0.1:"$port $endpoint_host":"$sport & - #log "udptunnel 127.0.0.1:$port $endpoint_host:$sport" -} - -forward=$(uci -q get wireguard."$WG".forward) -if [ "$forward" != "0" ]; then - config_load firewall - config_foreach chk_zone forwarding -else - uci set firewall.wgwforward=forwarding - uci set firewall.wgwforward.dest="wan" - uci set firewall.wgwforward.src="wg" - - uci set firewall.wwgforward=forwarding - uci set firewall.wwgforward.dest="wg" - uci set firewall.wwgforward.src="wan" - - uci set firewall.lwgforward=forwarding - uci set firewall.lwgforward.dest="wg" - uci set firewall.lwgforward.src="lan" - - uci set firewall.wglforward=forwarding - uci set firewall.wglforward.dest="lan" - uci set firewall.wglforward.src="wg" - uci commit firewall -fi -etc/init.d/firewall restart - -config_load network -SERVE=$(uci -q get wireguard."$WG".client) -if [ $SERVE = "0" ]; then - running=$(uci -q get wireguard.settings.server) - if [ $running = 1 ]; then - exit 0 - fi - UDP=$(uci -q get wireguard."$WG".udptunnel) - if [ $UDP = 1 ]; then - udp_server $WG - fi - handle_server - uci commit network - ifup wg1 - sleep 2 - uci set wireguard.settings.server="1" -else - running=$(uci -q get wireguard.settings.client) - log "Client running $running" - - INTER=$(uci -q get wireguard."$WG".wginter) - if [ -z "$INTER" ]; then - INTER=0 - fi - UDP=$(uci -q get wireguard."$WG".udptunnel) - if [ $UDP = 1 ]; then - udp_client $WG - fi - handle_client $INTER - uci commit network - log "Start Interface" - ifup wg$INTER - sleep 2 - uci set wireguard.settings.client="1" -fi - -uci set wireguard."$WG".active="1" -uci commit wireguard - diff --git a/rooter/0optionalapps/ext-wireguard/files/usr/lib/wireguard/stopvpn.sh b/rooter/0optionalapps/ext-wireguard/files/usr/lib/wireguard/stopvpn.sh deleted file mode 100644 index 9e56adf..0000000 --- a/rooter/0optionalapps/ext-wireguard/files/usr/lib/wireguard/stopvpn.sh +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/sh -. /lib/functions.sh - -log() { - logger -t "Wireguard Stop" "$@" -} - -chk_zone() { - local config=$1 - - config_get src $config src - config_get dest $config dest - if [ $src = "lan" -a $dest = "wg" ]; then - uci set firewall."$config".dest="wan" - uci commit firewall - fi -} - -WG=$1 - -forward=$(uci -q get wireguard."$WG".forward) -if [ "$forward" != "0" ]; then - config_load firewall - config_foreach chk_zone forwarding -else - uci delete firewall.wgwforward - uci delete firewall.wwgforward - uci delete firewall.lwgforward - uci delete firewall.wglforward - uci commit firewall -fi -/etc/init.d/firewall restart - -SERVE=$(uci get wireguard."$WG".client) -if [ $SERVE = "0" ]; then - ifdown wg1 - uci set wireguard.settings.server="0" - uci delete network.wg1 - uci set network.wg1=interface - uci set network.wg1.proto="wireguard" - uci set network.wg1.auto="0" - uci set network.wg1.private_key="" - uci set network.wg1.listen_port="" - uci add_list network.wg1.addresses="" - uci commit network -else - INTER=$(uci -q get wireguard."$WG".wginter) - if [ -z "$INTER" ]; then - INTER=0 - fi - ifdown wg$INTER - uci set wireguard.settings.client="0" - uci delete network.wg$INTER - uci set network.wg$INTER=interface - uci set network.wg$INTER.proto="wireguard" - uci set network.wg$INTER.auto="0" - uci set network.wg$INTER.private_key="" - uci set network.wg$INTER.listen_port="" - uci add_list network.wg$INTER.addresses="" - uci commit network -fi -UDP=$(uci get wireguard."$WG".udptunnel) -if [ $UDP = 1 ]; then - PID=$(ps |grep "udptunnel" | grep -v grep |head -n 1 | awk '{print $1}') - kill -9 $PID -fi - -uci set wireguard."$WG".active="0" -uci commit wireguard - -/etc/init.d/wireguard stop \ No newline at end of file diff --git a/rooter/0optionalapps/ext-wireguard/files/usr/lib/wireguard/text.sh b/rooter/0optionalapps/ext-wireguard/files/usr/lib/wireguard/text.sh deleted file mode 100644 index 2f5a622..0000000 --- a/rooter/0optionalapps/ext-wireguard/files/usr/lib/wireguard/text.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh -. /lib/functions.sh - -log() { - logger -t "Wireguard TextConf" "$@" -} - -conf1=$1 -conf=$(echo $conf1) -conf=$(echo "$conf" | tr "?" "~") - -boot=$(echo "$conf" | cut -d~ -f1) -iname=$(echo "$conf" | cut -d~ -f2) -conf=$(echo "$conf1" | tr "?" "~") -confile=$(echo "$conf" | cut -d~ -f3) - -echo "$confile" > /tmp/confile - -/usr/lib/wireguard/conf.sh $iname /tmp/confile $boot \ No newline at end of file diff --git a/rooter/0optionalapps/ext-wireguard/files/www/luci-static/resources/icons/wireguard.png b/rooter/0optionalapps/ext-wireguard/files/www/luci-static/resources/icons/wireguard.png deleted file mode 100644 index 34f85d8..0000000 Binary files a/rooter/0optionalapps/ext-wireguard/files/www/luci-static/resources/icons/wireguard.png and /dev/null differ diff --git a/rooter/0optionalapps/ext-wireguard/files/www/luci-static/resources/icons/wireguard_disabled.png b/rooter/0optionalapps/ext-wireguard/files/www/luci-static/resources/icons/wireguard_disabled.png deleted file mode 100644 index ccfb7ae..0000000 Binary files a/rooter/0optionalapps/ext-wireguard/files/www/luci-static/resources/icons/wireguard_disabled.png and /dev/null differ diff --git a/rooter/0optionalapps/ext-zerotier/Makefile b/rooter/0optionalapps/ext-zerotier/Makefile deleted file mode 100644 index b7cfa94..0000000 --- a/rooter/0optionalapps/ext-zerotier/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -#Owned by DairyMan@Whirlpool -# -#Copyright GNU act. -include $(TOPDIR)/rules.mk - -PKG_NAME:=ext-zerotier -PKG_VERSION:=4.500 -PKG_RELEASE:=1 - -PKG_MAINTAINER:=Created by DM/makefile by Cobia@whirlpool -include $(INCLUDE_DIR)/package.mk - -define Package/ext-zerotier - SECTION:=utils - CATEGORY:=ROOter - SUBMENU:=Optional Applications - DEPENDS:=+zerotier - TITLE:=Install scripts for Zerotier - PKGARCH:=all -endef - -define Package/ext-zerotier/description - Install scripts for Zerotier -endef - - -define Build/Compile -endef - -define Package/ext-zerotier/install - $(CP) ./files/* $(1)/ -endef - -$(eval $(call BuildPackage,ext-zerotier)) diff --git a/rooter/0optionalapps/ext-zerotier/files/etc/init.d/zerofire b/rooter/0optionalapps/ext-zerotier/files/etc/init.d/zerofire deleted file mode 100644 index 05b8693..0000000 --- a/rooter/0optionalapps/ext-zerotier/files/etc/init.d/zerofire +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh /etc/rc.common -. /lib/functions.sh -# Copyright (C) 2006 OpenWrt.org - -START=91 - -log() { - logger -t "ZeroTier Init.d : " "$@" -} - -check_config () { - WW=$(uci get firewall.zerozone) - if [ -z $WW ]; then - uci set firewall.zerozone=zone - uci set firewall.zerozone.name="zerotier" - uci set firewall.zerozone.forward="REJECT" - uci set firewall.zerozone.output="ACCEPT" - uci set firewall.zerozone.input="ACCEPT" - uci set firewall.zerozone.device="zt+" - uci set firewall.zerozone.masq="1" - uci set firewall.zerozone.mtu_fix="1" - - uci set firewall.zlzforward=forwarding - uci set firewall.zlzforward.dest="zerotier" - uci set firewall.zlzforward.src="lan" - - uci set firewall.zzlforward=forwarding - uci set firewall.zzlforward.dest="lan" - uci set firewall.zzlforward.src="zerotier" - uci commit firewall - /etc/init.d/firewall restart - fi -} - -start() { - check_config -} \ No newline at end of file diff --git a/rooter/0optionalapps/ext-zerotier/files/etc/uci-defaults/64-zerotier b/rooter/0optionalapps/ext-zerotier/files/etc/uci-defaults/64-zerotier deleted file mode 100644 index eee1ac9..0000000 --- a/rooter/0optionalapps/ext-zerotier/files/etc/uci-defaults/64-zerotier +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh /etc/rc.common - -id=$(uci -q get custom.zerotier.networkid) -uci delete zerotier.zerotier.join -uci add_list zerotier.zerotier.join=$id -uci commit zerotier -/etc/init.d/zerotier restart diff --git a/rooter/0optionalapps/ext-zerotier/files/usr/lib/lua/luci/controller/zerotier.lua b/rooter/0optionalapps/ext-zerotier/files/usr/lib/lua/luci/controller/zerotier.lua deleted file mode 100644 index 74c997b..0000000 --- a/rooter/0optionalapps/ext-zerotier/files/usr/lib/lua/luci/controller/zerotier.lua +++ /dev/null @@ -1,62 +0,0 @@ -module("luci.controller.zerotier", package.seeall) - -I18N = require "luci.i18n" -translate = I18N.translate - -function index() - local fs = require "nixio.fs" - local lock = luci.model.uci.cursor():get("custom", "menu", "full") - local multilock = luci.model.uci.cursor():get("custom", "multiuser", "multi") or "0" - local rootlock = luci.model.uci.cursor():get("custom", "multiuser", "root") or "0" - if (multilock == "0") or (multilock == "1" and rootlock == "1") then - if lock == "1" then - if fs.stat("/etc/config/zerotier") then - local page - if (multilock == "1" and rootlock == "1") then - page = entry({"admin", "adminmenu", "zerotier"}, template("zerotier/zerotier"), translate("Zerotier"), 7) - page.dependent = true - else - page = entry({"admin", "adminmenu", "zerotier"}, template("zerotier/zerotier"), translate("---Router ID"), 7) - page.dependent = true - end - end - end - end - - entry({"admin", "services", "getid"}, call("action_getid")) - entry({"admin", "services", "sendid"}, call("action_sendid")) - entry({"admin", "services", "get_ids"}, call("action_get_ids")) -end - -function action_getid() - local rv = {} - id = luci.model.uci.cursor():get("zerotier", "zerotier", "join") - rv["netid"] = id - secret = luci.model.uci.cursor():get("zerotier", "zerotier", "secret") - if secret == nil then - secret = "xxxxxxxxxx" - end - rv["routerid"] = string.sub(secret,1,10) - rv["password"] = luci.model.uci.cursor():get("custom", "zerotier", "password") - luci.http.prepare_content("application/json") - luci.http.write_json(rv) -end - -function action_sendid() - local set = luci.http.formvalue("set") - os.execute("/usr/lib/zerotier/netid.sh 1 " .. set) -end - -function action_get_ids() - local rv = {} - id = luci.model.uci.cursor():get("zerotier", "zerotier", "join") - rv["netid"] = id - secret = luci.model.uci.cursor():get("zerotier", "zerotier", "secret") - if secret ~= nil then - rv["routerid"] = string.sub(secret,1,10) - else - rv["routerid"] = "xxxxxxxxxx" - end - luci.http.prepare_content("application/json") - luci.http.write_json(rv) -end \ No newline at end of file diff --git a/rooter/0optionalapps/ext-zerotier/files/usr/lib/lua/luci/view/admin_status/index/zero.htm b/rooter/0optionalapps/ext-zerotier/files/usr/lib/lua/luci/view/admin_status/index/zero.htm deleted file mode 100644 index 47fd4b2..0000000 --- a/rooter/0optionalapps/ext-zerotier/files/usr/lib/lua/luci/view/admin_status/index/zero.htm +++ /dev/null @@ -1 +0,0 @@ -<%+zerotier/zerotier1%> \ No newline at end of file diff --git a/rooter/0optionalapps/ext-zerotier/files/usr/lib/lua/luci/view/zerotier/zerotier.htm b/rooter/0optionalapps/ext-zerotier/files/usr/lib/lua/luci/view/zerotier/zerotier.htm deleted file mode 100644 index 2e7e15b..0000000 --- a/rooter/0optionalapps/ext-zerotier/files/usr/lib/lua/luci/view/zerotier/zerotier.htm +++ /dev/null @@ -1,182 +0,0 @@ -<%+header%> -<% -local sys = require "luci.sys" -local utl = require "luci.util" -local fs = require "nixio.fs" - -function showicon(lck) - if lck == 0 then - return resource .. "/icons/unlock1.png" - else - return resource .. "/icons/lock1.png" - end -end - --%> - - - -
                -
                -

                <%:Router ID (Zerotier)%>

                -
                - - - - -
                - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                - -
                -
                -<%+footer%> \ No newline at end of file diff --git a/rooter/0optionalapps/ext-zerotier/files/usr/lib/lua/luci/view/zerotier/zerotier1.htm b/rooter/0optionalapps/ext-zerotier/files/usr/lib/lua/luci/view/zerotier/zerotier1.htm deleted file mode 100644 index dfb07b6..0000000 --- a/rooter/0optionalapps/ext-zerotier/files/usr/lib/lua/luci/view/zerotier/zerotier1.htm +++ /dev/null @@ -1,22 +0,0 @@ - - -
                - <%:Router Info%> - - - -
                <%:Network ID%><%:Loading%> Collecting data...
                <%:Router ID%>
                -
                - diff --git a/rooter/0optionalapps/ext-zerotier/files/usr/lib/zerotier/netid.sh b/rooter/0optionalapps/ext-zerotier/files/usr/lib/zerotier/netid.sh deleted file mode 100644 index 8993552..0000000 --- a/rooter/0optionalapps/ext-zerotier/files/usr/lib/zerotier/netid.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -. /lib/functions.sh - -log() { - logger -t "NetID" "$@" -} - -ID=$2 - -log "$ID" - -if [ $ID = "xxxxxxxxxxxxxxxx" ]; then - uci set zerotier.zerotier.enabled='0' -else - uci set zerotier.zerotier.enabled='1' -fi - -uci delete zerotier.zerotier.join -uci add_list zerotier.zerotier.join=$ID -uci commit zerotier -/etc/init.d/zerotier restart diff --git a/rooter/0optionalapps/extramenu/Makefile b/rooter/0optionalapps/extramenu/Makefile deleted file mode 100644 index 8896ae0..0000000 --- a/rooter/0optionalapps/extramenu/Makefile +++ /dev/null @@ -1,33 +0,0 @@ -#Owned by DairyMan@Whirlpool -# -#Copyright GNU act. -include $(TOPDIR)/rules.mk - -PKG_NAME:=extramenu -PKG_VERSION:=4.500 -PKG_RELEASE:=1 - -PKG_MAINTAINER:=Created by DM/makefile by Cobia@whirlpool -include $(INCLUDE_DIR)/package.mk - -define Package/extramenu - SECTION:=utils - CATEGORY:=ROOter - SUBMENU:=Optional Applications - TITLE:=Install scripts for Extra menus - PKGARCH:=all -endef - -define Package/extramenu/description - Install scripts for Extra menus -endef - - -define Build/Compile -endef - -define Package/extramenu/install - $(CP) ./files/* $(1)/ -endef - -$(eval $(call BuildPackage,extramenu)) diff --git a/rooter/0optionalapps/extramenu/files/etc/init.d/fullmenu b/rooter/0optionalapps/extramenu/files/etc/init.d/fullmenu deleted file mode 100644 index d4b7188..0000000 --- a/rooter/0optionalapps/extramenu/files/etc/init.d/fullmenu +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh /etc/rc.common - -START=88 - -log() { - logger -t "FULL MENU" "$@" -} - -start() -{ - df=$(uci -q get custom.menu.default) - if [ -z $df ]; then - df=0 - fi - uci set custom.menu.full=$df - uci set custom.menu.enabled='1' - uci commit custom -} diff --git a/rooter/0optionalapps/extramenu/files/usr/lib/fullmenu/setmenu.sh b/rooter/0optionalapps/extramenu/files/usr/lib/fullmenu/setmenu.sh deleted file mode 100644 index d5963e8..0000000 --- a/rooter/0optionalapps/extramenu/files/usr/lib/fullmenu/setmenu.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh -. /lib/functions.sh - -log() { - logger -t "Menu Change" "$@" -} - -full=$1 -source /etc/openwrt_release -twone=$(echo "$DISTRIB_RELEASE" | grep "21.02") - -if [ $full = "0" ]; then - fv="1" -else - fv="0" -fi -uci set custom.menu.full=$fv -uci commit custom \ No newline at end of file diff --git a/rooter/0optionalapps/extramenu/files/usr/lib/lua/luci/controller/fullmenu.lua b/rooter/0optionalapps/extramenu/files/usr/lib/lua/luci/controller/fullmenu.lua deleted file mode 100644 index 67488c4..0000000 --- a/rooter/0optionalapps/extramenu/files/usr/lib/lua/luci/controller/fullmenu.lua +++ /dev/null @@ -1,39 +0,0 @@ -module("luci.controller.fullmenu", package.seeall) - -I18N = require "luci.i18n" -translate = I18N.translate - -function index() - local page - entry({"admin", "adminmenu"}, firstchild(), translate("Administration"), 24).dependent=false - local df = luci.model.uci.cursor():get("custom", "menu", "default") - if df == '0' then - local multilock = luci.model.uci.cursor():get("custom", "multiuser", "multi") or "0" - local rootlock = luci.model.uci.cursor():get("custom", "multiuser", "root") or "0" - if (multilock == "0") or (multilock == "1" and rootlock == "1") then - page = entry({"admin", "adminmenu", "fullmenu"}, template("fullmenu/fullmenu"), translate("Unlock / Lock Menus"), 5) - page.dependent = true - end - end - - entry({"admin", "menu", "getmenu"}, call("action_getmenu")) - entry({"admin", "menu", "setmenu"}, call("action_setmenu")) - -end - -function action_getmenu() - local rv = {} - id = luci.model.uci.cursor():get("custom", "menu", "full") - rv["full"] = id - password = luci.model.uci.cursor():get("custom", "menu", "password") - rv["password"] = password - - luci.http.prepare_content("application/json") - luci.http.write_json(rv) -end - -function action_setmenu() - local set = luci.http.formvalue("set") - os.execute("/usr/lib/fullmenu/setmenu.sh " .. set) - -end \ No newline at end of file diff --git a/rooter/0optionalapps/extramenu/files/usr/lib/lua/luci/view/fullmenu/fullmenu.htm b/rooter/0optionalapps/extramenu/files/usr/lib/lua/luci/view/fullmenu/fullmenu.htm deleted file mode 100644 index 9511a60..0000000 --- a/rooter/0optionalapps/extramenu/files/usr/lib/lua/luci/view/fullmenu/fullmenu.htm +++ /dev/null @@ -1,181 +0,0 @@ -<%+header%> -<% -local sys = require "luci.sys" -local utl = require "luci.util" -local fs = require "nixio.fs" - -function showicon(lck) - if lck == 0 then - return resource .. "/icons/unlock1.png" - else - return resource .. "/icons/lock1.png" - end -end - --%> - - - -
                -
                -

                <%:Unlock or Lock Administrative Menus%>

                -
                - - - - -
                - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                - -
                -
                -<%+footer%> \ No newline at end of file diff --git a/rooter/0optionalapps/luci-app-dnsmasq-ipset/Makefile b/rooter/0optionalapps/luci-app-dnsmasq-ipset/Makefile deleted file mode 100644 index e6383bd..0000000 --- a/rooter/0optionalapps/luci-app-dnsmasq-ipset/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -#Owned by DairyMan@Whirlpool -# -#Copyright GNU act. -include $(TOPDIR)/rules.mk - -PKG_NAME:=luci-app-dnsmasq-ipset -PKG_VERSION:=1.000 -PKG_RELEASE:=1 - -PKG_MAINTAINER:=Created by DM/makefile by Cobia@whirlpool -include $(INCLUDE_DIR)/package.mk - -define Package/luci-app-dnsmasq-ipset - SECTION:=luci - CATEGORY:=LuCI - DEPENDS:=+dnsmasq-full - SUBMENU:=3. Applications - TITLE:=support for IP Set settings - PKGARCH:=all -endef - -define Package/luci-app-dnsmasq-ipset/description - Helper scripts for IP Set settings -endef - - -define Build/Compile -endef - -define Package/luci-app-dnsmasq-ipset/install - $(CP) ./files/* $(1)/ -endef - -$(eval $(call BuildPackage,luci-app-dnsmasq-ipset)) diff --git a/rooter/0optionalapps/luci-app-dnsmasq-ipset/files/etc/config/dnsmasq-ipset b/rooter/0optionalapps/luci-app-dnsmasq-ipset/files/etc/config/dnsmasq-ipset deleted file mode 100644 index 83ec840..0000000 --- a/rooter/0optionalapps/luci-app-dnsmasq-ipset/files/etc/config/dnsmasq-ipset +++ /dev/null @@ -1,5 +0,0 @@ -config ipsets - option ipset_name 'netflix' - option enabled '0' - list managed_domain 'netflix.com' - list managed_domain 'netflix.ca' \ No newline at end of file diff --git a/rooter/0optionalapps/luci-app-dnsmasq-ipset/files/etc/init.d/dnsmasq-ipset b/rooter/0optionalapps/luci-app-dnsmasq-ipset/files/etc/init.d/dnsmasq-ipset deleted file mode 100644 index a993efd..0000000 --- a/rooter/0optionalapps/luci-app-dnsmasq-ipset/files/etc/init.d/dnsmasq-ipset +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/sh /etc/rc.common -# Author Qier LU - -START=55 - -DNSMASQ="/etc/dnsmasq.conf" - -gen_config_file() { - local section="${1}" - config_get ipset_name "${section}" "ipset_name" - sname="#$ipset_name-1" - ename="#$ipset_name-2" - sed -i "/$sname/,/$ename/d" "$DNSMASQ" - config_get enabled "${section}" "enabled" - if [ -z $enabled ]; then - enabled=0 - fi - if [ ${enabled} -eq 0 ] - then - return - fi - - handle_domain() { - local domain="${1}" - ipline=$ipline"${domain}/" - } - - ipline="ipset=/" - echo "#$ipset_name-1" >> "$DNSMASQ" - config_list_foreach "${section}" "managed_domain" handle_domain - echo "$ipline${ipset_name}" >> "$DNSMASQ" - echo "#$ipset_name-2" >> "$DNSMASQ" - ipset -N -exist "$ipset_name" iphash - /etc/init.d/dnsmasq reload -} - -gen_config_files() { - config_load 'dnsmasq-ipset' - config_foreach gen_config_file 'ipsets' -} - -start() { - gen_config_files -} - -reload() { - sleep 5 - gen_config_files -} diff --git a/rooter/0optionalapps/luci-app-dnsmasq-ipset/files/usr/lib/lua/luci/controller/dnsmasq-ipset.lua b/rooter/0optionalapps/luci-app-dnsmasq-ipset/files/usr/lib/lua/luci/controller/dnsmasq-ipset.lua deleted file mode 100644 index d0a49b0..0000000 --- a/rooter/0optionalapps/luci-app-dnsmasq-ipset/files/usr/lib/lua/luci/controller/dnsmasq-ipset.lua +++ /dev/null @@ -1,12 +0,0 @@ - --- Auther Qier LU - -module("luci.controller.dnsmasq-ipset", package.seeall) - -function index() - if not nixio.fs.access("/etc/config/dnsmasq-ipset") then - return - end - - entry({"admin", "network", "dnsmasq-ipset"}, cbi("dnsmasq-ipset"), _("DNSmasq IP-Set"), 60).dependent = true -end diff --git a/rooter/0optionalapps/luci-app-dnsmasq-ipset/files/usr/lib/lua/luci/model/cbi/dnsmasq-ipset.lua b/rooter/0optionalapps/luci-app-dnsmasq-ipset/files/usr/lib/lua/luci/model/cbi/dnsmasq-ipset.lua deleted file mode 100644 index fe6fff5..0000000 --- a/rooter/0optionalapps/luci-app-dnsmasq-ipset/files/usr/lib/lua/luci/model/cbi/dnsmasq-ipset.lua +++ /dev/null @@ -1,24 +0,0 @@ --- Auther Qier LU - -local m, s, o, p - -m = Map("dnsmasq-ipset", translate("DNSmasq IPSet"), translate("IPSet lists for DNSMasq-full")) - -m.on_after_save = function(self) - luci.sys.call("/etc/init.d/dnsmasq-ipset reload &") -end - -s = m:section(TypedSection, "ipsets", translate("IPSet Lists")) -s.anonymous = true -s.addremove = true - -o = s:option(Value, "ipset_name", translate("IPSet Name")) -o.placeholder = "target ipset" -o.default = "rooter" -o.rmempty = false - -o = s:option(Flag, "enabled", translate("Enabled")) - -o = s:option(DynamicList, "managed_domain", translate("Managed Domain List")) - -return m diff --git a/rooter/0optionalapps/luci-app-hotspot/Makefile b/rooter/0optionalapps/luci-app-hotspot/Makefile deleted file mode 100644 index eedaaf3..0000000 --- a/rooter/0optionalapps/luci-app-hotspot/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -#Owned by DairyMan@Whirlpool -# -#Copyright GNU act. -include $(TOPDIR)/rules.mk - -PKG_NAME:=luci-app-hotspot -PKG_VERSION:=1.000 -PKG_RELEASE:=1 - -PKG_MAINTAINER:=Created by DM/makefile by Cobia@whirlpool -include $(INCLUDE_DIR)/package.mk - -define Package/luci-app-hotspot - SECTION:=luci - CATEGORY:=LuCI - DEPENDS:=+iw +iwinfo - SUBMENU:=3. Applications - TITLE:=support for Wifi Hotspot Manager - PKGARCH:=all -endef - -define Package/luci-app-hotspot/description - Helper scripts to enable Wifi Hotspot Manager -endef - - -define Build/Compile -endef - -define Package/luci-app-hotspot/install - $(CP) ./files/* $(1)/ -endef - -$(eval $(call BuildPackage,luci-app-hotspot)) diff --git a/rooter/0optionalapps/luci-app-hotspot/files/etc/config/travelmate b/rooter/0optionalapps/luci-app-hotspot/files/etc/config/travelmate deleted file mode 100644 index 23b3751..0000000 --- a/rooter/0optionalapps/luci-app-hotspot/files/etc/config/travelmate +++ /dev/null @@ -1,17 +0,0 @@ - -config travelmate 'global' - option trm_debug '1' - option trm_maxwait '20' - option trm_maxretry '3' - option trm_iw '1' - option trm_auto '1' - option radio0 '2.4 Ghz' - option radio1 '5.8 Ghz' - option radcnt '2' - option reconn '1' - option connecting '0' - option ssid '5' - option trm_enabled '0' - option lost '0' - option delay '15' - diff --git a/rooter/0optionalapps/luci-app-hotspot/files/etc/hotplug.d/iface/99-travelmate-iface b/rooter/0optionalapps/luci-app-hotspot/files/etc/hotplug.d/iface/99-travelmate-iface deleted file mode 100644 index c075669..0000000 --- a/rooter/0optionalapps/luci-app-hotspot/files/etc/hotplug.d/iface/99-travelmate-iface +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/sh - -wif=$(uci -q get travelmate.global.freq) -if [ "$ACTION" = ifup -a "$INTERFACE" = "wwan$wif" ]; then - exit 1 -fi - -if [ "$ACTION" = ifdown -a "$INTERFACE" = "wwan$wif" ]; then - wifilog "HOTSPOT" "hotplug (iface): action='$ACTION' interface='$INTERFACE'" - conn=$(uci -q get travelmate.global.connecting) - if [ "$conn" != "1" ]; then - uci -q set wireless.wwan$wif.ssid="Hotspot Manager Interface" - uci -q set wireless.wwan$wif.encryption="none" - uci -q set wireless.wwan$wif.key= - uci -q set wireless.wwan$wif.disabled=1 - uci -q commit wireless - wifilog "HOTSPOT" "Lost Connection" - ubus call network reload - disa=$(uci -q get travelmate.global.ssid) - # check for disconnect or lost connection - if [ "$disa" != "7" ]; then - uci set travelmate.global.ssid="9" # lost connection - reconn=$(uci -q get travelmate.global.reconn) - if [ "$reconn" != "0" ]; then - lost=$(uci -q get travelmate.global.lost) - if [ $reconn -eq 99 ]; then - lost="1" - fi - if [ $lost -le $reconn ]; then - let lost=$lost+1 - uci set travelmate.global.lost=$lost - uci set travelmate.global.delay="30" - uci commit travelmate - sleep 10 - /usr/lib/hotspot/travelmate.sh & - exit 0 - fi - fi - fi - uci set travelmate.global.trm_enabled="0" - uci commit travelmate - fi - - debug="$(uci -q get travelmate.global.trm_debug)" - if [ $debug = "1" ]; then - wifilog "HOTSPOT" "hotplug (iface): action='$ACTION' interface='$INTERFACE'" - fi -fi \ No newline at end of file diff --git a/rooter/0optionalapps/luci-app-hotspot/files/etc/init.d/travelmate b/rooter/0optionalapps/luci-app-hotspot/files/etc/init.d/travelmate deleted file mode 100644 index 565844b..0000000 --- a/rooter/0optionalapps/luci-app-hotspot/files/etc/init.d/travelmate +++ /dev/null @@ -1,94 +0,0 @@ -#!/bin/sh /etc/rc.common - -. /lib/functions.sh - -START=98 - -log() { - wifilog "Hotspot Initialize" "$@" -} - -do_zone() { - local config=$1 - local name - local network - - config_get name $1 name - config_get network $1 network - newnet="$network" - if [ $name = wan ]; then - WWAN=$(echo "$network" | grep "wwan2") - if [ -z "$WWAN" ]; then - newnet="$newnet wwan2 wwan5" - uci_set firewall "$config" network "$newnet" - uci_commit firewall - /etc/init.d/firewall restart - fi - fi -} - -do_radio() { - local config=$1 - local channel - local hwmode - - config_get channel $1 channel - config_get hwmode $1 hwmode - if [ $hwmode = "11g" ]; then - w2=$(uci -q get wireless.wwan2.device) - if [ -z $w2 ]; then - uci set wireless.wwan2=wifi-iface - uci set wireless.wwan2.device=$config - uci set wireless.wwan2.network="wwan2" - uci set wireless.wwan2.mode="sta" - uci set wireless.wwan2.ssid="Hotspot Manager Interface" - uci set wireless.wwan2.encryption="none" - uci set wireless.wwan2.disabled="1" - uci commit wireless - fi - else - w2=$(uci -q get wireless.wwan5.device) - if [ -z $w2 ]; then - uci set wireless.wwan5=wifi-iface - uci set wireless.wwan5.device=$config - uci set wireless.wwan5.network="wwan5" - uci set wireless.wwan5.mode="sta" - uci set wireless.wwan5.ssid="Hotspot Manager Interface" - uci set wireless.wwan5.encryption="none" - uci set wireless.wwan5.disabled="1" - uci commit wireless - fi - fi -} - -start() -{ -log "Hotspot Firewall" - - PRO=$(uci get network.wwan2.proto) - if [ -z $PRO ]; then - uci set network.wwan2=interface - uci set network.wwan2.proto=dhcp - uci set network.wwan2.metric='2' - uci set network.wwan26=interface - uci set network.wwan26.proto=dhcpv6 - uci set network.wwan26.metric='2' - uci set network.wwan5=interface - uci set network.wwan5.proto=dhcp - uci set network.wwan5.metric='2' - uci set network.wwan56=interface - uci set network.wwan56.proto=dhcpv6 - uci set network.wwan56.metric='2' - uci commit network - fi - config_load firewall - config_foreach do_zone zone - config_load wireless - config_foreach do_radio wifi-device - uci set travelmate.global.lost="0" - uci set travelmate.global.delay="30" - uci set travelmate.global.state='0' - uci commit travelmate -} - - diff --git a/rooter/0optionalapps/luci-app-hotspot/files/etc/init.d/zhot b/rooter/0optionalapps/luci-app-hotspot/files/etc/init.d/zhot deleted file mode 100644 index f610bee..0000000 --- a/rooter/0optionalapps/luci-app-hotspot/files/etc/init.d/zhot +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh /etc/rc.common - -. /lib/functions.sh - -START=99 - -log() { - wifilog "Z-Hotspot " "$@" -} - -start() -{ - uci set travelmate.global.lost="0" - uci set travelmate.global.delay="30" - uci commit travelmate - /usr/lib/hotspot/travelmate.sh & -} diff --git a/rooter/0optionalapps/luci-app-hotspot/files/lib/upgrade/keep.d/hotspot b/rooter/0optionalapps/luci-app-hotspot/files/lib/upgrade/keep.d/hotspot deleted file mode 100644 index 5ed46ef..0000000 --- a/rooter/0optionalapps/luci-app-hotspot/files/lib/upgrade/keep.d/hotspot +++ /dev/null @@ -1 +0,0 @@ -/etc/hotspot diff --git a/rooter/0optionalapps/luci-app-hotspot/files/usr/bin/hkillall b/rooter/0optionalapps/luci-app-hotspot/files/usr/bin/hkillall deleted file mode 100644 index 3802082..0000000 --- a/rooter/0optionalapps/luci-app-hotspot/files/usr/bin/hkillall +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -LOOKFOR=$1 -KILLLIST=$(ps | grep $LOOKFOR) -echo "$KILLLIST" | while read line; do - if `echo "$line" | grep "/$LOOKFOR" > /dev/null` ; then - PIDV=$(echo $line | grep -o "^[0-9]\{1,5\}" | grep -o "[0-9]\{1,5\}") - kill $PIDV - fi -done \ No newline at end of file diff --git a/rooter/0optionalapps/luci-app-hotspot/files/usr/lib/hotspot/band.sh b/rooter/0optionalapps/luci-app-hotspot/files/usr/lib/hotspot/band.sh deleted file mode 100644 index a214c8a..0000000 --- a/rooter/0optionalapps/luci-app-hotspot/files/usr/lib/hotspot/band.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh - -BAND=$1 -if [ $BAND = "1" ]; then - BAND=2 -else - BAND=5 -fi - -/usr/lib/hotspot/enable.sh 0 - -uci set travelmate.global.freq=$BAND -uci set travelmate.global.ssid="6" -uci commit travelmate - -result=`ps | grep -i "travelmate.sh" | grep -v "grep" | wc -l` -if [ $result -ge 1 ] -then - wifilog "Band Change" "Travelmate already running" -else - /usr/lib/hotspot/travelmate.sh & -fi -uci set travelmate.global.ssid="Hotspot Manager Interface" -uci commit travelmate -exit 0 \ No newline at end of file diff --git a/rooter/0optionalapps/luci-app-hotspot/files/usr/lib/hotspot/copyhot.sh b/rooter/0optionalapps/luci-app-hotspot/files/usr/lib/hotspot/copyhot.sh deleted file mode 100644 index 83d87ef..0000000 --- a/rooter/0optionalapps/luci-app-hotspot/files/usr/lib/hotspot/copyhot.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -if [ -f "/tmp/hot" ]; then - rm -f /etc/hotspot - while IFS='|' read -r ssid encrypt key flag - do - echo $ssid"|"$encrypt"|"$key >> /etc/hotspot - done <"/tmp/hot" -fi diff --git a/rooter/0optionalapps/luci-app-hotspot/files/usr/lib/hotspot/dis_hot.sh b/rooter/0optionalapps/luci-app-hotspot/files/usr/lib/hotspot/dis_hot.sh deleted file mode 100644 index 93e2f67..0000000 --- a/rooter/0optionalapps/luci-app-hotspot/files/usr/lib/hotspot/dis_hot.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh -. /lib/functions.sh - -wif=$(uci -q get travelmate.global.freq) -rm -f /tmp/hotman -uci set travelmate.global.ssid="7" -uci set travelmate.global.state='' -uci set travelmate.global.bssid="" -uci set travelmate.global.key='' -uci commit travelmate -uci -q set wireless.wwan$wif.disabled=1 -uci set wireless.wwan$wif.ssid="Hotspot Manager Interface" -uci -q commit wireless -/etc/init.d/network reload - diff --git a/rooter/0optionalapps/luci-app-hotspot/files/usr/lib/hotspot/enable.sh b/rooter/0optionalapps/luci-app-hotspot/files/usr/lib/hotspot/enable.sh deleted file mode 100644 index e2b645f..0000000 --- a/rooter/0optionalapps/luci-app-hotspot/files/usr/lib/hotspot/enable.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh -. /lib/functions.sh - -SET=$1 - -uci set travelmate.global.trm_enabled=$SET -uci commit travelmate - -wif=$(uci -q get travelmate.global.freq) - -if [ $SET = "1" ]; then - wifilog "Enable" "Connect Hotspot" - AU=$(uci get travelmate.global.trm_auto) - hkillall travelmate.sh - if [ $AU = "1" ]; then - uci set travelmate.global.ssid="8" - uci set travelmate.global.bssid="" - uci set travelmate.global.state='' - uci set travelmate.global.key='' - uci commit travelmate - uci -q set wireless.wwan$wif.encryption="none" - uci -q set wireless.wwan$wif.key= - uci set wireless.wwan$wif.ssid="Hotspot Manager Interface" - uci -q commit wireless - /usr/lib/hotspot/travelmate.sh & - fi -else - wifilog "Enable" "Disconnect Hotspot" - hkillall travelmate.sh - rm -f /tmp/hotman - uci set travelmate.global.ssid="7" - uci set travelmate.global.state="0" - uci set travelmate.global.key='' - uci set travelmate.global.bssid="" - uci set travelmate.global.trm_enabled="0" - uci commit travelmate - uci -q set wireless.wwan$wif.disabled=1 - uci set wireless.wwan$wif.ssid="Hotspot Manager Interface" - uci -q commit wireless - ubus call network.interface.wwan down - ubus call network reload -fi \ No newline at end of file diff --git a/rooter/0optionalapps/luci-app-hotspot/files/usr/lib/hotspot/getssid.sh b/rooter/0optionalapps/luci-app-hotspot/files/usr/lib/hotspot/getssid.sh deleted file mode 100644 index c42fb01..0000000 --- a/rooter/0optionalapps/luci-app-hotspot/files/usr/lib/hotspot/getssid.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -wif=$(uci -q get travelmate.global.freq) -RADIO=$(uci get wireless.wwan$wif.device) -ap_list="$(ubus -S call network.wireless status | jsonfilter -e "@.$RADIO.interfaces[@.config.mode=\"ap\"].ifname")" -if [ -z $ap_list ]; then - wifi up - ap_list="$(ubus -S call network.wireless status | jsonfilter -e "@.$RADIO.interfaces[@.config.mode=\"ap\"].ifname")" -fi - -rm -f /tmp/ssidlist -for ap in ${ap_list} -do - iwinfo "${ap}" scan >> /tmp/ssidlist -done diff --git a/rooter/0optionalapps/luci-app-hotspot/files/usr/lib/hotspot/inrange.sh b/rooter/0optionalapps/luci-app-hotspot/files/usr/lib/hotspot/inrange.sh deleted file mode 100644 index 77df595..0000000 --- a/rooter/0optionalapps/luci-app-hotspot/files/usr/lib/hotspot/inrange.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/sh -. "/lib/functions.sh" - -log() { - wifilog "In Range" "$@" -} - -rm -f /tmp/hot1 -cnt=0 -trm_ifstatus="false" -while [ ${cnt} -lt 20 ] -do - trm_ifstatus="$(ubus -S call network.wireless status | jsonfilter -l1 -e '@.*.up')" - if [ "${trm_ifstatus}" = "true" ] - then - break - fi - cnt=$((cnt+1)) - sleep 1 -done - -wif=$(uci -q get travelmate.global.freq) -RADIO=$(uci get wireless.wwan$wif.device) -ap_list="$(ubus -S call network.wireless status | jsonfilter -e "@.$RADIO.interfaces[@.config.mode=\"ap\"].ifname")" - -trm_scanner="$(which iw)" -for ap in ${ap_list} -do - ssid_list="$(${trm_scanner} dev "${ap}" scan 2>/dev/null > /tmp/scan - cat /tmp/scan | awk '/SSID: /{if(!seen[$0]++){printf "\"";for(i=2; i<=NF; i++)if(i==2)printf $i;else printf " "$i;printf "\" "}}')" - - if [ -n "${ssid_list}" ] - then - if [ -f "/etc/hotspot" ]; then - while IFS='|' read -r ssid encrypt key - do - ssidq="\"$ssid\"" - if [ -n "$(printf "${ssid_list}" | grep -Fo "${ssidq}")" ] - then - echo $ssid"|"$encrypt"|"$key"|1" >> /tmp/hot1 - else - echo $ssid"|"$encrypt"|"$key"|0" >> /tmp/hot1 - fi - done <"/etc/hotspot" - fi - else - if [ -f "/etc/hotspot" ]; then - while IFS='|' read -r ssid encrypt key - do - echo $ssid"|"$encrypt"|"$key"|0" >> /tmp/hot1 - done <"/etc/hotspot" - fi - fi -done -if [ -f "/tmp/hot1" ]; then - mv -f /tmp/hot1 /tmp/hot -fi - - diff --git a/rooter/0optionalapps/luci-app-hotspot/files/usr/lib/hotspot/manual.sh b/rooter/0optionalapps/luci-app-hotspot/files/usr/lib/hotspot/manual.sh deleted file mode 100644 index 63323d4..0000000 --- a/rooter/0optionalapps/luci-app-hotspot/files/usr/lib/hotspot/manual.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -MAN="$1" - -hkillall travelmate.sh - -/usr/lib/hotspot/dis_hot.sh -echo "$MAN" > /tmp/hotman -/usr/lib/hotspot/travelmate.sh & - diff --git a/rooter/0optionalapps/luci-app-hotspot/files/usr/lib/hotspot/mode.sh b/rooter/0optionalapps/luci-app-hotspot/files/usr/lib/hotspot/mode.sh deleted file mode 100644 index cbc9571..0000000 --- a/rooter/0optionalapps/luci-app-hotspot/files/usr/lib/hotspot/mode.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -SET=$1 - -rm -f /tmp/hotman -uci set travelmate.global.trm_auto=$SET -uci commit travelmate - -if [ $SET = "1" ]; then - result=`ps | grep -i "travelmate.sh" | grep -v "grep" | wc -l` - if [ $result -ge 1 ] - then - wifilog "HOTSPOT" "Travelmate already running" - else - /usr/lib/hotspot/travelmate.sh & - fi -else - hkillall travelmate.sh -fi \ No newline at end of file diff --git a/rooter/0optionalapps/luci-app-hotspot/files/usr/lib/hotspot/reconn.sh b/rooter/0optionalapps/luci-app-hotspot/files/usr/lib/hotspot/reconn.sh deleted file mode 100644 index cef0a60..0000000 --- a/rooter/0optionalapps/luci-app-hotspot/files/usr/lib/hotspot/reconn.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -. /lib/functions.sh - -log() { - logger -t "Reconnect" "$@" -} - -reconn=$1 -log "$reconn" -uci set travelmate.global.reconn=$reconn -uci commit travelmate \ No newline at end of file diff --git a/rooter/0optionalapps/luci-app-hotspot/files/usr/lib/hotspot/travelmate.sh b/rooter/0optionalapps/luci-app-hotspot/files/usr/lib/hotspot/travelmate.sh deleted file mode 100644 index 81574d7..0000000 --- a/rooter/0optionalapps/luci-app-hotspot/files/usr/lib/hotspot/travelmate.sh +++ /dev/null @@ -1,429 +0,0 @@ -#!/bin/sh - -. /lib/functions.sh - -# travelmate, a wlan connection manager for travel router -# written by Dirk Brenken (dev@brenken.org) - -# This is free software, licensed under the GNU General Public License v3. -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -# prepare environment -# -LC_ALL=C -PATH="/usr/sbin:/usr/bin:/sbin:/bin" -trm_ver="0.3.0" -trm_enabled=1 -trm_debug=0 -trm_maxwait=20 -trm_maxretry=1 -trm_iw=1 -trm_auto=$(uci -q get travelmate.global.trm_auto) - -check_wwan() { - uci set travelmate.global.ssid="8" - wif=$(uci -q get travelmate.global.freq) - if [ -z "$wif" ]; then - uci set travelmate.global.freq="2" - fi - uci commit travelmate - while [ ! -e /etc/config/wireless ] - do - sleep 1 - done - sleep 3 - f_check "ap" - cntx=0 - while [ "${trm_ifstatus}" != "true" ]; do - sleep 1 - f_check "ap" - let cntx=cntx+1 - if [ $cntx -ge 20 ]; then - break - fi - done - f_log "info" "AP Status ::: $trm_ifstatus" -} - -count_radio() { - local config=$1 - local channel - - config_get channel $1 channel - if [ $channel -gt 15 ]; then - uci set travelmate.global.radio5="5.8 Ghz" - else - uci set travelmate.global.radio2="2.4 Ghz" - fi - let radcnt=radcnt+1 -} - -check_radio() { - radcnt=0 - config_load wireless - config_foreach count_radio wifi-device - uci set travelmate.global.radcnt=$radcnt - uci commit travelmate -} - -f_envload() -{ - # source required system libraries - # - if [ -r "/lib/functions.sh" ] - then - . "/lib/functions.sh" - else - f_log "error" "required system library not found" - fi - - # load uci config and check 'enabled' option - # - option_cb() - { - local option="${1}" - local value="${2}" - eval "${option}=\"${value}\"" - } - config_load travelmate - - if [ ${trm_enabled} -ne 1 ] - then - f_log "info " "status ::: Hotspot Manager is currently disabled" - exit 0 - fi - - # check for preferred wireless tool - # - if [ ${trm_iw} -eq 1 ] - then - trm_scanner="$(which iw)" - else - trm_scanner="$(which iwinfo)" - fi - if [ -z "${trm_scanner}" ] - then - f_log "error" "status ::: no wireless tool for wlan scanning found, please install 'iw' or 'iwinfo'" - fi -} - -# function to bring down all STA interfaces -# -f_prepare() -{ - local config="${1}" - local mode="$(uci -q get wireless."${config}".mode)" - local network="$(uci -q get wireless."${config}".network)" - local disabled="$(uci -q get wireless."${config}".disabled)" - - if [ "${mode}" = "sta" ] && [ -n "${network}" ] - then - trm_stalist="${trm_stalist} ${config}_${network}" - if [ -z "${disabled}" ] || [ "${disabled}" = "0" ] - then - uci -q set wireless."${config}".disabled=1 - f_log "debug" "prepare ::: config: ${config}, interface: ${network}" - fi - fi -} - -f_check() -{ - local ifname cnt=0 mode="${1}" - trm_ifstatus="false" - - while [ ${cnt} -lt ${trm_maxwait} ] - do - wif=$(uci -q get travelmate.global.freq) - RADIO=$(uci get wireless.wwan$wif.device) - ifname="$(ubus -S call network.wireless status | jsonfilter -l 1 -e "@.$RADIO.interfaces[@.config.mode=\"${mode}\"].ifname")" - if [ -z $ifname ]; then - break - fi - if [ "${mode}" = "sta" ] - then - trm_ifstatus="$(ubus -S call network.interface dump | jsonfilter -e "@.interface[@.device=\"${ifname}\"].up")" - else - trm_ifstatus="$(ubus -S call network.wireless status | jsonfilter -l1 -e '@.*.up')" - fi - if [ "${trm_ifstatus}" = "true" ] - then - break - fi - cnt=$((cnt+1)) - sleep 1 - done - f_log "debug" "check ::: ${mode} name: ${ifname}, status: ${trm_ifstatus}, count: ${cnt}" -} - -# function to write to syslog -# -f_log() -{ - local class="${1}" - local log_msg="${2}" - - if [ -n "${log_msg}" ] && ([ "${class}" != "debug" ] || [ ${trm_debug} -eq 1 ]) - then - wifilog "HOTSPOT-[${trm_ver}] ${class}" "${log_msg}" - if [ "${class}" = "error" ] - then - wif=$(uci -q get travelmate.global.freq) - uci set travelmate.global.ssid="1" - uci commit travelmate - uci -q set wireless.wwan@wif.ssid="Hotspot Manager Interface" - uci -q set wireless.wwan$wif.encryption="none" - uci -q set wireless.wwan$wif.key= - uci -q commit wireless - #exit 255 - fi - fi -} - -ssid_list="" -ap_list="" -trm_stalist="" - -f_working_ap() { - f_check "ap" - wif=$(uci -q get travelmate.global.freq) - RADIO=$(uci get wireless.wwan$wif.device) - ap_list="$(ubus -S call network.wireless status | jsonfilter -e "@.$RADIO.interfaces[@.config.mode=\"ap\"].ifname")" - f_log "debug" "main ::: ap-list: ${ap_list}, sta-list: ${trm_stalist}" - if [ -z "${ap_list}" ] || [ -z "${trm_stalist}" ] - then - sleep 3 - f_check "ap" - ap_list="$(ubus -S call network.wireless status | jsonfilter -e "@.$RADIO.interfaces[@.config.mode=\"ap\"].ifname")" - f_log "debug" "main ::: ap-list: ${ap_list}, sta-list: ${trm_stalist}" - fi -} - -f_scan_ap() { - wif=$(uci -q get travelmate.global.freq) - radio=$(uci get wireless.wwan$wif.device) - # scan using AP radio - trm_iwinfo="$(command -v iwinfo)" - trm_maxscan="10" - scan_dev="$(ubus -S call network.wireless status 2>/dev/null | jsonfilter -q -l1 -e "@.${radio}.interfaces[0].ifname")" - ssid_list="$("${trm_iwinfo}" "${scan_dev:-${radio}}" scan 2>/dev/null | - awk 'BEGIN{FS="[[:space:]]"}/Address:/{var1=$NF}/ESSID:/{var2="";for(i=12;i<=NF;i++)if(var2==""){var2=$i}else{var2=var2" "$i}} - /Quality:/{split($NF,var0,"/")}/Encryption:/{if($NF=="none"){var3="+"}else{var3="-"}; - printf "%i %s %s %s\n",(var0[1]*100/var0[2]),var3,var1,var2}' | sort -rn | head -qn "${trm_maxscan}")" -} - -f_main() -{ - local config network ssid cnt=0 - wif=$(uci -q get travelmate.global.freq) - - trm_stalist="" - # check if wwan is connected - f_check "sta" - if [ "${trm_ifstatus}" == "true" ]; then - wifi down $(uci -q get wireless.wwan$wif.device) - f_check "sta" - f_log "info" "STA ${trm_ifstatus}" - while [ "${trm_ifstatus}" == "true" ]; do - sleep 1 - f_check "sta" - done - fi - if [ "${trm_ifstatus}" != "true" ] # not connected - then - uci set travelmate.global.state='1' - uci commit travelmate - f_check "ap" - f_log "info" "AP ${trm_ifstatus}" - if [ "${trm_ifstatus}" != "true" ]; then - wifi up $(uci -q get wireless.wwan$wif.device) - f_check "ap" - while [ "${trm_ifstatus}" != "true" ]; do - sleep 1 - f_check "ap" - done - fi - uci set travelmate.global.bssid="" - uci set travelmate.global.ssid="2" - uci commit travelmate - uci -q set wireless.wwan$wif.ssid="Hotspot Manager Interface" - uci -q set wireless.wwan$wif.encryption="none" - uci -q set wireless.wwan$wif.key= - uci -q commit wireless - ubus call network.interface.wwan$wif up - ubus call network reload - wifi up $(uci -q get wireless.wwan$wif.device) - sleep 5 - - # set disabled for wwan iface - config_load wireless - config_foreach f_prepare wifi-iface - if [ -n "$(uci -q changes wireless)" ] - then - uci -q commit wireless - ubus call network reload - fi - # check if AP working - f_working_ap - # AP or STA not working - if [ -z "${ap_list}" ] || [ -z "${trm_stalist}" ] - then - f_log "error" "main ::: no usable AP/STA configuration found" - - else - # single AP in list - for ap in ${ap_list} - do - #f_scan_ap - # repeat scan and connection - cnt=0 - delay=10 - reconn=$(uci -q get travelmate.global.reconn) - while [ ${cnt} -lt $reconn ] - do - f_log "info" " Retry Count ${cnt}" - if [ $reconn -eq 99 ]; then - cnt=0 - fi - f_scan_ap - f_log "info" " SSID List ${ssid_list}" - # get list of Hotspots present - if [ -n "${ssid_list}" ]; then - if [ "$trm_auto" = "1" ]; then - FILE="/etc/hotspot" - else - FILE="/tmp/hotman" - fi - if [ -f "${FILE}" ]; then - # read list of selected Hotspots - while IFS='|' read -r ssid encrypt key - do - ssidq="\"$ssid\"" - # see if in scan list - if [ -n "$(printf "${ssid_list}" | grep -Fo "${ssidq}")" ]; then - # connect to Hotspot - uci set travelmate.global.bssid="$ssid" - uci set travelmate.global.ssid=">>> $ssid" - uci set travelmate.global.connecting="1" - uci commit travelmate - uci -q set wireless.wwan$wif.ssid="$ssid" - uci -q set wireless.wwan$wif.encryption=$encrypt - uci -q set wireless.wwan$wif.key=$key - uci -q set wireless.wwan$wif.disabled=0 - uci -q commit wireless - wifi up $(uci -q get wireless.wwan$wif.device) - ubus call network.interface.wwan$wif up - ubus call network reload - f_log "info " "main ::: wwan interface connected to uplink ${ssid}" - sleep 5 - # wait and check for good connection - f_check "ap" - f_log "info" "AP Status ::: $trm_ifstatus" - cntx=0 - while [ "${trm_ifstatus}" != "true" ]; do - sleep 1 - f_check "ap" - let cntx=cntx+1 - if [ $cntx -ge $delay ]; then - break - fi - f_log "info" "AP Status ::: $trm_ifstatus" - done - cntx=0 - #delay=$(uci -q get travelmate.global.delay) - f_check "sta" - f_log "info" "STA Status ${trm_ifstatus}" - while [ "${trm_ifstatus}" != "true" ]; do - sleep 1 - f_check "sta" - let cntx=cntx+1 - if [ $cntx -ge $delay ]; then - break - fi - f_log "info" "STA Status ${trm_ifstatus}" - done - - if [ "${trm_ifstatus}" = "true" ]; then - uci set travelmate.global.ssid="$ssid" - uci set travelmate.global.connecting="0" - uci set travelmate.global.lost="0" - uci set travelmate.global.state='2' - uci set travelmate.global.key=$key - uci set travelmate.global.trm_auto="1" - uci commit travelmate - # connection good - f_log "info" "Connected $ssid" - exit 0 - fi - # bad connection try next Hotspot in list - uci set travelmate.global.bssid="" - uci set travelmate.global.ssid="3" - uci commit travelmate - uci -q set wireless.wwan$wif.ssid="Hotspot Manager Interface" - uci -q set wireless.wwan$wif.encryption="none" - uci -q set wireless.wwan$wif.key= - uci -q set wireless.wwan$wif.disabled=1 - uci -q commit wireless - ubus call network.interface.wwan$wif down - ubus call network reload - f_log "info" "Try next in list" - fi - done <"${FILE}" - wifi up $(uci -q get wireless.wwan$wif.device) - f_check "ap" - while [ "${trm_ifstatus}" != "true" ]; do - f_check "ap" - sleep 1 - done - fi - fi - # No connection to any in list - cnt=$((cnt+1)) - if [ $reconn -gt 0 ]; then - if [ ${cnt} -lt $reconn ]; then - f_log "info " "Sleep before retrying" - sleep 30 - fi - fi - # repeat scan and connect - done - done - fi - # unable to connect - if [ "$trm_auto" = "1" ]; then - uci set travelmate.global.ssid="4" - else - uci set travelmate.global.ssid="5" - fi - reconn=$(uci -q get travelmate.global.reconn) - lost=$(uci -q get travelmate.global.lost) - if [ $reconn -eq 99 ]; then - lost="1" - fi - if [ $lost -gt $reconn ]; then - uci set travelmate.global.ssid="5" - fi - uci set travelmate.global.trm_enabled="0" - uci set travelmate.global.connecting="0" - uci set travelmate.global.lost="0" - uci set travelmate.global.state='0' - uci set travelmate.global.bssid="" - uci set travelmate.global.trm_auto="1" - uci commit travelmate - uci -q set wireless.wwan$wif.ssid="Hotspot Manager Interface" - uci -q set wireless.wwan$wif.encryption="none" - uci -q set wireless.wwan$wif.key= - uci -q commit wireless - f_log "info " "main ::: no wwan uplink found" - fi - # already connected - exit 0 -} - -check_wwan -check_radio -f_envload -f_main - -exit 0 \ No newline at end of file diff --git a/rooter/0optionalapps/luci-app-hotspot/files/usr/lib/lua/luci/controller/hotspot.lua b/rooter/0optionalapps/luci-app-hotspot/files/usr/lib/lua/luci/controller/hotspot.lua deleted file mode 100644 index 75ceb27..0000000 --- a/rooter/0optionalapps/luci-app-hotspot/files/usr/lib/lua/luci/controller/hotspot.lua +++ /dev/null @@ -1,307 +0,0 @@ -module("luci.controller.hotspot", package.seeall) - -I18N = require "luci.i18n" -translate = I18N.translate - -function index() - local page - local multilock = luci.model.uci.cursor():get("custom", "multiuser", "multi") or "0" - local rootlock = luci.model.uci.cursor():get("custom", "multiuser", "root") or "0" - if (multilock == "0") or (multilock == "1" and rootlock == "1") then - entry({"admin", "hotspot"}, firstchild(), translate("Wifi Hotspot"), 29).dependent=false - page = entry({"admin", "hotspot", "hotspot"}, template("hotspot/hotspot"), _(translate("Hotspot Manager")), 5) - page.dependent = true - end - - entry({"admin", "services", "check_spot"}, call("action_check_spot")) - entry({"admin", "services", "set_mode"}, call("action_set_mode")) - entry({"admin", "services", "set_enabled"}, call("action_set_enabled")) - entry({"admin", "services", "disconnect"}, call("action_disconnect")) - entry({"admin", "services", "refreshlist"}, call("action_refresh")) - entry({"admin", "services", "moveup"}, call("action_moveup")) - entry({"admin", "services", "movedown"}, call("action_movedown")) - entry({"admin", "services", "addtolist"}, call("action_addtolist")) - entry({"admin", "services", "dellist"}, call("action_dellist")) - entry({"admin", "services", "editlist"}, call("action_editlist")) - entry({"admin", "services", "mancon"}, call("action_mancon")) - entry({"admin", "services", "bandchange"}, call("action_bandchange")) - entry({"admin", "services", "reconn"}, call("action_reconn")) -end - -function readhot() - line = nil - file = io.open("/tmp/hot", "r") - if file ~= nil then - repeat - tmp = file:read("*line") - if tmp ~= nil then - if line == nil then - line = tmp - else - line = line .. "|" .. tmp - end - end - until tmp == nil - file:close() - end - return line -end - -function action_check_spot() - local rv = {} - local freq = {} - local set = luci.http.formvalue("set") - auto = luci.model.uci.cursor():get("travelmate", "global", "trm_auto") - rv["auto"] = auto - rv["enabled"] = luci.model.uci.cursor():get("travelmate", "global", "trm_enabled") - rv["reconn"] = luci.model.uci.cursor():get("travelmate", "global", "reconn") - if rv["reconn"] == nil then - rv["reconn"] = "0" - end - - rv["ssid"] = luci.model.uci.cursor():get("travelmate", "global", "ssid") - if rv["ssid"] == nil then - rv["ssid"] = "No Connection" - end - fre = luci.model.uci.cursor():get("travelmate", "global", "freq") - encr = luci.model.uci.cursor():get("wireless", "wwan" .. fre, "encryption") - if encr == "none" then - rv["encryp"] = translate("Open") - else - rv["encryp"] = translate("Encrypted") - end - rv["disable"] = luci.model.uci.cursor():get("wireless", "wwan" .. fre, "disabled") - - dual = luci.model.uci.cursor():get("travelmate", "global", "radcnt") - rv["dual"] = dual - nrad = tonumber(dual) - for k = 0, nrad do - freq[k] = luci.model.uci.cursor():get("travelmate", "global", "radio" .. tostring(k)) - end - rv['freq'] = freq - - device = luci.model.uci.cursor():get("wireless", "wwan" .. fre, "device") - device = string.sub(device, 6, 7) - if fre == "2" then - fre="0" - else - fre="1" - end - rv["band"] = fre - - luci.http.prepare_content("application/json") - luci.http.write_json(rv) -end - -function action_set_mode() - local set = luci.http.formvalue("set") - os.execute("/usr/lib/hotspot/enable.sh " .. set) -end - -function action_set_enabled() - local set = luci.http.formvalue("set") - os.execute("/usr/lib/hotspot/enable.sh " .. set) -end - -function action_disconnect() - os.execute("/usr/lib/hotspot/dis_hot.sh") -end - -function action_refresh() - local rv = {} - os.execute("/usr/lib/hotspot/inrange.sh") - hotline = readhot() - if hotline == nil then - rv["empty"] = "1" - else - rv["empty"] = "0" - rv["hotline"] = hotline - end - - luci.http.prepare_content("application/json") - luci.http.write_json(rv) -end - -function movelist(direc, set, key) - local temp = {} - local rv = {} - local index = 0 - file = io.open("/tmp/hot", "r") - if file ~= nil then - repeat - tmp = file:read("*line") - if tmp ~= nil then - temp[index] = tmp - index = index + 1 - end - until tmp == nil - file:close() - if direc == 0 then - line2 = temp[set-1] - temp[set-1] = temp[set] - temp[set] = line2 - elseif direc == 1 then - line2 = temp[set+1] - temp[set+1] = temp[set] - temp[set] = line2 - elseif direc == 2 then - if index > 0 then - for i=set, index-2 do - temp[i] = temp[i+1] - end - end - index = index - 1 - elseif direc == 3 then - s, e = temp[set]:find("|") - name = temp[set]:sub(1, s-1) - cs, ce = temp[set]:find("|", e+1) - enc = temp[set]:sub(e+1, cs-1) - bs, be = temp[set]:find("|", ce+1) - ko = temp[set]:sub(ce+1, bs-1) - fl = temp[set]:sub(be+1) - temp[set] = name .. "|" .. enc .. "|" .. key .. "|" .. fl - end - if index < 0 then - --os.execute("rm -f /tmp/hot1; rm -f /etc/hotspot") - else - file = io.open("/tmp/hot", "w") - for i=0, index-1 do - file:write(temp[i], "\n") - end - file:close() - os.execute("/usr/lib/hotspot/copyhot.sh") - end - end -end - -function action_moveup() - local set = tonumber(luci.http.formvalue("set")) - local rv = {} - movelist(0, set) - hotline = readhot() - if hotline == nil then - rv["empty"] = "1" - else - rv["empty"] = "0" - rv["hotline"] = hotline - end - - luci.http.prepare_content("application/json") - luci.http.write_json(rv) -end - -function action_movedown() - local set = tonumber(luci.http.formvalue("set")) - local rv = {} - movelist(1, set) - hotline = readhot() - if hotline == nil then - rv["empty"] = "1" - else - rv["empty"] = "0" - rv["hotline"] = hotline - end - - luci.http.prepare_content("application/json") - luci.http.write_json(rv) -end - -function action_dellist() - local set = tonumber(luci.http.formvalue("set")) - local rv = {} - movelist(2, set) - hotline = readhot() - if hotline == nil then - rv["empty"] = "1" - else - rv["empty"] = "0" - rv["hotline"] = hotline - end - - luci.http.prepare_content("application/json") - luci.http.write_json(rv) -end - -function action_addtolist() - local set = luci.http.formvalue("set") - local rv = {} - - s, e = set:find("|") - ssid = set:sub(1, e-1) - - file = io.open("/etc/hotspot", "r") - if file ~= nil then - i = 0 - repeat - line = file:read("*line") - if line == nil then - break - else - s, e = line:find(ssid) - if s ~= nil then - i = 1 - break - end - end - until 1==0 - if i == 0 then - file = io.open("/etc/hotspot", "a") - file:write(set) - file:write("\n") - file:close() - end - else - file = io.open("/etc/hotspot", "w") - file:write(set) - file:write("\n") - file:close() - end - os.execute("/usr/lib/hotspot/inrange.sh") - hotline = readhot() - if hotline == nil then - rv["empty"] = "1" - else - rv["empty"] = "0" - rv["hotline"] = hotline - end - - luci.http.prepare_content("application/json") - luci.http.write_json(rv) -end - -function action_editlist() - local set = luci.http.formvalue("set") - local rv = {} - s, e = set:find("|") - sel = set:sub(1, s-1) - idx = tonumber(sel) - key = set:sub(e+1) - movelist(3, idx, key) - hotline = readhot() - if hotline == nil then - rv["empty"] = "1" - else - rv["empty"] = "0" - rv["hotline"] = hotline - end - - luci.http.prepare_content("application/json") - luci.http.write_json(rv) -end - -function action_mancon() - local set = luci.http.formvalue("set") - local rv = {} - os.execute("/usr/lib/hotspot/manual.sh \"" .. set .. "\"") -end - -function action_bandchange() - local set = luci.http.formvalue("set") - local rv = {} - os.execute("/usr/lib/hotspot/band.sh \"" .. set .. "\"") -end - -function action_reconn() - local set = luci.http.formvalue("set") - os.execute("/usr/lib/hotspot/reconn.sh \"" .. set .. "\"") -end \ No newline at end of file diff --git a/rooter/0optionalapps/luci-app-hotspot/files/usr/lib/lua/luci/controller/wifilog.lua b/rooter/0optionalapps/luci-app-hotspot/files/usr/lib/lua/luci/controller/wifilog.lua deleted file mode 100644 index b192569..0000000 --- a/rooter/0optionalapps/luci-app-hotspot/files/usr/lib/lua/luci/controller/wifilog.lua +++ /dev/null @@ -1,33 +0,0 @@ -module("luci.controller.wifilog", package.seeall) - -I18N = require "luci.i18n" -translate = I18N.translate - -function index() - local multilock = luci.model.uci.cursor():get("custom", "multiuser", "multi") or "0" - local rootlock = luci.model.uci.cursor():get("custom", "multiuser", "root") or "0" - if (multilock == "0") or (multilock == "1" and rootlock == "1") then - local page - page = entry({"admin", "hotspot", "wifilog"}, template("wifilog/wifilog"), _(translate("Hotspot Logging")), 61) - page.dependent = true - end - - entry({"admin", "status", "wifilog"}, call("action_wifilog")) -end - -function action_wifilog() - local file - local rv ={} - - file = io.open("/tmp/wifilog.log", "r") - if file ~= nil then - local tmp = file:read("*all") - rv["log"] = tmp - file:close() - else - rv["log"] = translate("No entries in log file") - end - - luci.http.prepare_content("application/json") - luci.http.write_json(rv) -end \ No newline at end of file diff --git a/rooter/0optionalapps/luci-app-hotspot/files/usr/lib/lua/luci/view/hotspot/hotspot.htm b/rooter/0optionalapps/luci-app-hotspot/files/usr/lib/lua/luci/view/hotspot/hotspot.htm deleted file mode 100644 index fae6a6b..0000000 --- a/rooter/0optionalapps/luci-app-hotspot/files/usr/lib/lua/luci/view/hotspot/hotspot.htm +++ /dev/null @@ -1,1139 +0,0 @@ -<%- - -local sys = require "luci.sys" -local utl = require "luci.util" - -wifi = {} -scan = {} -numnet = 0 - -printf = function(s,...) - io.write(s:format(...)) - local ss = s:format(...) -end - -function trim(s) - return (s:gsub("^%s*(.-)%s*$", "%1")) -end - -function showicon() - return resource .. "/icons/encryption.png" -end - -function guess_wifi_signal(info) - local scale = scan[info]["quality"] - local icon - if scale < 15 then - icon = resource .. "/icons/signal-0.png" - elseif scale < 35 then - icon = resource .. "/icons/signal-0-25.png" - elseif scale < 55 then - icon = resource .. "/icons/signal-25-50.png" - elseif scale < 75 then - icon = resource .. "/icons/signal-50-75.png" - else - icon = resource .. "/icons/signal-75-100.png" - end - - return icon -end - -function scan_open(rrx, rry) - rony = 1 - if rry["encrypt"] == "Open" then - rony = 0 - end - ronx = 1 - if rrx["encrypt"] == "Open" then - ronx = 0 - end - if ronx < rony then - return true - end - if ronx > rony then - return false - end - ronx = rrx["quality"] - rony = rry["quality"] - if ronx > rony then - return true - end - return false -end - -function partition(arr, left, right) - local i = left - local j = right - local pivot = math.floor((left + right) / 2) - local tmp - while i <= j do - while scan_open(arr[i], arr[pivot]) do - i = i + 1 - end - while scan_open(arr[pivot], arr[j]) do - j = j - 1 - end - if i <= j then - tmp = arr[i] - arr[i] = arr[j] - arr[j] = tmp - i = i + 1 - j = j - 1 - end - end - return i, arr -end - -function quicksort(arr, left, right) - index, arr = partition(arr, left, right) - if left < (index - 1) then - quicksort(arr, left, index-1) - end - if index < right then - quicksort(arr, index, right) - end - return arr -end - -function build_scan(j, k) - scan[k]["channel"] = wifi[j]["channel"] - scan[k]["essid"] = wifi[j]["essid"] - scan[k]["signal"] = tonumber(wifi[j]["signal"]) - qc = tonumber(wifi[j]["quality"]) - qm = tonumber(wifi[j]["quality_max"]) - scan[k]["quality"] = math.floor((100 / qm) * qc) - scan[k]["ekey"] = wifi[j]["ekey"] - if wifi[j]["ekey"] == "none" then - scan[k]["encrypt"] = "Open" - scan[k]["encryption"] = wifi[j]["encryption"] - else - scan[k]["encrypt"] = wifi[j]["ekey"] - scan[k]["encryption"] = wifi[j]["encryption"] - end -end - -function get_networks() - luci.util.exec("/usr/lib/hotspot/getssid.sh") - file = io.open("/tmp/ssidlist", "r") - if file == nil then - numnet = 0 - return - end - i = 0 - cont = 2 - line = file:read("*line") - repeat - if line == nil then - cont = 0 - else - s, e = line:find("Cell ") - if s ~= nil then - cont = 1 - essid=nil - i = i + 1 - wifi[i] = {} - encryption = "none" - repeat - line = file:read("*line") - if line == nil then - cont = 0 - break - else - s, e = line:find("Cell ") - if s ~= nil then - break - else - s, e = line:find("ESSID:") - if s ~= nil then - ee = line:len() - essid = trim(line:sub(e+3, ee-1)) - end - s, e = line:find("Mode:") - if s ~= nil then - line1 = trim(line:sub(e+1)) - bs, be = line1:find(" ", 1) - mode = trim(line1:sub(1, bs)) - cs, ce = line1:find(" ") - line2 = trim(line1:sub(ce+1)) - s, e = line2:find("Channel:") - channel = trim(line2:sub(e+2)) - end - s, e = line:find("Signal:") - if s ~= nil then - line1 = trim(line:sub(e+1)) - bs, be = line1:find(" ", 1) - signal = trim(line1:sub(1, bs)) - cs, ce = line1:find(" ") - line2 = trim(line1:sub(ce+1)) - s, e = line2:find("Quality:") - cs, ce = line2:find("/", e) - quality = trim(line2:sub(e+1, ce-1)) - quality_max = trim(line2:sub(ce+1)) - end - s, e = line:find("Encryption:") - if s ~= nil then - cs, ce = line:find("WEP") - if cs == nil then - encrypt = trim(line:sub(e+2)) - s, e = encrypt:find("none") - if s ~= nil then - encryption = "none" - else - s, e = encrypt:find("mixed") - if s ~= nil then - encryption = "psk-mixed" - else - s, e = encrypt:find("WPA2") - if s ~= nil then - encryption = "psk2" - else - encryption = "psk" - end - end - end - else - cont = 2 - i = i - 1 - break - end - end - end - end - until 1==0 - else - line = file:read("*line") - end - end - if cont < 2 then - if i > 0 then - if essid ~= nil and mode == "Master" then - wifi[i]["essid"] = essid - wifi[i]["channel"] = channel - wifi[i]["signal"] = signal - wifi[i]["quality"] = quality - wifi[i]["quality_max"] = quality_max - wifi[i]["ekey"] = encrypt - wifi[i]["encryption"] = encryption - end - end - end - if cont == 0 then - break - end - cont = 2 - until 1==0 - file:close() - - k = 0 - if i > 0 then - for j=1, i do - if wifi[j]["essid"] ~= nil and tonumber(wifi[j]["quality"]) > 0 then - if k < 1 then - k = k+1 - scan[k] = {} - build_scan(j, k) - else - flag = 0 - for l=1, k do - if wifi[j]["essid"] == scan[l]["essid"] and wifi[j]["channel"] == scan[l]["channel"] and wifi[j]["ekey"] == scan[l]["ekey"] then - qc = tonumber(wifi[j]["quality"]) - qm = tonumber(wifi[j]["quality_max"]) - qual = math.floor((100 / qm) * qc) - if qual > scan[l]["quality"] then - build_scan(j, l) - end - flag = 1 - break - end - end - if flag == 0 then - k = k+1 - scan[k] = {} - build_scan(j, k) - end - end - end - end - scan = quicksort(scan, 1, k) - end - numnet = k -end - --%> -<%+header%> - - - - -
                - -
                -

                <%:Wifi Hotspot Management%>

                -
                <%:Manage Your Wifi Hotspot Connections%>
                - - - -
                - - - - - - -
                  -  
                - - - - - -
                 
                - - - - - - - -
                <%:Reconnection Attempts on Dropped Connection%> - - -  
                - - - - - - - - - - - -
                 
                - - - - - - - -
                <%:Wifi Radio Frequency :%>
                - -  
                - - - - - -
                 
                - - - - - - - -
                <%:Current Wifi Hotspot : %>
                  - - - - - - - -
                  <%:Encryption : %>
                     
                    - - - - - -
                     
                    - - - - - - - - - -
                    <%:In Range%>
                    <%:Wifi Hotspot Networks%>
                     
                    - -
                      -
                    - -
                      -
                    •  
                    • -
                    • <%:No Wifi Hotspot Networks Selected%>
                    • -
                    •  
                    • -
                    - - - - - -
                     
                    - - - - - - - -
                    <%:Hotspot Name :%>
                       
                      - - - - - - - -
                      <%:Encrypted :%>
                         
                        - - - - - - - - -
                        <%:Key :%>
                           
                          - - - - - -
                           
                          - - - - - - - - - -
                           
                          - - - - - -
                           
                          - - <% get_networks() %> - - - - - -
                          <%:Available Networks : %><%=numnet%>
                          - <% if numnet > 0 then - for m=1, numnet do - data = scan[m]["essid"] .. "|" .. scan[m]["encryption"] - %> - - - - - - -
                          - -
                          - <%=scan[m]["quality"]%>% -
                          -
                          - <%=scan[m]["essid"]%>
                          - Channel: <%=scan[m]["channel"]%> | - Encryption: <%=scan[m]["encrypt"]%> -
                          - -
                          - <% end - end %> -
                          - -
                          -
                          - - - -
                          - - -<%+footer%> diff --git a/rooter/0optionalapps/luci-app-hotspot/files/usr/lib/lua/luci/view/wifilog/wifilog.htm b/rooter/0optionalapps/luci-app-hotspot/files/usr/lib/lua/luci/view/wifilog/wifilog.htm deleted file mode 100644 index 48bdb5f..0000000 --- a/rooter/0optionalapps/luci-app-hotspot/files/usr/lib/lua/luci/view/wifilog/wifilog.htm +++ /dev/null @@ -1,32 +0,0 @@ -<%+header%> - - - - -
                          -

                          <%:Hotspot Logging%>

                          -
                          -
                          - <%:Log%> - - - - -
                          - -
                          - -
                          - -
                          - -<%+footer%> \ No newline at end of file diff --git a/rooter/0optionalapps/luci-app-hotspot/files/usr/lib/rooter/log/wifilogger.sh b/rooter/0optionalapps/luci-app-hotspot/files/usr/lib/rooter/log/wifilogger.sh deleted file mode 100644 index c9b7bc2..0000000 --- a/rooter/0optionalapps/luci-app-hotspot/files/usr/lib/rooter/log/wifilogger.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -TEXT=$1 -DATE=$(date +%c) - -modlog="/tmp/wifilog.log" -tmplog="/tmp/twifilog" - -echo "$DATE : $TEXT" >> $modlog -lua $ROOTER/log/mrotate.lua $modlog $tmplog -mv $tmplog $modlog - diff --git a/rooter/0optionalapps/luci-app-hotspot/files/usr/sbin/wifilog b/rooter/0optionalapps/luci-app-hotspot/files/usr/sbin/wifilog deleted file mode 100644 index 962b1ce..0000000 --- a/rooter/0optionalapps/luci-app-hotspot/files/usr/sbin/wifilog +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -name=$1 -text=$2 - -logger -t "$name" "$text" -/usr/lib/rooter/log/wifilogger.sh "$name $text" \ No newline at end of file diff --git a/rooter/0optionalapps/luci-app-hotspot/files/www/luci-static/resources/icons/encryption.png b/rooter/0optionalapps/luci-app-hotspot/files/www/luci-static/resources/icons/encryption.png deleted file mode 100644 index b45e285..0000000 Binary files a/rooter/0optionalapps/luci-app-hotspot/files/www/luci-static/resources/icons/encryption.png and /dev/null differ diff --git a/rooter/0optionalapps/luci-app-nft-qos/Makefile b/rooter/0optionalapps/luci-app-nft-qos/Makefile deleted file mode 100644 index 94bf539..0000000 --- a/rooter/0optionalapps/luci-app-nft-qos/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -#Owned by DairyMan@Whirlpool -# -#Copyright GNU act. -include $(TOPDIR)/rules.mk - -PKG_NAME:=luci-app-nft-qos -PKG_VERSION:=1.000 -PKG_RELEASE:=1 - -PKG_MAINTAINER:=Created by DM/makefile by Cobia@whirlpool -include $(INCLUDE_DIR)/package.mk - -define Package/luci-app-nft-qos - SECTION:=luci - CATEGORY:=LuCI - DEPENDS:=+nft-qos - SUBMENU:=3. Applications - TITLE:=support for NFT over QOS - PKGARCH:=all -endef - -define Package/luci-app-nft-qos/description - Helper scripts to enable NFT over QOS -endef - - -define Build/Compile -endef - -define Package/luci-app-nft-qos/install - $(CP) ./files/* $(1)/ -endef - -$(eval $(call BuildPackage,luci-app-nft-qos)) diff --git a/rooter/0optionalapps/luci-app-nft-qos/files/usr/lib/lua/luci/controller/nft-qos.lua b/rooter/0optionalapps/luci-app-nft-qos/files/usr/lib/lua/luci/controller/nft-qos.lua deleted file mode 100644 index 637eb11..0000000 --- a/rooter/0optionalapps/luci-app-nft-qos/files/usr/lib/lua/luci/controller/nft-qos.lua +++ /dev/null @@ -1,55 +0,0 @@ --- Copyright 2018 Rosy Song --- Licensed to the public under the Apache License 2.0. - -module("luci.controller.nft-qos", package.seeall) - -function index() - if not nixio.fs.access("/etc/config/nft-qos") then - return - end - - entry({"admin", "status", "realtime", "rate"}, - template("nft-qos/rate"), _("Rate"), 5).leaf = true - entry({"admin", "status", "realtime", "rate_status"}, - call("action_rate")).leaf = true - entry({"admin", "services", "nft-qos"}, cbi("nft-qos/nft-qos"), - _("Qos over Nftables"), 60) -end - -function _action_rate(rv, n) - local c = nixio.fs.access("/proc/net/ipv6_route") and - io.popen("nft list chain inet nft-qos-monitor " .. n .. " 2>/dev/null") or - io.popen("nft list chain ip nft-qos-monitor " .. n .. " 2>/dev/null") - - if c then - for l in c:lines() do - local _, i, p, b = l:match( - '^%s+ip ([^%s]+) ([^%s]+) counter packets (%d+) bytes (%d+)' - ) - if i and p and b then - -- handle expression - rv[#rv + 1] = { - rule = { - family = "inet", - table = "nft-qos-monitor", - chain = n, - handle = 0, - expr = { - { match = { right = i } }, - { counter = { packets = p, bytes = b } } - } - } - } - end - end - c:close() - end -end - -function action_rate() - luci.http.prepare_content("application/json") - local data = { nftables = {} } - _action_rate(data.nftables, "upload") - _action_rate(data.nftables, "download") - luci.http.write_json(data) -end diff --git a/rooter/0optionalapps/luci-app-nft-qos/files/usr/lib/lua/luci/model/cbi/nft-qos/nft-qos.lua b/rooter/0optionalapps/luci-app-nft-qos/files/usr/lib/lua/luci/model/cbi/nft-qos/nft-qos.lua deleted file mode 100644 index 61a6d76..0000000 --- a/rooter/0optionalapps/luci-app-nft-qos/files/usr/lib/lua/luci/model/cbi/nft-qos/nft-qos.lua +++ /dev/null @@ -1,229 +0,0 @@ --- Copyright 2018 Rosy Song --- Licensed to the public under the Apache License 2.0. - -local uci = require("luci.model.uci").cursor() -local wa = require("luci.tools.webadmin") -local fs = require("nixio.fs") -local ipc = require("luci.ip") - -local def_rate_dl = uci:get("nft-qos", "default", "static_rate_dl") -local def_rate_ul = uci:get("nft-qos", "default", "static_rate_ul") -local def_unit_dl = uci:get("nft-qos", "default", "static_unit_dl") -local def_unit_ul = uci:get("nft-qos", "default", "static_unit_ul") - -local def_up = uci:get("nft-qos", "default", "dynamic_bw_up") -local def_down = uci:get("nft-qos", "default", "dynamic_bw_down") - -local limit_enable = uci:get("nft-qos", "default", "limit_enable") -local limit_type = uci:get("nft-qos", "default", "limit_type") -local enable_priority = uci:get("nft-qos", "default", "priority_enable") - -local has_ipv6 = fs.access("/proc/net/ipv6_route") - -m = Map("nft-qos", translate("Qos over Nftables")) - --- --- Taboptions --- -s = m:section(TypedSection, "default", translate("NFT-QoS Settings")) -s.addremove = false -s.anonymous = true - -s:tab("limit", "Limit Rate") -s:tab("priority", "Traffic Priority") - --- --- Static --- -o = s:taboption("limit", Flag, "limit_enable", translate("Limit Enable"), translate("Enable Limit Rate Feature")) -o.default = limit_enable or o.enabled -o.rmempty = false - -o = s:taboption("limit", ListValue, "limit_type", translate("Limit Type"), translate("Type of Limit Rate")) -o.default = limit_static or "static" -o:depends("limit_enable","1") -o:value("static", "Static") -o:value("dynamic", "Dynamic") - -o = s:taboption("limit", Value, "static_rate_dl", translate("Default Download Rate"), translate("Default value for download rate")) -o.datatype = "uinteger" -o.default = def_rate_dl or '50' -o:depends("limit_type","static") - -o = s:taboption("limit", ListValue, "static_unit_dl", translate("Default Download Unit"), translate("Default unit for download rate")) -o.default = def_unit_dl or "kbytes" -o:depends("limit_type","static") -o:value("bytes", "Bytes/s") -o:value("kbytes", "KBytes/s") -o:value("mbytes", "MBytes/s") - -o = s:taboption("limit", Value, "static_rate_ul", translate("Default Upload Rate"), translate("Default value for upload rate")) -o.datatype = "uinteger" -o.default = def_rate_ul or '50' -o:depends("limit_type","static") - -o = s:taboption("limit", ListValue, "static_unit_ul", translate("Default Upload Unit"), translate("Default unit for upload rate")) -o.default = def_unit_ul or "kbytes" -o:depends("limit_type","static") -o:value("bytes", "Bytes/s") -o:value("kbytes", "KBytes/s") -o:value("mbytes", "MBytes/s") - --- --- Dynamic --- -o = s:taboption("limit", Value, "dynamic_bw_down", translate("Download Bandwidth (Mbps)"), translate("Default value for download bandwidth")) -o.default = def_up or '100' -o.datatype = "uinteger" -o:depends("limit_type","dynamic") - -o = s:taboption("limit", Value, "dynamic_bw_up", translate("Upload Bandwidth (Mbps)"), translate("Default value for upload bandwidth")) -o.default = def_down or '100' -o.datatype = "uinteger" -o:depends("limit_type","dynamic") - -o = s:taboption("limit", Value, "dynamic_cidr", translate("Target Network (IPv4/MASK)"), translate("Network to be apply, e.g. 192.168.1.0/24, 10.2.0.0/16, etc")) -o.datatype = "cidr4" -ipc.routes({ family = 4, type = 1 }, function(rt) o.default = rt.dest end) -o:depends("limit_type","dynamic") - -if has_ipv6 then - o = s:taboption("limit", Value, "dynamic_cidr6", translate("Target Network6 (IPv6/MASK)"), translate("Network to be apply, e.g. AAAA::BBBB/64, CCCC::1/128, etc")) - o.datatype = "cidr6" - o:depends("limit_type","dynamic") -end - -o = s:taboption("limit", DynamicList, "limit_whitelist", translate("White List for Limit Rate")) -o.datatype = "ipaddr" -o:depends("limit_enable","1") - --- --- Priority --- -o = s:taboption("priority", Flag, "priority_enable", translate("Enable Traffic Priority"), translate("Enable this feature")) -o.default = enable_priority or o.enabled -o.rmempty = false - -o = s:taboption("priority", ListValue, "priority_netdev", translate("Default Network Interface"), translate("Network Interface for Traffic Shaping, e.g. br-lan, eth0.1, eth0, etc")) -o:depends("priority_enable", "1") -wa.cbi_add_networks(o) - --- --- Static Limit Rate - Download Rate --- -if limit_enable == "1" and limit_type == "static" then - -x = m:section(TypedSection, "download", translate("Static QoS-Download Rate")) -x.anonymous = true -x.addremove = true -x.template = "cbi/tblsection" - -o = x:option(Value, "hostname", translate("Hostname")) -o.datatype = "hostname" -o.default = 'undefined' - -if has_ipv6 then - o = x:option(Value, "ipaddr", translate("IP Address(V4 / V6)")) -else - o = x:option(Value, "ipaddr", translate("IP Address(V4 Only)")) -end -o.datatype = "ipaddr" -if nixio.fs.access("/tmp/dhcp.leases") or nixio.fs.access("/var/dhcp6.leases") then - o.titleref = luci.dispatcher.build_url("admin", "status", "overview") -end - -o = x:option(Value, "macaddr", translate("MAC (optional)")) -o.rmempty = true -o.datatype = "macaddr" - -o = x:option(Value, "rate", translate("Rate")) -o.default = def_rate_dl or '50' -o.size = 4 -o.datatype = "uinteger" - -o = x:option(ListValue, "unit", translate("Unit")) -o.default = def_unit_dl or "kbytes" -o:value("bytes", "Bytes/s") -o:value("kbytes", "KBytes/s") -o:value("mbytes", "MBytes/s") - --- --- Static Limit Rate - Upload Rate --- -y = m:section(TypedSection, "upload", translate("Static QoS-Upload Rate")) -y.anonymous = true -y.addremove = true -y.template = "cbi/tblsection" - -o = y:option(Value, "hostname", translate("Hostname")) -o.datatype = "hostname" -o.default = 'undefined' - -if has_ipv6 then - o = y:option(Value, "ipaddr", translate("IP Address(V4 / V6)")) -else - o = y:option(Value, "ipaddr", translate("IP Address(V4 Only)")) -end -o.datatype = "ipaddr" -if nixio.fs.access("/tmp/dhcp.leases") or nixio.fs.access("/var/dhcp6.leases") then - o.titleref = luci.dispatcher.build_url("admin", "status", "overview") -end - -o = y:option(Value, "macaddr", translate("MAC (optional)")) -o.rmempty = true -o.datatype = "macaddr" - -o = y:option(Value, "rate", translate("Rate")) -o.default = def_rate_ul or '50' -o.size = 4 -o.datatype = "uinteger" - -o = y:option(ListValue, "unit", translate("Unit")) -o.default = def_unit_ul or "kbytes" -o:value("bytes", "Bytes/s") -o:value("kbytes", "KBytes/s") -o:value("mbytes", "MBytes/s") - -end - --- --- Traffic Priority Settings --- -if enable_priority == "1" then - -s = m:section(TypedSection, "priority", translate("Traffic Priority Settings")) -s.anonymous = true -s.addremove = true -s.template = "cbi/tblsection" - -o = s:option(ListValue, "protocol", translate("Protocol")) -o.default = "tcp" -o:value("tcp", "TCP") -o:value("udp", "UDP") -o:value("udplite", "UDP-Lite") -o:value("sctp", "SCTP") -o:value("dccp", "DCCP") - -o = s:option(ListValue, "priority", translate("Priority")) -o.default = "1" -o:value("-400", "1") -o:value("-300", "2") -o:value("-225", "3") -o:value("-200", "4") -o:value("-150", "5") -o:value("-100", "6") -o:value("0", "7") -o:value("50", "8") -o:value("100", "9") -o:value("225", "10") -o:value("300", "11") - -o = s:option(Value, "service", translate("Service"), translate("e.g. https, 23, (separator is comma)")) -o.default = '?' - -o = s:option(Value, "comment", translate("Comment")) -o.default = '?' - -end - -return m diff --git a/rooter/0optionalapps/luci-app-nft-qos/files/usr/lib/lua/luci/view/nft-qos/rate.htm b/rooter/0optionalapps/luci-app-nft-qos/files/usr/lib/lua/luci/view/nft-qos/rate.htm deleted file mode 100644 index 5f9cb57..0000000 --- a/rooter/0optionalapps/luci-app-nft-qos/files/usr/lib/lua/luci/view/nft-qos/rate.htm +++ /dev/null @@ -1,167 +0,0 @@ -<%# - Copyright 2018 Rosy Song - Licensed to the public under the Apache License 2.0. --%> - -<%+header%> - - - -

                          <%:Realtime Rate%>

                          - -
                          <%:This page gives an overview over currently download/upload rate.%>
                          - -
                          - <%:Realtime Download Rate%> -
                          -
                          -
                          -
                          <%:IP Address%>
                          -
                          <%:Download Rate%>
                          -
                          <%:Bytes Total%>
                          -
                          <%:Packets Total%>
                          -
                          -
                          -
                          - <%:Collecting data...%> -
                          -
                          -
                          -
                          -
                          - -
                          - <%:Realtime Upload Rate%> -
                          -
                          -
                          -
                          <%:IP Address%>
                          -
                          <%:Upload Rate%>
                          -
                          <%:Bytes Total%>
                          -
                          <%:Packets Total%>
                          -
                          -
                          -
                          - <%:Collecting data...%> -
                          -
                          -
                          -
                          -
                          - -<%+footer%> diff --git a/rooter/0optionalapps/luci-app-nft-qos/po/bg/nft-qos.po b/rooter/0optionalapps/luci-app-nft-qos/po/bg/nft-qos.po deleted file mode 100644 index 6bfdc6b..0000000 --- a/rooter/0optionalapps/luci-app-nft-qos/po/bg/nft-qos.po +++ /dev/null @@ -1,233 +0,0 @@ -msgid "" -msgstr "" -"Language: bg\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:136 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:155 -msgid "Bytes Total" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:141 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:160 -msgid "Collecting data..." -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:224 -msgid "Comment" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default Download Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Default Network Interface" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default Upload Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default unit for download rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default unit for upload rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Default value for download bandwidth" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default value for download rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Default value for upload bandwidth" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default value for upload rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Download Bandwidth (Mbps)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:135 -msgid "Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Enable Limit Rate Feature" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable Traffic Priority" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable this feature" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:121 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:158 -msgid "Hostname" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:134 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:153 -msgid "IP Address" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:126 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:163 -msgid "IP Address(V4 / V6)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:128 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:165 -msgid "IP Address(V4 Only)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Limit Enable" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Limit Type" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:135 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:172 -msgid "MAC (optional)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:48 -msgid "MB" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:28 -msgid "NFT-QoS Settings" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Network Interface for Traffic Shaping, e.g. br-lan, eth0.1, eth0, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Network to be apply, e.g. 192.168.1.0/24, 10.2.0.0/16, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Network to be apply, e.g. AAAA::BBBB/64, CCCC::1/128, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:65 -msgid "No information available" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:137 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:156 -msgid "Packets Total" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:207 -msgid "Priority" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:199 -msgid "Protocol" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:16 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:23 -msgid "Qos over Nftables" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:12 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:139 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:176 -msgid "Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:130 -msgid "Realtime Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:125 -msgid "Realtime Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:149 -msgid "Realtime Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "Service" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:116 -msgid "Static QoS-Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:153 -msgid "Static QoS-Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Target Network (IPv4/MASK)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Target Network6 (IPv6/MASK)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:127 -msgid "This page gives an overview over currently download/upload rate." -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:194 -msgid "Traffic Priority Settings" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Type of Limit Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:144 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:181 -msgid "Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Upload Bandwidth (Mbps)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:154 -msgid "Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:96 -msgid "White List for Limit Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "e.g. https, 23, (separator is comma)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:44 -msgid "kB" -msgstr "" diff --git a/rooter/0optionalapps/luci-app-nft-qos/po/ca/nft-qos.po b/rooter/0optionalapps/luci-app-nft-qos/po/ca/nft-qos.po deleted file mode 100644 index c2eef3c..0000000 --- a/rooter/0optionalapps/luci-app-nft-qos/po/ca/nft-qos.po +++ /dev/null @@ -1,239 +0,0 @@ -msgid "" -msgstr "" -"PO-Revision-Date: 2020-01-10 12:23+0000\n" -"Last-Translator: Adolfo Jayme Barrientos \n" -"Language-Team: Catalan \n" -"Language: ca\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 3.10.1\n" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:136 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:155 -msgid "Bytes Total" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:141 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:160 -msgid "Collecting data..." -msgstr "S’estan recollint dades…" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:224 -msgid "Comment" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default Download Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Default Network Interface" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default Upload Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default unit for download rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default unit for upload rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Default value for download bandwidth" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default value for download rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Default value for upload bandwidth" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default value for upload rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Download Bandwidth (Mbps)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:135 -msgid "Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Enable Limit Rate Feature" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable Traffic Priority" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable this feature" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:121 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:158 -msgid "Hostname" -msgstr "Nom de l’amfitrió" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:134 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:153 -msgid "IP Address" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:126 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:163 -msgid "IP Address(V4 / V6)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:128 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:165 -msgid "IP Address(V4 Only)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Limit Enable" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Limit Type" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:135 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:172 -msgid "MAC (optional)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:48 -msgid "MB" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:28 -msgid "NFT-QoS Settings" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Network Interface for Traffic Shaping, e.g. br-lan, eth0.1, eth0, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Network to be apply, e.g. 192.168.1.0/24, 10.2.0.0/16, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Network to be apply, e.g. AAAA::BBBB/64, CCCC::1/128, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:65 -msgid "No information available" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:137 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:156 -msgid "Packets Total" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:207 -msgid "Priority" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:199 -msgid "Protocol" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:16 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:23 -msgid "Qos over Nftables" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:12 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:139 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:176 -msgid "Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:130 -msgid "Realtime Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:125 -msgid "Realtime Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:149 -msgid "Realtime Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "Service" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:116 -msgid "Static QoS-Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:153 -msgid "Static QoS-Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Target Network (IPv4/MASK)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Target Network6 (IPv6/MASK)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:127 -msgid "This page gives an overview over currently download/upload rate." -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:194 -msgid "Traffic Priority Settings" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Type of Limit Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:144 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:181 -msgid "Unit" -msgstr "Unitat" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Upload Bandwidth (Mbps)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:154 -msgid "Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:96 -msgid "White List for Limit Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "e.g. https, 23, (separator is comma)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:44 -msgid "kB" -msgstr "" diff --git a/rooter/0optionalapps/luci-app-nft-qos/po/cs/nft-qos.po b/rooter/0optionalapps/luci-app-nft-qos/po/cs/nft-qos.po deleted file mode 100644 index acc9a0f..0000000 --- a/rooter/0optionalapps/luci-app-nft-qos/po/cs/nft-qos.po +++ /dev/null @@ -1,239 +0,0 @@ -msgid "" -msgstr "" -"PO-Revision-Date: 2020-02-04 05:03+0000\n" -"Last-Translator: Pavel Borecki \n" -"Language-Team: Czech \n" -"Language: cs\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n" -"X-Generator: Weblate 3.11-dev\n" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:136 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:155 -msgid "Bytes Total" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:141 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:160 -msgid "Collecting data..." -msgstr "Shromažďování údajů…" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:224 -msgid "Comment" -msgstr "Komentář" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default Download Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Default Network Interface" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default Upload Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default unit for download rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default unit for upload rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Default value for download bandwidth" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default value for download rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Default value for upload bandwidth" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default value for upload rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Download Bandwidth (Mbps)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:135 -msgid "Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Enable Limit Rate Feature" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable Traffic Priority" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable this feature" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:121 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:158 -msgid "Hostname" -msgstr "Název počítače" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:134 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:153 -msgid "IP Address" -msgstr "IP adresa" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:126 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:163 -msgid "IP Address(V4 / V6)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:128 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:165 -msgid "IP Address(V4 Only)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Limit Enable" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Limit Type" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:135 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:172 -msgid "MAC (optional)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:48 -msgid "MB" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:28 -msgid "NFT-QoS Settings" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Network Interface for Traffic Shaping, e.g. br-lan, eth0.1, eth0, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Network to be apply, e.g. 192.168.1.0/24, 10.2.0.0/16, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Network to be apply, e.g. AAAA::BBBB/64, CCCC::1/128, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:65 -msgid "No information available" -msgstr "Údaje nejsou k dispozici" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:137 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:156 -msgid "Packets Total" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:207 -msgid "Priority" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:199 -msgid "Protocol" -msgstr "Protokol" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:16 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:23 -msgid "Qos over Nftables" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:12 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:139 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:176 -msgid "Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:130 -msgid "Realtime Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:125 -msgid "Realtime Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:149 -msgid "Realtime Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "Service" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:116 -msgid "Static QoS-Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:153 -msgid "Static QoS-Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Target Network (IPv4/MASK)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Target Network6 (IPv6/MASK)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:127 -msgid "This page gives an overview over currently download/upload rate." -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:194 -msgid "Traffic Priority Settings" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Type of Limit Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:144 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:181 -msgid "Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Upload Bandwidth (Mbps)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:154 -msgid "Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:96 -msgid "White List for Limit Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "e.g. https, 23, (separator is comma)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:44 -msgid "kB" -msgstr "" diff --git a/rooter/0optionalapps/luci-app-nft-qos/po/de/nft-qos.po b/rooter/0optionalapps/luci-app-nft-qos/po/de/nft-qos.po deleted file mode 100644 index 2c14fe3..0000000 --- a/rooter/0optionalapps/luci-app-nft-qos/po/de/nft-qos.po +++ /dev/null @@ -1,240 +0,0 @@ -msgid "" -msgstr "" -"PO-Revision-Date: 2020-07-11 21:29+0000\n" -"Last-Translator: ssantos \n" -"Language-Team: German \n" -"Language: de\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.2-dev\n" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:136 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:155 -msgid "Bytes Total" -msgstr "Bytes Gesamt" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:141 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:160 -msgid "Collecting data..." -msgstr "Sammle Daten..." - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:224 -msgid "Comment" -msgstr "Kommentar" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default Download Rate" -msgstr "Standard-Downloadrate" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default Download Unit" -msgstr "Standard-Download-Einheit" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Default Network Interface" -msgstr "Standard-Netzwerkschnittstelle" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default Upload Rate" -msgstr "Standard-Uploadrate" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default Upload Unit" -msgstr "Standard-Upload-Einheit" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default unit for download rate" -msgstr "Standardeinheit für Downloadrate" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default unit for upload rate" -msgstr "Standardeinheit für Upload-Rate" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Default value for download bandwidth" -msgstr "Standardwert für Download-Bandbreite" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default value for download rate" -msgstr "Standardwert für Downloadrate" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Default value for upload bandwidth" -msgstr "Standardwert für Upload-Bandbreite" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default value for upload rate" -msgstr "Standardwert für Upload-Rate" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Download Bandwidth (Mbps)" -msgstr "Download-Bandbreite (Mbps)" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:135 -msgid "Download Rate" -msgstr "Download-Rate" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Enable Limit Rate Feature" -msgstr "Aktiviere die Limit-Rate-Funktion" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable Traffic Priority" -msgstr "Aktiviere Traffic-Priorisierung" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable this feature" -msgstr "Diese Funktion aktivieren" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:121 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:158 -msgid "Hostname" -msgstr "Hostname" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:134 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:153 -msgid "IP Address" -msgstr "IP-Adresse" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:126 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:163 -msgid "IP Address(V4 / V6)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:128 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:165 -msgid "IP Address(V4 Only)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Limit Enable" -msgstr "Limit aktivieren" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Limit Type" -msgstr "Limit-Typ" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:135 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:172 -msgid "MAC (optional)" -msgstr "MAC (optional)" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:48 -msgid "MB" -msgstr "MB" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:28 -msgid "NFT-QoS Settings" -msgstr "NFT-QoS-Einstellungen" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Network Interface for Traffic Shaping, e.g. br-lan, eth0.1, eth0, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Network to be apply, e.g. 192.168.1.0/24, 10.2.0.0/16, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Network to be apply, e.g. AAAA::BBBB/64, CCCC::1/128, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:65 -msgid "No information available" -msgstr "Keine Informationen verfügbar" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:137 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:156 -msgid "Packets Total" -msgstr "Pakete Gesamt" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:207 -msgid "Priority" -msgstr "Priorität" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:199 -msgid "Protocol" -msgstr "Protokoll" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:16 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:23 -msgid "Qos over Nftables" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:12 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:139 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:176 -msgid "Rate" -msgstr "Rate" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:130 -msgid "Realtime Download Rate" -msgstr "Echtzeit-Downloadrate" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:125 -msgid "Realtime Rate" -msgstr "Echtzeit-Rate" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:149 -msgid "Realtime Upload Rate" -msgstr "Echtzeit-Uploadrate" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "Service" -msgstr "Service" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:116 -msgid "Static QoS-Download Rate" -msgstr "Statische QoS-Download-Rate" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:153 -msgid "Static QoS-Upload Rate" -msgstr "Statische QoS-Upload-Rate" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Target Network (IPv4/MASK)" -msgstr "Zielnetzwerk (IPv4/MASK)" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Target Network6 (IPv6/MASK)" -msgstr "Zielnetzwerk6 (IPv6/MASK)" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:127 -msgid "This page gives an overview over currently download/upload rate." -msgstr "" -"Diese Seite gibt einen Überblick über die aktuelle Download-/Uploadrate." - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:194 -msgid "Traffic Priority Settings" -msgstr "Einstellungen für Traffic-Priorität" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Type of Limit Rate" -msgstr "Typ der Limit-Rate" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:144 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:181 -msgid "Unit" -msgstr "Einheit" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Upload Bandwidth (Mbps)" -msgstr "Upload-Bandbreite (Mbps)" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:154 -msgid "Upload Rate" -msgstr "Uploadrate" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:96 -msgid "White List for Limit Rate" -msgstr "Whitelist für die Limit-Rate" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "e.g. https, 23, (separator is comma)" -msgstr "z.B. https, 23, (Trennzeichen ist Komma)" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:44 -msgid "kB" -msgstr "kB" diff --git a/rooter/0optionalapps/luci-app-nft-qos/po/el/nft-qos.po b/rooter/0optionalapps/luci-app-nft-qos/po/el/nft-qos.po deleted file mode 100644 index 57aa172..0000000 --- a/rooter/0optionalapps/luci-app-nft-qos/po/el/nft-qos.po +++ /dev/null @@ -1,239 +0,0 @@ -msgid "" -msgstr "" -"PO-Revision-Date: 2020-12-01 16:16+0000\n" -"Last-Translator: Marios Koutsoukis \n" -"Language-Team: Greek \n" -"Language: el\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.4-dev\n" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:136 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:155 -msgid "Bytes Total" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:141 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:160 -msgid "Collecting data..." -msgstr "Συλλογή δεδομένων..." - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:224 -msgid "Comment" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default Download Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Default Network Interface" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default Upload Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default unit for download rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default unit for upload rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Default value for download bandwidth" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default value for download rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Default value for upload bandwidth" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default value for upload rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Download Bandwidth (Mbps)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:135 -msgid "Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Enable Limit Rate Feature" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable Traffic Priority" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable this feature" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:121 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:158 -msgid "Hostname" -msgstr "Όνομα κεντρικού υπολογιστή" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:134 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:153 -msgid "IP Address" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:126 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:163 -msgid "IP Address(V4 / V6)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:128 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:165 -msgid "IP Address(V4 Only)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Limit Enable" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Limit Type" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:135 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:172 -msgid "MAC (optional)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:48 -msgid "MB" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:28 -msgid "NFT-QoS Settings" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Network Interface for Traffic Shaping, e.g. br-lan, eth0.1, eth0, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Network to be apply, e.g. 192.168.1.0/24, 10.2.0.0/16, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Network to be apply, e.g. AAAA::BBBB/64, CCCC::1/128, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:65 -msgid "No information available" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:137 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:156 -msgid "Packets Total" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:207 -msgid "Priority" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:199 -msgid "Protocol" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:16 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:23 -msgid "Qos over Nftables" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:12 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:139 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:176 -msgid "Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:130 -msgid "Realtime Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:125 -msgid "Realtime Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:149 -msgid "Realtime Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "Service" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:116 -msgid "Static QoS-Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:153 -msgid "Static QoS-Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Target Network (IPv4/MASK)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Target Network6 (IPv6/MASK)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:127 -msgid "This page gives an overview over currently download/upload rate." -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:194 -msgid "Traffic Priority Settings" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Type of Limit Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:144 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:181 -msgid "Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Upload Bandwidth (Mbps)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:154 -msgid "Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:96 -msgid "White List for Limit Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "e.g. https, 23, (separator is comma)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:44 -msgid "kB" -msgstr "" diff --git a/rooter/0optionalapps/luci-app-nft-qos/po/en/nft-qos.po b/rooter/0optionalapps/luci-app-nft-qos/po/en/nft-qos.po deleted file mode 100644 index f3e6b42..0000000 --- a/rooter/0optionalapps/luci-app-nft-qos/po/en/nft-qos.po +++ /dev/null @@ -1,233 +0,0 @@ -msgid "" -msgstr "" -"Language: en\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:136 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:155 -msgid "Bytes Total" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:141 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:160 -msgid "Collecting data..." -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:224 -msgid "Comment" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default Download Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Default Network Interface" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default Upload Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default unit for download rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default unit for upload rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Default value for download bandwidth" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default value for download rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Default value for upload bandwidth" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default value for upload rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Download Bandwidth (Mbps)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:135 -msgid "Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Enable Limit Rate Feature" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable Traffic Priority" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable this feature" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:121 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:158 -msgid "Hostname" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:134 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:153 -msgid "IP Address" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:126 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:163 -msgid "IP Address(V4 / V6)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:128 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:165 -msgid "IP Address(V4 Only)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Limit Enable" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Limit Type" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:135 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:172 -msgid "MAC (optional)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:48 -msgid "MB" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:28 -msgid "NFT-QoS Settings" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Network Interface for Traffic Shaping, e.g. br-lan, eth0.1, eth0, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Network to be apply, e.g. 192.168.1.0/24, 10.2.0.0/16, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Network to be apply, e.g. AAAA::BBBB/64, CCCC::1/128, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:65 -msgid "No information available" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:137 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:156 -msgid "Packets Total" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:207 -msgid "Priority" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:199 -msgid "Protocol" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:16 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:23 -msgid "Qos over Nftables" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:12 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:139 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:176 -msgid "Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:130 -msgid "Realtime Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:125 -msgid "Realtime Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:149 -msgid "Realtime Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "Service" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:116 -msgid "Static QoS-Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:153 -msgid "Static QoS-Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Target Network (IPv4/MASK)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Target Network6 (IPv6/MASK)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:127 -msgid "This page gives an overview over currently download/upload rate." -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:194 -msgid "Traffic Priority Settings" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Type of Limit Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:144 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:181 -msgid "Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Upload Bandwidth (Mbps)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:154 -msgid "Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:96 -msgid "White List for Limit Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "e.g. https, 23, (separator is comma)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:44 -msgid "kB" -msgstr "" diff --git a/rooter/0optionalapps/luci-app-nft-qos/po/es/nft-qos.po b/rooter/0optionalapps/luci-app-nft-qos/po/es/nft-qos.po deleted file mode 100644 index f12d261..0000000 --- a/rooter/0optionalapps/luci-app-nft-qos/po/es/nft-qos.po +++ /dev/null @@ -1,246 +0,0 @@ -msgid "" -msgstr "" -"Project-Id-Version: \n" -"POT-Creation-Date: \n" -"PO-Revision-Date: 2020-09-18 18:36+0000\n" -"Last-Translator: Franco Castillo \n" -"Language-Team: Spanish \n" -"Language: es\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.3-dev\n" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:136 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:155 -msgid "Bytes Total" -msgstr "Total de bytes" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:141 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:160 -msgid "Collecting data..." -msgstr "Recolectando datos…" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:224 -msgid "Comment" -msgstr "Comentario" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default Download Rate" -msgstr "Velocidad de descarga predeterminada" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default Download Unit" -msgstr "Unidad de descarga predeterminada" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Default Network Interface" -msgstr "Interfaz de red predeterminada" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default Upload Rate" -msgstr "Velocidad de carga predeterminada" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default Upload Unit" -msgstr "Unidad de carga predeterminada" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default unit for download rate" -msgstr "Unidad predeterminada para la velocidad de descarga" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default unit for upload rate" -msgstr "Unidad predeterminada para la velocidad de carga" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Default value for download bandwidth" -msgstr "Valor predeterminado para el ancho de banda de descarga" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default value for download rate" -msgstr "Valor predeterminado para la velocidad de descarga" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Default value for upload bandwidth" -msgstr "Valor predeterminado para el ancho de banda de carga" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default value for upload rate" -msgstr "Valor predeterminado para la velocidad de carga" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Download Bandwidth (Mbps)" -msgstr "Ancho de banda de descarga (Mbps)" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:135 -msgid "Download Rate" -msgstr "Velocidad de descarga" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Enable Limit Rate Feature" -msgstr "Activar función de límite de velocidad" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable Traffic Priority" -msgstr "Activar prioridad de tráfico" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable this feature" -msgstr "Activar esta característica" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:121 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:158 -msgid "Hostname" -msgstr "Nombre del host" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:134 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:153 -msgid "IP Address" -msgstr "Dirección IP" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:126 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:163 -msgid "IP Address(V4 / V6)" -msgstr "Dirección IP (v4/v6)" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:128 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:165 -msgid "IP Address(V4 Only)" -msgstr "Dirección IP (sólo v4)" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Limit Enable" -msgstr "Activar límite" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Limit Type" -msgstr "Tipo de límite" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:135 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:172 -msgid "MAC (optional)" -msgstr "MAC (opcional)" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:48 -msgid "MB" -msgstr "MB" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:28 -msgid "NFT-QoS Settings" -msgstr "Configuración de NFT-QoS" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Network Interface for Traffic Shaping, e.g. br-lan, eth0.1, eth0, etc" -msgstr "" -"Interfaz de red para configuración de tráfico, por ejemplo, br-lan, eth0.1, " -"eth0, etc." - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Network to be apply, e.g. 192.168.1.0/24, 10.2.0.0/16, etc" -msgstr "Red a aplicar, por ejemplo. 192.168.1.0/24, 10.2.0.0/16, etc." - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Network to be apply, e.g. AAAA::BBBB/64, CCCC::1/128, etc" -msgstr "Red a aplicar, por ejemplo. AAAA::BBBB/64, CCCC::1/128, etc." - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:65 -msgid "No information available" -msgstr "No hay información disponible" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:137 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:156 -msgid "Packets Total" -msgstr "Paquetes totales" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:207 -msgid "Priority" -msgstr "Prioridad" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:199 -msgid "Protocol" -msgstr "Protocolo" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:16 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:23 -msgid "Qos over Nftables" -msgstr "Qos sobre Nftables" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:12 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:139 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:176 -msgid "Rate" -msgstr "Velocidad" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:130 -msgid "Realtime Download Rate" -msgstr "Velocidad de descarga en tiempo real" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:125 -msgid "Realtime Rate" -msgstr "Velocidad en tiempo real" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:149 -msgid "Realtime Upload Rate" -msgstr "Velocidad de carga en tiempo real" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "Service" -msgstr "Servicio" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:116 -msgid "Static QoS-Download Rate" -msgstr "Velocidad de descarga de QoS estática" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:153 -msgid "Static QoS-Upload Rate" -msgstr "Velocidad de carga de QoS estática" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Target Network (IPv4/MASK)" -msgstr "Red de destino (IPv4 / MASK)" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Target Network6 (IPv6/MASK)" -msgstr "Red de destino 6 (IPv6/MÁSCARA)" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:127 -msgid "This page gives an overview over currently download/upload rate." -msgstr "" -"Esta página ofrece una vista general sobre la velocidad de descarga/carga " -"actual." - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:194 -msgid "Traffic Priority Settings" -msgstr "Ajustes de prioridad de tráfico" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Type of Limit Rate" -msgstr "Tipo de límite de velocidad" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:144 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:181 -msgid "Unit" -msgstr "Unidad" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Upload Bandwidth (Mbps)" -msgstr "Ancho de banda de carga (Mbps)" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:154 -msgid "Upload Rate" -msgstr "Velocidad de carga" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:96 -msgid "White List for Limit Rate" -msgstr "Lista blanca para el límite de velocidad" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "e.g. https, 23, (separator is comma)" -msgstr "p.ej. https, 23, (el separador es una coma)" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:44 -msgid "kB" -msgstr "kB" diff --git a/rooter/0optionalapps/luci-app-nft-qos/po/fr/nft-qos.po b/rooter/0optionalapps/luci-app-nft-qos/po/fr/nft-qos.po deleted file mode 100644 index 391c427..0000000 --- a/rooter/0optionalapps/luci-app-nft-qos/po/fr/nft-qos.po +++ /dev/null @@ -1,239 +0,0 @@ -msgid "" -msgstr "" -"PO-Revision-Date: 2020-10-24 08:56+0000\n" -"Last-Translator: ButterflyOfFire \n" -"Language-Team: French \n" -"Language: fr\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=n > 1;\n" -"X-Generator: Weblate 4.3.1\n" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:136 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:155 -msgid "Bytes Total" -msgstr "Total octets" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:141 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:160 -msgid "Collecting data..." -msgstr "Récupération des données…" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:224 -msgid "Comment" -msgstr "Commentaire" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default Download Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Default Network Interface" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default Upload Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default unit for download rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default unit for upload rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Default value for download bandwidth" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default value for download rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Default value for upload bandwidth" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default value for upload rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Download Bandwidth (Mbps)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:135 -msgid "Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Enable Limit Rate Feature" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable Traffic Priority" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable this feature" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:121 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:158 -msgid "Hostname" -msgstr "Nom d'hôte" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:134 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:153 -msgid "IP Address" -msgstr "Adresse IP" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:126 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:163 -msgid "IP Address(V4 / V6)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:128 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:165 -msgid "IP Address(V4 Only)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Limit Enable" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Limit Type" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:135 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:172 -msgid "MAC (optional)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:48 -msgid "MB" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:28 -msgid "NFT-QoS Settings" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Network Interface for Traffic Shaping, e.g. br-lan, eth0.1, eth0, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Network to be apply, e.g. 192.168.1.0/24, 10.2.0.0/16, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Network to be apply, e.g. AAAA::BBBB/64, CCCC::1/128, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:65 -msgid "No information available" -msgstr "Information indisponible" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:137 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:156 -msgid "Packets Total" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:207 -msgid "Priority" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:199 -msgid "Protocol" -msgstr "Protocole" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:16 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:23 -msgid "Qos over Nftables" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:12 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:139 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:176 -msgid "Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:130 -msgid "Realtime Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:125 -msgid "Realtime Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:149 -msgid "Realtime Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "Service" -msgstr "Service" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:116 -msgid "Static QoS-Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:153 -msgid "Static QoS-Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Target Network (IPv4/MASK)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Target Network6 (IPv6/MASK)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:127 -msgid "This page gives an overview over currently download/upload rate." -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:194 -msgid "Traffic Priority Settings" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Type of Limit Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:144 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:181 -msgid "Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Upload Bandwidth (Mbps)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:154 -msgid "Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:96 -msgid "White List for Limit Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "e.g. https, 23, (separator is comma)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:44 -msgid "kB" -msgstr "" diff --git a/rooter/0optionalapps/luci-app-nft-qos/po/he/nft-qos.po b/rooter/0optionalapps/luci-app-nft-qos/po/he/nft-qos.po deleted file mode 100644 index b182668..0000000 --- a/rooter/0optionalapps/luci-app-nft-qos/po/he/nft-qos.po +++ /dev/null @@ -1,240 +0,0 @@ -msgid "" -msgstr "" -"PO-Revision-Date: 2020-10-17 15:26+0000\n" -"Last-Translator: Yaron Shahrabani \n" -"Language-Team: Hebrew \n" -"Language: he\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=4; plural=(n == 1) ? 0 : ((n == 2) ? 1 : ((n > 10 && " -"n % 10 == 0) ? 2 : 3));\n" -"X-Generator: Weblate 4.3.1-dev\n" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:136 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:155 -msgid "Bytes Total" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:141 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:160 -msgid "Collecting data..." -msgstr "נאספים נתונים…" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:224 -msgid "Comment" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default Download Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Default Network Interface" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default Upload Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default unit for download rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default unit for upload rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Default value for download bandwidth" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default value for download rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Default value for upload bandwidth" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default value for upload rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Download Bandwidth (Mbps)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:135 -msgid "Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Enable Limit Rate Feature" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable Traffic Priority" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable this feature" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:121 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:158 -msgid "Hostname" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:134 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:153 -msgid "IP Address" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:126 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:163 -msgid "IP Address(V4 / V6)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:128 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:165 -msgid "IP Address(V4 Only)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Limit Enable" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Limit Type" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:135 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:172 -msgid "MAC (optional)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:48 -msgid "MB" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:28 -msgid "NFT-QoS Settings" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Network Interface for Traffic Shaping, e.g. br-lan, eth0.1, eth0, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Network to be apply, e.g. 192.168.1.0/24, 10.2.0.0/16, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Network to be apply, e.g. AAAA::BBBB/64, CCCC::1/128, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:65 -msgid "No information available" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:137 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:156 -msgid "Packets Total" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:207 -msgid "Priority" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:199 -msgid "Protocol" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:16 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:23 -msgid "Qos over Nftables" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:12 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:139 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:176 -msgid "Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:130 -msgid "Realtime Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:125 -msgid "Realtime Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:149 -msgid "Realtime Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "Service" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:116 -msgid "Static QoS-Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:153 -msgid "Static QoS-Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Target Network (IPv4/MASK)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Target Network6 (IPv6/MASK)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:127 -msgid "This page gives an overview over currently download/upload rate." -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:194 -msgid "Traffic Priority Settings" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Type of Limit Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:144 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:181 -msgid "Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Upload Bandwidth (Mbps)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:154 -msgid "Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:96 -msgid "White List for Limit Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "e.g. https, 23, (separator is comma)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:44 -msgid "kB" -msgstr "" diff --git a/rooter/0optionalapps/luci-app-nft-qos/po/hi/nft-qos.po b/rooter/0optionalapps/luci-app-nft-qos/po/hi/nft-qos.po deleted file mode 100644 index 29961a2..0000000 --- a/rooter/0optionalapps/luci-app-nft-qos/po/hi/nft-qos.po +++ /dev/null @@ -1,233 +0,0 @@ -msgid "" -msgstr "" -"Language: hi\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:136 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:155 -msgid "Bytes Total" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:141 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:160 -msgid "Collecting data..." -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:224 -msgid "Comment" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default Download Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Default Network Interface" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default Upload Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default unit for download rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default unit for upload rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Default value for download bandwidth" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default value for download rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Default value for upload bandwidth" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default value for upload rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Download Bandwidth (Mbps)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:135 -msgid "Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Enable Limit Rate Feature" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable Traffic Priority" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable this feature" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:121 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:158 -msgid "Hostname" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:134 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:153 -msgid "IP Address" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:126 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:163 -msgid "IP Address(V4 / V6)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:128 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:165 -msgid "IP Address(V4 Only)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Limit Enable" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Limit Type" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:135 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:172 -msgid "MAC (optional)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:48 -msgid "MB" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:28 -msgid "NFT-QoS Settings" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Network Interface for Traffic Shaping, e.g. br-lan, eth0.1, eth0, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Network to be apply, e.g. 192.168.1.0/24, 10.2.0.0/16, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Network to be apply, e.g. AAAA::BBBB/64, CCCC::1/128, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:65 -msgid "No information available" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:137 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:156 -msgid "Packets Total" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:207 -msgid "Priority" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:199 -msgid "Protocol" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:16 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:23 -msgid "Qos over Nftables" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:12 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:139 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:176 -msgid "Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:130 -msgid "Realtime Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:125 -msgid "Realtime Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:149 -msgid "Realtime Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "Service" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:116 -msgid "Static QoS-Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:153 -msgid "Static QoS-Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Target Network (IPv4/MASK)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Target Network6 (IPv6/MASK)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:127 -msgid "This page gives an overview over currently download/upload rate." -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:194 -msgid "Traffic Priority Settings" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Type of Limit Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:144 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:181 -msgid "Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Upload Bandwidth (Mbps)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:154 -msgid "Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:96 -msgid "White List for Limit Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "e.g. https, 23, (separator is comma)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:44 -msgid "kB" -msgstr "" diff --git a/rooter/0optionalapps/luci-app-nft-qos/po/hu/nft-qos.po b/rooter/0optionalapps/luci-app-nft-qos/po/hu/nft-qos.po deleted file mode 100644 index 1027fc6..0000000 --- a/rooter/0optionalapps/luci-app-nft-qos/po/hu/nft-qos.po +++ /dev/null @@ -1,240 +0,0 @@ -msgid "" -msgstr "" -"PO-Revision-Date: 2020-01-08 19:28+0000\n" -"Last-Translator: Balázs Úr \n" -"Language-Team: Hungarian \n" -"Language: hu\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 3.10.1-dev\n" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:136 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:155 -msgid "Bytes Total" -msgstr "Bájt összesen" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:141 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:160 -msgid "Collecting data..." -msgstr "Adatok összegyűjtése…" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:224 -msgid "Comment" -msgstr "Megjegyzés" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default Download Rate" -msgstr "Alapértelmezett letöltési arány" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default Download Unit" -msgstr "Alapértelmezett letöltési mértékegység" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Default Network Interface" -msgstr "Alapértelmezett hálózati csatoló" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default Upload Rate" -msgstr "Alapértelmezett feltöltési arány" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default Upload Unit" -msgstr "Alapértelmezett feltöltési mértékegység" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default unit for download rate" -msgstr "Alapértelmezett mértékegység a letöltési aránynál" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default unit for upload rate" -msgstr "Alapértelmezett mértékegység a feltöltési aránynál" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Default value for download bandwidth" -msgstr "Alapértelmezett érték a letöltési sávszélességnél" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default value for download rate" -msgstr "Alapértelmezett érték a letöltési aránynál" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Default value for upload bandwidth" -msgstr "Alapértelmezett érték a feltöltési sávszélességnél" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default value for upload rate" -msgstr "Alapértelmezett érték a feltöltési aránynál" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Download Bandwidth (Mbps)" -msgstr "Letöltési sávszélesség (Mbps)" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:135 -msgid "Download Rate" -msgstr "Letöltési arány" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Enable Limit Rate Feature" -msgstr "Arány korlátozása funkció engedélyezése" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable Traffic Priority" -msgstr "Forgalomprioritás engedélyezése" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable this feature" -msgstr "A funkció engedélyezése" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:121 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:158 -msgid "Hostname" -msgstr "Gépnév" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:134 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:153 -msgid "IP Address" -msgstr "IP-cím" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:126 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:163 -msgid "IP Address(V4 / V6)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:128 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:165 -msgid "IP Address(V4 Only)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Limit Enable" -msgstr "Korlátozás engedélyezése" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Limit Type" -msgstr "Korlát típusa" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:135 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:172 -msgid "MAC (optional)" -msgstr "MAC (elhagyható)" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:48 -msgid "MB" -msgstr "MB" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:28 -msgid "NFT-QoS Settings" -msgstr "NFT-QoS beállítások" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Network Interface for Traffic Shaping, e.g. br-lan, eth0.1, eth0, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Network to be apply, e.g. 192.168.1.0/24, 10.2.0.0/16, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Network to be apply, e.g. AAAA::BBBB/64, CCCC::1/128, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:65 -msgid "No information available" -msgstr "Nincs elérhető információ" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:137 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:156 -msgid "Packets Total" -msgstr "Csomagok összesen" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:207 -msgid "Priority" -msgstr "Prioritás" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:199 -msgid "Protocol" -msgstr "Protokoll" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:16 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:23 -msgid "Qos over Nftables" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:12 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:139 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:176 -msgid "Rate" -msgstr "Arány" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:130 -msgid "Realtime Download Rate" -msgstr "Valós idejű letöltési arány" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:125 -msgid "Realtime Rate" -msgstr "Valós idejű arány" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:149 -msgid "Realtime Upload Rate" -msgstr "Valós idejű feltöltési arány" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "Service" -msgstr "Szolgáltatás" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:116 -msgid "Static QoS-Download Rate" -msgstr "Statikus QoS-letöltési arány" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:153 -msgid "Static QoS-Upload Rate" -msgstr "Statikus QoS feltöltési arány" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Target Network (IPv4/MASK)" -msgstr "Célhálózat (IPv4/MASZK)" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Target Network6 (IPv6/MASK)" -msgstr "Célhálózat 6 (IPv6/MASZK)" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:127 -msgid "This page gives an overview over currently download/upload rate." -msgstr "" -"Ez az oldal áttekintést ad a jelenlegi letöltési és feltöltési arányról." - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:194 -msgid "Traffic Priority Settings" -msgstr "Forgalomprioritás beállításai" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Type of Limit Rate" -msgstr "Arány korlátozásának típusa" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:144 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:181 -msgid "Unit" -msgstr "Mértékegység" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Upload Bandwidth (Mbps)" -msgstr "Feltöltési sávszélesség (Mbps)" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:154 -msgid "Upload Rate" -msgstr "Feltöltési arány" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:96 -msgid "White List for Limit Rate" -msgstr "Fehérlista az arány korlátázásához" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "e.g. https, 23, (separator is comma)" -msgstr "például https, 23, (vesszővel elválasztva)" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:44 -msgid "kB" -msgstr "kB" diff --git a/rooter/0optionalapps/luci-app-nft-qos/po/it/nft-qos.po b/rooter/0optionalapps/luci-app-nft-qos/po/it/nft-qos.po deleted file mode 100644 index 0635c24..0000000 --- a/rooter/0optionalapps/luci-app-nft-qos/po/it/nft-qos.po +++ /dev/null @@ -1,239 +0,0 @@ -msgid "" -msgstr "" -"PO-Revision-Date: 2020-03-04 04:29+0000\n" -"Last-Translator: TuxAlex0 \n" -"Language-Team: Italian \n" -"Language: it\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.0-dev\n" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:136 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:155 -msgid "Bytes Total" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:141 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:160 -msgid "Collecting data..." -msgstr "Raccolta dati..." - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:224 -msgid "Comment" -msgstr "Commento" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default Download Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Default Network Interface" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default Upload Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default unit for download rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default unit for upload rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Default value for download bandwidth" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default value for download rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Default value for upload bandwidth" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default value for upload rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Download Bandwidth (Mbps)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:135 -msgid "Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Enable Limit Rate Feature" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable Traffic Priority" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable this feature" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:121 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:158 -msgid "Hostname" -msgstr "Hostname" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:134 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:153 -msgid "IP Address" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:126 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:163 -msgid "IP Address(V4 / V6)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:128 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:165 -msgid "IP Address(V4 Only)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Limit Enable" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Limit Type" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:135 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:172 -msgid "MAC (optional)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:48 -msgid "MB" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:28 -msgid "NFT-QoS Settings" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Network Interface for Traffic Shaping, e.g. br-lan, eth0.1, eth0, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Network to be apply, e.g. 192.168.1.0/24, 10.2.0.0/16, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Network to be apply, e.g. AAAA::BBBB/64, CCCC::1/128, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:65 -msgid "No information available" -msgstr "Nessuna informazione disponibile" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:137 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:156 -msgid "Packets Total" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:207 -msgid "Priority" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:199 -msgid "Protocol" -msgstr "Protocollo" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:16 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:23 -msgid "Qos over Nftables" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:12 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:139 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:176 -msgid "Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:130 -msgid "Realtime Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:125 -msgid "Realtime Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:149 -msgid "Realtime Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "Service" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:116 -msgid "Static QoS-Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:153 -msgid "Static QoS-Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Target Network (IPv4/MASK)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Target Network6 (IPv6/MASK)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:127 -msgid "This page gives an overview over currently download/upload rate." -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:194 -msgid "Traffic Priority Settings" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Type of Limit Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:144 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:181 -msgid "Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Upload Bandwidth (Mbps)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:154 -msgid "Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:96 -msgid "White List for Limit Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "e.g. https, 23, (separator is comma)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:44 -msgid "kB" -msgstr "" diff --git a/rooter/0optionalapps/luci-app-nft-qos/po/ja/nft-qos.po b/rooter/0optionalapps/luci-app-nft-qos/po/ja/nft-qos.po deleted file mode 100644 index 186ecb0..0000000 --- a/rooter/0optionalapps/luci-app-nft-qos/po/ja/nft-qos.po +++ /dev/null @@ -1,239 +0,0 @@ -msgid "" -msgstr "" -"PO-Revision-Date: 2020-10-10 13:26+0000\n" -"Last-Translator: RyotaGamer <21ryotagamer@gmail.com>\n" -"Language-Team: Japanese \n" -"Language: ja\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: Weblate 4.3-dev\n" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:136 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:155 -msgid "Bytes Total" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:141 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:160 -msgid "Collecting data..." -msgstr "データを収集中..." - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:224 -msgid "Comment" -msgstr "コメント" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default Download Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Default Network Interface" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default Upload Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default unit for download rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default unit for upload rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Default value for download bandwidth" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default value for download rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Default value for upload bandwidth" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default value for upload rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Download Bandwidth (Mbps)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:135 -msgid "Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Enable Limit Rate Feature" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable Traffic Priority" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable this feature" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:121 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:158 -msgid "Hostname" -msgstr "ホスト名" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:134 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:153 -msgid "IP Address" -msgstr "IP アドレス" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:126 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:163 -msgid "IP Address(V4 / V6)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:128 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:165 -msgid "IP Address(V4 Only)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Limit Enable" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Limit Type" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:135 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:172 -msgid "MAC (optional)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:48 -msgid "MB" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:28 -msgid "NFT-QoS Settings" -msgstr "NFT-QoS 設定" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Network Interface for Traffic Shaping, e.g. br-lan, eth0.1, eth0, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Network to be apply, e.g. 192.168.1.0/24, 10.2.0.0/16, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Network to be apply, e.g. AAAA::BBBB/64, CCCC::1/128, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:65 -msgid "No information available" -msgstr "情報なし" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:137 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:156 -msgid "Packets Total" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:207 -msgid "Priority" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:199 -msgid "Protocol" -msgstr "プロトコル" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:16 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:23 -msgid "Qos over Nftables" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:12 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:139 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:176 -msgid "Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:130 -msgid "Realtime Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:125 -msgid "Realtime Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:149 -msgid "Realtime Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "Service" -msgstr "サービス" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:116 -msgid "Static QoS-Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:153 -msgid "Static QoS-Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Target Network (IPv4/MASK)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Target Network6 (IPv6/MASK)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:127 -msgid "This page gives an overview over currently download/upload rate." -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:194 -msgid "Traffic Priority Settings" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Type of Limit Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:144 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:181 -msgid "Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Upload Bandwidth (Mbps)" -msgstr "アップロード帯域幅 (Mbps)" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:154 -msgid "Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:96 -msgid "White List for Limit Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "e.g. https, 23, (separator is comma)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:44 -msgid "kB" -msgstr "" diff --git a/rooter/0optionalapps/luci-app-nft-qos/po/ko/nft-qos.po b/rooter/0optionalapps/luci-app-nft-qos/po/ko/nft-qos.po deleted file mode 100644 index 5a3f704..0000000 --- a/rooter/0optionalapps/luci-app-nft-qos/po/ko/nft-qos.po +++ /dev/null @@ -1,239 +0,0 @@ -msgid "" -msgstr "" -"PO-Revision-Date: 2020-07-28 17:55+0000\n" -"Last-Translator: TheNoFace \n" -"Language-Team: Korean \n" -"Language: ko\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: Weblate 4.2-dev\n" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:136 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:155 -msgid "Bytes Total" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:141 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:160 -msgid "Collecting data..." -msgstr "데이터 수집 중..." - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:224 -msgid "Comment" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default Download Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Default Network Interface" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default Upload Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default unit for download rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default unit for upload rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Default value for download bandwidth" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default value for download rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Default value for upload bandwidth" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default value for upload rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Download Bandwidth (Mbps)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:135 -msgid "Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Enable Limit Rate Feature" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable Traffic Priority" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable this feature" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:121 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:158 -msgid "Hostname" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:134 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:153 -msgid "IP Address" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:126 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:163 -msgid "IP Address(V4 / V6)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:128 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:165 -msgid "IP Address(V4 Only)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Limit Enable" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Limit Type" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:135 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:172 -msgid "MAC (optional)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:48 -msgid "MB" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:28 -msgid "NFT-QoS Settings" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Network Interface for Traffic Shaping, e.g. br-lan, eth0.1, eth0, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Network to be apply, e.g. 192.168.1.0/24, 10.2.0.0/16, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Network to be apply, e.g. AAAA::BBBB/64, CCCC::1/128, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:65 -msgid "No information available" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:137 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:156 -msgid "Packets Total" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:207 -msgid "Priority" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:199 -msgid "Protocol" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:16 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:23 -msgid "Qos over Nftables" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:12 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:139 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:176 -msgid "Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:130 -msgid "Realtime Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:125 -msgid "Realtime Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:149 -msgid "Realtime Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "Service" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:116 -msgid "Static QoS-Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:153 -msgid "Static QoS-Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Target Network (IPv4/MASK)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Target Network6 (IPv6/MASK)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:127 -msgid "This page gives an overview over currently download/upload rate." -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:194 -msgid "Traffic Priority Settings" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Type of Limit Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:144 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:181 -msgid "Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Upload Bandwidth (Mbps)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:154 -msgid "Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:96 -msgid "White List for Limit Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "e.g. https, 23, (separator is comma)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:44 -msgid "kB" -msgstr "" diff --git a/rooter/0optionalapps/luci-app-nft-qos/po/mr/nft-qos.po b/rooter/0optionalapps/luci-app-nft-qos/po/mr/nft-qos.po deleted file mode 100644 index 86c0604..0000000 --- a/rooter/0optionalapps/luci-app-nft-qos/po/mr/nft-qos.po +++ /dev/null @@ -1,239 +0,0 @@ -msgid "" -msgstr "" -"PO-Revision-Date: 2020-02-07 09:18+0000\n" -"Last-Translator: Prachi Joshi \n" -"Language-Team: Marathi \n" -"Language: mr\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=n > 1;\n" -"X-Generator: Weblate 3.11-dev\n" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:136 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:155 -msgid "Bytes Total" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:141 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:160 -msgid "Collecting data..." -msgstr "डेटा संकलित करीत आहे ..." - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:224 -msgid "Comment" -msgstr "टिप्पणी" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default Download Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Default Network Interface" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default Upload Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default unit for download rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default unit for upload rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Default value for download bandwidth" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default value for download rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Default value for upload bandwidth" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default value for upload rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Download Bandwidth (Mbps)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:135 -msgid "Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Enable Limit Rate Feature" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable Traffic Priority" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable this feature" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:121 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:158 -msgid "Hostname" -msgstr "होस्टनाव" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:134 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:153 -msgid "IP Address" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:126 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:163 -msgid "IP Address(V4 / V6)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:128 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:165 -msgid "IP Address(V4 Only)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Limit Enable" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Limit Type" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:135 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:172 -msgid "MAC (optional)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:48 -msgid "MB" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:28 -msgid "NFT-QoS Settings" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Network Interface for Traffic Shaping, e.g. br-lan, eth0.1, eth0, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Network to be apply, e.g. 192.168.1.0/24, 10.2.0.0/16, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Network to be apply, e.g. AAAA::BBBB/64, CCCC::1/128, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:65 -msgid "No information available" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:137 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:156 -msgid "Packets Total" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:207 -msgid "Priority" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:199 -msgid "Protocol" -msgstr "प्रोटोकॉल" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:16 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:23 -msgid "Qos over Nftables" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:12 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:139 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:176 -msgid "Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:130 -msgid "Realtime Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:125 -msgid "Realtime Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:149 -msgid "Realtime Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "Service" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:116 -msgid "Static QoS-Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:153 -msgid "Static QoS-Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Target Network (IPv4/MASK)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Target Network6 (IPv6/MASK)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:127 -msgid "This page gives an overview over currently download/upload rate." -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:194 -msgid "Traffic Priority Settings" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Type of Limit Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:144 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:181 -msgid "Unit" -msgstr "युनिट" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Upload Bandwidth (Mbps)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:154 -msgid "Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:96 -msgid "White List for Limit Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "e.g. https, 23, (separator is comma)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:44 -msgid "kB" -msgstr "" diff --git a/rooter/0optionalapps/luci-app-nft-qos/po/ms/nft-qos.po b/rooter/0optionalapps/luci-app-nft-qos/po/ms/nft-qos.po deleted file mode 100644 index 08bfab1..0000000 --- a/rooter/0optionalapps/luci-app-nft-qos/po/ms/nft-qos.po +++ /dev/null @@ -1,239 +0,0 @@ -msgid "" -msgstr "" -"PO-Revision-Date: 2019-12-16 23:25+0000\n" -"Last-Translator: Pusak Hitam \n" -"Language-Team: Malay \n" -"Language: ms\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: Weblate 3.10-dev\n" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:136 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:155 -msgid "Bytes Total" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:141 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:160 -msgid "Collecting data..." -msgstr "Mengumpul data..." - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:224 -msgid "Comment" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default Download Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Default Network Interface" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default Upload Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default unit for download rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default unit for upload rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Default value for download bandwidth" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default value for download rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Default value for upload bandwidth" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default value for upload rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Download Bandwidth (Mbps)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:135 -msgid "Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Enable Limit Rate Feature" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable Traffic Priority" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable this feature" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:121 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:158 -msgid "Hostname" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:134 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:153 -msgid "IP Address" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:126 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:163 -msgid "IP Address(V4 / V6)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:128 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:165 -msgid "IP Address(V4 Only)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Limit Enable" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Limit Type" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:135 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:172 -msgid "MAC (optional)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:48 -msgid "MB" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:28 -msgid "NFT-QoS Settings" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Network Interface for Traffic Shaping, e.g. br-lan, eth0.1, eth0, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Network to be apply, e.g. 192.168.1.0/24, 10.2.0.0/16, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Network to be apply, e.g. AAAA::BBBB/64, CCCC::1/128, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:65 -msgid "No information available" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:137 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:156 -msgid "Packets Total" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:207 -msgid "Priority" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:199 -msgid "Protocol" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:16 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:23 -msgid "Qos over Nftables" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:12 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:139 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:176 -msgid "Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:130 -msgid "Realtime Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:125 -msgid "Realtime Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:149 -msgid "Realtime Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "Service" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:116 -msgid "Static QoS-Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:153 -msgid "Static QoS-Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Target Network (IPv4/MASK)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Target Network6 (IPv6/MASK)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:127 -msgid "This page gives an overview over currently download/upload rate." -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:194 -msgid "Traffic Priority Settings" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Type of Limit Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:144 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:181 -msgid "Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Upload Bandwidth (Mbps)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:154 -msgid "Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:96 -msgid "White List for Limit Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "e.g. https, 23, (separator is comma)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:44 -msgid "kB" -msgstr "" diff --git a/rooter/0optionalapps/luci-app-nft-qos/po/nb_NO/nft-qos.po b/rooter/0optionalapps/luci-app-nft-qos/po/nb_NO/nft-qos.po deleted file mode 100644 index 5ecf971..0000000 --- a/rooter/0optionalapps/luci-app-nft-qos/po/nb_NO/nft-qos.po +++ /dev/null @@ -1,239 +0,0 @@ -msgid "" -msgstr "" -"PO-Revision-Date: 2019-10-30 03:21+0000\n" -"Last-Translator: Allan Nordhøy \n" -"Language-Team: Norwegian Bokmål \n" -"Language: nb_NO\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 3.9.1\n" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:136 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:155 -msgid "Bytes Total" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:141 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:160 -msgid "Collecting data..." -msgstr "Samler inn data…" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:224 -msgid "Comment" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default Download Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Default Network Interface" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default Upload Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default unit for download rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default unit for upload rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Default value for download bandwidth" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default value for download rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Default value for upload bandwidth" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default value for upload rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Download Bandwidth (Mbps)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:135 -msgid "Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Enable Limit Rate Feature" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable Traffic Priority" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable this feature" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:121 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:158 -msgid "Hostname" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:134 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:153 -msgid "IP Address" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:126 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:163 -msgid "IP Address(V4 / V6)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:128 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:165 -msgid "IP Address(V4 Only)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Limit Enable" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Limit Type" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:135 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:172 -msgid "MAC (optional)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:48 -msgid "MB" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:28 -msgid "NFT-QoS Settings" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Network Interface for Traffic Shaping, e.g. br-lan, eth0.1, eth0, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Network to be apply, e.g. 192.168.1.0/24, 10.2.0.0/16, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Network to be apply, e.g. AAAA::BBBB/64, CCCC::1/128, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:65 -msgid "No information available" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:137 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:156 -msgid "Packets Total" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:207 -msgid "Priority" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:199 -msgid "Protocol" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:16 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:23 -msgid "Qos over Nftables" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:12 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:139 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:176 -msgid "Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:130 -msgid "Realtime Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:125 -msgid "Realtime Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:149 -msgid "Realtime Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "Service" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:116 -msgid "Static QoS-Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:153 -msgid "Static QoS-Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Target Network (IPv4/MASK)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Target Network6 (IPv6/MASK)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:127 -msgid "This page gives an overview over currently download/upload rate." -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:194 -msgid "Traffic Priority Settings" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Type of Limit Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:144 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:181 -msgid "Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Upload Bandwidth (Mbps)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:154 -msgid "Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:96 -msgid "White List for Limit Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "e.g. https, 23, (separator is comma)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:44 -msgid "kB" -msgstr "" diff --git a/rooter/0optionalapps/luci-app-nft-qos/po/pl/nft-qos.po b/rooter/0optionalapps/luci-app-nft-qos/po/pl/nft-qos.po deleted file mode 100644 index 7342882..0000000 --- a/rooter/0optionalapps/luci-app-nft-qos/po/pl/nft-qos.po +++ /dev/null @@ -1,240 +0,0 @@ -msgid "" -msgstr "" -"PO-Revision-Date: 2020-09-19 18:03+0000\n" -"Last-Translator: Marcin Net \n" -"Language-Team: Polish \n" -"Language: pl\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=3; plural=n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 " -"|| n%100>=20) ? 1 : 2;\n" -"X-Generator: Weblate 4.3-dev\n" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:136 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:155 -msgid "Bytes Total" -msgstr "Bajty ogółem" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:141 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:160 -msgid "Collecting data..." -msgstr "Trwa zbieranie danych..." - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:224 -msgid "Comment" -msgstr "Komentarz" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default Download Rate" -msgstr "Domyślna szybkość pobierania" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default Download Unit" -msgstr "Domyślna jednostka pobierania" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Default Network Interface" -msgstr "Domyślny interfejs sieciowy" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default Upload Rate" -msgstr "Domyślna szybkość przesyłania" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default Upload Unit" -msgstr "Domyślna jednostka przesyłania" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default unit for download rate" -msgstr "Domyślna jednostka dla szybkości pobierania" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default unit for upload rate" -msgstr "Domyślna jednostka szybkości wysyłania" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Default value for download bandwidth" -msgstr "Wartość domyślna dla przepustowości pobierania" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default value for download rate" -msgstr "Wartość domyślna dla szybkości pobierania" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Default value for upload bandwidth" -msgstr "Wartość domyślna dla przepustowości wysyłania" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default value for upload rate" -msgstr "Wartość domyślna szybkości wysyłania" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Download Bandwidth (Mbps)" -msgstr "Przepustowość pobierania (Mbps)" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:135 -msgid "Download Rate" -msgstr "Szybkość pobierania" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Enable Limit Rate Feature" -msgstr "Włącz funkcję limitu prędkości" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable Traffic Priority" -msgstr "Włącz priorytet ruchu" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable this feature" -msgstr "Włącz tę funkcję" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:121 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:158 -msgid "Hostname" -msgstr "Nazwa hosta" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:134 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:153 -msgid "IP Address" -msgstr "Adres IP" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:126 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:163 -msgid "IP Address(V4 / V6)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:128 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:165 -msgid "IP Address(V4 Only)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Limit Enable" -msgstr "Włącz limit" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Limit Type" -msgstr "Typ limitu" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:135 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:172 -msgid "MAC (optional)" -msgstr "MAC (opcjonalnie)" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:48 -msgid "MB" -msgstr "MB" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:28 -msgid "NFT-QoS Settings" -msgstr "Ustawienia NFT-QoS" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Network Interface for Traffic Shaping, e.g. br-lan, eth0.1, eth0, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Network to be apply, e.g. 192.168.1.0/24, 10.2.0.0/16, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Network to be apply, e.g. AAAA::BBBB/64, CCCC::1/128, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:65 -msgid "No information available" -msgstr "Brak dostępnych informacji" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:137 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:156 -msgid "Packets Total" -msgstr "Suma pakietów" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:207 -msgid "Priority" -msgstr "Priorytet" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:199 -msgid "Protocol" -msgstr "Protokół" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:16 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:23 -msgid "Qos over Nftables" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:12 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:139 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:176 -msgid "Rate" -msgstr "Tempo" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:130 -msgid "Realtime Download Rate" -msgstr "Szybkość pobierania w czasie rzeczywistym" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:125 -msgid "Realtime Rate" -msgstr "Szybkość w czasie rzeczywistym" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:149 -msgid "Realtime Upload Rate" -msgstr "Szybkość wysyłania w czasie rzeczywistym" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "Service" -msgstr "Usługa" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:116 -msgid "Static QoS-Download Rate" -msgstr "Statyczna prędkość pobierania QoS" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:153 -msgid "Static QoS-Upload Rate" -msgstr "Statyczna prędkość wysyłania QoS" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Target Network (IPv4/MASK)" -msgstr "Sieć docelowa (IPv4/Maska)" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Target Network6 (IPv6/MASK)" -msgstr "Sieć docelowa (IPv6/Maska)" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:127 -msgid "This page gives an overview over currently download/upload rate." -msgstr "Ta strona zawiera przegląd aktualnej prędkości pobierania/wysyłania." - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:194 -msgid "Traffic Priority Settings" -msgstr "Ustawienia priorytetu ruchu sieciowego" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Type of Limit Rate" -msgstr "Typ limitu prędkości" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:144 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:181 -msgid "Unit" -msgstr "Jednostka" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Upload Bandwidth (Mbps)" -msgstr "Przepustowość przesyłania (Mbps)" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:154 -msgid "Upload Rate" -msgstr "Szybkość wysyłania" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:96 -msgid "White List for Limit Rate" -msgstr "Biała lista dla limitu prędkości" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "e.g. https, 23, (separator is comma)" -msgstr "np. https, 23, (separator to przecinek)" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:44 -msgid "kB" -msgstr "kB" diff --git a/rooter/0optionalapps/luci-app-nft-qos/po/pt/nft-qos.po b/rooter/0optionalapps/luci-app-nft-qos/po/pt/nft-qos.po deleted file mode 100644 index 8c6b36e..0000000 --- a/rooter/0optionalapps/luci-app-nft-qos/po/pt/nft-qos.po +++ /dev/null @@ -1,240 +0,0 @@ -msgid "" -msgstr "" -"PO-Revision-Date: 2020-09-18 18:36+0000\n" -"Last-Translator: ssantos \n" -"Language-Team: Portuguese \n" -"Language: pt\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=n > 1;\n" -"X-Generator: Weblate 4.3-dev\n" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:136 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:155 -msgid "Bytes Total" -msgstr "Total de Bytes" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:141 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:160 -msgid "Collecting data..." -msgstr "A recolher dados..." - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:224 -msgid "Comment" -msgstr "Comentário" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default Download Rate" -msgstr "Taxa de Descarregamento Padrão" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default Download Unit" -msgstr "Unidade de Descarregamento Padrão" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Default Network Interface" -msgstr "Interface de Rede Padrão" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default Upload Rate" -msgstr "Taxa de Envio Padrão" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default Upload Unit" -msgstr "Unidade de Envio Padrão" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default unit for download rate" -msgstr "Unidade padrão para taxa de descarregamento" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default unit for upload rate" -msgstr "Unidade padrão para taxa de envio" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Default value for download bandwidth" -msgstr "Valor padrão para largura de banda de descarregamento" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default value for download rate" -msgstr "Valor padrão para taxa de descarregamento" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Default value for upload bandwidth" -msgstr "Valor padrão para a largura de banda de envio" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default value for upload rate" -msgstr "Valor padrão para a taxa de envio" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Download Bandwidth (Mbps)" -msgstr "Largura de Banda de Descarregamento (Mbps)" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:135 -msgid "Download Rate" -msgstr "Taxa de Descarregamento" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Enable Limit Rate Feature" -msgstr "Ativar Recurso de Limite de Taxa" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable Traffic Priority" -msgstr "Ativar Prioridade de Tráfego" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable this feature" -msgstr "Ativar este recurso" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:121 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:158 -msgid "Hostname" -msgstr "Nome do Host" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:134 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:153 -msgid "IP Address" -msgstr "Endereço IP" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:126 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:163 -msgid "IP Address(V4 / V6)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:128 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:165 -msgid "IP Address(V4 Only)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Limit Enable" -msgstr "Limitar Ativação" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Limit Type" -msgstr "Tipo de Limite" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:135 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:172 -msgid "MAC (optional)" -msgstr "MAC (opcional)" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:48 -msgid "MB" -msgstr "MB" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:28 -msgid "NFT-QoS Settings" -msgstr "Configurações NFT-QoS" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Network Interface for Traffic Shaping, e.g. br-lan, eth0.1, eth0, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Network to be apply, e.g. 192.168.1.0/24, 10.2.0.0/16, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Network to be apply, e.g. AAAA::BBBB/64, CCCC::1/128, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:65 -msgid "No information available" -msgstr "Sem informação disponível" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:137 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:156 -msgid "Packets Total" -msgstr "Total de Pacotes" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:207 -msgid "Priority" -msgstr "Prioridade" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:199 -msgid "Protocol" -msgstr "Protocolo" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:16 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:23 -msgid "Qos over Nftables" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:12 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:139 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:176 -msgid "Rate" -msgstr "Taxa" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:130 -msgid "Realtime Download Rate" -msgstr "Taxa de Descarregamento em Tempo Real" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:125 -msgid "Realtime Rate" -msgstr "Taxa em Tempo Real" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:149 -msgid "Realtime Upload Rate" -msgstr "Taxa de Envio em Tempo Real" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "Service" -msgstr "Serviço" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:116 -msgid "Static QoS-Download Rate" -msgstr "Taxa Estática de Descarregamanto de QoS" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:153 -msgid "Static QoS-Upload Rate" -msgstr "Taxa Estática de Envio QoS" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Target Network (IPv4/MASK)" -msgstr "Rede de Destino (IPv4/MASK)" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Target Network6 (IPv6/MASK)" -msgstr "Rede6 de Destino (IPv6/MASK)" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:127 -msgid "This page gives an overview over currently download/upload rate." -msgstr "" -"Esta página dá uma visão geral sobre a taxa de descarregamento/envio atual." - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:194 -msgid "Traffic Priority Settings" -msgstr "Configurações de Prioridade de Tráfego" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Type of Limit Rate" -msgstr "Tipo de Taxa Limite" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:144 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:181 -msgid "Unit" -msgstr "Unidade" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Upload Bandwidth (Mbps)" -msgstr "Largura de Banda de Envio (Mbps)" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:154 -msgid "Upload Rate" -msgstr "Taxa de Envio" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:96 -msgid "White List for Limit Rate" -msgstr "Lista Branca para a Taxa Limite" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "e.g. https, 23, (separator is comma)" -msgstr "por exemplo https, 23, (o separador é vírgula)" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:44 -msgid "kB" -msgstr "kB" diff --git a/rooter/0optionalapps/luci-app-nft-qos/po/pt_BR/nft-qos.po b/rooter/0optionalapps/luci-app-nft-qos/po/pt_BR/nft-qos.po deleted file mode 100644 index 40f436d..0000000 --- a/rooter/0optionalapps/luci-app-nft-qos/po/pt_BR/nft-qos.po +++ /dev/null @@ -1,239 +0,0 @@ -msgid "" -msgstr "" -"PO-Revision-Date: 2020-09-17 16:34+0000\n" -"Last-Translator: Wellington Terumi Uemura \n" -"Language-Team: Portuguese (Brazil) \n" -"Language: pt_BR\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=n > 1;\n" -"X-Generator: Weblate 4.3-dev\n" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:136 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:155 -msgid "Bytes Total" -msgstr "Total de Bytes" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:141 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:160 -msgid "Collecting data..." -msgstr "Coletando dados..." - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:224 -msgid "Comment" -msgstr "Comentário" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default Download Rate" -msgstr "Taxa de Download Padrão" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default Download Unit" -msgstr "Unidade de Download Padrão" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Default Network Interface" -msgstr "Interface de Rede Padrão" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default Upload Rate" -msgstr "Taxa de Upload Padrão" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default Upload Unit" -msgstr "Unidade de Upload Padrão" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default unit for download rate" -msgstr "Unidade padrão para taxa de download" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default unit for upload rate" -msgstr "Unidade padrão para taxa de upload" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Default value for download bandwidth" -msgstr "Valor padrão para a largura de banda para download" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default value for download rate" -msgstr "Valor padrão para a taxa de download" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Default value for upload bandwidth" -msgstr "Valor padrão para a largura de banda de upload" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default value for upload rate" -msgstr "Valor padrão para a taxa de upload" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Download Bandwidth (Mbps)" -msgstr "Largura de Banda de Download (Mbps)" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:135 -msgid "Download Rate" -msgstr "Taxa de Download" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Enable Limit Rate Feature" -msgstr "Ativar o Recurso de Limitação de Taxa" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable Traffic Priority" -msgstr "Ativar a Prioridade de Tráfego" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable this feature" -msgstr "Ativar este recurso" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:121 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:158 -msgid "Hostname" -msgstr "Nome do equipamento" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:134 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:153 -msgid "IP Address" -msgstr "Endereço IP" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:126 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:163 -msgid "IP Address(V4 / V6)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:128 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:165 -msgid "IP Address(V4 Only)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Limit Enable" -msgstr "Ativar Limite" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Limit Type" -msgstr "Tipo de Limite" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:135 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:172 -msgid "MAC (optional)" -msgstr "MAC (opcional)" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:48 -msgid "MB" -msgstr "MB" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:28 -msgid "NFT-QoS Settings" -msgstr "Configurações NFT-QoS" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Network Interface for Traffic Shaping, e.g. br-lan, eth0.1, eth0, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Network to be apply, e.g. 192.168.1.0/24, 10.2.0.0/16, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Network to be apply, e.g. AAAA::BBBB/64, CCCC::1/128, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:65 -msgid "No information available" -msgstr "Nenhuma informação disponível" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:137 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:156 -msgid "Packets Total" -msgstr "Total de Pacotes" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:207 -msgid "Priority" -msgstr "Prioridade" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:199 -msgid "Protocol" -msgstr "Protocolo" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:16 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:23 -msgid "Qos over Nftables" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:12 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:139 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:176 -msgid "Rate" -msgstr "Taxa" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:130 -msgid "Realtime Download Rate" -msgstr "Taxa de Download em Tempo Real" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:125 -msgid "Realtime Rate" -msgstr "Taxa em Tempo Real" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:149 -msgid "Realtime Upload Rate" -msgstr "Taxa de Upload em Tempo Real" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "Service" -msgstr "Serviço" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:116 -msgid "Static QoS-Download Rate" -msgstr "QoS estático - Taxa de download" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:153 -msgid "Static QoS-Upload Rate" -msgstr "QoS-Estático - Taxa de Upload" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Target Network (IPv4/MASK)" -msgstr "Rede de Destino (IPv4/MASK)" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Target Network6 (IPv6/MASK)" -msgstr "Rede de Destino (IPV6/MASK)" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:127 -msgid "This page gives an overview over currently download/upload rate." -msgstr "Esta página dá uma visão geral sobre a taxa atual de download/upload." - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:194 -msgid "Traffic Priority Settings" -msgstr "Configuração da Prioridade do Tráfego" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Type of Limit Rate" -msgstr "Tipo de Taxa Limite" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:144 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:181 -msgid "Unit" -msgstr "Unidade" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Upload Bandwidth (Mbps)" -msgstr "Largura de Banda de Upload (Mbps)" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:154 -msgid "Upload Rate" -msgstr "Taxa de Upload" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:96 -msgid "White List for Limit Rate" -msgstr "Lista Branca para a Limitação da Taxa" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "e.g. https, 23, (separator is comma)" -msgstr "por exemplo, https, 23, (separado por vírgulas)" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:44 -msgid "kB" -msgstr "kB" diff --git a/rooter/0optionalapps/luci-app-nft-qos/po/ro/nft-qos.po b/rooter/0optionalapps/luci-app-nft-qos/po/ro/nft-qos.po deleted file mode 100644 index bc97a06..0000000 --- a/rooter/0optionalapps/luci-app-nft-qos/po/ro/nft-qos.po +++ /dev/null @@ -1,240 +0,0 @@ -msgid "" -msgstr "" -"PO-Revision-Date: 2020-03-29 21:22+0000\n" -"Last-Translator: Cristian Ionescu \n" -"Language-Team: Romanian \n" -"Language: ro\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=3; plural=n==1 ? 0 : (n==0 || (n%100 > 0 && n%100 < " -"20)) ? 1 : 2;\n" -"X-Generator: Weblate 4.0-dev\n" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:136 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:155 -msgid "Bytes Total" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:141 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:160 -msgid "Collecting data..." -msgstr "Colectare date..." - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:224 -msgid "Comment" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default Download Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Default Network Interface" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default Upload Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default unit for download rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default unit for upload rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Default value for download bandwidth" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default value for download rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Default value for upload bandwidth" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default value for upload rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Download Bandwidth (Mbps)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:135 -msgid "Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Enable Limit Rate Feature" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable Traffic Priority" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable this feature" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:121 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:158 -msgid "Hostname" -msgstr "Numele gazdei ( hostname )" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:134 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:153 -msgid "IP Address" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:126 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:163 -msgid "IP Address(V4 / V6)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:128 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:165 -msgid "IP Address(V4 Only)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Limit Enable" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Limit Type" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:135 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:172 -msgid "MAC (optional)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:48 -msgid "MB" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:28 -msgid "NFT-QoS Settings" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Network Interface for Traffic Shaping, e.g. br-lan, eth0.1, eth0, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Network to be apply, e.g. 192.168.1.0/24, 10.2.0.0/16, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Network to be apply, e.g. AAAA::BBBB/64, CCCC::1/128, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:65 -msgid "No information available" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:137 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:156 -msgid "Packets Total" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:207 -msgid "Priority" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:199 -msgid "Protocol" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:16 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:23 -msgid "Qos over Nftables" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:12 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:139 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:176 -msgid "Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:130 -msgid "Realtime Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:125 -msgid "Realtime Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:149 -msgid "Realtime Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "Service" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:116 -msgid "Static QoS-Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:153 -msgid "Static QoS-Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Target Network (IPv4/MASK)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Target Network6 (IPv6/MASK)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:127 -msgid "This page gives an overview over currently download/upload rate." -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:194 -msgid "Traffic Priority Settings" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Type of Limit Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:144 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:181 -msgid "Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Upload Bandwidth (Mbps)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:154 -msgid "Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:96 -msgid "White List for Limit Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "e.g. https, 23, (separator is comma)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:44 -msgid "kB" -msgstr "" diff --git a/rooter/0optionalapps/luci-app-nft-qos/po/ru/nft-qos.po b/rooter/0optionalapps/luci-app-nft-qos/po/ru/nft-qos.po deleted file mode 100644 index 638701b..0000000 --- a/rooter/0optionalapps/luci-app-nft-qos/po/ru/nft-qos.po +++ /dev/null @@ -1,240 +0,0 @@ -msgid "" -msgstr "" -"PO-Revision-Date: 2020-10-09 00:10+0000\n" -"Last-Translator: Artem \n" -"Language-Team: Russian \n" -"Language: ru\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" -"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" -"X-Generator: Weblate 4.3-dev\n" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:136 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:155 -msgid "Bytes Total" -msgstr "Всего байт" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:141 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:160 -msgid "Collecting data..." -msgstr "Сбор данных..." - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:224 -msgid "Comment" -msgstr "Комментарий" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default Download Rate" -msgstr "Скорость загрузки по умолчанию" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default Download Unit" -msgstr "Единица загрузки по умолчанию" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Default Network Interface" -msgstr "Сетевой интерфейс по умолчанию" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default Upload Rate" -msgstr "Скорость отправки по умолчанию" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default Upload Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default unit for download rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default unit for upload rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Default value for download bandwidth" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default value for download rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Default value for upload bandwidth" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default value for upload rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Download Bandwidth (Mbps)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:135 -msgid "Download Rate" -msgstr "Скорость загрузки" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Enable Limit Rate Feature" -msgstr "Включить функцию ограничения скорости" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable Traffic Priority" -msgstr "Включить приоритет трафика" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable this feature" -msgstr "Включить эту функцию" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:121 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:158 -msgid "Hostname" -msgstr "Имя хоста" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:134 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:153 -msgid "IP Address" -msgstr "IP адрес" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:126 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:163 -msgid "IP Address(V4 / V6)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:128 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:165 -msgid "IP Address(V4 Only)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Limit Enable" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Limit Type" -msgstr "Тип лимита" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:135 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:172 -msgid "MAC (optional)" -msgstr "MAC (необязательно)" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:48 -msgid "MB" -msgstr "МБ" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:28 -msgid "NFT-QoS Settings" -msgstr "Настройки NFT-QoS" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Network Interface for Traffic Shaping, e.g. br-lan, eth0.1, eth0, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Network to be apply, e.g. 192.168.1.0/24, 10.2.0.0/16, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Network to be apply, e.g. AAAA::BBBB/64, CCCC::1/128, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:65 -msgid "No information available" -msgstr "Нет доступной информации" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:137 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:156 -msgid "Packets Total" -msgstr "Всего пакетов" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:207 -msgid "Priority" -msgstr "Приоритет" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:199 -msgid "Protocol" -msgstr "Протокол" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:16 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:23 -msgid "Qos over Nftables" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:12 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:139 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:176 -msgid "Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:130 -msgid "Realtime Download Rate" -msgstr "Скорость загрузки в реальном времени" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:125 -msgid "Realtime Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:149 -msgid "Realtime Upload Rate" -msgstr "Скорость отправки в реальном времени" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "Service" -msgstr "Служба" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:116 -msgid "Static QoS-Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:153 -msgid "Static QoS-Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Target Network (IPv4/MASK)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Target Network6 (IPv6/MASK)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:127 -msgid "This page gives an overview over currently download/upload rate." -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:194 -msgid "Traffic Priority Settings" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Type of Limit Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:144 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:181 -msgid "Unit" -msgstr "узел" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Upload Bandwidth (Mbps)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:154 -msgid "Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:96 -msgid "White List for Limit Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "e.g. https, 23, (separator is comma)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:44 -msgid "kB" -msgstr "" diff --git a/rooter/0optionalapps/luci-app-nft-qos/po/sk/nft-qos.po b/rooter/0optionalapps/luci-app-nft-qos/po/sk/nft-qos.po deleted file mode 100644 index 7c4afad..0000000 --- a/rooter/0optionalapps/luci-app-nft-qos/po/sk/nft-qos.po +++ /dev/null @@ -1,239 +0,0 @@ -msgid "" -msgstr "" -"PO-Revision-Date: 2020-04-04 17:35+0000\n" -"Last-Translator: Dušan Kazik \n" -"Language-Team: Slovak \n" -"Language: sk\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n" -"X-Generator: Weblate 4.0-dev\n" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:136 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:155 -msgid "Bytes Total" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:141 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:160 -msgid "Collecting data..." -msgstr "Zbieram dáta..." - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:224 -msgid "Comment" -msgstr "Komentár" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default Download Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Default Network Interface" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default Upload Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default unit for download rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default unit for upload rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Default value for download bandwidth" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default value for download rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Default value for upload bandwidth" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default value for upload rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Download Bandwidth (Mbps)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:135 -msgid "Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Enable Limit Rate Feature" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable Traffic Priority" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable this feature" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:121 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:158 -msgid "Hostname" -msgstr "Názov hostiteľa" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:134 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:153 -msgid "IP Address" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:126 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:163 -msgid "IP Address(V4 / V6)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:128 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:165 -msgid "IP Address(V4 Only)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Limit Enable" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Limit Type" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:135 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:172 -msgid "MAC (optional)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:48 -msgid "MB" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:28 -msgid "NFT-QoS Settings" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Network Interface for Traffic Shaping, e.g. br-lan, eth0.1, eth0, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Network to be apply, e.g. 192.168.1.0/24, 10.2.0.0/16, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Network to be apply, e.g. AAAA::BBBB/64, CCCC::1/128, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:65 -msgid "No information available" -msgstr "Nie sú dostupné žiadne informácie" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:137 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:156 -msgid "Packets Total" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:207 -msgid "Priority" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:199 -msgid "Protocol" -msgstr "Protokol" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:16 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:23 -msgid "Qos over Nftables" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:12 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:139 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:176 -msgid "Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:130 -msgid "Realtime Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:125 -msgid "Realtime Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:149 -msgid "Realtime Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "Service" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:116 -msgid "Static QoS-Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:153 -msgid "Static QoS-Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Target Network (IPv4/MASK)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Target Network6 (IPv6/MASK)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:127 -msgid "This page gives an overview over currently download/upload rate." -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:194 -msgid "Traffic Priority Settings" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Type of Limit Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:144 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:181 -msgid "Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Upload Bandwidth (Mbps)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:154 -msgid "Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:96 -msgid "White List for Limit Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "e.g. https, 23, (separator is comma)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:44 -msgid "kB" -msgstr "" diff --git a/rooter/0optionalapps/luci-app-nft-qos/po/sv/nft-qos.po b/rooter/0optionalapps/luci-app-nft-qos/po/sv/nft-qos.po deleted file mode 100644 index da1b53a..0000000 --- a/rooter/0optionalapps/luci-app-nft-qos/po/sv/nft-qos.po +++ /dev/null @@ -1,239 +0,0 @@ -msgid "" -msgstr "" -"PO-Revision-Date: 2020-11-22 15:35+0000\n" -"Last-Translator: PontusÖsterlindh \n" -"Language-Team: Swedish \n" -"Language: sv\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.4-dev\n" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:136 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:155 -msgid "Bytes Total" -msgstr "Bytes Totalt" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:141 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:160 -msgid "Collecting data..." -msgstr "Samlar in data..." - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:224 -msgid "Comment" -msgstr "Kommentera" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default Download Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Default Network Interface" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default Upload Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default unit for download rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default unit for upload rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Default value for download bandwidth" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default value for download rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Default value for upload bandwidth" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default value for upload rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Download Bandwidth (Mbps)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:135 -msgid "Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Enable Limit Rate Feature" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable Traffic Priority" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable this feature" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:121 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:158 -msgid "Hostname" -msgstr "Värdnamn" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:134 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:153 -msgid "IP Address" -msgstr "IP-adress" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:126 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:163 -msgid "IP Address(V4 / V6)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:128 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:165 -msgid "IP Address(V4 Only)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Limit Enable" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Limit Type" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:135 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:172 -msgid "MAC (optional)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:48 -msgid "MB" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:28 -msgid "NFT-QoS Settings" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Network Interface for Traffic Shaping, e.g. br-lan, eth0.1, eth0, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Network to be apply, e.g. 192.168.1.0/24, 10.2.0.0/16, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Network to be apply, e.g. AAAA::BBBB/64, CCCC::1/128, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:65 -msgid "No information available" -msgstr "Ingen information tillgänglig" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:137 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:156 -msgid "Packets Total" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:207 -msgid "Priority" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:199 -msgid "Protocol" -msgstr "Protokoll" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:16 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:23 -msgid "Qos over Nftables" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:12 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:139 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:176 -msgid "Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:130 -msgid "Realtime Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:125 -msgid "Realtime Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:149 -msgid "Realtime Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "Service" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:116 -msgid "Static QoS-Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:153 -msgid "Static QoS-Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Target Network (IPv4/MASK)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Target Network6 (IPv6/MASK)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:127 -msgid "This page gives an overview over currently download/upload rate." -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:194 -msgid "Traffic Priority Settings" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Type of Limit Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:144 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:181 -msgid "Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Upload Bandwidth (Mbps)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:154 -msgid "Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:96 -msgid "White List for Limit Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "e.g. https, 23, (separator is comma)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:44 -msgid "kB" -msgstr "" diff --git a/rooter/0optionalapps/luci-app-nft-qos/po/templates/nft-qos.pot b/rooter/0optionalapps/luci-app-nft-qos/po/templates/nft-qos.pot deleted file mode 100644 index 8fecfa0..0000000 --- a/rooter/0optionalapps/luci-app-nft-qos/po/templates/nft-qos.pot +++ /dev/null @@ -1,230 +0,0 @@ -msgid "" -msgstr "Content-Type: text/plain; charset=UTF-8" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:136 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:155 -msgid "Bytes Total" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:141 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:160 -msgid "Collecting data..." -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:224 -msgid "Comment" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default Download Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Default Network Interface" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default Upload Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default unit for download rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default unit for upload rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Default value for download bandwidth" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default value for download rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Default value for upload bandwidth" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default value for upload rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Download Bandwidth (Mbps)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:135 -msgid "Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Enable Limit Rate Feature" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable Traffic Priority" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable this feature" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:121 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:158 -msgid "Hostname" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:134 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:153 -msgid "IP Address" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:126 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:163 -msgid "IP Address(V4 / V6)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:128 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:165 -msgid "IP Address(V4 Only)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Limit Enable" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Limit Type" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:135 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:172 -msgid "MAC (optional)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:48 -msgid "MB" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:28 -msgid "NFT-QoS Settings" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Network Interface for Traffic Shaping, e.g. br-lan, eth0.1, eth0, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Network to be apply, e.g. 192.168.1.0/24, 10.2.0.0/16, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Network to be apply, e.g. AAAA::BBBB/64, CCCC::1/128, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:65 -msgid "No information available" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:137 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:156 -msgid "Packets Total" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:207 -msgid "Priority" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:199 -msgid "Protocol" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:16 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:23 -msgid "Qos over Nftables" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:12 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:139 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:176 -msgid "Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:130 -msgid "Realtime Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:125 -msgid "Realtime Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:149 -msgid "Realtime Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "Service" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:116 -msgid "Static QoS-Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:153 -msgid "Static QoS-Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Target Network (IPv4/MASK)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Target Network6 (IPv6/MASK)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:127 -msgid "This page gives an overview over currently download/upload rate." -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:194 -msgid "Traffic Priority Settings" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Type of Limit Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:144 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:181 -msgid "Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Upload Bandwidth (Mbps)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:154 -msgid "Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:96 -msgid "White List for Limit Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "e.g. https, 23, (separator is comma)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:44 -msgid "kB" -msgstr "" diff --git a/rooter/0optionalapps/luci-app-nft-qos/po/tr/nft-qos.po b/rooter/0optionalapps/luci-app-nft-qos/po/tr/nft-qos.po deleted file mode 100644 index fd53746..0000000 --- a/rooter/0optionalapps/luci-app-nft-qos/po/tr/nft-qos.po +++ /dev/null @@ -1,239 +0,0 @@ -msgid "" -msgstr "" -"PO-Revision-Date: 2020-11-28 20:18+0000\n" -"Last-Translator: Oğuz Ersen \n" -"Language-Team: Turkish \n" -"Language: tr\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.4-dev\n" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:136 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:155 -msgid "Bytes Total" -msgstr "Bayt Toplamı" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:141 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:160 -msgid "Collecting data..." -msgstr "Veri alınıyor..." - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:224 -msgid "Comment" -msgstr "Açıklama" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default Download Rate" -msgstr "Varsayılan İndirme Hızı" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default Download Unit" -msgstr "Varsayılan İndirme Birimi" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Default Network Interface" -msgstr "Varsayılan Ağ Arayüzü" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default Upload Rate" -msgstr "Varsayılan Yükleme Hızı" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default Upload Unit" -msgstr "Varsayılan Yükleme Birimi" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default unit for download rate" -msgstr "İndirme hızı için varsayılan birim" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default unit for upload rate" -msgstr "Yükleme hızı için varsayılan birim" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Default value for download bandwidth" -msgstr "İndirme bant genişliği için varsayılan değer" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default value for download rate" -msgstr "İndirme hızı için varsayılan değer" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Default value for upload bandwidth" -msgstr "Yükleme band genişliği için varsayılan değer" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default value for upload rate" -msgstr "Yükleme hızı için varsayılan değer" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Download Bandwidth (Mbps)" -msgstr "İndirme Band Genişliği (Mbps)" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:135 -msgid "Download Rate" -msgstr "İndirme Hızı" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Enable Limit Rate Feature" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable Traffic Priority" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable this feature" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:121 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:158 -msgid "Hostname" -msgstr "Sunucu adı" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:134 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:153 -msgid "IP Address" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:126 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:163 -msgid "IP Address(V4 / V6)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:128 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:165 -msgid "IP Address(V4 Only)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Limit Enable" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Limit Type" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:135 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:172 -msgid "MAC (optional)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:48 -msgid "MB" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:28 -msgid "NFT-QoS Settings" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Network Interface for Traffic Shaping, e.g. br-lan, eth0.1, eth0, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Network to be apply, e.g. 192.168.1.0/24, 10.2.0.0/16, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Network to be apply, e.g. AAAA::BBBB/64, CCCC::1/128, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:65 -msgid "No information available" -msgstr "Bilgi bulunmamaktadır" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:137 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:156 -msgid "Packets Total" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:207 -msgid "Priority" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:199 -msgid "Protocol" -msgstr "Protokol" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:16 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:23 -msgid "Qos over Nftables" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:12 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:139 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:176 -msgid "Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:130 -msgid "Realtime Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:125 -msgid "Realtime Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:149 -msgid "Realtime Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "Service" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:116 -msgid "Static QoS-Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:153 -msgid "Static QoS-Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Target Network (IPv4/MASK)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Target Network6 (IPv6/MASK)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:127 -msgid "This page gives an overview over currently download/upload rate." -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:194 -msgid "Traffic Priority Settings" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Type of Limit Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:144 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:181 -msgid "Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Upload Bandwidth (Mbps)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:154 -msgid "Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:96 -msgid "White List for Limit Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "e.g. https, 23, (separator is comma)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:44 -msgid "kB" -msgstr "" diff --git a/rooter/0optionalapps/luci-app-nft-qos/po/uk/nft-qos.po b/rooter/0optionalapps/luci-app-nft-qos/po/uk/nft-qos.po deleted file mode 100644 index 748da14..0000000 --- a/rooter/0optionalapps/luci-app-nft-qos/po/uk/nft-qos.po +++ /dev/null @@ -1,240 +0,0 @@ -msgid "" -msgstr "" -"PO-Revision-Date: 2020-02-17 11:51+0000\n" -"Last-Translator: Olexandr Nesterenko \n" -"Language-Team: Ukrainian \n" -"Language: uk\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" -"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" -"X-Generator: Weblate 3.11-dev\n" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:136 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:155 -msgid "Bytes Total" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:141 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:160 -msgid "Collecting data..." -msgstr "Збирання даних..." - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:224 -msgid "Comment" -msgstr "Примітка" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default Download Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Default Network Interface" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default Upload Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default unit for download rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default unit for upload rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Default value for download bandwidth" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default value for download rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Default value for upload bandwidth" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default value for upload rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Download Bandwidth (Mbps)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:135 -msgid "Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Enable Limit Rate Feature" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable Traffic Priority" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable this feature" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:121 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:158 -msgid "Hostname" -msgstr "Назва (ім'я) вузла" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:134 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:153 -msgid "IP Address" -msgstr "IP-адреса" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:126 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:163 -msgid "IP Address(V4 / V6)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:128 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:165 -msgid "IP Address(V4 Only)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Limit Enable" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Limit Type" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:135 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:172 -msgid "MAC (optional)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:48 -msgid "MB" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:28 -msgid "NFT-QoS Settings" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Network Interface for Traffic Shaping, e.g. br-lan, eth0.1, eth0, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Network to be apply, e.g. 192.168.1.0/24, 10.2.0.0/16, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Network to be apply, e.g. AAAA::BBBB/64, CCCC::1/128, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:65 -msgid "No information available" -msgstr "Інформація відсутня" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:137 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:156 -msgid "Packets Total" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:207 -msgid "Priority" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:199 -msgid "Protocol" -msgstr "Протокол" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:16 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:23 -msgid "Qos over Nftables" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:12 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:139 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:176 -msgid "Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:130 -msgid "Realtime Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:125 -msgid "Realtime Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:149 -msgid "Realtime Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "Service" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:116 -msgid "Static QoS-Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:153 -msgid "Static QoS-Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Target Network (IPv4/MASK)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Target Network6 (IPv6/MASK)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:127 -msgid "This page gives an overview over currently download/upload rate." -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:194 -msgid "Traffic Priority Settings" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Type of Limit Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:144 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:181 -msgid "Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Upload Bandwidth (Mbps)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:154 -msgid "Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:96 -msgid "White List for Limit Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "e.g. https, 23, (separator is comma)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:44 -msgid "kB" -msgstr "" diff --git a/rooter/0optionalapps/luci-app-nft-qos/po/vi/nft-qos.po b/rooter/0optionalapps/luci-app-nft-qos/po/vi/nft-qos.po deleted file mode 100644 index dcbba21..0000000 --- a/rooter/0optionalapps/luci-app-nft-qos/po/vi/nft-qos.po +++ /dev/null @@ -1,239 +0,0 @@ -msgid "" -msgstr "" -"PO-Revision-Date: 2019-11-13 13:07+0000\n" -"Last-Translator: Le Van Uoc \n" -"Language-Team: Vietnamese \n" -"Language: vi\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: Weblate 3.10-dev\n" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:136 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:155 -msgid "Bytes Total" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:141 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:160 -msgid "Collecting data..." -msgstr "Đang lấy dữ liệu..." - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:224 -msgid "Comment" -msgstr "Bình luận" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default Download Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Default Network Interface" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default Upload Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default unit for download rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default unit for upload rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Default value for download bandwidth" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default value for download rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Default value for upload bandwidth" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default value for upload rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Download Bandwidth (Mbps)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:135 -msgid "Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Enable Limit Rate Feature" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable Traffic Priority" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable this feature" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:121 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:158 -msgid "Hostname" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:134 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:153 -msgid "IP Address" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:126 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:163 -msgid "IP Address(V4 / V6)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:128 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:165 -msgid "IP Address(V4 Only)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Limit Enable" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Limit Type" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:135 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:172 -msgid "MAC (optional)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:48 -msgid "MB" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:28 -msgid "NFT-QoS Settings" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Network Interface for Traffic Shaping, e.g. br-lan, eth0.1, eth0, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Network to be apply, e.g. 192.168.1.0/24, 10.2.0.0/16, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Network to be apply, e.g. AAAA::BBBB/64, CCCC::1/128, etc" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:65 -msgid "No information available" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:137 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:156 -msgid "Packets Total" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:207 -msgid "Priority" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:199 -msgid "Protocol" -msgstr "Giao thức" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:16 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:23 -msgid "Qos over Nftables" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:12 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:139 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:176 -msgid "Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:130 -msgid "Realtime Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:125 -msgid "Realtime Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:149 -msgid "Realtime Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "Service" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:116 -msgid "Static QoS-Download Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:153 -msgid "Static QoS-Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Target Network (IPv4/MASK)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Target Network6 (IPv6/MASK)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:127 -msgid "This page gives an overview over currently download/upload rate." -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:194 -msgid "Traffic Priority Settings" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Type of Limit Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:144 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:181 -msgid "Unit" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Upload Bandwidth (Mbps)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:154 -msgid "Upload Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:96 -msgid "White List for Limit Rate" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "e.g. https, 23, (separator is comma)" -msgstr "" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:44 -msgid "kB" -msgstr "" diff --git a/rooter/0optionalapps/luci-app-nft-qos/po/zh_Hans/nft-qos.po b/rooter/0optionalapps/luci-app-nft-qos/po/zh_Hans/nft-qos.po deleted file mode 100644 index 02a59da..0000000 --- a/rooter/0optionalapps/luci-app-nft-qos/po/zh_Hans/nft-qos.po +++ /dev/null @@ -1,245 +0,0 @@ -# -# Yangfl , 2019. -# -msgid "" -msgstr "" -"Project-Id-Version: \n" -"POT-Creation-Date: \n" -"PO-Revision-Date: 2020-11-22 15:35+0000\n" -"Last-Translator: Eric \n" -"Language-Team: Chinese (Simplified) \n" -"Language: zh_Hans\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: Weblate 4.4-dev\n" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:136 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:155 -msgid "Bytes Total" -msgstr "字节总数" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:141 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:160 -msgid "Collecting data..." -msgstr "正在收集数据…" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:224 -msgid "Comment" -msgstr "注解" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default Download Rate" -msgstr "默认下载速率" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default Download Unit" -msgstr "默认下载速率单位" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Default Network Interface" -msgstr "默认网络接口" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default Upload Rate" -msgstr "默认上传速率" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default Upload Unit" -msgstr "默认上传速率单位" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default unit for download rate" -msgstr "默认的下载速率单位" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default unit for upload rate" -msgstr "默认的上传速率单位" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Default value for download bandwidth" -msgstr "下载带宽的默认值" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default value for download rate" -msgstr "下载速率的默认值" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Default value for upload bandwidth" -msgstr "上传带宽的默认值" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default value for upload rate" -msgstr "上传速率的默认值" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Download Bandwidth (Mbps)" -msgstr "下载带宽(Mbps)" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:135 -msgid "Download Rate" -msgstr "下载速率" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Enable Limit Rate Feature" -msgstr "开启速率限制功能" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable Traffic Priority" -msgstr "开启流量优先级" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable this feature" -msgstr "开启这个功能" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:121 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:158 -msgid "Hostname" -msgstr "主机名" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:134 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:153 -msgid "IP Address" -msgstr "IP 地址" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:126 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:163 -msgid "IP Address(V4 / V6)" -msgstr "IP 地址(V4 / V6)" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:128 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:165 -msgid "IP Address(V4 Only)" -msgstr "IP 地址(仅 V4)" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Limit Enable" -msgstr "限速开启" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Limit Type" -msgstr "限速类型" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:135 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:172 -msgid "MAC (optional)" -msgstr "物理地址(可选)" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:48 -msgid "MB" -msgstr "MB" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:28 -msgid "NFT-QoS Settings" -msgstr "NFT-QoS 设置" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Network Interface for Traffic Shaping, e.g. br-lan, eth0.1, eth0, etc" -msgstr "流量整形的目标网络接口,例如br-lan、eth0.1、eth0等" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Network to be apply, e.g. 192.168.1.0/24, 10.2.0.0/16, etc" -msgstr "将要应用规则的网络,例如192.168.1.0/24、10.2.0.0/16等" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Network to be apply, e.g. AAAA::BBBB/64, CCCC::1/128, etc" -msgstr "将要应用规则的网络,例如AAAA::BBBB/64、CCCC::1/128等" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:65 -msgid "No information available" -msgstr "无可用信息" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:137 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:156 -msgid "Packets Total" -msgstr "数据包总数" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:207 -msgid "Priority" -msgstr "优先级" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:199 -msgid "Protocol" -msgstr "协议" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:16 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:23 -msgid "Qos over Nftables" -msgstr "QoS Nftables 版" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:12 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:139 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:176 -msgid "Rate" -msgstr "速率" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:130 -msgid "Realtime Download Rate" -msgstr "实时下载速率" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:125 -msgid "Realtime Rate" -msgstr "实时速率显示" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:149 -msgid "Realtime Upload Rate" -msgstr "实时上传速率" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "Service" -msgstr "服务" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:116 -msgid "Static QoS-Download Rate" -msgstr "静态 QoS-下载速率" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:153 -msgid "Static QoS-Upload Rate" -msgstr "静态 QoS-上传速率" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Target Network (IPv4/MASK)" -msgstr "目标网络(IPv4 地址/掩码)" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Target Network6 (IPv6/MASK)" -msgstr "目标网络 v6(IPv6 地址/掩码)" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:127 -msgid "This page gives an overview over currently download/upload rate." -msgstr "该页面提供了当前上传和下载速率的一个总览。" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:194 -msgid "Traffic Priority Settings" -msgstr "流量优先级设置" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Type of Limit Rate" -msgstr "限速的类型" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:144 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:181 -msgid "Unit" -msgstr "单元" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Upload Bandwidth (Mbps)" -msgstr "上传带宽(Mbps)" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:154 -msgid "Upload Rate" -msgstr "上传速率" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:96 -msgid "White List for Limit Rate" -msgstr "限速白名单" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "e.g. https, 23, (separator is comma)" -msgstr "例如https, 23(用逗号分隔)" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:44 -msgid "kB" -msgstr "kB" diff --git a/rooter/0optionalapps/luci-app-nft-qos/po/zh_Hant/nft-qos.po b/rooter/0optionalapps/luci-app-nft-qos/po/zh_Hant/nft-qos.po deleted file mode 100644 index e2fa5f4..0000000 --- a/rooter/0optionalapps/luci-app-nft-qos/po/zh_Hant/nft-qos.po +++ /dev/null @@ -1,245 +0,0 @@ -# -# Yangfl , 2019. -# -msgid "" -msgstr "" -"Project-Id-Version: \n" -"POT-Creation-Date: \n" -"PO-Revision-Date: 2020-06-30 13:41+0000\n" -"Last-Translator: Hulen \n" -"Language-Team: Chinese (Traditional) \n" -"Language: zh_Hant\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: Weblate 4.2-dev\n" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:136 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:155 -msgid "Bytes Total" -msgstr "位元組總數" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:141 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:160 -msgid "Collecting data..." -msgstr "收集資料中..." - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:224 -msgid "Comment" -msgstr "註解" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default Download Rate" -msgstr "預設下載速率" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default Download Unit" -msgstr "預設下載速率單位" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Default Network Interface" -msgstr "預設網路介面" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default Upload Rate" -msgstr "預設上傳速率" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default Upload Unit" -msgstr "預設上傳速率單位" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:53 -msgid "Default unit for download rate" -msgstr "預設的下載速率單位" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:65 -msgid "Default unit for upload rate" -msgstr "預設的上傳速率單位" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Default value for download bandwidth" -msgstr "下載頻寬的預設值" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:48 -msgid "Default value for download rate" -msgstr "下載速率的預設值" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Default value for upload bandwidth" -msgstr "上傳頻寬的預設值" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:60 -msgid "Default value for upload rate" -msgstr "上傳速率的預設值" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:75 -msgid "Download Bandwidth (Mbps)" -msgstr "下載頻寬(Mbps)" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:135 -msgid "Download Rate" -msgstr "下載速率" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Enable Limit Rate Feature" -msgstr "開啟速率限制功能" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable Traffic Priority" -msgstr "開啟流量優先順序" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:103 -msgid "Enable this feature" -msgstr "開啟這個功能" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:121 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:158 -msgid "Hostname" -msgstr "主機名稱" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:134 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:153 -msgid "IP Address" -msgstr "IP 位址" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:126 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:163 -msgid "IP Address(V4 / V6)" -msgstr "IP 位址(V4 / V6)" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:128 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:165 -msgid "IP Address(V4 Only)" -msgstr "IP 位址(僅 V4)" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:38 -msgid "Limit Enable" -msgstr "限速開啟" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Limit Type" -msgstr "限速型別" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:135 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:172 -msgid "MAC (optional)" -msgstr "實體位址(可選)" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:48 -msgid "MB" -msgstr "MB" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:28 -msgid "NFT-QoS Settings" -msgstr "NFT-QoS 設定" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:107 -msgid "Network Interface for Traffic Shaping, e.g. br-lan, eth0.1, eth0, etc" -msgstr "流量整形的目標網路介面,例如br-lan、eth0.1、eth0等" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Network to be apply, e.g. 192.168.1.0/24, 10.2.0.0/16, etc" -msgstr "將要應用規則的網路,例如192.168.1.0/24、10.2.0.0/16等" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Network to be apply, e.g. AAAA::BBBB/64, CCCC::1/128, etc" -msgstr "將要應用規則的網路,例如AAAA::BBBB/64、CCCC::1/128等" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:65 -msgid "No information available" -msgstr "無可用資訊" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:137 -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:156 -msgid "Packets Total" -msgstr "資料包總數" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:207 -msgid "Priority" -msgstr "優先順序" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:199 -msgid "Protocol" -msgstr "協定" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:16 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:23 -msgid "Qos over Nftables" -msgstr "QoS Nftables 版" - -#: applications/luci-app-nft-qos/luasrc/controller/nft-qos.lua:12 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:139 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:176 -msgid "Rate" -msgstr "速率" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:130 -msgid "Realtime Download Rate" -msgstr "實時下載速率" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:125 -msgid "Realtime Rate" -msgstr "實時速率顯示" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:149 -msgid "Realtime Upload Rate" -msgstr "實時上傳速率" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "Service" -msgstr "服務" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:116 -msgid "Static QoS-Download Rate" -msgstr "靜態 QoS-下載速率" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:153 -msgid "Static QoS-Upload Rate" -msgstr "靜態 QoS-上傳速率" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:85 -msgid "Target Network (IPv4/MASK)" -msgstr "目標網路(IPv4 位址/掩碼)" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:91 -msgid "Target Network6 (IPv6/MASK)" -msgstr "目標網路 v6(IPv6 位址/掩碼)" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:127 -msgid "This page gives an overview over currently download/upload rate." -msgstr "該頁面提供了當前上傳和下載速率的一個總覽。" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:194 -msgid "Traffic Priority Settings" -msgstr "流量優先順序設定" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:42 -msgid "Type of Limit Rate" -msgstr "限速的型別" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:144 -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:181 -msgid "Unit" -msgstr "單元" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:80 -msgid "Upload Bandwidth (Mbps)" -msgstr "上傳頻寬(Mbps)" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:154 -msgid "Upload Rate" -msgstr "上傳速率" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:96 -msgid "White List for Limit Rate" -msgstr "限速白名單" - -#: applications/luci-app-nft-qos/luasrc/model/cbi/nft-qos/nft-qos.lua:221 -msgid "e.g. https, 23, (separator is comma)" -msgstr "例如https, 23(用逗號分隔)" - -#: applications/luci-app-nft-qos/luasrc/view/nft-qos/rate.htm:44 -msgid "kB" -msgstr "kB" diff --git a/rooter/0optionalapps/luci-app-nft-qos/root/usr/share/rpcd/acl.d/luci-app-nft-qos.json b/rooter/0optionalapps/luci-app-nft-qos/root/usr/share/rpcd/acl.d/luci-app-nft-qos.json deleted file mode 100644 index b2de626..0000000 --- a/rooter/0optionalapps/luci-app-nft-qos/root/usr/share/rpcd/acl.d/luci-app-nft-qos.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "luci-app-nft-qos": { - "description": "Grant UCI access for luci-app-nft-qos", - "read": { - "uci": [ "nft-qos" ] - }, - "write": { - "uci": [ "nft-qos" ] - } - } -} diff --git a/rooter/0optionalapps/luci-app-rooterddns/Makefile b/rooter/0optionalapps/luci-app-rooterddns/Makefile deleted file mode 100644 index 4ed1d3b..0000000 --- a/rooter/0optionalapps/luci-app-rooterddns/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -#Owned by DairyMan@Whirlpool -# -#Copyright GNU act. -include $(TOPDIR)/rules.mk - -PKG_NAME:=luci-app-rooterddns -PKG_VERSION:=1.000 -PKG_RELEASE:=1 - -PKG_MAINTAINER:=Created by DM/makefile by Cobia@whirlpool -include $(INCLUDE_DIR)/package.mk - -define Package/luci-app-rooterddns - SECTION:=luci - CATEGORY:=LuCI - DEPENDS:=+ddns-scripts +ddns-scripts_no-ip_com - SUBMENU:=3. Applications - TITLE:=LuCI Support for Dynamic DNS Client - PKGARCH:=all -endef - -define Package/luci-app-rooterddns/description - LuCI Support for Dynamic DNS Client -endef - - -define Build/Compile -endef - -define Package/luci-app-rooterddns/install - $(CP) ./files/* $(1)/ -endef - -$(eval $(call BuildPackage,luci-app-rooterddns)) diff --git a/rooter/0optionalapps/luci-app-rooterddns/files/etc/uci-defaults/40_luci-ddns b/rooter/0optionalapps/luci-app-rooterddns/files/etc/uci-defaults/40_luci-ddns deleted file mode 100644 index a82c1f9..0000000 --- a/rooter/0optionalapps/luci-app-rooterddns/files/etc/uci-defaults/40_luci-ddns +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -# no longer needed for "Save and Apply" to restart ddns -uci -q batch <<-EOF >/dev/null - delete ucitrack.@ddns[-1] - commit ucitrack -EOF - -rm -f /tmp/luci-indexcache -return 0 diff --git a/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/controller/ddns.lua b/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/controller/ddns.lua deleted file mode 100644 index 89da567..0000000 --- a/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/controller/ddns.lua +++ /dev/null @@ -1,308 +0,0 @@ --- Copyright 2008 Steven Barth --- Copyright 2008 Jo-Philipp Wich --- Copyright 2013 Manuel Munz --- Copyright 2014-2016 Christian Schoenebeck --- Licensed to the public under the Apache License 2.0. - -module("luci.controller.ddns", package.seeall) - -local NX = require "nixio" -local NXFS = require "nixio.fs" -local DISP = require "luci.dispatcher" -local HTTP = require "luci.http" -local I18N = require "luci.i18n" -- not globally avalible here -local IPKG = require "luci.model.ipkg" -local SYS = require "luci.sys" -local UCI = require "luci.model.uci" -local UTIL = require "luci.util" -local DDNS = require "luci.tools.ddns" -- ddns multiused functions - -luci_helper = "/usr/lib/ddns/dynamic_dns_lucihelper.sh" - -local srv_name = "ddns-scripts" -local srv_ver_min = "2.7.6" -- minimum version of service required -local srv_ver_cmd = luci_helper .. [[ -V | awk {'print $2'}]] -local app_name = "luci-app-ddns" -local app_title = "Dynamic DNS" -local app_version = "2.4.8-1" - -function index() - local nxfs = require "nixio.fs" -- global definitions not available - local sys = require "luci.sys" -- in function index() - local ddns = require "luci.tools.ddns" -- ddns multiused functions - local muci = require "luci.model.uci" - - -- no config create an empty one - if not nxfs.access("/etc/config/ddns") then - nxfs.writefile("/etc/config/ddns", "") - end - - -- preset new option "lookup_host" if not already defined - local uci = muci.cursor() - local commit = false - uci:foreach("ddns", "service", function (s) - if not s["lookup_host"] and s["domain"] then - uci:set("ddns", s[".name"], "lookup_host", s["domain"]) - commit = true - end - end) - if commit then uci:commit("ddns") end - uci:unload("ddns") - - entry( {"admin", "services", "ddns"}, cbi("ddns/overview"), _("Dynamic DNS"), 59) - entry( {"admin", "services", "ddns", "detail"}, cbi("ddns/detail"), nil ).leaf = true - entry( {"admin", "services", "ddns", "hints"}, cbi("ddns/hints", - {hideapplybtn=true, hidesavebtn=true, hideresetbtn=true}), nil ).leaf = true - entry( {"admin", "services", "ddns", "global"}, cbi("ddns/global"), nil ).leaf = true - entry( {"admin", "services", "ddns", "logview"}, call("logread") ).leaf = true - entry( {"admin", "services", "ddns", "startstop"}, post("startstop") ).leaf = true - entry( {"admin", "services", "ddns", "status"}, call("status") ).leaf = true -end - --- Application specific information functions -function app_description() - return I18N.translate("Dynamic DNS allows your router to be reached with " .. - "a fixed hostname while having a dynamically changing IP address.") -end -function app_title_back() - return [[]] - .. I18N.translate(app_title) - .. [[]] -end - --- Standardized application/service functions -function app_title_main() - return [[]] - .. I18N.translate(app_title) - .. [[]] -end -function service_version() - local ver = nil - - ver = UTIL.exec(srv_ver_cmd) - if #ver > 0 then return ver end - - IPKG.list_installed(srv_name, function(n, v, d) - if v and (#v > 0) then ver = v end - end - ) - return ver -end -function service_ok() - return IPKG.compare_versions((service_version() or "0"), ">=", srv_ver_min) -end - --- internal function to read all sections status and return data array -local function _get_status() - local uci = UCI.cursor() - local service = SYS.init.enabled("ddns") and 1 or 0 - local url_start = DISP.build_url("admin", "system", "startup") - local data = {} -- Array to transfer data to javascript - - data[#data+1] = { - enabled = service, -- service enabled - url_up = url_start, -- link to enable DDS (System-Startup) - } - - uci:foreach("ddns", "service", function (s) - - -- Get section we are looking at - -- and enabled state - local section = s[".name"] - local enabled = tonumber(s["enabled"]) or 0 - local datelast = "_empty_" -- formatted date of last update - local datenext = "_empty_" -- formatted date of next update - - -- get force seconds - local force_seconds = DDNS.calc_seconds( - tonumber(s["force_interval"]) or 72 , - s["force_unit"] or "hours" ) - -- get/validate pid and last update - local pid = DDNS.get_pid(section) - local uptime = SYS.uptime() - local lasttime = DDNS.get_lastupd(section) - if lasttime > uptime then -- /var might not be linked to /tmp - lasttime = 0 -- and/or not cleared on reboot - end - - -- no last update happen - if lasttime == 0 then - datelast = "_never_" - - -- we read last update - else - -- calc last update - -- sys.epoch - sys uptime + lastupdate(uptime) - local epoch = os.time() - uptime + lasttime - -- use linux date to convert epoch - datelast = DDNS.epoch2date(epoch) - -- calc and fill next update - datenext = DDNS.epoch2date(epoch + force_seconds) - end - - -- process running but update needs to happen - -- problems if force_seconds > uptime - force_seconds = (force_seconds > uptime) and uptime or force_seconds - if pid > 0 and ( lasttime + force_seconds - uptime ) <= 0 then - datenext = "_verify_" - - -- run once - elseif force_seconds == 0 then - datenext = "_runonce_" - - -- no process running and NOT enabled - elseif pid == 0 and enabled == 0 then - datenext = "_disabled_" - - -- no process running and enabled - elseif pid == 0 and enabled ~= 0 then - datenext = "_stopped_" - end - - -- get/set monitored interface and IP version - local iface = s["interface"] or "_nonet_" - local use_ipv6 = tonumber(s["use_ipv6"]) or 0 - if iface ~= "_nonet_" then - local ipv = (use_ipv6 == 1) and "IPv6" or "IPv4" - iface = ipv .. " / " .. iface - end - - -- try to get registered IP - local lookup_host = s["lookup_host"] or "_nolookup_" - local dnsserver = s["dns_server"] or "" - local force_ipversion = tonumber(s["force_ipversion"] or 0) - local force_dnstcp = tonumber(s["force_dnstcp"] or 0) - local is_glue = tonumber(s["is_glue"] or 0) - local command = luci_helper .. [[ -]] - if (use_ipv6 == 1) then command = command .. [[6]] end - if (force_ipversion == 1) then command = command .. [[f]] end - if (force_dnstcp == 1) then command = command .. [[t]] end - if (is_glue == 1) then command = command .. [[g]] end - command = command .. [[l ]] .. lookup_host - if (#dnsserver > 0) then command = command .. [[ -d ]] .. dnsserver end - command = command .. [[ -- get_registered_ip]] - local reg_ip = SYS.exec(command) - if reg_ip == "" then - reg_ip = "_nodata_" - end - - -- fill transfer array - data[#data+1] = { - section = section, - enabled = enabled, - iface = iface, - lookup = lookup_host, - reg_ip = reg_ip, - pid = pid, - datelast = datelast, - datenext = datenext - } - end) - - uci:unload("ddns") - return data -end - --- called by XHR.get from detail_logview.htm -function logread(section) - -- read application settings - local uci = UCI.cursor() - local ldir = uci:get("ddns", "global", "ddns_logdir") or "/var/log/ddns" - local lfile = ldir .. "/" .. section .. ".log" - local ldata = NXFS.readfile(lfile) - - if not ldata or #ldata == 0 then - ldata="_nodata_" - end - uci:unload("ddns") - HTTP.write(ldata) -end - --- called by XHR.get from overview_status.htm -function startstop(section, enabled) - local uci = UCI.cursor() - local pid = DDNS.get_pid(section) - local data = {} -- Array to transfer data to javascript - - -- if process running we want to stop and return - if pid > 0 then - local tmp = NX.kill(pid, 15) -- terminate - NX.nanosleep(2) -- 2 second "show time" - -- status changed so return full status - data = _get_status() - HTTP.prepare_content("application/json") - HTTP.write_json(data) - return - end - - -- read uncommitted changes - -- we don't save and commit data from other section or other options - -- only enabled will be done - local exec = true - local changed = uci:changes("ddns") - for k_config, v_section in pairs(changed) do - -- security check because uci.changes only gets our config - if k_config ~= "ddns" then - exec = false - break - end - for k_section, v_option in pairs(v_section) do - -- check if only section of button was changed - if k_section ~= section then - exec = false - break - end - for k_option, v_value in pairs(v_option) do - -- check if only enabled was changed - if k_option ~= "enabled" then - exec = false - break - end - end - end - end - - -- we can not execute because other - -- uncommitted changes pending, so exit here - if not exec then - HTTP.write("_uncommitted_") - return - end - - -- save enable state - uci:set("ddns", section, "enabled", ( (enabled == "true") and "1" or "0") ) - uci:save("ddns") - uci:commit("ddns") - uci:unload("ddns") - - -- start ddns-updater for section - local command = luci_helper .. [[ -S ]] .. section .. [[ -- start]] - os.execute(command) - NX.nanosleep(3) -- 3 seconds "show time" - - -- status changed so return full status - data = _get_status() - HTTP.prepare_content("application/json") - HTTP.write_json(data) -end - --- called by XHR.poll from overview_status.htm -function status() - local data = _get_status() - HTTP.prepare_content("application/json") - HTTP.write_json(data) -end - diff --git a/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/model/cbi/ddns/detail.lua b/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/model/cbi/ddns/detail.lua deleted file mode 100644 index d283c54..0000000 --- a/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/model/cbi/ddns/detail.lua +++ /dev/null @@ -1,1479 +0,0 @@ --- Copyright 2008 Steven Barth --- Copyright 2008 Jo-Philipp Wich --- Copyright 2013 Manuel Munz --- Copyright 2014-2016 Christian Schoenebeck --- Licensed to the public under the Apache License 2.0. - -local NX = require "nixio" -local NXFS = require "nixio.fs" -local SYS = require "luci.sys" -local UTIL = require "luci.util" -local HTTP = require "luci.http" -local DISP = require "luci.dispatcher" -local WADM = require "luci.tools.webadmin" -local DTYP = require "luci.cbi.datatypes" -local CTRL = require "luci.controller.ddns" -- this application's controller -local DDNS = require "luci.tools.ddns" -- ddns multiused functions - --- takeover arguments -- ####################################################### -local section = arg[1] - --- html constants -- ########################################################### -local font_red = "" -local font_off = "" -local bold_on = "" -local bold_off = "" - --- error text constants -- ##################################################### -local err_ipv6_plain = translate("IPv6 not supported") .. " - " .. - translate("please select 'IPv4' address version") -local err_ipv6_basic = bold_on .. - font_red .. - translate("IPv6 not supported") .. - font_off .. - "
                          " .. translate("please select 'IPv4' address version") .. - bold_off -local err_ipv6_other = bold_on .. - font_red .. - translate("IPv6 not supported") .. - font_off .. - "
                          " .. translate("please select 'IPv4' address version in") .. " " .. - [[]] .. - translate("Basic Settings") .. - [[]] .. - bold_off - -function err_tab_basic(self) - return translate("Basic Settings") .. " - " .. self.title .. ": " -end -function err_tab_adv(self) - return translate("Advanced Settings") .. " - " .. self.title .. ": " -end -function err_tab_timer(self) - return translate("Timer Settings") .. " - " .. self.title .. ": " -end - --- read services/services_ipv6 files -- ######################################## -local services4 = { } -- IPv4 -- -local fd4 = io.open("/etc/ddns/services", "r") -if fd4 then - local ln, s, t - repeat - ln = fd4:read("*l") - s = ln and ln:match('^%s*".*') -- only handle lines beginning with " - s = s and s:gsub('"','') -- remove " - t = s and UTIL.split(s,"(%s+)",nil,true) -- split on whitespaces - if t then services4[t[1]]=t[2] end - until not ln - fd4:close() -end - -local services6 = { } -- IPv6 -- -local fd6 = io.open("/etc/ddns/services_ipv6", "r") -if fd6 then - local ln, s, t - repeat - ln = fd6:read("*l") - s = ln and ln:match('^%s*".*') -- only handle lines beginning with " - s = s and s:gsub('"','') -- remove " - t = s and UTIL.split(s,"(%s+)",nil,true) -- split on whitespaces - if t then services6[t[1]]=t[2] end - until not ln - fd6:close() -end - --- multi-used functions -- #################################################### --- function to verify settings around ip_source --- will use dynamic_dns_lucihelper to check if --- local IP can be read -local function _verify_ip_source() - -- section is globally defined here be calling agrument (see above) - local _arg - - local _ipv6 = usev6:formvalue(section) - local _source = (_ipv6 == "1") - and src6:formvalue(section) - or src4:formvalue(section) - - local command = CTRL.luci_helper .. [[ -]] - if (_ipv6 == "1") then command = command .. [[6]] end - - if _source == "network" then - _arg = (_ipv6 == "1") - and ipn6:formvalue(section) - or ipn4:formvalue(section) - command = command .. [[n ]] .. _arg - elseif _source == "web" then - _arg = (_ipv6 == "1") - and iurl6:formvalue(section) - or iurl4:formvalue(section) - command = command .. [[u ]] .. _arg - - -- proxy only needed for checking url - _arg = (pxy) and pxy:formvalue(section) or "" - if (_arg and #_arg > 0) then - command = command .. [[ -p ]] .. _arg - end - elseif _source == "interface" then - command = command .. [[i ]] .. ipi:formvalue(section) - elseif _source == "script" then - command = command .. [[s ]] .. ips:formvalue(section) - end - command = command .. [[ -- get_local_ip]] - return (SYS.call(command) == 0) -end - --- function to check if option is used inside url or script --- return -1 on error, 0 NOT required, 1 required -local function _option_used(option, urlscript) - local surl -- search string for url - local ssh -- search string for script - local required -- option used inside url or script - - if option == "domain" then surl, ssh = '%[DOMAIN%]', '%$domain' - elseif option == "username" then surl, ssh = '%[USERNAME%]', '%$username' - elseif option == "password" then surl, ssh = '%[PASSWORD%]', '%$password' - elseif option == "param_enc" then surl, ssh = '%[PARAMENC%]', '%$param_enc' - elseif option == "param_opt" then surl, ssh = '%[PARAMOPT%]', '%$param_opt' - else - error("undefined option") - return -1 -- return on error - end - - local required = false - -- handle url - if urlscript:find('http') then - required = ( urlscript:find(surl) ) - -- handle script - else - if not urlscript:find("/") then - -- might be inside ddns-scripts directory - urlscript = "/usr/lib/ddns/" .. urlscript - end - -- problem with script exit here - if not NXFS.access(urlscript) then return -1 end - - local f = io.input(urlscript) - -- still problem with script exit here - if not f then return -1 end - for l in f:lines() do - repeat - if l:find('^#') then break end -- continue on comment lines - required = ( l:find(surl) or l:find(ssh) ) - until true - if required then break end - end - f:close() - end - return (required and 1 or 0) -end - --- function to verify if option is valid -local function _option_validate(self, value) - -- section is globally defined here be calling agrument (see above) - local fusev6 = usev6:formvalue(section) or "0" - local fsvc4 = svc4:formvalue(section) or "-" - local fsvc6 = svc6:formvalue(section) or "-" - local urlsh, used - - -- IP-Version dependent custom service selected - if (fusev6 == "0" and fsvc4 == "-") or - (fusev6 == "1" and fsvc6 == "-") then - -- read custom url - urlsh = uurl:formvalue(section) or "" - -- no url then read custom script - if (#urlsh == 0) then - urlsh = ush:formvalue(section) or "" - end - -- IPv4 read from services4 table - elseif (fusev6 == "0") then - urlsh = services4[fsvc4] or "" - -- IPv6 read from services6 table - else - urlsh = services6[fsvc6] or "" - end - -- problem with url or script exit here - -- error handled somewhere else - if (#urlsh == 0) then return "" end - - used = _option_used(self.option, urlsh) - -- on error or not used return empty sting - if used < 1 then return "" end - -- needed but no data then return error - if not value or (#value == 0) then - return nil, err_tab_basic(self) .. translate("missing / required") - end - return value -end - --- cbi-map definition -- ####################################################### -local m = Map("ddns") -m.title = CTRL.app_title_back() -m.description = CTRL.app_description() -m.redirect = DISP.build_url("admin", "services", "ddns") - -m.on_after_commit = function(self) - if self.changed then -- changes ? - local pid = DDNS.get_pid(section) - if pid > 0 then -- running ? - local tmp = NX.kill(pid, 1) -- send SIGHUP - end - end -end - --- provider switch was requested, save and reload page -if m:formvalue("cbid.ddns.%s._switch" % section) then -- section == arg[1] - local fsvc - local fusev6 = m:formvalue("cbid.ddns.%s.use_ipv6" % section) or "0" - if fusev6 == "1" then - fsvc = m:formvalue("cbid.ddns.%s.ipv6_service_name" % section) or "" - else - fsvc = m:formvalue("cbid.ddns.%s.ipv4_service_name" % section) or "" - end - - if fusev6 ~= (m:get(section, "use_ipv6") or "0") then -- IPv6 was changed - m:set(section, "use_ipv6", fusev6) -- save it - end - - if fsvc ~= "-" then -- NOT "custom" - m:set(section, "service_name", fsvc) -- save it - else -- else - m:del(section, "service_name") -- delete it - end - m.uci:save(m.config) - - -- reload page - HTTP.redirect( DISP.build_url("admin", "services", "ddns", "detail", section) ) - return -end - --- read application settings -- ################################################ --- log directory -local logdir = m.uci:get(m.config, "global", "ddns_logdir") or "/var/log/ddns" - --- cbi-section definition -- ################################################### -local ns = m:section( NamedSection, section, "service", - translate("Details for") .. ([[: %s]] % section), - translate("Configure here the details for selected Dynamic DNS service.") ) -ns.instance = section -- arg [1] -ns:tab("basic", translate("Basic Settings"), nil ) -ns:tab("advanced", translate("Advanced Settings"), nil ) -ns:tab("timer", translate("Timer Settings"), nil ) -ns:tab("logview", translate("Log File Viewer"), nil ) - --- TAB: Basic ##################################################################################### --- enabled -- ################################################################# -en = ns:taboption("basic", Flag, "enabled", - translate("Enabled"), - translate("Enable service") ) -en.orientation = "horizontal" - --- IPv4/IPv6 - lookup_host -- ################################################# -luh = ns:taboption("basic", Value, "lookup_host", - translate("Lookup Hostname"), - translate("Hostname/FQDN to validate, if an IP update happens or is necessary") ) -luh.rmempty = false -luh.placeholder = "myhost.example.com" -function luh.validate(self, value) - if not value - or not (#value > 0) - or not DTYP.hostname(value) then - return nil, err_tab_basic(self) .. translate("invalid FQDN / required - Sample") .. ": 'myhost.example.com'" - else - return UTIL.trim(value) - end -end -function luh.parse(self, section, novld) - DDNS.value_parse(self, section, novld) -end - --- use_ipv6 -- ################################################################ -usev6 = ns:taboption("basic", ListValue, "use_ipv6", - translate("IP address version"), - translate("Defines which IP address 'IPv4/IPv6' is send to the DDNS provider") ) -usev6.widget = "radio" -usev6.default = "0" -usev6:value("0", translate("IPv4-Address") ) -function usev6.cfgvalue(self, section) - local value = AbstractValue.cfgvalue(self, section) or "0" - if DDNS.has_ipv6 or (value == "1" and not DDNS.has_ipv6) then - self:value("1", translate("IPv6-Address") ) - end - if value == "1" and not DDNS.has_ipv6 then - self.description = err_ipv6_basic - end - return value -end -function usev6.validate(self, value) - if (value == "1" and DDNS.has_ipv6) or value == "0" then - return value - end - return nil, err_tab_basic(self) .. err_ipv6_plain -end -function usev6.parse(self, section, novld) - DDNS.value_parse(self, section, novld) -end - --- IPv4 - service_name -- ##################################################### -svc4 = ns:taboption("basic", ListValue, "ipv4_service_name", - translate("DDNS Service provider") .. " [IPv4]" ) -svc4.default = "-" -svc4:depends("use_ipv6", "0") -- only show on IPv4 -function svc4.cfgvalue(self, section) - local v = DDNS.read_value(self, section, "service_name") - if v and (#v > 0) then - for s, u in UTIL.kspairs(services4) do - if v == s then return v end - end - end - return "-" -end -function svc4.validate(self, value) - if usev6:formvalue(section) ~= "1" then -- do only on IPv4 - return value - else - return "" -- suppress validate error - end -end -function svc4.write(self, section, value) - if usev6:formvalue(section) ~= "1" then -- do only IPv4 here - self.map:del(section, self.option) -- to be shure - if value ~= "-" then -- and write "service_name - self.map:del(section, "update_url") -- delete update_url - self.map:del(section, "update_script") -- delete update_script - return self.map:set(section, "service_name", value) - else - return self.map:del(section, "service_name") - end - end -end -function svc4.parse(self, section, novld) - DDNS.value_parse(self, section, novld) -end - --- IPv6 - service_name -- ##################################################### -svc6 = ns:taboption("basic", ListValue, "ipv6_service_name", - translate("DDNS Service provider") .. " [IPv6]" ) -svc6.default = "-" -svc6:depends("use_ipv6", "1") -- only show on IPv6 -if not DDNS.has_ipv6 then - svc6.description = err_ipv6_basic -end -function svc6.cfgvalue(self, section) - local v = DDNS.read_value(self, section, "service_name") - if v and (#v > 0) then - for s, u in UTIL.kspairs(services4) do - if v == s then return v end - end - end - return "-" -end -function svc6.validate(self, value) - if usev6:formvalue(section) == "1" then -- do only on IPv6 - if DDNS.has_ipv6 then return value end - return nil, err_tab_basic(self) .. err_ipv6_plain - else - return "" -- suppress validate error - end -end -function svc6.write(self, section, value) - if usev6:formvalue(section) == "1" then -- do only when IPv6 - self.map:del(section, self.option) -- delete "ipv6_service_name" helper - if value ~= "-" then -- and write "service_name - self.map:del(section, "update_url") -- delete update_url - self.map:del(section, "update_script") -- delete update_script - return self.map:set(section, "service_name", value) - else - return self.map:del(section, "service_name") - end - end -end -function svc6.parse(self, section, novld) - DDNS.value_parse(self, section, novld) -end - --- IPv4/IPv6 - change Provider -- ############################################# -svs = ns:taboption("basic", Button, "_switch") -svs.title = translate("Really change DDNS provider?") -svs.inputtitle = translate("Change provider") -svs.inputstyle = "apply" - --- IPv4/IPv6 - update_url -- ################################################## -uurl = ns:taboption("basic", Value, "update_url", - translate("Custom update-URL"), - translate("Update URL to be used for updating your DDNS Provider." .. "
                          " .. - "Follow instructions you will find on their WEB page.") ) -function uurl.validate(self, value) - local fush = ush:formvalue(section) - local fusev6 = usev6:formvalue(section) - - if (fusev6 ~= "1" and svc4:formvalue(section) ~= "-") or - (fusev6 == "1" and svc6:formvalue(section) ~= "-") then - return "" -- suppress validate error - elseif not value or (#value == 0) then - if not fush or (#fush == 0) then - return nil, err_tab_basic(self) .. translate("missing / required") - else - return "" -- suppress validate error / update_script is given - end - elseif (#fush > 0) then - return nil, err_tab_basic(self) .. translate("either url or script could be set") - end - - local url = DDNS.parse_url(value) - if not url.scheme == "http" then - return nil, err_tab_basic(self) .. translate("must start with 'http://'") - elseif not url.query then - return nil, err_tab_basic(self) .. " " .. translate("missing / required") - elseif not url.host then - return nil, err_tab_basic(self) .. " " .. translate("missing / required") - elseif SYS.call([[nslookup ]] .. url.host .. [[ >/dev/null 2>&1]]) ~= 0 then - return nil, err_tab_basic(self) .. translate("can not resolve host: ") .. url.host - end - - return value -end -function uurl.parse(self, section, novld) - DDNS.value_parse(self, section, novld) -end - --- IPv4/IPv6 - update_script -- ############################################### -ush = ns:taboption("basic", Value, "update_script", - translate("Custom update-script"), - translate("Custom update script to be used for updating your DDNS Provider.") ) -function ush.validate(self, value) - local fuurl = uurl:formvalue(section) - local fusev6 = usev6:formvalue(section) - - if (fusev6 ~= "1" and svc4:formvalue(section) ~= "-") or - (fusev6 == "1" and svc6:formvalue(section) ~= "-") then - return "" -- suppress validate error - elseif not value or (#value == 0) then - if not fuurl or (#fuurl == 0) then - return nil, err_tab_basic(self) .. translate("missing / required") - else - return "" -- suppress validate error / update_url is given - end - elseif (#fuurl > 0) then - return nil, err_tab_basic(self) .. translate("either url or script could be set") - elseif not NXFS.access(value) then - return nil, err_tab_basic(self) .. translate("File not found") - end - return value -end -function ush.parse(self, section, novld) - DDNS.value_parse(self, section, novld) -end - --- IPv4/IPv6 - domain -- ###################################################### -dom = ns:taboption("basic", Value, "domain", - translate("Domain"), - translate("Replaces [DOMAIN] in Update-URL") ) -dom.placeholder = "myhost.example.com" -function dom.validate(self, value) - return _option_validate(self, value) -end -function dom.parse(self, section, novld) - DDNS.value_parse(self, section, novld) -end - --- IPv4/IPv6 - username -- #################################################### -user = ns:taboption("basic", Value, "username", - translate("Username"), - translate("Replaces [USERNAME] in Update-URL (URL-encoded)") ) -function user.validate(self, value) - return _option_validate(self, value) -end -function user.parse(self, section, novld) - DDNS.value_parse(self, section, novld) -end - --- IPv4/IPv6 - password -- #################################################### -pw = ns:taboption("basic", Value, "password", - translate("Password"), - translate("Replaces [PASSWORD] in Update-URL (URL-encoded)") ) -pw.password = true -function pw.validate(self, value) - return _option_validate(self, value) -end -function pw.parse(self, section, novld) - DDNS.value_parse(self, section, novld) -end - --- IPv4/IPv6 - param_enc -- ################################################### -pe = ns:taboption("basic", Value, "param_enc", - translate("Optional Encoded Parameter"), - translate("Optional: Replaces [PARAMENC] in Update-URL (URL-encoded)") ) -function pe.validate(self, value) - return _option_validate(self, value) -end -function pe.parse(self, section, novld) - DDNS.value_parse(self, section, novld) -end - --- IPv4/IPv6 - param_enc -- ################################################### -po = ns:taboption("basic", Value, "param_opt", - translate("Optional Parameter"), - translate("Optional: Replaces [PARAMOPT] in Update-URL (NOT URL-encoded)") ) -function po.validate(self, value) - return _option_validate(self, value) -end -function po.parse(self, section, novld) - DDNS.value_parse(self, section, novld) -end - --- handled service dependent show/display -- ################################## --- IPv4 -- -local cv4 = svc4:cfgvalue(section) -if cv4 ~= "-" then - svs:depends ("ipv4_service_name", "-" ) -- show only if "-" - ush:depends ("ipv4_service_name", "?") - uurl:depends("ipv4_service_name", "?") -else - uurl:depends("ipv4_service_name", "-") - ush:depends ("ipv4_service_name", "-") - dom:depends("ipv4_service_name", "-" ) - user:depends("ipv4_service_name", "-" ) - pw:depends("ipv4_service_name", "-" ) - pe:depends("ipv4_service_name", "-" ) - po:depends("ipv4_service_name", "-" ) -end -for s, u in UTIL.kspairs(services4) do - svc4:value(s) -- fill DropDown-List - if cv4 ~= s then - svs:depends("ipv4_service_name", s ) - else - dom:depends ("ipv4_service_name", ((_option_used(dom.option, u) == 1) and s or "?") ) - user:depends("ipv4_service_name", ((_option_used(user.option, u) == 1) and s or "?") ) - pw:depends ("ipv4_service_name", ((_option_used(pw.option, u) == 1) and s or "?") ) - pe:depends ("ipv4_service_name", ((_option_used(pe.option, u) == 1) and s or "?") ) - po:depends ("ipv4_service_name", ((_option_used(po.option, u) == 1) and s or "?") ) - end -end -svc4:value("-", translate("-- custom --") ) - --- IPv6 -- -local cv6 = svc6:cfgvalue(section) -if cv6 ~= "-" then - svs:depends ("ipv6_service_name", "-" ) - uurl:depends("ipv6_service_name", "?") - ush:depends ("ipv6_service_name", "?") -else - uurl:depends("ipv6_service_name", "-") - ush:depends ("ipv6_service_name", "-") - dom:depends("ipv6_service_name", "-" ) - user:depends("ipv6_service_name", "-" ) - pw:depends("ipv6_service_name", "-" ) - pe:depends("ipv6_service_name", "-" ) - po:depends("ipv6_service_name", "-" ) -end -for s, u in UTIL.kspairs(services6) do - svc6:value(s) -- fill DropDown-List - if cv6 ~= s then - svs:depends("ipv6_service_name", s ) - else - dom:depends ("ipv6_service_name", ((_option_used(dom.option, u) == 1) and s or "?") ) - user:depends("ipv6_service_name", ((_option_used(user.option, u) == 1) and s or "?") ) - pw:depends ("ipv6_service_name", ((_option_used(pw.option, u) == 1) and s or "?") ) - pe:depends ("ipv6_service_name", ((_option_used(pe.option, u) == 1) and s or "?") ) - po:depends ("ipv6_service_name", ((_option_used(po.option, u) == 1) and s or "?") ) - end -end -svc6:value("-", translate("-- custom --") ) - --- IPv4/IPv6 - use_https -- ################################################### -if DDNS.has_ssl or ( ( m:get(section, "use_https") or "0" ) == "1" ) then - https = ns:taboption("basic", Flag, "use_https", - translate("Use HTTP Secure") ) - https.orientation = "horizontal" - function https.cfgvalue(self, section) - local value = AbstractValue.cfgvalue(self, section) - if not DDNS.has_ssl and value == "1" then - self.description = bold_on .. font_red .. - translate("HTTPS not supported") .. font_off .. "
                          " .. - translate("please disable") .. " !" .. bold_off - else - self.description = translate("Enable secure communication with DDNS provider") - end - return value - end - function https.validate(self, value) - if (value == "1" and DDNS.has_ssl ) or value == "0" then return value end - return nil, err_tab_basic(self) .. translate("HTTPS not supported") .. " !" - end - function https.write(self, section, value) - if value == "1" then - return self.map:set(section, self.option, value) - else - self.map:del(section, "cacert") - return self.map:del(section, self.option) - end - end -end - --- IPv4/IPv6 - cacert -- ###################################################### -if DDNS.has_ssl then - cert = ns:taboption("basic", Value, "cacert", - translate("Path to CA-Certificate"), - translate("directory or path/file") .. "
                          " .. - translate("or") .. bold_on .. " IGNORE " .. bold_off .. - translate("to run HTTPS without verification of server certificates (insecure)") ) - cert:depends("use_https", "1") - cert.placeholder = "/etc/ssl/certs" - cert.forcewrite = true - function cert.validate(self, value) - if https:formvalue(section) ~= "1" then - return "" -- suppress validate error if NOT https - end - if value then -- otherwise errors in datatype check - if DTYP.directory(value) - or DTYP.file(value) - or (value == "IGNORE") - or (#value == 0) then - return value - end - end - return nil, err_tab_basic(self) .. - translate("file or directory not found or not 'IGNORE'") .. " !" - end - function cert.parse(self, section, novld) - DDNS.value_parse(self, section, novld) - end -end - --- TAB: Advanced ################################################################################# --- IPv4 - ip_source -- ######################################################## -src4 = ns:taboption("advanced", ListValue, "ipv4_source", - translate("IP address source") .. " [IPv4]", - translate("Defines the source to read systems IPv4-Address from, that will be send to the DDNS provider") ) -src4:depends("use_ipv6", "0") -- IPv4 selected -src4.default = "network" -src4:value("network", translate("Network")) -src4:value("web", translate("URL")) -src4:value("interface", translate("Interface")) -src4:value("script", translate("Script")) -function src4.cfgvalue(self, section) - return DDNS.read_value(self, section, "ip_source") -end -function src4.validate(self, value) - if usev6:formvalue(section) == "1" then - return "" -- ignore on IPv6 selected - elseif not _verify_ip_source() then - return nil, err_tab_adv(self) .. - translate("can not detect local IP. Please select a different Source combination") - else - return value - end -end -function src4.write(self, section, value) - if usev6:formvalue(section) == "1" then - return true -- ignore on IPv6 selected - elseif value == "network" then - self.map:del(section, "ip_url") -- delete not need parameters - self.map:del(section, "ip_interface") - self.map:del(section, "ip_script") - elseif value == "web" then - self.map:del(section, "ip_network") -- delete not need parameters - self.map:del(section, "ip_interface") - self.map:del(section, "ip_script") - elseif value == "interface" then - self.map:del(section, "ip_network") -- delete not need parameters - self.map:del(section, "ip_url") - self.map:del(section, "ip_script") - elseif value == "script" then - self.map:del(section, "ip_network") - self.map:del(section, "ip_url") -- delete not need parameters - self.map:del(section, "ip_interface") - end - self.map:del(section, self.option) -- delete "ipv4_source" helper - return self.map:set(section, "ip_source", value) -- and write "ip_source -end -function src4.parse(self, section, novld) - DDNS.value_parse(self, section, novld) -end - --- IPv6 - ip_source -- ######################################################## -src6 = ns:taboption("advanced", ListValue, "ipv6_source", - translate("IP address source") .. " [IPv6]", - translate("Defines the source to read systems IPv6-Address from, that will be send to the DDNS provider") ) -src6:depends("use_ipv6", 1) -- IPv6 selected -src6.default = "network" -src6:value("network", translate("Network")) -src6:value("web", translate("URL")) -src6:value("interface", translate("Interface")) -src6:value("script", translate("Script")) -if not DDNS.has_ipv6 then - src6.description = err_ipv6_other -end -function src6.cfgvalue(self, section) - return DDNS.read_value(self, section, "ip_source") -end -function src6.validate(self, value) - if usev6:formvalue(section) ~= "1" then - return "" -- ignore on IPv4 selected - elseif not DDNS.has_ipv6 then - return nil, err_tab_adv(self) .. err_ipv6_plain - elseif not _verify_ip_source() then - return nil, err_tab_adv(self) .. - translate("can not detect local IP. Please select a different Source combination") - else - return value - end -end -function src6.write(self, section, value) - if usev6:formvalue(section) ~= "1" then - return true -- ignore on IPv4 selected - elseif value == "network" then - self.map:del(section, "ip_url") -- delete not need parameters - self.map:del(section, "ip_interface") - self.map:del(section, "ip_script") - elseif value == "web" then - self.map:del(section, "ip_network") -- delete not need parameters - self.map:del(section, "ip_interface") - self.map:del(section, "ip_script") - elseif value == "interface" then - self.map:del(section, "ip_network") -- delete not need parameters - self.map:del(section, "ip_url") - self.map:del(section, "ip_script") - elseif value == "script" then - self.map:del(section, "ip_network") - self.map:del(section, "ip_url") -- delete not need parameters - self.map:del(section, "ip_interface") - end - self.map:del(section, self.option) -- delete "ipv4_source" helper - return self.map:set(section, "ip_source", value) -- and write "ip_source -end -function src6.parse(self, section, novld) - DDNS.value_parse(self, section, novld) -end - --- IPv4 - ip_network (default "wan") -- ####################################### -ipn4 = ns:taboption("advanced", ListValue, "ipv4_network", - translate("Network") .. " [IPv4]", - translate("Defines the network to read systems IPv4-Address from") ) -ipn4:depends("ipv4_source", "network") -ipn4.default = "wan" -WADM.cbi_add_networks(ipn4) -function ipn4.cfgvalue(self, section) - return DDNS.read_value(self, section, "ip_network") -end -function ipn4.validate(self, value) - if usev6:formvalue(section) == "1" - or src4:formvalue(section) ~= "network" then - -- ignore if IPv6 selected OR - -- ignore everything except "network" - return "" - else - return value - end -end -function ipn4.write(self, section, value) - if usev6:formvalue(section) == "1" - or src4:formvalue(section) ~= "network" then - -- ignore if IPv6 selected OR - -- ignore everything except "network" - return true - else - -- set also as "interface" for monitoring events changes/hot-plug - self.map:set(section, "interface", value) - self.map:del(section, self.option) -- delete "ipv4_network" helper - return self.map:set(section, "ip_network", value) -- and write "ip_network" - end -end -function ipn4.parse(self, section, novld) - DDNS.value_parse(self, section, novld) -end - --- IPv6 - ip_network (default "wan6") -- ###################################### -ipn6 = ns:taboption("advanced", ListValue, "ipv6_network", - translate("Network") .. " [IPv6]" ) -ipn6:depends("ipv6_source", "network") -ipn6.default = "wan6" -WADM.cbi_add_networks(ipn6) -if DDNS.has_ipv6 then - ipn6.description = translate("Defines the network to read systems IPv6-Address from") -else - ipn6.description = err_ipv6_other -end -function ipn6.cfgvalue(self, section) - return DDNS.read_value(self, section, "ip_network") -end -function ipn6.validate(self, value) - if usev6:formvalue(section) ~= "1" - or src6:formvalue(section) ~= "network" then - -- ignore if IPv4 selected OR - -- ignore everything except "network" - return "" - elseif DDNS.has_ipv6 then - return value - else - return nil, err_tab_adv(self) .. err_ipv6_plain - end -end -function ipn6.write(self, section, value) - if usev6:formvalue(section) ~= "1" - or src6:formvalue(section) ~= "network" then - -- ignore if IPv4 selected OR - -- ignore everything except "network" - return true - else - -- set also as "interface" for monitoring events changes/hotplug - self.map:set(section, "interface", value) - self.map:del(section, self.option) -- delete "ipv6_network" helper - return self.map:set(section, "ip_network", value) -- and write "ip_network" - end -end -function ipn6.parse(self, section, novld) - DDNS.value_parse(self, section, novld) -end - --- IPv4 - ip_url (default "checkip.dyndns.com") -- ############################ -iurl4 = ns:taboption("advanced", Value, "ipv4_url", - translate("URL to detect") .. " [IPv4]", - translate("Defines the Web page to read systems IPv4-Address from") ) -iurl4:depends("ipv4_source", "web") -iurl4.default = "http://checkip.dyndns.com" -function iurl4.cfgvalue(self, section) - return DDNS.read_value(self, section, "ip_url") -end -function iurl4.validate(self, value) - if usev6:formvalue(section) == "1" - or src4:formvalue(section) ~= "web" then - -- ignore if IPv6 selected OR - -- ignore everything except "web" - return "" - elseif not value or #value == 0 then - return nil, err_tab_adv(self) .. translate("missing / required") - end - - local url = DDNS.parse_url(value) - if not (url.scheme == "http" or url.scheme == "https") then - return nil, err_tab_adv(self) .. translate("must start with 'http://'") - elseif not url.host then - return nil, err_tab_adv(self) .. " " .. translate("missing / required") - elseif SYS.call([[nslookup ]] .. url.host .. [[>/dev/null 2>&1]]) ~= 0 then - return nil, err_tab_adv(self) .. translate("can not resolve host: ") .. url.host - else - return value - end -end -function iurl4.write(self, section, value) - if usev6:formvalue(section) == "1" - or src4:formvalue(section) ~= "web" then - -- ignore if IPv6 selected OR - -- ignore everything except "web" - return true - else - self.map:del(section, self.option) -- delete "ipv4_url" helper - return self.map:set(section, "ip_url", value) -- and write "ip_url" - end -end -function iurl4.parse(self, section, novld) - DDNS.value_parse(self, section, novld) -end - --- IPv6 - ip_url (default "checkipv6.dyndns.com") -- ########################## -iurl6 = ns:taboption("advanced", Value, "ipv6_url", - translate("URL to detect") .. " [IPv6]" ) -iurl6:depends("ipv6_source", "web") -iurl6.default = "http://checkipv6.dyndns.com" -if DDNS.has_ipv6 then - iurl6.description = translate("Defines the Web page to read systems IPv6-Address from") -else - iurl6.description = err_ipv6_other -end -function iurl6.cfgvalue(self, section) - return DDNS.read_value(self, section, "ip_url") -end -function iurl6.validate(self, value) - if usev6:formvalue(section) ~= "1" - or src6:formvalue(section) ~= "web" then - -- ignore if IPv4 selected OR - -- ignore everything except "web" - return "" - elseif not DDNS.has_ipv6 then - return nil, err_tab_adv(self) .. err_ipv6_plain - elseif not value or #value == 0 then - return nil, err_tab_adv(self) .. translate("missing / required") - end - - local url = DDNS.parse_url(value) - if not (url.scheme == "http" or url.scheme == "https") then - return nil, err_tab_adv(self) .. translate("must start with 'http://'") - elseif not url.host then - return nil, err_tab_adv(self) .. " " .. translate("missing / required") - elseif SYS.call([[nslookup ]] .. url.host .. [[>/dev/null 2>&1]]) ~= 0 then - return nil, err_tab_adv(self) .. translate("can not resolve host: ") .. url.host - else - return value - end -end -function iurl6.write(self, section, value) - if usev6:formvalue(section) ~= "1" - or src6:formvalue(section) ~= "web" then - -- ignore if IPv4 selected OR - -- ignore everything except "web" - return true - else - self.map:del(section, self.option) -- delete "ipv6_url" helper - return self.map:set(section, "ip_url", value) -- and write "ip_url" - end -end -function iurl6.parse(self, section, novld) - DDNS.value_parse(self, section, novld) -end - --- IPv4 + IPv6 - ip_interface -- ############################################## -ipi = ns:taboption("advanced", ListValue, "ip_interface", - translate("Interface"), - translate("Defines the interface to read systems IP-Address from") ) -ipi:depends("ipv4_source", "interface") -- IPv4 -ipi:depends("ipv6_source", "interface") -- or IPv6 -for _, v in pairs(SYS.net.devices()) do - -- show only interface set to a network - -- and ignore loopback - net = WADM.iface_get_network(v) - if net and net ~= "loopback" then - ipi:value(v) - end -end -function ipi.validate(self, value) - local fusev6 = usev6:formvalue(section) - if (fusev6 ~= "1" and src4:formvalue(section) ~= "interface") - or (fusev6 == "1" and src6:formvalue(section) ~= "interface") then - return "" - else - return value - end -end -function ipi.write(self, section, value) - local fusev6 = usev6:formvalue(section) - if (fusev6 ~= "1" and src4:formvalue(section) ~= "interface") - or (fusev6 == "1" and src6:formvalue(section) ~= "interface") then - return true - else - -- get network from device to - -- set also as "interface" for monitoring events changes/hotplug - local net = WADM.iface_get_network(value) - self.map:set(section, "interface", net) - return self.map:set(section, self.option, value) - end -end -function ipi.parse(self, section, novld) - DDNS.value_parse(self, section, novld) -end - --- IPv4 + IPv6 - ip_script -- ################################################# -ips = ns:taboption("advanced", Value, "ip_script", - translate("Script"), - translate("User defined script to read systems IP-Address") ) -ips:depends("ipv4_source", "script") -- IPv4 -ips:depends("ipv6_source", "script") -- or IPv6 -ips.placeholder = "/path/to/script.sh" -function ips.validate(self, value) - local fusev6 = usev6:formvalue(section) - local split - if value then split = UTIL.split(value, " ") end - - if (fusev6 ~= "1" and src4:formvalue(section) ~= "script") - or (fusev6 == "1" and src6:formvalue(section) ~= "script") then - return "" - elseif not value or not (#value > 0) or not NXFS.access(split[1], "x") then - return nil, err_tab_adv(self) .. - translate("not found or not executable - Sample: '/path/to/script.sh'") - else - return value - end -end -function ips.write(self, section, value) - local fusev6 = usev6:formvalue(section) - if (fusev6 ~= "1" and src4:formvalue(section) ~= "script") - or (fusev6 == "1" and src6:formvalue(section) ~= "script") then - return true - else - return self.map:set(section, self.option, value) - end -end -function ips.parse(self, section, novld) - DDNS.value_parse(self, section, novld) -end - --- IPv4 - interface - default "wan" -- ######################################## --- event network to monitor changes/hotplug/dynamic_dns_updater.sh --- only needs to be set if "ip_source"="web" or "script" --- if "ip_source"="network" or "interface" we use their network -eif4 = ns:taboption("advanced", ListValue, "ipv4_interface", - translate("Event Network") .. " [IPv4]", - translate("Network on which the ddns-updater scripts will be started") ) -eif4:depends("ipv4_source", "web") -eif4:depends("ipv4_source", "script") -eif4.default = "wan" -WADM.cbi_add_networks(eif4) -function eif4.cfgvalue(self, section) - return DDNS.read_value(self, section, "interface") -end -function eif4.validate(self, value) - local fsrc4 = src4:formvalue(section) or "" - if usev6:formvalue(section) == "1" - or fsrc4 == "network" - or fsrc4 == "interface" then - return "" -- ignore IPv6, network, interface - else - return value - end -end -function eif4.write(self, section, value) - local fsrc4 = src4:formvalue(section) or "" - if usev6:formvalue(section) == "1" - or fsrc4 == "network" - or fsrc4 == "interface" then - return true -- ignore IPv6, network, interface - else - self.map:del(section, self.option) -- delete "ipv4_interface" helper - return self.map:set(section, "interface", value) -- and write "interface" - end -end -function eif4.parse(self, section, novld) - DDNS.value_parse(self, section, novld) -end - --- IPv6 - interface - default "wan6" -- ####################################### --- event network to monitor changes/hotplug --- only needs to be set if "ip_source"="web" or "script" --- if "ip_source"="network" or "interface" we use their network -eif6 = ns:taboption("advanced", ListValue, "ipv6_interface", - translate("Event Network") .. " [IPv6]" ) -eif6:depends("ipv6_source", "web") -eif6:depends("ipv6_source", "script") -eif6.default = "wan6" -WADM.cbi_add_networks(eif6) -if not DDNS.has_ipv6 then - eif6.description = err_ipv6_other -else - eif6.description = translate("Network on which the ddns-updater scripts will be started") -end -function eif6.cfgvalue(self, section) - return DDNS.read_value(self, section, "interface") -end -function eif6.validate(self, value) - local fsrc6 = src6:formvalue(section) or "" - if usev6:formvalue(section) ~= "1" - or fsrc6 == "network" - or fsrc6 == "interface" then - return "" -- ignore IPv4, network, interface - elseif not DDNS.has_ipv6 then - return nil, err_tab_adv(self) .. err_ipv6_plain - else - return value - end -end -function eif6.write(self, section, value) - local fsrc6 = src6:formvalue(section) or "" - if usev6:formvalue(section) ~= "1" - or fsrc6 == "network" - or fsrc6 == "interface" then - return true -- ignore IPv4, network, interface - else - self.map:del(section, self.option) -- delete "ipv6_interface" helper - return self.map:set(section, "interface", value) -- and write "interface" - end -end -function eif6.parse(self, section, novld) - DDNS.value_parse(self, section, novld) -end - --- IPv4/IPv6 - bind_network -- ################################################ -if DDNS.has_bindnet or ( ( m:get(section, "bind_network") or "" ) ~= "" ) then - bnet = ns:taboption("advanced", ListValue, "bind_network", - translate("Bind Network") ) - bnet:depends("ipv4_source", "web") - bnet:depends("ipv6_source", "web") - bnet.default = "" - bnet:value("", translate("-- default --")) - WADM.cbi_add_networks(bnet) - function bnet.cfgvalue(self, section) - local value = AbstractValue.cfgvalue(self, section) - if not DDNS.has_bindnet and value ~= "" then - self.description = bold_on .. font_red .. - translate("Binding to a specific network not supported") .. font_off .. "
                          " .. - translate("please set to 'default'") .. " !" .. bold_off - else - self.description = translate("OPTIONAL: Network to use for communication") .. - "
                          " .. translate("Casual users should not change this setting") - end - return value - end - function bnet.validate(self, value) - if ( (value ~= "") and DDNS.has_bindnet ) or (value == "") then return value end - return nil, err_tab_adv(self) .. translate("Binding to a specific network not supported") .. " !" - end - function bnet.parse(self, section, novld) - DDNS.value_parse(self, section, novld) - end -end - --- IPv4 + IPv6 - force_ipversion -- ########################################### --- optional to force wget/curl and host to use only selected IP version --- command parameter "-4" or "-6" -if DDNS.has_forceip or ( ( m:get(section, "force_ipversion") or "0" ) ~= "0" ) then - fipv = ns:taboption("advanced", Flag, "force_ipversion", - translate("Force IP Version") ) - fipv.orientation = "horizontal" - function fipv.cfgvalue(self, section) - local value = AbstractValue.cfgvalue(self, section) - if not DDNS.has_forceip and value ~= "0" then - self.description = bold_on .. font_red .. - translate("Force IP Version not supported") .. font_off .. "
                          " .. - translate("please disable") .. " !" .. bold_off - else - self.description = translate("OPTIONAL: Force the usage of pure IPv4/IPv6 only communication.") - end - return value - end - function fipv.validate(self, value) - if (value == "1" and DDNS.has_forceip) or value == "0" then return value end - return nil, err_tab_adv(self) .. translate("Force IP Version not supported") - end -end - --- IPv4 + IPv6 - dns_server -- ################################################ --- optional DNS Server to use resolving my IP -if DDNS.has_dnsserver or ( ( m:get(section, "dns_server") or "" ) ~= "" ) then - dns = ns:taboption("advanced", Value, "dns_server", - translate("DNS-Server"), - translate("OPTIONAL: Use non-default DNS-Server to detect 'Registered IP'.") .. "
                          " .. - translate("Format: IP or FQDN")) - dns.placeholder = "mydns.lan" - function dns.validate(self, value) - -- if .datatype is set, then it is checked before calling this function - if not value or (#value == 0) then - return "" -- ignore on empty - elseif not DDNS.has_dnsserver then - return nil, err_tab_adv(self) .. translate("Specifying a DNS-Server is not supported") - elseif not DTYP.host(value) then - return nil, err_tab_adv(self) .. translate("use hostname, FQDN, IPv4- or IPv6-Address") - else - local ipv6 = usev6:formvalue(section) or "0" - local force = fipv:formvalue(section) or "0" - local command = CTRL.luci_helper .. [[ -]] - if (ipv6 == 1) then command = command .. [[6]] end - if (force == 1) then command = command .. [[f]] end - command = command .. [[d ]] .. value .. [[ -- verify_dns]] - - local ret = SYS.call(command) - if ret == 0 then return value -- everything OK - elseif ret == 2 then return nil, err_tab_adv(self) .. translate("nslookup can not resolve host") - elseif ret == 3 then return nil, err_tab_adv(self) .. translate("nc (netcat) can not connect") - elseif ret == 4 then return nil, err_tab_adv(self) .. translate("Forced IP Version don't matched") - else return nil, err_tab_adv(self) .. translate("unspecific error") - end - end - end - function dns.parse(self, section, novld) - DDNS.value_parse(self, section, novld) - end -end - --- IPv4 + IPv6 - force_dnstcp -- ############################################## -if DDNS.has_bindhost or ( ( m:get(section, "force_dnstcp") or "0" ) ~= "0" ) then - tcp = ns:taboption("advanced", Flag, "force_dnstcp", - translate("Force TCP on DNS") ) - tcp.orientation = "horizontal" - function tcp.cfgvalue(self, section) - local value = AbstractValue.cfgvalue(self, section) - if not DDNS.has_bindhost and value ~= "0" then - self.description = bold_on .. font_red .. - translate("DNS requests via TCP not supported") .. font_off .. "
                          " .. - translate("please disable") .. " !" .. bold_off - else - self.description = translate("OPTIONAL: Force the use of TCP instead of default UDP on DNS requests.") - end - return value - end - function tcp.validate(self, value) - if (value == "1" and DDNS.has_bindhost ) or value == "0" then - return value - end - return nil, err_tab_adv(self) .. translate("DNS requests via TCP not supported") - end -end - --- IPv4 + IPv6 - proxy -- ##################################################### --- optional Proxy to use for http/https requests [user:password@]proxyhost[:port] -if DDNS.has_proxy or ( ( m:get(section, "proxy") or "" ) ~= "" ) then - pxy = ns:taboption("advanced", Value, "proxy", - translate("PROXY-Server") ) - pxy.placeholder="user:password@myproxy.lan:8080" - function pxy.cfgvalue(self, section) - local value = AbstractValue.cfgvalue(self, section) - if not DDNS.has_proxy and value ~= "" then - self.description = bold_on .. font_red .. - translate("PROXY-Server not supported") .. font_off .. "
                          " .. - translate("please remove entry") .. "!" .. bold_off - else - self.description = translate("OPTIONAL: Proxy-Server for detection and updates.") .. "
                          " .. - translate("Format") .. ": " .. bold_on .. "[user:password@]proxyhost:port" .. bold_off .. "
                          " .. - translate("IPv6 address must be given in square brackets") .. ": " .. - bold_on .. " [2001:db8::1]:8080" .. bold_off - end - return value - end - function pxy.validate(self, value) - -- if .datatype is set, then it is checked before calling this function - if not value or (#value == 0) then - return "" -- ignore on empty - elseif DDNS.has_proxy then - local ipv6 = usev6:formvalue(section) or "0" - local force = fipv:formvalue(section) or "0" - local command = CRTL.luci_helper .. [[ -]] - if (ipv6 == 1) then command = command .. [[6]] end - if (force == 1) then command = command .. [[f]] end - command = command .. [[p ]] .. value .. [[ -- verify_proxy]] - local ret = SYS.call(command) - if ret == 0 then return value - elseif ret == 2 then return nil, err_tab_adv(self) .. translate("nslookup can not resolve host") - elseif ret == 3 then return nil, err_tab_adv(self) .. translate("nc (netcat) can not connect") - elseif ret == 4 then return nil, err_tab_adv(self) .. translate("Forced IP Version don't matched") - elseif ret == 5 then return nil, err_tab_adv(self) .. translate("proxy port missing") - else return nil, err_tab_adv(self) .. translate("unspecific error") - end - else - return nil, err_tab_adv(self) .. translate("PROXY-Server not supported") - end - end - function pxy.parse(self, section, novld) - DDNS.value_parse(self, section, novld) - end -end - --- use_syslog -- ############################################################## -slog = ns:taboption("advanced", ListValue, "use_syslog", - translate("Log to syslog"), - translate("Writes log messages to syslog. Critical Errors will always be written to syslog.") ) -slog.default = "2" -slog:value("0", translate("No logging")) -slog:value("1", translate("Info")) -slog:value("2", translate("Notice")) -slog:value("3", translate("Warning")) -slog:value("4", translate("Error")) -function slog.parse(self, section, novld) - DDNS.value_parse(self, section, novld) -end - --- use_logfile -- ############################################################# -logf = ns:taboption("advanced", Flag, "use_logfile", - translate("Log to file"), - translate("Writes detailed messages to log file. File will be truncated automatically.") .. "
                          " .. - translate("File") .. [[: "]] .. logdir .. [[/]] .. section .. [[.log"]] ) -logf.orientation = "horizontal" -logf.default = "1" -- if not defined write to log by default - --- TAB: Timer #################################################################################### --- check_interval -- ########################################################## -ci = ns:taboption("timer", Value, "check_interval", - translate("Check Interval") ) -ci.template = "ddns/detail_value" -ci.default = "10" -function ci.validate(self, value) - if not DTYP.uinteger(value) - or tonumber(value) < 1 then - return nil, err_tab_timer(self) .. translate("minimum value 5 minutes == 300 seconds") - end - - local secs = DDNS.calc_seconds(value, cu:formvalue(section)) - if secs >= 300 then - return value - else - return nil, err_tab_timer(self) .. translate("minimum value 5 minutes == 300 seconds") - end -end -function ci.write(self, section, value) - -- remove when default - local secs = DDNS.calc_seconds(value, cu:formvalue(section)) - if secs ~= 600 then --default 10 minutes - return self.map:set(section, self.option, value) - else - self.map:del(section, "check_unit") - return self.map:del(section, self.option) - end -end -function ci.parse(self, section, novld) - DDNS.value_parse(self, section, novld) -end - --- check_unit -- ############################################################## -cu = ns:taboption("timer", ListValue, "check_unit", "not displayed, but needed otherwise error", - translate("Interval to check for changed IP" .. "
                          " .. - "Values below 5 minutes == 300 seconds are not supported") ) -cu.template = "ddns/detail_lvalue" -cu.default = "minutes" -cu:value("seconds", translate("seconds")) -cu:value("minutes", translate("minutes")) -cu:value("hours", translate("hours")) ---cu:value("days", translate("days")) -function cu.write(self, section, value) - -- remove when default - local secs = DDNS.calc_seconds(ci:formvalue(section), value) - if secs ~= 600 then --default 10 minutes - return self.map:set(section, self.option, value) - else - return true - end -end -function cu.parse(self, section, novld) - DDNS.value_parse(self, section, novld) -end - --- force_interval (modified) -- ############################################### -fi = ns:taboption("timer", Value, "force_interval", - translate("Force Interval") ) -fi.template = "ddns/detail_value" -fi.default = "72" -- see dynamic_dns_updater.sh script ---fi.rmempty = false -- validate ourselves for translatable error messages -function fi.validate(self, value) - if not DTYP.uinteger(value) - or tonumber(value) < 0 then - return nil, err_tab_timer(self) .. translate("minimum value '0'") - end - - local force_s = DDNS.calc_seconds(value, fu:formvalue(section)) - if force_s == 0 then - return value - end - - local ci_value = ci:formvalue(section) - if not DTYP.uinteger(ci_value) then - return "" -- ignore because error in check_interval above - end - - local check_s = DDNS.calc_seconds(ci_value, cu:formvalue(section)) - if force_s >= check_s then - return value - end - - return nil, err_tab_timer(self) .. translate("must be greater or equal 'Check Interval'") -end -function fi.write(self, section, value) - -- simulate rmempty=true remove default - local secs = DDNS.calc_seconds(value, fu:formvalue(section)) - if secs ~= 259200 then --default 72 hours == 3 days - return self.map:set(section, self.option, value) - else - self.map:del(section, "force_unit") - return self.map:del(section, self.option) - end -end -function fi.parse(self, section, novld) - DDNS.value_parse(self, section, novld) -end - --- force_unit -- ############################################################## -fu = ns:taboption("timer", ListValue, "force_unit", "not displayed, but needed otherwise error", - translate("Interval to force updates send to DDNS Provider" .. "
                          " .. - "Setting this parameter to 0 will force the script to only run once" .. "
                          " .. - "Values lower 'Check Interval' except '0' are not supported") ) -fu.template = "ddns/detail_lvalue" -fu.default = "hours" ---fu.rmempty = false -- want to control write process ---fu:value("seconds", translate("seconds")) -fu:value("minutes", translate("minutes")) -fu:value("hours", translate("hours")) -fu:value("days", translate("days")) -function fu.write(self, section, value) - -- simulate rmempty=true remove default - local secs = DDNS.calc_seconds(fi:formvalue(section), value) - if secs ~= 259200 and secs ~= 0 then --default 72 hours == 3 days - return self.map:set(section, self.option, value) - else - return true - end -end -function fu.parse(self, section, novld) - DDNS.value_parse(self, section, novld) -end - --- retry_count -- ############################################################# -rc = ns:taboption("timer", Value, "retry_count") -rc.title = translate("Error Retry Counter") -rc.description = translate("On Error the script will stop execution after given number of retrys") - .. "
                          " - .. translate("The default setting of '0' will retry infinite.") -rc.default = "0" -function rc.validate(self, value) - if not DTYP.uinteger(value) then - return nil, err_tab_timer(self) .. translate("minimum value '0'") - else - return value - end -end -function rc.parse(self, section, novld) - DDNS.value_parse(self, section, novld) -end - --- retry_interval -- ########################################################## -ri = ns:taboption("timer", Value, "retry_interval", - translate("Error Retry Interval") ) -ri.template = "ddns/detail_value" -ri.default = "60" -function ri.validate(self, value) - if not DTYP.uinteger(value) - or tonumber(value) < 1 then - return nil, err_tab_timer(self) .. translate("minimum value '1'") - else - return value - end -end -function ri.write(self, section, value) - -- simulate rmempty=true remove default - local secs = DDNS.calc_seconds(value, ru:formvalue(section)) - if secs ~= 60 then --default 60seconds - return self.map:set(section, self.option, value) - else - self.map:del(section, "retry_unit") - return self.map:del(section, self.option) - end -end -function ri.parse(self, section, novld) - DDNS.value_parse(self, section, novld) -end - --- retry_unit -- ############################################################## -ru = ns:taboption("timer", ListValue, "retry_unit", "not displayed, but needed otherwise error", - translate("On Error the script will retry the failed action after given time") ) -ru.template = "ddns/detail_lvalue" -ru.default = "seconds" ---ru.rmempty = false -- want to control write process -ru:value("seconds", translate("seconds")) -ru:value("minutes", translate("minutes")) ---ru:value("hours", translate("hours")) ---ru:value("days", translate("days")) -function ru.write(self, section, value) - -- simulate rmempty=true remove default - local secs = DDNS.calc_seconds(ri:formvalue(section), value) - if secs ~= 60 then --default 60seconds - return self.map:set(section, self.option, value) - else - return true -- will be deleted by retry_interval - end -end -function ru.parse(self, section, novld) - DDNS.value_parse(self, section, novld) -end - --- TAB: LogView ################################################################################## -lv = ns:taboption("logview", DummyValue, "_logview") -lv.template = "ddns/detail_logview" -lv.inputtitle = translate("Read / Reread log file") -lv.rows = 50 -function lv.cfgvalue(self, section) - local lfile=logdir .. "/" .. section .. ".log" - if NXFS.access(lfile) then - return lfile .. "\n" .. translate("Please press [Read] button") - end - return lfile .. "\n" .. translate("File not found or empty") -end - -return m diff --git a/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/model/cbi/ddns/global.lua b/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/model/cbi/ddns/global.lua deleted file mode 100644 index 9dc0857..0000000 --- a/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/model/cbi/ddns/global.lua +++ /dev/null @@ -1,121 +0,0 @@ --- Copyright 2014 Christian Schoenebeck --- Licensed to the public under the Apache License 2.0. - -local NX = require "nixio" -local NXFS = require "nixio.fs" -local DISP = require "luci.dispatcher" -local SYS = require "luci.sys" -local CTRL = require "luci.controller.ddns" -- this application's controller -local DDNS = require "luci.tools.ddns" -- ddns multiused functions - --- cbi-map definition -- ####################################################### -local m = Map("ddns") -m.title = CTRL.app_title_back() -m.description = CTRL.app_description() -m.redirect = DISP.build_url("admin", "services", "ddns") - -function m.commit_handler(self) - if self.changed then -- changes ? - local command = CTRL.luci_helper .. " -- reload" - os.execute(command) -- reload configuration - end -end - --- cbi-section definition -- ################################################### -local ns = m:section( NamedSection, "global", "ddns", - translate("Global Settings"), - translate("Configure here the details for all Dynamic DNS services including this LuCI application.") - .. [[
                          ]] - .. translate("It is NOT recommended for casual users to change settings on this page.") - .. [[
                          ]] - .. [[]] - .. translate("For detailed information about parameter settings look here.") - .. [[]] - ) - --- section might not exist -function ns.cfgvalue(self, section) - if not self.map:get(section) then - self.map:set(section, nil, self.sectiontype) - end - return self.map:get(section) -end - --- upd_privateip -- ########################################################### -local ali = ns:option(Flag, "upd_privateip") -ali.title = translate("Allow non-public IP's") -ali.description = translate("Non-public and by default blocked IP's") .. ":" - .. [[
                          IPv4: ]] - .. "0/8, 10/8, 100.64/10, 127/8, 169.254/16, 172.16/12, 192.168/16" - .. [[
                          IPv6: ]] - .. "::/32, f000::/4" -ali.default = "0" - --- ddns_dateformat -- ######################################################### -local df = ns:option(Value, "ddns_dateformat") -df.title = translate("Date format") -df.description = [[]] - .. translate("For supported codes look here") - .. [[]] -df.template = "ddns/global_value" -df.default = "%F %R" -df.date_string = "" -function df.cfgvalue(self, section) - local value = AbstractValue.cfgvalue(self, section) or self.default - local epoch = os.time() - self.date_string = DDNS.epoch2date(epoch, value) - return value -end -function df.parse(self, section, novld) - DDNS.value_parse(self, section, novld) -end - --- ddns_rundir -- ############################################################# -local rd = ns:option(Value, "ddns_rundir") -rd.title = translate("Status directory") -rd.description = translate("Directory contains PID and other status information for each running section") -rd.default = "/var/run/ddns" --- no need to validate. if empty default is used everything else created by dns-scripts -function rd.parse(self, section, novld) - DDNS.value_parse(self, section, novld) -end - --- ddns_logdir -- ############################################################# -local ld = ns:option(Value, "ddns_logdir") -ld.title = translate("Log directory") -ld.description = translate("Directory contains Log files for each running section") -ld.default = "/var/log/ddns" --- no need to validate. if empty default is used everything else created by dns-scripts -function ld.parse(self, section, novld) - DDNS.value_parse(self, section, novld) -end - --- ddns_loglines -- ########################################################### -local ll = ns:option(Value, "ddns_loglines") -ll.title = translate("Log length") -ll.description = translate("Number of last lines stored in log files") -ll.default = "250" -function ll.validate(self, value) - local n = tonumber(value) - if not n or math.floor(n) ~= n or n < 1 then - return nil, self.title .. ": " .. translate("minimum value '1'") - end - return value -end -function ll.parse(self, section, novld) - DDNS.value_parse(self, section, novld) -end - --- use_curl -- ################################################################ -if (SYS.call([[ grep -i "\+ssl" /usr/bin/wget >/dev/null 2>&1 ]]) == 0) -and NXFS.access("/usr/bin/curl") then - local pc = ns:option(Flag, "use_curl") - pc.title = translate("Use cURL") - pc.description = translate("If both cURL and GNU Wget are installed, Wget is used by default.") - .. [[
                          ]] - .. translate("To use cURL activate this option.") - pc.orientation = "horizontal" - pc.default = "0" -end - -return m diff --git a/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/model/cbi/ddns/hints.lua b/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/model/cbi/ddns/hints.lua deleted file mode 100644 index df39a3a..0000000 --- a/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/model/cbi/ddns/hints.lua +++ /dev/null @@ -1,166 +0,0 @@ --- Copyright 2014-2016 Christian Schoenebeck --- Licensed to the public under the Apache License 2.0. - -local DISP = require "luci.dispatcher" -local SYS = require "luci.sys" -local CTRL = require "luci.controller.ddns" -- this application's controller -local DDNS = require "luci.tools.ddns" -- ddns multiused functions - --- html constants -font_red = [[]] -font_off = [[]] -bold_on = [[]] -bold_off = [[]] - --- cbi-map definition -- ####################################################### -m = Map("ddns") -m.title = CTRL.app_title_back() -m.description = CTRL.app_description() -m.redirect = DISP.build_url("admin", "services", "ddns") - --- SimpleSection definition -- ################################################# --- show Hints to optimize installation and script usage -s = m:section( SimpleSection, - translate("Hints"), - translate("Below a list of configuration tips for your system to run Dynamic DNS updates without limitations") ) - --- ddns-scripts needs to be updated for full functionality -if not CTRL.service_ok() then - local so = s:option(DummyValue, "_update_needed") - so.titleref = DISP.build_url("admin", "system", "packages") - so.rawhtml = true - so.title = font_red .. bold_on .. - translate("Software update required") .. bold_off .. font_off - so.value = translate("The currently installed 'ddns-scripts' package did not support all available settings.") .. - "
                          " .. - translate("Please update to the current version!") -end - --- DDNS Service disabled -if not SYS.init.enabled("ddns") then - local se = s:option(DummyValue, "_not_enabled") - se.titleref = DISP.build_url("admin", "system", "startup") - se.rawhtml = true - se.title = bold_on .. - translate("DDNS Autostart disabled") .. bold_off - se.value = translate("Currently DDNS updates are not started at boot or on interface events." .. "
                          " .. - "This is the default if you run DDNS scripts by yourself (i.e. via cron with force_interval set to '0')" ) -end - --- No IPv6 support -if not DDNS.has_ipv6 then - local v6 = s:option(DummyValue, "_no_ipv6") - v6.titleref = 'http://www.openwrt.org" target="_blank' - v6.rawhtml = true - v6.title = bold_on .. - translate("IPv6 not supported") .. bold_off - v6.value = translate("IPv6 is currently not (fully) supported by this system" .. "
                          " .. - "Please follow the instructions on OpenWrt's homepage to enable IPv6 support" .. "
                          " .. - "or update your system to the latest OpenWrt Release") -end - --- No HTTPS support -if not DDNS.has_ssl then - local sl = s:option(DummyValue, "_no_https") - sl.titleref = DISP.build_url("admin", "system", "packages") - sl.rawhtml = true - sl.title = bold_on .. - translate("HTTPS not supported") .. bold_off - sl.value = translate("Neither GNU Wget with SSL nor cURL installed to support secure updates via HTTPS protocol.") .. - "
                          - " .. - translate("You should install 'wget' or 'curl' or 'uclient-fetch' with 'libustream-*ssl' package.") .. - "
                          - " .. - translate("In some versions cURL/libcurl in OpenWrt is compiled without proxy support.") -end - --- No bind_network -if not DDNS.has_bindnet then - local bn = s:option(DummyValue, "_no_bind_network") - bn.titleref = DISP.build_url("admin", "system", "packages") - bn.rawhtml = true - bn.title = bold_on .. - translate("Binding to a specific network not supported") .. bold_off - bn.value = translate("Neither GNU Wget with SSL nor cURL installed to select a network to use for communication.") .. - "
                          - " .. - translate("You should install 'wget' or 'curl' package.") .. - "
                          - " .. - translate("GNU Wget will use the IP of given network, cURL will use the physical interface.") .. - "
                          - " .. - translate("In some versions cURL/libcurl in OpenWrt is compiled without proxy support.") -end - --- currently only cURL possibly without proxy support -if not DDNS.has_proxy then - local px = s:option(DummyValue, "_no_proxy") - px.titleref = DISP.build_url("admin", "system", "packages") - px.rawhtml = true - px.title = bold_on .. - translate("cURL without Proxy Support") .. bold_off - px.value = translate("cURL is installed, but libcurl was compiled without proxy support.") .. - "
                          - " .. - translate("You should install 'wget' or 'uclient-fetch' package or replace libcurl.") .. - "
                          - " .. - translate("In some versions cURL/libcurl in OpenWrt is compiled without proxy support.") -end - --- "Force IP Version not supported" -if not DDNS.has_forceip then - local fi = s:option(DummyValue, "_no_force_ip") - fi.titleref = DISP.build_url("admin", "system", "packages") - fi.rawhtml = true - fi.title = bold_on .. - translate("Force IP Version not supported") .. bold_off - local value = translate("BusyBox's nslookup and Wget do not support to specify " .. - "the IP version to use for communication with DDNS Provider!") - if not (DDNS.has_wgetssl or DDNS.has_curl or DDNS.has_fetch) then - value = value .. "
                          - " .. - translate("You should install 'wget' or 'curl' or 'uclient-fetch' package.") - end - if not DDNS.has_bindhost then - value = value .. "
                          - " .. - translate("You should install 'bind-host' or 'knot-host' or 'drill' package for DNS requests.") - end - fi.value = value -end - --- "DNS requests via TCP not supported" -if not DDNS.has_bindhost then - local dt = s:option(DummyValue, "_no_dnstcp") - dt.titleref = DISP.build_url("admin", "system", "packages") - dt.rawhtml = true - dt.title = bold_on .. - translate("DNS requests via TCP not supported") .. bold_off - dt.value = translate("BusyBox's nslookup and hostip do not support to specify to use TCP " .. - "instead of default UDP when requesting DNS server!") .. - "
                          - " .. - translate("You should install 'bind-host' or 'knot-host' or 'drill' package for DNS requests.") -end - --- nslookup compiled with musl produce problems when using -if not DDNS.has_dnsserver then - local ds = s:option(DummyValue, "_no_dnsserver") - ds.titleref = DISP.build_url("admin", "system", "packages") - ds.rawhtml = true - ds.title = bold_on .. - translate("Using specific DNS Server not supported") .. bold_off - ds.value = translate("BusyBox's nslookup in the current compiled version " .. - "does not handle given DNS Servers correctly!") .. - "
                          - " .. - translate("You should install 'bind-host' or 'knot-host' or 'drill' or 'hostip' package, " .. - "if you need to specify a DNS server to detect your registered IP.") -end - --- certificates installed -if DDNS.has_ssl and not DDNS.has_cacerts then - local ca = s:option(DummyValue, "_no_certs") - ca.titleref = DISP.build_url("admin", "system", "packages") - ca.rawhtml = true - ca.title = bold_on .. - translate("No certificates found") .. bold_off - ca.value = translate("If using secure communication you should verify server certificates!") .. - "
                          - " .. - translate("Install 'ca-certificates' package or needed certificates " .. - "by hand into /etc/ssl/certs default directory") -end - -return m diff --git a/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/model/cbi/ddns/overview.lua b/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/model/cbi/ddns/overview.lua deleted file mode 100644 index 337c6e7..0000000 --- a/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/model/cbi/ddns/overview.lua +++ /dev/null @@ -1,219 +0,0 @@ --- Copyright 2014-2016 Christian Schoenebeck --- Licensed to the public under the Apache License 2.0. - -local NXFS = require "nixio.fs" -local DISP = require "luci.dispatcher" -local HTTP = require "luci.http" -local SYS = require "luci.sys" -local CTRL = require "luci.controller.ddns" -- this application's controller -local DDNS = require "luci.tools.ddns" -- ddns multiused functions - -local show_hints = not (DDNS.has_ipv6 -- IPv6 support - and DDNS.has_ssl -- HTTPS support - and DDNS.has_proxy -- Proxy support - and DDNS.has_bindhost -- DNS TCP support - and DDNS.has_forceip -- Force IP version - and DDNS.has_dnsserver -- DNS server support - and DDNS.has_bindnet -- Bind to network/interface - and DDNS.has_cacerts -- certificates installed at /etc/ssl/certs - ) -local not_enabled = not SYS.init.enabled("ddns") -local need_update = not CTRL.service_ok() - --- html constants -font_red = [[]] -font_off = [[]] -bold_on = [[]] -bold_off = [[]] - --- cbi-map definition -- ####################################################### -m = Map("ddns") -m.title = CTRL.app_title_main() -m.description = CTRL.app_description() - -m.on_after_commit = function(self) - if self.changed then -- changes ? - local command = CTRL.luci_helper - if SYS.init.enabled("ddns") then -- ddns service enabled, restart all - command = command .. " -- restart" - os.execute(command) - else -- ddns service disabled, send SIGHUP to running - command = command .. " -- reload" - os.execute(command) - end - end -end - --- SimpleSection definition -- ################################################## --- with all the JavaScripts we need for "a good Show" -a = m:section( SimpleSection ) -a.template = "ddns/overview_status" - --- SimpleSection definition -- ################################################# --- show Hints to optimize installation and script usage -if not_enabled then - - s = m:section( SimpleSection, translate("Hints") ) - - -- DDNS Service disabled - if not_enabled then - local dv = s:option(DummyValue, "_not_enabled") - dv.titleref = DISP.build_url("admin", "system", "startup") - dv.rawhtml = true - dv.title = bold_on .. - translate("DDNS Autostart disabled") .. bold_off - dv.value = translate("Currently DDNS updates are not started at boot or on interface events." .. "
                          " .. - "You can start/stop each configuration here. It will run until next reboot.") - end - -end - -local_web="

                           

                           

                          " - --- TableSection definition -- ################################################## -ts = m:section( TypedSection, "service", - translate("Overview"), - translate("Below is a list of DDNS configurations and their current state.") - .. "
                          " - .. "
                          " .. local_web ) -ts.sectionhead = translate("Configuration") -ts.template = "cbi/tblsection" -ts.addremove = true -ts.extedit = DISP.build_url("admin", "services", "ddns", "detail", "%s") -function ts.create(self, name) - AbstractSection.create(self, name) - HTTP.redirect( self.extedit:format(name) ) -end - --- Lookup_Host and registered IP -- ################################################# -dom = ts:option(DummyValue, "_lookupIP", - translate("Lookup Hostname") .. "
                          " .. translate("Registered IP") ) -dom.template = "ddns/overview_doubleline" -function dom.set_one(self, section) - local lookup = self.map:get(section, "lookup_host") or "" - if lookup ~= "" then - return lookup - else - return [[]] .. translate("config error") .. [[]] - end -end -function dom.set_two(self, section) - local lookup_host = self.map:get(section, "lookup_host") or "" - if lookup_host == "" then return "" end - local dnsserver = self.map:get(section, "dnsserver") or "" - local use_ipv6 = tonumber(self.map:get(section, "use_ipv6") or 0) - local force_ipversion = tonumber(self.map:get(section, "force_ipversion") or 0) - local force_dnstcp = tonumber(self.map:get(section, "force_dnstcp") or 0) - local is_glue = tonumber(self.map:get(section, "is_glue") or 0) - local command = CTRL.luci_helper .. [[ -]] - if (use_ipv6 == 1) then command = command .. [[6]] end - if (force_ipversion == 1) then command = command .. [[f]] end - if (force_dnstcp == 1) then command = command .. [[t]] end - if (is_glue == 1) then command = command .. [[g]] end - command = command .. [[l ]] .. lookup_host - if (#dnsserver > 0) then command = command .. [[ -d ]] .. dnsserver end - command = command .. [[ -- get_registered_ip]] - local ip = SYS.exec(command) - if ip == "" then ip = translate("no data") end - return ip -end - --- enabled -ena = ts:option( Flag, "enabled", - translate("Enabled")) -ena.template = "ddns/overview_enabled" -ena.rmempty = false - --- show PID and next update -upd = ts:option( DummyValue, "_update", - translate("Last Update") .. "
                          " .. translate("Next Update")) -upd.template = "ddns/overview_doubleline" -function upd.set_one(self, section) -- fill Last Update - -- get/validate last update - local uptime = SYS.uptime() - local lasttime = DDNS.get_lastupd(section) - if lasttime > uptime then -- /var might not be linked to /tmp and cleared on reboot - lasttime = 0 - end - - -- no last update happen - if lasttime == 0 then - return translate("never") - - -- we read last update - else - -- calc last update - -- os.epoch - sys.uptime + lastupdate(uptime) - local epoch = os.time() - uptime + lasttime - -- use linux date to convert epoch - return DDNS.epoch2date(epoch) - end -end -function upd.set_two(self, section) -- fill Next Update - -- get enabled state - local enabled = tonumber(self.map:get(section, "enabled") or 0) - local datenext = translate("unknown error") -- formatted date of next update - - -- get force seconds - local force_interval = tonumber(self.map:get(section, "force_interval") or 72) - local force_unit = self.map:get(section, "force_unit") or "hours" - local force_seconds = DDNS.calc_seconds(force_interval, force_unit) - - -- get last update and get/validate PID - local uptime = SYS.uptime() - local lasttime = DDNS.get_lastupd(section) - if lasttime > uptime then -- /var might not be linked to /tmp and cleared on reboot - lasttime = 0 - end - local pid = DDNS.get_pid(section) - - -- calc next update - if lasttime > 0 then - local epoch = os.time() - uptime + lasttime + force_seconds - -- use linux date to convert epoch - datelast = DDNS.epoch2date(epoch) - end - - -- process running but update needs to happen - if pid > 0 and ( lasttime + force_seconds - uptime ) < 0 then - datenext = translate("Verify") - - -- run once - elseif force_seconds == 0 then - datenext = translate("Run once") - - -- no process running and NOT enabled - elseif pid == 0 and enabled == 0 then - datenext = translate("Disabled") - - -- no process running and NOT - elseif pid == 0 and enabled ~= 0 then - datenext = translate("Stopped") - end - - return datenext -end - --- start/stop button -btn = ts:option( Button, "_startstop", - translate("Process ID") .. "
                          " .. translate("Start / Stop") ) -btn.template = "ddns/overview_startstop" -function btn.cfgvalue(self, section) - local pid = DDNS.get_pid(section) - if pid > 0 then - btn.inputtitle = "PID: " .. pid - btn.inputstyle = "reset" - btn.disabled = false - elseif (self.map:get(section, "enabled") or "0") ~= "0" then - btn.inputtitle = translate("Start") - btn.inputstyle = "apply" - btn.disabled = false - else - btn.inputtitle = "----------" - btn.inputstyle = "button" - btn.disabled = true - end - return true -end - -return m diff --git a/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/tools/ddns.lua b/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/tools/ddns.lua deleted file mode 100644 index 209d9c3..0000000 --- a/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/tools/ddns.lua +++ /dev/null @@ -1,315 +0,0 @@ --- Copyright 2014-2016 Christian Schoenebeck --- Licensed to the public under the Apache License 2.0. - -module("luci.tools.ddns", package.seeall) - -local NX = require "nixio" -local NXFS = require "nixio.fs" -local OPKG = require "luci.model.ipkg" -local UCI = require "luci.model.uci" -local SYS = require "luci.sys" -local UTIL = require "luci.util" - -local function _check_certs() - local _, v = NXFS.glob("/etc/ssl/certs/*.crt") - if ( v == 0 ) then _, v = NXFS.glob("/etc/ssl/certs/*.pem") end - return (v > 0) -end - -has_wgetssl = (SYS.call( [[which wget-ssl >/dev/null 2>&1]] ) == 0) -- and true or nil -has_curl = (SYS.call( [[which curl >/dev/null 2>&1]] ) == 0) -has_curlssl = (SYS.call( [[$(which curl) -V 2>&1 | grep "Protocols:" | grep -qF "https"]] ) ~= 0) -has_curlpxy = (SYS.call( [[grep -i "all_proxy" /usr/lib/libcurl.so* >/dev/null 2>&1]] ) == 0) -has_fetch = (SYS.call( [[which uclient-fetch >/dev/null 2>&1]] ) == 0) -has_fetchssl = NXFS.access("/lib/libustream-ssl.so") -has_bbwget = (SYS.call( [[$(which wget) -V 2>&1 | grep -iqF "busybox"]] ) == 0) -has_bindhost = (SYS.call( [[which host >/dev/null 2>&1]] ) == 0) - or (SYS.call( [[which khost >/dev/null 2>&1]] ) == 0) - or (SYS.call( [[which drill >/dev/null 2>&1]] ) == 0) -has_hostip = (SYS.call( [[which hostip >/dev/null 2>&1]] ) == 0) -has_nslookup = (SYS.call( [[$(which nslookup) localhost 2>&1 | grep -qF "(null)"]] ) ~= 0) -has_ipv6 = (NXFS.access("/proc/net/ipv6_route") and NXFS.access("/usr/sbin/ip6tables")) -has_ssl = (has_wgetssl or has_curlssl or (has_fetch and has_fetchssl)) -has_proxy = (has_wgetssl or has_curlpxy or has_fetch or has_bbwget) -has_forceip = (has_wgetssl or has_curl or has_fetch) -- only really needed for transfer -has_dnsserver = (has_bindhost or has_hostip or has_nslookup) -has_bindnet = (has_wgetssl or has_curl) -has_cacerts = _check_certs() - --- function to calculate seconds from given interval and unit -function calc_seconds(interval, unit) - if not tonumber(interval) then - return nil - elseif unit == "days" then - return (tonumber(interval) * 86400) -- 60 sec * 60 min * 24 h - elseif unit == "hours" then - return (tonumber(interval) * 3600) -- 60 sec * 60 min - elseif unit == "minutes" then - return (tonumber(interval) * 60) -- 60 sec - elseif unit == "seconds" then - return tonumber(interval) - else - return nil - end -end - --- convert epoch date to given format -function epoch2date(epoch, format) - if not format or #format < 2 then - local uci = UCI.cursor() - format = uci:get("ddns", "global", "ddns_dateformat") or "%F %R" - uci:unload("ddns") - end - format = format:gsub("%%n", "
                          ") -- replace newline - format = format:gsub("%%t", " ") -- replace tab - return os.date(format, epoch) -end - --- read lastupdate from [section].update file -function get_lastupd(section) - local uci = UCI.cursor() - local rdir = uci:get("ddns", "global", "ddns_rundir") or "/var/run/ddns" - local etime = tonumber(NXFS.readfile("%s/%s.update" % { rdir, section } ) or 0 ) - uci:unload("ddns") - return etime -end - --- read PID from run file and verify if still running -function get_pid(section) - local uci = UCI.cursor() - local rdir = uci:get("ddns", "global", "ddns_rundir") or "/var/run/ddns" - local pid = tonumber(NXFS.readfile("%s/%s.pid" % { rdir, section } ) or 0 ) - if pid > 0 and not NX.kill(pid, 0) then - pid = 0 - end - uci:unload("ddns") - return pid -end - --- replacement of build-in read of UCI option --- modified AbstractValue.cfgvalue(self, section) from cbi.lua --- needed to read from other option then current value definition -function read_value(self, section, option) - local value - if self.tag_error[section] then - value = self:formvalue(section) - else - value = self.map:get(section, option) - end - - if not value then - return nil - elseif not self.cast or self.cast == type(value) then - return value - elseif self.cast == "string" then - if type(value) == "table" then - return value[1] - end - elseif self.cast == "table" then - return { value } - end -end - --- replacement of build-in parse of "Value" --- modified AbstractValue.parse(self, section, novld) from cbi.lua --- validate is called if rmempty/optional true or false --- before write check if forcewrite, value eq default, and more -function value_parse(self, section, novld) - local fvalue = self:formvalue(section) - local fexist = ( fvalue and (#fvalue > 0) ) -- not "nil" and "not empty" - local cvalue = self:cfgvalue(section) - local rm_opt = ( self.rmempty or self.optional ) - local eq_cfg -- flag: equal cfgvalue - - -- If favlue and cvalue are both tables and have the same content - -- make them identical - if type(fvalue) == "table" and type(cvalue) == "table" then - eq_cfg = (#fvalue == #cvalue) - if eq_cfg then - for i=1, #fvalue do - if cvalue[i] ~= fvalue[i] then - eq_cfg = false - end - end - end - if eq_cfg then - fvalue = cvalue - end - end - - -- removed parameter "section" from function call because used/accepted nowhere - -- also removed call to function "transfer" - local vvalue, errtxt = self:validate(fvalue) - - -- error handling; validate return "nil" - if not vvalue then - if novld then -- and "novld" set - return -- then exit without raising an error - end - - if fexist then -- and there is a formvalue - self:add_error(section, "invalid", errtxt or self.title .. ": invalid") - return -- so data are invalid - elseif not rm_opt then -- and empty formvalue but NOT (rmempty or optional) set - self:add_error(section, "missing", errtxt or self.title .. ": missing") - return -- so data is missing - elseif errtxt then - self:add_error(section, "invalid", errtxt) - return - end --- error ("\n option: " .. self.option .. --- "\n fvalue: " .. tostring(fvalue) .. --- "\n fexist: " .. tostring(fexist) .. --- "\n cvalue: " .. tostring(cvalue) .. --- "\n vvalue: " .. tostring(vvalue) .. --- "\n vexist: " .. tostring(vexist) .. --- "\n rm_opt: " .. tostring(rm_opt) .. --- "\n eq_cfg: " .. tostring(eq_cfg) .. --- "\n eq_def: " .. tostring(eq_def) .. --- "\n novld : " .. tostring(novld) .. --- "\n errtxt: " .. tostring(errtxt) ) - end - - -- lets continue with value returned from validate - eq_cfg = ( vvalue == cvalue ) -- update equal_config flag - local vexist = ( vvalue and (#vvalue > 0) ) and true or false -- not "nil" and "not empty" - local eq_def = ( vvalue == self.default ) -- equal_default flag - - -- (rmempty or optional) and (no data or equal_default) - if rm_opt and (not vexist or eq_def) then - if self:remove(section) then -- remove data from UCI - self.section.changed = true -- and push events - end - return - end - - -- not forcewrite and no changes, so nothing to write - if not self.forcewrite and eq_cfg then - return - end - - -- we should have a valid value here - assert (vvalue, "\n option: " .. self.option .. - "\n fvalue: " .. tostring(fvalue) .. - "\n fexist: " .. tostring(fexist) .. - "\n cvalue: " .. tostring(cvalue) .. - "\n vvalue: " .. tostring(vvalue) .. - "\n vexist: " .. tostring(vexist) .. - "\n rm_opt: " .. tostring(rm_opt) .. - "\n eq_cfg: " .. tostring(eq_cfg) .. - "\n eq_def: " .. tostring(eq_def) .. - "\n errtxt: " .. tostring(errtxt) ) - - -- write data to UCI; raise event only on changes - if self:write(section, vvalue) and not eq_cfg then - self.section.changed = true - end -end - ------------------------------------------------------------------------------ --- copied from https://svn.nmap.org/nmap/nselib/url.lua --- @author Diego Nehab --- @author Eddie Bell ---[[ - URI parsing, composition and relative URL resolution - LuaSocket toolkit. - Author: Diego Nehab - RCS ID: $Id: url.lua,v 1.37 2005/11/22 08:33:29 diego Exp $ - parse_query and build_query added For nmap (Eddie Bell ) -]]-- ---- --- Parses a URL and returns a table with all its parts according to RFC 2396. --- --- The following grammar describes the names given to the URL parts. --- --- ::= :///;?# --- ::= @: --- ::= [:] --- :: = {/} --- --- --- The leading / in / is considered part of --- . --- @param url URL of request. --- @param default Table with default values for each field. --- @return A table with the following fields, where RFC naming conventions have --- been preserved: --- scheme, authority, userinfo, --- user, password, host, --- port, path, params, --- query, and fragment. ------------------------------------------------------------------------------ -function parse_url(url) --, default) - -- initialize default parameters - local parsed = {} --- for i,v in base.pairs(default or parsed) do --- parsed[i] = v --- end - - -- remove whitespace --- url = string.gsub(url, "%s", "") - -- get fragment - url = string.gsub(url, "#(.*)$", - function(f) - parsed.fragment = f - return "" - end) - -- get scheme. Lower-case according to RFC 3986 section 3.1. - url = string.gsub(url, "^([%w][%w%+%-%.]*)%:", - function(s) - parsed.scheme = string.lower(s); - return "" - end) - -- get authority - url = string.gsub(url, "^//([^/]*)", - function(n) - parsed.authority = n - return "" - end) - -- get query stringing - url = string.gsub(url, "%?(.*)", - function(q) - parsed.query = q - return "" - end) - -- get params - url = string.gsub(url, "%;(.*)", - function(p) - parsed.params = p - return "" - end) - -- path is whatever was left - parsed.path = url - - local authority = parsed.authority - if not authority then - return parsed - end - authority = string.gsub(authority,"^([^@]*)@", - function(u) - parsed.userinfo = u; - return "" - end) - authority = string.gsub(authority, ":([0-9]*)$", - function(p) - if p ~= "" then - parsed.port = p - end; - return "" - end) - if authority ~= "" then - parsed.host = authority - end - - local userinfo = parsed.userinfo - if not userinfo then - return parsed - end - userinfo = string.gsub(userinfo, ":([^:]*)$", - function(p) - parsed.password = p; - return "" - end) - parsed.user = userinfo - return parsed -end diff --git a/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/view/admin_status/index/ddns.htm b/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/view/admin_status/index/ddns.htm deleted file mode 100644 index 9791065..0000000 --- a/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/view/admin_status/index/ddns.htm +++ /dev/null @@ -1 +0,0 @@ -<%+ddns/system_status%> diff --git a/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/view/ddns/detail_logview.htm b/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/view/ddns/detail_logview.htm deleted file mode 100644 index fd1d5be..0000000 --- a/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/view/ddns/detail_logview.htm +++ /dev/null @@ -1,56 +0,0 @@ - - - - -<%+cbi/valueheader%> - -
                          - -<% --- one button on top, one at the buttom -%> - /> - -

                          - -<% --- set a readable style taken from openwrt theme for textarea#syslog --- in openwrt theme there are problems with a width of 100 so we check for theme and set to lower value -%> - -

                          - -<% --- one button on top, one at the buttom -%> - /> - -<%+cbi/valuefooter%> - diff --git a/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/view/ddns/detail_lvalue.htm b/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/view/ddns/detail_lvalue.htm deleted file mode 100644 index b69d780..0000000 --- a/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/view/ddns/detail_lvalue.htm +++ /dev/null @@ -1,23 +0,0 @@ - - - -  -<% if self.widget == "select" then %> - -<% elseif self.widget == "radio" then - local c = 0 - for i, key in pairs(self.keylist) do - c = c + 1 -%> - /> - > - ><%=self.vallist[i]%> -<% if c == self.size then c = 0 %><% if self.orientation == "horizontal" then %> <% else %>
                          <% end %> -<% end end %> -<% end %> -<%+cbi/valuefooter%> - diff --git a/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/view/ddns/detail_value.htm b/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/view/ddns/detail_value.htm deleted file mode 100644 index cbe76ab..0000000 --- a/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/view/ddns/detail_value.htm +++ /dev/null @@ -1,9 +0,0 @@ - - -<%+cbi/valueheader%> - /> - - diff --git a/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/view/ddns/global_value.htm b/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/view/ddns/global_value.htm deleted file mode 100644 index 23ec059..0000000 --- a/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/view/ddns/global_value.htm +++ /dev/null @@ -1,34 +0,0 @@ - - -<%+cbi/valueheader%> - - - -/> -
                          -
                          - <%:help%><%=self.description%> -
                          - <%:Current setting%>: <%=self.date_string%> -
                          -
                          - - diff --git a/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/view/ddns/overview_doubleline.htm b/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/view/ddns/overview_doubleline.htm deleted file mode 100644 index 1d1b4be..0000000 --- a/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/view/ddns/overview_doubleline.htm +++ /dev/null @@ -1,10 +0,0 @@ - - -<%+cbi/valueheader%> - -<%=self:set_one(section)%> -
                          -<%=self:set_two(section)%> - -<%+cbi/valuefooter%> - diff --git a/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/view/ddns/overview_enabled.htm b/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/view/ddns/overview_enabled.htm deleted file mode 100644 index 2efc125..0000000 --- a/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/view/ddns/overview_enabled.htm +++ /dev/null @@ -1,16 +0,0 @@ - - -<%+cbi/valueheader%> - - /> - - /> -> - -<%+cbi/valuefooter%> - diff --git a/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/view/ddns/overview_startstop.htm b/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/view/ddns/overview_startstop.htm deleted file mode 100644 index 327028c..0000000 --- a/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/view/ddns/overview_startstop.htm +++ /dev/null @@ -1,17 +0,0 @@ - - -<%+cbi/valueheader%> - -<% if self:cfgvalue(section) ~= false then --- We need to garantie that function cfgvalue run first to set missing parameters -%> - - - " style="font-size: 100%;" type="button" onclick="onclick_startstop(this.id)" - <%= - attr("name", section) .. attr("id", cbid) .. attr("value", self.inputtitle) .. ifattr(self.disabled, "disabled") - %> /> -<% end %> - -<%+cbi/valuefooter%> - diff --git a/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/view/ddns/overview_status.htm b/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/view/ddns/overview_status.htm deleted file mode 100644 index b409ed0..0000000 --- a/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/view/ddns/overview_status.htm +++ /dev/null @@ -1,180 +0,0 @@ - - - - - - diff --git a/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/view/ddns/system_status.htm b/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/view/ddns/system_status.htm deleted file mode 100644 index 5bdcb03..0000000 --- a/rooter/0optionalapps/luci-app-rooterddns/files/usr/lib/lua/luci/view/ddns/system_status.htm +++ /dev/null @@ -1,144 +0,0 @@ - - - - -
                          - <%:Dynamic DNS%> - - - - - - - - - - - - -
                          <%:Configuration%><%:Next Update%><%:Lookup Hostname%><%:Registered IP%><%:Network%>

                          <%:Collecting data...%>
                          -
                          - diff --git a/rooter/0optionalapps/luci-app-rootervpn/Makefile b/rooter/0optionalapps/luci-app-rootervpn/Makefile deleted file mode 100644 index 46f6d81..0000000 --- a/rooter/0optionalapps/luci-app-rootervpn/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -#Owned by DairyMan@Whirlpool -# -#Copyright GNU act. -include $(TOPDIR)/rules.mk - -PKG_NAME:=luci-app-rootervpn -PKG_VERSION:=1.000 -PKG_RELEASE:=1 - -PKG_MAINTAINER:=Created by DM/makefile by Cobia@whirlpool -include $(INCLUDE_DIR)/package.mk - -define Package/luci-app-rootervpn - SECTION:=luci - CATEGORY:=LuCI - DEPENDS:=+openvpn-easy-rsa +openvpn-openssl +eoip - SUBMENU:=3. Applications - TITLE:=support for modified OpenVPN - PKGARCH:=all -endef - -define Package/luci-app-rootervpn/description - Helper scripts to enable OpenVPN support -endef - - -define Build/Compile -endef - -define Package/luci-app-rootervpn/install - $(CP) ./files/* $(1)/ -endef - -$(eval $(call BuildPackage,luci-app-rootervpn)) diff --git a/rooter/0optionalapps/luci-app-rootervpn/files/etc/config/openvpn_recipes b/rooter/0optionalapps/luci-app-rootervpn/files/etc/config/openvpn_recipes deleted file mode 100644 index 68b6274..0000000 --- a/rooter/0optionalapps/luci-app-rootervpn/files/etc/config/openvpn_recipes +++ /dev/null @@ -1,293 +0,0 @@ -# -# Routed point-to-point server -# -config openvpn_recipe b_server_tun_ptp - option _description "Basic point-to-point TUN VPN Server" - option _role "server" - option dev "tun-server" - option ifconfig "10.0.0.1 10.0.0.2" - option secret "shared-secret.key" - option keepalive "10 60" - option comp_lzo "yes" - option verb "3" - option mssfix "1420" - option topology "p2p" - -# -# Routed point-to-point client -# -config openvpn_recipe b_client_tun_ptp - option _description "Basic point-to-point TUN VPN Client" - option _role "client" - option client "1" - option dev "tun0" - list remote "vpnserver.example.org" - option ifconfig "10.0.0.2 10.0.0.1" - option secret "shared-secret.key" - option nobind "1" - option comp_lzo "yes" - option verb "3" - -# -# Routed multi-client server -# -config openvpn_recipe a_server_tun - option _description "Basic TUN VPN Server" - option _role "server" - option dev "tun-server" - option topology "subnet" - option port "1194" - option proto "udp" - option server "10.0.100.0 255.255.255.0" - option ca "/etc/openvpn/placeholder/placeholder.file" - option cert "/etc/openvpn/placeholder/placeholder.file" - option key "/etc/openvpn/placeholder/placeholder.file" - option dh "/etc/openvpn/placeholder/placeholder.file" - option keepalive "10 60" - option comp_lzo "yes" - option verb "3" - option mssfix "1420" - -# -# Routed client -# -config openvpn_recipe a_client_tun - option _description "Basic TUN VPN Client" - option _role "client" - option client "1" - option dev "tun0" - option proto "udp" - list remote "vpnserver.example.org" - option remote_cert_tls "server" - option comp_lzo "yes" - option nobind "1" - option persist_key "1" - option persist_tun "1" - option verb "3" - option reneg_sec "0" - option float "1" - option auth_user_pass "/etc/openvpn/placeholder/placeholder.file" - option ca "/etc/openvpn/placeholder/placeholder.file" - option cert "/etc/openvpn/placeholder/placeholder.file" - option key "/etc/openvpn/placeholder/placeholder.file" - -# -# Multi-client ethernet bridge server -# -config openvpn_recipe c_server_tap_bridge - option _description "Basic Server-Bridge TAP VPN Server" - option _role "server" - option dev "tap-server" - option port "1194" - option server_bridge "192.168.100.1 255.255.255.0 192.168.100.128 192.168.100.254" - option ca "/etc/openvpn/placeholder/placeholder.file" - option cert "/etc/openvpn/placeholder/placeholder.file" - option key "/etc/openvpn/placeholder/placeholder.file" - option dh "/etc/openvpn/placeholder/placeholder.file" - option keepalive "10 60" - option comp_lzo "yes" - option verb "3" - option mssfix "1420" - -# -# Ethernet bridge client -# -config openvpn_recipe c_client_tap_bridge - option _description "Basic Server-Bridge TAP VPN Client" - option _role "client" - option client "1" - option dev "tap0" - list remote "vpnserver.example.org" - option auth_user_pass "/etc/openvpn/placeholder/placeholder.file" - option ca "/etc/openvpn/placeholder/placeholder.file" - option cert "/etc/openvpn/placeholder/placeholder.file" - option key "/etc/openvpn/placeholder/placeholder.file" - option remote_cert_tls "server" - option comp_lzo "yes" - option nobind "1" - option persist_key "1" - option verb "3" - option reneg_sec "0" - option float "1" - -# -# OVPN Client -# -config openvpn_recipe d_ovpn_client - option _description "Client using OVPN File" - option _role "client" - option config "/etc/openvpn/placeholder/placeholder.file" - option auth_user_pass "/etc/openvpn/placeholder/placeholder.file" - -# -# NordVpn -# -config openvpn_recipe e_nordvpn_client_tun - option _description "Predefined Client for NordVPN" - option _role "client" - option config "/etc/openvpn/placeholder/placeholder.file" - option auth_user_pass "/etc/openvpn/placeholder/placeholder.file" - -# -# Private Internet Access Client -# -config openvpn_recipe e_pia_client_tun - option _description "Predefined Client for Private Internet Access" - option _role "client" - option client "1" - option dev "tun0" - option proto "udp" - list remote "us-example.privateinternetaccess.com" - option port "1198" - option resolv_retry "infinite" - option nobind "1" - option persist_key "1" - option persist_tun "1" - option cipher "aes-128-cbc" - option auth "sha1" - option tls_client "1" - option remote_cert_tls "server" - option auth_user_pass "/etc/openvpn/placeholder/placeholder.file" - option comp_lzo "yes" - option verb "1" - option reneg_sec "0" - option crl_verify "/etc/openvpn/pia/crl.rsa.2048.pem" - option ca "/etc/openvpn/pia/ca.rsa.2048.crt" - option disable_occ "1" - -# -# Windscribe -# -config openvpn_recipe e_windscribe_client_tun - option _description "Predefined Client for Windscribe" - option _role "client" - option client "1" - option dev "tun0" - option proto "udp" - list remote "example.windscribe.com" - option port "443" - option resolv_retry "infinite" - option nobind "1" - option persist_key "1" - option persist_tun "1" - option cipher "aes-256-cbc" - option auth "sha512" - option tls_client "1" - option remote_cert_tls "server" - option key_direction "1" - option auth_user_pass "/etc/openvpn/placeholder/placeholder.file" - option comp_lzo "yes" - option verb "2" - option reneg_sec "432000" - option tls_auth "/etc/openvpn/windscribe/ta.key" - option ca "/etc/openvpn/windscribe/ca.crt" - option redirect_gateway "def1" - -# -# ProtonVPN -# -config openvpn_recipe e_proton_client_tun - option _description "Predefined Client for ProtonVPN" - option _role "client" - option client "1" - option dev "tun0" - option proto "udp" - list remote "example.protonvpn.com" - option port "1194" - option resolv_retry "infinite" - option nobind "1" - option persist_key "1" - option persist_tun "1" - option cipher "aes-256-cbc" - option auth "sha512" - option tls_client "1" - option remote_cert_tls "server" - option key_direction "1" - option auth_user_pass "/etc/openvpn/placeholder/placeholder.file" - option comp_lzo "yes" - option verb "3" - option reneg_sec "0" - option tls_auth "/etc/openvpn/placeholder/placeholder.file" - option ca "/etc/openvpn/placeholder/placeholder.file" - option redirect_gateway "def1" - -# -# Mullvad -# -config openvpn_recipe e_mullvad_client_tun - option _description "Predefined Client for Mullvad" - option _role "client" - option client "1" - option dev "tun0" - option proto "udp" - list remote "example.mullvad.net" - option port "1194" - option resolv_retry "infinite" - option nobind "1" - option persist_key "1" - option persist_tun "1" - option cipher "aes-256-cbc" - option tls_client "1" - option remote_cert_tls "server" - option auth_user_pass "/etc/openvpn/placeholder/placeholder.file" - option comp_lzo "yes" - option verb "3" - option ca "/etc/openvpn/mullvad/mullvad_ca.crt" - option crl_verify "/etc/openvpn/mullvad/mullvad_crl.pem" - option redirect_gateway "def1" - -# -# AirVPN -# -config openvpn_recipe e_airvpn_client_tun - option _description "Predefined Client for AirVPN" - option _role "client" - option client "1" - option dev "tun0" - option proto "udp" - list remote "example.vpn.airdns.org" - option port "443" - option resolv_retry "infinite" - option nobind "1" - option persist_key "1" - option persist_tun "1" - option cipher "aes-256-cbc" - option route_delay "5" - option explicit_exit_notify "5" - option tls_client "1" - option remote_cert_tls "server" - option auth_user_pass "/etc/openvpn/placeholder/placeholder.file" - option comp_lzo "no" - option verb "3" - option key_direction "1" - option ca "/etc/openvpn/airvpn/ca.crt" - option cert "/etc/openvpn/airvpn/client.crt" - option key "/etc/openvpn/airvpn/client.key" - option tls_auth "/etc/openvpn/airvpn/ta.key" - -# -# Tunnelbear -# -config openvpn_recipe e_tunnelbear_client_tun - option _description "Predefined Client for Tunnelbear" - option _role "client" - option dev "tun0" - option proto "udp" - option port "443" - option client "1" - option nobind "1" - option persist_key "1" - option persist_tun "1" - option remote_cert_tls "server" - option reneg_sec "0" - option verb "1" - option comp_lzo "yes" - option auth_user_pass "/etc/openvpn/placeholder/placeholder.file" - option ca "/etc/openvpn/placeholder/placeholder.file" - option cert "/etc/openvpn/placeholder/placeholder.file" - option key "/etc/openvpn/placeholder/placeholder.file" - option remote "example.tunnelbear-ios.com" - option auth "SHA256" - option keysize "256" - option keep_alive "10 30" - option redirect_gateway "def1" diff --git a/rooter/0optionalapps/luci-app-rootervpn/files/etc/init.d/openvpn b/rooter/0optionalapps/luci-app-rootervpn/files/etc/init.d/openvpn deleted file mode 100644 index 543cdf1..0000000 --- a/rooter/0optionalapps/luci-app-rootervpn/files/etc/init.d/openvpn +++ /dev/null @@ -1,194 +0,0 @@ -#!/bin/sh /etc/rc.common -# Copyright (C) 2008-2013 OpenWrt.org -# Copyright (C) 2008 Jo-Philipp Wich -# This is free software, licensed under the GNU General Public License v2. -# See /LICENSE for more information. - -START=90 -STOP=10 - -USE_PROCD=1 -PROG=/usr/sbin/openvpn - -LIST_SEP=" -" -log() { - logger -t "OpenVpn init.d" "$@" -} - -if [ -e /tmp/openvpnboot ]; then - if [ -z "$1" ]; then - return - fi -fi - -UCI_STARTED= -UCI_DISABLED= - -append_param() { - local s="$1" - local v="$2" - case "$v" in - *_*_*_*) v=${v%%_*}-${v#*_}; v=${v%%_*}-${v#*_}; v=${v%%_*}-${v#*_} ;; - *_*_*) v=${v%%_*}-${v#*_}; v=${v%%_*}-${v#*_} ;; - *_*) v=${v%%_*}-${v#*_} ;; - esac - echo -n "$v" >> "/var/etc/openvpn-$s.conf" - return 0 -} - -append_bools() { - local p; local v; local s="$1"; shift - for p in $*; do - config_get_bool v "$s" "$p" - [ "$v" = 1 ] && append_param "$s" "$p" && echo >> "/var/etc/openvpn-$s.conf" - done -} - -append_params() { - local p; local v; local s="$1"; shift - for p in $*; do - config_get v "$s" "$p" - IFS="$LIST_SEP" - for v in $v; do - [ -n "$v" ] && [ "$p" != "push" ] && append_param "$s" "$p" && echo " $v" >> "/var/etc/openvpn-$s.conf" - [ -n "$v" ] && [ "$p" == "push" ] && append_param "$s" "$p" && echo " \"$v\"" >> "/var/etc/openvpn-$s.conf" - done - unset IFS - done -} - -append_list() { - local p; local v; local s="$1"; shift - - list_cb_append() { - v="${v}:$1" - } - - for p in $*; do - unset v - config_list_foreach "$s" "$p" list_cb_append - [ -n "$v" ] && append_param "$s" "$p" && echo " ${v:1}" >> "/var/etc/openvpn-$s.conf" - done -} - -section_enabled() { - config_get_bool enable "$1" 'enable' 0 - config_get_bool enabled "$1" 'enabled' 0 - [ $enable -gt 0 ] || [ $enabled -gt 0 ] -} - -openvpn_add_instance() { - local name="$1" - local dir="$2" - local conf="$3" - - uci set openvpn.$1.laststart="$(date +%s)" - uci commit openvpn - - procd_open_instance "$name" - procd_set_param command "$PROG" \ - --syslog "openvpn($name)" \ - --status "/var/run/openvpn.$name.status" \ - --cd "$dir" \ - --config "$conf" - procd_set_param file "$dir/$conf" - procd_set_param term_timeout 15 - procd_set_param respawn - procd_append_param respawn 3600 - procd_append_param respawn 5 - procd_append_param respawn -1 - procd_close_instance -} - -start_instance() { - local s="$1" - - config_get config "$s" config - config="${config:+$(readlink -f "$config")}" - - log "start instance $s" - if [ ! -e /tmp/openvpnboot ]; then - config_get_bool bootstart "$s" 'bootstart' 0 - if [ $bootstart -eq 0 ]; then - append UCI_DISABLED "$config" "$LIST_SEP" - return 1 - fi - fi - - section_enabled "$s" || { - append UCI_DISABLED "$config" "$LIST_SEP" - return 1 - } - - [ ! -d "/var/run" ] && mkdir -p "/var/run" - - if [ ! -z "$config" ]; then - append UCI_STARTED "$config" "$LIST_SEP" - openvpn_add_instance "$s" "${config%/*}" "$config" - return - fi - - [ ! -d "/var/etc" ] && mkdir -p "/var/etc" - [ -f "/var/etc/openvpn-$s.conf" ] && rm "/var/etc/openvpn-$s.conf" - - append_bools "$s" $OPENVPN_BOOLS - append_params "$s" $OPENVPN_PARAMS - append_list "$s" $OPENVPN_LIST - - openvpn_add_instance "$s" "/var/etc" "openvpn-$s.conf" - sleep 5 -} - -start_service() { - local instance="$1" - local instance_found=0 - - /etc/init.d/rootervpn start - - config_cb() { - local type="$1" - local name="$2" - if [ "$type" = "openvpn" ]; then - if [ -n "$instance" -a "$instance" = "$name" ]; then - instance_found=1 - fi - fi - } - - . /usr/share/openvpn/openvpn.options - config_load 'openvpn' - - if [ -n "$instance" ]; then - [ "$instance_found" -gt 0 ] || return - start_instance "$instance" - else - config_foreach start_instance 'openvpn' $1 - - - local path name - for path in /etc/openvpn/*.conf; do - if [ -f "$path" ]; then - name="${path##*/}"; name="${name%.conf}" - - # don't start configs again that are already started by uci - if echo "$UCI_STARTED" | grep -qxF "$path"; then - continue - - # don't start configs which are set to disabled in uci - elif echo "$UCI_DISABLED" | grep -qxF "$path"; then - logger -t openvpn "$name.conf is disabled in /etc/config/openvpn" - continue - fi - - openvpn_add_instance "$name" "${path%/*}" "$path" - - fi - done - fi - echo "0" > /tmp/openvpnboot -} - -service_triggers() { - procd_add_reload_trigger openvpn -} diff --git a/rooter/0optionalapps/luci-app-rootervpn/files/etc/init.d/rootervpn b/rooter/0optionalapps/luci-app-rootervpn/files/etc/init.d/rootervpn deleted file mode 100644 index eb83a60..0000000 --- a/rooter/0optionalapps/luci-app-rootervpn/files/etc/init.d/rootervpn +++ /dev/null @@ -1,183 +0,0 @@ -#!/bin/sh /etc/rc.common -# Copyright (C) 2006 OpenWrt.org - -START=60 - -log() { - logger -t "OpenVPN : " "$@" -} - -check_config () { - log "Check Client Interfaces" - CHANGE="0" - WW=$(uci get network.VPN) - if [ -z $WW ]; then - uci set network.VPN=interface - uci set network.VPN.proto="none" - uci set network.VPN.ifname="tun0" - uci set network.VPN.auto="0" - CHANGE="1" - fi - WW=$(uci get network.VPNS) - if [ -z $WW ]; then - uci set network.VPNS=interface - uci set network.VPNS.proto="none" - uci set network.VPNS.ifname="tun-server" - uci set network.VPNS.auto="0" - CHANGE="1" - fi - WW=$(uci get network.TAP) - if [ -z $WW ]; then - uci set network.TAP=interface - uci set network.TAP.proto="none" - uci set network.TAP.ifname="tap0" - uci set network.TAP.auto="1" - LANIF=$(uci get network.lan.ifname) - TAP0=$(echo $LANIF | grep "tap0") - if [ -z "$TAP0" ]; then - uci set network.lan.ifname="$(uci get network.lan.ifname) tap0" - fi - CHANGE="1" - fi - WW=$(uci get network.TAPS) - if [ -z $WW ]; then - uci set network.TAPS=interface - uci set network.TAPS.proto="none" - uci set network.TAPS.ifname="tap-server" - uci set network.TAPS.auto="0" - LANIF=$(uci get network.lan.ifname) - TAP1=$(echo $LANIF | grep "tap-server") - if [ -z "$TAP1" ]; then - uci set network.lan.ifname="$(uci get network.lan.ifname) tap-server" - fi - CHANGE="1" - fi - if [ $CHANGE = "1" ]; then - uci commit network - /etc/init.d/network restart - fi - - CHANGE="0" - WW=$(uci get firewall.vpnzone) - if [ -z $WW ]; then - uci set firewall.vpnzone=zone - uci set firewall.vpnzone.name="VPN" - uci set firewall.vpnzone.forward="REJECT" - uci set firewall.vpnzone.output="ACCEPT" - uci set firewall.vpnzone.network="VPN" - uci set firewall.vpnzone.input="REJECT" - uci set firewall.vpnzone.masq="1" - uci set firewall.vpnzone.mtu_fix="1" - uci set firewall.vpnforward=forwarding - uci set firewall.vpnforward.dest="VPN" - uci set firewall.vpnforward.src="lan" - CHANGE="1" - fi - WW=$(uci get firewall.vpnzones) - if [ -z $WW ]; then - uci set firewall.vpnzones=zone - uci set firewall.vpnzones.name="VPNS" - uci set firewall.vpnzones.forward="REJECT" - uci set firewall.vpnzones.output="ACCEPT" - uci set firewall.vpnzones.network="VPNS" - uci set firewall.vpnzones.input="ACCEPT" - uci set firewall.vpnzones.masq="1" - uci set firewall.vpnzones.mtu_fix="1" - uci set firewall.vpnforwards=forwarding - uci set firewall.vpnforwards.dest="VPNS" - uci set firewall.vpnforwards.src="lan" - CHANGE="1" - fi - if [ $CHANGE = "1" ]; then - uci commit firewall - /etc/init.d/firewall restart - fi - WW=$(uci get openvpn.settings) - if [ -z $WW ]; then - uci set openvpn.settings=settings - uci set openvpn.settings.vpn2lan="0" - uci set openvpn.settings.vpns2lan="0" - uci set openvpn.settings.vpn2wan="0" - uci set openvpn.settings.country="CA" - uci set openvpn.settings.city="Abbotsford" - uci set openvpn.settings.organ="ROOter" - uci set openvpn.settings.days="3650" - uci set openvpn.settings.nclient='1' - uci commit openvpn - fi -} - -checkserver() { - log "Check Server Interfaces" - local s=$1 - if [ -z $s ]; then - return - fi - local SERVER="0" - local config=$(uci get openvpn.$s.config) - if [ ! -z $config ]; then - return - fi - local client=$(uci get openvpn.$s.client) - if [ -z $client ]; then - SERVER="1" - else - if [ $client = "0" ]; then - SERVER="1" - fi - fi - - if [ $SERVER = "1" ]; then - port=$(uci get openvpn.$s.port) - if [ -z $port ]; then - PORT="1194" - else - PORT=$port - fi - # look for rule for this port - INB="inbound"$PORT - RULE=$(uci get firewall.$INB) - if [ -z $RULE ]; then - uci set firewall.$INB=rule - uci set firewall.$INB.name=$INB - uci set firewall.$INB.target=ACCEPT - uci set firewall.$INB.src=* - uci set firewall.$INB.proto=udp - uci set firewall.$INB.dest_port=$PORT - uci commit firewall - /etc/init.d/firewall reload - fi - DEV=$(uci get openvpn.$s.dev) - if [ $DEV = "tun0" ]; then - uci set openvpn.$s.dev="tun1" - uci commit openvpn - else - - if [ $DEV = "tap0" ]; then - uci set openvpn.$s.dev="tap1" - uci commit openvpn - fi - fi - else - DEV=$(uci get openvpn.$s.dev) - if [ $DEV = "tun1" ]; then - uci set openvpn.$s.dev="tun0" - uci commit openvpn - else - if [ $DEV = "tap1" ]; then - uci set openvpn.$s.dev="tap0" - uci commit openvpn - fi - fi - fi -} - -start() { - check_config - checkserver - - if [ -d /etc/luci-uploads ]; then - rm -rfv /etc/luci-uploads - fi - ln -s /etc/openvpn /etc/luci-uploads -} \ No newline at end of file diff --git a/rooter/0optionalapps/luci-app-rootervpn/files/etc/openvpn/airvpn/ca.crt b/rooter/0optionalapps/luci-app-rootervpn/files/etc/openvpn/airvpn/ca.crt deleted file mode 100644 index cc37250..0000000 --- a/rooter/0optionalapps/luci-app-rootervpn/files/etc/openvpn/airvpn/ca.crt +++ /dev/null @@ -1,36 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIGVDCCBDygAwIBAgIJAIzYQ+/kXyADMA0GCSqGSIb3DQEBBQUAMHkxCzAJBgNV -BAYTAklUMQswCQYDVQQIEwJJVDEQMA4GA1UEBxMHUGVydWdpYTETMBEGA1UEChMK -YWlydnBuLm9yZzEWMBQGA1UEAxMNYWlydnBuLm9yZyBDQTEeMBwGCSqGSIb3DQEJ -ARYPaW5mb0BhaXJ2cG4ub3JnMB4XDTE0MDQxMTEwMTU0NVoXDTI0MDQwODEwMTU0 -NVoweTELMAkGA1UEBhMCSVQxCzAJBgNVBAgTAklUMRAwDgYDVQQHEwdQZXJ1Z2lh -MRMwEQYDVQQKEwphaXJ2cG4ub3JnMRYwFAYDVQQDEw1haXJ2cG4ub3JnIENBMR4w -HAYJKoZIhvcNAQkBFg9pbmZvQGFpcnZwbi5vcmcwggIiMA0GCSqGSIb3DQEBAQUA -A4ICDwAwggIKAoICAQDGG3ZrJbP61PNjGc4mjTx0TLkUjP7IXZ3wnpPjwF/lwK9n -HgRqoPL0KY/ABJuzMViD8ChtwthNfc7PuJ7vSPtN84lSJ4JGmTxvZkNeLQLZsu1F -f88OcSpjW5ErBM05iVBeF8/ljwaajgFfbgop9W/UK5yMji4qgq5KHxxXqsB8R4rC -eFpWHoNTwFjvXhtVyMgXiT9XAh/vBYim021m8onio4K48q7YRZ4qU8gvE79h5M0g -miIlt6v1vaZskw9cqIBbCYefGMsvBRk2x824ChPf6FazMwAnQHsuBHt6eXAARvfF -DBDanzPHlRSiCP6Je6Vod/MPyepiTZgjgk2VxYUc1ohNxEEGzPGTayeNzLJUldou -P4B+tjJ0Xly30+wvlahADlqjtz3CGQmKMj7btZjd+Uo61B7gau5YiXR/IO7ZpFAC -PCZJSbrwFs6rt9Kewqk8zslfVIro8oDndXRkVsa/c8Qmd6ZE7V+oMGl2OggdWOLl -mDEjkytzx+Bw2sSSalJRAQmOQO8V0anOI6jGYLuU2jnFDsnqSHuwIK11xb6iHmh7 -ONsRLUtQ+d64TzB00w2M0fCvGqUIp0N+lf7nsZKsEcU08OoHQYUuwX75ZEOYNSZJ -rqAXohcXdVUHqgRlJRErfSkjcGMM0yqjHkvopcnBIRXKMYTDVXvzRJboyJiVpQID -AQABo4HeMIHbMB0GA1UdDgQWBBTlFdcTqJ4x49Ew1/Ef9OJj0lDIiDCBqwYDVR0j -BIGjMIGggBTlFdcTqJ4x49Ew1/Ef9OJj0lDIiKF9pHsweTELMAkGA1UEBhMCSVQx -CzAJBgNVBAgTAklUMRAwDgYDVQQHEwdQZXJ1Z2lhMRMwEQYDVQQKEwphaXJ2cG4u -b3JnMRYwFAYDVQQDEw1haXJ2cG4ub3JnIENBMR4wHAYJKoZIhvcNAQkBFg9pbmZv -QGFpcnZwbi5vcmeCCQCM2EPv5F8gAzAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEB -BQUAA4ICAQCUVAQteCtgNQiZMXV0wCdqivlxlCCuj5sD+XvEuoDqb7dH70u1KQ90 -OAbkeotHlIbqJU10xWtvHEjnXg8QG5VOzaWnWWev+ivdPCkGWe8E7C8shsr4WMlA -EF8PPRtzOwCKayxjR713x+Tc2Sb6/rDsXcY5LV6RNmE9HWBM6IoHdqruR8PHkYge -2CPXMuLByEADri6xmvussAjCWEDplJNY7tQsUGT7vjrwrNSNBx/SvxkXnWBj0wYa -EwNu43jrjcRfM/3eGcKDX3cQqTfRQd3j3OA7zmJOXPeExRUIWZTNCvQItGy1TJdw -JTphflw15Bui4l2mYfDqK08zm4aJODrCjoQnVVzM5uOzSTOjmneI6AHj3MjjL3A/ -CFA5PCSquBhUycF4UEVf3aPGiV0vAthCBUqM4eKE+rbjWPSaxKghVdr/S82o7Wzz -9mGwnOZDqWk+8AWSsGBjamMk3mNMR45E9FRfPF/dyjOSbVyyTsd1VzlTFEJa0wjB -l3yq3r3iZAM3UtevocAyTEAu0vDYBbS6TgWmWEDOizybB0hNrTx5u/SEI0Kwcthc -rilYxD+n4kmV7TvIR0ZSaYpgYALWQV27zOqY51Ol4UT98WCOokge9HdoFcGJU2Uj -5VneGp14/Oklh7y6BxxxGC3zNGjKGNQYuHGTIgw1DoASmRUdkPkn/w== ------END CERTIFICATE----- \ No newline at end of file diff --git a/rooter/0optionalapps/luci-app-rootervpn/files/etc/openvpn/airvpn/client.crt b/rooter/0optionalapps/luci-app-rootervpn/files/etc/openvpn/airvpn/client.crt deleted file mode 100644 index 7c8e434..0000000 --- a/rooter/0optionalapps/luci-app-rootervpn/files/etc/openvpn/airvpn/client.crt +++ /dev/null @@ -1,38 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIGnTCCBIWgAwIBAgIDAUsLMA0GCSqGSIb3DQEBBQUAMHkxCzAJBgNVBAYTAklU -MQswCQYDVQQIEwJJVDEQMA4GA1UEBxMHUGVydWdpYTETMBEGA1UEChMKYWlydnBu -Lm9yZzEWMBQGA1UEAxMNYWlydnBuLm9yZyBDQTEeMBwGCSqGSIb3DQEJARYPaW5m -b0BhaXJ2cG4ub3JnMB4XDTE2MDcyNjAwMTgxN1oXDTI2MDcyNDAwMTgxN1oweDEL -MAkGA1UEBhMCSVQxCzAJBgNVBAgTAklUMRAwDgYDVQQHEwdQZXJ1Z2lhMRMwEQYD -VQQKEwphaXJ2cG4ub3JnMRUwEwYDVQQDEwxhaXJ2cG4yNjE5MTQxHjAcBgkqhkiG -9w0BCQEWD2luZm9AYWlydnBuLm9yZzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCC -AgoCggIBANGrd9SWDf82gqtFjhtUfT3m43nozx+6I3/DYJplEk3K3xY/DU+0j9/Z -mftg6R4FJx562KHySqZfpTvPT99KjQMsyMW5iwGXlkbW3FdYn1GUNWQTzi+upzEA -eZqtBbPY5XQqX2aW03OdNJ5ycP63NqIkF34g9EAEOVodqC41wDJ0Fy/iak8htHRa -+tReSt/QxYVHT/n/pLgsrSZ00iJiSNEMRIdc7lmthj69C5HFi0tenWFgXbvn2vkJ -/m9FZq7tita9kuMsCPWWYA6qFuBlDhm62e/op5Z9TFXnp07PU4Y5xsPPuLVA/prL -bjuXSwhrHpkTCxxrSB+iNzcxRwKmDovdwauJ+ntqccpMx3i+xC4qWhxaVrqjgtYf -LWJxbyNDPDEsPACZDSSDu7lDciy/EJMW9ndS6A834dU8omx8LGpp7ZveEvBPcFRC -0XxoNiVyfcZG7HR9JtwNizNvndkcKJFoiYUkuZYofqU11VyGMG7Uf7GuksQsSgk1 -v78UCSq6sgm2ltb6maX44qAQ4cxxWpxCe9tFCV2I97EszKMxVlsbg9hUGbmlFG0/ -JH+/DfF26N/IHWR8hzgbfolj7wWLm5G7Xp8ft0JNCMiIpfqKdWCMq5MmPJ0thNpL -V7XEQ7zd1LWyNYR61bkiMAtpszs67NurV2OKfqYeGk07nV4Fu2Z7AgMBAAGjggEt -MIIBKTAJBgNVHRMEAjAAMC0GCWCGSAGG+EIBDQQgFh5FYXN5LVJTQSBHZW5lcmF0 -ZWQgQ2VydGlmaWNhdGUwHQYDVR0OBBYEFLFHNef5VZb2wM1uSQh7lh7aEWApMIGr -BgNVHSMEgaMwgaCAFJzkYNlvN+jPLlRVMsXY2QC+jXgDoX2kezB5MQswCQYDVQQG -EwJJVDELMAkGA1UECBMCSVQxEDAOBgNVBAcTB1BlcnVnaWExEzARBgNVBAoTCmFp -cnZwbi5vcmcxFjAUBgNVBAMTDWFpcnZwbi5vcmcgQ0ExHjAcBgkqhkiG9w0BCQEW -D2luZm9AYWlydnBuLm9yZ4IJAMJkKKJ2Uo1nMBMGA1UdJQQMMAoGCCsGAQUFBwMC -MAsGA1UdDwQEAwIHgDANBgkqhkiG9w0BAQUFAAOCAgEAJ2+ob0AbwJjOueMBjFmC -kLig/OpJr5Sx0RQ01x4759ULEs/NMzaNUr2lhsQAVkYN8EvPp4UM/iO46sATsigA -IgsBKoIZrJ5YzOQsczcE73AJSRBtHLQXesRXKreYVd02Kxez3zcO92xMURmo1YIM -gpEj332reruw6SCY5YQTN2Kso+Kx6nLaLiDMNVaeMlWlIZY0ZucQRVRsFhc2KLTN -OWUZOhHlNaeMltzqRzD5ncRB8e0disWdHpkjtSz18BvER7v4lZCjWZ8BDzg6YKf7 -hlphmxEB97t8b/3zBHjI72lgeKx/vo0M+mL5dzaujhQ0b2yqqsTsth3azULjXjUw -zb9g359T2QAJrGSuMsB0u+bzFE7R+8pYQwu6IYav4whElyp+HRAIE7AFqOh+BcWR -RAgN8weGnxN1H2AjtkCc9jDuvR9f5/eMePf2IxdbY/QQ5RS4s5mOQrC8XQj4YPUL -v3d6oci8Rud4R8vNYTBV92qhUoPkWnqxy5sIA9/JWLFPtnhJqmyTJJQnTVMHWp/6 -2lc9j/wvDQSSpu/za127+ULh27qh89IrqvtbE8C6G+cOIUs3/CcKiIcHtVsIcCWR -HN1jf5qZ8HtIB0K0EZ47kYWIfJbllnqshWGRRPAnzCpWafNIXWf/MjWUfyrfAkZ8 -qAZoGjCdOJq/IrQCq/95Cpw= ------END CERTIFICATE----- \ No newline at end of file diff --git a/rooter/0optionalapps/luci-app-rootervpn/files/etc/openvpn/airvpn/client.key b/rooter/0optionalapps/luci-app-rootervpn/files/etc/openvpn/airvpn/client.key deleted file mode 100644 index 9f34129..0000000 --- a/rooter/0optionalapps/luci-app-rootervpn/files/etc/openvpn/airvpn/client.key +++ /dev/null @@ -1,52 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIJRAIBADANBgkqhkiG9w0BAQEFAASCCS4wggkqAgEAAoICAQDRq3fUlg3/NoKr -RY4bVH095uN56M8fuiN/w2CaZRJNyt8WPw1PtI/f2Zn7YOkeBSceetih8kqmX6U7 -z0/fSo0DLMjFuYsBl5ZG1txXWJ9RlDVkE84vrqcxAHmarQWz2OV0Kl9mltNznTSe -cnD+tzaiJBd+IPRABDlaHaguNcAydBcv4mpPIbR0WvrUXkrf0MWFR0/5/6S4LK0m -dNIiYkjRDESHXO5ZrYY+vQuRxYtLXp1hYF2759r5Cf5vRWau7YrWvZLjLAj1lmAO -qhbgZQ4Zutnv6KeWfUxV56dOz1OGOcbDz7i1QP6ay247l0sIax6ZEwsca0gfojc3 -MUcCpg6L3cGrifp7anHKTMd4vsQuKlocWla6o4LWHy1icW8jQzwxLDwAmQ0kg7u5 -Q3IsvxCTFvZ3UugPN+HVPKJsfCxqae2b3hLwT3BUQtF8aDYlcn3GRux0fSbcDYsz -b53ZHCiRaImFJLmWKH6lNdVchjBu1H+xrpLELEoJNb+/FAkqurIJtpbW+pml+OKg -EOHMcVqcQnvbRQldiPexLMyjMVZbG4PYVBm5pRRtPyR/vw3xdujfyB1kfIc4G36J -Y+8Fi5uRu16fH7dCTQjIiKX6inVgjKuTJjydLYTaS1e1xEO83dS1sjWEetW5IjAL -abM7Ouzbq1djin6mHhpNO51eBbtmewIDAQABAoICAQCpSr2ylIYwrx7Kk5quToXh -WXAKmwPCJlVLb8GsaDdjQI7oM3jYBn60y8ocwp73ckmnvqD0AeJse4W6ySVAsb0x -9xMVMz8dxfu8rveyPwhEolqJt8Qfk/HDCxMk5NdZ46NBLIVjHB0XmLNHzDeYMu6V -9HZTjOAqYD6+mHuW9Cd/lWSzcSlNQ3WlDWDB4HCsTrFtb6sPvG6PluMnzeNth9Yr -lLAwa8S3+/gM6C9TQCG8dWS1n02PzyFrO7qItYy3aW1U/jR/4KpLQWPF82gNPwsn -k0ss/rlyNTFRm33nkFdsZXIr4KjPEO+CpQcYboxS+8r05f9uruDJSf0zP0KKzPGo -XiEhxGolfry0GR17AmJliWOmEbCrHkkOaMP8M2feV9C8vwQsEpNHsK2fyyyMUsok -eM4hNYpd/OsglhDrcBJy9h2Sg8y8II1xMDtnxpWAvhGky4UMUZY3oqNGHCRInexl -XHQkVmqa0hc0k+jD0EBxbGNLAd1tqV8pwlTxdPRdhREDLIUZi93Sn/AehCmwFngK -g+TQaLKUGxk86ccenr1+ElK8ulC0olGg4EFp6Y9O9KJsvy3E1PrpaUO2urP+SkUB -Qn0NJiw5TxJC9XeEpnPbk0aMU7bx3iuLdSMqBadrlM13mbALHdVnybC2KCoYTU3g -phLhUn+2+hmlh098M11nYQKCAQEA+ARSNiJ/t8YeDNotJ37JYaTVwMYa/ovU/DBI -LhEOASS4jXLTkJkbX/0V6cUsnlC27FjnRJ7l+QNCb23GgZnQTXY9nnUStyrCWvqC -fh00s0UntY079xT/d8X92yFKt9/NixdxF6WCbH1QDfF1HHDSMVdXdmWlqhgsFedD -yd7YWFacr2GddDfqQybkzFHxuSxizEH/uPmh/LlEtxSX1Kgg5veWsITPyxU0EdKX -Nlr3OmGYMc4eLKu0lsNEYhXkMPnIcu62eJYGCWJ2korruPDAS1i0KXSYlZ9VQU6r -9Fq/3iM3KY4MNYR9kOz4LLqSXFwEAyKfOGl0Y8o4+P7AGCnCHwKCAQEA2Gsp95OW -BXIC4JMn3mthg8DUyaPV7iG6oXBMBMPrzxcykb0Q+sFuMWaCaQoGdYQgMRrfb9uT -hu3BzOh5T5f8gq2MkbWDbifMjTvHG3nf/Z4zVgMgzjMZ+6Q7GRccxNLXSiyLecfO -oIklutGyE1zLnlrhxUPv0cOLpc1u1mpm2eDuIinCN/4A2BGe4L8NIRCN0KOclvEd -YWmipgoNxZ9wXuxwBO6I9rQa4ggmShJvgaAtoQ6QPY1hZqxedkXDrqPSCEGzCKeE -d8PhGutilMp0mkCpzHvS38e/01XjDBr8g5F3ORopbIpF2O/xMdzFoObPtC/awvlX -JQhsMEAMgfKoJQKCAQANPN3OeeTrQC3Wbca/Nus0xQGLuocyUvBZTZJsswhWU0lu -c1SLgUCOzQlgYt/Qy2oYD164sOqBcgUXwXo47KbLm6YKUSFgmW2qQXi5loF7mBNY -g2NR+tLv56d3DL3aNp3X8LZelrzxYXbmZ57il7sAWzMV5LME8ylXOfLKUZSmkmjm -i4VF8L4WO3s21KDcS1wynssxalGVFaZvRzAbb6Xh7hEi9tPIeSdAVEcx5YUQnqjq -7594rumCqoV53sVBP/PM/qTKpudHlPPTOor+YgtBekiTdd+3DLwWMkbHUhivmJ2X -IDfSm3HATIWqjYLGXzrvl+d7sVU/BkooMCC8qW3tAoIBAQDNG8OKgLWOM5/Gd7Ex -e1PQKtGAyWXXauAWYPerDIRQoQusVCPjg6+L4jt2kanNdouL/owE13XaSzuBmFJg -vQr0TscK0ZzeqZmTwTPTNo6zL1w4CH7u7j+R3vSjsuPxJmIkSlNl95g9Tb4UcOj0 -sN3KFxgifWCszUdsvGZvkCgqFqOafTk1F+Z04T5Sgr9OtwGw219tLtdJm3QrKRwk -UBeP30XLZscoCUnxLwga654CnGyiV8sciwHk7TgZn8T1nw1QBfRIH3vMhjix6qRj -n/0itGY5BqG0tPt4r82fi3QGvbbgx4q689F+6OkO+M3U0OvJOhF6+BU/Y9wlXo58 -Gh6BAoIBAQDxM76UGIx7ptYpbb2qmNj4MHJFzn2LiU+9GH1zRuOcphkafb/neZJw -poIYozm5MUPcuKcSMrvRNCDXL5HVkbtN0iPOvDA88Jp/rNEF0I9NPcGRAQJ6OvZS -QaMgnce4y0SNOq4o2bWNE2n6LRLBmvxacyFpggleOwjIHk+RUj6yWQcUjRid1U1s -LVg5clPNYxf5pm+4k0GS2nye4+wCKiu9/KUtCd73PPBvrW5xN9sKbrN+hy+m5KVC -Kx1/k/aB3j7WxVIJBKMxQqlM8k1frd0um6CaD18DvZHDAGMInEwTfkJJVLQDxN4/ -59PFiE0grG3JNZa3g34RjxOtsoNrz3bH ------END PRIVATE KEY----- \ No newline at end of file diff --git a/rooter/0optionalapps/luci-app-rootervpn/files/etc/openvpn/airvpn/ta.key b/rooter/0optionalapps/luci-app-rootervpn/files/etc/openvpn/airvpn/ta.key deleted file mode 100644 index 7d53ac5..0000000 --- a/rooter/0optionalapps/luci-app-rootervpn/files/etc/openvpn/airvpn/ta.key +++ /dev/null @@ -1,18 +0,0 @@ ------BEGIN OpenVPN Static key V1----- -7bb7a23a0f5f28d01e792df68f1764ab -f2688719288808bf58e8a2d4f9354ecf -132625dfb895fc3f6330ae1e868e4dfa -c164c0931593d7f9a7da9595cf353433 -8896e1d0a987a0d19838944af8fea4e5 -215a3a0c76f4c67d5a4aee6a53be66a4 -c88b84f850030840fb30f8550ed8068f -35c1ef34ee8f40a0ea5862dfb6f8d3c5 -7ab5e27ac2799cf93e8765ff63cd8cd8 -6b391b813925cd373bb202796f64d16f -003d042ca828d1b07f18ba1d0cb0323d -df3ee9287e9e084e655699efb3cffa92 -3626946fa372e7beee245e7a95b4c1d8 -7d16cae685218d4b8afc019b22e41083 -476ee9883fe666d236301e55b2062551 -4d91c8a69467a758293994df1e6fa7ae ------END OpenVPN Static key V1----- \ No newline at end of file diff --git a/rooter/0optionalapps/luci-app-rootervpn/files/etc/openvpn/mullvad/mullvad_ca.crt b/rooter/0optionalapps/luci-app-rootervpn/files/etc/openvpn/mullvad/mullvad_ca.crt deleted file mode 100644 index b795d91..0000000 --- a/rooter/0optionalapps/luci-app-rootervpn/files/etc/openvpn/mullvad/mullvad_ca.crt +++ /dev/null @@ -1,109 +0,0 @@ -Certificate: - Data: - Version: 3 (0x2) - Serial Number: 3 (0x3) - Signature Algorithm: sha1WithRSAEncryption - Issuer: C=NA, ST=None, L=None, O=Mullvad, CN=Mullvad CA/emailAddress=info@mullvad.net - Validity - Not Before: Mar 24 16:19:48 2009 GMT - Not After : Mar 22 16:19:48 2019 GMT - Subject: C=NA, ST=None, L=None, O=Mullvad, CN=master.mullvad.net/emailAddress=info@mullvad.net - Subject Public Key Info: - Public Key Algorithm: rsaEncryption - RSA Public Key: (2048 bit) - Modulus (2048 bit): - 00:c5:00:39:5d:fe:9b:0c:b7:ff:76:a4:93:bf:26: - 1b:d6:c8:4a:e5:3c:ce:1c:2c:16:80:a2:61:a6:e9: - 63:4b:70:a1:80:6f:0e:0c:bb:a9:b6:d1:bd:f5:a0: - 78:82:09:4d:94:22:aa:77:7c:09:36:42:cd:a5:a6: - 90:73:27:42:00:31:e4:d4:8b:49:36:65:a3:25:82: - b8:26:d7:d1:f5:b5:a9:be:57:93:9d:7c:d6:1c:df: - 9a:87:81:53:0b:17:81:d1:0d:ca:dc:4d:19:13:fa: - 11:e6:da:68:eb:81:05:39:e3:1e:3a:3f:fc:e2:64: - 3c:98:3c:89:a9:42:b3:30:70:57:56:a1:f5:08:b2: - 75:12:a0:36:93:9d:69:e9:7e:11:71:d9:1c:e8:7d: - ec:03:21:11:7a:0a:7a:03:35:ba:b8:b2:0c:3a:6f: - 57:88:62:45:3d:0c:6c:18:ff:21:49:37:ae:40:78: - 6d:45:52:29:ac:21:ad:4a:01:61:67:0b:01:c4:ac: - b0:88:97:52:ff:cb:3a:21:f0:14:2b:c1:79:8d:79: - 35:14:fc:9c:3f:6c:c9:62:fc:8c:c7:a8:51:34:75: - 1c:23:d5:db:b9:44:08:1c:0c:17:2c:21:2a:b4:29: - db:15:59:e7:a9:1c:d6:19:19:ef:e4:6b:ea:78:6d: - 76:8d - Exponent: 65537 (0x10001) - X509v3 extensions: - X509v3 Subject Key Identifier: - 75:8A:14:92:0D:F3:6E:B7:36:4F:8B:4F:15:6C:3F:18:15:90:64:DE - X509v3 Authority Key Identifier: - keyid:E1:63:B4:3E:55:A3:D2:37:5F:DE:3A:91:48:51:4B:20:1A:F2:9B:C5 - DirName:/C=NA/ST=None/L=None/O=Mullvad/CN=Mullvad CA/emailAddress=info@mullvad.net - serial:84:68:2E:A0:51:2A:BB:D4 - - X509v3 Basic Constraints: - CA:TRUE - Signature Algorithm: sha1WithRSAEncryption - a4:b4:62:3d:cb:7e:57:b3:bd:2a:41:e0:3b:94:d0:4c:08:69: - 8a:b1:73:15:13:20:c9:d7:b0:b6:5d:65:4a:4d:1d:27:cc:ca: - 11:0e:86:fa:65:61:26:39:c2:54:8e:da:eb:78:21:37:0e:c7: - a4:d2:17:8a:4b:ad:17:84:25:5e:24:0e:9a:81:ff:d1:1b:0e: - 32:9b:f4:81:e0:07:e9:8f:9d:c1:43:7f:40:30:01:07:7c:02: - c7:c4:9c:05:48:4c:bf:41:69:57:c1:d3:bb:a3:5a:01:17:96: - b0:c9:00:22:57:2f:84:da:45:33:6e:6c:2b:13:c5:af:75:a7: - b2:6b:71:6e:13:2c:97:0e:d9:93:da:6d:d9:34:c6:06:7d:0e: - e2:b8:d2:78:13:79:0f:ac:ac:a8:68:a9:72:73:7a:d8:ab:7b: - 0a:b0:54:b5:f3:ce:29:0d:47:82:0c:b4:d9:20:64:ff:ef:17: - 46:92:de:65:e8:67:ce:3a:92:de:e4:3e:99:73:9f:7a:7c:00: - 72:07:39:78:77:37:62:89:a2:db:24:fd:60:2a:e0:82:57:f6: - 55:94:f6:79:47:19:c9:13:3b:5d:b7:6b:66:14:d4:7d:3c:76: - 75:e9:a3:55:ba:b4:92:30:3b:ad:66:72:0c:39:4b:cc:95:a9: - bc:06:ef:2b ------BEGIN CERTIFICATE----- -MIIEQjCCAyqgAwIBAgIBAzANBgkqhkiG9w0BAQUFADBzMQswCQYDVQQGEwJOQTEN -MAsGA1UECBMETm9uZTENMAsGA1UEBxMETm9uZTEQMA4GA1UEChMHTXVsbHZhZDET -MBEGA1UEAxMKTXVsbHZhZCBDQTEfMB0GCSqGSIb3DQEJARYQaW5mb0BtdWxsdmFk -Lm5ldDAeFw0wOTAzMjQxNjE5NDhaFw0xOTAzMjIxNjE5NDhaMHsxCzAJBgNVBAYT -Ak5BMQ0wCwYDVQQIEwROb25lMQ0wCwYDVQQHEwROb25lMRAwDgYDVQQKEwdNdWxs -dmFkMRswGQYDVQQDExJtYXN0ZXIubXVsbHZhZC5uZXQxHzAdBgkqhkiG9w0BCQEW -EGluZm9AbXVsbHZhZC5uZXQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB -AQDFADld/psMt/92pJO/JhvWyErlPM4cLBaAomGm6WNLcKGAbw4Mu6m20b31oHiC -CU2UIqp3fAk2Qs2lppBzJ0IAMeTUi0k2ZaMlgrgm19H1tam+V5OdfNYc35qHgVML -F4HRDcrcTRkT+hHm2mjrgQU54x46P/ziZDyYPImpQrMwcFdWofUIsnUSoDaTnWnp -fhFx2RzofewDIRF6CnoDNbq4sgw6b1eIYkU9DGwY/yFJN65AeG1FUimsIa1KAWFn -CwHErLCIl1L/yzoh8BQrwXmNeTUU/Jw/bMli/IzHqFE0dRwj1du5RAgcDBcsISq0 -KdsVWeepHNYZGe/ka+p4bXaNAgMBAAGjgdgwgdUwHQYDVR0OBBYEFHWKFJIN8263 -Nk+LTxVsPxgVkGTeMIGlBgNVHSMEgZ0wgZqAFOFjtD5Vo9I3X946kUhRSyAa8pvF -oXekdTBzMQswCQYDVQQGEwJOQTENMAsGA1UECBMETm9uZTENMAsGA1UEBxMETm9u -ZTEQMA4GA1UEChMHTXVsbHZhZDETMBEGA1UEAxMKTXVsbHZhZCBDQTEfMB0GCSqG -SIb3DQEJARYQaW5mb0BtdWxsdmFkLm5ldIIJAIRoLqBRKrvUMAwGA1UdEwQFMAMB -Af8wDQYJKoZIhvcNAQEFBQADggEBAKS0Yj3LflezvSpB4DuU0EwIaYqxcxUTIMnX -sLZdZUpNHSfMyhEOhvplYSY5wlSO2ut4ITcOx6TSF4pLrReEJV4kDpqB/9EbDjKb -9IHgB+mPncFDf0AwAQd8AsfEnAVITL9BaVfB07ujWgEXlrDJACJXL4TaRTNubCsT -xa91p7JrcW4TLJcO2ZPabdk0xgZ9DuK40ngTeQ+srKhoqXJzetirewqwVLXzzikN -R4IMtNkgZP/vF0aS3mXoZ846kt7kPplzn3p8AHIHOXh3N2KJotsk/WAq4IJX9lWU -9nlHGckTO123a2YU1H08dnXpo1W6tJIwO61mcgw5S8yVqbwG7ys= ------END CERTIFICATE----- ------BEGIN CERTIFICATE----- -MIIEQjCCAyqgAwIBAgIJAIRoLqBRKrvUMA0GCSqGSIb3DQEBBQUAMHMxCzAJBgNV -BAYTAk5BMQ0wCwYDVQQIEwROb25lMQ0wCwYDVQQHEwROb25lMRAwDgYDVQQKEwdN -dWxsdmFkMRMwEQYDVQQDEwpNdWxsdmFkIENBMR8wHQYJKoZIhvcNAQkBFhBpbmZv -QG11bGx2YWQubmV0MB4XDTA5MDMyNDA2NDcyNVoXDTE5MDMyMjA2NDcyNVowczEL -MAkGA1UEBhMCTkExDTALBgNVBAgTBE5vbmUxDTALBgNVBAcTBE5vbmUxEDAOBgNV -BAoTB011bGx2YWQxEzARBgNVBAMTCk11bGx2YWQgQ0ExHzAdBgkqhkiG9w0BCQEW -EGluZm9AbXVsbHZhZC5uZXQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB -AQDNNzZOrq+gMaA6wfyWdNFmxlM2OB1czwFgtPiDd9f6F8m6CGYBQog3Q2Wx3yAv -hxt/uchFBCKtYz6Yh59BCxXKfNAQT2uaMC6KAvKFgz0wppi4S8YbWg2KDelNO/Zv -Rb1QT4CBWMbtYzCQZvlJpHr2ZwuXG2OiT477oMyX5Hmf+iT0drmqi+wylRr7CRBs -LBu+fxLZ2LFD5g6MATuL3ql5JLIoVjlSqIgbld74pD4WUnM61HRwFsKoCEjq409Y -QNP1xO7BeaJu3uQvg/HJhXnGZxTatXhqvdCuAPQRppQ4UnkUzxdSTrfgM3hqMony -vX1vy0dX1S8iTQCIeyzAYNObAgMBAAGjgdgwgdUwHQYDVR0OBBYEFOFjtD5Vo9I3 -X946kUhRSyAa8pvFMIGlBgNVHSMEgZ0wgZqAFOFjtD5Vo9I3X946kUhRSyAa8pvF -oXekdTBzMQswCQYDVQQGEwJOQTENMAsGA1UECBMETm9uZTENMAsGA1UEBxMETm9u -ZTEQMA4GA1UEChMHTXVsbHZhZDETMBEGA1UEAxMKTXVsbHZhZCBDQTEfMB0GCSqG -SIb3DQEJARYQaW5mb0BtdWxsdmFkLm5ldIIJAIRoLqBRKrvUMAwGA1UdEwQFMAMB -Af8wDQYJKoZIhvcNAQEFBQADggEBAMjMAFPDeFOrQsvMXD/x+CuARwegS2PDZuB5 -f1Svw3YDF6cB1jlc0F12nh9SZxaYRwKIlpYoolLCOLoUCLwQJ0gsokxLV7G4gVb8 -dzETnNq4HG/QOPwPisjoOCaEmcd0tx1EkyNY0KLqFZTS0VdmDHCn89dDFA/6yuYI -5u04uJs7c/K4qaW7X6ajOOdneqjbtPeVOvx9DWXHxA0xz4Y+/w4laX/OTRD7jySq -K9fLfRliE5zsxzpUr5EWxAnqiABoWL71SiItk5fG8k3MJJ9SVr+YnTHmE7S4KNqu -4wTksvkb0Tmjae1lRSlMd6u2AulAxVcVKAod2QVffhj+hdkYM94= ------END CERTIFICATE----- diff --git a/rooter/0optionalapps/luci-app-rootervpn/files/etc/openvpn/mullvad/mullvad_crl.pem b/rooter/0optionalapps/luci-app-rootervpn/files/etc/openvpn/mullvad/mullvad_crl.pem deleted file mode 100644 index 10e26dd..0000000 --- a/rooter/0optionalapps/luci-app-rootervpn/files/etc/openvpn/mullvad/mullvad_crl.pem +++ /dev/null @@ -1,36 +0,0 @@ ------BEGIN X509 CRL----- -MIIGMTCCBRkwDQYJKoZIhvcNAQELBQAwezELMAkGA1UEBhMCTkExDTALBgNVBAgT -BE5vbmUxDTALBgNVBAcTBE5vbmUxEDAOBgNVBAoTB011bGx2YWQxGzAZBgNVBAMT -Em1hc3Rlci5tdWxsdmFkLm5ldDEfMB0GCSqGSIb3DQEJARYQaW5mb0BtdWxsdmFk -Lm5ldBcNMTcwNjIyMTQzMzEyWhcNMjcwNjIwMTQzMzEyWjCCBGswEgIBARcNMTcw -NjIyMTQzMzExWjASAgEDFw0xNzA2MjIxNDMzMTFaMBICASkXDTE3MDYyMjE0MzMx -MVowEwICDasXDTE3MDYyMjE0MzMxMVowEwICDawXDTE3MDYyMjE0MzMxMVowEwIC -Da0XDTE3MDYyMjE0MzMxMVowEwICDx4XDTE3MDYyMjE0MzMxMVowEwICGxsXDTE3 -MDYyMjE0MzMxMVowEwICPf4XDTE3MDYyMjE0MzMxMVowEwICSrUXDTE3MDYyMjE0 -MzMxMVowFAIDAbbXFw0xNzA2MjIxNDMzMTFaMBQCAwaeUBcNMTcwNjIyMTQzMzEx -WjAUAgMGnlUXDTE3MDYyMjE0MzMxMVowFAIDCheTFw0xNzA2MjIxNDMzMTFaMBQC -AwpvDBcNMTcwNjIyMTQzMzExWjAUAgML2jcXDTE3MDYyMjE0MzMxMVowFAIDDCfI -Fw0xNzA2MjIxNDMzMTFaMBQCAwwrKhcNMTcwNjIyMTQzMzExWjAUAgMMNWEXDTE3 -MDYyMjE0MzMxMVowFAIDDDViFw0xNzA2MjIxNDMzMTFaMBQCAwyXhRcNMTcwNjIy -MTQzMzExWjAUAgMM99UXDTE3MDYyMjE0MzMxMVowFAIDDPfWFw0xNzA2MjIxNDMz -MTFaMBQCAwz31xcNMTcwNjIyMTQzMzExWjAUAgMM9+MXDTE3MDYyMjE0MzMxMVow -FAIDDPfkFw0xNzA2MjIxNDMzMTFaMBQCAwz35RcNMTcwNjIyMTQzMzExWjAUAgMN -FHEXDTE3MDYyMjE0MzMxMVowFAIDDRSLFw0xNzA2MjIxNDMzMTFaMBQCAw1FfBcN -MTcwNjIyMTQzMzExWjAUAgMNUWcXDTE3MDYyMjE0MzMxMVowFAIDDVFoFw0xNzA2 -MjIxNDMzMTFaMBQCAw1RbBcNMTcwNjIyMTQzMzExWjAUAgMN2AoXDTE3MDYyMjE0 -MzMxMVowFAIDDdgLFw0xNzA2MjIxNDMzMTFaMBQCAw6G3xcNMTcwNjIyMTQzMzEx -WjAUAgMOkpwXDTE3MDYyMjE0MzMxMVowFAIDDpKdFw0xNzA2MjIxNDMzMTFaMBQC -Aw7DWhcNMTcwNjIyMTQzMzExWjAUAgMPFEEXDTE3MDYyMjE0MzMxMVowFAIDDyaP -Fw0xNzA2MjIxNDMzMTFaMBQCAw9D1xcNMTcwNjIyMTQzMzExWjAUAgMPzJQXDTE3 -MDYyMjE0MzMxMVowFAIDE3pTFw0xNzA2MjIxNDMzMTFaMBQCAxN6VBcNMTcwNjIy -MTQzMzExWjAUAgMTjroXDTE3MDYyMjE0MzMxMVowFAIDFIUDFw0xNzA2MjIxNDMz -MTFaMBQCAx7XBxcNMTcwNjIyMTQzMzExWjAUAgMgFScXDTE3MDYyMjE0MzMxMVow -FAIDImufFw0xNzA2MjIxNDMzMTFaMBQCAyPpNRcNMTcwNjIyMTQzMzExWjAUAgMk -eEgXDTE3MDYyMjE0MzMxMVowDQYJKoZIhvcNAQELBQADggEBAEdGuk5OitTepMQL -O2ugSjKl9le9ttuwiNkXCowYZwMpvOvk98RuhcgqwetDtxdMIi7koMIlbILfbIwA -VYvaV7HzpOzkL9D4RpE8GN3r1xjc+pjz5RN08Q+l/pRI9VeS2Bz6sstujqDMu0kT -LEzxtyiWGgdyYL0ykirahStLxmjc0JLLSsZXHuVJGmdJsphoEw/zgTRR02N7Q0gP -AmL6+i4mXY8OMaUMFWwKikliT+VAT23H1VPPUpS/5n3p+j15Hn5bI+rHyLmO2Ca7 -0UlcBbTVhoNMO25/6js5icRktebiaI0hq3Zofd5U80tGJnH+udIUEAq6CD/wUNqq -VcdW4oc= ------END X509 CRL----- diff --git a/rooter/0optionalapps/luci-app-rootervpn/files/etc/openvpn/pia/ca.rsa.2048.crt b/rooter/0optionalapps/luci-app-rootervpn/files/etc/openvpn/pia/ca.rsa.2048.crt deleted file mode 100644 index 6deea60..0000000 --- a/rooter/0optionalapps/luci-app-rootervpn/files/etc/openvpn/pia/ca.rsa.2048.crt +++ /dev/null @@ -1,33 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIFqzCCBJOgAwIBAgIJAKZ7D5Yv87qDMA0GCSqGSIb3DQEBDQUAMIHoMQswCQYD -VQQGEwJVUzELMAkGA1UECBMCQ0ExEzARBgNVBAcTCkxvc0FuZ2VsZXMxIDAeBgNV -BAoTF1ByaXZhdGUgSW50ZXJuZXQgQWNjZXNzMSAwHgYDVQQLExdQcml2YXRlIElu -dGVybmV0IEFjY2VzczEgMB4GA1UEAxMXUHJpdmF0ZSBJbnRlcm5ldCBBY2Nlc3Mx -IDAeBgNVBCkTF1ByaXZhdGUgSW50ZXJuZXQgQWNjZXNzMS8wLQYJKoZIhvcNAQkB -FiBzZWN1cmVAcHJpdmF0ZWludGVybmV0YWNjZXNzLmNvbTAeFw0xNDA0MTcxNzM1 -MThaFw0zNDA0MTIxNzM1MThaMIHoMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0Ex -EzARBgNVBAcTCkxvc0FuZ2VsZXMxIDAeBgNVBAoTF1ByaXZhdGUgSW50ZXJuZXQg -QWNjZXNzMSAwHgYDVQQLExdQcml2YXRlIEludGVybmV0IEFjY2VzczEgMB4GA1UE -AxMXUHJpdmF0ZSBJbnRlcm5ldCBBY2Nlc3MxIDAeBgNVBCkTF1ByaXZhdGUgSW50 -ZXJuZXQgQWNjZXNzMS8wLQYJKoZIhvcNAQkBFiBzZWN1cmVAcHJpdmF0ZWludGVy -bmV0YWNjZXNzLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAPXD -L1L9tX6DGf36liA7UBTy5I869z0UVo3lImfOs/GSiFKPtInlesP65577nd7UNzzX -lH/P/CnFPdBWlLp5ze3HRBCc/Avgr5CdMRkEsySL5GHBZsx6w2cayQ2EcRhVTwWp -cdldeNO+pPr9rIgPrtXqT4SWViTQRBeGM8CDxAyTopTsobjSiYZCF9Ta1gunl0G/ -8Vfp+SXfYCC+ZzWvP+L1pFhPRqzQQ8k+wMZIovObK1s+nlwPaLyayzw9a8sUnvWB -/5rGPdIYnQWPgoNlLN9HpSmsAcw2z8DXI9pIxbr74cb3/HSfuYGOLkRqrOk6h4RC -OfuWoTrZup1uEOn+fw8CAwEAAaOCAVQwggFQMB0GA1UdDgQWBBQv63nQ/pJAt5tL -y8VJcbHe22ZOsjCCAR8GA1UdIwSCARYwggESgBQv63nQ/pJAt5tLy8VJcbHe22ZO -sqGB7qSB6zCB6DELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRMwEQYDVQQHEwpM -b3NBbmdlbGVzMSAwHgYDVQQKExdQcml2YXRlIEludGVybmV0IEFjY2VzczEgMB4G -A1UECxMXUHJpdmF0ZSBJbnRlcm5ldCBBY2Nlc3MxIDAeBgNVBAMTF1ByaXZhdGUg -SW50ZXJuZXQgQWNjZXNzMSAwHgYDVQQpExdQcml2YXRlIEludGVybmV0IEFjY2Vz -czEvMC0GCSqGSIb3DQEJARYgc2VjdXJlQHByaXZhdGVpbnRlcm5ldGFjY2Vzcy5j -b22CCQCmew+WL/O6gzAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBDQUAA4IBAQAn -a5PgrtxfwTumD4+3/SYvwoD66cB8IcK//h1mCzAduU8KgUXocLx7QgJWo9lnZ8xU -ryXvWab2usg4fqk7FPi00bED4f4qVQFVfGfPZIH9QQ7/48bPM9RyfzImZWUCenK3 -7pdw4Bvgoys2rHLHbGen7f28knT2j/cbMxd78tQc20TIObGjo8+ISTRclSTRBtyC -GohseKYpTS9himFERpUgNtefvYHbn70mIOzfOJFTVqfrptf9jXa9N8Mpy3ayfodz -1wiqdteqFXkTYoSDctgKMiZ6GdocK9nMroQipIQtpnwd4yBDWIyC6Bvlkrq5TQUt -YDQ8z9v+DMO6iwyIDRiU ------END CERTIFICATE----- diff --git a/rooter/0optionalapps/luci-app-rootervpn/files/etc/openvpn/pia/crl.rsa.2048.pem b/rooter/0optionalapps/luci-app-rootervpn/files/etc/openvpn/pia/crl.rsa.2048.pem deleted file mode 100644 index a58ef56..0000000 --- a/rooter/0optionalapps/luci-app-rootervpn/files/etc/openvpn/pia/crl.rsa.2048.pem +++ /dev/null @@ -1,15 +0,0 @@ ------BEGIN X509 CRL----- -MIICWDCCAUAwDQYJKoZIhvcNAQENBQAwgegxCzAJBgNVBAYTAlVTMQswCQYDVQQI -EwJDQTETMBEGA1UEBxMKTG9zQW5nZWxlczEgMB4GA1UEChMXUHJpdmF0ZSBJbnRl -cm5ldCBBY2Nlc3MxIDAeBgNVBAsTF1ByaXZhdGUgSW50ZXJuZXQgQWNjZXNzMSAw -HgYDVQQDExdQcml2YXRlIEludGVybmV0IEFjY2VzczEgMB4GA1UEKRMXUHJpdmF0 -ZSBJbnRlcm5ldCBBY2Nlc3MxLzAtBgkqhkiG9w0BCQEWIHNlY3VyZUBwcml2YXRl -aW50ZXJuZXRhY2Nlc3MuY29tFw0xNjA3MDgxOTAwNDZaFw0zNjA3MDMxOTAwNDZa -MCYwEQIBARcMMTYwNzA4MTkwMDQ2MBECAQYXDDE2MDcwODE5MDA0NjANBgkqhkiG -9w0BAQ0FAAOCAQEAQZo9X97ci8EcPYu/uK2HB152OZbeZCINmYyluLDOdcSvg6B5 -jI+ffKN3laDvczsG6CxmY3jNyc79XVpEYUnq4rT3FfveW1+Ralf+Vf38HdpwB8EW -B4hZlQ205+21CALLvZvR8HcPxC9KEnev1mU46wkTiov0EKc+EdRxkj5yMgv0V2Re -ze7AP+NQ9ykvDScH4eYCsmufNpIjBLhpLE2cuZZXBLcPhuRzVoU3l7A9lvzG9mjA -5YijHJGHNjlWFqyrn1CfYS6koa4TGEPngBoAziWRbDGdhEgJABHrpoaFYaL61zqy -MR6jC0K2ps9qyZAN74LEBedEfK7tBOzWMwr58A== ------END X509 CRL----- diff --git a/rooter/0optionalapps/luci-app-rootervpn/files/etc/openvpn/placeholder/placeholder.file b/rooter/0optionalapps/luci-app-rootervpn/files/etc/openvpn/placeholder/placeholder.file deleted file mode 100644 index e88efe6..0000000 --- a/rooter/0optionalapps/luci-app-rootervpn/files/etc/openvpn/placeholder/placeholder.file +++ /dev/null @@ -1,2 +0,0 @@ -placeholder file -placeholder \ No newline at end of file diff --git a/rooter/0optionalapps/luci-app-rootervpn/files/etc/openvpn/windscribe/ca.crt b/rooter/0optionalapps/luci-app-rootervpn/files/etc/openvpn/windscribe/ca.crt deleted file mode 100644 index 7edc133..0000000 --- a/rooter/0optionalapps/luci-app-rootervpn/files/etc/openvpn/windscribe/ca.crt +++ /dev/null @@ -1,34 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIF3DCCA8SgAwIBAgIJAMsOivWTmu9fMA0GCSqGSIb3DQEBCwUAMHsxCzAJBgNV -BAYTAkNBMQswCQYDVQQIDAJPTjEQMA4GA1UEBwwHVG9yb250bzEbMBkGA1UECgwS -V2luZHNjcmliZSBMaW1pdGVkMRMwEQYDVQQLDApPcGVyYXRpb25zMRswGQYDVQQD -DBJXaW5kc2NyaWJlIE5vZGUgQ0EwHhcNMTYwMzA5MDMyNjIwWhcNNDAxMDI5MDMy -NjIwWjB7MQswCQYDVQQGEwJDQTELMAkGA1UECAwCT04xEDAOBgNVBAcMB1Rvcm9u -dG8xGzAZBgNVBAoMEldpbmRzY3JpYmUgTGltaXRlZDETMBEGA1UECwwKT3BlcmF0 -aW9uczEbMBkGA1UEAwwSV2luZHNjcmliZSBOb2RlIENBMIICIjANBgkqhkiG9w0B -AQEFAAOCAg8AMIICCgKCAgEAruBtLR1Vufd71LeQEqChgHS4AQJ0fSRner0gmZPE -r2TL5uWboOEWXFFoEUTthF+P/N8yy3xRZ8HhG/zKlmJ1xw+7KZRbTADD6shJPj3/ -uvTIO80sU+9LmsyKSWuPhQ1NkgNA7rrMTfz9eHJ2MVDs4XCpYWyX9iuAQrHSY6aP -q+4TpCbUgprkM3Gwjh9RSt9IoDoc4CF2bWSaVepUcL9yz/SXLPzFx2OT9rFrDhL3 -ryHRzJQ/tA+VD8A7lo8bhOcDqiXgEFmVOZNMLw+r167Qq1Ck7X86yr2mnW/6HK2g -JOvY0/SPKukfGJAiYZKdG+fe4ekyYcAVhDfPJg7rF9wUqPwUzejJyAs1K18JwX94 -Y8fnD6vQobjpC3qfHtwQP7Uj2AcI6QC8ytWDegV6UIkHXAMXBQSX5suSQoE11deG -32cy7nyp5vhgy31rTyNoopqlcCAhPm6k0jVVQbvXhLcpTSL8iCCoMdrP28i/xsfv -ktBAkl5giHMdK6hxqWgPI+Bx9uPIhRp3fJ2z8AgFm8g1ARB2ZzQ+OZZ2RUIkJuUK -hi2kUhgKSAQ+eF89aoqDjp/J1miZqGRzt4DovSZfQOeL01RkKHEibAPYCfgHG2ZS -woLoeaxE2vNZiX4dpXiOQYTOIXOwEPZzPvfTQf9T4Kxvx3jzQnt3PzjlMCqKk3Ai -pm8CAwEAAaNjMGEwHQYDVR0OBBYEFEH2v9F2z938Ebngsj9RkVSSgs45MB8GA1Ud -IwQYMBaAFEH2v9F2z938Ebngsj9RkVSSgs45MA8GA1UdEwEB/wQFMAMBAf8wDgYD -VR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBCwUAA4ICAQAgI6NgYkVo5rB6yKStgHjj -ZsINsgEvoMuHwkM0YaV22XtKNiHdsiOmY/PGCRemFobTEHk5XHcvcOTWv/D1qVf8 -fI21WAoNQVH7h8KEsr4uMGKCB6Lu8l6xALXRMjo1xb6JKBWXwIAzUu691rUD2exT -1E+A5t+xw+gzqV8rWTMIoUaH7O1EKjN6ryGW71Khiik8/ETrP3YT32ZbS2P902iM -Kw9rpmuS0wWhnO5k/iO/6YNA1ZMV5JG5oZvZQYEDk7enLD9HvqazofMuy/Sz/n62 -ZCDdQsnabzxl04wwv5Y3JZbV/6bOM520GgdJEoDxviY05ax2Mz05otyBzrAVjFw9 -RZt/Ls8ATifu9BusZ2ootvscdIuE3x+ZCl5lvANcFEnvgGw0qpCeASLpsfxwq1dR -gIn7BOiTauFv4eoeFAQvCD+l+EKGWKu3M2y19DgYX94N2+Xs2bwChroaO5e4iFem -MLMuWKZvYgnqS9OAtRSYWbNX/wliiPz7u13yj+qSWgMfu8WPYNQlMZJXuGWUvKLE -XCUExlu7/o8D4HpsVs30E0pUdaqN0vExB1KegxPWWrmLcYnPG3knXpkC3ZBZ5P/e -l/2eyhZRy9ydiITF8gM3L08E8aeqvzZMw2FDSmousydIzlXgeS5VuEf+lUFA2h8o -ZYGQgrLt+ot8MbLhJlkp4Q== ------END CERTIFICATE----- \ No newline at end of file diff --git a/rooter/0optionalapps/luci-app-rootervpn/files/etc/openvpn/windscribe/ta.key b/rooter/0optionalapps/luci-app-rootervpn/files/etc/openvpn/windscribe/ta.key deleted file mode 100644 index dd556ac..0000000 --- a/rooter/0optionalapps/luci-app-rootervpn/files/etc/openvpn/windscribe/ta.key +++ /dev/null @@ -1,18 +0,0 @@ ------BEGIN OpenVPN Static key V1----- -5801926a57ac2ce27e3dfd1dd6ef8204 -2d82bd4f3f0021296f57734f6f1ea714 -a6623845541c4b0c3dea0a050fe6746c -b66dfab14cda27e5ae09d7c155aa554f -399fa4a863f0e8c1af787e5c602a801d -3a2ec41e395a978d56729457fe6102d7 -d9e9119aa83643210b33c678f9d4109e -3154ac9c759e490cb309b319cf708cae -83ddadc3060a7a26564d1a24411cd552 -fe6620ea16b755697a4fc5e6e9d0cfc0 -c5c4a1874685429046a424c026db672e -4c2c492898052ba59128d46200b40f88 -0027a8b6610a4d559bdc9346d33a0a6b -08e75c7fd43192b162bfd0aef0c716b3 -1584827693f676f9a5047123466f0654 -eade34972586b31c6ce7e395f4b478cb ------END OpenVPN Static key V1----- \ No newline at end of file diff --git a/rooter/0optionalapps/luci-app-rootervpn/files/lib/upgrade/keep.d/rootervpn b/rooter/0optionalapps/luci-app-rootervpn/files/lib/upgrade/keep.d/rootervpn deleted file mode 100644 index 30f20da..0000000 --- a/rooter/0optionalapps/luci-app-rootervpn/files/lib/upgrade/keep.d/rootervpn +++ /dev/null @@ -1 +0,0 @@ -/etc/openvpn/* diff --git a/rooter/0optionalapps/luci-app-rootervpn/files/usr/bin/ovpn-userpass b/rooter/0optionalapps/luci-app-rootervpn/files/usr/bin/ovpn-userpass deleted file mode 100644 index 615c85c..0000000 --- a/rooter/0optionalapps/luci-app-rootervpn/files/usr/bin/ovpn-userpass +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh - -log() { - logger -t "UserPass : " "$@" -} - -conf="/etc/openvpn/ovpnauth.conf" - -userpass=`cat $1` -username=`echo $userpass | awk '{print $1}'` -password=`echo $userpass | awk '{print $2}'` - -log "$username $password" - - -exit 0 \ No newline at end of file diff --git a/rooter/0optionalapps/luci-app-rootervpn/files/usr/bin/rkillall b/rooter/0optionalapps/luci-app-rootervpn/files/usr/bin/rkillall deleted file mode 100644 index 3802082..0000000 --- a/rooter/0optionalapps/luci-app-rootervpn/files/usr/bin/rkillall +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -LOOKFOR=$1 -KILLLIST=$(ps | grep $LOOKFOR) -echo "$KILLLIST" | while read line; do - if `echo "$line" | grep "/$LOOKFOR" > /dev/null` ; then - PIDV=$(echo $line | grep -o "^[0-9]\{1,5\}" | grep -o "[0-9]\{1,5\}") - kill $PIDV - fi -done \ No newline at end of file diff --git a/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/easyrsa/dns.sh b/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/easyrsa/dns.sh deleted file mode 100644 index b461228..0000000 --- a/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/easyrsa/dns.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/sh - -log() { - logger -t "Firewall Settings : " "$@" -} - -sleep 5 -LANOPENDNS=$(uci get openvpn.settings.lanopendns) -if [ -z $LANOPENDNS ]; then - LANOPENDNS="0" -fi -LANGOOGLE=$(uci get openvpn.settings.langoogle) -if [ -z $LANGOOGLE ]; then - LANGOOGLE="0" -fi -WANOPENDNS=$(uci get openvpn.settings.wanopendns) -if [ -z $WANOPENDNS ]; then - WANOPENDNS="0" -fi -WANGOOGLE=$(uci get openvpn.settings.wangoogle) -if [ -z $WANGOOGLE ]; then - WANGOOGLE="0" -fi - -if [ $LANOPENDNS = "1" -a $LANGOOGLE = "0" ]; then - uci del dhcp.lan.dhcp_option - uci add_list dhcp.lan.dhcp_option='6,208.67.222.222,208.67.220.220' -fi -if [ $LANOPENDNS = "0" -a $LANGOOGLE = "1" ]; then - uci del dhcp.lan.dhcp_option - uci add_list dhcp.lan.dhcp_option='6,8.8.8.8,8.8.4.4' -fi -if [ $LANOPENDNS = "1" -a $LANGOOGLE = "1" ]; then - uci del dhcp.lan.dhcp_option - uci add_list dhcp.lan.dhcp_option='6,8.8.8.8,8.8.4.4' - uci add_list dhcp.lan.dhcp_option='6,208.67.222.222,208.67.220.220' -fi -if [ $LANOPENDNS = "0" -a $LANGOOGLE = "0" ]; then - uci del dhcp.lan.dhcp_option -fi - -if [ $WANOPENDNS = "1" -a $WANGOOGLE = "0" ]; then - uci set network.wan.peerdns='0' - uci del network.wan.dns - uci add_list network.wan.dns='208.67.222.222' - uci add_list network.wan.dns='208.67.220.220' -fi -if [ $WANOPENDNS = "0" -a $WANGOOGLE = "1" ]; then - uci set network.wan.peerdns='0' - uci del network.wan.dns - uci add_list network.wan.dns='8.8.8.8' - uci add_list network.wan.dns='8.8.4.4' -fi -if [ $WANOPENDNS = "1" -a $WANGOOGLE = "1" ]; then - uci set network.wan.peerdns='0' - uci del network.wan.dns - uci add_list network.wan.dns='8.8.8.8' - uci add_list network.wan.dns='8.8.4.4' - uci add_list network.wan.dns='208.67.222.222' - uci add_list network.wan.dns='208.67.220.220' -fi -if [ $WANOPENDNS = "0" -a $WANGOOGLE = "0" ]; then - uci set network.wan.peerdns='1' - uci del network.wan.dns -fi -uci commit -/etc/init.d/network restart \ No newline at end of file diff --git a/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/easyrsa/firewall.sh b/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/easyrsa/firewall.sh deleted file mode 100644 index 3ae0752..0000000 --- a/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/easyrsa/firewall.sh +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/sh - -log() { - logger -t "Firewall Settings : " "$@" -} - -sleep 5 -VPN2LAN=$(uci get openvpn.settings.vpn2lan) -if [ -z $VPN2LAN ]; then - VPN2LAN="0" -fi -VPNS2LAN=$(uci get openvpn.settings.vpns2lan) -if [ -z $VPNS2LAN ]; then - VPNS2LAN="0" -fi -VPN2WAN=$(uci get openvpn.settings.vpn2wan) -if [ -z $VPN2WAN ]; then - VPN2WAN="0" -fi - -CHANGE="0" -if [ $VPN2LAN = "1" ]; then - WW=$(uci get firewall.vpnforward1) - if [ -z $WW ]; then - uci set firewall.vpnforward1=forwarding - uci set firewall.vpnforward1.dest="lan" - uci set firewall.vpnforward1.src="VPN" - CHANGE="1" - fi -else - WW=$(uci get firewall.vpnforward1) - if [ ! -z $WW ]; then - uci delete firewall.vpnforward1 - CHANGE="1" - fi -fi - -if [ $VPNS2LAN = "1" ]; then - WW=$(uci get firewall.vpnforwards1) - if [ -z $WW ]; then - uci set firewall.vpnforwards1=forwarding - uci set firewall.vpnforwards1.dest="lan" - uci set firewall.vpnforwards1.src="VPNS" - CHANGE="1" - fi -else - WW=$(uci get firewall.vpnforwards1) - if [ ! -z $WW ]; then - uci delete firewall.vpnforwards1 - CHANGE="1" - fi -fi - -if [ $VPN2WAN = "1" ]; then - WW=$(uci get firewall.vpnforward2) - if [ -z $WW ]; then - uci set firewall.vpnforward2=forwarding - uci set firewall.vpnforward2.dest="wan" - uci set firewall.vpnforward2.src="VPNS" - CHANGE="1" - fi -else - WW=$(uci get firewall.vpnforward2) - if [ ! -z $WW ]; then - uci delete firewall.vpnforward2 - CHANGE="1" - fi -fi - -if [ $CHANGE = "1" ]; then - uci commit firewall - /etc/init.d/firewall restart -fi \ No newline at end of file diff --git a/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/easyrsa/generate.sh b/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/easyrsa/generate.sh deleted file mode 100644 index 17e1704..0000000 --- a/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/easyrsa/generate.sh +++ /dev/null @@ -1,131 +0,0 @@ -#!/bin/sh - - rm -f /tmp/easyrsa -### Step 1: Create the PKI directory tree - PKI_DIR="/tmp/openvpn" - -# if [ -d "$PKI_DIR" ]; then - rm -rfv "$PKI_DIR" -# fi - mkdir -p ${PKI_DIR} - chmod -R 0777 ${PKI_DIR} - mkdir -p ${PKI_DIR}/client - chmod -R 0777 ${PKI_DIR}/client - mkdir -p ${PKI_DIR}/server - chmod -R 0777 ${PKI_DIR}/server - mkdir -p ${PKI_DIR}/package - chmod -R 0777 ${PKI_DIR}/package - if [ -d "/www/package" ]; then - rm -rfv "/www/package" - fi - ln -s ${PKI_DIR}/package /www/package - cd ${PKI_DIR} - - touch index.txt - echo 1000 > serial - mkdir newcerts - - -### Step 2: Start with a clean configuration, and establish the basic variables - cp /etc/ssl/openssl.cnf ${PKI_DIR} - PKI_CNF=${PKI_DIR}/openssl.cnf - - CNT=$(uci get openvpn.settings.country) - CTY=$(uci get openvpn.settings.city) - ORG=$(uci get openvpn.settings.organ) - DAYS=$(uci get openvpn.settings.days) - CNAME=$(uci get openvpn.settings.comm) - EMAIL=$(uci get openvpn.settings.email) - UNIT=$(uci get openvpn.settings.unit) - UNSTRUC=$(uci get openvpn.settings.unstruc) - NCLIENT=$(uci get openvpn.settings.nclient) - if [ -z $NCLIENT ]; then - NCLIENT=1 - fi - - sed -i "/^dir/ s:=.*:= ${PKI_DIR}/:" ${PKI_CNF} - sed -i '/.*Name/ s:= match:= optional:' ${PKI_CNF} - - sed -i "/organizationName_default/ s:= .*:= $ORG:" ${PKI_CNF} - sed -i "/stateOrProvinceName_default/ s:= .*:= $CTY:" ${PKI_CNF} - sed -i "/countryName_default/ s:= .*:= $CNT:" ${PKI_CNF} - if [ ! -z $CNAME ]; then - sed -i -e "s/commonName = Common Name (e.g. server FQDN or YOUR name)/commonName = $CNAME/g" ${PKI_CNF} - fi - if [ ! -z $EMAIL ]; then - sed -i -e "s/emailAddress = Email Address/emailAddress = $EMAIL/g" ${PKI_CNF} - fi - if [ ! -z $UNIT ]; then - sed -i -e "s/organizationalUnitName = Organizational Unit Name (eg, section)/organizationalUnitName = $UNIT/g" ${PKI_CNF} - fi - if [ ! -z $UNSTRUC ]; then - sed -i -e "s/unstructuredName = An optional company name/unstructuredName = $UNSTRUC/g" ${PKI_CNF} - fi - - sed -i "/default_days/ s:=.*:= $DAYS:" ${PKI_CNF} - sed -i "/default_bits/ s:=.*:= 2048:" ${PKI_CNF} - - -cat >> ${PKI_CNF} <<"EOF" -############################################################################### -### Check via: openssl x509 -text -noout -in *.crt | grep 509 -A 1 -[ my-server ] -# X509v3 Key Usage: Digital Signature, Key Encipherment -# X509v3 Extended Key Usage: TLS Web Server Authentication - keyUsage = digitalSignature, keyEncipherment - extendedKeyUsage = serverAuth - -[ my-client ] -# X509v3 Key Usage: Digital Signature -# X509v3 Extended Key Usage: TLS Web Client Authentication - keyUsage = digitalSignature - extendedKeyUsage = clientAuth - -EOF - - echo "1" > /tmp/easyrsa - -### Step 3a: Create the CA, Server, and Client certificates (*without* using easy-rsa): -# pkitool --initca ## equivalent to the 'build-ca' script - openssl req -batch -nodes -new -keyout "ca.key" -out "ca.crt" -x509 -days $DAYS -config ${PKI_CNF} 2> /dev/null ## x509 (self-signed) for the CA - - echo "2" > /tmp/easyrsa -# pkitool --server my-server ## equivalent to the 'build-key-server' script - openssl req -batch -nodes -new -keyout "$ORG-server.key" -out "$ORG-server.csr" -subj "/CN=$ORG-server" -config ${PKI_CNF} 2> /dev/null - openssl ca -batch -keyfile "ca.key" -cert "ca.crt" -in "$ORG-server.csr" -out "$ORG-server.crt" -config ${PKI_CNF} -extensions my-server 2> /dev/null - - echo "3" > /tmp/easyrsa -# pkitool my-client ## equivalent to the 'build-key' script - COUNTER=$NCLIENT - while [ $COUNTER -gt 0 ]; do - openssl req -batch -nodes -new -keyout "$ORG-client$COUNTER.key" -out "$ORG-client$COUNTER.csr" -subj "/CN=$ORG-client$COUNTER" -config ${PKI_CNF} 2> /dev/null - openssl ca -batch -keyfile "ca.key" -cert "ca.crt" -in "$ORG-client$COUNTER.csr" -out "$ORG-client$COUNTER.crt" -config ${PKI_CNF} -extensions my-client 2> /dev/null - let COUNTER=COUNTER-1 - done - - chmod 0600 "ca.key" - chmod 0600 "$ORG-server.key" - COUNTER=$NCLIENT - while [ $COUNTER -gt 0 ]; do - chmod 0600 "$ORG-client$COUNTER.key" - cp "$ORG-client$COUNTER.crt" ${PKI_DIR}/client - cp "$ORG-client$COUNTER.key" ${PKI_DIR}/client - let COUNTER=COUNTER-1 - done - - cp "ca.crt" ${PKI_DIR}/client - cp "ca.crt" ${PKI_DIR}/server - cp "$ORG-server.key" ${PKI_DIR}/server - cp "$ORG-server.crt" ${PKI_DIR}/server - - echo "4" > /tmp/easyrsa -### Step 4: Create the Diffie-Hellman parameters - openssl dhparam -out dh2048.pem 2048 2> /dev/null - cp "dh2048.pem" ${PKI_DIR}/server - - echo "5" > /tmp/easyrsa - - - tar -czf ${PKI_DIR}/package/certificates.tar.gz ./client ./server - sleep 7 - echo "6" > /tmp/easyrsa \ No newline at end of file diff --git a/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/easyrsa/stop.sh b/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/easyrsa/stop.sh deleted file mode 100644 index e9088c9..0000000 --- a/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/easyrsa/stop.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -result=`ps | grep -i "generate.sh" | grep -v "grep" | wc -l` -if [ $result -ge 1 ]; then - rkillall generate.sh - rm -f /tmp/easyrsa - PKI_DIR="/etc/openvpn/ssl" - if [ -d "$PKI_DIR" ]; then - rm -rfv "$PKI_DIR" - fi -fi \ No newline at end of file diff --git a/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/easyrsa/vpn.sh b/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/easyrsa/vpn.sh deleted file mode 100644 index e99b9b9..0000000 --- a/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/easyrsa/vpn.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -log() { - logger -t "OpenVpn Vpn" "$@" -} - -/etc/init.d/openvpn stop $1 -sleep 5 - diff --git a/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/easyrsa/vpng.sh b/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/easyrsa/vpng.sh deleted file mode 100644 index 8b34078..0000000 --- a/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/easyrsa/vpng.sh +++ /dev/null @@ -1,128 +0,0 @@ -#!/bin/sh -. /lib/functions.sh - -convert() { - secs=$1 - csec=$(printf "%02d:%02d:%02d" $(($secs/3600)) $(($secs%3600/60)) $(($secs%60))) -} - -clist() { - SDIR="/tmp/run" - - STAT=$SDIR"/openvpn."$1".status" - - COUNT=0 - RT=0 - TT="Virtual Address Common Name Real Address" - while read -r line; do - name="$line" - RTT=$(echo "$name" | grep "Virtual Address") - if [ ! -z "$RTT" ]; then - RT=1 - fi - RTT=$(echo "$name" | grep "GLOBAL STATS") - if [ ! -z "$RTT" ]; then - RT=0 - fi - if [ $RT = 1 ]; then - if [ $COUNT -gt 0 ]; then - vip=$(echo "$name" | cut -d, -f1) - com=$(echo "$name" | cut -d, -f2) - rel=$(echo "$name" | cut -d, -f3) - TT="$TT $vip $com $rel" - fi - let COUNT=COUNT+1 - fi - done < "$STAT" - if [ $COUNT -le 1 ]; then - TT="No clients" - COUNT=0 - else - let COUNT=COUNT-1 - fi -} - -rm -f /tmp/vpn - -vpn_instance() { - local s="$1" - echo "$s " >> /tmp/vpn - config_get config "$s" config - if [ -z $config ]; then - config_get_bool client "$s" client 0 - else - client=1 - fi - echo "$client" >> /tmp/vpn - config_get_bool enabled "$s" 'enabled' 0 - echo "$enabled" >> /tmp/vpn - - result=`ps | grep -i "/usr/sbin/openvpn --syslog openvpn($s)" | grep -v "grep" | wc -l` - if [ $result -ge 1 ] - then - echo "1" >> /tmp/vpn - else - echo "0" >> /tmp/vpn - fi - - if [ -z $config ]; then - config_get port "$s" port - if [ -z $port ]; then - echo "1194" >> /tmp/vpn - else - echo "$port" >> /tmp/vpn - fi - config_get proto "$s" proto - if [ -z $proto ]; then - echo "udp" >> /tmp/vpn - else - echo "$proto" >> /tmp/vpn - fi - else - prott=$(cat "$config" | grep -i "proto " | tr " " ",") - prot=$(echo "$prott" | cut -d, -f2) - remtt=$(cat "$config" | grep -i -m 1 "remote " | tr " " ",") - remt=$(echo "$remtt" | cut -d, -f3) - echo "$remt" >> /tmp/vpn - echo "$prot" >> /tmp/vpn - fi - if [ $client = "0" ]; then - echo "---" >> /tmp/vpn - if [ $result -ge 1 ]; then - clist $s - echo "$COUNT" >> /tmp/vpn - echo "$TT" >> /tmp/vpn - else - echo "0" >> /tmp/vpn - echo "Not running" >> /tmp/vpn - fi - else - if [ -z $config ]; then - config_get remote "$s" remote - echo "$remote" >> /tmp/vpn - else - remtt=$(cat "$config" | grep -i -m 1 "remote " | tr " " ",") - remt=$(echo "$remtt" | cut -d, -f2) - echo "$remt" >> /tmp/vpn - fi - echo "---" >> /tmp/vpn - echo "not server" >> /tmp/vpn - fi - if [ $result -ge 1 ] - then - config_get laststart "$s" laststart - CURRTIME=$(date +%s) - let upt=CURRTIME-laststart - convert $upt - upt=$csec - else - upt="---" - fi - echo "$upt" >> /tmp/vpn -} - -config_load 'openvpn' -config_foreach vpn_instance 'openvpn' - -exit 0 - diff --git a/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/lua/luci/controller/openvpn.lua b/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/lua/luci/controller/openvpn.lua deleted file mode 100644 index 80dbf89..0000000 --- a/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/lua/luci/controller/openvpn.lua +++ /dev/null @@ -1,135 +0,0 @@ --- Copyright 2008 Steven Barth --- Copyright 2008 Jo-Philipp Wich --- Licensed to the public under the Apache License 2.0. - -module("luci.controller.openvpn", package.seeall) - -I18N = require "luci.i18n" -translate = I18N.translate - -function index() - local multilock = luci.model.uci.cursor():get("custom", "multiuser", "multi") or "0" - local rootlock = luci.model.uci.cursor():get("custom", "multiuser", "root") or "0" - if (multilock == "0") or (multilock == "1" and rootlock == "1") then - entry({"admin", "vpn"}, firstchild(), translate("VPN"), 30).dependent=false - entry( {"admin", "vpn", "openvpn"}, cbi("openvpn"), _(translate("OpenVPN")), 1 ) - entry( {"admin", "vpn", "openvpn-server"}, cbi("openvpn-server"), _(translate("--OpenVPN Extras")), 2 ) - - entry( {"admin", "vpn", "openvpn", "basic"}, cbi("openvpn-basic"), nil ).leaf = true - entry( {"admin", "vpn", "openvpn", "advanced"}, cbi("openvpn-advanced"), nil ).leaf = true - entry( {"admin", "vpn", "openvpn", "file"}, form("openvpn-file"), nil ).leaf = true - entry( {"admin", "vpn", "openvpn", "upload"}, call("ovpn_upload")) - end - - entry({"admin", "vpn", "vpnstatus"}, call("action_vpnstatus")) - entry({"admin", "vpn", "rsastatus"}, call("action_status")) - entry({"admin", "vpn", "rsagenerate"}, call("action_generate")) - entry({"admin", "vpn", "rsastop"}, call("action_stop")) -end - -function ovpn_upload() - local fs = require("nixio.fs") - local http = require("luci.http") - local util = require("luci.util") - local uci = require("luci.model.uci").cursor() - local upload = http.formvalue("ovpn_file") - local name = http.formvalue("instance_name2") - local file = "/etc/openvpn/" ..name.. ".ovpn" - - if name and upload then - local fp - - http.setfilehandler( - function(meta, chunk, eof) - local data = util.trim(chunk:gsub("\r\n", "\n")) .. "\n" - data = util.trim(data:gsub("[\128-\255]", "")) - - if not fp and meta and meta.name == "ovpn_file" then - fp = io.open(file, "w") - end - if fp and data then - fp:write(data) - end - if fp and eof then - fp:close() - end - end - ) - - if fs.access(file) then - if not uci:get_first("openvpn", name) then - uci:set("openvpn", name, "openvpn") - uci:set("openvpn", name, "config", file) - uci:save("openvpn") - uci:commit("openvpn") - end - end - end - http.redirect(luci.dispatcher.build_url('admin/vpn/openvpn')) -end - -function action_status() - local rv = {} - - file = io.open("/tmp/easyrsa", "r") - if file ~= nil then - rv["status"] = file:read("*line") - file:close() - else - rv["status"] = "0" - end - - luci.http.prepare_content("application/json") - luci.http.write_json(rv) -end - -function action_generate() - os.execute("/usr/lib/easyrsa/generate.sh &") -end - -function action_stop() - os.execute("/usr/lib/easyrsa/stop.sh") -end - -function action_vpnstatus() - local rv ={} - - os.execute("/usr/lib/easyrsa/vpng.sh") - local file = io.open("/tmp/vpn", "r") - if file ~= nil then - i = 0 - name = file:read("*line") - while name ~= nil do - vpntype = file:read("*line") - enabled = file:read("*line") - started = file:read("*line") - port = file:read("*line") - proto = file:read("*line") - remote = file:read("*line") - clients = file:read("*line") - tooltip = file:read("*line") - laststart = file:read("*line") - rv[#rv+1] = { - name = name, - vpntype = vpntype, - enabled = enabled, - started = started, - port = port, - proto = proto, - remote = remote, - clients = clients, - tooltip = tooltip, - laststart = laststart - } - name = file:read("*line") - end - file:close() - else - rv[#rv+1] = { - enabled = "-1", - } - end - - luci.http.prepare_content("application/json") - luci.http.write_json(rv) -end \ No newline at end of file diff --git a/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/lua/luci/model/cbi/openvpn-advanced.lua b/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/lua/luci/model/cbi/openvpn-advanced.lua deleted file mode 100644 index a79288d..0000000 --- a/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/lua/luci/model/cbi/openvpn-advanced.lua +++ /dev/null @@ -1,902 +0,0 @@ --- Copyright 2008 Steven Barth --- Licensed to the public under the Apache License 2.0. - -local fs = require("nixio.fs") - -local knownParams = { - -- - --Widget - -- Name - -- Default(s) - -- Description - -- Option(s) - - { "Service", { - -- initialisation and daemon options - { ListValue, - "verb", - { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }, - translate("Set output verbosity") }, - { Flag, - "mlock", - 0, - translate("Disable Paging") }, - { Flag, - "disable_occ", - 0, - translate("Disable options consistency check") }, - -- { Value, - -- "user", - -- "root", - -- translate("Set UID to user") }, - -- { Value, - -- "group", - -- "root", - -- translate("Set GID to group") }, - { Value, - "cd", - "/etc/openvpn", - translate("Change to directory before initialization") }, - { Value, - "chroot", - "/var/run", - translate("Chroot to directory after initialization") }, - -- { Value, - -- "daemon", - -- "Instance-Name", - -- translate("Daemonize after initialization") }, - -- { Value, - -- "syslog", - -- "Instance-Name", - -- translate("Output to syslog and do not daemonize") }, - { Flag, - "passtos", - 0, - translate("TOS passthrough (applies to IPv4 only)") }, - -- { Value, - -- "inetd", - -- "nowait Instance-Name", - -- translate("Run as an inetd or xinetd server") }, - { Value, - "log", - "/var/log/openvpn.log", - translate("Write log to file") }, - { Value, - "log_append", - "/var/log/openvpn.log", - translate("Append log to file") }, - { Flag, - "suppress_timestamps", - 0, - translate("Don't log timestamps") }, - -- { Value, - -- "writepid", - -- "/var/run/openvpn.pid", - -- translate("Write process ID to file") }, - { Value, - "nice", - 0, - translate("Change process priority") }, - { Flag, - "fast_io", - 0, - translate("Optimize TUN/TAP/UDP writes") }, - { Value, - "echo", - "some params echoed to log", - translate("Echo parameters to log") }, - { ListValue, - "remap_usr1", - { "SIGHUP", "SIGTERM" }, - translate("Remap SIGUSR1 signals") }, - { Value, - "status", - "/var/run/openvpn.status 5", - translate("Write status to file every n seconds") }, - { Value, - "status_version", - { 1, 2 }, - translate("Status file format version") }, -- status - { Value, - "mute", - 5, - translate("Limit repeated log messages") }, - { Value, - "up", - "/usr/bin/ovpn-up", - translate("Shell cmd to execute after tun device open") }, - { Value, - "up_delay", - 5, - translate("Delay tun/tap open and up script execution") }, - { Value, - "down", - "/usr/bin/ovpn-down", - translate("Shell cmd to run after tun device close") }, - { Flag, - "down_pre", - 0, - translate("Call down cmd/script before TUN/TAP close") }, - { Flag, - "up_restart", - 0, - translate("Run up/down scripts for all restarts") }, - { Value, - "route_up", - "/usr/bin/ovpn-routeup", - translate("Execute shell cmd after routes are added") }, - { Value, - "ipchange", - "/usr/bin/ovpn-ipchange", - translate("Execute shell command on remote ip change"), - { mode="p2p" } }, - { DynamicList, - "setenv", - { "VAR1 value1", "VAR2 value2" }, - translate("Pass environment variables to script") }, - { Value, - "tls_verify", - "/usr/bin/ovpn-tlsverify", - translate("Shell command to verify X509 name") }, - { Value, - "client_connect", - "/usr/bin/ovpn-clientconnect", - translate("Run script cmd on client connection") }, - { Value, - "client_disconnect", - "/usr/bin/ovpn-clientdisconnect", - translate("Run script cmd on client disconnection") }, - { Value, - "learn_address", - "/usr/bin/ovpn-learnaddress", - translate("Executed in server mode whenever an IPv4 address/route or MAC address is added to OpenVPN's internal routing table") }, - { Value, - "auth_user_pass_verify", - "/usr/bin/ovpn-userpass via-env", - translate("Executed in server mode on new client connections, when the client is still untrusted") }, - { ListValue, - "script_security", - { 0, 1, 2, 3 }, - translate("Policy level over usage of external programs and scripts") }, - { ListValue, - "compress", - { "lzo", "lz4" }, - translate("Enable a compression algorithm") }, - } }, - - { "Networking", { - -- socket config - { ListValue, - "mode", - { "p2p", "server" }, - translate("Major mode") }, - { Value, - "local", - "0.0.0.0", - translate("Local host name or ip address") }, - { Value, - "port", - 1194, - translate("TCP/UDP port # for both local and remote") }, - { Value, - "lport", - 1194, - translate("TCP/UDP port # for local (default=1194)") }, - { Value, - "rport", - 1194, - translate("TCP/UDP port # for remote (default=1194)") }, - { Flag, - "float", - 0, - translate("Allow remote to change its IP or port") }, - { Flag, - "nobind", - 0, - translate("Do not bind to local address and port") }, - { Value, - "dev", - "tun0", - translate("tun/tap device") }, - { ListValue, - "dev_type", - { "tun", "tap" }, - translate("Type of used device") }, - { Value, - "dev_node", - "/dev/net/tun", - translate("Use tun/tap device node") }, - { Value, - "ifconfig", - "10.200.200.3 10.200.200.1", - translate("Set tun/tap adapter parameters") }, - { Flag, - "ifconfig_noexec", - 0, - translate("Don't actually execute ifconfig") }, - { Flag, - "ifconfig_nowarn", - 0, - translate("Don't warn on ifconfig inconsistencies") }, - { DynamicList, - "route", - "10.123.0.0 255.255.0.0", - translate("Add route after establishing connection") }, - { Value, - "route_gateway", - "10.234.1.1", - translate("Specify a default gateway for routes") }, - { Value, - "route_delay", - 0, - translate("Delay n seconds after connection") }, - { Flag, - "route_noexec", - 0, - translate("Don't add routes automatically") }, - { Flag, - "route_nopull", - 0, - translate("Don't pull routes automatically") }, - { Flag, - "allow_recursive_routing", - 0, - translate("Don't drop incoming tun packets with same destination as host") }, - { ListValue, - "mtu_disc", - { "yes", "maybe", "no" }, - translate("Enable Path MTU discovery") }, - { Flag, - "mtu_test", - 0, - translate("Empirically measure MTU") }, - { ListValue, - "comp_lzo", - { "yes", "no", "adaptive" }, - translate("Use fast LZO compression") }, - { Flag, - "comp_noadapt", - 0, - translate("Don't use adaptive lzo compression"), - { comp_lzo=1 } }, - { Value, - "link_mtu", - 1500, - translate("Set TCP/UDP MTU") }, - { Value, - "tun_mtu", - 1500, - translate("Set tun/tap device MTU") }, - { Value, - "tun_mtu_extra", - 1500, - translate("Set tun/tap device overhead") }, - { Value, - "fragment", - 1500, - translate("Enable internal datagram fragmentation"), - { proto="udp" } }, - { Value, - "mssfix", - 1500, - translate("Set upper bound on TCP MSS"), - { proto="udp" } }, - { Value, - "sndbuf", - 65536, - translate("Set the TCP/UDP send buffer size") }, - { Value, - "rcvbuf", - 65536, - translate("Set the TCP/UDP receive buffer size") }, - { Value, - "txqueuelen", - 100, - translate("Set tun/tap TX queue length") }, - { Value, - "shaper", - 10240, - translate("Shaping for peer bandwidth") }, - { Value, - "inactive", - 240, - translate("tun/tap inactivity timeout") }, - { Value, - "keepalive", - "10 60", - translate("Helper directive to simplify the expression of --ping and --ping-restart in server mode configurations") }, - { Value, - "ping", - 30, - translate("Ping remote every n seconds over TCP/UDP port") }, - { Value, - "ping_exit", - 120, - translate("Remote ping timeout") }, - { Value, - "ping_restart", - 60, - translate("Restart after remote ping timeout") }, - { Flag, - "ping_timer_rem", - 0, - translate("Only process ping timeouts if routes exist") }, - { Flag, - "persist_tun", - 0, - translate("Keep tun/tap device open on restart") }, - { Flag, - "persist_key", - 0, - translate("Don't re-read key on restart") }, - { Flag, - "persist_local_ip", - 0, - translate("Keep local IP address on restart") }, - { Flag, - "persist_remote_ip", - 0, - translate("Keep remote IP address on restart") }, - -- management channel - { Value, - "management", - "127.0.0.1 31194 /etc/openvpn/mngmt-pwds", - translate("Enable management interface on IP port") }, - -- management - { Flag, - "management_query_passwords", - 0, - translate("Query management channel for private key") }, - -- management - { Flag, - "management_hold", - 0, - translate("Start OpenVPN in a hibernating state") }, - -- management - { Value, - "management_log_cache", - 100, - translate("Number of lines for log file history") }, - { ListValue, - "topology", - { "net30", "p2p", "subnet" }, - translate("'net30', 'p2p', or 'subnet'"), - {dev_type="tun" } }, - } }, - - { "VPN", { - { Value, - "server", - "10.200.200.0 255.255.255.0", - translate("Configure server mode"), - { client="0" }, { client="" } }, - { Value, - "server_bridge", - "10.200.200.1 255.255.255.0 10.200.200.200 10.200.200.250", - translate("Configure server bridge"), - { client="0" }, { client="" } }, - { DynamicList, - "push", - { "redirect-gateway", "comp-lzo" }, - translate("Push options to peer"), - { client="0" }, { client="" } }, - { Flag, - "push_reset", - 0, - translate("Don't inherit global push options"), - { client="0" }, { client="" } }, - { Flag, - "disable", - 0, - translate("Client is disabled"), - { client="0" }, { client="" } }, - { Value, - "ifconfig_pool", - "10.200.200.100 10.200.200.150 255.255.255.0", - translate("Set aside a pool of subnets"), - { client="0" }, { client="" } }, - { Value, - "ifconfig_pool_persist", - "/etc/openvpn/ipp.txt 600", - translate("Persist/unpersist ifconfig-pool"), - { client="0" }, { client="" } }, - { Value, - "ifconfig_push", - "10.200.200.1 255.255.255.255", - translate("Push an ifconfig option to remote"), - { client="0" }, { client="" } }, - { Value, - "iroute", - "10.200.200.0 255.255.255.0", - translate("Route subnet to client"), - { client="0" }, { client="" } }, - { Flag, - "client_to_client", - 0, - translate("Allow client-to-client traffic"), - { client="0" }, { client="" } }, - { Flag, - "duplicate_cn", - 0, - translate("Allow multiple clients with same certificate"), - { client="0" }, { client="" } }, - { Value, - "client_config_dir", - "/etc/openvpn/ccd", - translate("Directory for custom client config files"), - { client="0" }, { client="" } }, - { Flag, - "ccd_exclusive", - 0, - translate("Refuse connection if no custom client config"), - { client="0" }, { client="" } }, - { Value, - "tmp_dir", - "/var/run/openvpn", - translate("Temporary directory for client-connect return file"), - { client="0" }, { client="" } }, - { Value, - "hash_size", - "256 256", - translate("Set size of real and virtual address hash tables"), - { client="0" }, { client="" } }, - { Value, - "bcast_buffers", - 256, - translate("Number of allocated broadcast buffers"), - { client="0" }, { client="" } }, - { Value, - "tcp_queue_limit", - 64, - translate("Maximum number of queued TCP output packets"), - { client="0" }, { client="" } }, - { Value, - "max_clients", - 10, - translate("Allowed maximum of connected clients"), - { client="0" }, { client="" } }, - { Value, - "max_routes_per_client", - 256, - translate("Allowed maximum of internal"), - { client="0" }, { client="" } }, - { Value, - "connect_freq", - "3 10", - translate("Allowed maximum of new connections"), - { client="0" }, { client="" } }, - { Flag, - "username_as_common_name", - 0, - translate("Use username as common name"), - { client="0" }, { client="" } }, - { Flag, - "client", - 0, - translate("Configure client mode") }, - { Flag, - "pull", - 0, - translate("Accept options pushed from server"), - { client="1" } }, - { FileUpload, - "auth_user_pass", - "/etc/openvpn/userpass.txt", - translate("Authenticate using username/password"), - { client="1" } }, - { ListValue, - "auth_retry", - { "none", "nointeract", "interact" }, - translate("Handling of authentication failures"), - { client="1" } }, - { Value, - "explicit_exit_notify", - 1, - translate("Send notification to peer on disconnect"), - { client="1" } }, - { DynamicList, - "remote", - "1.2.3.4", - translate("Remote host name or ip address") }, - { Flag, - "remote_random", - 0, - translate("Randomly choose remote server"), - { client="1" } }, - { ListValue, - "proto", - { "udp", "tcp-client", "tcp-server" }, - translate("Use protocol"), - { client="1" } }, - { Value, - "connect_retry", - 5, - translate("Connection retry interval"), - { proto="tcp-client" }, { client="1" } }, - { Value, - "http_proxy", - "192.168.1.100 8080", - translate("Connect to remote host through an HTTP proxy"), - { client="1" } }, - { Flag, - "http_proxy_retry", - 0, - translate("Retry indefinitely on HTTP proxy errors"), - { client="1" } }, - { Value, - "http_proxy_timeout", - 5, - translate("Proxy timeout in seconds"), - { client="1" } }, - { DynamicList, - "http_proxy_option", - { "VERSION 1.0", "AGENT OpenVPN/2.0.9" }, - translate("Set extended HTTP proxy options"), - { client="1" } }, - { Value, - "socks_proxy", - "192.168.1.200 1080", - translate("Connect through Socks5 proxy"), - { client="1" } }, - -- client && socks_proxy - { Value, - "socks_proxy_retry", - 5, - translate("Retry indefinitely on Socks proxy errors"), - { client="1" } }, - { Value, - "resolv_retry", - "infinite", - translate("If hostname resolve fails, retry"), - { client="1" } }, - { ListValue, - "redirect_gateway", - { "", "local", "def1", "local def1" }, - translate("Automatically redirect default route"), - { client="1" } }, - { Value, - "verify_client_cert", - { "none", "optional", "require" }, - translate("Specify whether the client is required to supply a valid certificate") }, - } }, - - { "Cryptography", { - { FileUpload, - "secret", - "/etc/openvpn/secret.key", - translate("Enable Static Key encryption mode (non-TLS)") }, - -- parse - { Value, - "auth", - "SHA1", - translate("HMAC authentication for packets") }, - -- parse - { Value, - "cipher", - { - "AES-128-CBC", - "AES-128-CFB", - "AES-128-CFB1", - "AES-128-CFB8", - "AES-128-GCM", - "AES-128-OFB", - "AES-192-CBC", - "AES-192-CFB", - "AES-192-CFB1", - "AES-192-CFB8", - "AES-192-GCM", - "AES-192-OFB", - "AES-256-CBC", - "AES-256-CFB", - "AES-256-CFB1", - "AES-256-CFB8", - "AES-256-GCM", - "AES-256-OFB", - "BF-CBC", - "BF-CFB", - "BF-OFB", - "CAST5-CBC", - "CAST5-CFB", - "CAST5-OFB", - "DES-CBC", - "DES-CFB", - "DES-CFB1", - "DES-CFB8", - "DES-EDE-CBC", - "DES-EDE-CFB", - "DES-EDE-OFB", - "DES-EDE3-CBC", - "DES-EDE3-CFB", - "DES-EDE3-CFB1", - "DES-EDE3-CFB8", - "DES-EDE3-OFB", - "DES-OFB", - "DESX-CBC", - "RC2-40-CBC", - "RC2-64-CBC", - "RC2-CBC", - "RC2-CFB", - "RC2-OFB" - }, - translate("Encryption cipher for packets") }, - -- parse - { Value, - "keysize", - 1024, - translate("Size of cipher key") }, - -- parse - { Value, - "engine", - "dynamic", - translate("Enable OpenSSL hardware crypto engines") }, - { Value, - "replay_window", - "64 15", - translate("Replay protection sliding window size") }, - { Flag, - "mute_replay_warnings", - 0, - translate("Silence the output of replay warnings") }, - { Value, - "replay_persist", - "/var/run/openvpn-replay-state", - translate("Persist replay-protection state") }, - { Flag, - "tls_server", - 0, - translate("Enable TLS and assume server role"), - { tls_client="" }, { tls_client="0" } }, - { Flag, - "tls_client", - 0, - translate("Enable TLS and assume client role"), - { tls_server="" }, { tls_server="0" } }, - { FileUpload, - "ca", - "/etc/easy-rsa/keys/ca.crt", - translate("Certificate authority") }, - { FileUpload, - "dh", - "/etc/easy-rsa/keys/dh1024.pem", - translate("Diffie Hellman parameters") }, - { FileUpload, - "cert", - "/etc/easy-rsa/keys/some-client.crt", - translate("Local certificate") }, - { FileUpload, - "key", - "/etc/easy-rsa/keys/some-client.key", - translate("Local private key") }, - { FileUpload, - "pkcs12", - "/etc/easy-rsa/keys/some-client.pk12", - translate("PKCS#12 file containing keys") }, - { ListValue, - "key_method", - { 1, 2 }, - translate("Enable TLS and assume client role") }, - { DynamicList, - "tls_cipher", - { - "DHE-RSA-AES256-SHA", - "DHE-DSS-AES256-SHA", - "AES256-SHA", - "EDH-RSA-DES-CBC3-SHA", - "EDH-DSS-DES-CBC3-SHA", - "DES-CBC3-SHA", - "DHE-RSA-AES128-SHA", - "DHE-DSS-AES128-SHA", - "AES128-SHA", - "RC4-SHA", - "RC4-MD5", - "EDH-RSA-DES-CBC-SHA", - "EDH-DSS-DES-CBC-SHA", - "DES-CBC-SHA", - "EXP-EDH-RSA-DES-CBC-SHA", - "EXP-EDH-DSS-DES-CBC-SHA", - "EXP-DES-CBC-SHA", - "EXP-RC2-CBC-MD5", - "EXP-RC4-MD5" - }, - translate("TLS cipher") }, - { DynamicList, - "tls_ciphersuites", - { - "TLS_AES_256_GCM_SHA384", - "TLS_AES_128_GCM_SHA256", - "TLS_CHACHA20_POLY1305_SHA256" - }, - translate("TLS 1.3 or newer cipher") }, - { Value, - "tls_timeout", - 2, - translate("Retransmit timeout on TLS control channel") }, - { Value, - "reneg_bytes", - 1024, - translate("Renegotiate data chan. key after bytes") }, - { Value, - "reneg_pkts", - 100, - translate("Renegotiate data chan. key after packets") }, - { Value, - "reneg_sec", - 3600, - translate("Renegotiate data chan. key after seconds") }, - { Value, - "hand_window", - 60, - translate("Timeframe for key exchange") }, - { Value, - "tran_window", - 3600, - translate("Key transition window") }, - { Flag, - "single_session", - 0, - translate("Allow only one session") }, - { Flag, - "tls_exit", - 0, - translate("Exit on TLS negotiation failure") }, - { Value, - "tls_auth", - "/etc/openvpn/tlsauth.key", - translate("Additional authentication over TLS") }, - { Value, - "tls_crypt", - "/etc/openvpn/tlscrypt.key", - translate("Encrypt and authenticate all control channel packets with the key") }, - -- { Value, - -- "askpass", - -- "[file]", - -- translate("Get PEM password from controlling tty before we daemonize") }, - { Flag, - "auth_nocache", - 0, - translate("Don't cache --askpass or --auth-user-pass passwords") }, - { Value, - "tls_remote", - "remote_x509_name", - translate("Only accept connections from given X509 name") }, - { ListValue, - "ns_cert_type", - { "client", "server" }, - translate("Require explicit designation on certificate") }, - { ListValue, - "remote_cert_tls", - { "client", "server" }, - translate("Require explicit key usage on certificate") }, - { Value, - "crl_verify", - "/etc/easy-rsa/keys/crl.pem", - translate("Check peer certificate against a CRL") }, - { Value, - "tls_version_min", - "1.0", - translate("The lowest supported TLS version") }, - { Value, - "tls_version_max", - "1.2", - translate("The highest supported TLS version") }, - { ListValue, - "key_direction", - { 0, 1 }, - translate("The key direction for 'tls-auth' and 'secret' options") }, - { Flag, - "ncp_disable", - 0, - translate("This completely disables cipher negotiation") }, - { Value, - "ncp_ciphers", - "AES-256-GCM:AES-128-GCM", - translate("Restrict the allowed ciphers to be negotiated") }, - } } -} - - -local cts = { } -local params = { } - -local m = Map("openvpn") -m.redirect = luci.dispatcher.build_url("admin", "vpn", "openvpn") -m.apply_on_parse = true - -local p = m:section( SimpleSection ) -p.template = "openvpn/pageswitch" -p.mode = "advanced" -p.instance = arg[1] -p.category = arg[2] or "Service" - -for _, c in ipairs(knownParams) do - cts[#cts+1] = c[1] - if c[1] == p.category then params = c[2] end -end - -p.categories = cts - - -local s = m:section( - NamedSection, arg[1], "openvpn", - translate("%s" % arg[2]) -) - -s.title = translate("%s" % arg[2]) -s.addremove = false -s.anonymous = true - - -for _, option in ipairs(params) do - local o = s:option( - option[1], option[2], - option[2], option[4] - ) - - o.optional = true - - if option[1] == DummyValue then - o.value = option[3] - elseif option[1] == FileUpload then - - o.initial_directory = "/etc/openvpn" - - function o.cfgvalue(self, section) - local cfg_val = AbstractValue.cfgvalue(self, section) - - if cfg_val then - return cfg_val - end - end - - function o.formvalue(self, section) - local sel_val = AbstractValue.formvalue(self, section) - local txt_val = luci.http.formvalue("cbid."..self.map.config.."."..section.."."..self.option..".textbox") - - if sel_val and sel_val ~= "" then - return sel_val - end - - if txt_val and txt_val ~= "" then - return txt_val - end - end - - function o.remove(self, section) - local cfg_val = AbstractValue.cfgvalue(self, section) - local txt_val = luci.http.formvalue("cbid."..self.map.config.."."..section.."."..self.option..".textbox") - - if cfg_val and fs.access(cfg_val) and txt_val == "" then - fs.unlink(cfg_val) - end - return AbstractValue.remove(self, section) - end - elseif option[1] == Flag then - o.default = nil - else - if option[1] == DynamicList then - function o.cfgvalue(...) - local val = AbstractValue.cfgvalue(...) - return ( val and type(val) ~= "table" ) and { val } or val - end - end - - if type(option[3]) == "table" then - if o.optional then o:value("", "-- remove --") end - for _, v in ipairs(option[3]) do - v = tostring(v) - o:value(v) - end - o.default = tostring(option[3][1]) - else - o.default = tostring(option[3]) - end - end - - for i=5,#option do - if type(option[i]) == "table" then - o:depends(option[i]) - end - end -end - -return m diff --git a/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/lua/luci/model/cbi/openvpn-basic.lua b/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/lua/luci/model/cbi/openvpn-basic.lua deleted file mode 100644 index dbab780..0000000 --- a/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/lua/luci/model/cbi/openvpn-basic.lua +++ /dev/null @@ -1,196 +0,0 @@ --- Copyright 2008 Steven Barth --- Licensed to the public under the Apache License 2.0. - -local fs = require("nixio.fs") - -local basicParams = { - -- - -- Widget, Name, Default(s), Description - -- - { ListValue, - "verb", - { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }, - translate("Set output verbosity") }, - { Value, - "nice", - 0, - translate("Change process priority") }, - { Value, - "port", - 1194, - translate("TCP/UDP port # for both local and remote") }, - { ListValue, - "dev_type", - { "tun", "tap" }, - translate("Type of used device") }, - { Value, - "ifconfig", - "10.200.200.3 10.200.200.1", - translate("Set tun/tap adapter parameters") }, - { Value, - "server", - "10.200.200.0 255.255.255.0", - translate("Configure server mode") }, - { Value, - "server_bridge", - "192.168.1.1 255.255.255.0 192.168.1.128 192.168.1.254", - translate("Configure server bridge") }, - { Flag, - "nobind", - 0, - translate("Do not bind to local address and port") }, - { ListValue, - "comp_lzo", - {"yes","no","adaptive"}, - translate("Use fast LZO compression") }, - { Value, - "keepalive", - "10 60", - translate("Helper directive to simplify the expression of --ping and --ping-restart in server mode configurations") }, - { Flag, - "client", - 0, - translate("Configure client mode") }, - { Flag, - "client_to_client", - 0, - translate("Allow client-to-client traffic") }, - { DynamicList, - "remote", - "vpnserver.example.org", - translate("Remote host name or ip address") }, - { FileUpload, - "secret", - "/etc/openvpn/secret.key", - translate("Enable Static Key encryption mode (non-TLS)") }, - { ListValue, - "key_direction", - { 0, 1 }, - translate("The key direction for 'tls-auth' and 'secret' options") }, - { FileUpload, - "pkcs12", - "/etc/easy-rsa/keys/some-client.pk12", - translate("PKCS#12 file containing keys") }, - { FileUpload, - "ca", - "/etc/easy-rsa/keys/ca.crt", - translate("Certificate authority") }, - { FileUpload, - "dh", - "/etc/easy-rsa/keys/dh1024.pem", - translate("Diffie Hellman parameters") }, - { FileUpload, - "cert", - "/etc/easy-rsa/keys/some-client.crt", - translate("Local certificate") }, - { FileUpload, - "key", - "/etc/easy-rsa/keys/some-client.key", - translate("Local private key") }, - { FileUpload, - "auth_user_pass", - "/etc/easy-rsa/keys/some-client.pass", - translate("Password file") }, -} - -local has_ipv6 = fs.access("/proc/net/ipv6_route") -if has_ipv6 then - table.insert( basicParams, { ListValue, - "proto", - { "udp", "tcp-client", "tcp-server", "udp4", "tcp4-client", "tcp4-server","udp6", "tcp6-client", "tcp6-server" }, - translate("Use protocol") - }) -else - table.insert( basicParams, { ListValue, - "proto", - { "udp", "tcp-client", "tcp-server" }, - translate("Use protocol") - }) -end - -local m = Map("openvpn") -m.redirect = luci.dispatcher.build_url("admin", "vpn", "openvpn") -m.apply_on_parse = true - -local p = m:section( SimpleSection ) -p.template = "openvpn/pageswitch" -p.mode = "basic" -p.instance = arg[1] - - -local s = m:section( NamedSection, arg[1], "openvpn" ) - -for _, option in ipairs(basicParams) do - local o = s:option( - option[1], option[2], - option[2], option[4] - ) - - o.optional = true - - if option[1] == DummyValue then - o.value = option[3] - elseif option[1] == FileUpload then - - o.initial_directory = "/etc/openvpn" - - function o.cfgvalue(self, section) - local cfg_val = AbstractValue.cfgvalue(self, section) - - if cfg_val then - return cfg_val - end - end - - function o.formvalue(self, section) - local sel_val = AbstractValue.formvalue(self, section) - local txt_val = luci.http.formvalue("cbid."..self.map.config.."."..section.."."..self.option..".textbox") - - if sel_val and sel_val ~= "" then - return sel_val - end - - if txt_val and txt_val ~= "" then - return txt_val - end - end - - function o.remove(self, section) - local cfg_val = AbstractValue.cfgvalue(self, section) - local txt_val = luci.http.formvalue("cbid."..self.map.config.."."..section.."."..self.option..".textbox") - - if cfg_val and fs.access(cfg_val) and txt_val == "" then - fs.unlink(cfg_val) - end - return AbstractValue.remove(self, section) - end - elseif option[1] == Flag then - o.default = nil - else - if option[1] == DynamicList then - function o.cfgvalue(...) - local val = AbstractValue.cfgvalue(...) - return ( val and type(val) ~= "table" ) and { val } or val - end - end - - if type(option[3]) == "table" then - if o.optional then o:value("", "-- remove --") end - for _, v in ipairs(option[3]) do - v = tostring(v) - o:value(v) - end - o.default = tostring(option[3][1]) - else - o.default = tostring(option[3]) - end - end - - for i=5,#option do - if type(option[i]) == "table" then - o:depends(option[i]) - end - end -end - -return m diff --git a/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/lua/luci/model/cbi/openvpn-file.lua b/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/lua/luci/model/cbi/openvpn-file.lua deleted file mode 100644 index 9d50601..0000000 --- a/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/lua/luci/model/cbi/openvpn-file.lua +++ /dev/null @@ -1,82 +0,0 @@ --- Licensed to the public under the Apache License 2.0. - -local ip = require("luci.ip") -local fs = require("nixio.fs") -local util = require("luci.util") -local uci = require("luci.model.uci").cursor() -local cfg_file = uci:get("openvpn", arg[1], "config") -local auth_file = cfg_file:match("(.+)%..+").. ".auth" - -local m = Map("openvpn") - -local p = m:section( SimpleSection ) -p.template = "openvpn/pageswitch" -p.mode = "file" -p.instance = arg[1] - -if not cfg_file or not fs.access(cfg_file) then - local f = SimpleForm("error", nil, translatef("The OVPN config file (%s) could not be found, please check your configuration.", cfg_file or "n/a")) - f:append(Template("openvpn/ovpn_css")) - f.reset = false - f.submit = false - return m, f -end - -if fs.stat(cfg_file).size >= 102400 then - f = SimpleForm("error", nil, - translatef("The size of the OVPN config file (%s) is too large for online editing in LuCI (≥ 100 KB). ", cfg_file) - .. translate("Please edit this file directly in a terminal session.")) - f:append(Template("openvpn/ovpn_css")) - f.reset = false - f.submit = false - return m, f -end - -f = SimpleForm("cfg", nil) -f:append(Template("openvpn/ovpn_css")) -f.submit = translate("Save") -f.reset = false - -s = f:section(SimpleSection, nil, translatef("Section to modify the OVPN config file (%s)", cfg_file)) -file = s:option(TextValue, "data1") -file.datatype = "string" -file.rows = 20 - -function file.cfgvalue() - return fs.readfile(cfg_file) or "" -end - -function file.write(self, section, data1) - return fs.writefile(cfg_file, "\n" .. util.trim(data1:gsub("\r\n", "\n")) .. "\n") -end - -function file.remove(self, section, value) - return fs.writefile(cfg_file, "") -end - -function s.handle(self, state, data1) - return true -end - -s = f:section(SimpleSection, nil, translatef("Section to add an optional 'auth-user-pass' file with your credentials (%s)", auth_file)) -file = s:option(TextValue, "data2") -file.datatype = "string" -file.rows = 5 - -function file.cfgvalue() - return fs.readfile(auth_file) or "" -end - -function file.write(self, section, data2) - return fs.writefile(auth_file, util.trim(data2:gsub("\r\n", "\n")) .. "\n") -end - -function file.remove(self, section, value) - return fs.writefile(auth_file, "") -end - -function s.handle(self, state, data2) - return true -end - -return m, f diff --git a/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/lua/luci/model/cbi/openvpn-server.lua b/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/lua/luci/model/cbi/openvpn-server.lua deleted file mode 100644 index 88c8888..0000000 --- a/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/lua/luci/model/cbi/openvpn-server.lua +++ /dev/null @@ -1,86 +0,0 @@ --- Copyright 2008 Steven Barth --- Licensed to the public under the Apache License 2.0. - -local fs = require "nixio.fs" -local sys = require "luci.sys" -local uci = require "luci.model.uci".cursor() - -local m = Map("openvpn", translate("OpenVPN Extras"), translate("Extra Settings for an OpenVPN Client or Server")) - -m.on_after_save = function(self) - luci.sys.call("/usr/lib/easyrsa/firewall.sh &") - luci.sys.call("/usr/lib/easyrsa/dns.sh &") -end - -gw = m:section(TypedSection, "settings", translate("Advanced Extras")) -gw.anonymous = true -gw:tab("default", translate("Custom Firewall Settings")) -gw:tab("dns", translate("Custom DNS Settings")) -gw:tab("key", translate("Key and Certificate Generation")) - -this_tab = "default" - -gw:taboption(this_tab, Flag, "vpn2lan", translate("Forward Client VPN to LAN"), translate("(Client) Allow clients behind the VPN server to connect to computers within your LAN") ) -gw:taboption(this_tab, Flag, "vpns2lan", translate("Forward Server VPN to LAN"), translate("(Server) Allow clients behind the VPN server to connect to computers within your LAN") ) -gw:taboption(this_tab, Flag, "vpn2wan", translate("Forward Server VPN to WAN"), translate("(Server) Allow clients to connect to the internet (WAN) through the tunnel") ) - -this_tab = "dns" - -gw:taboption(this_tab, Flag, "lanopendns", translate("LAN DNS using OpenDNS"), translate("Fixed DNS on LAN interface using OpenDNS") ) -gw:taboption(this_tab, Flag, "langoogle", translate("LAN DNS using Google"), translate("Fixed DNS on LAN interface using Google") ) -gw:taboption(this_tab, Flag, "wanopendns", translate("WAN DNS using OpenDNS"), translate("Fixed DNS on WAN interface using OpenDNS") ) -gw:taboption(this_tab, Flag, "wangoogle", translate("WAN DNS using Google"), translate("Fixed DNS on WAN interface using Google") ) - -this_tab = "key" - -country = gw:taboption(this_tab, Value, "country", translate("Country Name :"), translate("2 letter country abbreviation")); -country.optional=false; -country.rmempty = true; -country.default="CA" -country.datatype = "rangelength(2, 2)" - -city = gw:taboption(this_tab, Value, "city", translate("City Name :")); -city.optional=false; -city.rmempty = true; -city.default="Abbotsford" -city.datatype = "minlength(2)" - -organ = gw:taboption(this_tab, Value, "organ", translate("Organization Name :"), translate("name will appear on certs and keys")); -organ.optional=false; -organ.rmempty = true; -organ.default="ROOter" -organ.datatype = "minlength(2)" - -comm = gw:taboption(this_tab, Value, "comm", translate("Common Name :"), translate("(Optional) Common Name of Organization")); -comm.optional=true; -comm.rmempty = true; - -unit = gw:taboption(this_tab, Value, "unit", translate("Section Name :"), translate("(Optional) Name of Section")); -unit.optional=true; -unit.rmempty = true; - -unstruc = gw:taboption(this_tab, Value, "unstruc", translate("Optional Organization Name :"), translate("(Optional) Another Name for Organization")); -unstruc.optional=true; -unstruc.rmempty = true; - -email = gw:taboption(this_tab, Value, "email", translate("Email Address :"), translate("(Optional) Email Address")); -unit.optional=true; -unit.rmempty = true; - -days = gw:taboption(this_tab, Value, "days", translate("Days to certify for :"), translate("number of days certs and keys are valid")); -days.optional=false; -days.rmempty = true; -days.default="3650" -days.datatype = "min(1)" - -clnt = gw:taboption(this_tab, Value, "nclient", translate("Number of Clients :"), translate("number of clients to generate certs and keys for")); -clnt.optional=false; -clnt.rmempty = true; -clnt.default="1" -clnt.datatype = "min(1)" - -sx = gw:taboption(this_tab, Value, "_dmy1", translate(" ")) -sx.template = "easyrsa/easyrsa" - - -return m diff --git a/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/lua/luci/model/cbi/openvpn.lua b/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/lua/luci/model/cbi/openvpn.lua deleted file mode 100644 index b79df8b..0000000 --- a/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/lua/luci/model/cbi/openvpn.lua +++ /dev/null @@ -1,179 +0,0 @@ --- Copyright 2008 Steven Barth --- Licensed to the public under the Apache License 2.0. - -local fs = require "nixio.fs" -local sys = require "luci.sys" -local uci = require "luci.model.uci".cursor() -local testfullps = sys.exec("ps --help 2>&1 | grep BusyBox") --check which ps do we have -local psstring = (string.len(testfullps)>0) and "ps w" or "ps axfw" --set command we use to get pid - -local m = Map("openvpn", translate("OpenVPN")) -local s = m:section( TypedSection, "openvpn", translate("OpenVPN instances"), translate("Below is a list of configured OpenVPN instances and their current state") ) -s.template = "cbi/tblsection" -s.template_addremove = "openvpn/cbi-select-input-add" -s.addremove = true -s.add_select_options = { } - -local cfg = s:option(DummyValue, "config") -function cfg.cfgvalue(self, section) - local file_cfg = self.map:get(section, "config") - if file_cfg then - s.extedit = luci.dispatcher.build_url("admin", "vpn", "openvpn", "file", "%s") - else - s.extedit = luci.dispatcher.build_url("admin", "vpn", "openvpn", "basic", "%s") - end -end - -uci:load("openvpn_recipes") -uci:foreach( "openvpn_recipes", "openvpn_recipe", - function(section) - s.add_select_options[section['.name']] = - section['_description'] or section['.name'] - end -) - -function s.getPID(section) -- Universal function which returns valid pid # or nil - local pid = sys.exec("%s | grep -w '[o]penvpn(%s)'" % { psstring, section }) - if pid and #pid > 0 then - return tonumber(pid:match("^%s*(%d+)")) - else - return nil - end -end - -function s.parse(self, section) - local recipe = luci.http.formvalue( - luci.cbi.CREATE_PREFIX .. self.config .. "." .. - self.sectiontype .. ".select" - ) - - if recipe and not s.add_select_options[recipe] then - self.invalid_cts = true - else - TypedSection.parse( self, section ) - end -end - -function s.create(self, name) - local recipe = luci.http.formvalue( - luci.cbi.CREATE_PREFIX .. self.config .. "." .. - self.sectiontype .. ".select" - ) - local name = luci.http.formvalue( - luci.cbi.CREATE_PREFIX .. self.config .. "." .. - self.sectiontype .. ".text" - ) - if #name > 3 and not name:match("[^a-zA-Z0-9_]") then - local s = uci:section("openvpn", "openvpn", name) - if s then - local options = uci:get_all("openvpn_recipes", recipe) - for k, v in pairs(options) do - if k ~= "_role" and k ~= "_description" then - if type(v) == "boolean" then - v = v and "1" or "0" - end - uci:set("openvpn", name, k, v) - end - end - uci:save("openvpn") - uci:commit("openvpn") - if extedit then - luci.http.redirect( self.extedit:format(name) ) - end - end - elseif #name > 0 then - self.invalid_cts = true - end - return 0 -end - -function s.remove(self, name) - local cfg_file = "/etc/openvpn/" ..name.. ".ovpn" - local auth_file = "/etc/openvpn/" ..name.. ".auth" - if fs.access(cfg_file) then - fs.unlink(cfg_file) - end - if fs.access(auth_file) then - fs.unlink(auth_file) - end - uci:delete("openvpn", name) - uci:save("openvpn") - uci:commit("openvpn") -end - -s:option( Flag, "enabled", translate("Enabled") ) -s:option( Flag, "bootstart", translate("Start on Bootup") ) - -local active = s:option( DummyValue, "_active", translate("Started") ) -function active.cfgvalue(self, section) - local pid = s.getPID(section) - if pid ~= nil then - return (sys.process.signal(pid, 0)) - and translatef("yes (%i)", pid) - or translate("no") - end - return translate("no") -end - -local updown = s:option( Button, "_updown", translate("Start/Stop") ) -updown._state = false -updown.redirect = luci.dispatcher.build_url( - "admin", "vpn", "openvpn" -) -function updown.cbid(self, section) - local pid = s.getPID(section) - self._state = pid ~= nil and sys.process.signal(pid, 0) - self.option = self._state and "stop" or "start" - return AbstractValue.cbid(self, section) -end -function updown.cfgvalue(self, section) - self.title = self._state and "stop" or "start" - self.inputstyle = self._state and "reset" or "reload" -end -function updown.write(self, section, value) - if self.option == "stop" then - --sys.call("/etc/init.d/openvpn stop %s" % section) - sys.call("/usr/lib/easyrsa/vpn.sh %s" % section) - else - sys.call("/etc/init.d/openvpn start %s" % section) - end - luci.http.redirect( self.redirect ) -end - -local port = s:option( DummyValue, "port", translate("Port") ) -function port.cfgvalue(self, section) - local val = AbstractValue.cfgvalue(self, section) - if not val then - local file_cfg = self.map:get(section, "config") - if file_cfg and fs.access(file_cfg) then - val = sys.exec("awk '{if(match(tolower($1),/^port$/)&&match($2,/[0-9]+/)){cnt++;printf $2;exit}}END{if(cnt==0)printf \"-\"}' " ..file_cfg) - if val == "-" then - val = sys.exec("awk '{if(match(tolower($1),/^remote$/)&&match($3,/[0-9]+/)){cnt++;printf $3;exit}}END{if(cnt==0)printf \"-\"}' " ..file_cfg) - end - end - end - return val or "-" -end - -local proto = s:option( DummyValue, "proto", translate("Protocol") ) -function proto.cfgvalue(self, section) - local val = AbstractValue.cfgvalue(self, section) - if not val then - local file_cfg = self.map:get(section, "config") - if file_cfg and fs.access(file_cfg) then - val = sys.exec("awk '{if(match(tolower($1),/^proto$/)&&match(tolower($2),/^udp[46]*$|^tcp[46]*-server$|^tcp[46]*-client$/)){cnt++;printf tolower($2);exit}}END{if(cnt==0)printf \"-\"}' " ..file_cfg) - if val == "-" then - val = sys.exec("awk '{if(match(tolower($1),/^remote$/)&&match(tolower($4),/^udp[46]*$|^tcp[46]*-server$|^tcp[46]*-client$/)){cnt++;printf $4;exit}}END{if(cnt==0)printf \"-\"}' " ..file_cfg) - end - end - end - return val or "-" -end - -function m.on_after_apply(self,map) - --sys.call('/etc/init.d/openvpn reload') -end - -m:section(SimpleSection).template = "openvpn/vpn1" - -return m diff --git a/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/lua/luci/view/admin_status/index/vpn.htm b/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/lua/luci/view/admin_status/index/vpn.htm deleted file mode 100644 index fab323d..0000000 --- a/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/lua/luci/view/admin_status/index/vpn.htm +++ /dev/null @@ -1 +0,0 @@ -<%+openvpn/vpn1%> \ No newline at end of file diff --git a/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/lua/luci/view/easyrsa/easyrsa.htm b/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/lua/luci/view/easyrsa/easyrsa.htm deleted file mode 100644 index 25fe654..0000000 --- a/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/lua/luci/view/easyrsa/easyrsa.htm +++ /dev/null @@ -1,172 +0,0 @@ - - - -
                          - - - - - - - -
                             
                          -

                           

                          - - - - - - - -
                           <%:Key Generation will take 60 minutes or more so be patient.%>  
                          -

                           

                          -

                          <%:Status of Key Generation%>

                          -

                           

                          - - - - -
                          - -
                          - -

                           

                          - - - - - - - - -
                             
                          - -
                          diff --git a/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/lua/luci/view/openvpn/cbi-select-input-add.htm b/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/lua/luci/view/openvpn/cbi-select-input-add.htm deleted file mode 100644 index 9ca1e87..0000000 --- a/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/lua/luci/view/openvpn/cbi-select-input-add.htm +++ /dev/null @@ -1,111 +0,0 @@ - - - -<%+openvpn/ovpn_css%> - -
                          -
                          -

                          <%:Template based configuration%>

                          -
                          -
                          - -
                          -
                          - -
                          -
                          -
                          -
                          -
                          -

                          <%:OVPN configuration file upload%>

                          -
                          -
                          - -
                          -
                          - -
                          -
                          - -
                          -
                          -
                          -
                          - -
                          -
                          diff --git a/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/lua/luci/view/openvpn/ovpn_css.htm b/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/lua/luci/view/openvpn/ovpn_css.htm deleted file mode 100644 index 55c0a54..0000000 --- a/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/lua/luci/view/openvpn/ovpn_css.htm +++ /dev/null @@ -1,38 +0,0 @@ - diff --git a/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/lua/luci/view/openvpn/pageswitch.htm b/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/lua/luci/view/openvpn/pageswitch.htm deleted file mode 100644 index 7d88b84..0000000 --- a/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/lua/luci/view/openvpn/pageswitch.htm +++ /dev/null @@ -1,30 +0,0 @@ -<%# - Copyright 2008 Steven Barth - Copyright 2008 Jo-Philipp Wich - Licensed to the public under the Apache License 2.0. --%> - -<%+openvpn/ovpn_css%> - -
                          -

                          - <%:Overview%> » - <%=luci.i18n.translatef("Instance \"%s\"", self.instance)%> -

                          - <% if self.mode == "basic" then %> - "><%:Switch to advanced configuration%> »

                          -


                          - <% elseif self.mode == "advanced" then %> - <%:Switch to basic configuration%> »

                          -


                          - <%:Configuration category%>: - <% for i, c in ipairs(self.categories) do %> - <% if c == self.category then %> - <%=translate(c)%> - <% else %> - "><%=translate(c)%> - <% end %> - <% if next(self.categories, i) then %>|<% end %> - <% end %> - <% end %> -
                          diff --git a/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/lua/luci/view/openvpn/vpn1.htm b/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/lua/luci/view/openvpn/vpn1.htm deleted file mode 100644 index 1c70818..0000000 --- a/rooter/0optionalapps/luci-app-rootervpn/files/usr/lib/lua/luci/view/openvpn/vpn1.htm +++ /dev/null @@ -1,120 +0,0 @@ - - -
                          -

                          <%:OpenVPN Status%>

                          - - - - - - - - - - - - - - -
                          <%:Name%><%:Type%><%:Status%><%:Uptime%><%:Remote IP%><%:Clients%><%:Port%>

                          <%:Collecting data...%>
                          -
                          \ No newline at end of file diff --git a/rooter/0optionalapps/luci-app-rootervpn/files/www/luci-static/resources/icons/vpn-disabled.png b/rooter/0optionalapps/luci-app-rootervpn/files/www/luci-static/resources/icons/vpn-disabled.png deleted file mode 100644 index ccb0f56..0000000 Binary files a/rooter/0optionalapps/luci-app-rootervpn/files/www/luci-static/resources/icons/vpn-disabled.png and /dev/null differ diff --git a/rooter/0optionalapps/luci-app-rootervpn/files/www/luci-static/resources/icons/vpn-started.png b/rooter/0optionalapps/luci-app-rootervpn/files/www/luci-static/resources/icons/vpn-started.png deleted file mode 100644 index 3f58ff1..0000000 Binary files a/rooter/0optionalapps/luci-app-rootervpn/files/www/luci-static/resources/icons/vpn-started.png and /dev/null differ diff --git a/rooter/0optionalapps/luci-app-rootervpn/files/www/luci-static/resources/icons/vpn-stopped.png b/rooter/0optionalapps/luci-app-rootervpn/files/www/luci-static/resources/icons/vpn-stopped.png deleted file mode 100644 index 83ad3a0..0000000 Binary files a/rooter/0optionalapps/luci-app-rootervpn/files/www/luci-static/resources/icons/vpn-stopped.png and /dev/null differ diff --git a/rooter/0optionalapps/nft-qos/Makefile b/rooter/0optionalapps/nft-qos/Makefile deleted file mode 100644 index 78e0ec2..0000000 --- a/rooter/0optionalapps/nft-qos/Makefile +++ /dev/null @@ -1,59 +0,0 @@ -# -# Copyright (C) 2018 rosysong@rosinson.com -# -# This is free software, licensed under the GNU General Public License v2. -# See /LICENSE for more information. -# - -include $(TOPDIR)/rules.mk - -PKG_NAME:=nft-qos -PKG_VERSION:=1.0.6 -PKG_RELEASE:=1 -PKG_LICENSE:=GPL-2.0 - -PKG_MAINTAINER:=Rosy Song - -PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) - -include $(INCLUDE_DIR)/package.mk - -define Package/nft-qos - SECTION:=utils - CATEGORY:=Base system - DEPENDS:=+nftables +kmod-nft-netdev +kmod-nft-bridge - TITLE:=QoS scripts over nftables - PKGARCH:=all -endef - -define Package/nft-qos/description - This package provides implementation for qos over nftables. - Currently, static/dynamic qos and traffic shaping are supported. -endef - -define Package/nft-qos/conffiles -/etc/config/nft-qos -endef - -define Build/Prepare -endef - -define Build/Configure -endef - -define Build/Compile -endef - -define Package/nft-qos/install - $(INSTALL_DIR) $(1)/lib/nft-qos - $(INSTALL_DATA) ./files/lib/* $(1)/lib/nft-qos/ - $(INSTALL_DIR) $(1)/etc/config - $(INSTALL_CONF) ./files/nft-qos.config $(1)/etc/config/nft-qos - $(INSTALL_DIR) $(1)/etc/init.d - $(INSTALL_BIN) ./files/nft-qos.init $(1)/etc/init.d/nft-qos - $(INSTALL_DIR) $(1)/etc/hotplug.d/dhcp - $(INSTALL_BIN) ./files/nft-qos-monitor.hotplug $(1)/etc/hotplug.d/dhcp/00-nft-qos-monitor - $(INSTALL_BIN) ./files/nft-qos-dynamic.hotplug $(1)/etc/hotplug.d/dhcp/01-nft-qos-dynamic -endef - -$(eval $(call BuildPackage,nft-qos)) diff --git a/rooter/0optionalapps/nft-qos/files/lib/core.sh b/rooter/0optionalapps/nft-qos/files/lib/core.sh deleted file mode 100644 index d3c9d64..0000000 --- a/rooter/0optionalapps/nft-qos/files/lib/core.sh +++ /dev/null @@ -1,93 +0,0 @@ -#!/bin/sh -# -# Copyright (C) 2018 rosysong@rosinson.com -# - -# for uci_validate_section() -. /lib/functions/procd.sh - -NFT_QOS_HAS_BRIDGE= -NFT_QOS_INET_FAMILY=ip -NFT_QOS_SCRIPT_TEXT= -NFT_QOS_SCRIPT_FILE=/tmp/qos.nft - -qosdef_appendx() { # - NFT_QOS_SCRIPT_TEXT="$NFT_QOS_SCRIPT_TEXT""$1" -} - -qosdef_append_chain_def() { # - qosdef_appendx "\t\ttype $1 hook $2 priority $3; policy $4;\n" -} - -qosdef_append_chain_ingress() { # - qosdef_appendx "\t\ttype $1 hook ingress device $2 priority $3; policy $4;\n" -} - -# qosdef_append_rule_{MATCH}_{STATEMENT} -qosdef_append_rule_ip_limit() { # - local ipaddr=$1 - local operator=$2 - local unit=$3 - local rate=$4 - - qosdef_appendx \ - "\t\tip $operator $ipaddr limit rate over $rate $unit/second drop\n" -} - -# qosdef_append_rule_{MATCH}_{POLICY} -qosdef_append_rule_ip_policy() { # - qosdef_appendx "\t\tip $1 $2 $3\n" -} - -_handle_limit_whitelist() { # - local ipaddr=$1 - local operator - - [ -z "$ipaddr" ] && return - - case "$2" in - download) operator="daddr";; - upload) operator="saddr";; - esac - - qosdef_append_rule_ip_policy $operator $ipaddr accept -} - -qosdef_append_rule_limit_whitelist() { # - config_list_foreach default limit_whitelist _handle_limit_whitelist $1 -} - -qosdef_flush_table() { # - nft flush table $1 $2 2>/dev/null -} - -qosdef_remove_table() { #
                          - nft delete table $1 $2 2>/dev/null -} - -qosdef_init_header() { # add header for nft script - qosdef_appendx "#!/usr/sbin/nft -f\n" - qosdef_appendx "# Copyright (C) 2018 rosysong@rosinson.com\n" - qosdef_appendx "#\n\n" -} - -qosdef_init_env() { - # check interface type of lan - local lt="$(uci_get "network.lan.type")" - [ "$lt" = "bridge" ] && export NFT_QOS_HAS_BRIDGE="y" - - # check if ipv6 support - [ -e /proc/sys/net/ipv6 ] && export NFT_QOS_INET_FAMILY="inet" -} - -qosdef_clean_cache() { - rm -f $NFT_QOS_SCRIPT_FILE -} - -qosdef_init_done() { - echo -e $NFT_QOS_SCRIPT_TEXT > $NFT_QOS_SCRIPT_FILE 2>/dev/null -} - -qosdef_start() { - nft -f $NFT_QOS_SCRIPT_FILE 2>/dev/null -} diff --git a/rooter/0optionalapps/nft-qos/files/lib/dynamic.sh b/rooter/0optionalapps/nft-qos/files/lib/dynamic.sh deleted file mode 100644 index 207daca..0000000 --- a/rooter/0optionalapps/nft-qos/files/lib/dynamic.sh +++ /dev/null @@ -1,90 +0,0 @@ -#!/bin/sh -# -# Copyright (C) 2018 rosysong@rosinson.com -# - -. /lib/nft-qos/core.sh - -qosdef_validate_dynamic() { - uci_load_validate nft-qos default "$1" "$2" \ - 'limit_enable:bool:0' \ - 'limit_type:maxlength(8)' \ - 'dynamic_bw_up:uinteger:100' \ - 'dynamic_bw_down:uinteger:100' -} - -# return average rate for dhcp leases -qosdef_dynamic_rate() { # - local c=0 c6=0 - - [ ! -e /tmp/dhcp.leases -a \ - ! -e /var/dhcp6.leases ] && return - - [ -e /tmp/dhcp.leases ] && \ - c=$(wc -l < /tmp/dhcp.leases 2>/dev/null) - [ -e /var/dhcp6.leases ] && \ - c6=$(wc -l < /var/dhcp6.leases 2>/dev/null) - [ $c -eq 0 -a $c6 -eq 0 ] && \ - { echo 12500; return; } - - echo $(($1 / ($c + $c6))) -} - -qosdef_append_chain_dym() { # - local cidr cidr6 - local operator rate - local hook=$1 name=$2 bandwidth=$3 - - config_get cidr default 'dynamic_cidr' - config_get cidr6 default 'dynamic_cidr6' - - [ -z "$cidr" -a -z "$cidr6" ] && return - - case "$2" in - download) operator=daddr;; - upload) operator=saddr;; - esac - - rate=$(qosdef_dynamic_rate $bandwidth) - - qosdef_appendx "\tchain $name {\n" - qosdef_append_chain_def filter $hook 0 accept - qosdef_append_rule_limit_whitelist $name - [ -n "$cidr" ] && \ - qosdef_append_rule_ip_limit $cidr $operator kbytes $rate - [ -n "$cidr6" ] && \ - qosdef_append_rule_ip_limit $cidr6 $operator kbytes $rate - qosdef_appendx "\t}\n" -} - -qosdef_flush_dynamic() { - qosdef_flush_table "$NFT_QOS_INET_FAMILY" nft-qos-dynamic -} - -# init dynamic qos -qosdef_init_dynamic() { - local hook_ul="prerouting" hook_dl="postrouting" - - [ "$2" = 0 ] || { - logger -t nft-qos-dynamic "validation failed" - return 1 - } - - [ $limit_enable -eq 0 -o \ - "$limit_type" = "static" ] && return 1 - - # Transfer mbits/s to mbytes/s - # e.g. 100,000 kbits == 12,500 kbytes - dynamic_bw_up=$(($dynamic_bw_up * 1000 / 8)) - dynamic_bw_down=$(($dynamic_bw_down * 1000 / 8)) - - [ -z "$NFT_QOS_HAS_BRIDGE" ] && { - hook_ul="postrouting" - hook_dl="prerouting" - } - - qosdef_appendx "table $NFT_QOS_INET_FAMILY nft-qos-dynamic {\n" - qosdef_append_chain_dym $hook_ul upload $dynamic_bw_up - qosdef_append_chain_dym $hook_dl download $dynamic_bw_down - qosdef_appendx "}\n" -} diff --git a/rooter/0optionalapps/nft-qos/files/lib/monitor.sh b/rooter/0optionalapps/nft-qos/files/lib/monitor.sh deleted file mode 100644 index 54de88e..0000000 --- a/rooter/0optionalapps/nft-qos/files/lib/monitor.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh -# -# Copyright (C) 2018 rosysong@rosinson.com -# - -. /lib/nft-qos/core.sh - -qosdef_monitor_get_ip_handle() { # - echo $(nft list chain $1 nft-qos-monitor $2 -a 2>/dev/null | grep $3 | awk '{print $11}') -} - -qosdef_monitor_add() { # - handle_dl=$(qosdef_monitor_get_ip_handle $NFT_QOS_INET_FAMILY download $2) - [ -z "$handle_dl" ] && nft add rule $NFT_QOS_INET_FAMILY nft-qos-monitor download ip daddr $2 counter - handle_ul=$(qosdef_monitor_get_ip_handle $NFT_QOS_INET_FAMILY upload $2) - [ -z "$handle_ul" ] && nft add rule $NFT_QOS_INET_FAMILY nft-qos-monitor upload ip saddr $2 counter -} - -qosdef_monitor_del() { # - local handle_dl handle_ul - handle_dl=$(qosdef_monitor_get_ip_handle $NFT_QOS_INET_FAMILY download $2) - handle_ul=$(qosdef_monitor_get_ip_handle $NFT_QOS_INET_FAMILY upload $2) - [ -n "$handle_dl" ] && nft delete handle $handle_dl - [ -n "$handle_ul" ] && nft delete handle $handle_ul -} - -# init qos monitor -qosdef_init_monitor() { - local hook_ul="prerouting" hook_dl="postrouting" - - [ -z "$NFT_QOS_HAS_BRIDGE" ] && { - hook_ul="postrouting" - hook_dl="prerouting" - } - - nft add table $NFT_QOS_INET_FAMILY nft-qos-monitor - nft add chain $NFT_QOS_INET_FAMILY nft-qos-monitor upload { type filter hook $hook_ul priority 0\; } - nft add chain $NFT_QOS_INET_FAMILY nft-qos-monitor download { type filter hook $hook_dl priority 0\; } -} diff --git a/rooter/0optionalapps/nft-qos/files/lib/priority.sh b/rooter/0optionalapps/nft-qos/files/lib/priority.sh deleted file mode 100644 index 081b13f..0000000 --- a/rooter/0optionalapps/nft-qos/files/lib/priority.sh +++ /dev/null @@ -1,93 +0,0 @@ -#!/bin/sh -# -# Copyright (C) 2018 rosysong@rosinson.com -# - -. /lib/functions/network.sh -. /lib/nft-qos/core.sh - -P1=""; P2=""; P3=""; P4=""; P5=""; P6=""; -P7=""; P8=""; P9=""; P10=""; P11=""; - -qosdef_validate_priority() { - uci_load_validate nft-qos default "$1" "$2" \ - 'priority_enable:bool:0' \ - 'priority_netdev:maxlength(8)' -} - -_qosdef_handle_protox() { # - case "$1" in - -400) P1="$P1""$2";; - -300) P2="$P2""$2";; - -225) P3="$P3""$2";; - -200) P4="$P4""$2";; - -150) P5="$P5""$2";; - -100) P6="$P6""$2";; - 0) P7="$P7""$2";; - 50) P8="$P8""$2";; - 100) P9="$P9""$2";; - 225) P10="$P10""$2";; - 300) P11="$P11""$2";; - esac -} - -qosdef_handle_protox() { #
                          - local proto prio srv - - config_get proto $1 'protocol' - config_get prio $1 'priority' - config_get srv $1 'service' - - [ -z "$proto" -o \ - -z "$prio" -o \ - -z "$srv" ] && return - - _qosdef_handle_protox $prio \ - "\t\t$proto dport { $srv } accept\n" -} - -qosdef_append_rule_protox() { #
                          - config_foreach qosdef_handle_protox $1 - qosdef_appendx \ - "${P1}${P2}${P3}${P4}${P5}${P6}${P7}${P8}${P9}${P10}${P11}" -} - -qosdef_append_chain_priority() { #
                          - local name=$1 device=$3 - - qosdef_appendx "\tchain $name {\n" - qosdef_append_chain_ingress filter $device 0 accept - qosdef_append_rule_protox $2 - qosdef_appendx "\t}\n" -} - -qosdef_remove_priority() { - qosdef_remove_table netdev nft-qos-priority -} - -# init traffic priority -qosdef_init_priority() { - local ifname="br-lan" - - [ "$2" = 0 ] || { - logger -t nft-qos-priority "validation failed" - return 1 - } - - [ $priority_enable -eq 0 ] && return 1 - - case "$priority_netdev" in - lan) [ "$(uci_get network.lan.type)" != "bridge" ] && { - network_get_device ifname "$priority_netdev" || \ - ifname="$(uci_get network.lan.ifname)" - } - ;; - wan*) network_get_device ifname "$priority_netdev" || \ - ifname="$(uci_get network.$priority_netdev.ifname)" - ;; - esac - - qosdef_appendx "table netdev nft-qos-priority {\n" - qosdef_append_chain_priority filter priority $ifname - qosdef_appendx "}\n" -} diff --git a/rooter/0optionalapps/nft-qos/files/lib/static.sh b/rooter/0optionalapps/nft-qos/files/lib/static.sh deleted file mode 100644 index 051c0ba..0000000 --- a/rooter/0optionalapps/nft-qos/files/lib/static.sh +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/sh -# -# Copyright (C) 2018 rosysong@rosinson.com -# - -. /lib/nft-qos/core.sh - -qosdef_validate_static() { - uci_load_validate nft-qos default "$1" "$2" \ - 'limit_enable:bool:0' \ - 'limit_type:maxlength(8)' \ - 'static_unit_dl:string:kbytes' \ - 'static_unit_ul:string:kbytes' \ - 'static_rate_dl:uinteger:50' \ - 'static_rate_ul:uinteger:50' -} - -# append rule for static qos -qosdef_append_rule_sta() { #
                          - local ipaddr unit rate - local operator=$2 - - config_get ipaddr $1 ipaddr - config_get unit $1 unit $3 - config_get rate $1 rate $4 - - [ -z "$ipaddr" ] && return - - qosdef_append_rule_ip_limit $ipaddr $operator $unit $rate -} - -# append chain for static qos -qosdef_append_chain_sta() { #
                          - local hook=$1 name=$2 - local config=$3 operator - - case "$name" in - download) operator="daddr";; - upload) operator="saddr";; - esac - - qosdef_appendx "\tchain $name {\n" - qosdef_append_chain_def filter $hook 0 accept - qosdef_append_rule_limit_whitelist $name - config_foreach qosdef_append_rule_sta $config $operator $4 $5 - qosdef_appendx "\t}\n" -} - -qosdef_flush_static() { - qosdef_flush_table "$NFT_QOS_INET_FAMILY" nft-qos-static -} - -# static limit rate init -qosdef_init_static() { - local hook_ul="prerouting" hook_dl="postrouting" - - [ "$2" = 0 ] || { - logger -t nft-qos-static "validation failed" - return 1 - } - - [ $limit_enable -eq 0 -o \ - $limit_type = "dynamic" ] && return 1 - - [ -z "$NFT_QOS_HAS_BRIDGE" ] && { - hook_ul="postrouting" - hook_dl="prerouting" - } - - qosdef_appendx "table $NFT_QOS_INET_FAMILY nft-qos-static {\n" - qosdef_append_chain_sta $hook_ul upload upload $static_unit_ul $static_rate_ul - qosdef_append_chain_sta $hook_dl download download $static_unit_dl $static_rate_dl - qosdef_appendx "}\n" -} diff --git a/rooter/0optionalapps/nft-qos/files/nft-qos-dynamic.hotplug b/rooter/0optionalapps/nft-qos/files/nft-qos-dynamic.hotplug deleted file mode 100644 index b81fa94..0000000 --- a/rooter/0optionalapps/nft-qos/files/nft-qos-dynamic.hotplug +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# -# Copyright 2018 rosysong@rosinson.com -# - -export initscript="nft-qos-dynamic" - -. /lib/functions.sh -. /lib/nft-qos/core.sh -. /lib/nft-qos/dynamic.sh - -NFT_QOS_DYNAMIC_ON= - -qosdef_check_if_dynamic() { - [ $limit_enable -eq 1 -a \ - "$limit_type" = "dynamic" ] && \ - NFT_QOS_DYNAMIC_ON="y" -} - - -logger -t nft-qos-dynamic "ACTION=$ACTION, MACADDR=$MACADDR, IPADDR=$IPADDR, HOSTNAME=$HOSTNAME" - -case "$ACTION" in - add | update | remove) - qosdef_validate_dynamic default qosdef_check_if_dynamic - [ -z "$NFT_QOS_DYNAMIC_ON" ] && return - - qosdef_init_env - qosdef_flush_dynamic - - qosdef_init_header - qosdef_validate_dynamic default qosdef_init_dynamic - qosdef_init_done - qosdef_start - ;; -esac diff --git a/rooter/0optionalapps/nft-qos/files/nft-qos-monitor.hotplug b/rooter/0optionalapps/nft-qos/files/nft-qos-monitor.hotplug deleted file mode 100644 index 5868bb1..0000000 --- a/rooter/0optionalapps/nft-qos/files/nft-qos-monitor.hotplug +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh -# -# Copyright 2018 rosysong@rosinson.com -# - -export initscript="nft-qos-monitor" - -. /lib/nft-qos/monitor.sh - -logger -t nft-qos-monitor "ACTION=$ACTION, MACADDR=$MACADDR, IPADDR=$IPADDR, HOSTNAME=$HOSTNAME" - -case "$ACTION" in - add | update) - qosdef_init_env - qosdef_init_monitor - qosdef_monitor_add $MACADDR $IPADDR $HOSTNAME - ;; - remove) - qosdef_init_env - qosdef_init_monitor - qosdef_monitor_del $MACADDR $IPADDR $HOSTNAME - ;; -esac diff --git a/rooter/0optionalapps/nft-qos/files/nft-qos.config b/rooter/0optionalapps/nft-qos/files/nft-qos.config deleted file mode 100644 index 82e3b39..0000000 --- a/rooter/0optionalapps/nft-qos/files/nft-qos.config +++ /dev/null @@ -1,107 +0,0 @@ -# -# Copyright (C) 2018 rosysong@rosinson.com -# -# This is the sample for nft-qos configuration file, -# which will generate a nftables script in /tmp/qos.nft -# - -# Getting Started -# Official site : -# https://netfilter.org/projects/nftables/index.html -# What is nftables : -# https://wiki.nftables.org/wiki-nftables/index.php/Main_Page -# - -# Basic Operations -# Configuring Tables : -# https://wiki.nftables.org/wiki-nftables/index.php/Configuring_tables -# Configuring Chains : -# https://wiki.nftables.org/wiki-nftables/index.php/Configuring_chains -# Configuring Rules : -# https://wiki.nftables.org/wiki-nftables/index.php/Simple_rule_management -# Quick Reference (recommended) : -# https://wiki.nftables.org/wiki-nftables/index.php/Quick_reference-nftables_in_10_minutes -# https://netfilter.org/projects/nftables/manpage.html -# - -config default default - # Enable Flag for limit rate - option limit_enable '1' - - # Options for enable Static QoS (rate limit) - option limit_type 'static' - # Options for Static QoS (rate limit) - option static_unit_dl 'kbytes' - option static_unit_ul 'kbytes' - option static_rate_dl '50' - option static_rate_ul '50' - - # Options for enable Dynamic QoS - # This option can not compatible with Static QoS - # option limit_type 'dynamic' - - # For Dynamic QoS Samples (unit of bandwidth is Mbps): - option dynamic_cidr '192.168.1.0/24' - option dynamic_cidr6 'AAAA:BBBB::1/64' - option dynamic_bw_up '100' - option dynamic_bw_down '100' - - # White list for static/dynamic limit - # list limit_whitelist '192.168.1.225' - # list limit_whitelist '192.168.1.0/24' - # list limit_whitelist 'ABCD:CDEF::1/64' - - # Options for Traffic Priority - option priority_enable '0' - option priority_netdev 'lan' - - -# -# For Static QoS Rate Limit Samples : -# -# For Download : -#config download -# option hostname 'My PC' -# option unit 'kbytes' -# option ipaddr '192.168.1.224' -# option rate '128' -# -# For Upload : -#config upload -# option hostname 'office-pc' -# option unit 'mbytes' -# option ipaddr 'ABCD:FFED::1/64' -# option rate '1024' -# -# -# Traffic Priority Samples : -# -# protocol : tcp, udp, udplite, sctp, dccp, tcp is default -# priority : integer between 1-11, 1 is default and the highest -# service : you can input a integer or service name, -# e.g. '22', '11-22', 'telnet', 'ssh, http, ftp', etc -# -#config priority -# option protocol 'tcp' -# option priority '-400' -# option service '23' -# option comment '?' -# -#config priority -# option protocol 'udp' -# option priority '-400' -# option service 'https' -# option comment '?' -# -#config priority -# option protocol 'dccp' -# option priority '0' -# option service '22-35' -# option comment '?' -# -#config priority -# option protocol 'dccp' -# option priority '300' -# option service 'ftp,ssh,http' -# option comment '?' -# diff --git a/rooter/0optionalapps/nft-qos/files/nft-qos.init b/rooter/0optionalapps/nft-qos/files/nft-qos.init deleted file mode 100644 index 7a56ec7..0000000 --- a/rooter/0optionalapps/nft-qos/files/nft-qos.init +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/sh /etc/rc.common -# -# Copyright (C) 2018 rosysong@rosinson.com -# - -. /lib/nft-qos/core.sh -. /lib/nft-qos/monitor.sh -. /lib/nft-qos/dynamic.sh -. /lib/nft-qos/static.sh -. /lib/nft-qos/priority.sh - -START=99 -USE_PROCD=1 - -service_triggers() { - procd_add_reload_trigger nft-qos - - procd_open_validate - qosdef_validate_dynamic - qosdef_validate_static - qosdef_validate_priority - procd_close_validate -} - -start_service() { - config_load nft-qos - - qosdef_init_env - qosdef_flush_static - qosdef_flush_dynamic - qosdef_remove_priority - - qosdef_init_header - qosdef_init_monitor - qosdef_validate_dynamic default qosdef_init_dynamic - qosdef_validate_static default qosdef_init_static - qosdef_validate_priority default qosdef_init_priority - qosdef_init_done - qosdef_start -} - -stop_service() { - qosdef_flush_dynamic - qosdef_flush_static - qosdef_remove_priority - qosdef_clean_cache -} diff --git a/rooter/0optionalapps/pingtest/Makefile b/rooter/0optionalapps/pingtest/Makefile deleted file mode 100644 index 0393fd7..0000000 --- a/rooter/0optionalapps/pingtest/Makefile +++ /dev/null @@ -1,36 +0,0 @@ -#Owned by DairyMan@Whirlpool -# -#Copyright GNU act. -include $(TOPDIR)/rules.mk - -PKG_NAME:=pingtest -PKG_VERSION:=1.000 -PKG_RELEASE:=1 - -PKG_MAINTAINER:=Created by DM/makefile by Cobia@whirlpool -include $(INCLUDE_DIR)/package.mk - -define Package/pingtest - SECTION:=utils - CATEGORY:=ROOter - SUBMENU:=Optional Applications - DEPENDS:=+httping +curl - TITLE:=Added scripts for custom ping test - PKGARCH:=all -endef - -define Package/pingtest/description - Added scripts for custom ping test -endef - - -define Build/Compile -endef - -define Package/pingtest/install - $(CP) ./files/* $(1)/ - - -endef - -$(eval $(call BuildPackage,pingtest)) diff --git a/rooter/0optionalapps/pingtest/files/etc/config/ping b/rooter/0optionalapps/pingtest/files/etc/config/ping deleted file mode 100644 index 6fa2bfc..0000000 --- a/rooter/0optionalapps/pingtest/files/etc/config/ping +++ /dev/null @@ -1,6 +0,0 @@ -config ping 'ping' - option enable '0' - option delay '40' - option conn '1' - option interval '20' - option type '1' \ No newline at end of file diff --git a/rooter/0optionalapps/pingtest/files/etc/init.d/pingtest b/rooter/0optionalapps/pingtest/files/etc/init.d/pingtest deleted file mode 100644 index 32cc726..0000000 --- a/rooter/0optionalapps/pingtest/files/etc/init.d/pingtest +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh /etc/rc.common -# Copyright (C) 2013 OpenWrt.org - -START=99 -USE_PROCD=1 - -log() { - logger -t "pingtest" "$@" -} - -start_service() -{ - /usr/lib/custom/test_ping.sh & -} diff --git a/rooter/0optionalapps/pingtest/files/usr/lib/custom/johns_ping.sh b/rooter/0optionalapps/pingtest/files/usr/lib/custom/johns_ping.sh deleted file mode 100644 index 32af6cb..0000000 --- a/rooter/0optionalapps/pingtest/files/usr/lib/custom/johns_ping.sh +++ /dev/null @@ -1,99 +0,0 @@ -#!/bin/sh - -. /lib/functions.sh - -ROOTER=/usr/lib/rooter -ROOTER_LINK="/tmp/links" - -log() { -logger -t "Custom Ping Test " "$@" -} - -tping() { - hp=$(httping $2 -c 3 -s $1) - pingg=$(echo $hp" " | grep -o "round-trip .\+ ms ") - if [ -z "$pingg" ]; then - tmp=0 - else - tmp=200 - fi -} - -uci set ping.ping.conn="4" -uci commit ping - -CURRMODEM=1 -CPORT=$(uci -q get modem.modem$CURRMODEM.commport) -DELAY=$(uci get ping.ping.delay) - -TYPE=$(uci get ping.ping.type) -if [ $TYPE = "1" ]; then -log "Curl" - RETURN_CODE_1=$(curl -m 10 -s -o /dev/null -w "%{http_code}" http://www.google.com/) - RETURN_CODE_2=$(curl --ipv6 -m 10 -s -o /dev/null -w "%{http_code}" http://www.example.org/) - RETURN_CODE_3=$(curl -m 10 -s -o /dev/null -w "%{http_code}" https://github.com) -else -log "Ping" - tping "http://www.google.com/"; RETURN_CODE_1=$tmp - tping "http://www.example.org/" "-6"; RETURN_CODE_2=$tmp - tping "https://github.com"; RETURN_CODE_3=$tmp -fi - -if [[ "$RETURN_CODE_1" != "200" && "$RETURN_CODE_2" != "200" && "$RETURN_CODE_3" != "200" ]]; then - log "Bad Ping Test" - if [ $TYPE = "1" ]; then - tping "http://www.google.com/"; RETURN_CODE_1=$tmp - tping "http://www.example.org/" "-6"; RETURN_CODE_2=$tmp - tping "https://github.com"; RETURN_CODE_3=$tmp - else - RETURN_CODE_1=$(curl -m 10 -s -o /dev/null -w "%{http_code}" http://www.google.com/) - RETURN_CODE_2=$(curl --ipv6 -m 10 -s -o /dev/null -w "%{http_code}" http://www.example.org/) - RETURN_CODE_3=$(curl -m 10 -s -o /dev/null -w "%{http_code}" https://github.com) - fi - if [[ "$RETURN_CODE_1" != "200" && "$RETURN_CODE_2" != "200" && "$RETURN_CODE_3" != "200" ]]; then - log "Second Bad Ping Test" - uci set ping.ping.conn="3" - uci commit ping - ATCMDD="AT+CFUN=1,1" - $ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD" - sleep $DELAY - tries=0 - while [ $tries -lt 9 ] - do - CONN=$(uci -q get modem.modem$CURRMODEM.connected) - if [ $CONN = "1" ]; then - uci set ping.ping.conn="4" - uci commit ping - if [ $TYPE = "1" ]; then - log "Curl" - RETURN_CODE_1=$(curl -m 10 -s -o /dev/null -w "%{http_code}" http://www.google.com/) - RETURN_CODE_2=$(curl --ipv6 -m 10 -s -o /dev/null -w "%{http_code}" http://www.example.org/) - RETURN_CODE_3=$(curl -m 10 -s -o /dev/null -w "%{http_code}" https://github.com) - else - log "Ping" - tping "http://www.google.com/"; RETURN_CODE_1=$tmp - tping "http://www.example.org/" "-6"; RETURN_CODE_2=$tmp - tping "https://github.com"; RETURN_CODE_3=$tmp - fi - if [[ "$RETURN_CODE_1" != "200" && "$RETURN_CODE_2" != "200" && "$RETURN_CODE_3" != "200" ]]; then - uci set ping.ping.conn="1" - uci commit ping - reboot -f - fi - log "Second Ping Test Good" - uci set ping.ping.conn="2" - uci commit ping - exit 0 - else - sleep 20 - tries=$((tries+1)) - fi - done - reboot -f - fi -else - log "Good Ping" - uci set ping.ping.conn="2" - uci commit ping -fi -exit 0 diff --git a/rooter/0optionalapps/pingtest/files/usr/lib/custom/test_ping.sh b/rooter/0optionalapps/pingtest/files/usr/lib/custom/test_ping.sh deleted file mode 100644 index ab3c5a3..0000000 --- a/rooter/0optionalapps/pingtest/files/usr/lib/custom/test_ping.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh - -. /lib/functions.sh - -ROOTER=/usr/lib/rooter -ROOTER_LINK="/tmp/links" - -log() { -logger -t "Custom Ping Test " "$@" -} - -sleep 20 -CURRMODEM=1 -uci set ping.ping.conn="1" -uci commit ping -while [ true ] -do - INTER=$(uci get ping.ping.interval) - ENB=$(uci get ping.ping.enable) - if [ $ENB = 0 ]; then - sleep $INTER - else - CONN=$(uci -q get modem.modem$CURRMODEM.connected) - if [ $CONN = "1" ]; then - result=`ps | grep -i "johns_ping.sh" | grep -v "grep" | wc -l` - if [ $result -lt 1 ]; then - /usr/lib/custom/johns_ping.sh & - fi - else - uci set ping.ping.conn="1" - uci commit ping - fi - sleep $INTER - fi -done \ No newline at end of file diff --git a/rooter/0optionalapps/pingtest/files/usr/lib/lua/luci/controller/ping.lua b/rooter/0optionalapps/pingtest/files/usr/lib/lua/luci/controller/ping.lua deleted file mode 100644 index 025d16b..0000000 --- a/rooter/0optionalapps/pingtest/files/usr/lib/lua/luci/controller/ping.lua +++ /dev/null @@ -1,16 +0,0 @@ --- Licensed to the public under the Apache License 2.0. - -module("luci.controller.ping", package.seeall) - -I18N = require "luci.i18n" -translate = I18N.translate - -function index() - local page - local multilock = luci.model.uci.cursor():get("custom", "multiuser", "multi") or "0" - local rootlock = luci.model.uci.cursor():get("custom", "multiuser", "root") or "0" - if (multilock == "0") or (multilock == "1" and rootlock == "1") then - page = entry({"admin", "modem", "ping"}, cbi("ping"), _(translate("Custom Ping Test")), 45) - page.dependent = true - end -end diff --git a/rooter/0optionalapps/pingtest/files/usr/lib/lua/luci/model/cbi/ping.lua b/rooter/0optionalapps/pingtest/files/usr/lib/lua/luci/model/cbi/ping.lua deleted file mode 100644 index caa3bf6..0000000 --- a/rooter/0optionalapps/pingtest/files/usr/lib/lua/luci/model/cbi/ping.lua +++ /dev/null @@ -1,42 +0,0 @@ -local utl = require "luci.util" - -local sys = require "luci.sys" -local zones = require "luci.sys.zoneinfo" -local fs = require "nixio.fs" -local conf = require "luci.config" - -m = Map("ping", translate("Custom Ping Test"), translate("Enable/Disable Custom Ping Test")) - -d = m:section(TypedSection, "ping", " ") -d.anonymous = true - -c1 = d:option(ListValue, "enable", "Ping Test Status : ", "Ping every 20 seconds and, if it fails, restart modem or reboot router"); -c1:value("0", "Disabled") -c1:value("1", "Enabled") -c1.default=0 - -interval = d:option(Value, "interval", translate("Test Interval :"), translate("Number of seconds between testing the connection. Range is 20 to 120 secs.")); -interval.rmempty = true; -interval.optional=false; -interval.datatype = 'range(20,120)'; -interval.default="20"; - -type = d:option(ListValue, "type", "Test Type :", "Type of test - Page Retrieval or Ping"); -type:value("0", "Ping") -type:value("1", "Page Retrieval") -type.default=1 - -d1 = d:option(ListValue, "delay", "Reconnection Delay","Delay in seconds after restarting modem before checking for connection"); -d1:value("40", "40 seconds") -d1:value("45", "45 seconds") -d1:value("50", "50 seconds") -d1:value("55", "55 seconds") -d1:value("60", "60 seconds") -d1:value("70", "70 seconds") -d1:value("80", "80 seconds") -d1:value("90", "90 seconds") -d1:value("100", "100 seconds") -d1:value("120", "120 seconds") -d1.default=40 - -return m \ No newline at end of file diff --git a/rooter/0optionalapps/pingtest/files/usr/lib/lua/luci/view/admin_status/index/extping.htm b/rooter/0optionalapps/pingtest/files/usr/lib/lua/luci/view/admin_status/index/extping.htm deleted file mode 100644 index ed0c240..0000000 --- a/rooter/0optionalapps/pingtest/files/usr/lib/lua/luci/view/admin_status/index/extping.htm +++ /dev/null @@ -1 +0,0 @@ -<%+pingtest/extping%> \ No newline at end of file diff --git a/rooter/0optionalapps/pingtest/files/usr/lib/lua/luci/view/pingtest/extping.htm b/rooter/0optionalapps/pingtest/files/usr/lib/lua/luci/view/pingtest/extping.htm deleted file mode 100644 index daba06c..0000000 --- a/rooter/0optionalapps/pingtest/files/usr/lib/lua/luci/view/pingtest/extping.htm +++ /dev/null @@ -1,26 +0,0 @@ - - -
                          - <%:Custom Ping Test Status%> -
                          - -
                          <%:Ping Status%><%:Loading%> Collecting data...
                          - - diff --git a/rooter/0optionalapps/qfirehose/Makefile b/rooter/0optionalapps/qfirehose/Makefile deleted file mode 100644 index 6ceb348..0000000 --- a/rooter/0optionalapps/qfirehose/Makefile +++ /dev/null @@ -1,40 +0,0 @@ -# -# Copyright (C) 2011-2014 OpenWrt.org -# -# This is free software, licensed under the GNU General Public License v2. -# See /LICENSE for more information. -# - -include $(TOPDIR)/rules.mk - -PKG_NAME:=qfirehose -PKG_RELEASE:=1 - -PKG_FLAGS:=nonshared - -include $(INCLUDE_DIR)/package.mk - -define Package/qfirehose - SECTION:=utils - CATEGORY:=ROOter - SUBMENU:=Optional Applications - TITLE:=Quectel FireHose - MAINTAINER:=Dairyman -endef - -define Package/qfirehose/description - Quectel FireHose -endef - -define Build/Compile - $(MAKE) -C $(PKG_BUILD_DIR) \ - CC="$(TARGET_CC)" \ - CFLAGS="$(TARGET_CFLAGS) -Wall" -endef - -define Package/qfirehose/install - $(INSTALL_DIR) $(1)/usr/bin - $(INSTALL_BIN) $(PKG_BUILD_DIR)/qfirehose $(1)/usr/bin/QFirehose -endef - -$(eval $(call BuildPackage,qfirehose)) diff --git a/rooter/0optionalapps/qfirehose/src/Makefile b/rooter/0optionalapps/qfirehose/src/Makefile deleted file mode 100644 index 44864b7..0000000 --- a/rooter/0optionalapps/qfirehose/src/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -all: qfirehose - -qfirehose: - $(CC) $(CFLAGS) -Wall firehose_protocol.c qfirehose.c sahara_protocol.c usb_linux.c stream_download_protocol.c md5.c usb2tcp.c -o $@ $^ - -clean: - rm -rf firehose obj libs diff --git a/rooter/0optionalapps/qfirehose/src/firehose_protocol.c b/rooter/0optionalapps/qfirehose/src/firehose_protocol.c deleted file mode 100644 index 7116cde..0000000 --- a/rooter/0optionalapps/qfirehose/src/firehose_protocol.c +++ /dev/null @@ -1,970 +0,0 @@ -/****************************************************************************** - @file firehose_protocol.c - @brief firehose protocol. - - DESCRIPTION - QFirehoe Tool for USB and PCIE of Quectel wireless cellular modules. - - INITIALIZATION AND SEQUENCING REQUIREMENTS - None. - - --------------------------------------------------------------------------- - Copyright (c) 2016 - 2020 Quectel Wireless Solution, Co., Ltd. All Rights Reserved. - Quectel Wireless Solution Proprietary and Confidential. - --------------------------------------------------------------------------- -******************************************************************************/ -#include "usb_linux.h" -#include -#include -#include - -#define error_return() do {dbg_time("%s %s %d fail\n", __FILE__, __func__, __LINE__); return __LINE__; } while(0) -int recv_sc600y_configure_num = 1; -extern const char *q_device_type; -static int fh_recv_cmd_sk[2]; - -extern unsigned q_erase_all_before_download; -extern int update_transfer_bytes(long long bytes_cur); -extern int show_progress(); - -struct fh_configure_cmd { - const char *type; - const char *MemoryName; - uint32_t Verbose; - uint32_t AlwaysValidate; - uint32_t MaxDigestTableSizeInBytes; - uint32_t MaxPayloadSizeToTargetInBytes; - uint32_t MaxPayloadSizeFromTargetInBytes ; //2048 - uint32_t MaxPayloadSizeToTargetInByteSupported; //16k - uint32_t ZlpAwareHost; - uint32_t SkipStorageInit; -}; - -struct fh_erase_cmd { - const char *type; - //uint32_t PAGES_PER_BLOCK; - //uint32_t SECTOR_SIZE_IN_BYTES; - //char label[32]; - uint32_t last_sector; - uint32_t num_partition_sectors; - //uint32_t physical_partition_number; - uint32_t start_sector; -}; - -struct fh_program_cmd { - const char *type; - char *filename; - uint32_t filesz; - //uint32_t PAGES_PER_BLOCK; - uint32_t SECTOR_SIZE_IN_BYTES; - //char label[32]; - //uint32_t last_sector; - uint32_t num_partition_sectors; - //uint32_t physical_partition_number; - uint32_t start_sector; -}; - -struct fh_response_cmd { - const char *type; - const char *value; - uint32_t rawmode; - uint32_t MaxPayloadSizeToTargetInBytes; -}; - -struct fh_log_cmd { - const char *type; -}; - -struct fh_patch_cmd { - const char *type; - char *filename; - uint32_t filesz; - uint32_t SECTOR_SIZE_IN_BYTES; - uint32_t num_partition_sectors; -}; - -struct fh_cmd_header { - const char *type; -}; - -struct fh_vendor_defines { - const char *type; // "vendor" -}; - -struct fh_cmd { - union { - struct fh_cmd_header cmd; - struct fh_configure_cmd cfg; - struct fh_erase_cmd erase; - struct fh_program_cmd program; - struct fh_response_cmd response; - struct fh_log_cmd log; - struct fh_patch_cmd patch; - struct fh_vendor_defines vdef; - }; - int part_upgrade; - char xml_original_data[512]; -}; - -struct fh_data { - const char *firehose_dir; - const void *usb_handle; - unsigned MaxPayloadSizeToTargetInBytes; - unsigned fh_cmd_count; - unsigned fh_patch_count; - unsigned ZlpAwareHost; - struct fh_cmd fh_cmd_table[256]; //AG525 have more than 64 partition - - unsigned xml_tx_size; - unsigned xml_rx_size; - char xml_tx_buf[1024]; - char xml_rx_buf[1024]; -}; - -static const char * fh_xml_find_value(const char *xml_line, const char *key, char **ppend) { - char *pchar = strstr(xml_line, key); - char *pend; - - if (!pchar) { - dbg_time("%s: no key %s in %s\n", __func__, key, xml_line); - return NULL; - } - - pchar += strlen(key); - if (pchar[0] != '=' && pchar[1] != '"') { - dbg_time("%s: no start %s in %s\n", __func__, "=\"", xml_line); - return NULL; - } - - pchar += strlen("=\""); - pend = strstr(pchar, "\""); - if (!pend) { - dbg_time("%s: no end %s in %s\n", __func__, "\"", xml_line); - return NULL; - } - - *ppend = pend; - return pchar; -} - -static const char * fh_xml_get_value(const char *xml_line, const char *key) { - static char value[64]; - char *pend; - const char *pchar = fh_xml_find_value(xml_line, key, &pend); - - if (!pchar) { - return NULL; - } - - strncpy(value, pchar, pend - pchar); - value[pend - pchar] = '\0'; - - return value; -} - -static void fh_xml_set_value(char *xml_line, const char *key, unsigned value) { - char *pend; - const char *pchar = fh_xml_find_value(xml_line, key, &pend); - char *tmp_line = strdup(xml_line); - char value_str[32]; - - if (!pchar || !tmp_line) { - return; - } - - snprintf(value_str, sizeof(value_str), "%u", value); - tmp_line[pchar - xml_line] = '\0'; - strcat(tmp_line, value_str); - strcat(tmp_line, pend); - - strcpy(xml_line, tmp_line); - free(tmp_line); -} - -static int fh_parse_xml_line(const char *xml_line, struct fh_cmd *fh_cmd) { - const char *pchar = NULL; - size_t len = strlen(xml_line); - - memset(fh_cmd, 0, sizeof( struct fh_cmd)); - strcpy(fh_cmd->xml_original_data, xml_line); - if (fh_cmd->xml_original_data[len - 1] == '\n') - fh_cmd->xml_original_data[len - 1] = '\0'; - - if (strstr(xml_line, "vendor=\"quectel\"")) { - fh_cmd->vdef.type = "vendor"; - return 0; - } - else if (!strncmp(xml_line, "erase.type = "erase"; - if (strstr(xml_line, "last_sector")) { - if ((pchar = fh_xml_get_value(xml_line, "last_sector"))) - fh_cmd->erase.last_sector = atoi(pchar); - } - if ((pchar = fh_xml_get_value(xml_line, "start_sector"))) - fh_cmd->erase.start_sector = atoi(pchar); - if ((pchar = fh_xml_get_value(xml_line, "num_partition_sectors"))) - fh_cmd->erase.num_partition_sectors = atoi(pchar); - - return 0; - } - else if (!strncmp(xml_line, "program.type = "program"; - if ((pchar = fh_xml_get_value(xml_line, "filename"))) - { - fh_cmd->program.filename = strdup(pchar); - if(fh_cmd->program.filename[0] == '\0') - {//some fw version have blank program line, ignore it. - return -1; - } - } - if ((pchar = fh_xml_get_value(xml_line, "start_sector"))) - fh_cmd->program.start_sector = atoi(pchar); - if ((pchar = fh_xml_get_value(xml_line, "num_partition_sectors"))) - fh_cmd->program.num_partition_sectors = atoi(pchar); - if ((pchar = fh_xml_get_value(xml_line, "SECTOR_SIZE_IN_BYTES"))) - fh_cmd->program.SECTOR_SIZE_IN_BYTES = atoi(pchar); - - return 0; - } - else if (!strncmp(xml_line, "patch.type = "patch"; - pchar = fh_xml_get_value(xml_line, "filename"); - if (pchar && strcmp(pchar, "DISK")) - return -1; - return 0; - } - else if (!strncmp(xml_line, "response.type = "response"; - pchar = fh_xml_get_value(xml_line, "value"); - if (pchar) { - if (!strcmp(pchar, "ACK")) - fh_cmd->response.value = "ACK"; - else if(!strcmp(pchar, "NAK")) - fh_cmd->response.value = "NAK"; - else - fh_cmd->response.value = "OTHER"; - } - if (strstr(xml_line, "rawmode")) { - pchar = fh_xml_get_value(xml_line, "rawmode"); - if (pchar) { - fh_cmd->response.rawmode = !strcmp(pchar, "true"); - } - } - else if (strstr(xml_line, "MaxPayloadSizeToTargetInBytes")) { - pchar = fh_xml_get_value(xml_line, "MaxPayloadSizeToTargetInBytes"); - if (pchar) { - fh_cmd->response.MaxPayloadSizeToTargetInBytes = atoi(pchar); - } - } - return 0; - } - else if (!strncmp(xml_line, "program.type = "log"; - return 0; - } - - error_return(); -} - -static int fh_parse_xml_file(struct fh_data *fh_data, const char *xml_file) { - FILE *fp = fopen(xml_file, "rb"); - - if (fp == NULL) { - dbg_time("%s fail to fopen(%s), errno: %d (%s)\n", __func__, xml_file, errno, strerror(errno)); - error_return(); - } - - while (fgets(fh_data->xml_tx_buf, fh_data->xml_tx_size, fp)) { - char *xml_line = strstr(fh_data->xml_tx_buf, "<"); - char *c_start = NULL; - - if (!xml_line) - continue; - - c_start = strstr(xml_line, ""); - - if (c_end) { - /* - - - - */ - char *tmp = strstr(xml_line, "/>"); - if (tmp && (tmp < c_start || tmp > c_end)) { - memset(c_start, ' ', c_end - c_start + strlen("-->")); - goto __fh_parse_xml_line; - } - - continue; - } - else { - /* - - --> - */ - do { - if (fgets(fh_data->xml_tx_buf, fh_data->xml_tx_size, fp) == NULL) { break; }; - xml_line = fh_data->xml_tx_buf; - } while (!strstr(xml_line, "-->") && strstr(xml_line, " SAHARA_RESET"); - if (0 == sahara_tx_data (usb_handle, tx_buffer, sizeof(sahara_packet_reset))) { - dbg(LOG_ERROR, "Sending RESET packet failed"); - return 0; - } - - return 1; -#endif -} - -static int send_done_packet (void *usb_handle, void *tx_buffer) { - sahara_packet_done *sahara_done = (sahara_packet_done *)tx_buffer; - - sahara_done->header.command = le_uint32(SAHARA_DONE_ID); - sahara_done->header.length = le_uint32(sizeof(sahara_packet_done)); - // Send the image data - dbg(LOG_EVENT, "SENDING --> SAHARA_DONE"); - if (0 == sahara_tx_data (usb_handle, tx_buffer, sizeof(sahara_packet_done))) { - dbg(LOG_ERROR, "Sending DONE packet failed"); - return 0; - } - return 1; -} - -static int start_image_transfer(void *usb_handle, void *tx_buffer, const sahara_packet_read_data *sahara_read_data, FILE *file_handle) -{ - int retval = 0; - uint32_t bytes_read = 0, bytes_to_read_next; - uint32_t DataOffset = le_uint32(sahara_read_data->data_offset); - uint32_t DataLength = le_uint32(sahara_read_data->data_length); - - dbg(LOG_INFO, "0x%08x 0x%08x 0x%08x", le_uint32(sahara_read_data->image_id), DataOffset, DataLength); - - if (fseek(file_handle, (long)DataOffset, SEEK_SET)) { - dbg(LOG_INFO, "%d errno: %d (%s)", __LINE__, errno, strerror(errno)); - return 0; - } - - while (bytes_read < DataLength) { - bytes_to_read_next = MIN((uint32_t)DataLength - bytes_read, SAHARA_RAW_BUFFER_SIZE); - retval = fread(tx_buffer, 1, bytes_to_read_next, file_handle); - - if (retval < 0) { - dbg(LOG_ERROR, "file read failed: %s", strerror(errno)); - return 0; - } - - if ((uint32_t) retval != bytes_to_read_next) { - dbg(LOG_ERROR, "Read %d bytes, but was asked for 0x%08x bytes", retval, DataLength); - return 0; - } - - /*send the image data*/ - if (0 == sahara_tx_data (usb_handle, tx_buffer, bytes_to_read_next)) { - dbg(LOG_ERROR, "Tx Sahara Image Failed"); - return 0; - } - - bytes_read += bytes_to_read_next; - } - - return 1; -} - -static int start_image_transfer_64bit(void *usb_handle, void *tx_buffer, const sahara_packet_read_data_64bit *sahara_read_data_64bit, FILE *file_handle) -{ - sahara_packet_read_data sahara_read_data; - - sahara_read_data.header = sahara_read_data_64bit->header; - sahara_read_data.image_id = sahara_read_data_64bit->image_id; - sahara_read_data.data_offset = sahara_read_data_64bit->data_offset; - sahara_read_data.data_length = sahara_read_data_64bit->data_length; - - return start_image_transfer(usb_handle, tx_buffer, &sahara_read_data, file_handle); -} - -static int sahara_start(void *usb_handle, void *tx_buffer, void *rx_buffer, FILE *file_handle) { - uint32_t image_id = 0; - sahara_packet_header* sahara_cmd = (sahara_packet_header *)rx_buffer; - sahara_packet_hello *sahara_hello = (sahara_packet_hello *)rx_buffer; - sahara_packet_read_data *sahara_read_data = (sahara_packet_read_data *)rx_buffer; - sahara_packet_read_data_64bit *sahara_read_data_64bit = (sahara_packet_read_data_64bit *)rx_buffer; - sahara_packet_done_resp *sahara_done_resp = (sahara_packet_done_resp *)rx_buffer; - sahara_packet_end_image_tx *sahara_end_image_tx = (sahara_packet_end_image_tx *)rx_buffer; - - sahara_packet_hello_resp *sahara_hello_resp = (sahara_packet_hello_resp *)tx_buffer; - - dbg(LOG_EVENT, "STATE <-- SAHARA_WAIT_HELLO"); - if (0 == sahara_rx_data(usb_handle, rx_buffer, 0)) { -#if 0 - unsigned char edl_cmd[] = {0x4b, 0x65, 0x01, 0x00, 0x54, 0x0f, 0x7e}; - sahara_tx_data(usb_handle, edl_cmd, sizeof(edl_cmd)); -#else - sahara_tx_data(usb_handle, tx_buffer, 1); -#endif - if (0 == sahara_rx_data(usb_handle, rx_buffer, 0)) - return 0; - } - - //Check if the received command is a hello command - if (le_uint32(sahara_cmd->command) != SAHARA_HELLO_ID) { - dbg(LOG_ERROR, "Received a different command: %x while waiting for hello packet", sahara_hello->header.command); - send_reset_command(usb_handle, rx_buffer); - return 0; - } - - // Recieved hello, send the hello response - //Create a Hello request - sahara_hello_resp->header.command = le_uint32(SAHARA_HELLO_RESP_ID); - sahara_hello_resp->header.length = le_uint32(sizeof(sahara_packet_hello_resp)); - sahara_hello_resp->version = sahara_hello->version; //SAHARA_VERSION; - sahara_hello_resp->version_supported = sahara_hello->version_supported; //SAHARA_VERSION_SUPPORTED; - sahara_hello_resp->status = le_uint32(SAHARA_STATUS_SUCCESS); - sahara_hello_resp->mode = sahara_hello->mode; - sahara_hello_resp->reserved0 = le_uint32(1); - sahara_hello_resp->reserved1 = le_uint32(2); - sahara_hello_resp->reserved2 = le_uint32(3); - sahara_hello_resp->reserved3 = le_uint32(4); - sahara_hello_resp->reserved4 = le_uint32(5); - sahara_hello_resp->reserved5 = le_uint32(6); - - switch (le_uint32(sahara_hello->mode)) { - case SAHARA_MODE_IMAGE_TX_PENDING: - dbg(LOG_EVENT, "RECEIVED <-- SAHARA_MODE_IMAGE_TX_PENDING"); - break; - case SAHARA_MODE_IMAGE_TX_COMPLETE: - dbg(LOG_EVENT, "RECEIVED <-- SAHARA_MODE_IMAGE_TX_COMPLETE"); - break; - case SAHARA_MODE_MEMORY_DEBUG: - dbg(LOG_EVENT, "RECEIVED <-- SAHARA_MODE_MEMORY_DEBUG"); - break; - case SAHARA_MODE_COMMAND: - dbg(LOG_EVENT, "RECEIVED <-- SAHARA_MODE_COMMAND"); - break; - default: - dbg(LOG_EVENT, "RECEIVED <-- SAHARA_MODE_0x%x", le_uint32(sahara_hello->mode)); - break; - } - - if (le_uint32(sahara_hello->mode) != SAHARA_MODE_IMAGE_TX_PENDING) { - dbg(LOG_ERROR, "ERROR NOT SAHARA_MODE_IMAGE_TX_PENDING"); - sahara_hello_resp->mode = SAHARA_MODE_IMAGE_TX_PENDING; - } - - /*Send the Hello Resonse Request*/ - dbg(LOG_EVENT, "SENDING --> SAHARA_HELLO_RESPONSE"); - if (0 == sahara_tx_data (usb_handle, tx_buffer, sizeof(sahara_packet_hello_resp))) { - dbg(LOG_ERROR, "Tx Sahara Data Failed "); - return 0; - } - - while (1) { - dbg(LOG_INFO, "STATE <-- SAHARA_WAIT_COMMAND"); - if (0 == sahara_rx_data(usb_handle, rx_buffer, 0)) - return 0; - - if (le_uint32(sahara_cmd->command) == SAHARA_READ_DATA_ID) { - start_image_transfer(usb_handle, tx_buffer, sahara_read_data, file_handle); - } - else if (le_uint32(sahara_cmd->command) == SAHARA_64_BITS_READ_DATA_ID) { - start_image_transfer_64bit(usb_handle, tx_buffer, sahara_read_data_64bit, file_handle); - } - else if (le_uint32(sahara_cmd->command) == SAHARA_END_IMAGE_TX_ID) { - dbg(LOG_EVENT, "image_id = %d, status = %d", le_uint32(sahara_end_image_tx->image_id), le_uint32(sahara_end_image_tx->status)); - if (le_uint32(sahara_end_image_tx->status) == SAHARA_STATUS_SUCCESS) { - image_id = le_uint32(sahara_end_image_tx->image_id); - send_done_packet (usb_handle, tx_buffer); - break; - } else { - return 0; - } - } - else if (le_uint32(sahara_cmd->command) == SAHARA_HELLO_ID) { - continue; - } - else { - dbg(LOG_ERROR, "Received an unknown command: %d ", le_uint32(sahara_cmd->command)); - send_reset_command (usb_handle, tx_buffer); - return 0; - } - } - - dbg(LOG_EVENT, "STATE <-- SAHARA_WAIT_DONE_RESP"); - if (0 == sahara_rx_data(usb_handle, rx_buffer, 0)) - return 0; - - dbg(LOG_INFO, "image_tx_status = %d", le_uint32(sahara_done_resp->image_tx_status)); - - if (SAHARA_MODE_IMAGE_TX_PENDING == le_uint32(sahara_done_resp->image_tx_status)) { - if (image_id == 13) //prog_nand_firehose_9x07.mbn - return 1; - if (image_id == 7) //NPRG9x55.mbn - return 1; - if (image_id == 21) //sbl1.mbn, October 22 2020 2:12 PM, AG35CEVAR05A07T4G - return 1; - } - else if (SAHARA_MODE_IMAGE_TX_COMPLETE == le_uint32(sahara_done_resp->image_tx_status)) { - dbg(LOG_EVENT,"Successfully uploaded all images"); - return 1; - } - else { - dbg(LOG_ERROR, "Received unrecognized status %d at SAHARA_WAIT_DONE_RESP state", - le_uint32(sahara_done_resp->image_tx_status)); - return 0; - } - - return 0; -} - -int sahara_main(const char *firehose_dir, const char *firehose_mbn, void *usb_handle, int edl_mode_05c69008) { - int retval = 0; - char full_path[512]; - FILE *file_handle; - void *tx_buffer; - void *rx_buffer; - - if (edl_mode_05c69008) { - snprintf(full_path, sizeof(full_path), "%.255s/%.240s", firehose_dir, firehose_mbn); - } - else { - char *prog_nand_firehose_filename = NULL; - - snprintf(full_path, sizeof(full_path), "%.255s/..", firehose_dir); - if (!qfile_find_file(full_path, "NPRG9x", ".mbn", &prog_nand_firehose_filename) - && !qfile_find_file(full_path, "NPRG9x", ".mbn", &prog_nand_firehose_filename)) { - dbg(LOG_ERROR, "retrieve NPRG MBN failed."); - return ENOENT; - } - dbg(LOG_INFO, "prog_nand_firehose_filename = %s", prog_nand_firehose_filename); - - snprintf(full_path, sizeof(full_path), "%.255s/../%.240s", firehose_dir, prog_nand_firehose_filename); - free(prog_nand_firehose_filename); - } - - file_handle = fopen(full_path, "rb"); - if (file_handle == NULL) { - dbg(LOG_INFO, "%s %d %s errno: %d (%s)", __func__, __LINE__, full_path, errno, strerror(errno)); - return ENOENT; - } - - rx_buffer = malloc (SAHARA_RAW_BUFFER_SIZE); - tx_buffer = malloc (SAHARA_RAW_BUFFER_SIZE); - - if (NULL == rx_buffer || NULL == tx_buffer) { - dbg(LOG_ERROR, "Failed to allocate sahara buffers"); - return ENOMEM; - } - - retval = sahara_start(usb_handle, tx_buffer, rx_buffer, file_handle); - if (0 == retval) { - dbg(LOG_ERROR, "Sahara protocol error"); - } - else { - dbg(LOG_STATUS, "Sahara protocol completed"); - } - - free(rx_buffer); - free(tx_buffer); - fclose(file_handle); - - if (retval) - return 0; - - return __LINE__; -} diff --git a/rooter/0optionalapps/qfirehose/src/sahara_protocol.h b/rooter/0optionalapps/qfirehose/src/sahara_protocol.h deleted file mode 100644 index bb88a2c..0000000 --- a/rooter/0optionalapps/qfirehose/src/sahara_protocol.h +++ /dev/null @@ -1,385 +0,0 @@ -/*=========================================================================== - * FILE: - * sahara_packet.h - * - * DESCRIPTION: - * Sahara protocol states and structure declaration. - * - * Copyright (C) 2012 Qualcomm Technologies, Inc. All rights reserved. - * Qualcomm Technologies Proprietary/GTDR - * - * All data and information contained in or disclosed by this document is - * confidential and proprietary information of Qualcomm Technologies, Inc. and all - * rights therein are expressly reserved. By accepting this material the - * recipient agrees that this material and the information contained therein - * is held in confidence and in trust and will not be used, copied, reproduced - * in whole or in part, nor its contents revealed in any manner to others - * without the express written permission of Qualcomm Technologies, Inc. - * =========================================================================== - * - * sahara_packet.h : Sahara protocol states and structure declaration. - * ========================================================================================== - * $Header: //components/rel/boot.bf/3.1.4/boot_images/core/storage/tools/QSaharaServer/src/sahara_protocol.h#1 $ - * $DateTime: 2017/02/21 04:58:32 $ - * $Author: pwbldsvc $ - * - * Edit History: - * YYYY-MM-DD who why - * ----------------------------------------------------------------------------- - * 2010-09-28 ng Added command mode support - * 2010-10-18 ab Added memory debug mode support - * - * Copyright 2012 by Qualcomm Technologies, Inc. All Rights Reserved. - * - *========================================================================================== - */ - -#ifndef SAHARA_PROTOCOL_H -#define SAHARA_PROTOCOL_H - -/*=========================================================================== - * - * INCLUDE FILES - * - * ===========================================================================*/ - -/*=========================================================================== - * - * PUBLIC DATA DECLARATIONS - * - * ===========================================================================*/ -// Sahara Protocol Version -#define SAHARA_VERSION 2 -#define SAHARA_VERSION_SUPPORTED 4 - -/*Maximum 1 megabyte tx buffer size*/ - -#define SAHARA_RAW_BUFFER_SIZE (4*1024) - -// Sahara command IDs -typedef enum -{ - SAHARA_NO_CMD_ID = 0x00, - SAHARA_HELLO_ID = 0x01, // sent from target to host - SAHARA_HELLO_RESP_ID = 0x02, // sent from host to target - SAHARA_READ_DATA_ID = 0x03, // sent from target to host - SAHARA_END_IMAGE_TX_ID = 0x04, // sent from target to host - SAHARA_DONE_ID = 0x05, // sent from host to target - SAHARA_DONE_RESP_ID = 0x06, // sent from target to host - SAHARA_RESET_ID = 0x07, // sent from host to target - SAHARA_RESET_RESP_ID = 0x08, // sent from target to host - SAHARA_MEMORY_DEBUG_ID = 0x09, // sent from target to host - SAHARA_MEMORY_READ_ID = 0x0A, // sent from host to target - SAHARA_CMD_READY_ID = 0x0B, // sent from target to host - SAHARA_CMD_SWITCH_MODE_ID = 0x0C, // sent from host to target - SAHARA_CMD_EXEC_ID = 0x0D, // sent from host to target - SAHARA_CMD_EXEC_RESP_ID = 0x0E, // sent from target to host - SAHARA_CMD_EXEC_DATA_ID = 0x0F, // sent from host to target - SAHARA_64_BITS_MEMORY_DEBUG_ID = 0x10, // sent from target to host - SAHARA_64_BITS_MEMORY_READ_ID = 0x11, // sent from host to target - SAHARA_64_BITS_READ_DATA_ID = 0x12, - // place all new commands above this - SAHARA_LAST_CMD_ID, - SAHARA_MAX_CMD_ID = 0x7FFFFFFF // To ensure 32-bits wide -} boot_sahara_cmd_id; - -typedef enum { - SAHARA_IMAGE_TYPE_BINARY = 0, /* Binary format */ - SAHARA_IMAGE_TYPE_ELF, /* ELF format */ - SAHARA_IMAGE_UNKNOWN = 0x7FFFFFFF /* To ensure 32-bits wide */ -} boot_sahara_image; - -// Status codes for Sahara -typedef enum -{ - // Success - SAHARA_STATUS_SUCCESS = 0x00, - - // Invalid command received in current state - SAHARA_NAK_INVALID_CMD = 0x01, - - // Protocol mismatch between host and target - SAHARA_NAK_PROTOCOL_MISMATCH = 0x02, - - // Invalid target protocol version - SAHARA_NAK_INVALID_TARGET_PROTOCOL = 0x03, - - // Invalid host protocol version - SAHARA_NAK_INVALID_HOST_PROTOCOL = 0x04, - - // Invalid packet size received - SAHARA_NAK_INVALID_PACKET_SIZE = 0x05, - - // Unexpected image ID received - SAHARA_NAK_UNEXPECTED_IMAGE_ID = 0x06, - - // Invalid image header size received - SAHARA_NAK_INVALID_HEADER_SIZE = 0x07, - - // Invalid image data size received - SAHARA_NAK_INVALID_DATA_SIZE = 0x08, - - // Invalid image type received - SAHARA_NAK_INVALID_IMAGE_TYPE = 0x09, - - // Invalid tranmission length - SAHARA_NAK_INVALID_TX_LENGTH = 0x0A, - - // Invalid reception length - SAHARA_NAK_INVALID_RX_LENGTH = 0x0B, - - // General transmission or reception error - SAHARA_NAK_GENERAL_TX_RX_ERROR = 0x0C, - - // Error while transmitting READ_DATA packet - SAHARA_NAK_READ_DATA_ERROR = 0x0D, - - // Cannot receive specified number of program headers - SAHARA_NAK_UNSUPPORTED_NUM_PHDRS = 0x0E, - - // Invalid data length received for program headers - SAHARA_NAK_INVALID_PDHR_SIZE = 0x0F, - - // Multiple shared segments found in ELF image - SAHARA_NAK_MULTIPLE_SHARED_SEG = 0x10, - - // Uninitialized program header location - SAHARA_NAK_UNINIT_PHDR_LOC = 0x11, - - // Invalid destination address - SAHARA_NAK_INVALID_DEST_ADDR = 0x12, - - // Invalid data size receieved in image header - SAHARA_NAK_INVALID_IMG_HDR_DATA_SIZE = 0x13, - - // Invalid ELF header received - SAHARA_NAK_INVALID_ELF_HDR = 0x14, - - // Unknown host error received in HELLO_RESP - SAHARA_NAK_UNKNOWN_HOST_ERROR = 0x15, - - // Timeout while receiving data - SAHARA_NAK_TIMEOUT_RX = 0x16, - - // Timeout while transmitting data - SAHARA_NAK_TIMEOUT_TX = 0x17, - - // Invalid mode received from host - SAHARA_NAK_INVALID_HOST_MODE = 0x18, - - // Invalid memory read access - SAHARA_NAK_INVALID_MEMORY_READ = 0x19, - - // Host cannot handle read data size requested - SAHARA_NAK_INVALID_DATA_SIZE_REQUEST = 0x1A, - - // Memory debug not supported - SAHARA_NAK_MEMORY_DEBUG_NOT_SUPPORTED = 0x1B, - - // Invalid mode switch - SAHARA_NAK_INVALID_MODE_SWITCH = 0x1C, - - // Failed to execute command - SAHARA_NAK_CMD_EXEC_FAILURE = 0x1D, - - // Invalid parameter passed to command execution - SAHARA_NAK_EXEC_CMD_INVALID_PARAM = 0x1E, - - // Unsupported client command received - SAHARA_NAK_EXEC_CMD_UNSUPPORTED = 0x1F, - - // Invalid client command received for data response - SAHARA_NAK_EXEC_DATA_INVALID_CLIENT_CMD = 0x20, - - // Failed to authenticate hash table - SAHARA_NAK_HASH_TABLE_AUTH_FAILURE = 0x21, - - // Failed to verify hash for a given segment of ELF image - SAHARA_NAK_HASH_VERIFICATION_FAILURE = 0x22, - - // Failed to find hash table in ELF image - SAHARA_NAK_HASH_TABLE_NOT_FOUND = 0x23, - - // Place all new error codes above this - SAHARA_NAK_LAST_CODE, - - SAHARA_NAK_MAX_CODE = 0x7FFFFFFF // To ensure 32-bits wide -} boot_sahara_status; - -// Status of all image transfers -typedef enum -{ - SAHARA_MODE_IMAGE_TX_PENDING = 0x0, - SAHARA_MODE_IMAGE_TX_COMPLETE = 0x1, - SAHARA_MODE_MEMORY_DEBUG = 0x2, - SAHARA_MODE_COMMAND = 0x3, - - // place all new commands above this - SAHARA_MODE_LAST, - SAHARA_MODE_MAX = 0x7FFFFFFF -} boot_sahara_mode; - -// Executable commands when target is in command mode -typedef enum -{ - SAHARA_EXEC_CMD_NOP = 0x00, - SAHARA_EXEC_CMD_SERIAL_NUM_READ = 0x01, - SAHARA_EXEC_CMD_MSM_HW_ID_READ = 0x02, - SAHARA_EXEC_CMD_OEM_PK_HASH_READ = 0x03, - SAHARA_EXEC_CMD_SWITCH_DMSS = 0x04, - SAHARA_EXEC_CMD_SWITCH_STREAMING = 0x05, - SAHARA_EXEC_CMD_READ_DEBUG_DATA = 0x06, - - // place all new commands above this - SAHARA_EXEC_CMD_LAST, - SAHARA_EXEC_CMD_MAX = 0x7FFFFFFF -} boot_sahara_exec_cmd_id; - -/* Sahara Protocol states */ -typedef enum { - SAHARA_WAIT_HELLO, - SAHARA_WAIT_COMMAND, - SAHARA_WAIT_RESET_RESP, - SAHARA_WAIT_DONE_RESP, - SAHARA_WAIT_MEMORY_READ, - SAHARA_WAIT_CMD_EXEC_RESP, - SAHARA_WAIT_MEMORY_TABLE, - SAHARA_WAIT_MEMORY_REGION, -} boot_sahara_state; - -/* ============================================================================= */ -/* Sahara protocol packet defintions */ -/* ============================================================================= */ - -typedef struct -{ - uint32_t command; // command ID - uint32_t length; // packet length incl command and length -} sahara_packet_header; - -// HELLO command packet type - sent from target to host -// indicates start of protocol on target side -typedef struct -{ - sahara_packet_header header; - uint32_t version; // target protocol version number - uint32_t version_supported; // minimum protocol version number supported - // on target - uint32_t cmd_packet_length; // maximum packet size supported for command - // packets - uint32_t mode; // expected mode of target operation - uint32_t reserved0; // reserved field - uint32_t reserved1; // reserved field - uint32_t reserved2; // reserved field - uint32_t reserved3; // reserved field - uint32_t reserved4; // reserved field - uint32_t reserved5; // reserved field -} sahara_packet_hello; - -// HELLO_RESP command packet type - sent from host to target -// response to hello, protocol version running on host and status sent -typedef struct -{ - sahara_packet_header header; - uint32_t version; // host protocol version number - uint32_t version_supported; // minimum protocol version number supported - // on host - uint32_t status; // OK or error condition - uint32_t mode; // mode of operation for target to execute - uint32_t reserved0; // reserved field - uint32_t reserved1; // reserved field - uint32_t reserved2; // reserved field - uint32_t reserved3; // reserved field - uint32_t reserved4; // reserved field - uint32_t reserved5; // reserved field -} sahara_packet_hello_resp; - -// READ_DATA command packet type - sent from target to host -// sends data segment offset and length to be read from current host -// image file -typedef struct -{ - sahara_packet_header header; - uint32_t image_id; // ID of image to be transferred - uint32_t data_offset; // offset into image file to read data from - uint32_t data_length; // length of data segment to be retreived - // from image file -} sahara_packet_read_data; - -// READ_DATA_64 command packet type - sent from target to host -// sends data segment offset and length to be read from current host -// image file -/* -#ifdef WINDOWSPC -#define PACK( __Declaration__ ) __pragma( pack(push, 1) ) __Declaration__ __pragma( pack(pop) ) -PACK( -typedef struct // note for gcc use __attribute__((__packed__)) -{ - sahara_packet_header header; - uint32_t image_id; // ID of image to be transferred - uint64_t data_offset; // offset into image file to read data from - uint32_t data_length; // length of data segment to be retreived - // from image file -} sahara_packet_read_data_64bit; -); -#else -typedef __attribute__((__packed__)) struct -{ - sahara_packet_header header; - uint32_t image_id; // ID of image to be transferred - uint64_t data_offset; // offset into image file to read data from - uint32_t data_length; // length of data segment to be retreived - // from image file -} sahara_packet_read_data_64bit; -#endif -*/ -typedef struct -{ - sahara_packet_header header; - uint64_t image_id; // ID of image to be transferred - uint64_t data_offset; // offset into image file to read data from - uint64_t data_length; // length of data segment to be retreived - // from image file -} sahara_packet_read_data_64bit; - -// END_IMAGE_TX command packet type - sent from target to host -// indicates end of a single image transfer and status of transfer -typedef struct -{ - sahara_packet_header header; - uint32_t image_id; // ID of image to be transferred - uint32_t status; // OK or error condition -} sahara_packet_end_image_tx; - -// DONE packet type - sent from host to target -// indicates end of single image transfer -typedef struct -{ - sahara_packet_header header; -} sahara_packet_done; - -// DONE_RESP packet type - sent from target to host -// indicates end of all image transfers -typedef struct -{ - sahara_packet_header header; - uint32_t image_tx_status; // indicates if all images have been - // transferred; - // 0 = IMAGE_TX_PENDING - // 1 = IMAGE_TX_COMPLETE -} sahara_packet_done_resp; - -// RESET packet type - sent from host to target -// indicates to target to reset -typedef struct -{ - sahara_packet_header header; -} sahara_packet_reset; - -// RESET_RESP packet type - sent from target to host -// indicates to host that target has reset -typedef struct -{ - sahara_packet_header header; -} sahara_packet_reset_resp; -#endif /* SAHARA_PACKET_H */ diff --git a/rooter/0optionalapps/qfirehose/src/stream_download_protocol.c b/rooter/0optionalapps/qfirehose/src/stream_download_protocol.c deleted file mode 100644 index 1033565..0000000 --- a/rooter/0optionalapps/qfirehose/src/stream_download_protocol.c +++ /dev/null @@ -1,766 +0,0 @@ -/****************************************************************************** - @file stream_download_protocol.c - @brief stream protocol. - - DESCRIPTION - QFirehoe Tool for USB and PCIE of Quectel wireless cellular modules. - - INITIALIZATION AND SEQUENCING REQUIREMENTS - None. - - --------------------------------------------------------------------------- - Copyright (c) 2016 - 2020 Quectel Wireless Solution, Co., Ltd. All Rights Reserved. - Quectel Wireless Solution Proprietary and Confidential. - --------------------------------------------------------------------------- -******************************************************************************/ - -#include "usb_linux.h" -#include "hostdl_packet.h" - -#define true (1==1) -#define false (1!=1) - -#define MAX_SEND_BUFFER_SIZE 1280 -#define MAX_RECEIVE_BUFFER_SIZE 1280 -unsigned char g_Transmit_Buffer[MAX_SEND_BUFFER_SIZE]; -int g_Transmit_Length; - -unsigned char g_Receive_Buffer[MAX_RECEIVE_BUFFER_SIZE]; -int g_Receive_Bytes; - -static void *stream_usb_handle; - -static void dump_buffer(unsigned char * buff, int len) -{ - int i = 0; - - dbg_time("dump buffer: %d bytes\n", len); - for(i = 0; i < len; i++) - { - dbg_time("%02x ", buff[i]); - } - dbg_time("\nend\n"); - -} - -#define CRC_16_L_SEED 0xFFFF -#define CRC_TAB_SIZE 256 /* 2^CRC_TAB_BITS */ -#define CRC_16_L_POLYNOMIAL 0x8408 - -static const uint16_t crc_16_l_table[ CRC_TAB_SIZE ] = { - 0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf, - 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7, - 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e, - 0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876, - 0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd, - 0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5, - 0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c, - 0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974, - 0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb, - 0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3, - 0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a, - 0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72, - 0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9, - 0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1, - 0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738, - 0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70, - 0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7, - 0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff, - 0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036, - 0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e, - 0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5, - 0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd, - 0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134, - 0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c, - 0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3, - 0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb, - 0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232, - 0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a, - 0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1, - 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9, - 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330, - 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78 -}; - -unsigned short crc_16_l_calc(unsigned char *buf_ptr, int len) { - int data, crc_16; - for (crc_16 = CRC_16_L_SEED; len >= 8; len -= 8, buf_ptr++) { - crc_16 = crc_16_l_table[(crc_16 ^ *buf_ptr) & 0x00ff] ^ (crc_16 >> 8); - } - if (len != 0) { - - data = ((int) (*buf_ptr)) << (16 - 8); - - while (len-- != 0) { - if (((crc_16 ^ data) & 0x01) != 0) { - - crc_16 >>= 1; - crc_16 ^= CRC_16_L_POLYNOMIAL; - - } else { - - crc_16 >>= 1; - - } - - data >>= 1; - } - } - return (~crc_16); -} - -void compute_reply_crc () -{ - unsigned short crc = crc_16_l_calc (g_Transmit_Buffer, g_Transmit_Length * 8); - g_Transmit_Buffer[g_Transmit_Length] = crc & 0xFF; - g_Transmit_Buffer[g_Transmit_Length + 1] = crc >> 8; - g_Transmit_Length += 2; -} - -static void compose_packet(unsigned char cmd, unsigned char *parameter, uint32_t parameter_len, unsigned char *data, uint32_t data_len) { - uint32_t i; - - g_Transmit_Buffer[0] = cmd; - if (parameter == NULL) parameter_len = 0; - if (data == NULL) data_len = 0; - for (i = 0; i < parameter_len; i++) { - g_Transmit_Buffer[1 + i] = parameter[i]; - } - for (i = 0; i < data_len; i++) { - g_Transmit_Buffer[1 + parameter_len + i] = data[i]; - } - g_Transmit_Length = 1 + parameter_len + data_len; - g_Transmit_Buffer[g_Transmit_Length] = 0; -} - -static unsigned char stream_tx_buf[1280]; -#define CHECK_FOR_DATA() do {} while(0) -#define TRANSMIT_BYTE(_byte) do { stream_tx_buf[j++] = _byte; } while(0) - -static int send_packet(int flag) { - int i; - int ch; - int j; - - j = 0; - - - CHECK_FOR_DATA (); - - /* Since we don't know how long it's been. */ - if (!!flag) { - TRANSMIT_BYTE (0x7E); - } - - for (i = 0; i < g_Transmit_Length; i++) - { - /* we only need to check once every 31 characters, since RX and TX - * run at about the same speed, and our RX FIFO is 64 characters - */ - if ((i & 31) == 31) - CHECK_FOR_DATA (); - - ch = g_Transmit_Buffer[i]; - - if (ch == 0x7E || ch == 0x7D) - { - TRANSMIT_BYTE (0x7D); - TRANSMIT_BYTE (0x20 ^ ch); /*lint !e734 */ - } - else - { - TRANSMIT_BYTE (ch); /*lint !e734 */ - } - } - - CHECK_FOR_DATA (); - TRANSMIT_BYTE (0x7E); - -#if 0 - /* Hack for USB protocol. If we have an exact multiple of the USB frame - * size, then the last frame will not be sent out. The USB standard says - * that a "short packet" needs to be sent to flush the data. Two flag - * characters can serve as the short packet. Doing it this way, we only - * perform this test once on every entire packet from the target, so the - * over head is not too much. - */ - if ((j%512) == 0) - { - TRANSMIT_BYTE (0x7E); - TRANSMIT_BYTE (0x7E); - } - #endif - - return (qusb_noblock_write(stream_usb_handle, stream_tx_buf, j, j, 3000, 1) == j) ? 0 : -1; -} - -static int remove_escape_hdlc_flag(unsigned char* buffer, int len) -{ - int i = 0; - int index = 0; - int escape = 0; - //dump_buffer(buffer, len); - if(len == 0) return 0; - //ignore the first HDLC FLAG bytes - while(buffer[i] == 0x7e) - { - i++; - } - //all bytes is HDLC FLAG - if(i == len) - return 0; - for(; i < len; i++) - { - if(buffer[i] == 0x7D) - { - escape = 1; - continue; - } - if(escape == 1) - { - escape = 0; - buffer[i] ^= 0x20; - } - buffer[index++] = buffer[i]; - } - buffer[index] = 0; - //dump_buffer(buffer, index); - return index; -} - -static int receive_packet(void) -{ - int bytesread = 0; - unsigned char *buff = g_Receive_Buffer; - int idx = 0; - do - { - bytesread = qusb_noblock_read(stream_usb_handle, &buff[idx], MAX_RECEIVE_BUFFER_SIZE, 0, 3000); - if(bytesread == 0) - { - //timeout may be error - dbg_time("%s timeout\n", __FUNCTION__); - return 0; - } - //dump_buffer(&buff[idx], bytesread); - idx += bytesread; - if(buff[idx - 1] == 0x7e) - { - //check the packet whether valid. - g_Receive_Bytes = remove_escape_hdlc_flag(buff, idx); - if(g_Receive_Bytes == 0) - { - continue; - }else{ - return 1; - } - } - }while(1); - - return 0; -} - -static int handle_hello(void) -{ - static const char host_header[] = "QCOM fast download protocol host"; - //static const char target_header[] = "QCOM fast download protocol targ"; - //char string1[64]; - //int size; - int err; - dbg_time("%s\n", __func__); - - memset(&g_Transmit_Buffer[0],0,sizeof(g_Transmit_Buffer)); - g_Transmit_Buffer[HELLO_CMD_OFFSET] = HELLO_REQ; - memcpy(&g_Transmit_Buffer[HELLO_MAGIC_NUM_OFFSET],host_header,32); - g_Transmit_Buffer[HELLO_MAX_VER_OFFSET] = STREAM_DLOAD_MAX_VER; - g_Transmit_Buffer[HELLO_MIN_VER_OFFSET] = STREAM_DLOAD_MIN_VER; - g_Transmit_Buffer[HELLO_MAX_DATA_SZ_1_OFFSET] = 0; - g_Transmit_Length = 36; - - compute_reply_crc(); - send_packet(1); - - int timeout = 5; - do{ - err = receive_packet(); - if(err == 1){ - switch(g_Receive_Buffer[0]) - { - case 0x02: - return 1; - case 0x0d: - continue; - default: - //dump_buffer(g_Receive_Buffer, 64); - return 0; - } - } - else if(err == -1){ - dbg_time("error = %d, strerr = %s\n", errno, strerror(errno)); - return 0; - } - timeout--; - }while(timeout); - - return 0; -} - -static int handle_security_mode(unsigned char trusted) { - dbg_time("%s trusted = %d\n", __func__, trusted); - compose_packet(0x17, &trusted, 1, NULL, 0); - compute_reply_crc(); - send_packet(1); - int timeout = 5; - do{ - if(receive_packet() == 1){ - switch(g_Receive_Buffer[0]) - { - case 0x18: - return 1; - default: - return 0; - } - }else - { - timeout--; - if(timeout==0) - { - dbg_time("%s timeout\n", __FUNCTION__); - return 0; - } - } - }while(1); - return 0; -} -/* -set download flag in module, quectel custom command, -if flag : reboot, module will enter DM -if not flag: reboot normal -*/ -static int handle_quectel_download_flag(unsigned char mode) { - //byte mode = 1; - compose_packet(0x60, &mode, 1, NULL, 0); - compute_reply_crc(); - send_packet(1); - int timeout = 5; - do{ - if(receive_packet() == 1) - { - switch(g_Receive_Buffer[0]) - { - case 0x61: - switch( g_Receive_Buffer[1] ) - { - case 0x00: - return 1; - default: - return 0; - } - break; - case 0x0E: - dbg_time("Invalid command"); - return 2; - default: - dump_buffer(g_Receive_Buffer, 64); - return 0; - } - } - else - { - timeout--; - if(timeout==0) - { - dbg_time("%s timeout\n", __FUNCTION__); - return 0; - } - } - }while(1); -} - -static const char *stream_firehose_dir; -static int stread_fread(const char *filename, void **pp_filebuf) { - int filesize = 0; - FILE *fp; - char fullpath[MAX_PATH*2]; - - snprintf(fullpath, sizeof(fullpath), "%.240s/../%.240s", stream_firehose_dir, filename); - fp = fopen(fullpath, "rb"); - if (fp == NULL) { - dbg_time("fail to fope %s, errno: %d (%s)\n", fullpath, errno, strerror(errno)); - return 0; - } - - fseek(fp, 0, SEEK_END); - filesize = ftell(fp); - - *pp_filebuf = malloc(filesize); - fseek(fp, 0, SEEK_SET); - filesize = fread(*pp_filebuf, 1, filesize, fp); - fclose(fp); - - dbg_time("%s filename=%s, filesize=%d\n", __func__, filename, filesize); - return filesize; -} - -static int handle_parti_tbl(unsigned char override) { - int timeout = 5; - int filesize; - void *filebuf; - const char *partition_path= "partition.mbn"; - dbg_time("%s override = %d\n", __func__, override); - - filesize = stread_fread(partition_path, &filebuf); - if (filesize <= 0) - return 0; - - compose_packet(0x19, &override, 1, filebuf, filesize); - compute_reply_crc(); - send_packet(1); - free(filebuf); - - do{ - if(receive_packet() == 1){ - dbg_time("handle_parti_tbl command = %02x, status = %02x\n", g_Receive_Buffer[0], g_Receive_Buffer[1]); - switch(g_Receive_Buffer[0]) - { - case 0x1a: - switch( g_Receive_Buffer[1] ){ - case 0x00: - return 1; - case 0x01: //0x1 this means that the original partition is different from the current partition,try to send partition - return 0; - case 0x02: //0x2 Partition table format not recognized, does not accept override - return 0; - case 0x03: //0x3 Erase operation failed - return 0; - break; - default: - return 0; - } - default: - return 0; - } - }else - { - timeout--; - if(timeout == 0) - { - dbg_time("%s timeout\n", __FUNCTION__); - return 0; - } - } - }while(1); -} - -static int handle_reset(void) { - dbg_time("%s\n", __func__); - compose_packet(0x0b, NULL, 0, NULL, 0); - compute_reply_crc(); - send_packet(1); -#if 1 - return 1; -#else - int timeout = 5; - do{ - if(receive_packet() == 1){ - switch(g_Receive_Buffer[0]) - { - case 0x0c: - return 1; - case 0x0d: - continue; - default: - dump_buffer(g_Receive_Buffer, 64); - return 0; - } - } - else - { - - timeout--; - if(timeout == 0) - { - dbg_time("%s timeout\n", __FUNCTION__); - return 0; - } - } - }while(1); -#endif -} - -/******pkt_open_multi_image*******/ - -static void pkt_open_multi_image (unsigned char mode, unsigned char *data, uint32_t size) { - compose_packet(0x1b, &mode, 1, data, size); - compute_reply_crc(); -} - -static int handle_openmulti(uint32_t size,unsigned char* data) -{ - int timeout = 5; - unsigned char mode=0x0e; - - pkt_open_multi_image(mode, data, size); - send_packet(1); - do { - if (receive_packet() == 1) { - switch (g_Receive_Buffer[0]) { - case 0x1c: - return 1; - case 0x0d: - continue; - default: - return 0; - } - }else - { - - timeout--; - if(timeout == 0) - { - dbg_time("%s timeout\n", __FUNCTION__); - return 0; - } - } - } while (1); - return 1; -} - -/******pkt_write_multi_image*******/ -static void pkt_write_multi_image(uint32_t addr, unsigned char*data, uint16_t size) { - unsigned char parameter[4] = {(unsigned char)(addr)&0xff, (unsigned char)(addr>>8)&0xff, (unsigned char)(addr>>16)&0xff, (unsigned char)(addr>>24)&0xff}; - compose_packet(0x07, parameter, 4, data, size); - compute_reply_crc(); -} - -static int handle_write(unsigned char *data, uint32_t size) -{ - //uint32_t total_size; - uint32_t addr = 0; - uint32_t writesize; - uint32_t buffer_size = 1024; - //int loop = 1; - int retry_cnt = 3; //if send failed,send again - int ret; - - //total_size = size; - while(size) - { - writesize = (size < buffer_size) ? size : buffer_size; - - pkt_write_multi_image(addr, data, writesize); -start_send_packet: - ret = send_packet(1); - if(0 != ret) - { - dbg_time("io read/write failed\n"); - return 0; - } - if(receive_packet() == 1){ - switch(g_Receive_Buffer[0]) - { - case 0x08: - size -= writesize; - addr += writesize; - //retry_cnt=5; - break; - default: - goto retry_send_packet; - return 0; - } - } - else - { - -retry_send_packet: - retry_cnt--; - if(retry_cnt > 0) - { - goto start_send_packet; - } - else - { - dbg_time( "value is [0x%02x]",g_Receive_Buffer[0]); - return 0; - } - } - - } - - return 1; -} -/******PARTITION*******/ -static int handle_close(void) { - int timeout = 5; - compose_packet(0x15, NULL, 0, NULL, 0); - compute_reply_crc(); - send_packet(1); - - do{ - if(receive_packet() == 1){ - switch(g_Receive_Buffer[0]) - { - case 0x16: - return 1; - default: - return 0; - } - }else - { - - timeout--; - if(timeout == 0) - { - dbg_time("%s timeout\n", __FUNCTION__); - return 0; - } - } - }while(1); - return 0; -} - -static int do_flash_mbn(const char *partion, const char *filepath) { - int result = false; - void *filebuf = NULL; - int filesize = 0; - - dbg_time("%s %s\n", __func__, partion); - - if (filepath) { - filesize = stread_fread(filepath, &filebuf); - if (filesize <= 0) - return 0; - } - else { - filesize = 4*1024; - filebuf = (unsigned char *)malloc(filesize); - memset(filebuf, 0x00, filesize); - } - - result = handle_openmulti(strlen(partion) + 1, (unsigned char *)partion); - if (result == false) { - dbg_time("%s open failed\n", partion); - goto __fail; - } - - dbg_time("sending '%s' (%dKB)\n", partion, (int)(filesize/1024)); - - result = handle_write(filebuf, filesize); - if (result == false) { - dbg_time("%s download failed\n", partion); - goto __fail; - } - - result = handle_close(); - if (result == false) { - dbg_time("%s close failed.\n", partion); - goto __fail; - } - - dbg_time("OKAY\n"); - -__fail: - free(filebuf); - - return result; -} - -int stream_download(const char *firehose_dir, void *usb_handle, unsigned qusb_zlp_mode) -{ - (void)qusb_zlp_mode; - stream_usb_handle = usb_handle; - stream_firehose_dir = firehose_dir; - - if (handle_hello() == false) { - dbg_time("Send hello command fail\n"); - return false; - } - - /* - hello packet will set dload flag in module, when upgrade interrup, restart module,module will enter dm(quectel sbl) - */ - if (handle_security_mode(1) == false) { - dbg_time("Send trust command fail\n"); - return false; - } - - if (handle_parti_tbl(0) == false) { - dbg_time("----------------------------------\n"); - dbg_time("Detect partition mismatch.\n"); - dbg_time("Download parition with override.\n"); - dbg_time("----------------------------------\n"); - - if(handle_parti_tbl(1) == false) { - dbg_time("override failed. \n"); - return false; - } - - /* - partition is not match, the download flag will be clear, so set it again, reset will clear it - */ - if(handle_quectel_download_flag(1) == false) { - dbg_time("Set Quectel download flag failed\n"); - } - else { - dbg_time("Set Quectel download flag successfully\n"); - } - } - -#if 1 - if (do_flash_mbn("0:SBL", "sbl1.mbn") == false) { - return false; - } -#endif - - if (handle_reset() == false) { - dbg_time("Send reset command failed\n"); - return false; - } - - dbg_time("%s successful\n", __func__); - - return true; -} - -//hunter.lv add -//retrieve module soft revision - -typedef struct -{ - unsigned char cmd_code; - unsigned char version; - unsigned char reserved[2]; - unsigned char msm[4]; - unsigned char mobile_modle_number[4]; - unsigned char mobile_software_revision[1]; -}__attribute__ ((packed))extended_build_id_response_t; - -int retrieve_soft_revision(void *usb_handle, uint8_t *mobile_software_revision, unsigned length) -{ -/* -80-v1294-1_yyd_serial_interface_control_document_(icd)_for_cdma_dual-mode_subscriber_station_data 3.4.122 Extended Build ID -*/ - uint8_t req1[] = {0x7E,0x7C, 0x93,0x49, 0x7E}; - int ret; - uint8_t *rx_buff = malloc(2048); - - memset(mobile_software_revision, 0x00, length); - - if (rx_buff == NULL) - return 0; - - ret = qusb_noblock_write(usb_handle, req1, sizeof(req1), sizeof(req1), 1000, 0); - if(ret > 0) { - ret = qusb_noblock_read(usb_handle, rx_buff , 2048, 1, 3000); - if (ret > 0) { - if (rx_buff[0] == 0x7C && rx_buff[ret - 1] == 0x7E) { - extended_build_id_response_t *rsp = (extended_build_id_response_t *)rx_buff; - (void)length; - memcpy(mobile_software_revision, rsp->mobile_software_revision, strlen((const char *)rsp->mobile_software_revision)); - } - } - } - - free(rx_buff); - return (mobile_software_revision[0] != '\0'); -} diff --git a/rooter/0optionalapps/qfirehose/src/usb2tcp.c b/rooter/0optionalapps/qfirehose/src/usb2tcp.c deleted file mode 100644 index 0d8e4d3..0000000 --- a/rooter/0optionalapps/qfirehose/src/usb2tcp.c +++ /dev/null @@ -1,338 +0,0 @@ -/****************************************************************************** - @file tty2tcp.c - @brief switch data between tcp socket and ttyUSB port. - - DESCRIPTION - QLog Tool for USB and PCIE of Quectel wireless cellular modules. - - INITIALIZATION AND SEQUENCING REQUIREMENTS - None. - - --------------------------------------------------------------------------- - Copyright (c) 2016 - 2020 Quectel Wireless Solution, Co., Ltd. All Rights Reserved. - Quectel Wireless Solution Proprietary and Confidential. - --------------------------------------------------------------------------- -******************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 20) -#include -#else -#include -#endif -//#include -#include "usb_linux.h" -#include //for __BYTE_ORDER -char *inet_ntoa(struct in_addr in); - -#define dprintf dbg_time - -#define MIN(a,b) ((a) < (b)? (a) : (b)) - -#define MAX_USBFS_BULK_IN_SIZE (4 * 1024) -#define MAX_USBFS_BULK_OUT_SIZE (16 * 1024) - -static uint32_t cpu_to_le32 (uint32_t v32) { - uint32_t tmp = v32; -#if __BYTE_ORDER == __LITTLE_ENDIAN -#else - unsigned char *s = (unsigned char *)(&v32); - unsigned char *d = (unsigned char *)(&tmp); - d[0] = s[3]; - d[1] = s[2]; - d[2] = s[1]; - d[3] = s[0]; -#endif - return tmp; -} -#define le32_to_cpu(_v32) cpu_to_le32(_v32) - -static int qusb_control[2]; - -static int noblock_full_read(int fd, void *pbuf, ssize_t size) { - ssize_t cur = 0; - - while (cur < size) { - ssize_t ret = read(fd, (char *)pbuf+cur, size-cur); - - if (ret > 0) - cur += ret; - else if (ret < 0 && errno == EAGAIN) { - struct pollfd pollfds[] = {{fd, POLLIN, 0}}; - poll(pollfds, 1, -1); - if (pollfds[0].revents & (POLLERR | POLLHUP | POLLNVAL)) - break; - } else { - dprintf("fd=%d read=%zd, errno: %d (%s)\n", fd, ret, errno, strerror(errno)); - break; - } - } - - if (cur != size) { - dprintf("%s fd=%d cur=%zd, size=%zd\n", __func__, fd, cur, size); - } - - return cur; -} - -static ssize_t noblock_full_write(int fd, const void *pbuf, ssize_t size) { - ssize_t cur = 0; - - while (cur < size) { - ssize_t ret = write(fd, (char *)pbuf+cur, size-cur); - if (ret > 0) - cur += ret; - else if (ret <= 0 && errno == EAGAIN) { - struct pollfd pollfds[] = {{fd, POLLOUT, 0}}; - poll(pollfds, 1, -1); - if (pollfds[0].revents & (POLLERR | POLLHUP | POLLNVAL)) - break; - } else { - dprintf("fd=%d write=%zd, errno: %d (%s)\n", fd, ret, errno, strerror(errno)); - break; - } - } - - if (cur != size) { - dprintf("%s fd=%d cur=%zd, size=%zd\n", __func__, fd, cur, size); - } - - return cur; -} - -static void* usb_bulk_read_thread(void* arg) { - const void *usb_handle = arg; - void *buf = malloc(MAX_USBFS_BULK_IN_SIZE); - int fd = qusb_control[1]; - - if (buf == NULL) - return NULL; - - while(usb_handle) { - int count = qusb_noblock_read(usb_handle, buf, MAX_USBFS_BULK_IN_SIZE, 1, 30000); - - if (count > 0) { - count = write(fd, buf, count); - count = read(fd, buf, 32); //wait usb2tcp_main read - if (count <= 0) { - dprintf("read=%d\n", count); - break; - } - } else if (count <= 0) { - break; - } - } - - close(fd); - free(buf); - return NULL; -} - -static int qusb_open(const void *usb_handle) { - int fd = -1; - pthread_t thread_id; - - pthread_attr_t usb_thread_attr; - pthread_attr_init(&usb_thread_attr); - pthread_attr_setdetachstate(&usb_thread_attr, PTHREAD_CREATE_DETACHED); - - socketpair(AF_LOCAL, SOCK_STREAM, 0, qusb_control); - pthread_create(&thread_id, &usb_thread_attr, usb_bulk_read_thread, (void*)usb_handle); - - fd = qusb_control[0]; - - return fd; -} - -static ssize_t qusb_read(int fd, void* pbuf, size_t size) { - return read(fd, pbuf, size); -} - -static int create_tcp_server(int socket_port) { - int sockfd = -1; - int reuse_addr = 1; - struct sockaddr_in sockaddr; - - dprintf("%s tcp_port=%d\n", __func__, socket_port); - /*Create server socket*/ - sockfd = socket(AF_INET, SOCK_STREAM, 0); - if (sockfd <= 0) - return sockfd; - - memset(&sockaddr, 0, sizeof(sockaddr)); - sockaddr.sin_family = AF_INET; - sockaddr.sin_addr.s_addr = htonl(INADDR_ANY); - sockaddr.sin_port = htons(socket_port); - - setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &reuse_addr,sizeof(reuse_addr)); - if (bind(sockfd, (struct sockaddr *)&sockaddr, sizeof(sockaddr)) < 0) { - close(sockfd); - dprintf("%s bind %d errno: %d (%s)\n", __func__, socket_port, errno, strerror(errno)); - return -1; - } - - return sockfd; -} - -static int wait_client_connect(int server_fd) { - int client_fd = -1; - unsigned char addr[128]; - socklen_t alen = sizeof(addr); - - dprintf("%s\n", __func__); - listen(server_fd, 1); - client_fd = accept(server_fd, (struct sockaddr *)addr, &alen); - if (client_fd <= 0) - return client_fd; - - if (client_fd > 0) { - struct sockaddr_in *addr_in = (struct sockaddr_in *)addr; - dprintf("clientfd = %d %s:%d connect\n", client_fd, inet_ntoa(addr_in->sin_addr), addr_in->sin_port); - } - - return client_fd; -} - -int usb2tcp_main(const void *usb_handle, int tcp_port, unsigned qusb_zlp_mode) { - void *pbuf = malloc(MAX_USBFS_BULK_OUT_SIZE); - int server_fd = -1, client_fd = -1, usb_fd = -1, size = -1; - TLV_USB tlv_usb; - - if (pbuf == NULL) - return -1; - - server_fd = create_tcp_server(tcp_port); - dprintf("server_fd=%d\n", server_fd); - if (server_fd <= 0) { - dprintf("Fail create_tcp_server\n"); - goto _out; - } - - if (client_fd <= 0) { - client_fd = wait_client_connect(server_fd); - if (client_fd < 0) { - dprintf("Fail wait_client_connect\n"); - goto _out; - } - } - - usb_fd = qusb_open(usb_handle); - dprintf("usb_fd = %d\n", usb_fd); - - tlv_usb.tag = cpu_to_le32(Q_USB2TCP_VERSION); - tlv_usb.length = cpu_to_le32(12); - tlv_usb.idVendor = cpu_to_le32(0x05c6); - tlv_usb.idProduct = cpu_to_le32(0x9008); - tlv_usb.interfaceNum = cpu_to_le32(1); - if (write(client_fd, &tlv_usb, sizeof(tlv_usb)) == -1) {}; - - fcntl(usb_fd, F_SETFL, fcntl(usb_fd,F_GETFL) | O_NONBLOCK); - fcntl(client_fd, F_SETFL, fcntl(client_fd,F_GETFL) | O_NONBLOCK); - - while (usb_fd > 0 && client_fd > 0) { - struct pollfd pollfds[] = {{usb_fd, POLLIN, 0}, {client_fd, POLLIN, 0}}; - int ne, ret, nevents = sizeof(pollfds)/sizeof(pollfds[0]); - - do { - ret = poll(pollfds, nevents, -1); - } while (ret < 0 && errno == EINTR); - - - if (ret <= 0) { - dprintf("%s poll=%d, errno: %d (%s)\n", __func__, ret, errno, strerror(errno)); - goto _hangup; - } - - - if (pollfds[0].revents & (POLLERR | POLLHUP | POLLNVAL)) { - dprintf("%s poll usb_fd = %d, revents = %04x\n", __func__, usb_fd, pollfds[0].revents); - goto _hangup; - } - - - if (pollfds[1].revents & (POLLERR | POLLHUP | POLLNVAL)) { - dprintf("%s poll client_fd = %d, revents = %04x\n", __func__, client_fd, pollfds[1].revents); - goto _hangup; - } - - for (ne = 0; ne < nevents; ne++) { - int fd = pollfds[ne].fd; - TLV tlv = {Q_USB2TCP_VERSION, 0}; - - if ((pollfds[ne].revents & POLLIN) == 0) - continue; - - if (fd == usb_fd) { - size = qusb_read(usb_fd, pbuf, MAX_USBFS_BULK_IN_SIZE); - if (size <= 0) { - dprintf("usb_fd=%d read=%d, errno: %d (%s)\n", fd, size, errno, strerror(errno)); - goto _hangup;; - } - if (write(usb_fd, pbuf, 1) == -1) {}; //wakeup usb_bulk_read_thread - - tlv.tag = cpu_to_le32(Q_USB2TCP_VERSION); - tlv.length = cpu_to_le32(size); - if (sizeof(tlv) != noblock_full_write(client_fd, &tlv, sizeof(tlv))) { - goto _hangup; - break; - } - - if (size != noblock_full_write(client_fd, pbuf, size)) { - goto _hangup; - break; - } - } - else if (fd == client_fd) { - size = noblock_full_read(client_fd, &tlv, sizeof(tlv)); - if (size != sizeof(tlv)) { - dprintf("client_fd=%d read=%d, errno: %d (%s)\n", fd, size, errno, strerror(errno)); - goto _hangup; - } - - if (le32_to_cpu(tlv.tag) != Q_USB2TCP_VERSION) { - break; - } - - size = le32_to_cpu(tlv.length); - if (size != noblock_full_read(client_fd, pbuf, size)) { - goto _hangup; - break; - } - qusb_noblock_write(usb_handle, pbuf, size, size, 3000, qusb_zlp_mode); - } - } - } - -_hangup: - if (usb_fd > 0) { - close(usb_fd); - usb_fd = -1; - } - if (client_fd > 0) { - close(client_fd); - client_fd = -1; - } - -_out: - free(pbuf); - return 0; -} diff --git a/rooter/0optionalapps/qfirehose/src/usb_linux.c b/rooter/0optionalapps/qfirehose/src/usb_linux.c deleted file mode 100644 index 89e7917..0000000 --- a/rooter/0optionalapps/qfirehose/src/usb_linux.c +++ /dev/null @@ -1,1197 +0,0 @@ -/****************************************************************************** - @file usb_linux.c - @brief read and write usb devices. - - DESCRIPTION - QFirehoe Tool for USB and PCIE of Quectel wireless cellular modules. - - INITIALIZATION AND SEQUENCING REQUIREMENTS - None. - - --------------------------------------------------------------------------- - Copyright (c) 2016 - 2020 Quectel Wireless Solution, Co., Ltd. All Rights Reserved. - Quectel Wireless Solution Proprietary and Confidential. - --------------------------------------------------------------------------- -******************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 20) -#include -#else -#include -#endif -#include -#include -#include -#include "usb_linux.h" - -int edl_pcie_mhifd = -1; -int switch_to_edl_mode(void *usb_handle); - -extern uint32_t inet_addr(const char *); - -#define MAX_USBFS_BULK_IN_SIZE (4 * 1024) -#define EC20_MAX_INF 4 -#define MKDEV(__ma, __mi) (((__ma & 0xfff) << 8) | (__mi & 0xff) | ((__mi & 0xfff00) << 12)) - -struct quectel_usb_device { - char devname[64]; - int desc; - int ttyfd; - int idVendor; - int idProduct; - uint8_t bNumInterfaces; - uint8_t intr_ep[EC20_MAX_INF]; - uint8_t bulk_ep_in[EC20_MAX_INF]; - uint8_t bulk_ep_out[EC20_MAX_INF]; - int wMaxPacketSize[EC20_MAX_INF]; - int control[EC20_MAX_INF][2]; -}; - -static struct quectel_usb_device quectel_9x07; -static int tcp_socket_fd = -1; -static int usb_dm_interface = 0; - -static int strStartsWith(const char *line, const char *prefix) -{ - if (!prefix || prefix[0] == '\0') - return 1; - - for ( ; *line != '\0' && *prefix != '\0' ; line++, prefix++) { - if (*line != *prefix) { - return 0; - } - } - - return *prefix == '\0'; -} - -static int strEndsWith(const char *line, const char *suffix) -{ - size_t a, b; - - if (!suffix || suffix[0] == '\0') - return 1; - - a = strlen(line); - b = strlen(suffix); - return (a >= b) && (strcmp(line + (a -b), suffix) == 0); -} - -static int quectel_get_sysinfo_by_uevent(const char *uevent, MODULE_SYS_INFO *pSysInfo) { - FILE *fp; - char line[MAX_PATH]; - - memset(pSysInfo, 0x00, sizeof(MODULE_SYS_INFO)); - - fp = fopen(uevent, "r"); - if (fp == NULL) { - dbg_time("fail to fopen %s, errno: %d (%s)\n", uevent, errno, strerror(errno)); - return 0; - } - - //dbg_time("%s\n", uevent); - while (fgets(line, sizeof(line), fp)) { - if (line[strlen(line) - 1] == '\n' || line[strlen(line) - 1] == '\r') { - line[strlen(line) - 1] = '\0'; - } - - //dbg_time("%s\n", line); - if (strStartsWith(line, "MAJOR=")) { - pSysInfo->MAJOR = atoi(&line[strlen("MAJOR=")]); - } - else if (strStartsWith(line, "MINOR=")) { - pSysInfo->MINOR = atoi(&line[strlen("MINOR=")]); - } - else if (strStartsWith(line, "DEVNAME=")) { - if(pSysInfo) - strncpy(pSysInfo->DEVNAME, &line[strlen("DEVNAME=")], sizeof(pSysInfo->DEVNAME)); - } - else if (strStartsWith(line, "DEVTYPE=")) { - strncpy(pSysInfo->DEVTYPE, &line[strlen("DEVTYPE=")], sizeof(pSysInfo->DEVTYPE)); - } - else if (strStartsWith(line, "PRODUCT=")) { - strncpy(pSysInfo->PRODUCT, &line[strlen("PRODUCT=")], sizeof(pSysInfo->PRODUCT)); - } - } - - fclose(fp); - - return 1; -} - -// the return value is the number of quectel modules -int auto_find_quectel_modules(char *module_sys_path, unsigned size) -{ - const char *base = "/sys/bus/usb/devices"; - DIR *busdir = NULL; - struct dirent *de = NULL; - int count = 0; - - busdir = opendir(base); - if (busdir == NULL) - return -1; - - while ((de = readdir(busdir))) { - static char uevent[MAX_PATH]; - static MODULE_SYS_INFO sysinfo; - - if (!isdigit(de->d_name[0])) continue; - - snprintf(uevent, sizeof(uevent), "%.24s/%.16s/uevent", base, de->d_name); - if (!quectel_get_sysinfo_by_uevent(uevent, &sysinfo)) - continue; - - if (sysinfo.MAJOR != 189) - continue; - - //dbg_time("MAJOR=%d, MINOR=%d, DEVNAME=%s, DEVTYPE=%s, PRODUCT=%s\n", - // sysinfo.MAJOR, sysinfo.MINOR, sysinfo.DEVNAME, sysinfo.DEVTYPE, sysinfo.PRODUCT); - - if (sysinfo.DEVTYPE[0] == '\0' || strStartsWith(sysinfo.DEVTYPE, "usb_device") == 0) - continue; - - if (sysinfo.PRODUCT[0] == '\0') { - continue; - } - - if (!(strStartsWith(sysinfo.PRODUCT, "2c7c/") - || strStartsWith(sysinfo.PRODUCT, "5c6/9008") - || strStartsWith(sysinfo.PRODUCT, "5c6/901f") - || strStartsWith(sysinfo.PRODUCT, "5c6/9091") - || strStartsWith(sysinfo.PRODUCT, "3763/3c93/318"))) { - continue; - } - - if ((strStartsWith(sysinfo.PRODUCT, "2c7c/6") || strStartsWith(sysinfo.PRODUCT, "2c7c/8")) - && (sysinfo.PRODUCT[strlen("2c7c/6000")] == '/')) //skip ASR&HISI modules - continue; - - snprintf(module_sys_path, size, "%.24s/%s", base, de->d_name); - count++; - dbg_time("[%d] %s %s\n", count, module_sys_path, sysinfo.PRODUCT); - } - - closedir(busdir); - - return count; -} - -void quectel_get_ttyport_by_syspath(const char *module_sys_path, char *module_port_name, unsigned size) { - char infname[256]; - DIR *infdir = NULL; - struct dirent *de = NULL; - - module_port_name[0] = '\0'; - - sprintf(infname, "%s:1.%d", module_sys_path, usb_dm_interface); - infdir = opendir(infname); - if (infdir == NULL) - return; - - while ((de = readdir(infdir))) { - if (strStartsWith(de->d_name, "ttyUSB")) { - snprintf(module_port_name, size, "/dev/%s", de->d_name); - break; - } - else if (!strncmp(de->d_name, "tty", strlen("tty"))) { - sprintf(infname, "%s:1.%d/tty", module_sys_path, usb_dm_interface); - closedir(infdir); - infdir = opendir(infname); - if (infdir == NULL) - break; - } - } - - if (infdir) closedir(infdir); -} - -static void quectel_fixup_sysport(const char *module_port_name, char *sysport, unsigned size) { - char syspath[MAX_PATH+16]; - const char *sys_base = "/sys/class/tty"; - DIR *sys_dir = NULL; - struct dirent *dev = NULL; - - sysport[0] = '\0'; - sys_dir = opendir(sys_base); - if (!sys_dir) { - dbg_time("fail to opendir('%s'), errno: %d (%s)\n", sys_base, errno, strerror(errno)); - return; - } - - while (NULL != (dev = readdir(sys_dir))) - { - if (!strncasecmp("ttyUSB", dev->d_name, strlen("ttyUSB"))) { - MODULE_SYS_INFO sysinfo; - - snprintf(syspath, sizeof(syspath), "%.24s/%.16s/uevent", sys_base, dev->d_name); - if (quectel_get_sysinfo_by_uevent(syspath, &sysinfo)) { - struct stat buf; - dev_t devt; - - devt = makedev(sysinfo.MAJOR, sysinfo.MINOR); - if(!stat(module_port_name, &buf) && buf.st_rdev == devt) { - snprintf(sysport, size, "/sys/class/tty/%.16s", dev->d_name); - break; - } - } - } - } - closedir(sys_dir); -} - - -void quectel_get_syspath_name_by_ttyport(const char *module_port_name, char *module_sys_path, unsigned size) { - char syspath[MAX_PATH]; - char sysport[64]; - int count; - char *pchar = NULL; - char dm_tty[24]; - - snprintf(dm_tty, sizeof(dm_tty), ":1.%d/tty", usb_dm_interface); - module_sys_path[0] = '\0'; - - snprintf(sysport, sizeof(sysport), "/sys/class/tty/%.48s", &module_port_name[strlen("/dev/")]); - if(access(sysport, F_OK) && errno == ENOENT) { - quectel_fixup_sysport(module_port_name, sysport, sizeof(sysport));//query real name - } - if(access(sysport, F_OK) && errno == ENOENT) - return; - count = readlink(sysport, syspath, sizeof(syspath) - 1); - if (count < (int)strlen(dm_tty)) - return; - -//ttyUSB0 -> ../../devices/soc0/soc/2100000.aips-bus/2184200.usb/ci_hdrc.1/usb1/1-1/1-1:1.0/ttyUSB0/tty/ttyUSB0 - pchar = strstr(syspath, dm_tty); - if (pchar == NULL) - return; - - *pchar = '\0'; - while (*pchar != '/') - pchar--; - - snprintf(module_sys_path, size, "/sys/bus/usb/devices/%.232s", pchar + 1); -} - -static void quectel_get_usb_device_info(const char *module_sys_path, struct quectel_usb_device *udev) { - static unsigned char devdesc[1024]; - size_t desclength, len; - char devname[MAX_PATH]; - int desc_fd; - __u8 bInterfaceNumber = 0; - int dev_mknod_and_delete_after_use = 0; - - MODULE_SYS_INFO sysinfo; - snprintf(devname, sizeof(devname), "%.248s/%s", module_sys_path, "uevent"); - if (!quectel_get_sysinfo_by_uevent(devname, &sysinfo)) - return; - - snprintf(devname, sizeof(devname), "/dev/%s", sysinfo.DEVNAME); - if (access(devname, R_OK) && errno_nodev()) { - //maybe Linux have create /sys/ device, but not ready to create /dev/ device. - usleep(100*1000); - } - - if (access(devname, R_OK) && errno_nodev()) - { - char *p = strstr(devname+strlen("/dev/"), "/"); - - while (p) { - p[0] = '_'; - p = strstr(p, "/"); - } - - if (mknod(devname, S_IFCHR|0666, MKDEV(sysinfo.MAJOR, sysinfo.MINOR))) { - devname[1] = 't'; - devname[2] = 'm'; - devname[3] = 'p'; - - if (mknod(devname, S_IFCHR|0666, MKDEV(sysinfo.MAJOR, sysinfo.MINOR))) { - dbg_time("Fail to mknod %s, errno : %d (%s)\n", devname, errno, strerror(errno)); - return; - } - } - - dev_mknod_and_delete_after_use = 1; - } - - desc_fd = open(devname, O_RDWR | O_NOCTTY); - - if (dev_mknod_and_delete_after_use) { - remove(devname); - } - - if (desc_fd <= 0) { - dbg_time("fail to open %s, errno: %d (%s)\n", devname, errno, strerror(errno)); - return; - } - - desclength = read(desc_fd, devdesc, sizeof(devdesc)); - len = 0; - while (len < desclength) { - struct usb_descriptor_header *h = (struct usb_descriptor_header *)(&devdesc[len]); - - if (h->bLength == sizeof(struct usb_device_descriptor) && h->bDescriptorType == USB_DT_DEVICE) { - struct usb_device_descriptor *device = (struct usb_device_descriptor *)h; - - udev->idVendor = device->idVendor; - udev->idProduct = device->idProduct; - dbg_time("P: %s idVendor=%04x idProduct=%04x\n", devname, device->idVendor, device->idProduct); - } - else if (h->bLength == sizeof(struct usb_config_descriptor) && h->bDescriptorType == USB_DT_CONFIG) { - struct usb_config_descriptor *config = (struct usb_config_descriptor *)h; - - dbg_time("C: %s bNumInterfaces: %d\n", devname, config->bNumInterfaces); - udev->bNumInterfaces = config->bNumInterfaces; - } - else if (h->bLength == sizeof(struct usb_interface_descriptor) && h->bDescriptorType == USB_DT_INTERFACE) { - struct usb_interface_descriptor *interface = (struct usb_interface_descriptor *)h; - - dbg_time("I: If#= %d Alt= %d #EPs= %d Cls=%02x Sub=%02x Prot=%02x\n", - interface->bInterfaceNumber, interface->bAlternateSetting, interface->bNumEndpoints, - interface->bInterfaceClass, interface->bInterfaceSubClass, interface->bInterfaceProtocol); - bInterfaceNumber = interface->bInterfaceNumber; - } - else if (h->bLength == USB_DT_ENDPOINT_SIZE && h->bDescriptorType == USB_DT_ENDPOINT) { - if (bInterfaceNumber < EC20_MAX_INF) { - struct usb_endpoint_descriptor *endpoint = (struct usb_endpoint_descriptor *)h; - - dbg_time("E: Ad=%02x Atr=%02x MxPS= %d Ivl=%dms\n", - endpoint->bEndpointAddress, endpoint->bmAttributes, endpoint->wMaxPacketSize, endpoint->bInterval); - - if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_BULK) { - if (endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) - udev->bulk_ep_in[bInterfaceNumber] = endpoint->bEndpointAddress; - else - udev->bulk_ep_out[bInterfaceNumber] = endpoint->bEndpointAddress; - udev->wMaxPacketSize[bInterfaceNumber] = endpoint->wMaxPacketSize; - } else if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT){ - udev->intr_ep[bInterfaceNumber] = endpoint->bEndpointAddress; - } - } - } else { - } - - len += h->bLength; - } - - if (len == desclength) { - strcpy(udev->devname, devname); - udev->desc = desc_fd; - } - - usb_dm_interface = 0; - if ((udev->bulk_ep_in[usb_dm_interface] == 0 && udev->bulk_ep_in[usb_dm_interface] == 0) - || (udev->idVendor == 0x2c7c && udev->idProduct == 0x0127) //EM05CEFC-LNV Laptop - || (udev->idVendor == 0x2c7c && udev->idProduct == 0x0514) //EG060K-EA - || (udev->idVendor == 0x2c7c && udev->idProduct == 0x0310) //EM05-CN Laptop - || (udev->idVendor == 0x2c7c && udev->idProduct == 0x030a) //EM05-G Laptop - || (udev->idVendor == 0x2c7c && udev->idProduct == 0x0309) //EM05E-EDU Laptop - || (udev->idVendor == 0x2c7c && udev->idProduct == 0x030d)) //EM05G-FCCL Laptop - { - - if ((udev->idVendor == 0x2c7c && udev->idProduct == 0x0127) //EM05CEFC-LNV Laptop - || (udev->idVendor == 0x2c7c && udev->idProduct == 0x0310) //EM05-CN Laptop - || (udev->idVendor == 0x2c7c && udev->idProduct == 0x030a) //EM05-G Laptop - || (udev->idVendor == 0x2c7c && udev->idProduct == 0x0309) //EM05E-EDU Laptop - || (udev->idVendor == 0x2c7c && udev->idProduct == 0x030d)) //EM05G-FCCL Laptop - usb_dm_interface = 3; - - if (udev->idVendor == 0x2c7c && udev->idProduct == 0x0514) //EG060K-EA - usb_dm_interface = 2; - } -} - -static int usbfs_bulk_write(struct quectel_usb_device *udev, const void *data, int len, int timeout_msec, int need_zlp) { - struct usbdevfs_urb bulk; - struct usbdevfs_urb *urb = &bulk; - int n = -1; - int bInterfaceNumber = usb_dm_interface; - - (void)timeout_msec; - //if (urb->type == 0) - { - memset(urb, 0, sizeof(struct usbdevfs_urb)); - urb->type = USBDEVFS_URB_TYPE_BULK; - urb->endpoint = udev->bulk_ep_out[bInterfaceNumber]; - } - - urb->status = -1; - urb->buffer = (void *)data; - urb->buffer_length = len; - urb->usercontext = urb; - - if (need_zlp && (len%udev->wMaxPacketSize[bInterfaceNumber]) == 0) { - //dbg_time("USBDEVFS_URB_ZERO_PACKET\n"); -#ifndef USBDEVFS_URB_ZERO_PACKET -#define USBDEVFS_URB_ZERO_PACKET 0x40 -#endif - urb->flags = USBDEVFS_URB_ZERO_PACKET; - } else { - urb->flags = 0; - } - - do { - n = ioctl(udev->desc, USBDEVFS_SUBMITURB, urb); - } while((n < 0) && (errno == EINTR)); - - if (n != 0) { - dbg_time("inf[%d] USBDEVFS_SUBMITURB %d/%d, errno = %d (%s)\n", bInterfaceNumber, n, urb->buffer_length, errno, strerror(errno)); - return -1; - } - - do { - urb = NULL; - n = ioctl(udev->desc, USBDEVFS_REAPURB, &urb); - } while((n < 0) && (errno == EINTR)); - - if (n != 0) { - dbg_time("inf[%d] ep_out %d/%d, errno = %d (%s)\n", bInterfaceNumber, n, urb->buffer_length, errno, strerror(errno)); - } - - //dbg_time("[ urb @%p status = %d, actual = %d ]\n", urb, urb->status, urb->actual_length); - - if (urb && urb->status == 0 && urb->actual_length) - return urb->actual_length; - - return -1; -} - -static int poll_wait(int poll_fd, short events, int timeout_msec) { - struct pollfd pollfds[] = {{poll_fd, events, 0}}; - int ret; - - do { - ret = poll(pollfds, 1, timeout_msec); - } while(ret == -1 && errno == EINTR); - - if (ret == 1 && (pollfds[0].revents & (events))) - return 0; - else if (ret == 0) {//timeout - dbg_time("poll_wait events=%s msec=%d timeout\n", - (events & POLLIN) ? "POLLIN" : "POLLOUT", timeout_msec); - return ETIMEDOUT; - } - - return EIO; -} - -static int usbfs_bulk_read(struct quectel_usb_device *udev, void *pbuf, int len, int timeout) { - struct usbdevfs_bulktransfer bulk; - int n = -1; - int bInterfaceNumber = usb_dm_interface; - - if (len < 512) { - dbg_time("%s len=%d is too short\n", __func__, len); - return 0; - } - - bulk.ep = udev->bulk_ep_in[bInterfaceNumber]; - bulk.len = (len > MAX_USBFS_BULK_IN_SIZE) ? MAX_USBFS_BULK_IN_SIZE : len; - bulk.data = (void *)pbuf; - bulk.timeout = timeout; - - n = ioctl(udev->desc, USBDEVFS_BULK, &bulk); - if( n <= 0 ) { - if (errno == ETIMEDOUT) { - dbg_time("inf[%d] ep_in %d/%d, errno = %d (%s), timeout=%d\n", bInterfaceNumber, n, bulk.len, errno, strerror(errno), timeout); - n = 0; - } - else - dbg_time("inf[%d] ep_in %d/%d, errno = %d (%s)\n", bInterfaceNumber, n, bulk.len, errno, strerror(errno)); - } - - return n ; -} - -static int qtcp_connect(const char *port_name, int *idVendor, int *idProduct, int *interfaceNum) { - int fd = -1; - char *tcp_host = strdup(port_name); - char *tcp_port = strchr(tcp_host, ':'); - struct sockaddr_in sockaddr; - TLV_USB tlv_usb; - - dbg_time("%s port_name = %s\n", __func__, port_name); - - if (tcp_port == NULL) - return -1; - - *tcp_port++ = '\0'; - if (atoi(tcp_port) < 1 || atoi(tcp_port) > 0xFFFF) - return -1; - - fd = socket(AF_INET, SOCK_STREAM, 0); - - if (fd <= 0) { - dbg_time("Device could not be socket: Linux System Errno: %s\n", strerror (errno)); - return -1; - } - - memset(&sockaddr, 0, sizeof(sockaddr)); - sockaddr.sin_family = AF_INET; - sockaddr.sin_addr.s_addr = inet_addr(tcp_host); - sockaddr.sin_port = htons(atoi(tcp_port)); - - free(tcp_host); - if (connect(fd, (struct sockaddr *) &sockaddr, sizeof(sockaddr)) < 0) { - close(fd); - dbg_time("Device could not be connect: Linux System Errno: %s\n", strerror (errno)); - return -1; - } - - //block read, untill usb2tcp tell me the usb device information - memset(&tlv_usb, 0x00, sizeof(tlv_usb)); - if (read(fd, &tlv_usb, sizeof(tlv_usb)) == -1) { }; - *idVendor = tlv_usb.idVendor; - *idProduct = tlv_usb.idProduct; - *interfaceNum = tlv_usb.interfaceNum; - - dbg_time("idVendor=%04x, idProduct=%04x, interfaceNum=%d\n", *idVendor, *idProduct, *interfaceNum); - - return fd; -} - -static int qtcp_read(int fd, void *pbuf, int size, int timeout_msec) { - static TLV tlv = {Q_USB2TCP_VERSION, 0}; - int cur = 0; - int len; - - if (tlv.length == 0) { - len = read(fd, &tlv, sizeof(tlv)); - if (len != sizeof(tlv)) { - dbg_time("%s read=%d, errno: %d (%s)\n", __func__, len, errno, strerror(errno)); - return 0; - } - - if (tlv.tag != Q_USB2TCP_VERSION) { - dbg_time("%s tlv->tag=0x%x\n", __func__, tlv.tag); - return 0; - } - } - - if (size > tlv.length) - size = tlv.length; - tlv.length -= size; - - while (cur < size) { - if (poll_wait(fd, POLLIN, timeout_msec)) - break; - - len = read(fd, (uint8_t *)pbuf+cur, size-cur); - if (len > 0) { - cur += len; - } - else { - dbg_time("%s read=%d, errno: %d (%s)\n", __func__, len, errno, strerror(errno)); - break; - } - } - - if (cur != size) { - dbg_time("%s cur=%d, size=%d\n", __func__, cur, size); - } - - return cur; -} - -static int qtcp_write(int fd, void*pbuf, int size, int timeout_msec) { - TLV tlv = {Q_USB2TCP_VERSION, size}; - int cur = 0; - int len; - - len = write(fd, &tlv, sizeof(tlv)); - if (len != sizeof(tlv)) { - dbg_time("%s write=%d, errno: %d (%s)\n", __func__, len, errno, strerror(errno)); - return 0; - } - - while (cur < size) { - if (poll_wait(fd, POLLOUT, timeout_msec)) - break; - - len = write(fd, (uint8_t *)pbuf+cur, size-cur); - if (len > 0) { - cur += len; - } - else { - dbg_time("%s write=%d, errno: %d (%s)\n", __func__, len, errno, strerror(errno)); - break; - } - } - - if (cur != size) { - dbg_time("%s cur=%d, size=%d\n", __func__, cur, size); - } - - return cur; -} - -struct usbfs_getdriver -{ - unsigned int interface; - char driver[255 + 1]; -}; - -struct usbfs_ioctl -{ - int ifno; /* interface 0..N ; negative numbers reserved */ - int ioctl_code; /* MUST encode size + direction of data so the - * macros in give correct values */ - void *data; /* param buffer (in, or out) */ -}; - -#define IOCTL_USBFS_DISCONNECT _IO('U', 22) -#define IOCTL_USBFS_CONNECT _IO('U', 23) - -int usbfs_is_kernel_driver_alive(int fd, int ifnum) -{ - struct usbfs_getdriver getdrv; - getdrv.interface = ifnum; - if (ioctl(fd, USBDEVFS_GETDRIVER, &getdrv) < 0) { - if (errno != ENODATA) - dbg_time("%s ioctl USBDEVFS_GETDRIVER failed, errno: %d (%s)\n", __func__, errno, strerror(errno)); - return 0; - } - dbg_time("%s find interface %d has match the driver %s\n", __func__, ifnum, getdrv.driver); - return 1; -} - -void usbfs_detach_kernel_driver(int fd, int ifnum) -{ - struct usbfs_ioctl operate; - operate.data = NULL; - operate.ifno = ifnum; - operate.ioctl_code = IOCTL_USBFS_DISCONNECT; - if (ioctl(fd, USBDEVFS_IOCTL, &operate) < 0) { - dbg_time("%s detach kernel driver failed\n", __func__); - } else { - dbg_time("%s detach kernel driver success\n", __func__); - } -} - -#define KVERSION(j,n,p) ((j)*1000000 + (n)*1000 + (p)) -static struct utsname utsname; /* for the kernel version */ -static int ql_get_kernel_version(void) -{ - int osmaj, osmin, ospatch; - int kernel_version; - - uname(&utsname); - osmaj = osmin = ospatch = 0; - sscanf(utsname.release, "%d.%d.%d", &osmaj, &osmin, &ospatch); - kernel_version = KVERSION(osmaj, osmin, ospatch); - - return kernel_version; -} - -static int detect_xhci_usb_zero_packet_bug_not_fix(const char *module_sys_path) { - char buf[256]; - int tmp; - char *driver; - - tmp = snprintf(buf, sizeof(buf), "/sys/bus/usb/devices/usb%c/../driver", module_sys_path[strlen("/sys/bus/usb/devices/")]); - driver = buf + (++tmp); - *driver = '\0'; - - tmp = readlink(buf, driver, sizeof(buf) - tmp); - dbg_time("tmp=%s, driver=%s\n", buf, driver); - if (tmp <= 0) - return 0; - - if (!strstr(driver, "xhci")) - return 0; - - tmp = ql_get_kernel_version(); - if (tmp >= KVERSION(4,3,0)) - return 0; - - dbg_time("WARNNING ON File:%s Function:%s Line:%d\n", __FILE__, __func__, __LINE__); - dbg_time("The module attach to XHCI controller, but your kernel verison less than V4.3.0\n"); - dbg_time("Please make sure your kernel had apply patch 'usb: xhci: Add support for URB_ZERO_PACKET to bulk/sg transfers'\n"); - dbg_time("https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/drivers/usb/host/xhci-ring.c?id=4758dcd19a7d9ba9610b38fecb93f65f56f86346\n"); - sleep(2); //sleep 2 seconds, make sure FAE/customers can notice this warnning. - - return 1; -} - -void *qusb_noblock_open(const char *module_sys_path, int *idVendor, int *idProduct, int *interfaceNum) { - struct termios ios; - int retval; - int fd = -1; - struct quectel_usb_device *udev = &quectel_9x07; - - *idVendor = *idProduct = *interfaceNum = 0; - tcp_socket_fd = -1; - - if (module_sys_path && module_sys_path[0] == '/') { - char port_name[64]; - - memset(udev, 0, sizeof(struct quectel_usb_device)); - quectel_get_usb_device_info(module_sys_path, udev); - if (udev->desc <= 0) - return NULL; - quectel_get_ttyport_by_syspath(module_sys_path, port_name, sizeof(port_name)); - detect_xhci_usb_zero_packet_bug_not_fix(module_sys_path); - - *idVendor = udev->idVendor; - *idProduct = udev->idProduct; - *interfaceNum = udev->bNumInterfaces; - - if (port_name[0] == '\0' || (port_name[0] != '\0' && access(port_name, R_OK)) || (udev->idVendor == 0x05c6 && udev->idProduct == 0x9008)) { - int bInterfaceNumber = usb_dm_interface; - - if (usbfs_is_kernel_driver_alive(udev->desc, bInterfaceNumber)) { - usbfs_detach_kernel_driver(udev->desc, bInterfaceNumber); - } - retval = ioctl(udev->desc, USBDEVFS_CLAIMINTERFACE, &bInterfaceNumber); - if(retval != 0) { - dbg_time("Fail to claim interface %d, errno: %d (%s)\n", bInterfaceNumber, errno, strerror(errno)); - if (udev->idVendor == 0x05c6) { - int n; - struct { - char infname[255 * 2]; - char driver[255 * 2]; - } *pl; - const char *driver = NULL; - - pl = (typeof(pl)) malloc(sizeof(*pl)); - - snprintf(pl->infname, sizeof(pl->infname), "%.255s:1.%d/driver", module_sys_path, usb_dm_interface); - n = readlink(pl->infname, pl->driver, sizeof(pl->driver)); - if (n > 0) { - pl->driver[n] = '\0'; - while (pl->driver[n] != '/') - n--; - driver = (&pl->driver[n+1]); - } - - dbg_time("Error: when module in 'Emergency download mode', should not register any usb driver\n"); - if (driver) - dbg_time("Error: it register to usb driver ' %s ' now, should delete 05c6&9008 from the source file of this driver\n", driver); - if (driver && !strcmp(driver, "qcserial")) - dbg_time("Delete 05c6&9008 from 'drivers/usb/serial/qcserial.c' or disable qcserial from kernel config\n"); - qusb_noblock_close(udev); - free(pl); - } - return NULL; - } - - udev->ttyfd = -1; - return udev; - } - else if (!access(port_name, R_OK)) { - dbg_time("%s port_name = %s\n", __func__, port_name); - - fd = open (port_name, O_RDWR | O_SYNC); - - if (fd <= 0) { - dbg_time("Device %s could not be open: Linux System Errno: %s", port_name, strerror (errno)); - return NULL; - } - - retval = tcgetattr (fd, &ios); - if (-1 == retval) { - dbg_time("ermio settings could not be fetched Linux System Error:%s", strerror (errno)); - return NULL; - } - - cfmakeraw (&ios); - cfsetispeed(&ios, B115200); - cfsetospeed(&ios, B115200); - - retval = tcsetattr (fd, TCSANOW, &ios); - if (-1 == retval) { - dbg_time("Device could not be configured: Linux System Errno: %s", strerror (errno)); - } - udev->ttyfd = fd; - fcntl(fd, F_SETFL, fcntl(fd,F_GETFL) | O_NONBLOCK); - - return udev; - } - else { - dbg_time("fail to access %s errno: %d (%s)\n", port_name, errno, strerror(errno)); - } - } - else { - fd = qtcp_connect(module_sys_path, idVendor, idProduct, interfaceNum); - if (fd > 0) { - tcp_socket_fd = fd; - fcntl(fd, F_SETFL, fcntl(fd,F_GETFL) | O_NONBLOCK); - return &tcp_socket_fd; - } - } - - return NULL; -} - -int qusb_noblock_close(void *handle) { - struct quectel_usb_device *udev = &quectel_9x07; - - if (handle == &tcp_socket_fd) { - close(tcp_socket_fd); - tcp_socket_fd = -1; - } if (handle == udev && udev->ttyfd > 0) { - close(udev->ttyfd); - close(udev->desc); - } - else if (handle == udev && udev->desc > 0) { - int bInterfaceNumber = usb_dm_interface; - ioctl(udev->desc, USBDEVFS_RELEASEINTERFACE, &bInterfaceNumber); - close(udev->desc); - } - else if (handle == &edl_pcie_mhifd && edl_pcie_mhifd > 0) { - close(edl_pcie_mhifd); edl_pcie_mhifd = -1; - } - memset(udev, 0, sizeof(*udev)); - - return 0; -} - -int qusb_use_usbfs_interface(const void *handle) { - struct quectel_usb_device *udev = &quectel_9x07; - - return (handle == udev && udev->ttyfd <= 0 && udev->desc > 0); -} - -int qusb_noblock_read(const void *handle, void *pbuf, int max_size, int min_size, int timeout_msec) { - struct quectel_usb_device *udev = &quectel_9x07; - int cur = 0; - int poll_ret = 0; - - if (min_size == 0) - min_size = 1; - if (timeout_msec == 0) - timeout_msec = 3000; - -#if 0 //depend on your worst net speed - if (handle == &tcp_socket_fd) { - if (timeout_msec > 1000) //before sahala&firebose, we allow read timeout occurs - timeout_msec = 120*1000; - } -#endif - - while (cur < min_size) { - int len = 0; - - if (handle == &tcp_socket_fd) { - if ((poll_ret = poll_wait(tcp_socket_fd, POLLIN, timeout_msec))) - break; - len = qtcp_read(tcp_socket_fd, (uint8_t *)pbuf+cur, max_size-cur, timeout_msec); - } - else if (handle == udev && udev->ttyfd > 0) { - if ((poll_ret = poll_wait(udev->ttyfd, POLLIN, timeout_msec))) - break; - len = read(udev->ttyfd, (uint8_t *)pbuf+cur, max_size-cur); - } - else if (handle == udev && udev->desc > 0) { - len = usbfs_bulk_read(udev, (uint8_t *)pbuf+cur, max_size-cur, timeout_msec); - } - else if (handle == &edl_pcie_mhifd && edl_pcie_mhifd > 0) { - if ((poll_ret = poll_wait(edl_pcie_mhifd, POLLIN, timeout_msec))) - break; - len = read(edl_pcie_mhifd, (uint8_t *)pbuf+cur, max_size-cur); - } - else { - break; - } - - if (len > 0) { - cur += len; - } else { - dbg_time("%s read=%d, errno: %d (%s)\n", __func__, len, errno, strerror(errno)); - break; - } - } - - if (poll_ret == EIO) - return -1; - else if (poll_ret == ETIMEDOUT) - return cur; - - if (cur < min_size) { - dbg_time("%s cur=%d, min_size=%d\n", __func__, cur, min_size); - } - - return cur; -} - -int qusb_noblock_write(const void *handle, void *pbuf, int max_size, int min_size, int timeout_msec, int need_zlp) { - struct quectel_usb_device *udev = &quectel_9x07; - int cur = 0; - - if (min_size == 0) - min_size = 1; - if (timeout_msec == 0) - timeout_msec = 3000; - -#if 0 //depend on your worst net speed - if (handle == &tcp_socket_fd) { - timeout_msec = 120*1000; - } -#endif - - while (cur < min_size) { - int len = 0; - - if (handle == &tcp_socket_fd) { - if (poll_wait(tcp_socket_fd, POLLOUT, timeout_msec)) - break; - len = qtcp_write(tcp_socket_fd, (uint8_t *)pbuf+cur, max_size-cur, timeout_msec); - } - else if (handle == udev && udev->ttyfd > 0) { - if (poll_wait(udev->ttyfd, POLLOUT, timeout_msec)) - break; - len = write(udev->ttyfd, (uint8_t *)pbuf+cur, max_size-cur); - } else if (handle == udev && udev->desc > 0) { - len = usbfs_bulk_write(udev, (uint8_t *)pbuf+cur, max_size-cur, timeout_msec, need_zlp); - } - else if (handle == &edl_pcie_mhifd && edl_pcie_mhifd > 0) { - if (poll_wait(edl_pcie_mhifd, POLLOUT, timeout_msec)) - break; - len = write(edl_pcie_mhifd, (uint8_t *)pbuf+cur, max_size-cur); - } - else { - break; - } - - if (len > 0) { - cur += len; - } else { - dbg_time("%s write=%d, errno: %d (%s)\n", __func__, len, errno, strerror(errno)); - break; - } - } - - if (cur < min_size) { - dbg_time("%s cur=%d, min_size=%d\n", __func__, cur, min_size); - } - - return cur; -} - -int qfile_find_file(const char *dir, const char *prefix, const char *suffix, char** filename) { - DIR *pdir; - struct dirent* ent = NULL; - pdir = opendir(dir); - - *filename = NULL; - if(pdir) - { - while((ent = readdir(pdir)) != NULL) - { - if (strStartsWith(ent->d_name, prefix) && strEndsWith(ent->d_name, suffix)) - { - dbg_time("find '%s'\n", ent->d_name); - *filename = strdup(ent->d_name); - break; - } - } - } - - closedir(pdir); - return *filename != NULL; -} - -const char * firehose_get_time(void) { - static char time_buf[50]; - struct timeval tv; - static int s_start_msec = -1; - int now_msec, cost_msec; - - gettimeofday (&tv, NULL); - now_msec = tv.tv_sec * 1000; - now_msec += (tv.tv_usec + 500) / 1000; - - if (s_start_msec == -1) { - s_start_msec = now_msec; - } - - cost_msec = now_msec - s_start_msec; - - sprintf(time_buf, "[%03d.%03d]", cost_msec/1000, cost_msec%1000); - return time_buf; -} - -// void dbg_time (const char *fmt, ...) { -// va_list args; -// va_start(args, fmt); -// static char line[2048]; -// snprintf(line, sizeof(line), "%s ", firehose_get_time()); -// vsnprintf(line + strlen(line), sizeof(line) - strlen(line), fmt, args); -// fprintf(stdout, "%s", line); -// fflush(stdout); -// } - -int qpcie_open(const char *firehose_dir, const char *firehose_mbn) { - int bhifd, edlfd, diagfd; - long ret; - FILE *fp; - BHI_INFO_TYPE *bhi_info = malloc(sizeof(BHI_INFO_TYPE)); - char prog_firehose_sdx24[256+32]; - size_t filesize; - void *filebuf; - - snprintf(prog_firehose_sdx24, sizeof(prog_firehose_sdx24), "%.255s/%s", firehose_dir, firehose_mbn); - fp = fopen(prog_firehose_sdx24, "rb"); - if (fp ==NULL) { - dbg_time("fail to fopen %s, errno: %d (%s)\n", prog_firehose_sdx24, errno, strerror(errno)); - error_return(); - } - - fseek(fp, 0, SEEK_END); - filesize = ftell(fp); - fseek(fp, 0, SEEK_SET); - - filebuf = malloc(sizeof(filesize)+filesize); - memcpy(filebuf, &filesize, sizeof(filesize)); - if (fread((uint8_t *)filebuf+sizeof(filesize), 1, filesize, fp) == (size_t)0) { }; - fclose(fp); - - diagfd = open("/dev/mhi_DIAG", O_RDWR | O_NOCTTY); - if (diagfd > 0) - { - int edl_retry = 30; //SDX55 require long time by now 20190412 - void *usb_handle = &edl_pcie_mhifd; - edl_pcie_mhifd = diagfd; - - while (access("/dev/mhi_DIAG", R_OK) == 0 && edl_retry-- > 0) { - dbg_time("switch_to_edl_mode\n"); - switch_to_edl_mode(usb_handle); - sleep(1); - } - - close(diagfd); - edl_pcie_mhifd = -1; - } - - sleep(1); //see https://ticket.quectel.com/browse/FAE-39737 - bhifd = open("/dev/mhi_BHI", O_RDWR | O_NOCTTY); - if (bhifd <= 0) { - dbg_time("fail to open %s, errno: %d (%s)\n", "/dev/mhi_BHI", errno, strerror(errno)); - error_return(); - } - - ret = ioctl(bhifd, IOCTL_BHI_GETDEVINFO, bhi_info); - if (ret) { - dbg_time("fail to ioctl IOCTL_BHI_GETDEVINFO, errno: %d (%s)\n", errno, strerror(errno)); - error_return(); - } - - dbg_time("bhi_ee = %d\n", bhi_info->bhi_ee); - if (bhi_info->bhi_ee != MHI_EE_EDL) { - dbg_time("bhi_ee is not MHI_EE_EDL\n"); - close(bhifd); - free(filebuf); - error_return(); - } - free(bhi_info); - - ret = ioctl(bhifd, IOCTL_BHI_WRITEIMAGE, filebuf); - if (ret) { - dbg_time("fail to ioctl IOCTL_BHI_GETDEVINFO, errno: %d (%s)\n", errno, strerror(errno)); - error_return(); - } - - close(bhifd); - free(filebuf); - - sleep(1); - edlfd = open("/dev/mhi_EDL", O_RDWR | O_NOCTTY); - if (edlfd <= 0) { - dbg_time("fail to access %s, errno: %d (%s)\n", "/dev/mhi_EDL", errno, strerror(errno)); - error_return(); - } - - edl_pcie_mhifd = edlfd; - - return 0; -} - -int usbmon_fd = -1; -int usbmon_logfile_fd = -1; - -void *catch_log(void *arg) -{ - int nreads = 0; - char tbuff[256]; - size_t off = strlen("[999.999] "); - - (void)arg; - tbuff[off - 1] = ' '; - while(1) { - nreads = read(usbmon_fd, tbuff + off, sizeof(tbuff) - off); - if (nreads == -1 && errno == EINTR) - continue; - if (nreads <= 0) - break; - - tbuff[off + nreads] = '\0'; - memcpy(tbuff, firehose_get_time(), off - 1); - - if (write(usbmon_logfile_fd, tbuff, strlen(tbuff)) == -1) { }; - } - - return NULL; -} - -int ql_capture_usbmon_log(const char* usbmon_logfile) -{ - const char *usbmon_path = "/sys/kernel/debug/usb/usbmon/0u"; - pthread_t pt; - pthread_attr_t attr; - - if (access("/sys/kernel/debug/usb", F_OK)) { - dbg_time("debugfs is not mount, please execute \"mount -t debugfs none_debugs /sys/kernel/debug\"\n"); - return -1; - } - if (access("/sys/kernel/debug/usb/usbmon", F_OK)) { - dbg_time("usbmon is not load, please execute \"modprobe usbmon\" or \"insmod usbmon.ko\"\n"); - return -1; - } - - usbmon_fd = open(usbmon_path, O_RDONLY); - if (usbmon_fd < 0) { - dbg_time("open %s error(%d) (%s)\n", usbmon_path, errno, strerror(errno)); - return -1; - } - - usbmon_logfile_fd = open(usbmon_logfile, O_WRONLY | O_CREAT | O_TRUNC, 0666); - if (usbmon_logfile_fd < 0) { - dbg_time("open %s error(%d) (%s)\n", usbmon_logfile, errno, strerror(errno)); - close(usbmon_fd); - return -1; - } - - pthread_attr_init(&attr); - pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); - pthread_create(&pt, &attr, catch_log, NULL); - - return 0; -} - -void ql_stop_usbmon_log() -{ - if (usbmon_logfile_fd > 0) - close(usbmon_logfile_fd); - if (usbmon_fd > 0) - close(usbmon_fd); -} diff --git a/rooter/0optionalapps/qfirehose/src/usb_linux.h b/rooter/0optionalapps/qfirehose/src/usb_linux.h deleted file mode 100644 index 881e49c..0000000 --- a/rooter/0optionalapps/qfirehose/src/usb_linux.h +++ /dev/null @@ -1,140 +0,0 @@ -#ifndef __QFIREHOSE_USB_LINUX_H__ -#define __QFIREHOSE_USB_LINUX_H__ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define MAX_PATH 256 -#define MIN(a,b) ((a) < (b)? (a) : (b)) - -typedef struct module_sys_info { -/* -MAJOR=189 -MINOR=1 -DEVNAME=bus/usb/001/002 -DEVTYPE=usb_device -DRIVER=usb -PRODUCT=2c7c/415/318 -TYPE=239/2/1 -BUSNUM=001 -*/ - //char sys_path[MAX_PATH]; - int MAJOR; - int MINOR; - char DEVNAME[64]; - char DEVTYPE[64]; - char PRODUCT[64]; -}MODULE_SYS_INFO; - -void * qusb_noblock_open(const char *module_sys_path, int *idVendor, int *idProduct, int *interfaceNum); -int qusb_noblock_close(void *handle); -int qusb_noblock_write(const void *handle, void *pbuf, int max_size, int min_size, int timeout_msec, int need_zlp); -int qusb_noblock_read(const void *handle, void *pbuf, int max_size, int min_size, int timeout_msec); -int qfile_find_file(const char *dir, const char *prefix, const char *suffix, char** filename); -#define errno_nodev() (errno == ENOENT || errno == ENODEV) -// void dbg_time (const char *fmt, ...); -const char * firehose_get_time(void); -extern FILE *loghandler; -#ifdef FH_DEBUG -#define dbg_time(fmt, args...) \ - do \ - { \ - fprintf(stdout, "[%15s-%04d]%s: " fmt, __FILE__, __LINE__, firehose_get_time(), ##args); \ - fflush(stdout); \ - if (loghandler) \ - fprintf(loghandler, "[%15s-%04d]%s: " fmt, __FILE__, __LINE__, firehose_get_time(), ##args); \ - } while (0); -#else -#define dbg_time(fmt, args...) \ - do \ - { \ - fprintf(stdout, "%s: " fmt, firehose_get_time(), ##args); \ - fflush(stdout); \ - if (loghandler) \ - fprintf(loghandler, "%s: " fmt, firehose_get_time(), ##args); \ - } while (0); -#endif -double get_now(); -void get_duration(double start); -int update_transfer_bytes(long long bytes_cur); -void set_transfer_allbytes(long long bytes); -int auto_find_quectel_modules(char *module_sys_path, unsigned size); -void quectel_get_syspath_name_by_ttyport(const char *module_port_name, char *module_sys_path, unsigned size); -void quectel_get_ttyport_by_syspath(const char *module_sys_path, char *module_port_name, unsigned size); -#define error_return() do {dbg_time("%s %s %d fail\n", __FILE__, __func__, __LINE__); return __LINE__; } while(0) - -extern int edl_pcie_mhifd; - -#define IOCTL_BHI_GETDEVINFO 0x8BE0 + 1 -#define IOCTL_BHI_WRITEIMAGE 0x8BE0 + 2 - -typedef unsigned int ULONG; - -typedef struct _bhi_info_type -{ - ULONG bhi_ver_minor; - ULONG bhi_ver_major; - ULONG bhi_image_address_low; - ULONG bhi_image_address_high; - ULONG bhi_image_size; - ULONG bhi_rsvd1; - ULONG bhi_imgtxdb; - ULONG bhi_rsvd2; - ULONG bhi_msivec; - ULONG bhi_rsvd3; - ULONG bhi_ee; - ULONG bhi_status; - ULONG bhi_errorcode; - ULONG bhi_errdbg1; - ULONG bhi_errdbg2; - ULONG bhi_errdbg3; - ULONG bhi_sernum; - ULONG bhi_sblantirollbackver; - ULONG bhi_numsegs; - ULONG bhi_msmhwid[6]; - ULONG bhi_oempkhash[48]; - ULONG bhi_rsvd5; -}BHI_INFO_TYPE, *PBHI_INFO_TYPE; - -enum MHI_EE { - MHI_EE_PBL = 0x0, /* Primary Boot Loader */ - MHI_EE_SBL = 0x1, /* Secondary Boot Loader */ - MHI_EE_AMSS = 0x2, /* AMSS Firmware */ - MHI_EE_RDDM = 0x3, /* WIFI Ram Dump Debug Module */ - MHI_EE_WFW = 0x4, /* WIFI (WLAN) Firmware */ - MHI_EE_PT = 0x5, /* PassThrough, Non PCIe BOOT (PCIe is BIOS locked, not used for boot */ - MHI_EE_EDL = 0x6, /* PCIe enabled in PBL for emergency download (Non PCIe BOOT) */ - MHI_EE_FP = 0x7, /* FlashProg, Flash Programmer Environment */ - MHI_EE_BHIE = MHI_EE_FP, - MHI_EE_UEFI = 0x8, /* UEFI */ - - MHI_EE_DISABLE_TRANSITION = 0x9, - MHI_EE_MAX -}; -int qpcie_open(const char *firehose_dir, const char *firehose_mbn); - -#define Q_USB2TCP_VERSION 0x12345678 -typedef struct { - int tag; - int length; - int value[]; -} TLV; - -typedef struct { - int tag; - int length; - int idVendor; - int idProduct; - int interfaceNum; -} TLV_USB; -#endif diff --git a/rooter/0optionalapps/qlog/Makefile b/rooter/0optionalapps/qlog/Makefile deleted file mode 100644 index cef8271..0000000 --- a/rooter/0optionalapps/qlog/Makefile +++ /dev/null @@ -1,41 +0,0 @@ -# -# Copyright (C) 2011-2014 OpenWrt.org -# -# This is free software, licensed under the GNU General Public License v2. -# See /LICENSE for more information. -# - -include $(TOPDIR)/rules.mk - -PKG_NAME:=qlog -PKG_RELEASE:=1 - -PKG_FLAGS:=nonshared - -include $(INCLUDE_DIR)/package.mk - -define Package/qlog - SECTION:=utils - CATEGORY:=ROOter - SUBMENU:=Optional Applications - TITLE:=Quectel Qlog - MAINTAINER:=Dairyman -endef - -define Package/qlog/description - Quectel Qlog -endef - -define Build/Compile - $(MAKE) -C $(PKG_BUILD_DIR) \ - CC="$(TARGET_CC)" \ - CFLAGS="$(TARGET_CFLAGS) -Wall" -endef - -define Package/qlog/install - $(INSTALL_DIR) $(1)/usr/bin - $(INSTALL_BIN) $(PKG_BUILD_DIR)/QLog $(1)/usr/bin/QLog - $(CP) ./files/* $(1)/ -endef - -$(eval $(call BuildPackage,qlog)) diff --git a/rooter/0optionalapps/qlog/files/usr/lib/conf/T1.LinuxData-OTA-DataService-AP_V01.cfg b/rooter/0optionalapps/qlog/files/usr/lib/conf/T1.LinuxData-OTA-DataService-AP_V01.cfg deleted file mode 100644 index f662486..0000000 Binary files a/rooter/0optionalapps/qlog/files/usr/lib/conf/T1.LinuxData-OTA-DataService-AP_V01.cfg and /dev/null differ diff --git a/rooter/0optionalapps/qlog/files/usr/lib/conf/T2.RegServ-CotextAct_V01.cfg b/rooter/0optionalapps/qlog/files/usr/lib/conf/T2.RegServ-CotextAct_V01.cfg deleted file mode 100644 index 8645a8a..0000000 Binary files a/rooter/0optionalapps/qlog/files/usr/lib/conf/T2.RegServ-CotextAct_V01.cfg and /dev/null differ diff --git a/rooter/0optionalapps/qlog/files/usr/lib/conf/T3.SimpleData-(TCPUDP)_V01.cfg b/rooter/0optionalapps/qlog/files/usr/lib/conf/T3.SimpleData-(TCPUDP)_V01.cfg deleted file mode 100644 index 6289c58..0000000 Binary files a/rooter/0optionalapps/qlog/files/usr/lib/conf/T3.SimpleData-(TCPUDP)_V01.cfg and /dev/null differ diff --git a/rooter/0optionalapps/qlog/files/usr/lib/conf/T4.Throughput_V01.cfg b/rooter/0optionalapps/qlog/files/usr/lib/conf/T4.Throughput_V01.cfg deleted file mode 100644 index 3eccce1..0000000 Binary files a/rooter/0optionalapps/qlog/files/usr/lib/conf/T4.Throughput_V01.cfg and /dev/null differ diff --git a/rooter/0optionalapps/qlog/files/usr/lib/conf/T5.COMMON-T1T4_V01.cfg b/rooter/0optionalapps/qlog/files/usr/lib/conf/T5.COMMON-T1T4_V01.cfg deleted file mode 100644 index 57d1346..0000000 Binary files a/rooter/0optionalapps/qlog/files/usr/lib/conf/T5.COMMON-T1T4_V01.cfg and /dev/null differ diff --git a/rooter/0optionalapps/qlog/files/usr/lib/conf/T6.FullMessage.SimpleLogPacket(AT)_V01.cfg b/rooter/0optionalapps/qlog/files/usr/lib/conf/T6.FullMessage.SimpleLogPacket(AT)_V01.cfg deleted file mode 100644 index 19499f0..0000000 Binary files a/rooter/0optionalapps/qlog/files/usr/lib/conf/T6.FullMessage.SimpleLogPacket(AT)_V01.cfg and /dev/null differ diff --git a/rooter/0optionalapps/qlog/files/usr/lib/conf/T7.V2X_ALL_V01.cfg b/rooter/0optionalapps/qlog/files/usr/lib/conf/T7.V2X_ALL_V01.cfg deleted file mode 100644 index 656cb83..0000000 Binary files a/rooter/0optionalapps/qlog/files/usr/lib/conf/T7.V2X_ALL_V01.cfg and /dev/null differ diff --git a/rooter/0optionalapps/qlog/files/usr/lib/conf/default.cfg b/rooter/0optionalapps/qlog/files/usr/lib/conf/default.cfg deleted file mode 100644 index d3ffdb1..0000000 Binary files a/rooter/0optionalapps/qlog/files/usr/lib/conf/default.cfg and /dev/null differ diff --git a/rooter/0optionalapps/qlog/src/Makefile b/rooter/0optionalapps/qlog/src/Makefile deleted file mode 100644 index b5b7daa..0000000 --- a/rooter/0optionalapps/qlog/src/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -SOURCES = main.c asr.c mdm.c tty2tcp.c sahara.c - -linux: clean - ${CC} $(SOURCES) $(CFLAGS) -Wall -o QLog -lpthread -ldl - -clean: - rm -rf QLog *.exe *.dSYM *.obj *.exp .*o *.lib *~ libs out - diff --git a/rooter/0optionalapps/qlog/src/asr.c b/rooter/0optionalapps/qlog/src/asr.c deleted file mode 100644 index af54c56..0000000 --- a/rooter/0optionalapps/qlog/src/asr.c +++ /dev/null @@ -1,87 +0,0 @@ -#include "qlog.h" - -struct CSDLFileHeader -{ - uint32_t dwHeaderVersion;//0x0 - uint32_t dwDataFormat;//0x1 - uint32_t dwAPVersion; - uint32_t dwCPVersion; - uint32_t dwSequenceNum;//ļţ0ʼ - uint32_t dwTime;//Total seconds from 1970.1.1 0:0:0 - uint32_t dwCheckSum;//0x0 -}; - -int g_is_asr_chip = 0; - -ssize_t asr_send_cmd(int ttyfd, const unsigned char *buf, size_t size) { - ssize_t wc = 0; - - while (wc < size) { - uint32_t *cmd_data = (uint32_t *)(buf+wc); - unsigned cmd_len = qlog_le32(cmd_data[0]); - //unsigned i; - - if (cmd_len > (size - wc)) - break; - - //qlog_dbg("Send CMD to UE: "); - //for(i=0; i ../../devices/soc0/soc/2100000.aips-bus/2184200.usb/ci_hdrc.1/usb1/1-1/1-1:1.0/ttyUSB0/tty/ttyUSB0 - pchar = strstr(syspath, ":1.0/tty"); //MDM - if (pchar == NULL) { - pchar = strstr(syspath, ":1.2/tty"); //ASR - g_is_asr_chip = (pchar != NULL); - } - if (pchar == NULL) { - qlog_dbg("%s is not a usb-to-serial device?\n", ttyport); - return; - } - - *pchar = '\0'; - while (*pchar != '/') - pchar--; - - strcpy(sysport, pchar + 1); - - snprintf(syspath, sizeof(syspath), "/sys/bus/usb/devices/%s/idVendor", sysport); - fd = open(syspath, O_RDONLY); - if (fd <= 0) { - qlog_dbg("Fail to open %s, errno: %d (%s)\n", syspath, errno, strerror(errno)); - return; - } - read(fd, idVendor, 4); - close(fd); - - snprintf(syspath, sizeof(syspath), "/sys/bus/usb/devices/%s/idProduct", sysport); - fd = open(syspath, O_RDONLY); - if (fd <= 0) { - qlog_dbg("Fail to open %s, errno: %d (%s)\n", syspath, errno, strerror(errno)); - return; - } - read(fd, idProduct, 4); - close(fd); - - snprintf(syspath, sizeof(syspath), "/sys/bus/usb/devices/%s/bNumInterfaces", sysport); - fd = open(syspath, O_RDONLY); - if (fd <= 0) { - qlog_dbg("Fail to open %s, errno: %d (%s)\n", syspath, errno, strerror(errno)); - return; - } - read(fd, bNumInterfaces, 4); - close(fd); - - qlog_dbg("%s idVendor=%s, idProduct=%s, bNumInterfaces=%d\n", __func__, idVendor, idProduct, atoi(bNumInterfaces)); -} - -static unsigned long get_now_msec() -{ - struct timeval tv; - gettimeofday(&tv, NULL); - return tv.tv_sec*1000 + tv.tv_usec / 1000; -} - -static size_t ql_tty_read(int fd, void *buf, size_t size) -{ - size_t rc; - - rc = read(fd,buf,size); - - if (rc > 0) { - static size_t total_read = 0; - static unsigned long now_msec = 0; - unsigned long n = get_now_msec(); - - if (now_msec == 0) - now_msec = get_now_msec(); - total_read += rc; - - if ((total_read >= (4*1024*1024)) || (n >= (now_msec + 5000))) { - qlog_dbg("recv: %zdM %zdK %zdB in %ld msec\n", total_read/(1024*1024), - total_read/1024%1024,total_read%1024, n-now_msec); - now_msec = n; - total_read = 0; - } - } - - return rc; -} - -ssize_t qlog_poll_write(int fd, const void *buf, size_t size, unsigned timeout_msec) { - ssize_t wc = 0; - ssize_t nbytes; - - nbytes = write(fd, buf+wc, size-wc); - - if (nbytes <= 0) { - if (errno != EAGAIN) { - qlog_dbg("Fail to write fd = %d, errno : %d (%s)\n", fd, errno, strerror(errno)); - goto out; - } - else { - nbytes = 0; - } - } - - wc += nbytes; - - while (wc < size) { - int ret; - struct pollfd pollfds[] = {{fd, POLLOUT, 0}}; - - ret = poll(pollfds, 1, timeout_msec); - - if (ret <= 0) { - qlog_dbg("Fail to poll fd = %d, errno : %d (%s)\n", fd, errno, strerror(errno)); - break; - } - - if (pollfds[0].revents & (POLLERR | POLLHUP | POLLNVAL)) { - qlog_dbg("Fail to poll fd = %d, revents = %04x\n", fd, pollfds[0].revents); - break; - } - - if (pollfds[0].revents & (POLLOUT)) { - nbytes = write(fd, buf+wc, size-wc); - - if (nbytes <= 0) { - qlog_dbg("Fail to write fd = %d, errno : %d (%s)\n", fd, errno, strerror(errno)); - break; - } - wc += nbytes; - } - } - -out: - if (wc != size) { - qlog_dbg("%s fd=%d, size=%zd, timeout=%d, wc=%zd\n", __func__, fd, size, timeout_msec, wc); - } - - return (wc); -} - -static int qlog_logfile_create(const char *logfile_dir, const char *logfile_suffix, unsigned logfile_seq) { - int logfd; - time_t ltime; - char shortname[32]; - char filename[255+1]; - struct tm *currtime; - - //delete old logfile - if (s_logfile_num && s_logfile_List[logfile_seq%s_logfile_num][0]) { - sprintf(filename, "%s/%s.%s", logfile_dir, s_logfile_List[logfile_seq%s_logfile_num], logfile_suffix); - if (access(filename, R_OK) == 0) { - remove(filename); - } - } - - time(<ime); - currtime = localtime(<ime); - snprintf(shortname, sizeof(shortname), "%04d%02d%02d_%02d%02d%02d_%04d", - (currtime->tm_year+1900), (currtime->tm_mon+1), currtime->tm_mday, - currtime->tm_hour, currtime->tm_min, currtime->tm_sec, logfile_seq); - sprintf(filename, "%s/%s.%s", logfile_dir, shortname, logfile_suffix); - - logfd = open(filename, O_CREAT | O_WRONLY | O_TRUNC, 0444); - if (logfd <= 0) { - qlog_dbg("Fail to create new logfile! errno : %d (%s)\n", errno, strerror(errno)); - } - - qlog_dbg("%s %s logfd=%d\n", __func__, filename, logfd); - - if (s_logfile_num) { - strcpy(s_logfile_List[logfile_seq%s_logfile_num], shortname); - } - - return logfd; -} - -static size_t qlog_logfile_save(int logfd, const void *buf, size_t size) { - return qlog_poll_write(logfd, buf, size, 1000); -} - -static int qlog_logfile_close(int logfd) { - return close(logfd); -} - -static void* qlog_logfile_init_filter_thread(void* arg) { - void **thread_args = (void **)arg; - qlog_ops_t *qlog_ops = (qlog_ops_t *)thread_args[0]; - int *ttyfd = (int *)thread_args[1]; - const char *filter_cfg = ( const char *)thread_args[2]; - - if (qlog_ops->init_filter) - qlog_ops->init_filter(*ttyfd, filter_cfg); - - return NULL; -} - -static int qlog_handle(int ttyfd, const char *logfile_dir, size_t logfile_size, unsigned logfile_num, const char *filter_cfg) { - ssize_t savelog_size = 0; - void *rbuf; - const size_t rbuf_size = (16*1024); - static int logfd = -1; - unsigned logfile_seq = 0; - const char *logfile_suffix = g_is_asr_chip ? "sdl" : "qmdl"; - static qlog_ops_t qlog_ops; - pthread_t thread_id; - pthread_attr_t thread_attr; - const void *thread_args[3]; - - if (logfile_dir[0] == '9' && atoi(logfile_dir) >= 9000) { - filter_cfg = logfile_dir; - qlog_ops = tty2tcp_qlog_ops; - } - else { - qlog_ops = g_is_asr_chip ? asr_qlog_ops : mdm_qlog_ops; - if (access(logfile_dir, F_OK) && errno == ENOENT) - mkdir(logfile_dir, 0755); - } - - if (!qlog_ops.logfile_create) - qlog_ops.logfile_create = qlog_logfile_create; - if (!qlog_ops.logfile_save) - qlog_ops.logfile_save = qlog_logfile_save; - if (!qlog_ops.logfile_close) - qlog_ops.logfile_close = qlog_logfile_close; - - rbuf = malloc(rbuf_size); - if (rbuf == NULL) { - qlog_dbg("Fail to malloc rbuf_size=%zd, errno: %d (%s)\n", rbuf_size, errno, strerror(errno)); - return -1; - } - - thread_args[0] = &qlog_ops; - thread_args[1] = &ttyfd; - thread_args[2] = filter_cfg; - pthread_attr_init(&thread_attr); - pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_DETACHED); - pthread_create(&thread_id, &thread_attr, qlog_logfile_init_filter_thread, (void*)thread_args); - - while(1) { - ssize_t rc, wc; - int ret; - struct pollfd pollfds[] = {{ttyfd, POLLIN, 0}}; - - ret = poll(pollfds, 1, -1); - - if (ret <= 0) { - qlog_dbg("poll(ttyfd) =%d, errno: %d (%s)\n", ret, errno, strerror(errno)); - break; - } - - if (pollfds[0].revents & (POLLERR | POLLHUP | POLLNVAL)) { - qlog_dbg("ttyfd revents = %04x\n", pollfds[0].revents); - break; - } - - if (pollfds[0].revents & (POLLIN)) { - rc = ql_tty_read(ttyfd, rbuf, rbuf_size); - - if(rc > 0) { - if (logfd == -1) { - logfd = qlog_ops.logfile_create(logfile_dir, logfile_suffix, logfile_seq); - if (logfd <= 0) { - break; - } - if (qlog_ops.logfile_init) - qlog_ops.logfile_init(logfd, logfile_seq); - logfile_seq++; - } - - wc = qlog_ops.logfile_save(logfd, rbuf, rc); - - if (wc != rc) { - qlog_dbg("savelog fail %zd/%zd, break\n", wc, rc); - break; - } - - savelog_size += wc; - - if (savelog_size >= logfile_size) { - savelog_size = 0; - qlog_ops.logfile_close(logfd); - logfd = -1; - } - } - else - { - qlog_dbg("ttyfd recv %zd Bytes. break\n", rc); - break; - } - } - } - - if (logfd > 0) - qlog_ops.logfile_close(logfd); - free(rbuf); - - return 0; -} - -static void ql_sigaction(int signal_num) { - qlog_dbg("recv signal %d\n", signal_num); -} - -static void qlog_usage(const char *self, const char *dev) { - qlog_dbg("Usage: %s -p -s -f filter_cfg -n -b \n", self); - qlog_dbg("Default: %s -p %s -s %s -n %d -b %d to save log to local disk\n", - self, dev, ".", LOGFILE_NUM, LOGFILE_SIZE_DEFAULT/1024/1024); - qlog_dbg(" -p ttyport to catch log, default is '/dev/ttyUSB0'\n"); - qlog_dbg(" -s where to save log, default is '.' \n"); - qlog_dbg(" if set as '9000', QLog will run as TCP Server Mode, and let 'QPST/QWinLog/CATStudio' to connect!\n"); - qlog_dbg(" -f filter cfg for catch log, can be found in directory 'conf'. if not set this arg, will use default filter conf\n"); - qlog_dbg(" and UC200T&EC200T do not need filter cfg.\n"); - qlog_dbg(" -n max num of log file to save, range is '0~512'. default is 0. 0 means no limit.\n"); - qlog_dbg(" or QLog will auto delete oldtest log file if exceed max num\n"); - qlog_dbg(" -m max size of single log file, unit is MBytes, range is '2~512', default is 128\n"); - - qlog_dbg("\nFor example: %s -p /dev/ttyUSB0 -w .\n", self); -} - -int main(int argc, char **argv) -{ - int opt; - char ttyname[32] = "/dev/ttyUSB0"; - int ttyfd = -1; - const char *logfile_dir = "./"; - const char *filter_cfg = NULL; - size_t logfile_size = LOGFILE_SIZE_DEFAULT; - unsigned logfile_num = LOGFILE_NUM; - char idVendor[5] = "0000"; - char idProduct[5] = "0000"; - char bNumInterfaces[5] = "0"; - - qlog_dbg("QLog Version: Quectel_QLog_Linux&Android_V1.3\n"); //when release, rename to V1.X - - optind = 1; //call by popen(), optind mayby is not 1 - while ( -1 != (opt = getopt(argc, argv, "d:p:s:w:n:m:b:f:c:h"))) { - switch (opt) { - case 'p': - if (optarg[0] == 't') //ttyUSB0 - snprintf(ttyname, sizeof(ttyname), "/dev/%s", optarg); - else if (optarg[0] == 'U') //USB0 - snprintf(ttyname, sizeof(ttyname), "/dev/tty%s", optarg); - else if (optarg[0] == '/') - snprintf(ttyname, sizeof(ttyname), "%s", optarg); - else { - qlog_dbg("unknow dev %s\n", optarg); - } - break; - case 's': - logfile_dir = optarg; - break; - case 'n': - logfile_num = atoi(optarg); - if (logfile_num < 0) - logfile_num = 0; - else if (logfile_num > LOGFILE_NUM) - logfile_num = LOGFILE_NUM; - s_logfile_num = logfile_num; - break; - case 'm': - logfile_size = atoi(optarg)*1024*1024; - if (logfile_size < LOGFILE_SIZE_MIN) - logfile_size = LOGFILE_SIZE_MIN; - else if (logfile_size > LOGFILE_SIZE_MAX) - logfile_size = LOGFILE_SIZE_MAX; - break; - case 'f': - filter_cfg = optarg; - break; - case 'b': - case 'c': //unused - break; - default: - qlog_usage(argv[0], ttyname); - return 0; - break; - } - } - - signal(SIGTERM, ql_sigaction); - signal(SIGHUP, ql_sigaction); - signal(SIGINT, ql_sigaction); - - ttyfd = open (ttyname, O_RDWR | O_NDELAY | O_NOCTTY); - - if (ttyfd <= 0) { - qlog_dbg("Fail to open %s, errno : %d (%s)\n", ttyname, errno, strerror(errno)); - return -1; - } - - qlog_dbg("open %s ttyfd = %d\n", ttyname, ttyfd); - - if ( ttyfd > 0 ) { - struct termios ios; - - memset(&ios, 0, sizeof(ios)); - tcgetattr( ttyfd, &ios ); - cfmakeraw(&ios); - cfsetispeed(&ios, B115200); - cfsetospeed(&ios, B115200); - tcsetattr( ttyfd, TCSANOW, &ios ); - } - - if (strncmp(ttyname, "/dev/mhi", strlen("/dev/mhi"))) { - qlog_get_vidpid_by_ttyport(ttyname, idVendor, idProduct, bNumInterfaces); - } - else { - if (!strcmp(ttyname, "/dev/mhi_DIAG")) { - strcpy(idVendor, "2c7c"); - strcpy(bNumInterfaces, "5"); //log mode - } - else if (!strcmp(ttyname, "/dev/mhi_SAHARA")) { - strcpy(idVendor, "2c7c"); - strcpy(bNumInterfaces, "1"); //dump mode - } - } - - qlog_dbg("Press CTRL+C to stop catch log.\n"); - - if (g_is_asr_chip == 0 && atoi(bNumInterfaces) == 1) { - if (access(logfile_dir, F_OK) && errno == ENOENT) - mkdir(logfile_dir, 0755); - sahara_catch_dump(ttyfd, logfile_dir, 1); - } - else if (atoi(bNumInterfaces) > 1) { - qlog_handle(ttyfd, logfile_dir, logfile_size, logfile_num, filter_cfg); - } - else { - qlog_dbg("unknow state! quit!\n"); - } - - close(ttyfd); - - return 0; -} diff --git a/rooter/0optionalapps/qlog/src/mdm.c b/rooter/0optionalapps/qlog/src/mdm.c deleted file mode 100644 index 42d1adf..0000000 --- a/rooter/0optionalapps/qlog/src/mdm.c +++ /dev/null @@ -1,203 +0,0 @@ -#include "qlog.h" - -static unsigned char qlog_mdm_default_cfg[] = { -0x1d,0x1c,0x3b,0x7e,0x00,0x78,0xf0,0x7e,0x4b,0x32,0x06,0x00,0xba,0x4d,0x7e,0x7c,0x93,0x49,0x7e,0x1c,0x95,0x2a,0x7e,0x0c,0x14,0x3a,0x7e,0x63,0xe5,0xa1,0x7e,0x4b, -0x0f,0x00,0x00,0xbb,0x60,0x7e,0x4b,0x09,0x00,0x00,0x62,0xb6,0x7e,0x4b,0x08,0x00,0x00,0xbe,0xec,0x7e,0x4b,0x08,0x01,0x00,0x66,0xf5,0x7e,0x4b,0x04,0x00,0x00,0x1d, -0x49,0x7e,0x4b,0x04,0x0f,0x00,0xd5,0xca,0x7e,0x4b,0x0f,0x18,0x00,0x01,0x9e,0xa9,0x7e,0x4b,0x0f,0x18,0x00,0x02,0x05,0x9b,0x7e,0x4b,0x0f,0x2c,0x00,0x28,0xea,0x7e, -0x4b,0x12,0x39,0x00,0xeb,0x7b,0x7e,0x4b,0x12,0x3c,0x00,0x53,0x05,0x7e,0x4b,0x12,0x37,0x00,0xfb,0xe1,0x7e,0x4b,0x12,0x3b,0x00,0x5b,0x48,0x7e,0x4b,0x12,0x35,0x00, -0x4b,0xd2,0x7e,0x4b,0x12,0x3a,0x00,0x83,0x51,0x7e,0x4b,0x12,0x00,0x08,0x19,0x96,0x7e,0x7d,0x5d,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x74,0x41,0x7e,0x7d,0x5d,0x04, -0x00,0x00,0x02,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1c,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x4c,0x06,0x7e,0x7d,0x5d,0x04,0x05,0x00,0x05,0x00,0x00,0x00,0x1f,0x00, -0x00,0x00,0xce,0xa7,0x7e,0x7d,0x5d,0x04,0x07,0x00,0x08,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0xd0,0x71,0x7e,0x7d,0x5d,0x04,0x0b,0x00,0x0c,0x00, -0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x7c,0x68,0x7e,0x7d,0x5d,0x04,0x0e,0x00,0x12,0x00,0x00,0x00,0xff,0x01,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00, -0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0xb5,0x3a,0x7e,0x7d,0x5d,0x04,0x14,0x00,0x15,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x2e,0xbb, -0x7e,0x7d,0x5d,0x04,0x19,0x00,0x19,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x88,0xd0,0x7e,0x7d,0x5d,0x04,0x20,0x00,0x20,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0xea,0xaa, -0x7e,0x7d,0x5d,0x04,0x27,0x00,0x28,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0xfe,0x01,0x00,0x00,0x89,0x11,0x7e,0x7d,0x5d,0x04,0x2a,0x00,0x2b,0x00,0x00,0x00,0x1e,0x00, -0x00,0x00,0x1e,0x00,0x00,0x00,0x01,0x1a,0x7e,0x7d,0x5d,0x04,0x33,0x00,0x33,0x00,0x00,0x00,0x1f,0x00,0x00,0x00,0xc2,0xc1,0x7e,0x7d,0x5d,0x04,0x36,0x00,0x36,0x00, -0x00,0x00,0x1e,0x00,0x00,0x00,0xa3,0xd6,0x7e,0x7d,0x5d,0x04,0x39,0x00,0x3a,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x65,0xdf,0x7e,0x7d,0x5d,0x04, -0x3f,0x00,0x41,0x00,0x00,0x00,0x1f,0x00,0x00,0x00,0xfe,0xff,0x1f,0x00,0x1f,0x00,0x00,0x00,0xc9,0x67,0x7e,0x7d,0x5d,0x04,0x44,0x00,0x45,0x00,0x00,0x00,0x1e,0x00, -0x00,0x00,0x1e,0x00,0x00,0x00,0x2e,0x6c,0x7e,0x7d,0x5d,0x04,0x48,0x00,0x4a,0x00,0x00,0x00,0x1f,0x00,0x00,0x00,0x1f,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x4f,0xf2, -0x7e,0x7d,0x5d,0x04,0x4c,0x00,0x4c,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0xf2,0x66,0x7e,0x7d,0x5d,0x04,0x4e,0x00,0x4e,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x11,0x0f, -0x7e,0x7d,0x5d,0x04,0x58,0x00,0x58,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x9a,0x49,0x7e,0x7d,0x5d,0x04,0x5a,0x00,0x5b,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00, -0x00,0x00,0x0e,0x43,0x7e,0x7d,0x5d,0x04,0x63,0x00,0x63,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0xd9,0x60,0x7e,0x7d,0x5d,0x04,0x70,0x00,0x70,0x00,0x00,0x00,0x1e,0x00, -0x00,0x00,0x4a,0x17,0x7e,0x7d,0x5d,0x04,0x75,0x00,0x75,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xc8,0x6d,0x7e,0x7d,0x5d,0x04,0xea,0x03,0xea,0x03,0x00,0x00,0x1e,0x00, -0x00,0x00,0xa9,0x9e,0x7e,0x7d,0x5d,0x04,0xee,0x03,0xef,0x03,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x9b,0x20,0x7e,0x7d,0x5d,0x04,0xd0,0x07,0xd7,0x07, -0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00, -0x00,0x00,0xdc,0x10,0x7e,0x7d,0x5d,0x04,0xb8,0x0b,0xc5,0x0b,0x00,0x00,0x1f,0x00,0x00,0x00,0xfe,0xff,0x7f,0x00,0x7f,0x00,0x00,0x00,0x1f,0x00,0x00,0x00,0x1f,0x00, -0x00,0x00,0xff,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00, -0x00,0x00,0x1c,0x00,0x00,0x00,0xa9,0x36,0x7e,0x7d,0x5d,0x04,0xa0,0x0f,0xaa,0x0f,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00, -0x00,0x00,0xfe,0x01,0x00,0x00,0x1e,0x00,0x00,0x00,0xfe,0xff,0x01,0x00,0xfe,0xff,0x07,0x00,0xfe,0xff,0x01,0x00,0xfe,0x07,0x00,0x00,0x1e,0x00,0x00,0x00,0xc3,0xb9, -0x7e,0x7d,0x5d,0x04,0x05,0x12,0x05,0x12,0x00,0x00,0x1f,0x00,0x00,0x00,0xd2,0x41,0x7e,0x7d,0x5d,0x04,0x07,0x12,0x07,0x12,0x00,0x00,0x1f,0x00,0x00,0x00,0xf3,0x12, -0x7e,0x7d,0x5d,0x04,0x88,0x13,0xa8,0x13,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00, -0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00, -0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1f,0x00,0x00,0x00,0x1f,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00, -0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00, -0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0xf4,0x4c,0x7e,0x7d,0x5d,0x04,0x72,0x17,0x72,0x17,0x00,0x00,0x1e,0x00,0x00,0x00,0xcc,0x20, -0x7e,0x7d,0x5d,0x04,0x74,0x17,0x74,0x17,0x00,0x00,0x3f,0x00,0x00,0x00,0x47,0x46,0x7e,0x7d,0x5d,0x04,0x93,0x17,0x93,0x17,0x00,0x00,0x1e,0x00,0x00,0x00,0x8f,0xca, -0x7e,0x7d,0x5d,0x04,0x97,0x17,0x97,0x17,0x00,0x00,0x1e,0x00,0x00,0x00,0xcd,0x6c,0x7e,0x7d,0x5d,0x04,0xa4,0x17,0xb7,0x17,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00, -0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00, -0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00, -0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x8d,0xd1,0x7e,0x7d,0x5d,0x04,0xc0,0x17,0xc0,0x17,0x00,0x00,0x1e,0x00,0x00,0x00,0x96,0x89,0x7e,0x7d,0x5d,0x04, -0x34,0x21,0x34,0x21,0x00,0x00,0x1e,0x00,0x00,0x00,0x10,0xc3,0x7e,0x7d,0x5d,0x04,0x1c,0x25,0x25,0x25,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0xff,0x1f,0x00,0x7d,0x5e, -0x00,0x00,0x00,0x3e,0x00,0x00,0x00,0x7d,0x5e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0xfe,0x03,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x3e,0xd0,0x00,0x00, -0x90,0xed,0x7e,0x7d,0x5d,0x04,0x0b,0x28,0x0f,0x28,0x00,0x00,0x1c,0x00,0x00,0x00,0x1c,0x00,0x00,0x00,0x1c,0x00,0x00,0x00,0x1c,0x00,0x00,0x00,0x1c,0x00,0x00,0x00, -0x71,0x86,0x7e,0x7d,0x5d,0x04,0x6e,0x28,0x89,0x28,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00, -0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00, -0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00, -0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x52,0x90,0x7e,0x73, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xda,0x81,0x7e,0x73,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xfe,0x0f,0x00,0x00,0xf0,0x07,0xc8,0x00,0x00,0x40, -0xc4,0x00,0x00,0x00,0x00,0xc0,0x49,0xf3,0xc7,0x5b,0x7c,0xf3,0x0b,0x01,0x00,0x00,0x00,0x20,0xec,0x00,0xcc,0x83,0x01,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x38,0x00, -0x38,0x00,0x38,0x00,0x00,0x01,0x01,0x00,0x40,0x08,0xf0,0x07,0x0c,0xf8,0x47,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x40,0x04,0x00,0xff,0xf7,0x7f,0xf0,0xfc,0xff,0xff,0xad,0xe0,0x7f,0x02,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78, -0xe0,0xff,0xff,0xff,0x48,0x1c,0x1e,0x00,0x03,0x10,0x18,0xff,0xff,0xff,0xff,0xbf,0x00,0x00,0x00,0x00,0x00,0x90,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x80,0x1b,0x80,0xff,0x5f,0x06,0x00,0x00,0x41,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0xc0,0x07,0x01,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x10,0x00,0x80,0x00,0x00,0x7f,0xce,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x00,0x00, -0x08,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0xf8,0x07,0x00,0x00,0x00, -0x07,0x00,0x00,0xc0,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0a,0x30,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0xb7,0xb2,0x7e,0x73,0x00,0x00, -0x00,0x03,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x09,0x08,0x00,0x00,0x31,0x00,0x09,0x80,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0xef,0x20,0xf0,0x90,0x3c,0x1d,0x60,0x04,0x00,0x00,0x4f,0x03,0xfe,0x07,0x43,0x0b,0x02, -0x01,0x00,0x00,0x07,0xf4,0x45,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x86,0x8a,0x45,0xf8,0x25,0x10,0x00,0xcc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x82,0xc3,0x1e,0x00,0x7d,0x5e,0x00,0x4e,0x00,0xff,0x03,0x00,0x3c,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x09,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x01,0x32,0x3e,0x7e,0x73,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x5d, -0x0c,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x90,0x6f,0x3b,0xfc,0x01,0x13,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd0,0xff,0xd7,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0xf0,0xff,0xe7,0xff,0xbf,0xf3,0x43,0x3f,0x02,0x00,0xe0,0xe3,0x01,0xff,0x0d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x90,0x6f,0x1f,0xfc,0x71,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xd0,0xff,0x57,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0xe0,0xe7,0xff,0xf7,0xc3,0x3f,0x01,0x00,0xe0,0xe3,0x01,0x10,0x5d,0xe6,0x7e,0x73,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x57,0x0b, -0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x01,0x00,0x7f,0x02,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0xff,0x37,0x06,0xea,0x07,0x00,0x07,0x00,0x00,0x00,0x00,0xfc,0xf0,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x01,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x77,0x00,0x00,0x7f,0x9f,0xaa,0x7e,0x73,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0xd0,0x01,0x00,0x00, -0x06,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x5f,0x00,0x00,0x00,0xce,0x04,0xce,0x00,0x3f,0x00,0x3f,0x00,0xdf,0x24,0x00,0x00,0x7f,0xfc,0x3c,0x00, -0x00,0x00,0x3e,0x28,0x4e,0x50,0x05,0x12,0x51,0xe0,0x00,0x00,0xff,0xff,0xff,0xe2,0xcf,0xe1,0x7d,0x5d,0x51,0x7f,0x00,0x01,0x74,0x42,0xe0,0xac,0x34,0x7e,0x73,0x00, -0x00,0x00,0x03,0x00,0x00,0x00,0x0d,0x00,0x00,0x00,0x39,0x01,0x00,0x00,0x79,0xa6,0xff,0xff,0xff,0xa1,0x1f,0x00,0xdf,0x01,0x00,0x00,0x03,0x40,0x00,0x00,0x00,0x9f, -0x00,0x00,0x00,0x00,0xc0,0x06,0x00,0x00,0x00,0x00,0x5f,0x00,0x00,0x00,0xff,0x37,0xff,0xbf,0x1b,0x05,0x00,0x01,0x2b,0x17,0x7e,0x60,0x00,0x12,0x6a,0x7e,0x60,0x01, -0x9b,0x7b,0x7e,0x82,0x00,0x00,0x00,0x55,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, -0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xb7,0x0f,0x00,0x00,0x00,0x00,0x00,0x88,0xf4,0x0b,0x00,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x61,0x00,0x00,0x00,0x00,0x00,0x00, -0x00,0x00,0x04,0x00,0xd8,0x8f,0xff,0x3d,0xf8,0x48,0xfa,0x3f,0x06,0x00,0x00,0x19,0x00,0x00,0x00,0x0a,0xe0,0x0f,0x22,0x00,0x00,0x00,0xf8,0x84,0x2f,0x40,0x00,0x00, -0x0a,0x80,0xff,0xef,0x01,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0xe0,0x01,0xff,0x3f,0x82,0x00,0x01, -0x7d,0x5e,0x00,0x00,0x80,0xff,0x00,0x00,0x00,0x00,0xbe,0x19,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0xff,0x0f,0xfe,0x7f,0x00,0x18,0x00,0x00,0x00,0xe0,0x01,0x00,0x00, -0xc0,0xfd,0xbf,0x95,0x03,0x00,0x00,0x00,0x00,0x00,0x80,0x81,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0xc0,0x3f,0x12,0x8c,0x04,0x00,0x60,0xc8, -0x2f,0xf8,0xe7,0xf9,0xff,0x7f,0xff,0xff,0x07,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x03,0xfc,0x6f,0x00,0xc7,0x9f,0x00,0x03,0x80,0xf9,0xfa,0x0f,0x80, -0x7b,0x80,0x37,0x24,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x23,0x8c, -0x0d,0x00,0x00,0x01,0x98,0x04,0x00,0x30,0x00,0x00,0x00,0x00,0x06,0x00,0xf2,0x07,0x00,0x44,0x00,0xf8,0x1f,0x20,0x73,0x7e -}; - -extern int tty2tcp_sockfd; -ssize_t mdm_send_cmd(int ttyfd, const unsigned char *buf, size_t size) { - size_t wc = 0; - - while (wc < size) { - size_t flag = wc; - const unsigned char *cur = buf + wc; - unsigned short len = cur[2] + (((unsigned short)cur[3]) << 8) + 5; - - if (cur[0] == 0x7e && cur[1] == 0x01 && (wc + len) <= size && cur[len - 1] == 0x7e) { - flag += (len - 1); - } - else { - if (flag == 0 && buf[flag] == 0x7E) - flag++; - - while (buf[flag] != 0x7E && flag < size) - flag++; - } - - if (buf[flag] == 0x7E || flag == size) - qlog_poll_write(ttyfd, buf + wc, flag - wc + 1, 1000); - - if (tty2tcp_sockfd > 0 && (flag + 1) < size) { - size_t i = 0; - qlog_dbg("size=%zd, cur=%zd\n", size, flag - wc + 1); - for (i = 0; i < 16; i++) - printf("%02x", buf[i+wc]); - printf("\n"); - } - - wc = flag + 1; - } - - return size; -} - -static int mdm_init_filter(int ttyfd, const char *cfg) { - unsigned char *rbuf; - const size_t rbuf_size = (16*1024); - size_t cfg_size = 0; - -#if 0 - if (cfg == NULL) { - const unsigned char mdm_enter_dump1[] = { - 0x4b, 0x12, 0x18, 0x02, 0x01, 0x00, 0xd2, 0x7e - }; - const unsigned char mdm_enter_dump2[] = { - 0x7e, 0x01, 0x04, 0x00, 0x4b, 0x25, 0x03, 0x00, 0x7e - }; - qlog_dbg("send mdm dump command\n"); - mdm_send_cmd(ttyfd, mdm_enter_dump1, sizeof(mdm_enter_dump1)); - usleep(100*1000); - mdm_send_cmd(ttyfd, mdm_enter_dump2, sizeof(mdm_enter_dump2)); - return 0; - } -#endif - - rbuf = (unsigned char *)malloc(rbuf_size); - if (rbuf == NULL) { - qlog_dbg("Fail to malloc rbuf_size=%zd, errno: %d (%s)\n", rbuf_size, errno, strerror(errno)); - return -1; - } - - if (cfg) { - int cfgfd = open(cfg, O_RDONLY); - if (cfgfd < 0) { - qlog_dbg("Fail to open %s, errno : %d (%s)\n", cfg, errno, strerror(errno)); - } - - cfg_size = read(cfgfd, rbuf, rbuf_size); - close(cfgfd); - } - - if (cfg_size <= 0) { - cfg_size = sizeof(qlog_mdm_default_cfg); - memcpy(rbuf, qlog_mdm_default_cfg, cfg_size); - } - - mdm_send_cmd(ttyfd, rbuf, cfg_size); - - free(rbuf); - - return 0; -} - -qlog_ops_t mdm_qlog_ops = { - .init_filter = mdm_init_filter, -}; diff --git a/rooter/0optionalapps/qlog/src/qlog.h b/rooter/0optionalapps/qlog/src/qlog.h deleted file mode 100644 index 6ff8266..0000000 --- a/rooter/0optionalapps/qlog/src/qlog.h +++ /dev/null @@ -1,44 +0,0 @@ -#include -#include -#include -#ifndef __QUECTEL_QLOG_H -#define __QUECTEL_QLOG_H -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -typedef unsigned int uint32_t; - -typedef struct { - int (*init_filter)(int ttyfd, const char *conf); - int (*logfile_create)(const char *logfile_dir, const char *logfile_suffix, unsigned logfile_seq); - int (*logfile_init)(int logfd, unsigned logfile_seq); - size_t (*logfile_save)(int logfd, const void *buf, size_t size); - int (*logfile_close)(int logfd); -} qlog_ops_t; - -extern qlog_ops_t mdm_qlog_ops; -extern qlog_ops_t asr_qlog_ops; -extern qlog_ops_t tty2tcp_qlog_ops; -extern int g_is_asr_chip; -extern ssize_t asr_send_cmd(int ttyfd, const unsigned char *buf, size_t size); -extern ssize_t mdm_send_cmd(int ttyfd, const unsigned char *buf, size_t size); - -extern uint32_t qlog_le32 (uint32_t v32); -extern uint64_t qlog_le64 (uint64_t v64); -extern ssize_t qlog_poll_write(int fd, const void *buf, size_t size, unsigned timeout_mesc); - -extern unsigned qlog_msecs(void); -#define qlog_dbg(fmt, arg... ) do { unsigned msec = qlog_msecs(); printf("[%03d.%03d]" fmt, msec/1000, msec%1000, ## arg); } while (0) - int sahara_catch_dump(int port_fd, const char *path_to_save_files, int do_reset); -#endif diff --git a/rooter/0optionalapps/qlog/src/sahara.c b/rooter/0optionalapps/qlog/src/sahara.c deleted file mode 100644 index 347f3df..0000000 --- a/rooter/0optionalapps/qlog/src/sahara.c +++ /dev/null @@ -1,660 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -unsigned int inet_addr(const char *cp); - -/* modify macro MIN -* usually we difine it as: (a) < (b) ? (a) : (b) -* but it will cause some problems, here is a case: -* MIN(i++, j++), when calling the macro above, i++ will be run two times, which is wrong. -* so we can modify it as following. -* (void)(&_a == &_b); is use to check wether the type of 'a' and 'b' is same or not. -* (void) is used to eliminated warnning. -*/ -#define MIN(a, b) ({ \ - typeof(a) _a = a; \ - typeof(b) _b = b; \ - (void)(&_a == &_b); \ - _a < _b ? _a : _b; \ - }) - -#include "sahara_protocol.h" -#include "qlog.h" - -sahara_data_t sahara_data = { - NULL, // rx_buffer - NULL, // tx_buffer - NULL, // misc_buffer - SAHARA_WAIT_HELLO, // state - 0, // timed_data_size - -1, // fd - -1, // ram_dump_image - 5, // max_ram_dump_retries - SAHARA_RAW_BUFFER_SIZE, // max_ram_dump_read - SAHARA_MODE_LAST, // mode - SAHARA_MODE_LAST, // prev_mode - 0, // command - false // ram_dump_64bit -}; - -typedef struct { - char *port_name; - int port_fd; - int rx_timeout; - size_t MAX_TO_READ; - size_t MAX_TO_WRITE; -} com_port_t; - -static com_port_t com_port = { - "/dev/ttyUSB0", // port_name - -1, // port_fd - 5, // rx_timeout - 1024 * 64, - 1024 * 64, -}; - -typedef struct { - const char *path_to_save_files; - int verbose; - int do_reset; -} kickstart_options_t; - -static kickstart_options_t kickstart_options = { - NULL, // path_to_save_files - 1, // verbose - 1, -}; - -enum LOG_LEVEL { -LOG_DEBUG = 1, -LOG_EVENT, -LOG_INFO, -LOG_STATUS, -LOG_WARN, -LOG_ERROR -}; - -extern unsigned qlog_msecs(void); -#define dbg( log_level, fmt, arg... ) do {if (kickstart_options.verbose || LOG_ERROR == log_level) { unsigned msec = qlog_msecs(); printf("[%03d.%03d]" fmt "\n", msec/1000, msec%1000, ## arg);}} while (0) - -static bool port_tx_data (void *buffer, size_t bytes_to_send) { - int temp_bytes_sent; - size_t bytes_sent = 0; - - while (bytes_sent < bytes_to_send) { - do { - temp_bytes_sent = write (com_port.port_fd, buffer + bytes_sent, MIN(bytes_to_send - bytes_sent, com_port.MAX_TO_WRITE)); - if (-1 == temp_bytes_sent && (errno == EINTR || errno == EAGAIN)) { - sleep(1); - } else { - break; - } - } while(1); - - if (temp_bytes_sent <= 0) { - dbg(LOG_ERROR, "Write returned failure %d, errno %d, System error code: %s", temp_bytes_sent, errno, strerror (errno)); - return false; - } - else { - bytes_sent += temp_bytes_sent; - } - } - - return true; -} - -static bool port_rx_data(void *buffer, size_t bytes_to_read, size_t *bytes_read) { - fd_set rfds; - struct timeval tv; - int retval; - - // Init read file descriptor - FD_ZERO (&rfds); - FD_SET (com_port.port_fd, &rfds); - - // time out initializtion. - tv.tv_sec = com_port.rx_timeout >= 0 ? com_port.rx_timeout : 0; - tv.tv_usec = 0; - - retval = select (com_port.port_fd + 1, &rfds, NULL, NULL, ((com_port.rx_timeout >= 0) ? (&tv) : (NULL))); - if (retval <= 0) { - dbg(LOG_ERROR, "select returned error: %s", strerror (errno)); - return false; - } - - retval = read (com_port.port_fd, buffer, MIN(bytes_to_read, com_port.MAX_TO_READ)); - if (retval <= 0) { - dbg(LOG_ERROR, "Read/Write File descriptor returned error: %s, error code %d", strerror (errno), retval); - return false; - } - - if (NULL != bytes_read) - *bytes_read = retval; - - return true; -} - -static bool sahara_tx_data (size_t bytes_to_send) { - return port_tx_data(sahara_data.tx_buffer, bytes_to_send); -} - -static bool sahara_rx_data(size_t bytes_to_read) { - sahara_packet_header* command_packet_header = NULL; - size_t temp_bytes_read = 0, bytes_read = 0; - - const char *boot_sahara_cmd_id_str[SAHARA_LAST_CMD_ID] = { - "SAHARA_NO_CMD_ID", // = 0x00, - " SAHARA_HELLO_ID", // = 0x01, // sent from target to host - "SAHARA_HELLO_RESP_ID", // = 0x02, // sent from host to target - "SAHARA_READ_DATA_ID", // = 0x03, // sent from target to host - "SAHARA_END_IMAGE_TX_ID", // = 0x04, // sent from target to host - "SAHARA_DONE_ID", // = 0x05, // sent from host to target - "SAHARA_DONE_RESP_ID", // = 0x06, // sent from target to host - "SAHARA_RESET_ID", // = 0x07, // sent from host to target - "SAHARA_RESET_RESP_ID", // = 0x08, // sent from target to host - "SAHARA_MEMORY_DEBUG_ID", // = 0x09, // sent from target to host - "SAHARA_MEMORY_READ_ID", // = 0x0A, // sent from host to target - "SAHARA_CMD_READY_ID", // = 0x0B, // sent from target to host - "SAHARA_CMD_SWITCH_MODE_ID", // = 0x0C, // sent from host to target - "SAHARA_CMD_EXEC_ID", // = 0x0D, // sent from host to target - "SAHARA_CMD_EXEC_RESP_ID", // = 0x0E, // sent from target to host - "SAHARA_CMD_EXEC_DATA_ID", // = 0x0F, // sent from host to target - "SAHARA_64_BITS_MEMORY_DEBUG_ID", // = 0x10, // sent from target to host - "SAHARA_64_BITS_MEMORY_READ_ID", // = 0x11, // sent from host to target - "SAHARA_64_BITS_READ_DATA_ID", // = 0x12, - }; - - if (0 == bytes_to_read) { - command_packet_header = (sahara_packet_header *) sahara_data.rx_buffer; - memset(command_packet_header, 0x00, sizeof(sahara_packet_header)); - - if (false == port_rx_data(sahara_data.rx_buffer, sizeof(sahara_packet_header), &temp_bytes_read)) - return false; - - dbg(LOG_INFO, "Read %zd bytes, command %d and packet length %d bytes", temp_bytes_read, qlog_le32(command_packet_header->command), qlog_le32(command_packet_header->length)); - if (temp_bytes_read != sizeof(sahara_packet_header)) - return false; - - if (qlog_le32(command_packet_header->command) < SAHARA_LAST_CMD_ID) { - dbg(LOG_EVENT, "RECEIVED <-- %s", boot_sahara_cmd_id_str[qlog_le32(command_packet_header->command)]); - if (false == port_rx_data(sahara_data.rx_buffer + sizeof(sahara_packet_header), qlog_le32(command_packet_header->length) - sizeof(sahara_packet_header), &temp_bytes_read)) - return false; - if (temp_bytes_read != (qlog_le32(command_packet_header->length) - sizeof(sahara_packet_header))) { - dbg(LOG_INFO, "Read %zd bytes", temp_bytes_read + sizeof(sahara_packet_header)); - return false; - } - } else { - dbg(LOG_EVENT, "RECEIVED <-- SAHARA_CMD_UNKONOW_%d", qlog_le32(command_packet_header->command)); - return false; - } - } - else { - while (bytes_read < bytes_to_read) { - if (false == port_rx_data(sahara_data.rx_buffer + bytes_read, bytes_to_read - bytes_read, &temp_bytes_read)) { - dbg(LOG_ERROR, "bytes_read = %zd, bytes_to_read = %zd", bytes_read, bytes_to_read); - return false; - } else - bytes_read += temp_bytes_read; - } - } - - return true; -} - -static int timeval_subtract (struct timeval *result, struct timeval *x, struct timeval *y) { - // Perform the carry for the later subtraction by updating y. - if (x->tv_usec < y->tv_usec) { - int nsec = (y->tv_usec - x->tv_usec) / 1000000 + 1; - y->tv_usec -= 1000000 * nsec; - y->tv_sec += nsec; - } - if (x->tv_usec - y->tv_usec > 1000000) { - int nsec = (x->tv_usec - y->tv_usec) / 1000000; - y->tv_usec += 1000000 * nsec; - y->tv_sec -= nsec; - } - - // Compute the time remaining to wait. tv_usec is certainly positive. */ - result->tv_sec = x->tv_sec - y->tv_sec; - result->tv_usec = x->tv_usec - y->tv_usec; - - // Return 1 if result is negative. - return x->tv_sec < y->tv_sec; -} - -static void time_throughput_calculate(struct timeval *start_time, struct timeval *end_time, size_t size_bytes) -{ - struct timeval result; - double TP = 0.0; - - if (size_bytes == 0) { - dbg(LOG_INFO, "Cannot calculate throughput, size is 0"); - return; - } - timeval_subtract(&result, end_time, start_time); - - TP = (double)result.tv_usec/1000000.0; - TP += (double)result.tv_sec; - - if(TP>0.0) - { - TP = (double)((double)size_bytes/TP)/(1024.0*1024.0); - dbg(LOG_STATUS, "%zd bytes transferred in %ld.%06ld seconds (%.4fMBps)", size_bytes, result.tv_sec, result.tv_usec,TP); - } - else - dbg(LOG_STATUS, "%zd bytes transferred in %ld.%06ld seconds", size_bytes, result.tv_sec, result.tv_usec); -} - -static bool send_reset_command () -{ - sahara_packet_reset *sahara_reset = (sahara_packet_reset *)sahara_data.tx_buffer; - sahara_reset->header.command = qlog_le32(SAHARA_RESET_ID); - sahara_reset->header.length = qlog_le32(sizeof(sahara_packet_reset)); - - /* Send the Reset Request */ - dbg(LOG_EVENT, "SENDING --> SAHARA_RESET"); - if (false == sahara_tx_data (sizeof(sahara_packet_reset))) { - dbg(LOG_ERROR, "Sending RESET packet failed"); - return false; - } - - return true; -} - -static bool send_memory_read_packet (uint64_t memory_table_address, uint64_t memory_table_length) { - sahara_packet_memory_read *sahara_memory_read = (sahara_packet_memory_read *)sahara_data.tx_buffer; - sahara_packet_memory_read_64bit *sahara_memory_read_64bit = (sahara_packet_memory_read_64bit *)sahara_data.tx_buffer; - - dbg(LOG_EVENT, "SENDING --> SAHARA_MEMORY_READ, address 0x%08"PRIX64", length 0x%08"PRIX64, memory_table_address, memory_table_length); - - if (true == sahara_data.ram_dump_64bit) { - sahara_memory_read_64bit->header.command = qlog_le32(SAHARA_64_BITS_MEMORY_READ_ID); - sahara_memory_read_64bit->header.length = qlog_le32(sizeof(sahara_packet_memory_read_64bit)); - sahara_memory_read_64bit->memory_addr = qlog_le64(memory_table_address); - sahara_memory_read_64bit->memory_length = qlog_le64(memory_table_length); - - /* Send the Memory Read packet */ - if (false == sahara_tx_data (sizeof(sahara_packet_memory_read_64bit))) { - dbg(LOG_ERROR, "Sending MEMORY_READ packet failed"); - return false; - } - } else { - sahara_memory_read->header.command = qlog_le32(SAHARA_MEMORY_READ_ID); - sahara_memory_read->header.length = qlog_le32(sizeof(sahara_packet_memory_read)); - sahara_memory_read->memory_addr = qlog_le32((uint32_t)memory_table_address); - sahara_memory_read->memory_length = qlog_le32((uint32_t)memory_table_length); - - /* Send the Memory Read packet */ - if (false == sahara_tx_data (sizeof(sahara_packet_memory_read))) { - dbg(LOG_ERROR, "Sending MEMORY_READ packet failed"); - return false; - } - } - - return true; -} - -static bool is_valid_memory_table(uint64_t memory_table_size) -{ - if (true == sahara_data.ram_dump_64bit && memory_table_size % sizeof(dload_debug_type_64bit) == 0) { - return true; - } - else if (false == sahara_data.ram_dump_64bit && memory_table_size % sizeof(dload_debug_type) == 0) { - return true; - } - else { - return false; - } -} - -static bool sahara_start(void) { - int retval = 0; - int num_debug_entries = -1; - int i = 0; - uint64_t memory_table_addr = 0; - uint64_t memory_table_length = 0; - - struct timeval time_start, time_end; - - sahara_packet_hello *sahara_hello = (sahara_packet_hello *)sahara_data.rx_buffer; - sahara_packet_hello_resp *sahara_hello_resp = (sahara_packet_hello_resp *)sahara_data.tx_buffer; - sahara_packet_memory_debug *sahara_memory_debug = (sahara_packet_memory_debug *)sahara_data.rx_buffer; - sahara_packet_memory_debug_64bit *sahara_memory_debug_64bit = (sahara_packet_memory_debug_64bit *)sahara_data.rx_buffer; - dload_debug_type *sahara_memory_table_rx = (dload_debug_type *)sahara_data.rx_buffer; - dload_debug_type_64bit *sahara_memory_table = (dload_debug_type_64bit *)sahara_data.misc_buffer; - sahara_packet_reset_resp *sahara_reset_resp = (sahara_packet_reset_resp *)sahara_data.rx_buffer; - - sahara_data.state = SAHARA_WAIT_HELLO; - kickstart_options.verbose = 1; - - while (1) - { - switch (sahara_data.state) - { - case SAHARA_WAIT_HELLO: - dbg(LOG_EVENT, "STATE <-- SAHARA_WAIT_HELLO"); - if (false == sahara_rx_data(0)) // size 0 means we don't know what to expect. So we'll just try to read the 8 byte header - { - sahara_tx_data(1); - if (false == sahara_rx_data(0)) - return false; - } - - //Check if the received command is a hello command - if (SAHARA_HELLO_ID != qlog_le32(sahara_hello->header.command)) { - dbg(LOG_ERROR, "Received a different command: %x while waiting for hello packet", qlog_le32(sahara_hello->header.command)); - if (false == send_reset_command ()) { - return false; - } - // set the state to SAHARA_WAIT_RESET_RESP - dbg(LOG_EVENT, "STATE <-- SAHARA_WAIT_RESET_RESP\n"); - sahara_data.state = SAHARA_WAIT_RESET_RESP; - } - else { - // Recieved hello, send the hello response - // Create a Hello request - sahara_hello_resp->header.command = qlog_le32(SAHARA_HELLO_RESP_ID); - sahara_hello_resp->header.length = qlog_le32(sizeof(sahara_packet_hello_resp)); - sahara_hello_resp->version = sahara_hello->version; //SAHARA_VERSION; - sahara_hello_resp->version_supported = sahara_hello->version_supported; //SAHARA_VERSION_SUPPORTED; - sahara_hello_resp->status = qlog_le32(SAHARA_STATUS_SUCCESS); - sahara_hello_resp->mode = sahara_hello->mode; - sahara_hello_resp->reserved0 = qlog_le32(1); - sahara_hello_resp->reserved1 = qlog_le32(2); - sahara_hello_resp->reserved2 = qlog_le32(3); - sahara_hello_resp->reserved3 = qlog_le32(4); - sahara_hello_resp->reserved4 = qlog_le32(5); - sahara_hello_resp->reserved5 = qlog_le32(6); - - switch (qlog_le32(sahara_hello->mode)) { - case SAHARA_MODE_IMAGE_TX_PENDING: - dbg(LOG_EVENT, "RECEIVED <-- SAHARA_MODE_IMAGE_TX_PENDING"); - break; - case SAHARA_MODE_IMAGE_TX_COMPLETE: - dbg(LOG_EVENT, "RECEIVED <-- SAHARA_MODE_IMAGE_TX_COMPLETE"); - break; - case SAHARA_MODE_MEMORY_DEBUG: - dbg(LOG_EVENT, "RECEIVED <-- SAHARA_MODE_MEMORY_DEBUG"); - break; - case SAHARA_MODE_COMMAND: - dbg(LOG_EVENT, "RECEIVED <-- SAHARA_MODE_COMMAND"); - break; - default: - dbg(LOG_EVENT, "RECEIVED <-- SAHARA_MODE_0x%x", qlog_le32(sahara_hello->mode)); - break; - } - - if (qlog_le32(sahara_hello->mode) != sahara_data.mode) { - dbg(LOG_ERROR, "Not expect module state "); - return false; - } - - /*Send the Hello Resonse Request*/ - dbg(LOG_EVENT, "SENDING --> SAHARA_HELLO_RESPONSE"); - if (false == sahara_tx_data (sizeof(sahara_packet_hello_resp))) - { - dbg(LOG_ERROR, "Tx Sahara Data Failed "); - return false; - } - sahara_data.state = SAHARA_WAIT_COMMAND; - } - break; - - case SAHARA_WAIT_COMMAND: - dbg(LOG_INFO, "STATE <-- SAHARA_WAIT_COMMAND"); - if (false == sahara_rx_data(0)) - return false; - - // Check if it is an end of image Tx - if (SAHARA_MEMORY_DEBUG_ID == qlog_le32(((sahara_packet_header *)sahara_data.rx_buffer)->command) - || SAHARA_64_BITS_MEMORY_DEBUG_ID == qlog_le32(((sahara_packet_header *)sahara_data.rx_buffer)->command)) { - dbg(LOG_EVENT, "RECEIVED <-- SAHARA_MEMORY_DEBUG"); - - if (SAHARA_64_BITS_MEMORY_DEBUG_ID == qlog_le32(((sahara_packet_header *)sahara_data.rx_buffer)->command)) { - sahara_data.ram_dump_64bit = true; - dbg(LOG_EVENT, "Using 64 bit RAM dump mode"); - memory_table_addr = qlog_le64(sahara_memory_debug_64bit->memory_table_addr); - memory_table_length = qlog_le64(sahara_memory_debug_64bit->memory_table_length); - } - else { - sahara_data.ram_dump_64bit = false; - memory_table_addr = qlog_le32(sahara_memory_debug->memory_table_addr); - memory_table_length = qlog_le32(sahara_memory_debug->memory_table_length); - } - - dbg(LOG_INFO, "Memory Table Address: 0x%08"PRIX64", Memory Table Length: 0x%08"PRIX64, memory_table_addr, memory_table_length); - - if (false == is_valid_memory_table(memory_table_length)) { - dbg(LOG_ERROR, "Invalid memory table received"); - if (false == send_reset_command ()) { - return false; - } - sahara_data.state = SAHARA_WAIT_RESET_RESP; - break; - } - - if (memory_table_length > 0) { - if (false == send_memory_read_packet(memory_table_addr, memory_table_length)) { - return false; - } - - if (memory_table_length > SAHARA_RAW_BUFFER_SIZE) { - dbg(LOG_ERROR, "Memory table length is greater than size of intermediate buffer"); - return false; - } - } - dbg(LOG_EVENT, "STATE <-- SAHARA_WAIT_MEMORY_TABLE"); - sahara_data.state = SAHARA_WAIT_MEMORY_TABLE; - } - else { - dbg(LOG_ERROR, "Received an unknown command: %d ", qlog_le32(((sahara_packet_header *)sahara_data.rx_buffer)->command)); - if (SAHARA_HELLO_ID == qlog_le32(((sahara_packet_header *)sahara_data.rx_buffer)->command)) - continue; - if (false == send_reset_command ()) { - return false; - } - // set the state to SAHARA_WAIT_RESET_RESP - dbg(LOG_EVENT, "STATE <-- SAHARA_WAIT_RESET_RESP"); - sahara_data.state = SAHARA_WAIT_RESET_RESP; - } - break; - - case SAHARA_WAIT_MEMORY_TABLE: - dbg(LOG_INFO, "STATE <-- SAHARA_WAIT_MEMORY_TABLE"); - num_debug_entries = 0; - if (memory_table_length > 0) { - if (false == sahara_rx_data((size_t)memory_table_length)) { - return false; - } - dbg(LOG_INFO, "Memory Debug table received"); - - if (true == sahara_data.ram_dump_64bit) { - memcpy (sahara_data.misc_buffer, sahara_data.rx_buffer, (size_t)memory_table_length); - num_debug_entries = (int)(memory_table_length/sizeof(dload_debug_type_64bit)); - } - else { - num_debug_entries = (int)(memory_table_length/sizeof(dload_debug_type)); - if (num_debug_entries * sizeof(dload_debug_type_64bit) > SAHARA_RAW_BUFFER_SIZE) { - dbg(LOG_ERROR, "Length of memory table converted to 64-bit entries is greater than size of intermediate buffer"); - return false; - } - - for (i = 0; i < num_debug_entries; ++i) { - sahara_memory_table[i].save_pref = (uint64_t) qlog_le32(sahara_memory_table_rx[i].save_pref); - sahara_memory_table[i].mem_base = (uint64_t) qlog_le32(sahara_memory_table_rx[i].mem_base); - sahara_memory_table[i].length = (uint64_t) qlog_le32(sahara_memory_table_rx[i].length); - strncpy(sahara_memory_table[i].filename, sahara_memory_table_rx[i].filename, DLOAD_DEBUG_STRLEN_BYTES); - strncpy(sahara_memory_table[i].desc, sahara_memory_table_rx[i].desc, DLOAD_DEBUG_STRLEN_BYTES); - } // end for (i = 0; i < num_debug_entries; ++i) - } - } - - for(i = 0; i < num_debug_entries; i++) { - dbg(LOG_EVENT, "Base 0x%08"PRIX64" Len 0x%08"PRIX64", '%s', '%s'", sahara_memory_table[i].mem_base, sahara_memory_table[i].length, sahara_memory_table[i].filename, sahara_memory_table[i].desc); - } - sahara_data.state = SAHARA_WAIT_MEMORY_REGION; - break; - - case SAHARA_WAIT_MEMORY_REGION: - dbg(LOG_INFO, "STATE <-- SAHARA_WAIT_MEMORY_REGION"); - for(i = 0; i < num_debug_entries; i++) { - uint64_t cur = 0; - int fd = -1; - char full_filename[255] = {0}; - if (kickstart_options.path_to_save_files) { - strcpy(full_filename, kickstart_options.path_to_save_files); - strcat(full_filename, "/"); - } - strcat(full_filename, sahara_memory_table[i].filename); - - fd = open(full_filename, O_CREAT | O_WRONLY | O_TRUNC, 0444); - if (fd==-1) { - dbg(LOG_ERROR, "ERROR: Your file '%s' does not exist or cannot be created\n\n",sahara_memory_table[num_debug_entries].filename); - exit(0); - } - gettimeofday(&time_start, NULL); - - while (cur < sahara_memory_table[i].length) { - uint64_t len = MIN((uint32_t)(sahara_memory_table[i].length - cur), sahara_data.max_ram_dump_read); - - if (len < sahara_data.max_ram_dump_read || cur == 0 || (cur%(16*1024*1024)) == 0) - kickstart_options.verbose = 1; - else - kickstart_options.verbose = 0; - - retval = send_memory_read_packet(sahara_memory_table[i].mem_base + cur, len); - if (false == retval) { - return false; - } - - retval = sahara_rx_data((size_t)len); - if (false == retval) { - system("fuser /dev/ttyUSB0"); - if ( sahara_data.max_ram_dump_read > (16*1024)) { - sahara_data.max_ram_dump_read = sahara_data.max_ram_dump_read / 2; - continue; - } - return false; - } - - cur += len; - - retval = write(fd, sahara_data.rx_buffer, (unsigned int)len); - if (retval < 0) { - dbg(LOG_ERROR, "file write failed: %s", strerror(errno)); - return false; - } - if ((uint32_t) retval != len) { - dbg(LOG_WARN, "Wrote only %d of 0x%08"PRIX64" bytes", retval, memory_table_length); - } - } - - - kickstart_options.verbose = 1; - dbg(LOG_STATUS, "Received file '%s'", sahara_memory_table[i].filename); - close(fd); - gettimeofday(&time_end, NULL); - time_throughput_calculate(&time_start, &time_end, sahara_memory_table[i].length); - } - - if ( kickstart_options.do_reset) { - if (false == send_reset_command ()) { - return false; - } - sahara_data.state = SAHARA_WAIT_RESET_RESP; - } else { - return true; - } - break; - - case SAHARA_WAIT_DONE_RESP: - dbg(LOG_EVENT, "STATE <-- SAHARA_WAIT_DONE_RESP"); - return false; - break; - - case SAHARA_WAIT_RESET_RESP: - dbg(LOG_EVENT, "STATE <-- SAHARA_WAIT_RESET_RESP"); - if (true == sahara_rx_data(0)) { - if (SAHARA_RESET_RESP_ID != qlog_le32(sahara_reset_resp->header.command)) { - dbg(LOG_INFO,"Waiting for reset response code %i, received %i instead.", SAHARA_RESET_RESP_ID, qlog_le32(sahara_reset_resp->header.command)); - continue; - } - } else { - if (SAHARA_RESET_RESP_ID == qlog_le32(sahara_reset_resp->header.command)) { - dbg(LOG_INFO,"Get reset response code %i", sahara_reset_resp->header.command); - return true; - } else { - dbg(LOG_ERROR, "read failed: Linux system error: %s", strerror(errno)); - return false; - } - } - - return true; - break; - - default: - dbg(LOG_ERROR, "Unrecognized state %d", sahara_data.state); - return false; - } /* end switch */ - } /* end while (1) */ -} - - int sahara_catch_dump(int port_fd, const char *path_to_save_files, int do_reset) { - int retval; - - sahara_data.mode = SAHARA_MODE_MEMORY_DEBUG; - com_port.port_fd = port_fd; - kickstart_options.path_to_save_files = path_to_save_files; - kickstart_options.do_reset = do_reset; - - sahara_data.rx_buffer = malloc (SAHARA_RAW_BUFFER_SIZE); - sahara_data.tx_buffer = malloc (2048); - sahara_data.misc_buffer = malloc (2048); - - if (NULL == sahara_data.rx_buffer || NULL == sahara_data.tx_buffer || NULL == sahara_data.misc_buffer) { - dbg(LOG_ERROR, "Failed to allocate sahara buffers"); - return false; - } - - retval = sahara_start(); - if (false == retval) { - dbg(LOG_ERROR, "Sahara protocol error"); - } - else { - dbg(LOG_ERROR, "Sahara protocol completed"); - } - - free(sahara_data.rx_buffer); - free(sahara_data.tx_buffer); - free(sahara_data.misc_buffer); - - sahara_data.rx_buffer = sahara_data.tx_buffer = sahara_data.misc_buffer = NULL; - - if (retval == false) - dbg(LOG_INFO, "Catch DUMP using Sahara protocol failed\n\n"); - else - dbg(LOG_INFO, "Catch DUMP using Sahara protocol successful\n\n"); - - return retval; -} diff --git a/rooter/0optionalapps/qlog/src/sahara_protocol.h b/rooter/0optionalapps/qlog/src/sahara_protocol.h deleted file mode 100644 index 0db7989..0000000 --- a/rooter/0optionalapps/qlog/src/sahara_protocol.h +++ /dev/null @@ -1,510 +0,0 @@ -/*=========================================================================== - * FILE: - * sahara_packet.h - * - * DESCRIPTION: - * Sahara protocol states and structure declaration. - * - * Copyright (C) 2012 Qualcomm Technologies, Inc. All rights reserved. - * Qualcomm Technologies Proprietary/GTDR - * - * All data and information contained in or disclosed by this document is - * confidential and proprietary information of Qualcomm Technologies, Inc. and all - * rights therein are expressly reserved. By accepting this material the - * recipient agrees that this material and the information contained therein - * is held in confidence and in trust and will not be used, copied, reproduced - * in whole or in part, nor its contents revealed in any manner to others - * without the express written permission of Qualcomm Technologies, Inc. - * =========================================================================== - * - * sahara_packet.h : Sahara protocol states and structure declaration. - * ========================================================================================== - * $Header: //components/rel/boot.bf/3.1.4/boot_images/core/storage/tools/QSaharaServer/src/sahara_protocol.h#1 $ - * $DateTime: 2017/02/21 04:58:32 $ - * $Author: pwbldsvc $ - * - * Edit History: - * YYYY-MM-DD who why - * ----------------------------------------------------------------------------- - * 2010-09-28 ng Added command mode support - * 2010-10-18 ab Added memory debug mode support - * - * Copyright 2012 by Qualcomm Technologies, Inc. All Rights Reserved. - * - *========================================================================================== - */ - -#ifndef SAHARA_PROTOCOL_H -#define SAHARA_PROTOCOL_H - -/*=========================================================================== - * - * INCLUDE FILES - * - * ===========================================================================*/ - -/*=========================================================================== - * - * PUBLIC DATA DECLARATIONS - * - * ===========================================================================*/ -// Sahara Protocol Version -#define SAHARA_VERSION 2 -#define SAHARA_VERSION_SUPPORTED 4 - -/*Maximum 1 megabyte tx buffer size*/ -#define SAHARA_RAW_BUFFER_SIZE (64*1024) - -// Sahara command IDs -typedef enum -{ - SAHARA_NO_CMD_ID = 0x00, - SAHARA_HELLO_ID = 0x01, // sent from target to host - SAHARA_HELLO_RESP_ID = 0x02, // sent from host to target - SAHARA_READ_DATA_ID = 0x03, // sent from target to host - SAHARA_END_IMAGE_TX_ID = 0x04, // sent from target to host - SAHARA_DONE_ID = 0x05, // sent from host to target - SAHARA_DONE_RESP_ID = 0x06, // sent from target to host - SAHARA_RESET_ID = 0x07, // sent from host to target - SAHARA_RESET_RESP_ID = 0x08, // sent from target to host - SAHARA_MEMORY_DEBUG_ID = 0x09, // sent from target to host - SAHARA_MEMORY_READ_ID = 0x0A, // sent from host to target - SAHARA_CMD_READY_ID = 0x0B, // sent from target to host - SAHARA_CMD_SWITCH_MODE_ID = 0x0C, // sent from host to target - SAHARA_CMD_EXEC_ID = 0x0D, // sent from host to target - SAHARA_CMD_EXEC_RESP_ID = 0x0E, // sent from target to host - SAHARA_CMD_EXEC_DATA_ID = 0x0F, // sent from host to target - SAHARA_64_BITS_MEMORY_DEBUG_ID = 0x10, // sent from target to host - SAHARA_64_BITS_MEMORY_READ_ID = 0x11, // sent from host to target - SAHARA_64_BITS_READ_DATA_ID = 0x12, - // place all new commands above this - SAHARA_LAST_CMD_ID, - SAHARA_MAX_CMD_ID = 0x7FFFFFFF // To ensure 32-bits wide -} boot_sahara_cmd_id; - -typedef enum { - SAHARA_IMAGE_TYPE_BINARY = 0, /* Binary format */ - SAHARA_IMAGE_TYPE_ELF, /* ELF format */ - SAHARA_IMAGE_UNKNOWN = 0x7FFFFFFF /* To ensure 32-bits wide */ -} boot_sahara_image; - -// Status codes for Sahara -typedef enum -{ - // Success - SAHARA_STATUS_SUCCESS = 0x00, - - // Invalid command received in current state - SAHARA_NAK_INVALID_CMD = 0x01, - - // Protocol mismatch between host and target - SAHARA_NAK_PROTOCOL_MISMATCH = 0x02, - - // Invalid target protocol version - SAHARA_NAK_INVALID_TARGET_PROTOCOL = 0x03, - - // Invalid host protocol version - SAHARA_NAK_INVALID_HOST_PROTOCOL = 0x04, - - // Invalid packet size received - SAHARA_NAK_INVALID_PACKET_SIZE = 0x05, - - // Unexpected image ID received - SAHARA_NAK_UNEXPECTED_IMAGE_ID = 0x06, - - // Invalid image header size received - SAHARA_NAK_INVALID_HEADER_SIZE = 0x07, - - // Invalid image data size received - SAHARA_NAK_INVALID_DATA_SIZE = 0x08, - - // Invalid image type received - SAHARA_NAK_INVALID_IMAGE_TYPE = 0x09, - - // Invalid tranmission length - SAHARA_NAK_INVALID_TX_LENGTH = 0x0A, - - // Invalid reception length - SAHARA_NAK_INVALID_RX_LENGTH = 0x0B, - - // General transmission or reception error - SAHARA_NAK_GENERAL_TX_RX_ERROR = 0x0C, - - // Error while transmitting READ_DATA packet - SAHARA_NAK_READ_DATA_ERROR = 0x0D, - - // Cannot receive specified number of program headers - SAHARA_NAK_UNSUPPORTED_NUM_PHDRS = 0x0E, - - // Invalid data length received for program headers - SAHARA_NAK_INVALID_PDHR_SIZE = 0x0F, - - // Multiple shared segments found in ELF image - SAHARA_NAK_MULTIPLE_SHARED_SEG = 0x10, - - // Uninitialized program header location - SAHARA_NAK_UNINIT_PHDR_LOC = 0x11, - - // Invalid destination address - SAHARA_NAK_INVALID_DEST_ADDR = 0x12, - - // Invalid data size receieved in image header - SAHARA_NAK_INVALID_IMG_HDR_DATA_SIZE = 0x13, - - // Invalid ELF header received - SAHARA_NAK_INVALID_ELF_HDR = 0x14, - - // Unknown host error received in HELLO_RESP - SAHARA_NAK_UNKNOWN_HOST_ERROR = 0x15, - - // Timeout while receiving data - SAHARA_NAK_TIMEOUT_RX = 0x16, - - // Timeout while transmitting data - SAHARA_NAK_TIMEOUT_TX = 0x17, - - // Invalid mode received from host - SAHARA_NAK_INVALID_HOST_MODE = 0x18, - - // Invalid memory read access - SAHARA_NAK_INVALID_MEMORY_READ = 0x19, - - // Host cannot handle read data size requested - SAHARA_NAK_INVALID_DATA_SIZE_REQUEST = 0x1A, - - // Memory debug not supported - SAHARA_NAK_MEMORY_DEBUG_NOT_SUPPORTED = 0x1B, - - // Invalid mode switch - SAHARA_NAK_INVALID_MODE_SWITCH = 0x1C, - - // Failed to execute command - SAHARA_NAK_CMD_EXEC_FAILURE = 0x1D, - - // Invalid parameter passed to command execution - SAHARA_NAK_EXEC_CMD_INVALID_PARAM = 0x1E, - - // Unsupported client command received - SAHARA_NAK_EXEC_CMD_UNSUPPORTED = 0x1F, - - // Invalid client command received for data response - SAHARA_NAK_EXEC_DATA_INVALID_CLIENT_CMD = 0x20, - - // Failed to authenticate hash table - SAHARA_NAK_HASH_TABLE_AUTH_FAILURE = 0x21, - - // Failed to verify hash for a given segment of ELF image - SAHARA_NAK_HASH_VERIFICATION_FAILURE = 0x22, - - // Failed to find hash table in ELF image - SAHARA_NAK_HASH_TABLE_NOT_FOUND = 0x23, - - // Place all new error codes above this - SAHARA_NAK_LAST_CODE, - - SAHARA_NAK_MAX_CODE = 0x7FFFFFFF // To ensure 32-bits wide -} boot_sahara_status; - -// Status of all image transfers -typedef enum -{ - SAHARA_MODE_IMAGE_TX_PENDING = 0x0, - SAHARA_MODE_IMAGE_TX_COMPLETE = 0x1, - SAHARA_MODE_MEMORY_DEBUG = 0x2, - SAHARA_MODE_COMMAND = 0x3, - - // place all new commands above this - SAHARA_MODE_LAST, - SAHARA_MODE_MAX = 0x7FFFFFFF -} boot_sahara_mode; - -// Executable commands when target is in command mode -typedef enum -{ - SAHARA_EXEC_CMD_NOP = 0x00, - SAHARA_EXEC_CMD_SERIAL_NUM_READ = 0x01, - SAHARA_EXEC_CMD_MSM_HW_ID_READ = 0x02, - SAHARA_EXEC_CMD_OEM_PK_HASH_READ = 0x03, - SAHARA_EXEC_CMD_SWITCH_DMSS = 0x04, - SAHARA_EXEC_CMD_SWITCH_STREAMING = 0x05, - SAHARA_EXEC_CMD_READ_DEBUG_DATA = 0x06, - - // place all new commands above this - SAHARA_EXEC_CMD_LAST, - SAHARA_EXEC_CMD_MAX = 0x7FFFFFFF -} boot_sahara_exec_cmd_id; - -/* Sahara Protocol states */ -typedef enum { - SAHARA_WAIT_HELLO, - SAHARA_WAIT_COMMAND, - SAHARA_WAIT_RESET_RESP, - SAHARA_WAIT_DONE_RESP, - SAHARA_WAIT_MEMORY_READ, - SAHARA_WAIT_CMD_EXEC_RESP, - SAHARA_WAIT_MEMORY_TABLE, - SAHARA_WAIT_MEMORY_REGION, -} boot_sahara_state; - -/* ============================================================================= */ -/* Sahara protocol packet defintions */ -/* ============================================================================= */ - -typedef struct -{ - uint32_t command; // command ID - uint32_t length; // packet length incl command and length -} sahara_packet_header; - -// HELLO command packet type - sent from target to host -// indicates start of protocol on target side -typedef struct -{ - sahara_packet_header header; - uint32_t version; // target protocol version number - uint32_t version_supported; // minimum protocol version number supported - // on target - uint32_t cmd_packet_length; // maximum packet size supported for command - // packets - uint32_t mode; // expected mode of target operation - uint32_t reserved0; // reserved field - uint32_t reserved1; // reserved field - uint32_t reserved2; // reserved field - uint32_t reserved3; // reserved field - uint32_t reserved4; // reserved field - uint32_t reserved5; // reserved field -} sahara_packet_hello; - -// HELLO_RESP command packet type - sent from host to target -// response to hello, protocol version running on host and status sent -typedef struct -{ - sahara_packet_header header; - uint32_t version; // host protocol version number - uint32_t version_supported; // minimum protocol version number supported - // on host - uint32_t status; // OK or error condition - uint32_t mode; // mode of operation for target to execute - uint32_t reserved0; // reserved field - uint32_t reserved1; // reserved field - uint32_t reserved2; // reserved field - uint32_t reserved3; // reserved field - uint32_t reserved4; // reserved field - uint32_t reserved5; // reserved field -} sahara_packet_hello_resp; - -// READ_DATA command packet type - sent from target to host -// sends data segment offset and length to be read from current host -// image file -typedef struct -{ - sahara_packet_header header; - uint32_t image_id; // ID of image to be transferred - uint32_t data_offset; // offset into image file to read data from - uint32_t data_length; // length of data segment to be retreived - // from image file -} sahara_packet_read_data; - -// READ_DATA_64 command packet type - sent from target to host -// sends data segment offset and length to be read from current host -// image file -/* -#ifdef WINDOWSPC -#define PACK( __Declaration__ ) __pragma( pack(push, 1) ) __Declaration__ __pragma( pack(pop) ) -PACK( -typedef struct // note for gcc use __attribute__((__packed__)) -{ - sahara_packet_header header; - uint32_t image_id; // ID of image to be transferred - uint64_t data_offset; // offset into image file to read data from - uint32_t data_length; // length of data segment to be retreived - // from image file -} sahara_packet_read_data_64bit; -); -#else -typedef __attribute__((__packed__)) struct -{ - sahara_packet_header header; - uint32_t image_id; // ID of image to be transferred - uint64_t data_offset; // offset into image file to read data from - uint32_t data_length; // length of data segment to be retreived - // from image file -} sahara_packet_read_data_64bit; -#endif -*/ -typedef struct -{ - sahara_packet_header header; - uint64_t image_id; // ID of image to be transferred - uint64_t data_offset; // offset into image file to read data from - uint64_t data_length; // length of data segment to be retreived - // from image file -} sahara_packet_read_data_64bit; - -// END_IMAGE_TX command packet type - sent from target to host -// indicates end of a single image transfer and status of transfer -typedef struct -{ - sahara_packet_header header; - uint32_t image_id; // ID of image to be transferred - uint32_t status; // OK or error condition -} sahara_packet_end_image_tx; - -// DONE packet type - sent from host to target -// indicates end of single image transfer -typedef struct -{ - sahara_packet_header header; -} sahara_packet_done; - -// DONE_RESP packet type - sent from target to host -// indicates end of all image transfers -typedef struct -{ - sahara_packet_header header; - uint32_t image_tx_status; // indicates if all images have been - // transferred; - // 0 = IMAGE_TX_PENDING - // 1 = IMAGE_TX_COMPLETE -} sahara_packet_done_resp; - -// RESET packet type - sent from host to target -// indicates to target to reset -typedef struct -{ - sahara_packet_header header; -} sahara_packet_reset; - -// RESET_RESP packet type - sent from target to host -// indicates to host that target has reset -typedef struct -{ - sahara_packet_header header; -} sahara_packet_reset_resp; - -// MEMORY_DEBUG packet type - sent from target to host -// sends host the location and length of memory region table -typedef struct -{ - sahara_packet_header header; - uint32_t memory_table_addr; // location of memory region table - uint32_t memory_table_length; // length of memory table -} sahara_packet_memory_debug; -typedef struct -{ - sahara_packet_header header; - uint64_t memory_table_addr; // location of memory region table - uint64_t memory_table_length; // length of memory table -} sahara_packet_memory_debug_64bit; - -// MEMORY_READ packet type - sent from host to target -// sends memory address and length to read from target memory -typedef struct -{ - sahara_packet_header header; - uint32_t memory_addr; // memory location to read from - uint32_t memory_length; // length of data to send -} sahara_packet_memory_read; -typedef struct -{ - sahara_packet_header header; - uint64_t memory_addr; // memory location to read from - uint64_t memory_length; // length of data to send -} sahara_packet_memory_read_64bit; - -// CMD_READY packet type - sent from target to host -// indicates to host that target is ready to accept commands -typedef struct -{ - sahara_packet_header header; -} sahara_packet_cmd_ready; - -// CMD_SWITCH_MODE packet type - sent from host to target -// indicates to target to switch modes -typedef struct -{ - sahara_packet_header header; - uint32_t mode; // mode of operation for target to execute -} sahara_packet_cmd_switch_mode; - -// CMD_EXEC packet type - sent from host to target -// indicates to target to execute given client_command -typedef struct -{ - sahara_packet_header header; - uint32_t client_command; // command ID for target Sahara client to - // execute -} sahara_packet_cmd_exec; - -// CMD_EXEC_RESP packet type - sent from host to target -// indicates to host that target has successfully executed command -// and length of data response -typedef struct -{ - sahara_packet_header header; - uint32_t client_command; // command ID for target Sahara client to - // execute - uint32_t resp_length; // length of response returned from command - // execution -} sahara_packet_cmd_exec_resp; - -// CMD_EXEC_DATA packet type - sent from target to host -// indicates that host is ready to receive data after command execution -typedef struct -{ - sahara_packet_header header; - uint32_t client_command; // command ID for target Sahara client to - // execute -} sahara_packet_cmd_exec_data; - -#define DLOAD_DEBUG_STRLEN_BYTES 20 -typedef struct -{ - uint32_t save_pref; - uint32_t mem_base; - uint32_t length; - char desc[DLOAD_DEBUG_STRLEN_BYTES]; - char filename[DLOAD_DEBUG_STRLEN_BYTES]; -} dload_debug_type; - -typedef struct -{ - uint64_t save_pref; //force 8 bytes alignment - uint64_t mem_base; - uint64_t length; - char desc[DLOAD_DEBUG_STRLEN_BYTES]; - char filename[DLOAD_DEBUG_STRLEN_BYTES]; -} dload_debug_type_64bit; - -typedef struct { - /* buffer for sahara rx */ - void* rx_buffer; - - /* buffer for sahara tx */ - void* tx_buffer; - - /* buffer for memory table */ - void* misc_buffer; - - /* Sahara state */ - boot_sahara_state state; - - size_t timed_data_size; - - // handle to input image - int fd; - - int ram_dump_image; - - int max_ram_dump_retries; - - uint32_t max_ram_dump_read; - - boot_sahara_mode mode; - boot_sahara_mode prev_mode; - - unsigned int command; - bool ram_dump_64bit; - -} sahara_data_t; -#endif /* SAHARA_PACKET_H */ diff --git a/rooter/0optionalapps/qlog/src/tty2tcp.c b/rooter/0optionalapps/qlog/src/tty2tcp.c deleted file mode 100644 index 9d3b6e4..0000000 --- a/rooter/0optionalapps/qlog/src/tty2tcp.c +++ /dev/null @@ -1,174 +0,0 @@ -#include "qlog.h" - -unsigned int inet_addr(const char *cp); -char *inet_ntoa(struct in_addr in); - -static int wait_tcp_client_connect(int tcp_port) { - int sockfd, n, connfd; - struct sockaddr_in serveraddr; - struct sockaddr_in clientaddr; - int reuse_addr = 1; - size_t sin_size; - - sockfd = socket(AF_INET, SOCK_STREAM, 0); - if (sockfd == -1) - { - qlog_dbg("Create socket fail!\n"); - return 0; - } - - memset(&serveraddr, 0, sizeof(serveraddr)); - serveraddr.sin_family = AF_INET; - serveraddr.sin_addr.s_addr = htonl(INADDR_ANY); - serveraddr.sin_port = htons(tcp_port); - - qlog_dbg("Starting the TCP server(%d)...\n", tcp_port); - - setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &reuse_addr,sizeof(reuse_addr)); - - n = bind(sockfd, (struct sockaddr *)&serveraddr, sizeof(serveraddr)); - if (n == -1) - { - qlog_dbg("bind fail! errno: %d\n", errno); - close(sockfd); - return 0; - } - qlog_dbg("bind OK!\n"); - - n = listen(sockfd, 1); - if (n == -1) - { - qlog_dbg("listen fail! errno: %d\n", errno); - close(sockfd); - return 0; - } - qlog_dbg("listen OK!\nWaiting the TCP Client...\n"); - - sin_size = sizeof(struct sockaddr_in); - connfd = accept(sockfd, (struct sockaddr *)&clientaddr, (socklen_t *)&sin_size); - close(sockfd); - if (connfd == -1) - { - qlog_dbg("accept fail! errno: %d\n", errno); - return -1; - } - - qlog_dbg("TCP Client %s:%d connect\n", inet_ntoa(clientaddr.sin_addr), clientaddr.sin_port); - - return connfd; -} - -int tty2tcp_sockfd = -1; -static int tty2tcp_ttyfd = -1; -static int tty2tcp_tcpport = 9000; - -static void *tcp_sock_read_Loop(void *arg) { - int sockfd = tty2tcp_sockfd; - int ttyfd = tty2tcp_ttyfd; - void *rbuf; - const size_t rbuf_size = (4*1024); - - rbuf = malloc(rbuf_size); - if (rbuf == NULL) { - qlog_dbg("Fail to malloc rbuf_size=%zd, errno: %d (%s)\n", rbuf_size, errno, strerror(errno)); - return NULL; - } - - while (sockfd > 0) { - ssize_t rc, wc; - int ret; - struct pollfd pollfds[] = {{sockfd, POLLIN, 0}}; - - ret = poll(pollfds, 1, -1); - - if (ret <= 0) { - qlog_dbg("poll(ttyfd) =%d, errno: %d (%s)\n", ret, errno, strerror(errno)); - break; - } - - if (pollfds[0].revents & (POLLERR | POLLHUP | POLLNVAL)) { - tty2tcp_sockfd = -1; - close(sockfd); - qlog_dbg("ttyfd revents = %04x\n", pollfds[0].revents); - sockfd = tty2tcp_sockfd = wait_tcp_client_connect(tty2tcp_tcpport); - } - - if (pollfds[0].revents & (POLLIN)) { - rc = read(sockfd, rbuf, rbuf_size); - - if(rc > 0) { - if (g_is_asr_chip) - wc = asr_send_cmd(ttyfd, rbuf, rc); - else - wc = mdm_send_cmd(ttyfd, rbuf, rc); - - if (wc != rc) { - //qlog_dbg("ttyfd write fail %zd/%zd, break\n", wc, rc); - //break; - } - } - else - { - tty2tcp_sockfd = -1; - close(sockfd); - qlog_dbg("sockfd recv %zd Bytes. maybe terminae by peer!\n", rc); - sockfd = tty2tcp_sockfd = wait_tcp_client_connect(tty2tcp_tcpport); - } - } - } - - free(rbuf); - close(ttyfd); - tty2tcp_sockfd = -1; - qlog_dbg("%s exit\n", __func__); - - return NULL; -} - -static int tty2tcp_init_filter(int ttyfd, const char *cfg) { - int tcp_port = 9000; - int sockfd = -1; - pthread_t tid; - pthread_attr_t attr; - - if (cfg) - tcp_port = atoi(cfg); - - tty2tcp_tcpport = tcp_port; - sockfd = wait_tcp_client_connect(tcp_port); - - if (sockfd <= 0) - return -1; - - fcntl(sockfd, F_SETFL, fcntl(sockfd, F_GETFL) | O_NONBLOCK); - - pthread_attr_init (&attr); - pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); - - tty2tcp_sockfd = sockfd; - tty2tcp_ttyfd = ttyfd; - pthread_create(&tid, &attr, tcp_sock_read_Loop, &attr); - - return 0; -} - -static int tty2tcp_logfile_create(const char *logfile_dir, const char *logfile_suffix, unsigned logfile_seq) { - return 1; -} - -static size_t tty2tcp_logfile_save(int logfd, const void *buf, size_t size) { - if (tty2tcp_sockfd > 0) - return qlog_poll_write(tty2tcp_sockfd, buf, size, 200); - return size; -} - -static int tty2tcp_logfile_close(int logfd) { - return 0; -} - -qlog_ops_t tty2tcp_qlog_ops = { - .init_filter = tty2tcp_init_filter, - .logfile_create = tty2tcp_logfile_create, - .logfile_save = tty2tcp_logfile_save, - .logfile_close = tty2tcp_logfile_close, -}; diff --git a/rooter/0optionalapps/udp-tunnel/Makefile b/rooter/0optionalapps/udp-tunnel/Makefile deleted file mode 100644 index 4d568b5..0000000 --- a/rooter/0optionalapps/udp-tunnel/Makefile +++ /dev/null @@ -1,40 +0,0 @@ -# -# Copyright (C) 2011-2014 OpenWrt.org -# -# This is free software, licensed under the GNU General Public License v2. -# See /LICENSE for more information. -# - -include $(TOPDIR)/rules.mk - -PKG_NAME:=udp-tunnel -PKG_RELEASE:=1 - -PKG_FLAGS:=nonshared - -include $(INCLUDE_DIR)/package.mk - -define Package/udp-tunnel - SECTION:=utils - CATEGORY:=ROOter - SUBMENU:=Optional Applications - TITLE:=UDPTunnel - MAINTAINER:=Dairyman -endef - -define Package/udp-tunnel/description - UDPTunnel -endef - -define Build/Compile - $(MAKE) -C $(PKG_BUILD_DIR) \ - CC="$(TARGET_CC)" \ - CFLAGS="$(TARGET_CFLAGS) -Wall" -endef - -define Package/udp-tunnel/install - $(INSTALL_DIR) $(1)/sbin - $(INSTALL_BIN) $(PKG_BUILD_DIR)/udptunnel $(1)/sbin/udptunnel -endef - -$(eval $(call BuildPackage,udp-tunnel)) diff --git a/rooter/0optionalapps/udp-tunnel/src/Makefile b/rooter/0optionalapps/udp-tunnel/src/Makefile deleted file mode 100644 index 0a70e29..0000000 --- a/rooter/0optionalapps/udp-tunnel/src/Makefile +++ /dev/null @@ -1,36 +0,0 @@ -prefix = /usr/local - -CFLAGS ?= -g -O2 - -INSTALL ?= install -PKG_CONFIG ?= pkg-config - -ifeq ($(shell $(PKG_CONFIG) --exists libsystemd || echo NO),) -DEFS += -DHAVE_SYSTEMD_SD_DAEMON_H $(shell $(PKG_CONFIG) --cflags libsystemd) -LDADD += $(shell $(PKG_CONFIG) --libs libsystemd) -endif - -CPPFLAGS += $(DEFS) $(INCLUDES) - -OBJECTS := log.o network.o utils.o udptunnel.o - -all: depend udptunnel - -install: - $(INSTALL) -d $(BASEDIR)$(prefix)/sbin/ - $(INSTALL) -m 0755 udptunnel $(BASEDIR)$(prefix)/sbin/ - -clean: - rm -f Makefile.depend $(OBJECTS) udptunnel - -%.o: %.c - $(CC) $(CPPFLAGS) $(CFLAGS) -c $< - -udptunnel: $(OBJECTS) - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDADD) $(LIBS) - -depend: Makefile.depend -Makefile.depend: - $(CC) $(CPPFLAGS) $(CFLAGS) -MM -MG *.c > $@ - --include Makefile.depend diff --git a/rooter/0optionalapps/udp-tunnel/src/log.c b/rooter/0optionalapps/udp-tunnel/src/log.c deleted file mode 100644 index 91bb04d..0000000 --- a/rooter/0optionalapps/udp-tunnel/src/log.c +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (C) 2018 Marco d'Itri - * - * Inspired by log.c from the cowdancer package by James Clarke. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include -#include -#include -#include -#include - -#include "log.h" -#include "utils.h" - -static log_level filter_level = log_info; - -/* - * Return the appropriate file handle (stdout vs. stderr) for the log level. - */ -static FILE *file_for_level(log_level level) -{ - if (level & log_stderr || filter_level & log_stderr) - return stderr; - - if ((level & LOG_LEVEL_MASK) > log_warning) - return stdout; - else - return stderr; -} - -static void log_doit(log_level level, const char *format, va_list args) -{ - static int syslog_initialized; - - if ((level & LOG_LEVEL_MASK) > (filter_level & LOG_LEVEL_MASK)) - return; - - if (level & log_syslog || filter_level & log_syslog) { - if (!syslog_initialized) { - openlog(NULL, LOG_PID, LOG_DAEMON); - syslog_initialized = 1; - } - - if (level & log_strerror) { - int len = strlen(format); - char *format2; - - format2 = NOFAIL(malloc(len + 4 + 1)); - strcpy(format2, format); - strcpy(format2 + len, ": %m"); - vsyslog(level & LOG_LEVEL_MASK, format2, args); - free(format2); - } else { - vsyslog(level & LOG_LEVEL_MASK, format, args); - } - return; - } - - vfprintf(file_for_level(level), format, args); - if (level & log_strerror) - fprintf(file_for_level(level), ": %s", strerror(errno)); - fprintf(file_for_level(level), "\n"); -} - -log_level log_get_filter_level(void) -{ - return filter_level; -} - -void log_set_options(log_level filter_level_new) -{ - filter_level = filter_level_new; -} - -void log_printf(log_level level, const char *format, ...) -{ - va_list args; - - va_start(args, format); - log_doit(level, format, args); - va_end(args); -} - -void log_printf_exit(int status, log_level level, const char *format, ...) -{ - va_list args; - - va_start(args, format); - log_doit(level, format, args); - va_end(args); - - exit(status); -} - -void log_printf_err(log_level level, const char *format, ...) -{ - va_list args; - - va_start(args, format); - log_doit(level | log_strerror, format, args); - va_end(args); -} - -void log_printf_err_exit(int status, log_level level, const char *format, ...) -{ - va_list args; - - va_start(args, format); - log_doit(level | log_strerror, format, args); - va_end(args); - - exit(status); -} - diff --git a/rooter/0optionalapps/udp-tunnel/src/log.h b/rooter/0optionalapps/udp-tunnel/src/log.h deleted file mode 100644 index e42665d..0000000 --- a/rooter/0optionalapps/udp-tunnel/src/log.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2018 Marco d'Itri - * - * Inspired by log.c from the cowdancer package by James Clarke. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __LOG_H__ -#define __LOG_H__ - -#include - -#include "utils.h" - -typedef enum log_level { - /* the value of the first 3 bits matches the syslog(3) levels */ - log_emerg = 0, - log_alert = 1, - log_crit = 2, - log_err = 3, - log_warning = 4, - log_notice = 5, - log_info = 6, - log_debug = 7, - log_nothing = 8, - - /* the following entries are bit flags to be OR'ed with the level */ - log_stderr = 0x10, - log_syslog = 0x20, - log_strerror = 0x40, -} log_level; - -/* remove the flags from log_level */ -#define LOG_LEVEL_MASK 0xf - -log_level log_get_filter_level(void); - -void log_set_options(log_level filter_level_new); - -__attribute__ ((format(printf, 2, 3))) -void log_printf(log_level level, const char *format, ...); - -__attribute__ ((format(printf, 3, 4), noreturn)) -void log_printf_exit(int status, log_level level, const char *format, ...); - -__attribute__ ((format(printf, 2, 3))) -void log_printf_err(log_level level, const char *format, ...); - -__attribute__ ((format(printf, 3, 4), noreturn)) -void log_printf_err_exit(int status, log_level level, const char *format, ...); - -#define err_sys(...) log_printf_err_exit(1, log_err, __VA_ARGS__) - -#endif /* !__LOG_H__ */ diff --git a/rooter/0optionalapps/udp-tunnel/src/network.c b/rooter/0optionalapps/udp-tunnel/src/network.c deleted file mode 100644 index 2c0f2c1..0000000 --- a/rooter/0optionalapps/udp-tunnel/src/network.c +++ /dev/null @@ -1,401 +0,0 @@ -/* - * Copyright (C) 2018 Marco d'Itri - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/* for getaddrinfo... */ -#define _GNU_SOURCE - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "network.h" -#include "utils.h" -#include "log.h" - -char *print_addr_port(const struct sockaddr *addr, socklen_t addrlen) -{ - static char buf[1100], address[1025], port[32]; - int err; - - err = getnameinfo(addr, addrlen, address, sizeof(address), - port, sizeof(port), NI_NUMERICHOST | NI_NUMERICSERV); - if (err == EAI_SYSTEM) - err_sys("getnameinfo"); - else if (err) - log_printf_exit(1, log_err, "getnameinfo: %s", gai_strerror(err)); - - if (addr->sa_family == AF_INET6) - snprintf(buf, sizeof(buf) - 1, "[%s]:%s", address, port); - else - snprintf(buf, sizeof(buf) - 1, "%s:%s", address, port); - - return buf; -} - -static char *ai_print_addr_port(struct addrinfo *ai) -{ - return print_addr_port((struct sockaddr *) ai->ai_addr, ai->ai_addrlen); -} - -/* - * Try to parse anything that looks like: - * - an IPv4 or IPv6 address or a domain, with an optional port number - * - a port number - * - * address and/or port will be NULL if not found in the input. - * If address and port are not NULL then they must be freed by the caller. - */ -static void parse_address_port(const char *input, char **address, char **port) -{ - const char *p; - - *address = NULL; - *port = NULL; - - if (*input == '\0') { - return; - } else if (*input == '[' && (p = strchr(input, ']'))) { /* IPv6 */ - char *s; - int len = p - input - 1; - - *address = s = NOFAIL(malloc(len + 1)); - memcpy(s, input + 1, len); - *(s + len) = '\0'; - - p = strchr(p, ':'); - if (p && *(p + 1) != '\0') - *port = NOFAIL(strdup(p + 1)); /* IPv6 + port */ - } else if ((p = strchr(input, ':')) && /* IPv6, no port */ - strchr(p + 1, ':')) { /* and no brackets */ - *address = NOFAIL(strdup(input)); - } else if ((p = strchr(input, ':'))) { /* IPv4 + port */ - char *s; - int len = p - input; - - if (len) { - *address = s = NOFAIL(malloc(len + 1)); - memcpy(s, input, len); - *(s + len) = '\0'; - } - - p++; - if (*p != '\0') - *port = NOFAIL(strdup(p)); - } else { - for (p = input; *p; p++) - if (!isdigit(p[0])) - break; - if (*p) - *address = NOFAIL(strdup(input)); /* IPv4, no port */ - else - *port = NOFAIL(strdup(input)); /* just the port */ - } -} - -int udp_listener(const char *s) -{ - char *address, *port; - struct addrinfo hints, *res, *ai; - int err, fd; - - parse_address_port(s, &address, &port); - - if (!port) - log_printf_exit(2, log_err, "Missing port in '%s'!", s); - - memset(&hints, 0, sizeof hints); - hints.ai_family = AF_UNSPEC; - hints.ai_socktype = SOCK_DGRAM; - hints.ai_flags = AI_ADDRCONFIG | AI_PASSIVE | AI_IDN; - - err = getaddrinfo(address, port, &hints, &res); - if (err == EAI_SYSTEM) - err_sys("getaddrinfo(%s:%s)", address, port); - else if (err) - log_printf_exit(1, log_err, "Cannot resolve %s:%s: %s", - address, port, gai_strerror(err)); - - if (address) - free(address); - if (port) - free(port); - - for (ai = res; ai; ai = ai->ai_next) { - if ((fd = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol)) < 0) - continue; /* ignore */ - if (bind(fd, (struct sockaddr *) ai->ai_addr, ai->ai_addrlen) == 0) - break; /* success */ - close(fd); - } - - if (!ai) - err_sys("Cannot bind to %s", s); - - log_printf(log_info, "Listening for UDP connections on %s", - ai_print_addr_port(ai)); - - freeaddrinfo(res); - - return fd; -} - -int *tcp_listener(const char *s) -{ - char *address, *port; - struct addrinfo hints, *res, *ai; - int err, fd, opt; - int fd_num = 0; - int *fd_list = NULL; - size_t allocated_fds = 0; - - parse_address_port(s, &address, &port); - - if (!port) - log_printf_exit(2, log_err, "Missing port in '%s'!", s); - - memset(&hints, 0, sizeof hints); - hints.ai_family = AF_UNSPEC; - hints.ai_socktype = SOCK_STREAM; - hints.ai_flags = AI_ADDRCONFIG | AI_PASSIVE | AI_IDN; - - err = getaddrinfo(address, port, &hints, &res); - if (err == EAI_SYSTEM) - err_sys("getaddrinfo(%s:%s)", address, port); - else if (err) - log_printf_exit(1, log_err, "Cannot resolve %s:%s: %s", - address, port, gai_strerror(err)); - - if (address) - free(address); - if (port) - free(port); - - /* add to fd_list all the sockets which match ai_flags */ - for (ai = res; ai; ai = ai->ai_next) { - if ((fd = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol)) < 0) - continue; /* ignore */ - opt = 1; - if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) < 0) - err_sys("setsockopt(SOL_SOCKET, SO_REUSEADDR)"); - if (bind(fd, (struct sockaddr *) ai->ai_addr, ai->ai_addrlen) < 0) - err_sys("Cannot bind to %s", s); - - /* success */ - if (listen(fd, 128) < 0) - err_sys("listen"); - - if (allocated_fds < fd_num + 1 + 1) { - allocated_fds += 8; - fd_list = realloc(fd_list, allocated_fds * sizeof(int)); - } - fd_list[fd_num++] = fd; - - log_printf(log_info, "Listening for TCP connections on %s", - ai_print_addr_port(ai)); - } - - /* and then add -1 as the list terminator */ - if (allocated_fds < fd_num + 1 + 1) - fd_list = realloc(fd_list, ++allocated_fds * sizeof(int)); - fd_list[fd_num] = -1; - - if (!fd_list) - err_sys("socket"); - - freeaddrinfo(res); - - return fd_list; -} - -/* - * Accept new connections and return after forking for each one. - */ -int accept_connections(int listening_sockets[]) -{ - while (1) { - int max = 0; - int i, fd; - fd_set readfds; - pid_t pid; - - FD_ZERO(&readfds); - for (i = 0; listening_sockets[i] != -1; i++) { - int flags; - - if ((flags = fcntl(listening_sockets[i], F_GETFL, 0)) < 0) - err_sys("fcntl(F_GETFL)"); - if (fcntl(listening_sockets[i], F_SETFL, flags | O_NONBLOCK) < 0) - err_sys("fcntl(F_SETFL, O_NONBLOCK)"); - - FD_SET(listening_sockets[i], &readfds); - SET_MAX(listening_sockets[i]); - } - - if (select(max, &readfds, NULL, NULL, NULL) < 0) { - if (errno == EINTR || errno == EAGAIN) - continue; - err_sys("select"); - } - - for (i = 0; listening_sockets[i] != -1; i++) { - int listen_sock; - struct sockaddr_storage client_addr; - socklen_t addrlen = sizeof(client_addr); - - if (!FD_ISSET(listening_sockets[i], &readfds)) - continue; - listen_sock = listening_sockets[i]; - - fd = accept(listen_sock, (struct sockaddr *) &client_addr, &addrlen); - if (fd < 0) { - if (errno == EAGAIN) - continue; - err_sys("accept"); - } - - log_printf(log_notice, "Received a TCP connection from %s", - print_addr_port((struct sockaddr *) &client_addr, addrlen)); - -#if 0 - /* do not fork, for testing */ - pid = 0; -#else - pid = fork(); -#endif - - if (pid < 0) - err_sys("fork"); - - if (pid > 0) { - close(fd); - } else { - for (i = 0; listening_sockets[i] != -1; i++) - close(listening_sockets[i]); - return fd; - } - } - } -} - -int udp_client(const char *s, struct sockaddr_storage *remote_udpaddr) -{ - char *address, *port; - struct addrinfo hints, *res, *ai; - int err, fd; - - parse_address_port(s, &address, &port); - - if (!address || !port) - log_printf_exit(2, log_err, "Missing address or port in '%s'!", s); - - memset(&hints, 0, sizeof hints); - hints.ai_family = AF_UNSPEC; - hints.ai_socktype = SOCK_DGRAM; - hints.ai_flags = AI_ADDRCONFIG | AI_IDN; - - err = getaddrinfo(address, port, &hints, &res); - if (err == EAI_SYSTEM) - err_sys("getaddrinfo(%s:%s)", address, port); - else if (err) - log_printf_exit(1, log_err, "Cannot resolve %s:%s: %s", - address, port, gai_strerror(err)); - - if (address) - free(address); - if (port) - free(port); - - /* continue with the first socket which matches ai_flags */ - for (ai = res; ai; ai = ai->ai_next) { - if ((fd = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol)) < 0) - continue; /* ignore */ - break; /* success */ - } - - if (!ai) - err_sys("socket"); - - log_printf(log_debug, "The UDP destination is %s", ai_print_addr_port(ai)); - - /* - * Return to the caller the resolved address, to be able to use it as the - * destination address of the next UDP packet. - */ - if (remote_udpaddr) - memcpy(remote_udpaddr, ai->ai_addr, ai->ai_addrlen); - - freeaddrinfo(res); - - return fd; -} - -int tcp_client(const char *s) -{ - char *address, *port; - struct addrinfo hints, *res, *ai; - int err, fd; - - parse_address_port(s, &address, &port); - - if (!address || !port) - log_printf_exit(2, log_err, "Missing address or port in '%s'!", s); - - memset(&hints, 0, sizeof(struct addrinfo)); - hints.ai_family = AF_UNSPEC; - hints.ai_socktype = SOCK_STREAM; - hints.ai_flags = AI_ADDRCONFIG | AI_IDN; - - err = getaddrinfo(address, port, &hints, &res); - if (err == EAI_SYSTEM) - err_sys("getaddrinfo(%s:%s)", address, port); - else if (err) - log_printf_exit(1, log_err, "Cannot resolve %s:%s: %s", - address, port, gai_strerror(err)); - - if (address) - free(address); - if (port) - free(port); - - for (ai = res; ai; ai = ai->ai_next) { - if ((fd = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol)) < 0) - continue; /* ignore */ - if (connect(fd, (struct sockaddr *) ai->ai_addr, ai->ai_addrlen) == 0) - break; /* success */ - close(fd); - } - - if (!ai) - err_sys("Cannot connect to %s", s); - - log_printf(log_info, "TCP connection opened to %s", - ai_print_addr_port(ai)); - - freeaddrinfo(res); - - return fd; -} - diff --git a/rooter/0optionalapps/udp-tunnel/src/network.h b/rooter/0optionalapps/udp-tunnel/src/network.h deleted file mode 100644 index 2fafdc1..0000000 --- a/rooter/0optionalapps/udp-tunnel/src/network.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2018 Marco d'Itri - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __NETWORK_H__ -#define __NETWORK_H__ - -#define SET_MAX(fd) do { if (max < (fd) + 1) { max = (fd) + 1; } } while (0) - -char *print_addr_port(const struct sockaddr *addr, socklen_t addrlen); - -int udp_listener(const char *s); - -int *tcp_listener(const char *s); - -int udp_listener_sa(const int num); - -int *tcp_listener_sa(const int num); - -int udp_client(const char *s, struct sockaddr_storage *remote_udpaddr); - -int tcp_client(const char *s); - -int accept_connections(int listening_sockets[]); - -#endif diff --git a/rooter/0optionalapps/udp-tunnel/src/udptunnel.c b/rooter/0optionalapps/udp-tunnel/src/udptunnel.c deleted file mode 100644 index 8dd9c17..0000000 --- a/rooter/0optionalapps/udp-tunnel/src/udptunnel.c +++ /dev/null @@ -1,523 +0,0 @@ -/* - * Copyright (C) 2018 Marco d'Itri - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * - * Parts of this program are derived from udptunnel.c by Jonathan Lennox. - * This is the license of the original code: - * - * Copyright 1999, 2001 by Columbia University. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS - * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* for sigaction... */ -#define _GNU_SOURCE - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef HAVE_SYSTEMD_SD_DAEMON_H -#include -#endif - -#include "utils.h" -#include "log.h" -#include "network.h" - -#ifdef HAVE_GETOPT_LONG -#include -#endif - -#define TCPBUFFERSIZE 65536 -#define UDPBUFFERSIZE (TCPBUFFERSIZE - 2) /* TCP packet - length */ - -struct out_packet { - uint16_t length; - char buf[UDPBUFFERSIZE]; -}; - -struct opts { - const char *udpaddr, *tcpaddr; - - int is_server; - int use_inetd; - char *handshake; - int timeout; -}; - -struct relay { - struct sockaddr_storage remote_udpaddr; - - int udp_sock, tcp_sock; - - int expect_handshake; - char handshake[32]; - int udp_timeout, tcp_timeout; - char buf[TCPBUFFERSIZE]; - char *buf_ptr, *packet_start; - int packet_length; - enum { - uninitialized = 0, - reading_handshake, - reading_length, - reading_packet, - } state; -}; - -static void usage(int status) -{ - FILE *fp = status == 0 ? stdout : stderr; - - fprintf(fp, "Usage: udptunnel [OPTION]... [[SOURCE:]PORT] DESTINATION:PORT\n\n"); - fprintf(fp, "-s --server listen for TCP connections\n"); - fprintf(fp, "-i --inetd expect to be started by inetd\n"); - fprintf(fp, "-T N --timeout N close the source connection after N seconds\n"); - fprintf(fp, " where no data was received\n"); - fprintf(fp, "-S --syslog log to syslog instead of standard error\n"); - fprintf(fp, "-v --verbose explain what is being done\n"); - fprintf(fp, "-h --help display this help and exit\n"); - fprintf(fp, "\nSOURCE:PORT must not be specified when using inetd or socket activation.\n\n"); - fprintf(fp, "If the -s option is used then the program will listen on SOURCE:PORT for TCP\n"); - fprintf(fp, "connections and relay the encapsulated packets with UDP to DESTINATION:PORT.\n"); - fprintf(fp, "Otherwise it will listen on SOURCE:PORT for UDP packets and encapsulate\n"); - fprintf(fp, "them in a TCP connection to DESTINATION:PORT.\n"); - - exit(status); -} - -static void parse_args(int argc, char *argv[], struct opts *opts) -{ -#ifdef HAVE_GETOPT_LONG - const struct option longopts[] = { - {"inetd", no_argument, NULL, 'i' }, - {"server", no_argument, NULL, 's' }, - {"syslog", no_argument, NULL, 'S' }, - {"timeout", required_argument, NULL, 'T' }, - {"help", no_argument, NULL, 'h' }, - {"verbose", no_argument, NULL, 'v' }, - {NULL, 0, NULL, 0 }, - }; - int longindex; -#endif - int c; - int expected_args; - int verbose = 0; - int use_syslog = 0; - - /* defaults */ - opts->handshake = NOFAIL(malloc(32)); - memcpy(opts->handshake, "udptunnel by md.\0\0\0\x01\x03\x06\x10\x15\x21\x28\x36\x45\x55\x66\x78\x91", 32); - - while ((c = GETOPT_LONGISH(argc, argv, "ihsvST:", - longopts, &longindex)) > 0) { - switch (c) { - case 'i': - opts->use_inetd = 1; - break; - case 's': - opts->is_server = 1; - break; - case 'S': - use_syslog = 1; - break; - case 'T': - opts->timeout = atol(optarg); - break; - case 'v': - verbose++; - break; - case 'h': - usage(0); - break; - default: - usage(2); - break; - } - } - - /* - * Look for 2 command line arguments (source and destination) - * if used in standalone mode or only 1 argument (destination) - * if used in inetd or socket activated modes. - */ - expected_args = (sd_listen_fds(0) || opts->use_inetd) ? 1 : 2; - - if (argc - optind == 0) - usage(2); - if (argc - optind != expected_args) { - fprintf(stderr, "Expected %d argument(s)!\n\n", expected_args); - usage(2); - } - - /* the source and destination addresses */ - if (opts->is_server) { - if (expected_args == 2) - opts->tcpaddr = NOFAIL(strdup(argv[optind++])); - opts->udpaddr = NOFAIL(strdup(argv[optind++])); - } else { - if (expected_args == 2) - opts->udpaddr = NOFAIL(strdup(argv[optind++])); - opts->tcpaddr = NOFAIL(strdup(argv[optind++])); - } - - if (!verbose) - log_set_options(log_warning); - else if (verbose == 1) - log_set_options(log_notice); - else if (verbose == 2) - log_set_options(log_info); - else - log_set_options(log_debug); - - if (use_syslog) - log_set_options(log_get_filter_level() | log_syslog); -} - -int udp_listener_sa(const int num) -{ - int fd = SD_LISTEN_FDS_START; - - if (num != 1) - log_printf_exit(2, log_err, - "UDP socket activation supports a single socket."); - - if (sd_is_socket(fd, AF_UNSPEC, SOCK_DGRAM, -1) <= 0) - log_printf_exit(2, log_err, - "UDP socket activation fd %d is not valid.", fd); - - return fd; -} - -int *tcp_listener_sa(const int num) -{ - int fd; - int *fds; - int fd_num = 0; - - fds = NOFAIL(malloc((num + 1) * sizeof(int))); - - for (fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + num; fd++) { - if (sd_is_socket(fd, AF_UNSPEC, SOCK_STREAM, 1) <= 0) - log_printf_exit(2, log_err, - "TCP socket activation fd %d is not valid.", fd); - fds[fd_num++] = fd; - } - - fds[fd_num] = -1; - - return fds; -} - -static void udp_to_tcp(struct relay *relay) -{ - struct out_packet p; - int buflen; - struct sockaddr_storage remote_udpaddr; - socklen_t addrlen = sizeof(remote_udpaddr); - - buflen = recvfrom(relay->udp_sock, p.buf, UDPBUFFERSIZE, 0, - (struct sockaddr *) &remote_udpaddr, &addrlen); - if (buflen < 0) - err_sys("recvfrom(udp)"); - if (buflen == 0) - return; /* ignore empty packets */ - - /* - * Store the source address of the received UDP packet, to be able to use - * it in send_udp_packet as the destination address of the next UDP reply. - */ - memcpy(&(relay->remote_udpaddr), &remote_udpaddr, addrlen); - -#ifdef DEBUG - log_printf(log_debug, "Received a %d bytes UDP packet from %s", buflen, - print_addr_port((struct sockaddr *) &remote_udpaddr, addrlen)); -#endif - - p.length = htons(buflen); - if (send(relay->tcp_sock, &p, buflen + sizeof(p.length), 0) < 0) - err_sys("send(tcp)"); -} - -static void send_udp_packet(struct relay *relay) -{ - int opt = 0; - socklen_t len = sizeof(opt); - - if (relay->remote_udpaddr.ss_family == 0) { - log_printf(log_info, - "Ignoring a packet for a still unknown UDP destination!"); - return; - } - - if (sendto(relay->udp_sock, relay->packet_start, relay->packet_length, 0, - (struct sockaddr *) &relay->remote_udpaddr, - sizeof(relay->remote_udpaddr)) >= 0) - return; - - /* this is the error path */ - if (errno != ECONNREFUSED) - err_sys("sendto(udp)"); - - /* clear the error if there is no UDP listener yet on the other end */ - log_printf(log_info, "sendto(udp) returned ECONNREFUSED: ignored"); - if (getsockopt(relay->udp_sock, SOL_SOCKET, SO_ERROR, &opt, &len) < 0) - err_sys("getsockopt(udp, SOL_SOCKET, SO_ERROR)"); - - return; -} - -static void tcp_to_udp(struct relay *relay) -{ - int read_len; - - if (relay->state == uninitialized) { - if (relay->expect_handshake) { - relay->state = reading_handshake; - relay->packet_length = sizeof(relay->handshake); - } else { - relay->state = reading_length; - relay->packet_length = sizeof(uint16_t); - } - relay->buf_ptr = relay->buf; - relay->packet_start = relay->buf; - } - - read_len = read(relay->tcp_sock, relay->buf_ptr, - (relay->buf + TCPBUFFERSIZE - relay->buf_ptr)); - if (read_len < 0) - err_sys("read(tcp)"); - - if (read_len == 0) - log_printf_exit(0, log_notice, "Remote closed the connection"); - - relay->buf_ptr += read_len; - - while (relay->buf_ptr - relay->packet_start >= relay->packet_length) { - if (relay->state == reading_handshake) { - /* check the handshake string */ - if (memcmp(relay->packet_start, &(relay->handshake), - sizeof(relay->handshake)) != 0) - log_printf_exit(0, log_info, - "Received a bad handshake, exiting"); - log_printf(log_debug, "Received a good handshake"); - relay->packet_start += sizeof(relay->handshake); - relay->state = reading_length; - relay->packet_length = sizeof(uint16_t); - } else if (relay->state == reading_length) { - /* read the lenght of the next packet */ - relay->packet_length = ntohs(*(uint16_t *) relay->packet_start); - relay->packet_start += sizeof(uint16_t); - relay->state = reading_packet; - } else if (relay->state == reading_packet) { - /* read an encapsulated packet and send it as UDP */ -#ifdef DEBUG - log_printf(log_debug, "Received a %u bytes TCP packet", - relay->packet_length); -#endif - - send_udp_packet(relay); - - memmove(relay->buf, relay->packet_start + relay->packet_length, - relay->buf_ptr - - (relay->packet_start + relay->packet_length)); - relay->buf_ptr -= - relay->packet_length + (relay->packet_start - relay->buf); - relay->packet_start = relay->buf; - relay->state = reading_length; - relay->packet_length = sizeof(uint16_t); - } - } -} - -static void send_handshake(struct relay *relay) -{ - if (sendto(relay->tcp_sock, relay->handshake, sizeof(relay->handshake), 0, - (struct sockaddr *) &relay->remote_udpaddr, - sizeof(relay->remote_udpaddr)) < 0) - err_sys("sendto(tcp, handshake)"); -} - -static void wait_for_child(int sig) -{ - while (waitpid(-1, NULL, WNOHANG) > 0); -} - -static void main_loop(struct relay *relay) -{ - time_t last_udp_input, last_tcp_input; - - last_udp_input = relay->udp_timeout ? time(NULL) : 0; - last_tcp_input = relay->tcp_timeout ? time(NULL) : 0; - - while (1) { - int ready_fds; - int max = 0; - fd_set readfds; - struct timeval tv, *ptv; - - FD_ZERO(&readfds); - FD_SET(relay->tcp_sock, &readfds); - SET_MAX(relay->tcp_sock); - FD_SET(relay->udp_sock, &readfds); - SET_MAX(relay->udp_sock); - - /* - * If a data timeout was configured then set a 10s timeout for - * select. - */ - if (last_udp_input || last_tcp_input) { - tv.tv_usec = 0; - tv.tv_sec = 10; - ptv = &tv; - } else { - ptv = NULL; - } - - ready_fds = select(max, &readfds, NULL, NULL, ptv); - if (ready_fds < 0) { - if (errno == EINTR || errno == EAGAIN) - continue; - err_sys("select"); - } - - /* check the timeout if one was configured and select(2) timed out */ - if (last_udp_input && !ready_fds) { /* timeout */ - if (time(NULL) - last_udp_input > relay->udp_timeout) - log_printf_exit(0, log_notice, - "Exiting after a %ds timeout for UDP input", - relay->udp_timeout); - } - if (last_tcp_input && !ready_fds) { /* timeout */ - if (time(NULL) - last_tcp_input > relay->tcp_timeout) - log_printf_exit(0, log_notice, - "Exiting after a %ds timeout for TCP input", - relay->tcp_timeout); - } - - if (FD_ISSET(relay->tcp_sock, &readfds)) { - tcp_to_udp(relay); - if (last_tcp_input) - last_tcp_input = time(NULL); - } - if (FD_ISSET(relay->udp_sock, &readfds)) { - udp_to_tcp(relay); - if (last_udp_input) - last_udp_input = time(NULL); - } - } -} - -int main(int argc, char *argv[]) -{ - struct opts opts; - struct relay relay; - - memset(&relay, 0, sizeof(relay)); - relay.tcp_sock = -1; - - memset(&opts, 0, sizeof(opts)); - parse_args(argc, argv, &opts); - if (opts.handshake) - memcpy(relay.handshake, opts.handshake, sizeof(relay.handshake)); - - sd_notify(0, "READY=1"); - - if (opts.is_server) { - struct sigaction sa; - - sa.sa_handler = wait_for_child; - sigemptyset(&sa.sa_mask); - sa.sa_flags = SA_RESTART; - if (sigaction(SIGCHLD, &sa, NULL) == -1) - err_sys("sigaction"); - - if (opts.timeout) - relay.tcp_timeout = opts.timeout; - relay.expect_handshake = 1; - - if (opts.use_inetd) { - relay.tcp_sock = 0; - log_set_options(log_get_filter_level() | log_syslog); - } else { - int socket_activation_fds = sd_listen_fds(0); - int *listening_sockets; - - if (socket_activation_fds) - listening_sockets = tcp_listener_sa(socket_activation_fds); - else - listening_sockets = tcp_listener(opts.tcpaddr); - relay.tcp_sock = accept_connections(listening_sockets); - } - relay.udp_sock = udp_client(opts.udpaddr, &relay.remote_udpaddr); - } else { - if (opts.timeout) - relay.udp_timeout = opts.timeout; - - if (opts.use_inetd) { - relay.udp_sock = 0; - log_set_options(log_get_filter_level() | log_syslog); - } else { - int socket_activation_fds = sd_listen_fds(0); - - if (socket_activation_fds) - relay.udp_sock = udp_listener_sa(socket_activation_fds); - else - relay.udp_sock = udp_listener(opts.udpaddr); - } - relay.tcp_sock = tcp_client(opts.tcpaddr); - - send_handshake(&relay); - } - - main_loop(&relay); - exit(0); -} - diff --git a/rooter/0optionalapps/udp-tunnel/src/utils.c b/rooter/0optionalapps/udp-tunnel/src/utils.c deleted file mode 100644 index 088ffe8..0000000 --- a/rooter/0optionalapps/udp-tunnel/src/utils.c +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2018 Marco d'Itri - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include - -#include "utils.h" - -void *do_nofail(void *ptr, const char *file, const int line) -{ - if (ptr) - return ptr; - - fprintf(stderr, "Memory allocation failure at %s:%d.", file, line); - exit(1); -} - diff --git a/rooter/0optionalapps/udp-tunnel/src/utils.h b/rooter/0optionalapps/udp-tunnel/src/utils.h deleted file mode 100644 index be91197..0000000 --- a/rooter/0optionalapps/udp-tunnel/src/utils.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2018 Marco d'Itri - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __UTILS_H__ -#define __UTILS_H__ - -#if !defined __GNUC__ && !defined __attribute__ -#define __attribute__(x) /*NOTHING*/ -#endif - -#ifndef AI_IDN -#define AI_IDN 0 -#endif - -#ifndef AI_ADDRCONFIG -#define AI_ADDRCONFIG 0 -#endif - -#ifndef SD_LISTEN_FDS_START -#define SD_LISTEN_FDS_START 0 -#define sd_listen_fds(a) 0 -#define sd_notify(a, b) -#define sd_is_socket(a, b, c, d) -1 -#endif - -#if defined __GLIBC__ || (defined __APPLE__ && defined __MACH__) -#define HAVE_GETOPT_LONG -#endif - -#ifdef HAVE_GETOPT_LONG -#define GETOPT_LONGISH(c, v, o, l, i) getopt_long(c, v, o, l, i) -#else -#define GETOPT_LONGISH(c, v, o, l, i) getopt(c, v, o) -#endif - -#define NOFAIL(ptr) do_nofail((ptr), __FILE__, __LINE__) - -void *do_nofail(void *ptr, const char *file, const int line); - -#endif diff --git a/rooter/0optionalapps/webconsole/Makefile b/rooter/0optionalapps/webconsole/Makefile deleted file mode 100644 index eb8cc4b..0000000 --- a/rooter/0optionalapps/webconsole/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -#Owned by DairyMan@Whirlpool -# -#Copyright GNU act. -include $(TOPDIR)/rules.mk - -PKG_NAME:=webconsole -PKG_VERSION:=1.000 -PKG_RELEASE:=1 - -PKG_MAINTAINER:=Created by DM/makefile by Cobia@whirlpool -include $(INCLUDE_DIR)/package.mk - -define Package/webconsole - SECTION:=utils - CATEGORY:=ROOter - SUBMENU:=Optional Applications - TITLE:=Install scripts for Web Console - PKGARCH:=all -endef - -define Package/webconsole/description - Helper scripts to install scripts for Web Console -endef - - -define Build/Compile -endef - -define Package/webconsole/install - $(CP) ./files/* $(1)/ - - -endef - -$(eval $(call BuildPackage,webconsole)) diff --git a/rooter/0optionalapps/webconsole/files/usr/lib/lua/luci/controller/webconsole.lua b/rooter/0optionalapps/webconsole/files/usr/lib/lua/luci/controller/webconsole.lua deleted file mode 100644 index d65745a..0000000 --- a/rooter/0optionalapps/webconsole/files/usr/lib/lua/luci/controller/webconsole.lua +++ /dev/null @@ -1,31 +0,0 @@ --- A simple web console in case you don't have access to the shell --- --- Hua Shao - -module("luci.controller.webconsole", package.seeall) -local http = require("luci.http") - -I18N = require "luci.i18n" -translate = I18N.translate - -function index() - local multilock = luci.model.uci.cursor():get("custom", "multiuser", "multi") or "0" - local rootlock = luci.model.uci.cursor():get("custom", "multiuser", "root") or "0" - if (multilock == "0") or (multilock == "1" and rootlock == "1") then - entry({"admin", "system", "console"}, template("web/web_console"), _(translate("Web Console")), 66) - end - entry({"admin", "system", "webcmd"}, call("action_webcmd")) -end - -function action_webcmd() - local cmd = http.formvalue("cmd") - if cmd then - local fp = io.popen(tostring(cmd).." 2>&1") - local result = fp:read("*a") - fp:close() - result = result:gsub("<", "<") - http.write(tostring(result)) - else - http.write_json(http.formvalue()) - end -end diff --git a/rooter/0optionalapps/webconsole/files/usr/lib/lua/luci/view/web/web_console.htm b/rooter/0optionalapps/webconsole/files/usr/lib/lua/luci/view/web/web_console.htm deleted file mode 100644 index 682dcad..0000000 --- a/rooter/0optionalapps/webconsole/files/usr/lib/lua/luci/view/web/web_console.htm +++ /dev/null @@ -1,51 +0,0 @@ -<%+header%> - -

                          <%:Web Console%>

                          -
                          -
                          - <%:Execute shell commands or scripts as root.%><%:Be Careful%>. -

                          <%:Press%> Enter <%:to execute. Press%> Shift+Enter <%:to start a new line.%>

                          -

                          -

                          - - - - - - - -

                          
                          -    
                          -
                          - - - -<%+footer%> - diff --git a/rooter/0protocols/luci-proto-3x/Makefile b/rooter/0protocols/luci-proto-3x/Makefile deleted file mode 100644 index a28fb4e..0000000 --- a/rooter/0protocols/luci-proto-3x/Makefile +++ /dev/null @@ -1,62 +0,0 @@ -# -# Copyright (C) 2007-2013 OpenWrt.org -# Copyright (C) 2010 Vertical Communications -# -# This is free software, licensed under the GNU General Public License v2. -# See /LICENSE for more information. -# - -include $(TOPDIR)/rules.mk - -PKG_NAME:=luci-proto-3x -PKG_VERSION:=1.0 -PKG_RELEASE:=1 -PKG_MAINTAINER:=Dairyman -PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE) - -include $(INCLUDE_DIR)/package.mk - -define Package/luci-proto-3x/Default - VERSION:=$(PKG_VERSION)-$(PKG_RELEASE) - URL:=http://openwrt.org/ - MAINTAINER:=Dairyman -endef - -define Package/luci-proto-3x -$(call Package/luci-proto-3x/Default) - SECTION:=net - CATEGORY:=ROOter - SUBMENU:=Protocols - TITLE:=Support for 3x -endef - -define Package/luci-proto-3x/description - This package contains LuCI support for 3x -endef - -define Build/Prepare - mkdir -p $(PKG_BUILD_DIR) -endef - -define Build/Configure -endef - -define Build/Compile/Default -endef - -Build/Compile = $(Build/Compile/Default) - -define Package/luci-proto-3x/install - $(INSTALL_DIR) $(1)/usr - $(INSTALL_DIR) $(1)/usr/lib - $(INSTALL_DIR) $(1)/usr/lib/lua - $(INSTALL_DIR) $(1)/usr/lib/lua/luci - $(INSTALL_DIR) $(1)/usr/lib/lua/luci/model - $(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/network - $(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi - $(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi/admin_network - $(INSTALL_DATA) ./files/usr/lib/lua/luci/model/network/proto_3x.lua $(1)/usr/lib/lua/luci/model/network/ - $(INSTALL_DATA) ./files/usr/lib/lua/luci/model/cbi/admin_network/proto_3x.lua $(1)/usr/lib/lua/luci/model/cbi/admin_network/ -endef - -$(eval $(call BuildPackage,luci-proto-3x)) diff --git a/rooter/0protocols/luci-proto-3x/files/usr/lib/lua/luci/model/cbi/admin_network/proto_3x.lua b/rooter/0protocols/luci-proto-3x/files/usr/lib/lua/luci/model/cbi/admin_network/proto_3x.lua deleted file mode 100644 index 59bf2f6..0000000 --- a/rooter/0protocols/luci-proto-3x/files/usr/lib/lua/luci/model/cbi/admin_network/proto_3x.lua +++ /dev/null @@ -1,146 +0,0 @@ --- Copyright 2011 Jo-Philipp Wich --- Licensed to the public under the Apache License 2.0. - -local map, section, net = ... - -local device, apn, service, pincode, username, password, dialnumber -local ipv6, maxwait, defaultroute, metric, peerdns, dns, - keepalive_failure, keepalive_interval, demand - - -device = section:taboption("general", Value, "device", translate("Modem device")) -device.rmempty = false - -local device_suggestions = nixio.fs.glob("/dev/tty[A-Z]*") - or nixio.fs.glob("/dev/tts/*") - -if device_suggestions then - local node - for node in device_suggestions do - device:value(node) - end -end - - -service = section:taboption("general", Value, "service", translate("Service Type")) -service:value("", translate("-- Please choose --")) -service:value("umts", "UMTS/GPRS") -service:value("umts_only", translate("UMTS only")) -service:value("gprs_only", translate("GPRS only")) -service:value("evdo", "CDMA/EV-DO") - - -apn = section:taboption("general", Value, "apn", translate("APN")) - - -pincode = section:taboption("general", Value, "pincode", translate("PIN")) - - -username = section:taboption("general", Value, "username", translate("PAP/CHAP username")) - - -password = section:taboption("general", Value, "password", translate("PAP/CHAP password")) -password.password = true - -dialnumber = section:taboption("general", Value, "dialnumber", translate("Dial number")) -dialnumber.placeholder = "*99***1#" - -if luci.model.network:has_ipv6() then - - ipv6 = section:taboption("advanced", Flag, "ipv6", - translate("Enable IPv6 negotiation on the PPP link")) - - ipv6.default = ipv6.disabled - -end - - -maxwait = section:taboption("advanced", Value, "maxwait", - translate("Modem init timeout"), - translate("Maximum amount of seconds to wait for the modem to become ready")) - -maxwait.placeholder = "20" -maxwait.datatype = "min(1)" - - -defaultroute = section:taboption("advanced", Flag, "defaultroute", - translate("Use default gateway"), - translate("If unchecked, no default route is configured")) - -defaultroute.default = defaultroute.enabled - - -metric = section:taboption("advanced", Value, "metric", - translate("Use gateway metric")) - -metric.placeholder = "0" -metric.datatype = "uinteger" -metric:depends("defaultroute", defaultroute.enabled) - - -peerdns = section:taboption("advanced", Flag, "peerdns", - translate("Use DNS servers advertised by peer"), - translate("If unchecked, the advertised DNS server addresses are ignored")) - -peerdns.default = peerdns.enabled - - -dns = section:taboption("advanced", DynamicList, "dns", - translate("Use custom DNS servers")) - -dns:depends("peerdns", "") -dns.datatype = "ipaddr" -dns.cast = "string" - - -keepalive_failure = section:taboption("advanced", Value, "_keepalive_failure", - translate("LCP echo failure threshold"), - translate("Presume peer to be dead after given amount of LCP echo failures, use 0 to ignore failures")) - -function keepalive_failure.cfgvalue(self, section) - local v = m:get(section, "keepalive") - if v and #v > 0 then - return tonumber(v:match("^(%d+)[ ,]+%d+") or v) - end -end - -function keepalive_failure.write() end -function keepalive_failure.remove() end - -keepalive_failure.placeholder = "0" -keepalive_failure.datatype = "uinteger" - - -keepalive_interval = section:taboption("advanced", Value, "_keepalive_interval", - translate("LCP echo interval"), - translate("Send LCP echo requests at the given interval in seconds, only effective in conjunction with failure threshold")) - -function keepalive_interval.cfgvalue(self, section) - local v = m:get(section, "keepalive") - if v and #v > 0 then - return tonumber(v:match("^%d+[ ,]+(%d+)")) - end -end - -function keepalive_interval.write(self, section, value) - local f = tonumber(keepalive_failure:formvalue(section)) or 0 - local i = tonumber(value) or 5 - if i < 1 then i = 1 end - if f > 0 then - m:set(section, "keepalive", "%d %d" %{ f, i }) - else - m:del(section, "keepalive") - end -end - -keepalive_interval.remove = keepalive_interval.write -keepalive_interval.placeholder = "5" -keepalive_interval.datatype = "min(1)" - - -demand = section:taboption("advanced", Value, "demand", - translate("Inactivity timeout"), - translate("Close inactive connection after the given amount of seconds, use 0 to persist connection")) - -demand.placeholder = "0" -demand.datatype = "uinteger" diff --git a/rooter/0protocols/luci-proto-3x/files/usr/lib/lua/luci/model/network/proto_3x.lua b/rooter/0protocols/luci-proto-3x/files/usr/lib/lua/luci/model/network/proto_3x.lua deleted file mode 100644 index 9795a7c..0000000 --- a/rooter/0protocols/luci-proto-3x/files/usr/lib/lua/luci/model/network/proto_3x.lua +++ /dev/null @@ -1,68 +0,0 @@ ---[[ -LuCI - Network model - 3G, PPP, PPtP, PPPoE and PPPoA protocol extension - -Copyright 2011 Jo-Philipp Wich - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -]]-- - -local netmod = luci.model.network - -local _, p -for _, p in ipairs({"3x"}) do - - local proto = netmod:register_protocol(p) - - function proto.get_i18n(self) - return luci.i18n.translate("UMTS/GPRS/EV-DO") - end - - function proto.ifname(self) - return p .. "-" .. self.sid - end - - function proto.opkg_package(self) - return "comgt" - end - - function proto.is_installed(self) - return nixio.fs.access("/lib/netifd/proto/3x.sh") - end - - function proto.is_floating(self) - return (p ~= "pppoe") - end - - function proto.is_virtual(self) - return true - end - - function proto.get_interfaces(self) - if self:is_floating() then - return nil - else - return netmod.protocol.get_interfaces(self) - end - end - - function proto.contains_interface(self, ifc) - if self:is_floating() then - return (netmod:ifnameof(ifc) == self:ifname()) - else - return netmod.protocol.contains_interface(self, ifc) - end - end - - netmod:register_pattern_virtual("^%s-%%w" % p) -end \ No newline at end of file diff --git a/rooter/0protocols/luci-proto-mbim/Makefile b/rooter/0protocols/luci-proto-mbim/Makefile deleted file mode 100644 index ca3441c..0000000 --- a/rooter/0protocols/luci-proto-mbim/Makefile +++ /dev/null @@ -1,62 +0,0 @@ -# -# Copyright (C) 2007-2013 OpenWrt.org -# Copyright (C) 2010 Vertical Communications -# -# This is free software, licensed under the GNU General Public License v2. -# See /LICENSE for more information. -# - -include $(TOPDIR)/rules.mk - -PKG_NAME:=luci-proto-mbim -PKG_VERSION:=1.0 -PKG_RELEASE:=1 -PKG_MAINTAINER:=Dairyman -PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE) - -include $(INCLUDE_DIR)/package.mk - -define Package/luci-proto-mbim/Default - VERSION:=$(PKG_VERSION)-$(PKG_RELEASE) - URL:=http://openwrt.org/ - MAINTAINER:=Dairyman -endef - -define Package/luci-proto-mbim -$(call Package/luci-proto-mbim/Default) - SECTION:=net - CATEGORY:=ROOter - SUBMENU:=Protocols - TITLE:=Support for mbim -endef - -define Package/luci-proto-mbim/description - This package contains LuCI support for mbim -endef - -define Build/Prepare - mkdir -p $(PKG_BUILD_DIR) -endef - -define Build/Configure -endef - -define Build/Compile/Default -endef - -Build/Compile = $(Build/Compile/Default) - -define Package/luci-proto-mbim/install - $(INSTALL_DIR) $(1)/usr - $(INSTALL_DIR) $(1)/usr/lib - $(INSTALL_DIR) $(1)/usr/lib/lua - $(INSTALL_DIR) $(1)/usr/lib/lua/luci - $(INSTALL_DIR) $(1)/usr/lib/lua/luci/model - $(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/network - $(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi - $(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi/admin_network - $(INSTALL_DATA) ./files/usr/lib/lua/luci/model/network/proto_mbim.lua $(1)/usr/lib/lua/luci/model/network/ - $(INSTALL_DATA) ./files/usr/lib/lua/luci/model/cbi/admin_network/proto_mbim.lua $(1)/usr/lib/lua/luci/model/cbi/admin_network/ -endef - -$(eval $(call BuildPackage,luci-proto-mbim)) diff --git a/rooter/0protocols/luci-proto-mbim/files/usr/lib/lua/luci/model/cbi/admin_network/proto_mbim.lua b/rooter/0protocols/luci-proto-mbim/files/usr/lib/lua/luci/model/cbi/admin_network/proto_mbim.lua deleted file mode 100644 index 380f471..0000000 --- a/rooter/0protocols/luci-proto-mbim/files/usr/lib/lua/luci/model/cbi/admin_network/proto_mbim.lua +++ /dev/null @@ -1,45 +0,0 @@ --- Copyright 2016 David Thornley --- Licensed to the public under the Apache License 2.0. - -local map, section, net = ... - -local device, apn, pincode, username, password -local auth, ipv6 - - -device = section:taboption("general", Value, "device", translate("Modem device")) -device.rmempty = false - -local device_suggestions = nixio.fs.glob("/dev/cdc-wdm*") - -if device_suggestions then - local node - for node in device_suggestions do - device:value(node) - end -end - - -apn = section:taboption("general", Value, "apn", translate("APN")) - - -pincode = section:taboption("general", Value, "pincode", translate("PIN")) - - -username = section:taboption("general", Value, "username", translate("PAP/CHAP username")) - - -password = section:taboption("general", Value, "password", translate("PAP/CHAP password")) -password.password = true - -auth = section:taboption("general", Value, "auth", translate("Authentication Type")) -auth:value("", translate("-- Please choose --")) -auth:value("both", "PAP/CHAP (both)") -auth:value("pap", "PAP") -auth:value("chap", "CHAP") -auth:value("none", "NONE") - -if luci.model.network:has_ipv6() then - ipv6 = section:taboption("advanced", Flag, "ipv6", translate("Enable IPv6 negotiation")) - ipv6.default = ipv6.disabled -end \ No newline at end of file diff --git a/rooter/0protocols/luci-proto-mbim/files/usr/lib/lua/luci/model/network/proto_mbim.lua b/rooter/0protocols/luci-proto-mbim/files/usr/lib/lua/luci/model/network/proto_mbim.lua deleted file mode 100644 index 2cc525a..0000000 --- a/rooter/0protocols/luci-proto-mbim/files/usr/lib/lua/luci/model/network/proto_mbim.lua +++ /dev/null @@ -1,51 +0,0 @@ --- Copyright 2016 David Thornley --- Licensed to the public under the Apache License 2.0. - -local netmod = luci.model.network -local interface = luci.model.network.interface -local proto = netmod:register_protocol("mbim") - -function proto.get_i18n(self) - return luci.i18n.translate("MBIM") -end - -function proto.ifname(self) - local base = netmod._M.protocol - local ifname = base.ifname(self) -- call base class "protocol.ifname(self)" - - -- Note: ifname might be nil if the adapter could not be determined through ubus (default name to qmi-wan in this case) - if ifname == nil then - ifname = "mbim-" .. self.sid - end - return ifname -end - -function proto.get_interface(self) - return interface(self:ifname(), self) -end - -function proto.opkg_package(self) - return "rmbim" -end - -function proto.is_installed(self) - return nixio.fs.access("/lib/netifd/proto/mbim.sh") -end - -function proto.is_floating(self) - return true -end - -function proto.is_virtual(self) - return true -end - -function proto.get_interfaces(self) - return nil -end - -function proto.contains_interface(self, ifc) - return (netmod:ifnameof(ifc) == self:ifname()) -end - -netmod:register_pattern_virtual("^mbim-%w") \ No newline at end of file diff --git a/rooter/0routerspecfic/rd05a1/Makefile b/rooter/0routerspecfic/rd05a1/Makefile deleted file mode 100644 index c303d11..0000000 --- a/rooter/0routerspecfic/rd05a1/Makefile +++ /dev/null @@ -1,37 +0,0 @@ -#Owned by DairyMan@Whirlpool -# -#Copyright GNU act. -include $(TOPDIR)/rules.mk - -PKG_NAME:=rd05a1 -PKG_VERSION:=1.000 -PKG_RELEASE:=1 - -PKG_MAINTAINER:=Created by DM/makefile by Cobia@whirlpool -include $(INCLUDE_DIR)/package.mk - -define Package/rd05a1 - SECTION:=utils - CATEGORY:=ROOter - SUBMENU:=Router Specific - DEPENDS:=+ath9k-htc-firmware +kmod-ath10k \ - +kmod-ath9k-htc - TITLE:=Install scripts for RD05A1 - PKGARCH:=all -endef - -define Package/rd05a1/description - Helper scripts to install scripts for RD05A1 -endef - - -define Build/Compile -endef - -define Package/rd05a1/install - $(CP) ./files/* $(1)/ - - -endef - -$(eval $(call BuildPackage,rd05a1)) diff --git a/rooter/0routerspecfic/rd05a1/files/etc/init.d/pciepwr b/rooter/0routerspecfic/rd05a1/files/etc/init.d/pciepwr deleted file mode 100644 index f77fa81..0000000 --- a/rooter/0routerspecfic/rd05a1/files/etc/init.d/pciepwr +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh /etc/rc.common -# Copyright (C) 2013 OpenWrt.org - -START=87 -USE_PROCD=1 - -log() { - logger -t "RD05A1 PCie Power" "$@" -} - -start_service() -{ - gpio=13 - echo $gpio > /sys/class/gpio/export - echo out > /sys/class/gpio/gpio${gpio}/direction - echo 1 > /sys/class/gpio/gpio${gpio}/value - log "Turn on PCie Power" -} diff --git a/rooter/0routerspecfic/rd05a1/files/lib/firmware/ath10k/QCA9887/hw1.0/board.bin b/rooter/0routerspecfic/rd05a1/files/lib/firmware/ath10k/QCA9887/hw1.0/board.bin deleted file mode 100644 index 9ef7e7b..0000000 Binary files a/rooter/0routerspecfic/rd05a1/files/lib/firmware/ath10k/QCA9887/hw1.0/board.bin and /dev/null differ diff --git a/rooter/0routerspecfic/rd05a1/files/lib/firmware/ath10k/QCA9887/hw1.0/firmware-5.bin b/rooter/0routerspecfic/rd05a1/files/lib/firmware/ath10k/QCA9887/hw1.0/firmware-5.bin deleted file mode 100644 index 2109698..0000000 Binary files a/rooter/0routerspecfic/rd05a1/files/lib/firmware/ath10k/QCA9887/hw1.0/firmware-5.bin and /dev/null differ diff --git a/rooter/0routerspecfic/rd05a1/files/lib/firmware/ath10k/cal-pci-0000_00_00.0.bin b/rooter/0routerspecfic/rd05a1/files/lib/firmware/ath10k/cal-pci-0000_00_00.0.bin deleted file mode 100644 index 4588a06..0000000 Binary files a/rooter/0routerspecfic/rd05a1/files/lib/firmware/ath10k/cal-pci-0000_00_00.0.bin and /dev/null differ diff --git a/rooter/0routerspecfic/we826q/Makefile b/rooter/0routerspecfic/we826q/Makefile deleted file mode 100644 index 36779cd..0000000 --- a/rooter/0routerspecfic/we826q/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -#Owned by DairyMan@Whirlpool -# -#Copyright GNU act. -include $(TOPDIR)/rules.mk - -PKG_NAME:=we826q -PKG_VERSION:=1.000 -PKG_RELEASE:=1 - -PKG_MAINTAINER:=Created by DM/makefile by Cobia@whirlpool -include $(INCLUDE_DIR)/package.mk - -define Package/we826q - SECTION:=utils - CATEGORY:=ROOter - SUBMENU:=Router Specific - TITLE:=Install scripts for WE826-Q - PKGARCH:=all -endef - -define Package/we826q/description - Helper scripts to install scripts for WE826-Q -endef - - -define Build/Compile -endef - -define Package/we826q/install - $(CP) ./files/* $(1)/ - - -endef - -$(eval $(call BuildPackage,we826q)) diff --git a/rooter/0routerspecfic/we826q/files/etc/init.d/wd-init b/rooter/0routerspecfic/we826q/files/etc/init.d/wd-init deleted file mode 100644 index fde562a..0000000 --- a/rooter/0routerspecfic/we826q/files/etc/init.d/wd-init +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh /etc/rc.common -# Copyright (C) 2013 OpenWrt.org - -START=20 -USE_PROCD=1 - -log() { - logger -t "usb-modeswitch" "$@" -} - -start_service() -{ - /usr/lib/custom/watchdog.sh & -} diff --git a/rooter/0routerspecfic/we826q/files/usr/lib/custom/watchdog.sh b/rooter/0routerspecfic/we826q/files/usr/lib/custom/watchdog.sh deleted file mode 100644 index 281cd4a..0000000 --- a/rooter/0routerspecfic/we826q/files/usr/lib/custom/watchdog.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh - -#for example WE825-Q watchdog gpio is 2 -wd_gpio="2" - -echo $wd_gpio > /sys/class/gpio/export -echo out > /sys/class/gpio/gpio$wd_gpio/direction - -while [ 1 ] -do - echo 1 >/sys/class/gpio/gpio$wd_gpio/value - sleep 1 - echo 0 >/sys/class/gpio/gpio$wd_gpio/value - sleep 1 - - echo 1 >/sys/class/gpio/gpio$wd_gpio/value - sleep 1 - echo 0 >/sys/class/gpio/gpio$wd_gpio/value - sleep 1 - - echo 1 >/sys/class/gpio/gpio$wd_gpio/value - sleep 1 - echo 0 >/sys/class/gpio/gpio$wd_gpio/value - sleep 1 -done diff --git a/rooter/0routerspecfic/we826q/files/usr/lib/rooter/changedevice.sh b/rooter/0routerspecfic/we826q/files/usr/lib/rooter/changedevice.sh deleted file mode 100644 index 507c479..0000000 --- a/rooter/0routerspecfic/we826q/files/usr/lib/rooter/changedevice.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -log() { - logger -t "Change Device" "$@" -} - -uci set system.led_wan.dev=$1 -uci commit system -/etc/init.d/led restart \ No newline at end of file diff --git a/rooter/0splash/ext-splash/Makefile b/rooter/0splash/ext-splash/Makefile deleted file mode 100644 index 8372994..0000000 --- a/rooter/0splash/ext-splash/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -#Owned by DairyMan@Whirlpool -# -#Copyright GNU act. -include $(TOPDIR)/rules.mk - -PKG_NAME:=ext-splash -PKG_VERSION:=1.000 -PKG_RELEASE:=1 - -PKG_MAINTAINER:=Created by DM/makefile by Cobia@whirlpool -include $(INCLUDE_DIR)/package.mk - -define Package/ext-splash - SECTION:=utils - CATEGORY:=ROOter - SUBMENU:=Splash Screens - TITLE:=Added scripts for Login display - PKGARCH:=all -endef - -define Package/ext-splash/description - Added scripts for Login display -endef - - -define Build/Compile -endef - -define Package/ext-splash/install - $(CP) ./files/* $(1)/ - - -endef - -$(eval $(call BuildPackage,ext-splash)) diff --git a/rooter/0splash/ext-splash/files/etc/config/iframe b/rooter/0splash/ext-splash/files/etc/config/iframe deleted file mode 100644 index a97bc1d..0000000 --- a/rooter/0splash/ext-splash/files/etc/config/iframe +++ /dev/null @@ -1,17 +0,0 @@ - -config iframe 'iframe' - option splashpage '0' - option splashtitle 'ROOter' - option url 'www.ofmodemsandmen.com' - option dual '0' - option speed '0' - option band '0' - -config login 'login' - option logframe '0' - option logtype '3' - option logimage 'open.png' - option logimageheight '300' - option logimagewidth '300' - option logimagepos 'absmiddle' - diff --git a/rooter/0splash/ext-splash/files/etc/init.d/iframeint b/rooter/0splash/ext-splash/files/etc/init.d/iframeint deleted file mode 100644 index 79f6de6..0000000 --- a/rooter/0splash/ext-splash/files/etc/init.d/iframeint +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh /etc/rc.common -# Copyright (C) 2013 OpenWrt.org - -START=60 -USE_PROCD=1 - -log() { - logger -t "iframe" "$@" -} - -start_service() -{ - if [ ! -d /tmp/www ]; then - mkdir -p /tmp/www - fi - /usr/lib/iframe/create.sh & - /usr/lib/iframe/status.sh & -} diff --git a/rooter/0splash/ext-splash/files/usr/lib/iframe/band.html b/rooter/0splash/ext-splash/files/usr/lib/iframe/band.html deleted file mode 100644 index 9db882d..0000000 --- a/rooter/0splash/ext-splash/files/usr/lib/iframe/band.html +++ /dev/null @@ -1 +0,0 @@ -
                          Bandwidth Usage
                          \ No newline at end of file diff --git a/rooter/0splash/ext-splash/files/usr/lib/iframe/bwdays.sh b/rooter/0splash/ext-splash/files/usr/lib/iframe/bwdays.sh deleted file mode 100644 index 1c5a776..0000000 --- a/rooter/0splash/ext-splash/files/usr/lib/iframe/bwdays.sh +++ /dev/null @@ -1,109 +0,0 @@ -#!/bin/sh -. /lib/functions.sh - -genline() { - MONLIST=$MONLIST"" - t1="
                          $START
                          " - t2="
                          $updata
                          " - t3="
                          $downdata
                          " - t4="
                          $totaldata
                          " - MONLIST=$MONLIST$t1$t2$t3$t4"" -} - -bwdata() { - START="-" - END="-" - header=0 - while IFS= read -r line; do - if [ $header -eq 0 ]; then - days=$line - read -r line - DOWN=$line - read -r line - UP=$line - read -r line - TOTAL=$line - read -r line - line=$(echo $line" " | tr "|" ",") - END=$(echo $line | cut -d, -f1) - START=$END - updata=$(echo $line | cut -d, -f2) - downdata=$(echo $line | cut -d, -f3) - totaldata=$(echo $line | cut -d, -f4) - genline - read -r line - header=1 - if [ -z "$line" ]; then - break - fi - fi - line=$(echo $line" " | tr "|" ",") - START=$(echo $line | cut -d, -f1) - updata=$(echo $line | cut -d, -f2) - downdata=$(echo $line | cut -d, -f3) - totaldata=$(echo $line | cut -d, -f4) - genline - - done < /usr/lib/bwmon/data/monthly.data -} - -currdata() { - while IFS= read -r line; do - if [ $line = '0' ]; then - break - else - cdays=$line - read -r line - read -r line - ctused=$line - read -r line - read -r line - ctdwn=$line - read -r line - read -r line - ctup=$line - read -r line - read -r line - cproject=$line - break - fi - done < /tmp/bwdata -} - - STEMP="/tmp/www/dtemp.html" - STATUS="/usr/lib/iframe/bwtemplate.html" - IFSTATUS="/tmp/www/daylist.html" - - MONLIST="" - - rm -f $STEMP - cp $STATUS $STEMP - if [ -e /usr/lib/bwmon/data/monthly.data ]; then - #MONLIST="" - bwdata - MONLIST=$MONLIST"
                          " - else - START="-" - END="-" - TOTAL="-" - DOWN="-" - UP="-" - fi - - currdata - - sed -i -e "s!#START#!$START!g" $STEMP - sed -i -e "s!#END#!$END!g" $STEMP - sed -i -e "s!#TOTAL#!$TOTAL!g" $STEMP - sed -i -e "s!#DOWN#!$DOWN!g" $STEMP - sed -i -e "s!#UP#!$UP!g" $STEMP - sed -i -e "s!#MONLIST#!$MONLIST!g" $STEMP - - sed -i -e "s!#CDAYS#!$cdays!g" $STEMP - sed -i -e "s!#CTOTAL#!$ctused!g" $STEMP - sed -i -e "s!#CDOWN#!$ctdwn!g" $STEMP - sed -i -e "s!#CUP#!$ctup!g" $STEMP - sed -i -e "s!#PROJECT#!$cproject!g" $STEMP - - mv $STEMP $IFSTATUS - diff --git a/rooter/0splash/ext-splash/files/usr/lib/iframe/bwtemplate.html b/rooter/0splash/ext-splash/files/usr/lib/iframe/bwtemplate.html deleted file mode 100644 index 81b6ec9..0000000 --- a/rooter/0splash/ext-splash/files/usr/lib/iframe/bwtemplate.html +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - - - - -

                          Current Month's Bandwidth Usage

                          -
                          -
                          -
                          -
                          Days
                          - #CDAYS# -
                          -
                          -
                          Total Amount Used
                          - #CTOTAL# -
                          -
                          -
                          -
                          -
                          Downloaded
                          - #CDOWN# -
                          -
                          -
                          Uploaded
                          - #CUP# -
                          -
                          -
                          Projected Amount
                          - #PROJECT# -
                          -
                          -
                          - -

                          Last 30 Day Bandwidth Usage

                          - - -
                          -
                          -
                          -
                          Starting Date
                          - #START# -
                          -
                          -
                          Ending Date
                          - #END# -
                          -
                          -
                          -
                          -
                          Total
                          - #TOTAL# -
                          -
                          -
                          Download
                          - #DOWN# -
                          -
                          -
                          Upload
                          - #UP# -
                          -
                          -
                          - -
                          - - - - - - - - - #MONLIST# - - - diff --git a/rooter/0splash/ext-splash/files/usr/lib/iframe/create.sh b/rooter/0splash/ext-splash/files/usr/lib/iframe/create.sh deleted file mode 100644 index 5a292e5..0000000 --- a/rooter/0splash/ext-splash/files/usr/lib/iframe/create.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh -. /lib/functions.sh - -bwdata() { - result=`ps | grep -i "create_data.lua" | grep -v "grep" | wc -l` - if [ $result -lt 1 ]; then - lua /usr/lib/bwmon/create_data.lua - fi - while [ true ] - do - if [ -e /tmp/bwdata ]; then - break - fi - sleep 1 - done -} - -bwdata -/usr/lib/iframe/update.sh -logtype=$(uci -q get iframe.login.logtype) -if [ $logtype = "1" ]; then - sleep 300 - while [ true ] - do - result=`ps | grep -i "update.sh" | grep -v "grep" | wc -l` - if [ $result -lt 1 ]; then - /usr/lib/iframe/update.sh - fi - sleep 300 - done -fi \ No newline at end of file diff --git a/rooter/0splash/ext-splash/files/usr/lib/iframe/daylist.html b/rooter/0splash/ext-splash/files/usr/lib/iframe/daylist.html deleted file mode 100644 index ba5170d..0000000 --- a/rooter/0splash/ext-splash/files/usr/lib/iframe/daylist.html +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - - - - -

                          Current Month's Bandwidth Usage

                          -
                          -
                          -
                          -
                          Days
                          - 10 -
                          -
                          -
                          Total Amount Used
                          - 451.39 MB -
                          -
                          -
                          -
                          -
                          Downloaded
                          - 409.57 MB -
                          -
                          -
                          Uploaded
                          - 41.82 MB -
                          -
                          -
                          Projected Amount
                          - 1.35 GB -
                          -
                          -
                          - -

                          Last 30 Day Bandwidth Usage

                          - - -
                          -
                          -
                          -
                          Starting Date
                          - 2022-01-03 -
                          -
                          -
                          Ending Date
                          - 2022-01-15 -
                          -
                          -
                          -
                          -
                          Total
                          - 360.05 MB -
                          -
                          -
                          Download
                          - 322.79 MB -
                          -
                          -
                          Upload
                          - 37.25 MB -
                          -
                          -
                          - -
                          -
                          DATE
                          DOWN
                          UP
                          TOTAL
                          - - - - - - - -
                          DATE
                          DOWN
                          UP
                          TOTAL
                          2022-01-15
                          0.00 K
                          0.00 K
                          0.00 K
                          2022-01-14
                          0.00 K
                          0.00 K
                          0.00 K
                          2022-01-13
                          41.87 MB
                          1.71 MB
                          43.58 MB
                          2022-01-12
                          0.00 K
                          0.00 K
                          0.00 K
                          2022-01-07
                          18.56 MB
                          5.24 MB
                          23.80 MB
                          2022-01-06
                          175.59 MB
                          25.72 MB
                          201.32 MB
                          2022-01-04
                          56.19 MB
                          3.59 MB
                          59.78 MB
                          2022-01-03
                          30.58 MB
                          986.00 K
                          31.57 MB
                          -
                          - - diff --git a/rooter/0splash/ext-splash/files/usr/lib/iframe/iframe.html b/rooter/0splash/ext-splash/files/usr/lib/iframe/iframe.html deleted file mode 100644 index aa47d93..0000000 --- a/rooter/0splash/ext-splash/files/usr/lib/iframe/iframe.html +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - -

                          #TITLE#

                          - -
                          -
                          -
                          -
                          Reporting Period (Days)
                          - #DAYS# -
                          -
                          -
                          -
                          -
                          Total Bandwidth Used
                          - #TOTAL# -
                          -
                          -
                          Projected Use
                          - #PROJ# -
                          -
                          -
                          -
                          -
                          Total Downloaded
                          - #DOWN# -
                          -
                          -
                          Total Uploaded
                          - #UP# -
                          -
                          -
                          - - diff --git a/rooter/0splash/ext-splash/files/usr/lib/iframe/image.html b/rooter/0splash/ext-splash/files/usr/lib/iframe/image.html deleted file mode 100644 index a7b9893..0000000 --- a/rooter/0splash/ext-splash/files/usr/lib/iframe/image.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - -

                           

                          -

                          - - diff --git a/rooter/0splash/ext-splash/files/usr/lib/iframe/mframe.html b/rooter/0splash/ext-splash/files/usr/lib/iframe/mframe.html deleted file mode 100644 index 589c857..0000000 --- a/rooter/0splash/ext-splash/files/usr/lib/iframe/mframe.html +++ /dev/null @@ -1,111 +0,0 @@ - - - - - - - - - - -
                          -

                          Modem 1

                          -
                          -
                          -
                          Strength (%)
                          - #PER# -
                          -
                          -
                          CSQ
                          - #CSQ# -
                          -
                          -
                          RSSI (dBm)
                          - #RSSI# -
                          -
                          -
                          RSCP (dBm) RSRP
                          - #RSCP# -
                          -
                          -
                          ECIO (dB) RSRQ
                          - #RSRQ# -
                          -
                          -
                          SINR (dB)
                          - #SINR# -
                          -
                          - -
                          -

                          Network

                          - -
                          -
                          -
                          Mode
                          - #MODE# -
                          -
                          -
                          MCC
                          - #MCC# -
                          -
                          -
                          MNC
                          - #MNC# -
                          -
                          -
                          RNC/eNB ID
                          - #RNC# #RNCN# -
                          - -
                          -
                          LAC
                          - #LAC# #LACN# -
                          -
                          -
                          Channel (EARFCN)
                          - #CHAN# -
                          -
                          -
                          PCI
                          - #CELLID# -
                          -
                          -
                          Bands
                          - #BAND# -
                          -
                          -
                          -
                          -

                          Device

                          - -
                          -
                          -
                          Router
                          - #ROUTER# -
                          -
                          -
                          Modem
                          - #MODEM# -
                          -
                          -
                          Provider
                          - #PROVIDER# -
                          -
                          -
                          Protocol
                          - #PROTO# -
                          -
                          -
                          Port
                          - #PORT# -
                          -
                          -
                          Temperature
                          - #TEMP# -
                          -
                          -
                          -
                          - - diff --git a/rooter/0splash/ext-splash/files/usr/lib/iframe/modem2.html b/rooter/0splash/ext-splash/files/usr/lib/iframe/modem2.html deleted file mode 100644 index 5957a8b..0000000 --- a/rooter/0splash/ext-splash/files/usr/lib/iframe/modem2.html +++ /dev/null @@ -1 +0,0 @@ -

                          Modem 2

                          Strength (%)
                          #PER#
                          CSQ
                          #CSQ#
                          RSSI (dBm)
                          #RSSI#
                          RSCP (dBm) RSRP
                          #RSCP#
                          ECIO (dB) RSRQ
                          #RSRQ#
                          SINR (dB)
                          #SINR#

                          Network

                          Mode
                          #MODE#
                          MCC
                          #MCC#
                          MNC
                          #MNC#
                          RNC/eNB ID
                          #RNC# #RNCN#
                          LAC
                          #LAC# #LACN#
                          Channel (EARFCN)
                          #CHAN#
                          PCI
                          #CELLID#
                          Bands
                          #BAND#

                          Device

                          Modem
                          #MODEM#
                          Provider
                          #MODEMN#
                          Protocol
                          #PROTO#
                          Port
                          #PORT#
                          Temperature
                          #TEMP#
                          \ No newline at end of file diff --git a/rooter/0splash/ext-splash/files/usr/lib/iframe/open.html b/rooter/0splash/ext-splash/files/usr/lib/iframe/open.html deleted file mode 100644 index fa7d40d..0000000 --- a/rooter/0splash/ext-splash/files/usr/lib/iframe/open.html +++ /dev/null @@ -1 +0,0 @@ -
                          OpenSpeedTest
                          \ No newline at end of file diff --git a/rooter/0splash/ext-splash/files/usr/lib/iframe/speed.html b/rooter/0splash/ext-splash/files/usr/lib/iframe/speed.html deleted file mode 100644 index 0338c71..0000000 --- a/rooter/0splash/ext-splash/files/usr/lib/iframe/speed.html +++ /dev/null @@ -1,114 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

                          OpenSpeedTest

                          - -
                          - -
                          - -
                          - - - - diff --git a/rooter/0splash/ext-splash/files/usr/lib/iframe/status.html b/rooter/0splash/ext-splash/files/usr/lib/iframe/status.html deleted file mode 100644 index 7c7c33d..0000000 --- a/rooter/0splash/ext-splash/files/usr/lib/iframe/status.html +++ /dev/null @@ -1,154 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - #TITLEBAR# - #BUTTON# -
                          -

                          Modem 1

                          -
                          -
                          -
                          Strength (%)
                          - #PER# -
                          -
                          -
                          CSQ
                          - #CSQ# -
                          -
                          -
                          RSSI (dBm)
                          - #RSSI# -
                          -
                          -
                          RSCP (dBm) RSRP
                          - #RSCP# -
                          -
                          -
                          ECIO (dB) RSRQ
                          - #RSRQ# -
                          -
                          -
                          SINR (dB)
                          - #SINR# -
                          -
                          - -
                          -

                          Network

                          - -
                          -
                          -
                          Mode
                          - #MODE# -
                          -
                          -
                          MCC
                          - #MCC# -
                          -
                          -
                          MNC
                          - #MNC# -
                          -
                          -
                          RNC/eNB ID
                          - #RNC# #RNCN# -
                          - -
                          -
                          LAC
                          - #LAC# #LACN# -
                          -
                          -
                          Channel (EARFCN)
                          - #CHAN# -
                          -
                          -
                          PCI
                          - #CELLID# -
                          -
                          -
                          Bands
                          - #BAND# -
                          -
                          -
                          -
                          -

                          Device

                          - -
                          -
                          -
                          Router
                          - #ROUTER# -
                          -
                          -
                          Modem
                          - #MODEM# -
                          -
                          -
                          Provider
                          - #PROVIDER# -
                          -
                          -
                          Protocol
                          - #PROTO# -
                          -
                          -
                          Port
                          - #PORT# -
                          -
                          -
                          Temperature
                          - #TEMP# -
                          -
                          -
                          External IP
                          - #EXTERNAL# -
                          -
                          -
                          - #MODEM2# -
                          - - - #OPEN# - - #BWMON# - - - diff --git a/rooter/0splash/ext-splash/files/usr/lib/iframe/status.sh b/rooter/0splash/ext-splash/files/usr/lib/iframe/status.sh deleted file mode 100644 index ed0881b..0000000 --- a/rooter/0splash/ext-splash/files/usr/lib/iframe/status.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -/usr/lib/rooter/signal/status.sh 1 "No Modem Present" - -while [ true ] -do - result=`ps | grep -i "stupdate.sh" | grep -v "grep" | wc -l` - if [ $result -lt 1 ]; then - /usr/lib/iframe/stupdate.sh - /usr/lib/iframe/bwdays.sh - fi - splash=$(uci -q get iframe.iframe.splashpage) - if [ $splash = "1" ]; then - mv /www/splash_files/check1.gif /www/splash_files/check.gif - ln -s /tmp/www/splash.html /www/splash.html - else - mv /www/splash_files/check.gif /www/splash_files/check1.gif - rm -f /www/splash.html - fi - sleep 10 -done \ No newline at end of file diff --git a/rooter/0splash/ext-splash/files/usr/lib/iframe/stupdate.sh b/rooter/0splash/ext-splash/files/usr/lib/iframe/stupdate.sh deleted file mode 100644 index 656a8f2..0000000 --- a/rooter/0splash/ext-splash/files/usr/lib/iframe/stupdate.sh +++ /dev/null @@ -1,404 +0,0 @@ -#!/bin/sh -. /lib/functions.sh - -log() { - logger -t "Status Update" "$@" -} - -levelsper="101,85,70,55,40,25,0" -namesper="Perfect,Excellent,Good,Medium,Low,Bad,Dead" -levelsrssi="1,70,90,100,119,113,0" -namesrssi="Perfect,High,Medium,Poor,Bad,None" -levelsrscp="50,70,90,100,112,136,140,0" -namesrscp='High (3G) :High (4G),Medium (3G) : High (4G),Poor (3G) : Good (4G),Weak (3G) : Medium (4G),None (3G) : Poor (4G)' - -level2txt() { - tmp="$1" - key=$2 - front="" - tmp1="$tmp"" " - if [ "$tmp" = "-" ]; then - namev="""--""" - return - fi - if [ $key = "per" ]; then - tmp=$(echo "$tmp" | sed -e "s/%//g") - level=$levelsper - namev=$namesper - namez=$namev - cindex=1 - nindex=0 - namev="-" - while [ true ] - do - levelv=$(echo "$level" | cut -d, -f$cindex) - if [ $levelv = "0" ]; then - namev="-" - break - fi - if [ "$tmp" -ge "$levelv" ]; then - nind=$((${nindex}+1)) - namev=$(echo "$namez" | cut -d, -f$nind) - break - fi - cindex=$((${cindex}+1)) - nindex=$((${nindex}+1)) - done - css="level_"$nindex - desc="
                          "$namev"
                          " - namev="""$front$tmp1"""$desc - return - fi - if [ $key = "rssi" ]; then - front="-" - tmp=$(echo "$tmp" | sed -e "s/-//g") - tmp=$(echo "$tmp" | sed -e "s/dBm//g") - tmp1="$tmp"" " - level=$levelsrssi - namev=$namesrssi - namez=$namev - cindex=1 - nindex=0 - namev="-" - while [ true ] - do - levelv=$(echo "$level" | cut -d, -f$cindex) - if [ $levelv = "0" ]; then - namev="-" - break - fi - if [ "$tmp" -le "$levelv" ]; then - nindex=$((${nindex}+1)) - namev=$(echo "$namez" | cut -d, -f$nindex) - break - fi - cindex=$((${cindex}+1)) - nindex=$((${nindex}+1)) - done - css="level_"$nindex - desc="
                          "$namev"
                          " - namev="""$front$tmp1"""$desc - return - fi - if [ $key = "rscp" ]; then - front="" - tmp=$(echo "$tmp" | sed -e "s/dBm//g") - tmp=$(echo "$tmp" | sed -e "s/([^)]*)//g") - tmp1="$tmp"" " - tmp=$(echo "$tmp" | sed -e "s/-//g") - tmp=$(echo "$tmp" | tr " " "," | cut -d, -f1 ) - tmp=$(printf %.0f "$tmp") - level=$levelsrscp - namev=$namesrscp - namez=$namev - cindex=1 - nindex=0 - namev="-" - while [ true ] - do - levelv=$(echo "$level" | cut -d, -f$cindex) - if [ $levelv = "0" ]; then - namev="-" - break - fi - if [ "$tmp" -le "$levelv" ]; then - namev=$(echo "$namez" | cut -d, -f$nindex) - nindex=$((${nindex}-1)) - break - fi - cindex=$((${cindex}+1)) - nindex=$((${nindex}+1)) - done - css="level_"$nindex - desc="
                          "$namev"
                          " - namev="""$front$tmp1"""$desc - return - fi - - if [ $key = "single" ]; then - desc="" - tmp=$(echo "$tmp" | sed -e "s/dBm//g") - tmp=$(echo "$tmp" | sed -e "s/dB//g") - if [ $3 != "1" ];then - tmp=$(echo "$tmp" | sed -e "s/-//g") - fi - if [ $3 = "1" -o $3 = "0" ];then - desc="
                          "."
                          " - fi - namev="""$tmp"""$desc - return - fi -} - -readstatus() { -modd=$1 - while IFS= read -r line; do - port="$line" - read -r line - csq="$line" - read -r line - per="$line" - read -r line - rssi="$line" - read -r line - modem="$line" - read -r line - cops="$line" - read -r line - mode="$line" - read -r line - lac="$line" - read -r line - lacn="$line" - read -r line - cid="$line" - - read -r line - cidn="$line" - read -r line - mcc="$line" - read -r line - mnc="$line" - read -r line - rnc="$line" - read -r line - rncn="$line" - read -r line - down="$line" - read -r line - up="$line" - read -r line - ecio="$line" - read -r line - rscp="$line" - read -r line - ecio1="$line" - - read -r line - rscp1="$line" - read -r line - netmode="$line" - read -r line - cell="$line" - read -r line - modtype="$line" - read -r line - conntype="$line" - read -r line - channel="$line" - read -r line - phone="$line" - read -r line - read -r line - lband="$line" - read -r line - tempur="$line" - - read -r line - proto="$line" - read -r line - pci="$line" - read -r line - sinr="$line" - break - done < /tmp/status$modd.file -} - -bwdata() { - while IFS= read -r line; do - if [ $line = '0' ]; then - nodata="1" - break - else - nodata="0" - days=$line - read -r line - read -r line - tused=$line - read -r line - read -r line - tdwn=$line - read -r line - read -r line - tup=$line - read -r line - read -r line - project=$line - break - fi - done < /tmp/bwdata -} - -splash=$(uci -q get iframe.iframe.splashpage) - -if [ $splash = "1" ]; then - STEMP="/tmp/www/stemp.html" - STATUS="/usr/lib/iframe/status.html" - SPSTATUS="/tmp/www/splash.html" - rm -f $STEMP - cp $STATUS $STEMP - button="" - sed -i -e "s!#BUTTON#!$button!g" $STEMP - sed -i -e "s!#LUCIS#!luci-static/!g" $STEMP - titlebar="" - url=$(uci -q get iframe.iframe.url) - if [ -z $url ]; then - url="www.ofmodemsandmen.com" - fi - titlebar=$(echo "$titlebar" | sed -e "s!#URL#!$url!g") - sed -i -e "s!#TITLEBAR#!$titlebar!g" $STEMP - title=$(uci -q get iframe.iframe.splashtitle) - sed -i -e "s!#TITLE#!$title!g" $STEMP - - readstatus 1 - level2txt "$csq" "single" 0 - sed -i -e "s!#CSQ#!$namev!g" $STEMP - level2txt "$per" "per" - sed -i -e "s!#PER#!$namev!g" $STEMP - level2txt "$rssi" "rssi" - sed -i -e "s!#RSSI#!$namev!g" $STEMP - level2txt "$rscp" "rscp" - sed -i -e "s!#RSCP#!$namev!g" $STEMP - level2txt "$ecio" "single" 1 - sed -i -e "s!#RSRQ#!$namev!g" $STEMP - level2txt "$sinr" "single" 1 - sed -i -e "s!#SINR#!$namev!g" $STEMP - - level2txt "$mode" "single" - sed -i -e "s!#MODE#!$namev!g" $STEMP - level2txt "$mcc" "single" - sed -i -e "s!#MCC#!$namev!g" $STEMP - level2txt "$mnc" "single" - sed -i -e "s!#MNC#!$namev!g" $STEMP - level2txt "$rnc" "single" - sed -i -e "s!#RNC#!$namev!g" $STEMP - level2txt "$rncn" "single" - sed -i -e "s!#RNCN#!$namev!g" $STEMP - level2txt "$lac" "single" - sed -i -e "s!#LAC#!$namev!g" $STEMP - level2txt "$lacn" "single" - sed -i -e "s!#LACN#!$namev!g" $STEMP - level2txt "$pci" "single" - sed -i -e "s!#CELLID#!$namev!g" $STEMP - level2txt "$channel" "single" - sed -i -e "s!#CHAN#!$namev!g" $STEMP - level2txt "$lband" "single" - sed -i -e "s!#BAND#!$namev!g" $STEMP - - if [ -e /etc/custom ]; then - mod="/etc/custom" - else - mod="/tmp/sysinfo/model" - fi - while IFS= read -r line; do - ROUTER=$line - break - done < $mod - level2txt "$ROUTER" "single" - sed -i -e "s!#ROUTER#!$namev!g" $STEMP - level2txt "$modem" "single" - sed -i -e "s!#MODEM#!$namev!g" $STEMP - level2txt "$cops" "single" - namev=$(echo "$namev" | tr -d '&') - sed -i -e "s~#PROVIDER#~$namev~g" $STEMP - level2txt "$proto" "single" - sed -i -e "s!#PROTO#!$namev!g" $STEMP - level2txt "$port" "single" - sed -i -e "s!#PORT#!$namev!g" $STEMP - level2txt "$tempur" "single" - sed -i -e "s!#TEMP#!$namev!g" $STEMP - rm -f /tmp/spip; wget -O /tmp/spip http://ipecho.net/plain > /dev/null 2>&1 - extr=$(cat /tmp/spip) - if [ -z "$extr" ]; then - extr="-" - fi - level2txt "$extr" "single" - sed -i -e "s!#EXTERNAL#!$namev!g" $STEMP - - dual=$(uci -q get iframe.iframe.dual) - if [ $dual = "1" ]; then - STEMP2="/tmp/www/stemp2.html" - STATUS2="/usr/lib/iframe/modem2.html" - rm -f $STEMP2 - cp $STATUS2 $STEMP2 - - readstatus 2 - level2txt "$csq" "single" 0 - sed -i -e "s!#CSQ#!$namev!g" $STEMP2 - level2txt "$per" "per" - sed -i -e "s!#PER#!$namev!g" $STEMP2 - level2txt "$rssi" "rssi" - sed -i -e "s!#RSSI#!$namev!g" $STEMP2 - level2txt "$rscp" "rscp" - sed -i -e "s!#RSCP#!$namev!g" $STEMP2 - level2txt "$ecio" "single" 1 - sed -i -e "s!#RSRQ#!$namev!g" $STEMP2 - level2txt "$sinr" "single" 1 - sed -i -e "s!#SINR#!$namev!g" $STEMP2 - - level2txt "$mode" "single" - sed -i -e "s!#MODE#!$namev!g" $STEMP2 - level2txt "$mcc" "single" - sed -i -e "s!#MCC#!$namev!g" $STEMP2 - level2txt "$mnc" "single" - sed -i -e "s!#MNC#!$namev!g" $STEMP2 - level2txt "$rnc" "single" - sed -i -e "s!#RNC#!$namev!g" $STEMP2 - level2txt "$rncn" "single" - sed -i -e "s!#RNCN#!$namev!g" $STEMP2 - level2txt "$lac" "single" - sed -i -e "s!#LAC#!$namev!g" $STEMP2 - level2txt "$lacn" "single" - sed -i -e "s!#LACN#!$namev!g" $STEMP2 - level2txt "$pci" "single" - sed -i -e "s!#CELLID#!$namev!g" $STEMP2 - level2txt "$channel" "single" - sed -i -e "s!#CHAN#!$namev!g" $STEMP2 - level2txt "$lband" "single" - sed -i -e "s!#BAND#!$namev!g" $STEMP2 - - level2txt "$modem" "single" - sed -i -e "s!#MODEM#!$namev!g" $STEMP2 - level2txt "$cops" "single" - namev=$(echo "$namev" | tr -d '&') - sed -i -e "s!#MODEMN#!$namev!g" $STEMP2 - level2txt "$proto" "single" - sed -i -e "s!#PROTO#!$namev!g" $STEMP2 - level2txt "$port" "single" - sed -i -e "s!#PORT#!$namev!g" $STEMP2 - level2txt "$tempur" "single" - sed -i -e "s!#TEMP#!$namev!g" $STEMP2 - - MODEM2=$(cat $STEMP2) - sed -i -e "s!#MODEM2#!$MODEM2!g" $STEMP - else - sed -i -e "s!#MODEM2#!!g" $STEMP - fi - - open=$(uci -q get iframe.iframe.speed) - if [ $open = "1" ]; then - STEMP2="/tmp/www/stemp2.html" - STATUS2="/usr/lib/iframe/open.html" - rm -f $STEMP2 - cp $STATUS2 $STEMP2 - MODEM2=$(cat $STEMP2) - sed -i -e "s!#OPEN#!$MODEM2!g" $STEMP - else - sed -i -e "s!#OPEN#!!g" $STEMP - fi - - band=$(uci -q get iframe.iframe.band) - if [ $band = "1" ]; then - STEMP2="/tmp/www/stemp2.html" - STATUS2="/usr/lib/iframe/band.html" - rm -f $STEMP2 - cp $STATUS2 $STEMP2 - MODEM2=$(cat $STEMP2) - sed -i -e "s!#BWMON#!$MODEM2!g" $STEMP - else - sed -i -e "s!#BWMON#!!g" $STEMP - fi - - mv $STEMP $SPSTATUS -fi - diff --git a/rooter/0splash/ext-splash/files/usr/lib/iframe/update.sh b/rooter/0splash/ext-splash/files/usr/lib/iframe/update.sh deleted file mode 100644 index e6cb8df..0000000 --- a/rooter/0splash/ext-splash/files/usr/lib/iframe/update.sh +++ /dev/null @@ -1,301 +0,0 @@ -#!/bin/sh -. /lib/functions.sh - -log() { - logger -t "Status Update" "$@" -} - -levelsper="101,85,70,55,40,25,10,1,0" -namesper="Perfect,Excellent,Good,Medium,Low,Bad,Dead" -levelsrssi="113,119,100,90,70,1,0" -namesrssi="None,Bad,Poor,Medium,High,Perfect" -levelsrscp="140,136,112,100,90,70,50,1,0" -namesrscp='None,None (3G) : Poor (4G),Weak (3G) : Medium (4G),Poor (3G) : Good (4G),Medium (3G) : High (4G),High (3G) :High (4G)' - -level2txt() { - tmp="$1" - key=$2 - front="" - tmp1="$tmp"" " - if [ "$tmp" = "-" ]; then - namev="""--""" - return - fi - if [ $key = "per" ]; then - tmp=$(echo "$tmp" | sed -e "s/%//g") - level=$levelsper - namev=$namesper - fi - if [ $key = "rssi" ]; then - front="-" - tmp=$(echo "$tmp" | sed -e "s/-//g") - tmp=$(echo "$tmp" | sed -e "s/dBm//g") - tmp1="$tmp"" " - level=$levelsrssi - namev=$namesrssi - fi - if [ $key = "rscp" ]; then - front="" - tmp=$(echo "$tmp" | sed -e "s/dBm//g") - tmp=$(echo "$tmp" | sed -e "s/([^)]*)//g") - tmp1="$tmp"" " - tmp=$(echo "$tmp" | sed -e "s/-//g") - tmp=$(echo "$tmp" | tr " " "," | cut -d, -f1 ) - tmp=$(printf %.0f "$tmp") - level=$levelsrscp - namev=$namesrscp - fi - - if [ $key = "single" ]; then - desc="" - tmp=$(echo "$tmp" | sed -e "s/dBm//g") - tmp=$(echo "$tmp" | sed -e "s/dB//g") - if [ $3 != "1" ];then - tmp=$(echo "$tmp" | sed -e "s/-//g") - fi - if [ $3 = "1" -o $3 = "0" ];then - desc="
                          "."
                          " - fi - namev="""$tmp"""$desc - return - fi - - namez=$namev - cindex=1 - nindex=0 - namev="-" - - while [ true ] - do - levelv=$(echo "$level" | cut -d, -f$cindex) - if [ $levelv = "0" ]; then - namev="-" - break - fi - if [ "$tmp" -ge "$levelv" ]; then - namev=$(echo "$namez" | cut -d, -f$nindex) - break - fi - cindex=$((${cindex}+1)) - nindex=$((${nindex}+1)) - done - - css="level_"$nindex - desc="
                          "$namev"
                          " - namev="""$front$tmp1"""$desc -} - -readstatus() { -modd=$1 - while IFS= read -r line; do - port="$line" - read -r line - csq="$line" - read -r line - per="$line" - read -r line - rssi="$line" - read -r line - modem="$line" - read -r line - cops="$line" - read -r line - mode="$line" - read -r line - lac="$line" - read -r line - lacn="$line" - read -r line - cid="$line" - - read -r line - cidn="$line" - read -r line - mcc="$line" - read -r line - mnc="$line" - read -r line - rnc="$line" - read -r line - rncn="$line" - read -r line - down="$line" - read -r line - up="$line" - read -r line - ecio="$line" - read -r line - rscp="$line" - read -r line - ecio1="$line" - - read -r line - rscp1="$line" - read -r line - netmode="$line" - read -r line - cell="$line" - read -r line - modtype="$line" - read -r line - conntype="$line" - read -r line - channel="$line" - read -r line - phone="$line" - read -r line - read -r line - lband="$line" - read -r line - tempur="$line" - - read -r line - proto="$line" - read -r line - pci="$line" - read -r line - sinr="$line" - break - done < /tmp/status$modd.file -} -bwdata() { - while IFS= read -r line; do - if [ $line = '0' ]; then - nodata="1" - break - else - nodata="0" - days=$line - read -r line - read -r line - tused=$line - read -r line - read -r line - tdwn=$line - read -r line - read -r line - tup=$line - read -r line - read -r line - project=$line - break - fi - done < /tmp/bwdata -} - -logtype=$(uci -q get iframe.login.logtype) -if [ $logtype = "1" ]; then - STEMP="/tmp/www/itemp.html" - STATUS="/usr/lib/iframe/mframe.html" - IFSTATUS="/tmp/www/display.html" - - rm -f $STEMP - cp $STATUS $STEMP - readstatus 1 - level2txt "$csq" "single" 0 - sed -i -e "s!#CSQ#!$namev!g" $STEMP - level2txt "$per" "per" - sed -i -e "s!#PER#!$namev!g" $STEMP - level2txt "$rssi" "rssi" - sed -i -e "s!#RSSI#!$namev!g" $STEMP - level2txt "$rscp" "rscp" - sed -i -e "s!#RSCP#!$namev!g" $STEMP - level2txt "$ecio" "single" 1 - sed -i -e "s!#RSRQ#!$namev!g" $STEMP - level2txt "$sinr" "single" 1 - sed -i -e "s!#SINR#!$namev!g" $STEMP - - level2txt "$mode" "single" - sed -i -e "s!#MODE#!$namev!g" $STEMP - level2txt "$mcc" "single" - sed -i -e "s!#MCC#!$namev!g" $STEMP - level2txt "$mnc" "single" - sed -i -e "s!#MNC#!$namev!g" $STEMP - level2txt "$rnc" "single" - sed -i -e "s!#RNC#!$namev!g" $STEMP - level2txt "$rncn" "single" - sed -i -e "s!#RNCN#!$namev!g" $STEMP - level2txt "$lac" "single" - sed -i -e "s!#LAC#!$namev!g" $STEMP - level2txt "$lacn" "single" - sed -i -e "s!#LACN#!$namev!g" $STEMP - level2txt "$pci" "single" - sed -i -e "s!#CELLID#!$namev!g" $STEMP - level2txt "$channel" "single" - sed -i -e "s!#CHAN#!$namev!g" $STEMP - level2txt "$lband" "single" - sed -i -e "s!#BAND#!$namev!g" $STEMP - - if [ -e /etc/custom ]; then - mod="/etc/custom" - else - mod="/tmp/sysinfo/model" - fi - while IFS= read -r line; do - ROUTER=$line - break - done < $mod - level2txt "$ROUTER" "single" - sed -i -e "s!#ROUTER#!$namev!g" $STEMP - level2txt "$modem" "single" - sed -i -e "s!#MODEM#!$namev!g" $STEMP - level2txt "$cops" "single" - namev=$(echo "$namev" | tr -d '&') - sed -i -e "s!#PROVIDER#!$namev!g" $STEMP - level2txt "$proto" "single" - sed -i -e "s!#PROTO#!$namev!g" $STEMP - level2txt "$port" "single" - sed -i -e "s!#PORT#!$namev!g" $STEMP - level2txt "$tempur" "single" - sed -i -e "s!#TEMP#!$namev!g" $STEMP - - mv $STEMP $IFSTATUS -fi - -if [ $logtype = "2" ]; then - STEMP="/tmp/www/itemp.html" - STATUS="/usr/lib/iframe/image.html" - IFSTATUS="/tmp/www/display.html" - - rm -f $STEMP - cp $STATUS $STEMP - logimage=$(uci -q get iframe.login.logimage) - sed -i -e "s!#IMAGE#!$logimage!g" $STEMP - logimagewidth=$(uci -q get iframe.login.logimagewidth) - sed -i -e "s!#WIDTH#!$logimagewidth!g" $STEMP - - mv $STEMP $IFSTATUS -fi - -if [ $logtype = "4" ]; then - STEMP="/tmp/www/itemp.html" - STATUS="/usr/lib/iframe/speed.html" - IFSTATUS="/tmp/www/display.html" - - rm -f $STEMP - cp $STATUS $STEMP - - mv $STEMP $IFSTATUS -fi - -if [ $logtype = "3" ]; then - STEMP="/tmp/www/itemp.html" - STATUS="/usr/lib/iframe/zerotier.html" - IFSTATUS="/tmp/www/display.html" - - rm -f $STEMP - cp $STATUS $STEMP - - ID=$(uci -q get zerotier.zerotier.secret) - if [ -z $ID ]; then - ID="xxxxxxxxxx" - else - ID=${ID:0:10} - fi - - sed -i -e "s!#ID#!$ID!g" $STEMP - source /etc/codename - sed -i -e "s!#VER#!$CODENAME!g" $STEMP - - mv $STEMP $IFSTATUS -fi \ No newline at end of file diff --git a/rooter/0splash/ext-splash/files/usr/lib/iframe/zerotier.html b/rooter/0splash/ext-splash/files/usr/lib/iframe/zerotier.html deleted file mode 100644 index aaba6a5..0000000 --- a/rooter/0splash/ext-splash/files/usr/lib/iframe/zerotier.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - -

                          Router ID : #ID#

                          -
                          Powered by : #VER#
                          - - - diff --git a/rooter/0splash/ext-splash/files/www/luci-static/display.html b/rooter/0splash/ext-splash/files/www/luci-static/display.html deleted file mode 100644 index acc2f86..0000000 --- a/rooter/0splash/ext-splash/files/www/luci-static/display.html +++ /dev/null @@ -1 +0,0 @@ -/tmp/www/display.html \ No newline at end of file diff --git a/rooter/0splash/ext-splash/files/www/luci-static/iframe.html b/rooter/0splash/ext-splash/files/www/luci-static/iframe.html deleted file mode 100644 index 444edca..0000000 --- a/rooter/0splash/ext-splash/files/www/luci-static/iframe.html +++ /dev/null @@ -1 +0,0 @@ -/tmp/www/daylist.html \ No newline at end of file diff --git a/rooter/0splash/ext-splash/files/www/luci-static/ifstatus.html b/rooter/0splash/ext-splash/files/www/luci-static/ifstatus.html deleted file mode 100644 index 1155573..0000000 --- a/rooter/0splash/ext-splash/files/www/luci-static/ifstatus.html +++ /dev/null @@ -1 +0,0 @@ -/tmp/www/ifstatus.html \ No newline at end of file diff --git a/rooter/0splash/ext-splash/files/www/luci-static/rooter/css/iconmoon_splash.css b/rooter/0splash/ext-splash/files/www/luci-static/rooter/css/iconmoon_splash.css deleted file mode 100644 index 5254b92..0000000 --- a/rooter/0splash/ext-splash/files/www/luci-static/rooter/css/iconmoon_splash.css +++ /dev/null @@ -1,69 +0,0 @@ -@font-face { - font-family: 'icomoon_splash'; - src: url('../fonts/icomoon_splash.eot?vja16g'); - src: url('../fonts/icomoon_splash.eot?vja16g#iefix') format('embedded-opentype'), - url('../fonts/icomoon_splash.ttf?vja16g') format('truetype'), - url('../fonts/icomoon_splash.woff?vja16g') format('woff'), - url('../fonts/icomoon_splash.svg?vja16g#icomoon_splash') format('svg'); - font-weight: normal; - font-style: normal; -} - -[class^="icon-"], [class*=" icon-"] { - /* use !important to prevent issues with browser extensions that change fonts */ - font-family: 'icomoon_splash' !important; - speak: none; - font-style: normal; - font-weight: normal; - font-variant: normal; - text-transform: none; - line-height: 1; - - /* Better Font Rendering =========== */ - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - - -.icon-power-off:before { - content: "\f011"; -} -.icon-signal:before { - content: "\f012"; -} -.icon-cog:before { - content: "\f013"; -} -.icon-gear:before { - content: "\f013"; -} -.icon-home:before { - content: "\f015"; -} -.icon-exclamation-triangle:before { - content: "\f071"; -} -.icon-warning:before { - content: "\f071"; -} -.icon-comments:before { - content: "\f086"; -} -.icon-hdd-o:before { - content: "\f0a0"; -} -.icon-plug:before { - content: "\f1e6"; -} -.icon-wifi:before { - content: "\f1eb"; -} -.icon-connection:before { - content: "\e91b"; -} -.icon-podcast:before { - content: "\e91c"; -} -.icon-earth:before { - content: "\e9ca"; -} diff --git a/rooter/0splash/ext-splash/files/www/luci-static/rooter/css/splash.css b/rooter/0splash/ext-splash/files/www/luci-static/rooter/css/splash.css deleted file mode 100644 index 05040a4..0000000 --- a/rooter/0splash/ext-splash/files/www/luci-static/rooter/css/splash.css +++ /dev/null @@ -1,342 +0,0 @@ -/* @override http://src.dev.lo.lo/ROOter/www/luci-static/rooter/css/splash.css */ - -/* - CSS for ROOter splash pages - Copyright Francois Dechery - https://github.com/soif -*/ - -/* @group Splash Pages ---------------------------------------------------*/ - -.rooterSplash{ - padding: 0; - background: #F0F0F0; -} -.rooterPageHead{ - background: #55F; - padding: 20px 5px; - background: rgb(140,140,255); - background: -moz-linear-gradient(top, rgba(140,140,255,1) 0%, rgba(85,85,255,1) 100%); - background: -webkit-linear-gradient(top, rgba(140,140,255,1) 0%,rgba(85,85,255,1) 100%); - background: linear-gradient(to bottom, rgba(140,140,255,1) 0%,rgba(85,85,255,1) 100%); - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#8c8cff', endColorstr='#5555ff',GradientType=0 ); - border-bottom: 1px solid rgba(0,0,0,0.7); - -} -.rooterPageContent{ - border-top: 1px solid rgba(255,255,255,0.8); - border-bottom: 1px solid rgba(0,0,0, 0.1); - padding: 0px 0px; - max-width: 1200px; - margin: auto; -} - -.rooterPageContentBW{ - border-top: 1px solid rgba(255,255,255,0.8); - border-bottom: 1px solid rgba(0,0,0, 0.1); - padding: 10px 0px; - max-width: 600px; - margin: auto; -} - -.rooterHeadTitle{ - color: #fff; - text-align: center; - font-family: Georgia, "Times New Roman", Times, serif; - font-size: 32px; - line-height: 120%; - text-shadow: -1px -1px 2px rgba(0,0,0,0.5); -} -.rooterPageFoot{ - border-top: 1px solid rgba(255,255,255,0.8); - margin-top: 20px; - padding: 10px 10px; - max-width: 950px; - margin: auto; - font-size: 16px; -} -.rooterFootMenu{ - float: left; - margin-bottom: 10px; -} -.rooterFootMenu A{ - text-decoration: none; -} -.rooterFootMenu A:hover{ - color: #000; -} -.rooterFootMenu UL{ - padding: 0; - margin: 0; - overflow: hidden; - display: inline-block; -} -.rooterFootMenu LI{ - float: left; - padding: 0; - margin: 0; - list-style: none; -} -.rooterFootMenu LI A{ - padding: 0 10px; - color: #555; -} -.rooterFootMenu LI:first-child A{ - padding-left: 0; -} -.rooterFootCredits{ - float: right; - padding: 0; - margin: 0; - color: #999; - text-align: right; -} -.rooterFootCredits A{ - color: #777; -} -/* @end */ - - - - -/* @group Page: Home ---------------------------------------------------*/ - - -/* @group Logo -++++++++++++++++++ */ -.rooterHeadBox{ - font-size: 50px; - font-family: Georgia, "Times New Roman", Times, serif; - color: #fff; - line-height: 100%; - overflow: hidden; - width: 700px; - margin: auto; - padding-top: 10px; - opacity: 0; -} -.rooterLogo{ - background: url("../img/kangaroo_800.png") no-repeat; - background-size: 100%; - float: left; - height: 110px; - width: 250px; - opacity: 0.4; -} -.rooterTagline{ - margin-left: 100px; - padding-left: 10px; - text-shadow: 2px 2px 3px rgba(0,0,0,0.3); -} - -/* @end */ - -@media only screen and (max-width: 600px) { - .rooterHeadBox{ - text-align: center; - width: auto; - } - .rooterLogo{ - display: inline-block; - float: none; - } - .rooterTagline { - display: none; - } - .rooterFootCredits, - .rooterFootMenu{ - float: none; - text-align: center; - } -} - -#rooterItems{ - clear: both; - max-width: 600px ; - margin: auto; -} - -#rooterItemss{ - clear: both; - max-width: 300px ; - margin: auto; -} -.rooterItem{ - overflow: hidden; - border: 5px solid #00; - border-color: #00 #DDD #DDD #00; - padding: 20px 15px; - margin-bottom: 20px; - border-radius: 8px; - background-color: #AFAFAF; -} -.rooterItem:hover{ - background-color: #CFCFCF; - border-color: #AAA; -} -.rooterItemTitle{ - float: left; - font-size: 18px; - font-weight: bold; - padding-right: 10px; - color: #000; - line-height: 2em; -} -.rooterItemTitle .icon{ - color: #55F; - margin-right: 8px; - font-size: 2em; - vertical-align: middle; -} - -.rooterItemsp{ - overflow: hidden; - border: 5px solid #00; - border-color: #00 #DDD #DDD #00; - padding: 5px 15px; - margin-bottom: 5px; - border-radius: 8px; - background-color: #AFAFAF; - max-width: 300px ; -} -.rooterItemsp:hover{ - background-color: #CFCFCF; - border-color: #AAA; -} - -#rooterItems A{ - text-decoration: none; -} -.rooterItemDesc{ - font-size: 18px; - color: #777; - margin-left: 220px; - margin-top: 0.7em; -} -/* @end */ - - - -/* @group Page: Status ---------------------------------------------------*/ - -.modemStatusBlock{ - margin-bottom: 30px; -} -#rooterSplashStatus h3{ - clear:both; - font-size: 18px; - color: #55F; -} -#rooterSplashStatus h3 .icon{ - margin-right: 3px; -} -#rooterSplashStatus h3 .msCell{ - color: #666; -} -.modemStatusRow{ - clear:both; - padding-bottom: 20px; - overflow: hidden; -} -.modemStatusRow .msTitle{ - border-radius: 2px 2px 0 0; - padding: 5px 5px ; - background: #484848; - color: #fff; - background: rgb(99,99,99); - background: -moz-linear-gradient(top, rgba(99,99,99,1) 0%, rgba(72,72,72,1) 100%); - background: -webkit-linear-gradient(top, rgba(99,99,99,1) 0%,rgba(72,72,72,1) 100%); - background: linear-gradient(to bottom, rgba(99,99,99,1) 0%,rgba(72,72,72,1) 100%); - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#636363', endColorstr='#484848',GradientType=0 ); -} -.modemStatusRow .msCell{ - border-radius: 10px; - display: inline-block; - margin-top: 10px; - float:left; - border: 1px solid #ccc; - padding-bottom: 5px; - background: #fff; - -} -.modemStatusRow1 .msCell{ - width: 176px; - margin: 10px 5px 0 5px; - text-align: center; -} -.modemStatusRow1 SPAN B{ - font-weight: bold; - font-size: 35px; - line-height: 110%; - text-shadow: 1px 1px 1px rgba(0,0,0,0.4); -} -.modemStatusRow1 .msDesc{ - color: #000; - font-size: 12px; -} -.modemStatusRow2 .msCell{ - margin: 10px 5px; - text-align: center; -} -.modemStatusRow2 SPAN{ - display: inline-block; - padding: 5px 5px ; - font-size: 14px; -} -#counter_div{ - color: #000; - font-weight: normal; - font-size: 14px; -} -#counter_val{ - color: #F00; - font-size: 32px; - font-weight: bold; - text-shadow: 1px 1px 1px rgba(0,0,0,0.1); -} -#msCell_per{} -#msCell_csq{} -#msCell_rssi{} -#msCell_rscp{} -#msCell_ecio{} - -#rooterSplashStatus .level_0{ - color: #0F0; // green -} -#rooterSplashStatus .level_1{ - color: #0CB; // green blue -} -#rooterSplashStatus .level_2{ - color: #00F; // blue -} -#rooterSplashStatus .level_3{ - color: #F0F; // violet -} -#rooterSplashStatus .level_4{ - color: #F80; // orange -} -#rooterSplashStatus .level_5{ - color: #F00; // red -} -#rooterSplashStatus .level_6{ - color: #FF0; // yellow -} - -/* @end */ - - -/* Easy Color changer ------------- */ - -.rooterPageHead{ - /*background: #55F;*/ -} -.rooterItemTitle .icon, -#rooterSplashStatus h3{ - color: #55F; -} - - - diff --git a/rooter/0splash/ext-splash/files/www/luci-static/rooter/fonts/icomoon_splash.eot b/rooter/0splash/ext-splash/files/www/luci-static/rooter/fonts/icomoon_splash.eot deleted file mode 100644 index 29cd4d1..0000000 Binary files a/rooter/0splash/ext-splash/files/www/luci-static/rooter/fonts/icomoon_splash.eot and /dev/null differ diff --git a/rooter/0splash/ext-splash/files/www/luci-static/rooter/fonts/icomoon_splash.svg b/rooter/0splash/ext-splash/files/www/luci-static/rooter/fonts/icomoon_splash.svg deleted file mode 100644 index dc2127b..0000000 --- a/rooter/0splash/ext-splash/files/www/luci-static/rooter/fonts/icomoon_splash.svg +++ /dev/null @@ -1,22 +0,0 @@ - - - -Generated by IcoMoon - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/rooter/0splash/ext-splash/files/www/luci-static/rooter/fonts/icomoon_splash.ttf b/rooter/0splash/ext-splash/files/www/luci-static/rooter/fonts/icomoon_splash.ttf deleted file mode 100644 index 4e27645..0000000 Binary files a/rooter/0splash/ext-splash/files/www/luci-static/rooter/fonts/icomoon_splash.ttf and /dev/null differ diff --git a/rooter/0splash/ext-splash/files/www/luci-static/rooter/fonts/icomoon_splash.woff b/rooter/0splash/ext-splash/files/www/luci-static/rooter/fonts/icomoon_splash.woff deleted file mode 100644 index 63f5413..0000000 Binary files a/rooter/0splash/ext-splash/files/www/luci-static/rooter/fonts/icomoon_splash.woff and /dev/null differ diff --git a/rooter/0splash/ext-splash/files/www/luci-static/rooter/img/favicon.gif b/rooter/0splash/ext-splash/files/www/luci-static/rooter/img/favicon.gif deleted file mode 100644 index bfbe292..0000000 Binary files a/rooter/0splash/ext-splash/files/www/luci-static/rooter/img/favicon.gif and /dev/null differ diff --git a/rooter/0splash/ext-splash/files/www/luci-static/rooter/img/kangaroo_800.png b/rooter/0splash/ext-splash/files/www/luci-static/rooter/img/kangaroo_800.png deleted file mode 100644 index 478fa6d..0000000 Binary files a/rooter/0splash/ext-splash/files/www/luci-static/rooter/img/kangaroo_800.png and /dev/null differ diff --git a/rooter/0splash/ext-splash/files/www/splash_files/check1.gif b/rooter/0splash/ext-splash/files/www/splash_files/check1.gif deleted file mode 100644 index 75b945d..0000000 Binary files a/rooter/0splash/ext-splash/files/www/splash_files/check1.gif and /dev/null differ diff --git a/rooter/0splash/ext-splashconfig/Makefile b/rooter/0splash/ext-splashconfig/Makefile deleted file mode 100644 index c986ca8..0000000 --- a/rooter/0splash/ext-splashconfig/Makefile +++ /dev/null @@ -1,36 +0,0 @@ -#Owned by DairyMan@Whirlpool -# -#Copyright GNU act. -include $(TOPDIR)/rules.mk - -PKG_NAME:=ext-splashconfig -PKG_VERSION:=1.000 -PKG_RELEASE:=1 - -PKG_MAINTAINER:=Created by DM/makefile by Cobia@whirlpool -include $(INCLUDE_DIR)/package.mk - -define Package/ext-splashconfig - SECTION:=utils - CATEGORY:=ROOter - SUBMENU:=Splash Screens - DEPENDS:=+ext-splash - TITLE:=Added scripts for Login display - PKGARCH:=all -endef - -define Package/ext-splashconfig/description - Added scripts for Login display -endef - - -define Build/Compile -endef - -define Package/ext-splashconfig/install - $(CP) ./files/* $(1)/ - - -endef - -$(eval $(call BuildPackage,ext-splashconfig)) diff --git a/rooter/0splash/ext-splashconfig/files/usr/lib/lua/luci/controller/splash.lua b/rooter/0splash/ext-splashconfig/files/usr/lib/lua/luci/controller/splash.lua deleted file mode 100644 index 40b8960..0000000 --- a/rooter/0splash/ext-splashconfig/files/usr/lib/lua/luci/controller/splash.lua +++ /dev/null @@ -1,10 +0,0 @@ ---[[ -ext-theme -]]-- - -module("luci.controller.splash", package.seeall) - -function index() - entry({"admin", "splash"}, firstchild(), "Splash Screen", 82).dependent=false - entry({"admin", "splash", "splash"}, cbi("splashm"), _("Configuration"), 20) -end diff --git a/rooter/0splash/ext-splashconfig/files/usr/lib/lua/luci/model/cbi/splashm.lua b/rooter/0splash/ext-splashconfig/files/usr/lib/lua/luci/model/cbi/splashm.lua deleted file mode 100644 index 0073acb..0000000 --- a/rooter/0splash/ext-splashconfig/files/usr/lib/lua/luci/model/cbi/splashm.lua +++ /dev/null @@ -1,44 +0,0 @@ - - -local sys = require "luci.sys" -local zones = require "luci.sys.zoneinfo" -local fs = require "nixio.fs" -local conf = require "luci.config" - -m = Map("iframe", "Splash Screen Configuration",translate("Change the configuration of the Splash and Login screen.")) -m:chain("luci") - -s = m:section(TypedSection, "iframe", "Status Page Configuration") -s.anonymous = true -s.addremove = false - -c1 = s:option(ListValue, "splashpage", "Enable Network Status Page Before Login :"); -c1:value("0", "Disabled") -c1:value("1", "Enabled") -c1.default=0 - -a1 = s:option(Value, "splashtitle", "Network Status Title :"); -a1.optional=false; -a1.default = "ROOter Status" -a1:depends("splashpage", "1") - -dc1 = s:option(ListValue, "dual", "Enable Modem 2 Status :"); -dc1:value("0", "Disabled") -dc1:value("1", "Enabled") -dc1.default=0 -dc1:depends("splashpage", "1") - -cc1 = s:option(ListValue, "speed", "Enable OpenSpeedTest :"); -cc1:value("0", "Disabled") -cc1:value("1", "Enabled") -cc1.default=0 -cc1:depends("splashpage", "1") - -ec1 = s:option(ListValue, "band", "Enable Bandwidth Summary :"); -ec1:value("0", "Disabled") -ec1:value("1", "Enabled") -ec1.default=0 -ec1:depends("splashpage", "1") - - -return m \ No newline at end of file diff --git a/rooter/0splash/splash/Makefile b/rooter/0splash/splash/Makefile deleted file mode 100644 index 2941b94..0000000 --- a/rooter/0splash/splash/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -#Owned by DairyMan@Whirlpool -# -#Copyright GNU act. -include $(TOPDIR)/rules.mk - -PKG_NAME:=splash -PKG_VERSION:=1.000 -PKG_RELEASE:=1 - -PKG_MAINTAINER:=Created by DM/makefile by Cobia@whirlpool -include $(INCLUDE_DIR)/package.mk - -define Package/splash - SECTION:=utils - CATEGORY:=ROOter - SUBMENU:=Splash Screens - TITLE:=Added scripts for Splash screen - PKGARCH:=all -endef - -define Package/splash/description - Added scripts for Splash screen -endef - - -define Build/Compile -endef - -define Package/splash/install - $(CP) ./files/* $(1)/ - - -endef - -$(eval $(call BuildPackage,splash)) diff --git a/rooter/0splash/splash/files/www/luci-static/rooter/css/iconmoon_splash.css b/rooter/0splash/splash/files/www/luci-static/rooter/css/iconmoon_splash.css deleted file mode 100644 index 5254b92..0000000 --- a/rooter/0splash/splash/files/www/luci-static/rooter/css/iconmoon_splash.css +++ /dev/null @@ -1,69 +0,0 @@ -@font-face { - font-family: 'icomoon_splash'; - src: url('../fonts/icomoon_splash.eot?vja16g'); - src: url('../fonts/icomoon_splash.eot?vja16g#iefix') format('embedded-opentype'), - url('../fonts/icomoon_splash.ttf?vja16g') format('truetype'), - url('../fonts/icomoon_splash.woff?vja16g') format('woff'), - url('../fonts/icomoon_splash.svg?vja16g#icomoon_splash') format('svg'); - font-weight: normal; - font-style: normal; -} - -[class^="icon-"], [class*=" icon-"] { - /* use !important to prevent issues with browser extensions that change fonts */ - font-family: 'icomoon_splash' !important; - speak: none; - font-style: normal; - font-weight: normal; - font-variant: normal; - text-transform: none; - line-height: 1; - - /* Better Font Rendering =========== */ - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - - -.icon-power-off:before { - content: "\f011"; -} -.icon-signal:before { - content: "\f012"; -} -.icon-cog:before { - content: "\f013"; -} -.icon-gear:before { - content: "\f013"; -} -.icon-home:before { - content: "\f015"; -} -.icon-exclamation-triangle:before { - content: "\f071"; -} -.icon-warning:before { - content: "\f071"; -} -.icon-comments:before { - content: "\f086"; -} -.icon-hdd-o:before { - content: "\f0a0"; -} -.icon-plug:before { - content: "\f1e6"; -} -.icon-wifi:before { - content: "\f1eb"; -} -.icon-connection:before { - content: "\e91b"; -} -.icon-podcast:before { - content: "\e91c"; -} -.icon-earth:before { - content: "\e9ca"; -} diff --git a/rooter/0splash/splash/files/www/luci-static/rooter/css/splash.css b/rooter/0splash/splash/files/www/luci-static/rooter/css/splash.css deleted file mode 100644 index 76957ea..0000000 --- a/rooter/0splash/splash/files/www/luci-static/rooter/css/splash.css +++ /dev/null @@ -1,311 +0,0 @@ -/* @override http://src.dev.lo.lo/ROOter/www/luci-static/rooter/css/splash.css */ - -/* - CSS for ROOter splash pages - Copyright Francois Dechery - https://github.com/soif -*/ - -/* @group Splash Pages ---------------------------------------------------*/ - -.rooterSplash{ - padding: 0; - background: #F0F0F0; -} -.rooterPageHead{ - background: #55F; - padding: 10px 5px; - background: rgb(140,140,255); - background: -moz-linear-gradient(top, rgba(140,140,255,1) 0%, rgba(85,85,255,1) 100%); - background: -webkit-linear-gradient(top, rgba(140,140,255,1) 0%,rgba(85,85,255,1) 100%); - background: linear-gradient(to bottom, rgba(140,140,255,1) 0%,rgba(85,85,255,1) 100%); - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#8c8cff', endColorstr='#5555ff',GradientType=0 ); - border-bottom: 1px solid rgba(0,0,0,0.7); - -} -.rooterPageContent{ - border-top: 1px solid rgba(255,255,255,0.8); - border-bottom: 1px solid rgba(0,0,0, 0.1); - padding: 25px 10px; - max-width: 950px; - margin: auto; -} -.rooterHeadTitle{ - color: #fff; - text-align: center; - font-family: Georgia, "Times New Roman", Times, serif; - font-size: 32px; - line-height: 120%; - text-shadow: -1px -1px 2px rgba(0,0,0,0.5); -} -.rooterPageFoot{ - border-top: 1px solid rgba(255,255,255,0.8); - margin-top: 20px; - padding: 10px 10px; - max-width: 950px; - margin: auto; - font-size: 11px; -} -.rooterFootMenu{ - float: left; - margin-bottom: 10px; -} -.rooterFootMenu A{ - text-decoration: none; -} -.rooterFootMenu A:hover{ - color: #000; -} -.rooterFootMenu UL{ - padding: 0; - margin: 0; - overflow: hidden; - display: inline-block; -} -.rooterFootMenu LI{ - float: left; - padding: 0; - margin: 0; - list-style: none; -} -.rooterFootMenu LI A{ - padding: 0 10px; - color: #555; -} -.rooterFootMenu LI:first-child A{ - padding-left: 0; -} -.rooterFootCredits{ - float: right; - padding: 0; - margin: 0; - color: #999; - text-align: right; -} -.rooterFootCredits A{ - color: #777; -} -/* @end */ - - - - -/* @group Page: Home ---------------------------------------------------*/ - - -/* @group Logo -++++++++++++++++++ */ -.rooterHeadBox{ - font-size: 50px; - font-family: Georgia, "Times New Roman", Times, serif; - color: #fff; - line-height: 100%; - overflow: hidden; - width: 700px; - margin: auto; - padding-top: 10px; - opacity: 0; -} -.rooterLogo{ - background: url("../img/kangaroo_800.png") no-repeat; - background-size: 100%; - float: left; - height: 110px; - width: 250px; - opacity: 0.4; -} -.rooterTagline{ - margin-left: 100px; - padding-left: 10px; - text-shadow: 2px 2px 3px rgba(0,0,0,0.3); -} - -/* @end */ - -@media only screen and (max-width: 600px) { - .rooterHeadBox{ - text-align: center; - width: auto; - } - .rooterLogo{ - display: inline-block; - float: none; - } - .rooterTagline { - display: none; - } - .rooterFootCredits, - .rooterFootMenu{ - float: none; - text-align: center; - } -} - -#rooterItems{ - clear: both; - max-width: 800px ; - margin: auto; -} -.rooterItem{ - overflow: hidden; - border: 1px solid #EEE; - border-color: #EEE #DDD #DDD #EEE; - padding: 20px 15px; - margin-bottom: 20px; - border-radius: 8px; - background-color: #fff; -} -.rooterItem:hover{ - background-color: #F3F3FF; - border-color: #AAA; -} -.rooterItemTitle{ - float: left; - font-size: 18px; - font-weight: bold; - padding-right: 10px; - color: #000; - line-height: 2em; -} -.rooterItemTitle .icon{ - color: #55F; - margin-right: 8px; - font-size: 2em; - vertical-align: middle; -} -#rooterItems A{ - text-decoration: none; -} -.rooterItemDesc{ - font-size: 14px; - color: #777; - margin-left: 220px; - margin-top: 0.7em; -} -/* @end */ - - - -/* @group Page: Status ---------------------------------------------------*/ - -.modemStatusBlock{ - margin-bottom: 30px; -} -#rooterSplashStatus h3{ - clear:both; - font-size: 18px; - color: #55F; -} -#rooterSplashStatus h3 .icon{ - margin-right: 3px; -} -#rooterSplashStatus h3 .msCell{ - color: #666; -} -.modemStatusRow{ - clear:both; - padding-bottom: 20px; - overflow: hidden; -} -.modemStatusRow .msTitle{ - border-radius: 2px 2px 0 0; - padding: 5px 5px ; - background: #484848; - color: #fff; - background: rgb(99,99,99); - background: -moz-linear-gradient(top, rgba(99,99,99,1) 0%, rgba(72,72,72,1) 100%); - background: -webkit-linear-gradient(top, rgba(99,99,99,1) 0%,rgba(72,72,72,1) 100%); - background: linear-gradient(to bottom, rgba(99,99,99,1) 0%,rgba(72,72,72,1) 100%); - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#636363', endColorstr='#484848',GradientType=0 ); -} -.modemStatusRow .msCell{ - border-radius: 10px; - display: inline-block; - margin-top: 10px; - float:left; - border: 1px solid #ccc; - padding-bottom: 5px; - background: #fff; - -} -.modemStatusRow1 .msCell{ - width: 176px; - margin: 10px 5px 0 5px; - text-align: center; -} -.modemStatusRow1 SPAN B{ - font-weight: bold; - font-size: 70px; - line-height: 110%; - text-shadow: 1px 1px 1px rgba(0,0,0,0.4); -} -.modemStatusRow1 .msDesc{ - color: #000; - font-size: 12px; -} -.modemStatusRow2 .msCell{ - margin: 10px 5px; - text-align: center; -} -.modemStatusRow2 SPAN{ - display: inline-block; - padding: 5px 5px ; - font-size: 14px; -} -#counter_div{ - color: #000; - font-weight: normal; - font-size: 14px; -} -#counter_val{ - color: #F00; - font-size: 32px; - font-weight: bold; - text-shadow: 1px 1px 1px rgba(0,0,0,0.1); -} -#msCell_per{} -#msCell_csq{} -#msCell_rssi{} -#msCell_rscp{} -#msCell_ecio{} - -#rooterSplashStatus .level_0{ - color: #0F0; // green -} -#rooterSplashStatus .level_1{ - color: #0CB; // green blue -} -#rooterSplashStatus .level_2{ - color: #00F; // blue -} -#rooterSplashStatus .level_3{ - color: #F0F; // violet -} -#rooterSplashStatus .level_4{ - color: #F80; // orange -} -#rooterSplashStatus .level_5{ - color: #F00; // red -} -#rooterSplashStatus .level_6{ - color: #FF0; // yellow -} - -/* @end */ - - -/* Easy Color changer ------------- */ - -.rooterPageHead{ - /*background: #55F;*/ -} -.rooterItemTitle .icon, -#rooterSplashStatus h3{ - color: #55F; -} - - - diff --git a/rooter/0splash/splash/files/www/luci-static/rooter/fonts/icomoon_splash.eot b/rooter/0splash/splash/files/www/luci-static/rooter/fonts/icomoon_splash.eot deleted file mode 100644 index 29cd4d1..0000000 Binary files a/rooter/0splash/splash/files/www/luci-static/rooter/fonts/icomoon_splash.eot and /dev/null differ diff --git a/rooter/0splash/splash/files/www/luci-static/rooter/fonts/icomoon_splash.svg b/rooter/0splash/splash/files/www/luci-static/rooter/fonts/icomoon_splash.svg deleted file mode 100644 index dc2127b..0000000 --- a/rooter/0splash/splash/files/www/luci-static/rooter/fonts/icomoon_splash.svg +++ /dev/null @@ -1,22 +0,0 @@ - - - -Generated by IcoMoon - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/rooter/0splash/splash/files/www/luci-static/rooter/fonts/icomoon_splash.ttf b/rooter/0splash/splash/files/www/luci-static/rooter/fonts/icomoon_splash.ttf deleted file mode 100644 index 4e27645..0000000 Binary files a/rooter/0splash/splash/files/www/luci-static/rooter/fonts/icomoon_splash.ttf and /dev/null differ diff --git a/rooter/0splash/splash/files/www/luci-static/rooter/fonts/icomoon_splash.woff b/rooter/0splash/splash/files/www/luci-static/rooter/fonts/icomoon_splash.woff deleted file mode 100644 index 63f5413..0000000 Binary files a/rooter/0splash/splash/files/www/luci-static/rooter/fonts/icomoon_splash.woff and /dev/null differ diff --git a/rooter/0splash/splash/files/www/luci-static/rooter/img/favicon.gif b/rooter/0splash/splash/files/www/luci-static/rooter/img/favicon.gif deleted file mode 100644 index bfbe292..0000000 Binary files a/rooter/0splash/splash/files/www/luci-static/rooter/img/favicon.gif and /dev/null differ diff --git a/rooter/0splash/splash/files/www/luci-static/rooter/img/kangaroo_800.png b/rooter/0splash/splash/files/www/luci-static/rooter/img/kangaroo_800.png deleted file mode 100644 index 478fa6d..0000000 Binary files a/rooter/0splash/splash/files/www/luci-static/rooter/img/kangaroo_800.png and /dev/null differ diff --git a/rooter/0splash/splash/files/www/splash.html b/rooter/0splash/splash/files/www/splash.html deleted file mode 100644 index 21de451..0000000 --- a/rooter/0splash/splash/files/www/splash.html +++ /dev/null @@ -1,101 +0,0 @@ - - - - Home - ROOter - - - - - - - - - - - - - - - - - - - -
                          - -
                          - -
                          The ROOter Project
                          -
                          -
                          - - - -
                          -
                          - -
                          -
                          - ROOter Splash Page by Soif and Dairyman -
                          -
                          - - - - diff --git a/rooter/0splash/splash/files/www/splash_files/cellular.png b/rooter/0splash/splash/files/www/splash_files/cellular.png deleted file mode 100644 index 953bf08..0000000 Binary files a/rooter/0splash/splash/files/www/splash_files/cellular.png and /dev/null differ diff --git a/rooter/0splash/splash/files/www/splash_files/check.gif b/rooter/0splash/splash/files/www/splash_files/check.gif deleted file mode 100644 index 75b945d..0000000 Binary files a/rooter/0splash/splash/files/www/splash_files/check.gif and /dev/null differ diff --git a/rooter/0splash/splash/files/www/splash_files/check.jpg b/rooter/0splash/splash/files/www/splash_files/check.jpg deleted file mode 100644 index f1fb739..0000000 Binary files a/rooter/0splash/splash/files/www/splash_files/check.jpg and /dev/null differ diff --git a/rooter/0splash/splash/files/www/splash_files/forum.png b/rooter/0splash/splash/files/www/splash_files/forum.png deleted file mode 100644 index 9e8b8c2..0000000 Binary files a/rooter/0splash/splash/files/www/splash_files/forum.png and /dev/null differ diff --git a/rooter/0splash/splash/files/www/splash_files/home.png b/rooter/0splash/splash/files/www/splash_files/home.png deleted file mode 100644 index 38687c7..0000000 Binary files a/rooter/0splash/splash/files/www/splash_files/home.png and /dev/null differ diff --git a/rooter/0splash/splash/files/www/splash_files/kanga1.png b/rooter/0splash/splash/files/www/splash_files/kanga1.png deleted file mode 100644 index 7f3420e..0000000 Binary files a/rooter/0splash/splash/files/www/splash_files/kanga1.png and /dev/null differ diff --git a/rooter/0splash/splash/files/www/splash_files/openwrt.png b/rooter/0splash/splash/files/www/splash_files/openwrt.png deleted file mode 100644 index 0bec4c2..0000000 Binary files a/rooter/0splash/splash/files/www/splash_files/openwrt.png and /dev/null differ diff --git a/rooter/0splash/splash/files/www/splash_files/rooter.png b/rooter/0splash/splash/files/www/splash_files/rooter.png deleted file mode 100644 index be8099f..0000000 Binary files a/rooter/0splash/splash/files/www/splash_files/rooter.png and /dev/null differ diff --git a/rooter/0splash/splash/files/www/status.html b/rooter/0splash/splash/files/www/status.html deleted file mode 100644 index 930709f..0000000 --- a/rooter/0splash/splash/files/www/status.html +++ /dev/null @@ -1,254 +0,0 @@ - - - - Live Network Status - - - - - - - - - - - - - - - -
                          -
                          ROOter Live Network Status
                          -
                          - -
                          - - - - - - - -
                          Enter your credentials :
                          - -
                          -

                          0 sec
                          - Signal

                          - -
                          -
                          -
                          Strength (%)
                          - - -
                          -
                          -
                          CSQ
                          - - -
                          -
                          -
                          RSSI (dBm)
                          - - -
                          -
                          -
                          RSCP (dBm) RSRP
                          - - -
                          -
                          -
                          ECIO (dB) RSRQ
                          - - -
                          -
                          -
                          - -
                          -

                          Network -

                          - -
                          -
                          -
                          Mode
                          - - -
                          -
                          -
                          MCC
                          - - -
                          -
                          -
                          MNC
                          - - -
                          -
                          -
                          RNC/eNB ID
                          - - - -
                          - -
                          -
                          LAC
                          - - - -
                          -
                          -
                          Cell ID
                          - - -
                          -
                          -
                          Channel
                          - - -
                          -
                          -
                          Bands
                          - - -
                          -
                          -
                          - -
                          -

                          Device -

                          - -
                          -
                          -
                          Modem
                          - - -
                          -
                          -
                          Protocol
                          - - -
                          -
                          -
                          Port
                          - - -
                          -
                          -
                          Temperature
                          - - -
                          -
                          -
                          - -
                          - -
                          -
                          - -
                          -
                          -
                          M2M Wireless -- Your Wireless Connection
                          -
                          -
                          - - - diff --git a/rooter/0splash/status/Makefile b/rooter/0splash/status/Makefile deleted file mode 100644 index 7bb30c0..0000000 --- a/rooter/0splash/status/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -#Owned by DairyMan@Whirlpool -# -#Copyright GNU act. -include $(TOPDIR)/rules.mk - -PKG_NAME:=status -PKG_VERSION:=1.000 -PKG_RELEASE:=1 - -PKG_MAINTAINER:=Created by DM/makefile by Cobia@whirlpool -include $(INCLUDE_DIR)/package.mk - -define Package/status - SECTION:=utils - CATEGORY:=ROOter - SUBMENU:=Splash Screens - TITLE:=Added scripts for Status Splash screen - PKGARCH:=all -endef - -define Package/status/description - Added scripts for Status Splash screen -endef - - -define Build/Compile -endef - -define Package/status/install - $(CP) ./files/* $(1)/ - - -endef - -$(eval $(call BuildPackage,status)) diff --git a/rooter/0splash/status/files/etc/config/splash b/rooter/0splash/status/files/etc/config/splash deleted file mode 100644 index 1d6102f..0000000 --- a/rooter/0splash/status/files/etc/config/splash +++ /dev/null @@ -1,4 +0,0 @@ -config settings 'settings' - option enabled '1' - option full '1' - \ No newline at end of file diff --git a/rooter/0splash/status/files/usr/lib/lua/luci/controller/splashset.lua b/rooter/0splash/status/files/usr/lib/lua/luci/controller/splashset.lua deleted file mode 100644 index 7500383..0000000 --- a/rooter/0splash/status/files/usr/lib/lua/luci/controller/splashset.lua +++ /dev/null @@ -1,11 +0,0 @@ ---[[ -luci-app-argon-config -]]-- - -module("luci.controller.splashset", package.seeall) - -function index() - if nixio.fs.access("/etc/config/splash") then - entry({"admin", "theme", "splashset"}, cbi("splash"), _("Splash Screen"), 71) - end -end diff --git a/rooter/0splash/status/files/usr/lib/lua/luci/model/cbi/splash.lua b/rooter/0splash/status/files/usr/lib/lua/luci/model/cbi/splash.lua deleted file mode 100644 index b36dc8b..0000000 --- a/rooter/0splash/status/files/usr/lib/lua/luci/model/cbi/splash.lua +++ /dev/null @@ -1,22 +0,0 @@ -local fs = require "nixio.fs" -local sys = require "luci.sys" -local uci = require "luci.model.uci".cursor() -require("luci.util") -require("luci.model.ipkg") - -local m = Map("splash", translate("Splash Screen"), translate("Enable/disable Splash Screen")) - -m.on_after_save = function(self) - luci.sys.call("/usr/lib/splash/splash.sh &") -end - -gwx = m:section(TypedSection, "settings", translate("Management")) -gwx.anonymous = true - - -bl = gwx:option(ListValue, "enabled", "Enable Splash Screen :"); -bl:value("0", "Disabled") -bl:value("1", "Enabled") -bl.default=0 - -return m \ No newline at end of file diff --git a/rooter/0splash/status/files/usr/lib/splash/check.gif b/rooter/0splash/status/files/usr/lib/splash/check.gif deleted file mode 100644 index 75b945d..0000000 Binary files a/rooter/0splash/status/files/usr/lib/splash/check.gif and /dev/null differ diff --git a/rooter/0splash/status/files/usr/lib/splash/full.gif b/rooter/0splash/status/files/usr/lib/splash/full.gif deleted file mode 100644 index 75b945d..0000000 Binary files a/rooter/0splash/status/files/usr/lib/splash/full.gif and /dev/null differ diff --git a/rooter/0splash/status/files/usr/lib/splash/splash.sh b/rooter/0splash/status/files/usr/lib/splash/splash.sh deleted file mode 100644 index 6b1cca7..0000000 --- a/rooter/0splash/status/files/usr/lib/splash/splash.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -log() { - logger -t "Splash Screen : " "$@" -} - -sleep 5 - -ENB=$(uci get splash.settings.enabled) -FULL=$(uci get splash.settings.full) - -if [ $ENB = "0" ]; then - rm -f /www/splash_files/check.gif - rm -f /www/splash_files/full.gif -else - cp /usr/lib/splash/check.gif /www/splash_files - rm -f /www/splash_files/full.gif - if [ $FULL = "1" ]; then - cp /usr/lib/splash/full.gif /www/splash_files - fi -fi \ No newline at end of file diff --git a/rooter/0splash/status/files/www/luci-static/rooter/css/iconmoon_splash.css b/rooter/0splash/status/files/www/luci-static/rooter/css/iconmoon_splash.css deleted file mode 100644 index 5254b92..0000000 --- a/rooter/0splash/status/files/www/luci-static/rooter/css/iconmoon_splash.css +++ /dev/null @@ -1,69 +0,0 @@ -@font-face { - font-family: 'icomoon_splash'; - src: url('../fonts/icomoon_splash.eot?vja16g'); - src: url('../fonts/icomoon_splash.eot?vja16g#iefix') format('embedded-opentype'), - url('../fonts/icomoon_splash.ttf?vja16g') format('truetype'), - url('../fonts/icomoon_splash.woff?vja16g') format('woff'), - url('../fonts/icomoon_splash.svg?vja16g#icomoon_splash') format('svg'); - font-weight: normal; - font-style: normal; -} - -[class^="icon-"], [class*=" icon-"] { - /* use !important to prevent issues with browser extensions that change fonts */ - font-family: 'icomoon_splash' !important; - speak: none; - font-style: normal; - font-weight: normal; - font-variant: normal; - text-transform: none; - line-height: 1; - - /* Better Font Rendering =========== */ - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - - -.icon-power-off:before { - content: "\f011"; -} -.icon-signal:before { - content: "\f012"; -} -.icon-cog:before { - content: "\f013"; -} -.icon-gear:before { - content: "\f013"; -} -.icon-home:before { - content: "\f015"; -} -.icon-exclamation-triangle:before { - content: "\f071"; -} -.icon-warning:before { - content: "\f071"; -} -.icon-comments:before { - content: "\f086"; -} -.icon-hdd-o:before { - content: "\f0a0"; -} -.icon-plug:before { - content: "\f1e6"; -} -.icon-wifi:before { - content: "\f1eb"; -} -.icon-connection:before { - content: "\e91b"; -} -.icon-podcast:before { - content: "\e91c"; -} -.icon-earth:before { - content: "\e9ca"; -} diff --git a/rooter/0splash/status/files/www/luci-static/rooter/css/splash.css b/rooter/0splash/status/files/www/luci-static/rooter/css/splash.css deleted file mode 100644 index bafcc6c..0000000 --- a/rooter/0splash/status/files/www/luci-static/rooter/css/splash.css +++ /dev/null @@ -1,311 +0,0 @@ -/* @override http://src.dev.lo.lo/ROOter/www/luci-static/rooter/css/splash.css */ - -/* - CSS for ROOter splash pages - Copyright Francois Dechery - https://github.com/soif -*/ - -/* @group Splash Pages ---------------------------------------------------*/ - -.rooterSplash{ - padding: 0; - background: #F0F0F0; -} -.rooterPageHead{ - background: #55F; - padding: 10px 5px; - background: rgb(140,140,255); - background: -moz-linear-gradient(top, rgba(140,140,255,1) 0%, rgba(85,85,255,1) 100%); - background: -webkit-linear-gradient(top, rgba(140,140,255,1) 0%,rgba(85,85,255,1) 100%); - background: linear-gradient(to bottom, rgba(140,140,255,1) 0%,rgba(85,85,255,1) 100%); - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#8c8cff', endColorstr='#5555ff',GradientType=0 ); - border-bottom: 1px solid rgba(0,0,0,0.7); - -} -.rooterPageContent{ - border-top: 1px solid rgba(255,255,255,0.8); - border-bottom: 1px solid rgba(0,0,0, 0.1); - padding: 25px 10px; - max-width: 1200px; - margin: auto; -} -.rooterHeadTitle{ - color: #fff; - text-align: center; - font-family: Georgia, "Times New Roman", Times, serif; - font-size: 32px; - line-height: 120%; - text-shadow: -1px -1px 2px rgba(0,0,0,0.5); -} -.rooterPageFoot{ - border-top: 1px solid rgba(255,255,255,0.8); - margin-top: 20px; - padding: 10px 10px; - max-width: 950px; - margin: auto; - font-size: 16px; -} -.rooterFootMenu{ - float: left; - margin-bottom: 10px; -} -.rooterFootMenu A{ - text-decoration: none; -} -.rooterFootMenu A:hover{ - color: #000; -} -.rooterFootMenu UL{ - padding: 0; - margin: 0; - overflow: hidden; - display: inline-block; -} -.rooterFootMenu LI{ - float: left; - padding: 0; - margin: 0; - list-style: none; -} -.rooterFootMenu LI A{ - padding: 0 10px; - color: #555; -} -.rooterFootMenu LI:first-child A{ - padding-left: 0; -} -.rooterFootCredits{ - float: right; - padding: 0; - margin: 0; - color: #999; - text-align: right; -} -.rooterFootCredits A{ - color: #777; -} -/* @end */ - - - - -/* @group Page: Home ---------------------------------------------------*/ - - -/* @group Logo -++++++++++++++++++ */ -.rooterHeadBox{ - font-size: 50px; - font-family: Georgia, "Times New Roman", Times, serif; - color: #fff; - line-height: 100%; - overflow: hidden; - width: 700px; - margin: auto; - padding-top: 10px; - opacity: 0; -} -.rooterLogo{ - background: url("../img/kangaroo_800.png") no-repeat; - background-size: 100%; - float: left; - height: 110px; - width: 250px; - opacity: 0.4; -} -.rooterTagline{ - margin-left: 100px; - padding-left: 10px; - text-shadow: 2px 2px 3px rgba(0,0,0,0.3); -} - -/* @end */ - -@media only screen and (max-width: 600px) { - .rooterHeadBox{ - text-align: center; - width: auto; - } - .rooterLogo{ - display: inline-block; - float: none; - } - .rooterTagline { - display: none; - } - .rooterFootCredits, - .rooterFootMenu{ - float: none; - text-align: center; - } -} - -#rooterItems{ - clear: both; - max-width: 800px ; - margin: auto; -} -.rooterItem{ - overflow: hidden; - border: 1px solid #EEE; - border-color: #EEE #DDD #DDD #EEE; - padding: 20px 15px; - margin-bottom: 20px; - border-radius: 8px; - background-color: #fff; -} -.rooterItem:hover{ - background-color: #F3F3FF; - border-color: #AAA; -} -.rooterItemTitle{ - float: left; - font-size: 18px; - font-weight: bold; - padding-right: 10px; - color: #000; - line-height: 2em; -} -.rooterItemTitle .icon{ - color: #55F; - margin-right: 8px; - font-size: 2em; - vertical-align: middle; -} -#rooterItems A{ - text-decoration: none; -} -.rooterItemDesc{ - font-size: 14px; - color: #777; - margin-left: 220px; - margin-top: 0.7em; -} -/* @end */ - - - -/* @group Page: Status ---------------------------------------------------*/ - -.modemStatusBlock{ - margin-bottom: 30px; -} -#rooterSplashStatus h3{ - clear:both; - font-size: 18px; - color: #55F; -} -#rooterSplashStatus h3 .icon{ - margin-right: 3px; -} -#rooterSplashStatus h3 .msCell{ - color: #666; -} -.modemStatusRow{ - clear:both; - padding-bottom: 20px; - overflow: hidden; -} -.modemStatusRow .msTitle{ - border-radius: 2px 2px 0 0; - padding: 5px 5px ; - background: #484848; - color: #fff; - background: rgb(99,99,99); - background: -moz-linear-gradient(top, rgba(99,99,99,1) 0%, rgba(72,72,72,1) 100%); - background: -webkit-linear-gradient(top, rgba(99,99,99,1) 0%,rgba(72,72,72,1) 100%); - background: linear-gradient(to bottom, rgba(99,99,99,1) 0%,rgba(72,72,72,1) 100%); - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#636363', endColorstr='#484848',GradientType=0 ); -} -.modemStatusRow .msCell{ - border-radius: 10px; - display: inline-block; - margin-top: 10px; - float:left; - border: 1px solid #ccc; - padding-bottom: 5px; - background: #fff; - -} -.modemStatusRow1 .msCell{ - width: 176px; - margin: 10px 5px 0 5px; - text-align: center; -} -.modemStatusRow1 SPAN B{ - font-weight: bold; - font-size: 70px; - line-height: 110%; - text-shadow: 1px 1px 1px rgba(0,0,0,0.4); -} -.modemStatusRow1 .msDesc{ - color: #000; - font-size: 12px; -} -.modemStatusRow2 .msCell{ - margin: 10px 5px; - text-align: center; -} -.modemStatusRow2 SPAN{ - display: inline-block; - padding: 5px 5px ; - font-size: 14px; -} -#counter_div{ - color: #000; - font-weight: normal; - font-size: 14px; -} -#counter_val{ - color: #F00; - font-size: 32px; - font-weight: bold; - text-shadow: 1px 1px 1px rgba(0,0,0,0.1); -} -#msCell_per{} -#msCell_csq{} -#msCell_rssi{} -#msCell_rscp{} -#msCell_ecio{} - -#rooterSplashStatus .level_0{ - color: #0F0; // green -} -#rooterSplashStatus .level_1{ - color: #0CB; // green blue -} -#rooterSplashStatus .level_2{ - color: #00F; // blue -} -#rooterSplashStatus .level_3{ - color: #F0F; // violet -} -#rooterSplashStatus .level_4{ - color: #F80; // orange -} -#rooterSplashStatus .level_5{ - color: #F00; // red -} -#rooterSplashStatus .level_6{ - color: #FF0; // yellow -} - -/* @end */ - - -/* Easy Color changer ------------- */ - -.rooterPageHead{ - /*background: #55F;*/ -} -.rooterItemTitle .icon, -#rooterSplashStatus h3{ - color: #55F; -} - - - diff --git a/rooter/0splash/status/files/www/luci-static/rooter/fonts/icomoon_splash.eot b/rooter/0splash/status/files/www/luci-static/rooter/fonts/icomoon_splash.eot deleted file mode 100644 index 29cd4d1..0000000 Binary files a/rooter/0splash/status/files/www/luci-static/rooter/fonts/icomoon_splash.eot and /dev/null differ diff --git a/rooter/0splash/status/files/www/luci-static/rooter/fonts/icomoon_splash.svg b/rooter/0splash/status/files/www/luci-static/rooter/fonts/icomoon_splash.svg deleted file mode 100644 index dc2127b..0000000 --- a/rooter/0splash/status/files/www/luci-static/rooter/fonts/icomoon_splash.svg +++ /dev/null @@ -1,22 +0,0 @@ - - - -Generated by IcoMoon - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/rooter/0splash/status/files/www/luci-static/rooter/fonts/icomoon_splash.ttf b/rooter/0splash/status/files/www/luci-static/rooter/fonts/icomoon_splash.ttf deleted file mode 100644 index 4e27645..0000000 Binary files a/rooter/0splash/status/files/www/luci-static/rooter/fonts/icomoon_splash.ttf and /dev/null differ diff --git a/rooter/0splash/status/files/www/luci-static/rooter/fonts/icomoon_splash.woff b/rooter/0splash/status/files/www/luci-static/rooter/fonts/icomoon_splash.woff deleted file mode 100644 index 63f5413..0000000 Binary files a/rooter/0splash/status/files/www/luci-static/rooter/fonts/icomoon_splash.woff and /dev/null differ diff --git a/rooter/0splash/status/files/www/luci-static/rooter/img/favicon.gif b/rooter/0splash/status/files/www/luci-static/rooter/img/favicon.gif deleted file mode 100644 index bfbe292..0000000 Binary files a/rooter/0splash/status/files/www/luci-static/rooter/img/favicon.gif and /dev/null differ diff --git a/rooter/0splash/status/files/www/luci-static/rooter/img/kangaroo_800.png b/rooter/0splash/status/files/www/luci-static/rooter/img/kangaroo_800.png deleted file mode 100644 index 478fa6d..0000000 Binary files a/rooter/0splash/status/files/www/luci-static/rooter/img/kangaroo_800.png and /dev/null differ diff --git a/rooter/0splash/status/files/www/splash.html b/rooter/0splash/status/files/www/splash.html deleted file mode 100644 index df6f0af..0000000 --- a/rooter/0splash/status/files/www/splash.html +++ /dev/null @@ -1,264 +0,0 @@ - - - - Live Network Status - - - - - - - - - - - - - - - -
                          -
                          ROOter Live Network Status
                          -
                          - -
                          - - - - - - - -
                          Enter your password :
                          - - - -
                          -

                          0 sec
                          - Signal

                          - -
                          -
                          -
                          Strength (%)
                          - - -
                          -
                          -
                          CSQ
                          - - -
                          -
                          -
                          RSSI (dBm)
                          - - -
                          -
                          -
                          RSCP (dBm) RSRP
                          - - -
                          -
                          -
                          ECIO (dB) RSRQ
                          - - -
                          -
                          -
                          SINR (dB)
                          - - -
                          -
                          -
                          - -
                          -

                          Network -

                          - -
                          -
                          -
                          Mode
                          - - -
                          -
                          -
                          MCC
                          - - -
                          -
                          -
                          MNC
                          - - -
                          -
                          -
                          RNC/eNB ID
                          - - - -
                          - -
                          -
                          LAC
                          - - - -
                          -
                          -
                          Cell ID
                          - - -
                          -
                          -
                          Channel
                          - - -
                          -
                          -
                          Bands
                          - - -
                          -
                          -
                          - -
                          -

                          Device -

                          - -
                          -
                          -
                          Modem
                          - - -
                          -
                          -
                          Protocol
                          - - -
                          -
                          -
                          Port
                          - - -
                          -
                          -
                          Temperature
                          - - -
                          -
                          -
                          - -
                          - -
                          -
                          - ROOter Splash Page by Soif and Dairyman -
                          -
                          - - - diff --git a/rooter/0splash/status/files/www/splash_files/cellular.png b/rooter/0splash/status/files/www/splash_files/cellular.png deleted file mode 100644 index 953bf08..0000000 Binary files a/rooter/0splash/status/files/www/splash_files/cellular.png and /dev/null differ diff --git a/rooter/0splash/status/files/www/splash_files/check.gif b/rooter/0splash/status/files/www/splash_files/check.gif deleted file mode 100644 index 75b945d..0000000 Binary files a/rooter/0splash/status/files/www/splash_files/check.gif and /dev/null differ diff --git a/rooter/0splash/status/files/www/splash_files/check.jpg b/rooter/0splash/status/files/www/splash_files/check.jpg deleted file mode 100644 index f1fb739..0000000 Binary files a/rooter/0splash/status/files/www/splash_files/check.jpg and /dev/null differ diff --git a/rooter/0splash/status/files/www/splash_files/forum.png b/rooter/0splash/status/files/www/splash_files/forum.png deleted file mode 100644 index 9e8b8c2..0000000 Binary files a/rooter/0splash/status/files/www/splash_files/forum.png and /dev/null differ diff --git a/rooter/0splash/status/files/www/splash_files/full.gif b/rooter/0splash/status/files/www/splash_files/full.gif deleted file mode 100644 index 75b945d..0000000 Binary files a/rooter/0splash/status/files/www/splash_files/full.gif and /dev/null differ diff --git a/rooter/0splash/status/files/www/splash_files/home.png b/rooter/0splash/status/files/www/splash_files/home.png deleted file mode 100644 index 38687c7..0000000 Binary files a/rooter/0splash/status/files/www/splash_files/home.png and /dev/null differ diff --git a/rooter/0splash/status/files/www/splash_files/kanga1.png b/rooter/0splash/status/files/www/splash_files/kanga1.png deleted file mode 100644 index 7f3420e..0000000 Binary files a/rooter/0splash/status/files/www/splash_files/kanga1.png and /dev/null differ diff --git a/rooter/0splash/status/files/www/splash_files/openwrt.png b/rooter/0splash/status/files/www/splash_files/openwrt.png deleted file mode 100644 index 0bec4c2..0000000 Binary files a/rooter/0splash/status/files/www/splash_files/openwrt.png and /dev/null differ diff --git a/rooter/0splash/status/files/www/splash_files/rooter.png b/rooter/0splash/status/files/www/splash_files/rooter.png deleted file mode 100644 index be8099f..0000000 Binary files a/rooter/0splash/status/files/www/splash_files/rooter.png and /dev/null differ diff --git a/rooter/0splash/status/files/www/splashfull.html b/rooter/0splash/status/files/www/splashfull.html deleted file mode 100644 index 1624809..0000000 --- a/rooter/0splash/status/files/www/splashfull.html +++ /dev/null @@ -1,101 +0,0 @@ - - - - Home - ROOter - - - - - - - - - - - - - - - - - - - -
                          - -
                          - -
                          The ROOter Project
                          -
                          -
                          - - - -
                          -
                          - -
                          -
                          - ROOter Splash Page by Soif and Dairyman -
                          -
                          - - - - diff --git a/rooter/0splash/status/files/www/statusfull.html b/rooter/0splash/status/files/www/statusfull.html deleted file mode 100644 index 6e37899..0000000 --- a/rooter/0splash/status/files/www/statusfull.html +++ /dev/null @@ -1,271 +0,0 @@ - - - - Live Network Status - - - - - - - - - - - - - - - -
                          -
                          ROOter Live Network Status
                          -
                          - -
                          - - - - - - - -
                          Enter your password :
                          - - - -
                          -

                          0 sec
                          - Signal

                          - -
                          -
                          -
                          Strength (%)
                          - - -
                          -
                          -
                          CSQ
                          - - -
                          -
                          -
                          RSSI (dBm)
                          - - -
                          -
                          -
                          RSCP (dBm) RSRP
                          - - -
                          -
                          -
                          ECIO (dB) RSRQ
                          - - -
                          -
                          -
                          SINR (dB)
                          - - -
                          -
                          -
                          - -
                          -

                          Network -

                          - -
                          -
                          -
                          Mode
                          - - -
                          -
                          -
                          MCC
                          - - -
                          -
                          -
                          MNC
                          - - -
                          -
                          -
                          RNC/eNB ID
                          - - - -
                          - -
                          -
                          LAC
                          - - - -
                          -
                          -
                          Cell ID
                          - - -
                          -
                          -
                          Channel
                          - - -
                          -
                          -
                          Bands
                          - - -
                          -
                          -
                          - -
                          -

                          Device -

                          - -
                          -
                          -
                          Modem
                          - - -
                          -
                          -
                          Protocol
                          - - -
                          -
                          -
                          Port
                          - - -
                          -
                          -
                          Temperature
                          - - -
                          -
                          -
                          - -
                          - -
                          -
                          - -
                          -
                          - ROOter Splash Page by Soif and Dairyman -
                          -
                          - - - diff --git a/rooter/ext-rooter-basic/Makefile b/rooter/ext-rooter-basic/Makefile deleted file mode 100644 index fe3e528..0000000 --- a/rooter/ext-rooter-basic/Makefile +++ /dev/null @@ -1,43 +0,0 @@ -#Owned by DairyMan@Whirlpool -# -#Copyright GNU act. -include $(TOPDIR)/rules.mk - -PKG_NAME:=ext-rooter-basic -PKG_VERSION:=4.500 -PKG_RELEASE:=1 - -PKG_MAINTAINER:=Created by DM/makefile by Cobia@whirlpool -include $(INCLUDE_DIR)/package.mk - -# +kmod-rt2800-usb - -define Package/ext-rooter-basic - SECTION:=utils - CATEGORY:=ROOter - SUBMENU:=Basic Support - DEPENDS:=+luci-compat +kmod-usb-net +kmod-usb-net-huawei-cdc-ncm +kmod-usb-net-cdc-ether +kmod-usb-acm \ - +kmod-usb-net-qmi-wwan +kmod-usb-net-rndis +kmod-usb-serial-qualcomm \ - +kmod-usb-net-sierrawireless +kmod-usb-ohci +kmod-usb-serial +kmod-nls-utf8 \ - +kmod-usb-serial-option +kmod-usb-serial-sierrawireless +luci-proto-3x \ - +kmod-usb-uhci +kmod-usb2 +luci-proto-3g +luci-theme-bootstrap \ - +usb-modeswitch +wireless-tools +rmbim +rqmi +ext-sms +ext-buttons - TITLE:=ROOter support for usbmodems - PKGARCH:=all -endef - -define Package/ext-rooter-basic/description - Helper scripts to enable ROOter to manage usb modem interfaces -endef - - -define Build/Compile -endef - -define Package/ext-rooter-basic/install - $(CP) ./files/* $(1)/ - - -endef - -$(eval $(call BuildPackage,ext-rooter-basic)) diff --git a/rooter/ext-rooter-basic/files/etc/codename b/rooter/ext-rooter-basic/files/etc/codename deleted file mode 100644 index 252dcda..0000000 --- a/rooter/ext-rooter-basic/files/etc/codename +++ /dev/null @@ -1 +0,0 @@ -CODENAME="GoldenOrb-Version-1" \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/etc/config/custom b/rooter/ext-rooter-basic/files/etc/config/custom deleted file mode 100644 index 67d0a8e..0000000 --- a/rooter/ext-rooter-basic/files/etc/config/custom +++ /dev/null @@ -1,64 +0,0 @@ - -config bwallocate 'bwallocate' - option rollover '1' - option allocate '1000' - option password '1234' - option lock '0' - option enabled '0' - -config texting 'texting' - option text '0' - option phone '1222333444' - option time '72' - option ident 'John Doe' - option method '0' - option days '1' - option increment '50' - option used '0' - option tore '0' - -config menu 'menu' - option password '1234' - option full '0' - option enabled '0' - option default '0' - -config atcmd 'atcmd' - option lock '0' - option enabled '1' - option password '1234' - option sierra '/etc/sierracmd' - option quectel '/etc/quectelcmd' - option generic '/etc/genericcmd' - -config bandlock 'bandlock' - option enabled '1' - option cenable1 '0' - option earfcn1 '0' - option pci1 '0' - -config zerotier 'zerotier' - option password '1234' - option lock '0' - option networkid 'xxxxxxxxxxxxxxxx' - -config logo 'logo' - option size 'large' - -config connect 'connect' - option ipv6 '1' - -config profile 'profile' - option save '0' - -config multi 'multiuser' - option multi '0' - option root '0' - -config bwday 'bwday' - option bwday '0' - option phone '0' - option delay '8' - -config simpin 'simpin' - option pin '' \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/etc/config/modem b/rooter/ext-rooter-basic/files/etc/config/modem deleted file mode 100644 index 617a570..0000000 --- a/rooter/ext-rooter-basic/files/etc/config/modem +++ /dev/null @@ -1,18 +0,0 @@ - -config info 'general' - option modemnum '1' - option max '6' - -config new 'customize' - -config modem 'modem1' - option empty '1' - -config minfo1 'modeminfo1' - -config modem 'modem2' - option empty '1' - -config minfo2 'modeminfo2' - - diff --git a/rooter/ext-rooter-basic/files/etc/config/profile b/rooter/ext-rooter-basic/files/etc/config/profile deleted file mode 100644 index 42bafa1..0000000 --- a/rooter/ext-rooter-basic/files/etc/config/profile +++ /dev/null @@ -1,19 +0,0 @@ - -config default 'default' - option auth '0' - option ppp '0' - option lock '0' - option log '0' - option lb '1' - option alive '0' - option delay '5' - option at '0' - option apn 'internet' - option tzone '0' - option nodhcp '0' - option pdptype '0' - -config disable 'disable' - option enabled '0' - -config simpin 'simpin' \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/etc/config/ttl b/rooter/ext-rooter-basic/files/etc/config/ttl deleted file mode 100644 index e7e7367..0000000 --- a/rooter/ext-rooter-basic/files/etc/config/ttl +++ /dev/null @@ -1,11 +0,0 @@ - -config ttl 'ttl' - option enabled '0' - option value '65' - -config hotspot 'hotspot' - option enable '0' - option oldenable '0' - option amt '10000' - option total '0' - diff --git a/rooter/ext-rooter-basic/files/etc/genericcmd b/rooter/ext-rooter-basic/files/etc/genericcmd deleted file mode 100644 index b6b15bc..0000000 --- a/rooter/ext-rooter-basic/files/etc/genericcmd +++ /dev/null @@ -1,4 +0,0 @@ -AT+CRSM=176,12258,0,0,10 -ICCID -at+csq -Signal Information diff --git a/rooter/ext-rooter-basic/files/etc/header_msg b/rooter/ext-rooter-basic/files/etc/header_msg deleted file mode 100644 index e3f2398..0000000 --- a/rooter/ext-rooter-basic/files/etc/header_msg +++ /dev/null @@ -1,4 +0,0 @@ - -/img/header.png -/img/rosy.png -/img/tomato.png \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/etc/hotplug.d/iface/10-lan b/rooter/ext-rooter-basic/files/etc/hotplug.d/iface/10-lan deleted file mode 100644 index 3512e42..0000000 --- a/rooter/ext-rooter-basic/files/etc/hotplug.d/iface/10-lan +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh - -logger -t URL-DEBUG "hotplug (iface): action='$ACTION' interface='$INTERFACE'" - -if [ "$ACTION" = ifup -a "$INTERFACE" = "lan" ]; then - IP=$(uci get network.lan.ipaddr) - ipaddr=$(cat /etc/dnsmasq.conf | grep "address=/rooter.local/") - if [ ! -z $ipaddr ]; then - ipaddr=$(echo "$ipaddr" | sed -e "s!address=/rooter.local/!!g") - if [ $ipaddr != $IP ]; then - cp -f /etc/dnsmasq.conf /etc/dnsmasq.conf.bk - sed /"#StartURL"/,/"#EndURL"/d /etc/dnsmasq.conf.bk > /etc/dnsmasq.conf - rm -f /etc/dnsmasq.conf.bk - echo "#StartURL" >> /etc/dnsmasq.conf - echo "address=/rooter.local/$IP" >> /etc/dnsmasq.conf - echo "address=/www.rooter.local/$IP" >> /etc/dnsmasq.conf - echo "#EndURL" >> /etc/dnsmasq.conf - /etc/init.d/dnsmasq restart - fi - else - echo "#StartURL" >> /etc/dnsmasq.conf - echo "address=/rooter.local/$IP" >> /etc/dnsmasq.conf - echo "address=/www.rooter.local/$IP" >> /etc/dnsmasq.conf - echo "#EndURL" >> /etc/dnsmasq.conf - /etc/init.d/dnsmasq restart - fi -fi \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/etc/hotplug.d/iface/19-rooter b/rooter/ext-rooter-basic/files/etc/hotplug.d/iface/19-rooter deleted file mode 100644 index e0ecea9..0000000 --- a/rooter/ext-rooter-basic/files/etc/hotplug.d/iface/19-rooter +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh -# -# /etc/hotplug.d/iface/19-rooter -# - -log() { - logger -t "19-ROOTER" "$@" -} - -for I in `seq 1 $(uci get modem.general.modemnum)` -do - IFACE="wan"$I - - [ "$ACTION" = ifup -o "$ACTION" = ifupdate ] || exit 0 - if [ ${INTERFACE} = "$IFACE" ]; then - if [ ${ACTION} = "ifup" ]; then - # TTL fix - if [ 1 = 0 ]; then - ttl=$(uci -q get modem.modeminfo$I.ttl) - if [ -z $ttl ]; then - ttl=0 - fi - if [ $ttl -eq 0 ]; then - ENB=$(uci get ttl.ttl.enabled) - if [ ! -z "$ENB" ]; then - #exst=$(cat /etc/firewall.user | grep " mangle .* $DEVICE " | wc -l) - #[ "$exst" -eq 4 ] || /usr/lib/custom/ttlx.sh - /usr/lib/custom/ttlx.sh - fi - fi - fi - MTU=$(uci get modem.modeminfo$I.mtu) - if [ -z $MTU ]; then - MTU=1500 - fi - if [ -n "$MTU" ]; then - ip link set mtu $MTU dev $DEVICE - logger -t "Custom MTU" $DEVICE set to $MTU - fi - fi - fi -done diff --git a/rooter/ext-rooter-basic/files/etc/hotplug.d/tty/30-3x b/rooter/ext-rooter-basic/files/etc/hotplug.d/tty/30-3x deleted file mode 100644 index 664d4ae..0000000 --- a/rooter/ext-rooter-basic/files/etc/hotplug.d/tty/30-3x +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh -. /lib/functions.sh -. /lib/netifd/netifd-proto.sh - -find_3g_iface() { - local cfg="$1" - local tty="$2" - local proto - config_get proto "$cfg" proto - [ "$proto" = 3x ] || return 0 - - # bypass state vars here because 00-netstate could clobber .device - local dev=$(uci_get network "$cfg" device) - if [ "${dev##*/}" = "${tty##*/}" ]; then - if [ "$ACTION" = add ]; then - available=1 - else - available=0 - fi - proto_set_available "$cfg" $available - fi -} - -case "$DEVICENAME" in - tty*) - [ -e "/dev/$DEVICENAME" ] || [ "$ACTION" = remove ] || exit 0 - config_load network - config_foreach find_3g_iface interface "/dev/$DEVICENAME" - ;; -esac - diff --git a/rooter/ext-rooter-basic/files/etc/hotplug.d/usb/20-usb_mode b/rooter/ext-rooter-basic/files/etc/hotplug.d/usb/20-usb_mode deleted file mode 100644 index aef0620..0000000 --- a/rooter/ext-rooter-basic/files/etc/hotplug.d/usb/20-usb_mode +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -/usr/lib/rooter/modeswitch.sh & \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/etc/init.d/clear b/rooter/ext-rooter-basic/files/etc/init.d/clear deleted file mode 100644 index a924aaa..0000000 --- a/rooter/ext-rooter-basic/files/etc/init.d/clear +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh /etc/rc.common -# Copyright (C) 2006 OpenWrt.org - -START=19 - -start() { - COUNTER=1 - while [ $COUNTER -le 5 ]; do - INEX=$(uci -q get network.wan$COUNTER) - if [ -z $INEX ]; then - break - else - uci delete network.wan$COUNTER - uci commit network - fi - let COUNTER=COUNTER+1 - done - uci delete network.wg0 - uci delete network.wg1 - uci commit network -} diff --git a/rooter/ext-rooter-basic/files/etc/init.d/iphone b/rooter/ext-rooter-basic/files/etc/init.d/iphone deleted file mode 100644 index 625b1e0..0000000 --- a/rooter/ext-rooter-basic/files/etc/init.d/iphone +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh /etc/rc.common -# Copyright (C) 2006 OpenWrt.org - -START=95 - -start() { - if [ ! -d "/var/lib/lockdown" ];then - mkdir -p /var/lib/lockdown - fi - bkp_files=`ls /etc/lockdown/locks` - for file in $bkp_files; - do - if [ ! -f "/var/lib/lockdown/$file" ];then - cp /etc/lockdown/locks/$file /var/lib/lockdown/ - fi - done - proc_usbmuxd=`ps | grep usbmuxd` - nb_usbmuxd=`echo "$proc_usbmuxd" | grep /usr/sbin/usbmuxd | wc -l` - if [ ! "$nb_usbmuxd" -eq 1 ];then - [ -x /usr/sbin/usbmuxd ] && usbmuxd -v - fi -} \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/etc/init.d/rooter b/rooter/ext-rooter-basic/files/etc/init.d/rooter deleted file mode 100644 index 1199b98..0000000 --- a/rooter/ext-rooter-basic/files/etc/init.d/rooter +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh /etc/rc.common -# Copyright (C) 2006 OpenWrt.org - -START=99 - -start() { - /usr/lib/rooter/initialize.sh -} - diff --git a/rooter/ext-rooter-basic/files/etc/init.d/usbmode b/rooter/ext-rooter-basic/files/etc/init.d/usbmode deleted file mode 100644 index 441b70a..0000000 --- a/rooter/ext-rooter-basic/files/etc/init.d/usbmode +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh /etc/rc.common -# Copyright (C) 2013 OpenWrt.org - -START=88 -USE_PROCD=1 - -log() { - logger -t "usb-modeswitch" "$@" -} - -start_service() -{ - log "Remove early Modeswitch" -} diff --git a/rooter/ext-rooter-basic/files/etc/lockdown/locks/0000000000000000000000000000000000000000.plist b/rooter/ext-rooter-basic/files/etc/lockdown/locks/0000000000000000000000000000000000000000.plist deleted file mode 100644 index e69de29..0000000 diff --git a/rooter/ext-rooter-basic/files/etc/netspeed b/rooter/ext-rooter-basic/files/etc/netspeed deleted file mode 100644 index c227083..0000000 --- a/rooter/ext-rooter-basic/files/etc/netspeed +++ /dev/null @@ -1 +0,0 @@ -0 \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/etc/quectelcmd b/rooter/ext-rooter-basic/files/etc/quectelcmd deleted file mode 100644 index a87e3b5..0000000 --- a/rooter/ext-rooter-basic/files/etc/quectelcmd +++ /dev/null @@ -1,6 +0,0 @@ -AT+CRSM=176,12258,0,0,10 -ICCID -AT+QMBNCFG="AutoSel",0 -APNFIX#1 -AT+QMBNCFG="Deactivate" -APNFIX#2 diff --git a/rooter/ext-rooter-basic/files/etc/sierracmd b/rooter/ext-rooter-basic/files/etc/sierracmd deleted file mode 100644 index d62aaa1..0000000 --- a/rooter/ext-rooter-basic/files/etc/sierracmd +++ /dev/null @@ -1,4 +0,0 @@ -AT+CRSM=176,12258,0,0,10 -ICCID -at+csq -Signal Strength diff --git a/rooter/ext-rooter-basic/files/etc/ttl.user b/rooter/ext-rooter-basic/files/etc/ttl.user deleted file mode 100644 index 98707a2..0000000 --- a/rooter/ext-rooter-basic/files/etc/ttl.user +++ /dev/null @@ -1,4 +0,0 @@ -# -# TTL Setting -# - diff --git a/rooter/ext-rooter-basic/files/etc/usb-mode.json b/rooter/ext-rooter-basic/files/etc/usb-mode.json deleted file mode 100644 index 90a68be..0000000 --- a/rooter/ext-rooter-basic/files/etc/usb-mode.json +++ /dev/null @@ -1,3180 +0,0 @@ -{ - "messages" : [ - "555342431234567800000000000006d0000000000000000000000000000000", - "55534243123456780002000000000a2a000000003300000100000000000000", - "5553424312345678000000000000061b004600000000000000000000000000", - "0f00010142", - "55534243f0298d8124000000800006bc626563240000000000000000000000", - "0902200001010080fa0904000002080650000705010200020007058102000200", - "55534243785634120100000080000601000000000000000000000000000000", - "55534243123456780000000000000616000000000000000000000000000000", - "55534243123456782400000080000612000024000000000000000000000000", - "5553424312345678000000000000061b000000ff0000000000000000000000", - "5553424368032c882400000080000612000000240000000000000000000000", - "5553424308306384c000000080000671030000000000000000000000000000", - "5553424312345678c00000008000069f140000000000000000000000000000", - "01b0000000000000000000000000000000000000000000000000000000000000", - "555342431234567800000000000006bd000000020000000000000000000000", - "1b5a01", - "5553424312345678c000000080010606f50402527000000000000000000000", - "55534243123456788000000080000606f50402527000000000000000000000", - "555342431234567800000000000006f0010300000000000000000000000000", - "55534243123456780000000000000aff554d53434847000000000000000000", - "555342431234567803000000800006f1010100000000000000000000000000", - "555342431234567800000000000005f1010100000000000000000000000000", - "555342431234567824000000800008ff024445564348470000000000000000", - "555342431234567824000000800008ff020000000000000000000000000000", - "55534243b82e238c24000000800008ff020000000000000000000000000000", - "55534243123456780600000080000601000000000000000000000000000000", - "55534243123456780600000080010a11060000000000000000000000000000", - "55534243123456780000000000000601000000000000000000000000000000", - "555342431234567824000000800008ff524445564348470000000000000000", - "555342431234567824000000800008ff524445564348473100000000000000", - "55534243123456782400000080000dfe524445564348473d4e444953000000", - "55534243d85dd88524000000800008ff524445564348470000000000000000", - "55534243123456702000000080000c85010101180101010101000000000000", - "55534243123456782400000080000685000000240000000000000000000000", - "55534243d8a523862400000080000685000000240000000000000000000000", - "5553424348c4758600000000000010ff000000000000000000000000000000", - "555342431234567824000000800006bc626563240000000000000000000000", - "5553424330f4cf8124000000800108df200000000000000000000000000000", - "5553424312345678c00000008000069f030000000000000000000000000000", - "555342431234567824000000800008FF05B112AEE102000000000000000000", - "55534243123456780000000000000606f50402527000000000000000000000", - "55534243123456780000000080000606f50402527000000000000000000000", - "555342431234567800000000000001ff000000000000000000000000000000", - "55534243123456781200000080000603000000020000000000000000000000", - "55534243123456780000000000000cff020000000000000000000000000000", - "5553424312345678800000008000060619181a207000000000000000000000", - "555342431234567800000000000010ff000000000000000000000000000000", - "555342431234567800000000000008ff000000000000030000000000000000", - "555342431234567824000000800108df200000000000000000000000000000", - "55534243f8d2e6838000000080000606f50402527000000000000000000000", - "555342431234567800000000000003f0010100000000000000000000000000", - "55534243123456780000000000000600000000000000000000000000000000", - "5553424312345679c000000080000671030000000000000000000000000000", - "555342430820298900000000000003f0010100000000000000000000000000", - "55534243123456700000000000000616aa0000000000000000000000000000", - "5553424312345678c000000080000671010000000000000000000000000000", - "5553424340799288C000000080010A16000000C00000000000000000000000", - "555342431234567800000000000006161f6d62706b00000000000000000000", - "5553424398e2c4812400000080000bff524445564348473d43440000000000" - ], - - "devices" : { - "03f0:002a": { - "*": { - "t_class": 7, - "msg": [ 0 ] - } - }, - "03f0:032a": { - "*": { - "t_class": 7, - "msg": [ 0 ] - } - }, - "03f0:371d": { - "*": { - "msg": [ ], - "config": 0 - } - }, - "03f0:4b1d": { - "*": { - "msg": [ ], - "config": 0 - } - }, - "03f0:4e1d": { - "*": { - "msg": [ ], - "config": 0 - } - }, - "03f0:521d": { - "*": { - "msg": [ ], - "config": 0 - } - }, - "03f0:531d": { - "*": { - "msg": [ ], - "config": 0 - } - }, - "03f0:541d": { - "*": { - "msg": [ ], - "config": 0 - } - }, - "03f0:581d": { - "*": { - "msg": [ ], - "config": 0 - } - }, - "03f0:631d": { - "*": { - "msg": [ ], - "config": 0 - } - }, - "03f0:641d": { - "*": { - "msg": [ ], - "config": 0 - } - }, - "03f0:681d": { - "*": { - "msg": [ ], - "config": 0 - } - }, - "03f0:911d": { - "*": { - "msg": [ ], - "config": 0 - } - }, - "03f0:931d": { - "*": { - "msg": [ ], - "config": 0 - } - }, - "03f0:9a1d": { - "*": { - "msg": [ ], - "config": 0 - } - }, - "03f0:9d1d": { - "*": { - "msg": [ ], - "config": 0 - } - }, - "03f0:a31d": { - "*": { - "msg": [ ], - "config": 0 - } - }, - "0408:1000": { - "*": { - "t_vendor": 1032, - "t_product": [ 59906 ], - "msg": [ 1 ] - } - }, - "0408:ea17": { - "*": { - "t_vendor": 1032, - "t_product": [ 59926 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "0408:ea43": { - "*": { - "t_vendor": 1032, - "t_product": [ 59975, 59977, 59981 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "0408:f000": { - ":uMa=Yota": { - "t_vendor": 1032, - "t_product": [ 53257 ], - "msg": [ 2 ] - } - }, - "0421:060c": { - "*": { - "t_vendor": 1057, - "t_product": [ 1550 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "0421:0610": { - "*": { - "t_vendor": 1057, - "t_product": [ 1554 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "0421:0618": { - "*": { - "t_vendor": 1057, - "t_product": [ 1561 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "0421:061d": { - "*": { - "t_vendor": 1057, - "t_product": [ 1566 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "0421:0622": { - "*": { - "t_vendor": 1057, - "t_product": [ 1571 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "0421:0627": { - "*": { - "t_vendor": 1057, - "t_product": [ 1554, 1577 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "0421:062c": { - "*": { - "t_vendor": 1057, - "t_product": [ 1581, 1583 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "0421:0632": { - "*": { - "t_vendor": 1057, - "t_product": [ 1586 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "0421:0637": { - "*": { - "t_vendor": 1057, - "t_product": [ 1592 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "046d:c261": { - "*": { - "t_class": 3, - "msg_endpoint": 1, - "msg": [ 3 ], - "response_endpoint": 1 - } - }, - "0471:1210": { - ":uMa=Philips": { - "t_class": 255, - "mode": "StandardEject", - "msg": [ ] - }, - ":uMa=Wisue": { - "t_vendor": 7612, - "t_product": [ 5 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "0471:1237": { - "*": { - "t_vendor": 1137, - "t_product": [ 4614, 4660 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "0482:024d": { - "*": { - "msg": [ ], - "config": 2 - } - }, - "04bb:bccd": { - "*": { - "t_vendor": 1211, - "t_product": [ 2377 ], - "msg": [ 4 ] - } - }, - "04cc:2251": { - "*": { - "t_vendor": 1228, - "t_product": [ 8793, 8814 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "04cc:225c": { - "*": { - "msg": [ ], - "config": 2 - } - }, - "04cc:226e": { - "*": { - "msg": [ ], - "config": 2 - } - }, - "04cc:226f": { - "*": { - "msg": [ ], - "config": 2 - } - }, - "04e8:680c": { - "*": { - "t_vendor": 1256, - "t_product": [ 26514 ], - "msg": [ 5 ] - } - }, - "04e8:689a": { - "*": { - "t_vendor": 1256, - "t_product": [ 26761 ], - "msg": [ 6 ] - } - }, - "04e8:f000": { - ":sMo=U209": { - "t_vendor": 1256, - "t_product": [ 26113 ], - "msg": [ 7 ] - } - }, - "04fc:2140": { - "*": { - "t_vendor": 1276, - "t_product": [ 1557, 4672 ], - "msg": [ 8 ] - } - }, - "057c:62ff": { - "*": { - "t_vendor": 1404, - "t_product": [ 34049, 34050 ], - "msg": [ 9 ] - } - }, - "057c:84ff": { - "*": { - "t_vendor": 1404, - "t_product": [ 33793 ], - "msg": [ 9 ] - } - }, - "0586:2030": { - "*": { - "t_vendor": 1414, - "t_product": [ 13379, 13380 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "05c6:0010": { - "*": { - "t_vendor": 1478, - "t_product": [ 160 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "05c6:1000": { - ":uMa=AnyDATA": { - "t_vendor": 5845, - "t_product": [ 25858 ], - "mode": "StandardEject", - "msg": [ ] - }, - ":uMa=CELOT": { - "t_vendor": 8479, - "t_product": [ 26625, 26626 ], - "mode": "StandardEject", - "msg": [ ] - }, - ":uMa=Co.,Ltd": { - "t_vendor": 7433, - "t_product": [ 17158 ], - "mode": "StandardEject", - "msg": [ ] - }, - ":uMa=DGT": { - "t_vendor": 8479, - "t_product": [ 26626 ], - "mode": "StandardEject", - "msg": [ ] - }, - ":uMa=SAMSUNG": { - "t_vendor": 1256, - "t_product": [ 26113 ], - "msg": [ 7 ] - }, - ":uMa=SSE": { - "t_vendor": 1478, - "t_product": [ 24576 ], - "mode": "StandardEject", - "msg": [ ] - }, - ":uMa=StrongRising": { - "t_vendor": 650, - "t_product": [ 4102 ], - "mode": "StandardEject", - "msg": [ ] - }, - ":uMa=Vertex": { - "t_vendor": 8167, - "t_product": [ 256 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "05c6:2000": { - "*": { - "t_vendor": 1478, - "t_product": [ 21, 22, 24, 52759 ], - "msg": [ 10 ], - "response": true, - "check": true - } - }, - "05c6:2001": { - "*": { - "t_vendor": 7694, - "t_product": [ 52758, 52759, 52990 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "05c6:6503": { - "*": { - "t_vendor": 5845, - "t_product": [ 25858 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "05c6:9024": { - "*": { - "t_vendor": 1478, - "t_product": [ 36901 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "05c6:98ff": { - "*": { - "t_vendor": 1478, - "t_product": [ 24577 ], - "mode": "Sierra", - "msg": [ ] - } - }, - "05c6:f000": { - "*": { - "t_vendor": 1478, - "t_product": [ 22, 24576, 36864 ], - "mode": "StandardEject", - "msg": [ 11 ] - } - }, - "05c7:1000": { - "*": { - "t_vendor": 1479, - "t_product": [ 24576 ], - "msg": [ 12 ] - } - }, - "0685:2000": { - "*": { - "t_vendor": 7326, - "t_product": [ 38403 ], - "msg": [ 10 ], - "response": true - } - }, - "072f:100d": { - "*": { - "t_vendor": 1839, - "t_product": [ 37068 ], - "msg_endpoint": 2, - "msg": [ 13 ] - } - }, - "07d1:a800": { - "*": { - "t_vendor": 2001, - "t_product": [ 15873, 15874, 32268 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "07d1:a804": { - "*": { - "t_vendor": 2001, - "t_product": [ 32273 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "07d1:f000": { - "*": { - "t_vendor": 2001, - "t_product": [ 32263 ], - "msg": [ 14 ] - } - }, - "0846:0fff": { - "*": { - "t_vendor": 2118, - "t_product": [ 26835 ], - "mode": "Sierra", - "msg": [ ] - } - }, - "0922:1001": { - "*": { - "t_vendor": 2338, - "t_product": [ 4098 ], - "msg_endpoint": 1, - "msg": [ 15 ], - "response_endpoint": 1 - } - }, - "0922:1003": { - "*": { - "t_vendor": 2338, - "t_product": [ 4100 ], - "msg_endpoint": 1, - "msg": [ 15 ], - "response_endpoint": 1 - } - }, - "0922:1007": { - "*": { - "t_vendor": 2338, - "t_product": [ 4104 ], - "msg_endpoint": 1, - "msg": [ 15 ], - "response_endpoint": 1 - } - }, - "0930:0d46": { - "*": { - "t_vendor": 2352, - "t_product": [ 3397 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "0ace:2011": { - "*": { - "mode": "StandardEject", - "msg": [ ] - } - }, - "0ace:20ff": { - "*": { - "mode": "StandardEject", - "msg": [ ] - } - }, - "0af0:4007": { - "*": { - "t_vendor": 2800, - "t_product": [ 16389 ], - "mode": "Sierra", - "msg": [ ] - } - }, - "0b3c:c700": { - "*": { - "t_vendor": 2876, - "t_product": [ 49152, 49153, 49154 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "0b3c:f000": { - "*": { - "t_vendor": 2876, - "t_product": [ 49155, 49156 ], - "msg": [ 16 ], - "response": true - } - }, - "0b3c:f00c": { - "*": { - "t_vendor": 2876, - "t_product": [ 49162 ], - "msg": [ 17 ] - } - }, - "0b3c:f017": { - "*": { - "t_vendor": 2876, - "t_product": [ 49163 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "0bdb:190d": { - "*": { - "msg": [ ], - "config": 2 - } - }, - "0bdb:1910": { - "*": { - "msg": [ ], - "config": 2 - } - }, - "0cf3:20ff": { - "*": { - "t_vendor": 3315, - "t_product": [ 28688 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "0d46:45a1": { - "*": { - "t_vendor": 3398, - "t_product": [ 17833 ], - "mode": "Kobil", - "msg": [ ] - } - }, - "0d46:45a5": { - "*": { - "t_vendor": 3398, - "t_product": [ 17837 ], - "mode": "Kobil", - "msg": [ ] - } - }, - "0df7:0800": { - "*": { - "t_class": 255, - "mode": "MobileAction", - "msg": [ ] - } - }, - "0e8d:0002": { - ":uPr=MT": { - "t_vendor": 3725, - "t_product": [ 161, 162, 165 ], - "msg": [ 18 ] - }, - ":uPr=Product": { - "t_vendor": 3725, - "t_product": [ 161, 162, 165 ], - "msg": [ 18 ] - } - }, - "0e8d:7109": { - "*": { - "t_vendor": 3725, - "t_product": [ 28949, 28952 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "0fce:d0cf": { - "*": { - "msg": [ ], - "config": 3 - } - }, - "0fce:d0df": { - "*": { - "msg": [ ], - "config": 2 - } - }, - "0fce:d0e1": { - "*": { - "t_class": 2, - "mode": "Sony", - "msg": [ ], - "config": 2 - } - }, - "0fce:d103": { - "*": { - "t_class": 2, - "mode": "Sony", - "msg": [ ], - "config": 2 - } - }, - "0fd1:1000": { - "*": { - "msg": [ ], - "config": 3 - } - }, - "1004:1000": { - "*": { - "t_class": 255, - "msg": [ 19 ] - } - }, - "1004:607f": { - "*": { - "t_vendor": 4100, - "t_product": [ 24576, 24852 ], - "msg": [ 20 ], - "response": true - } - }, - "1004:610c": { - "*": { - "t_vendor": 4100, - "t_product": [ 24841 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "1004:613a": { - "*": { - "t_vendor": 4100, - "t_product": [ 24868 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "1004:613f": { - "*": { - "t_vendor": 4100, - "t_product": [ 24897 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "1004:614e": { - "*": { - "t_vendor": 4100, - "t_product": [ 24885 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "1004:6156": { - "*": { - "t_vendor": 4100, - "t_product": [ 24919 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "1004:6190": { - "*": { - "t_vendor": 4100, - "t_product": [ 24963, 24999 ], - "mode": "StandardEject", - "msg": [ ], - "wait": 10 - } - }, - "1004:61dd": { - "*": { - "t_vendor": 4100, - "t_product": [ 24975 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "1004:61e7": { - "*": { - "t_vendor": 4100, - "t_product": [ 25062 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "1004:61eb": { - "*": { - "t_vendor": 4100, - "t_product": [ 25066 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "1004:6327": { - "*": { - "t_vendor": 4100, - "t_product": [ 25382 ], - "msg": [ 21 ] - } - }, - "106c:3b03": { - "*": { - "t_vendor": 4204, - "t_product": [ 14101 ], - "msg": [ 22 ] - } - }, - "106c:3b05": { - "*": { - "t_vendor": 4204, - "t_product": [ 14102 ], - "msg": [ 23 ] - } - }, - "106c:3b06": { - "*": { - "t_vendor": 4204, - "t_product": [ 14103 ], - "msg": [ 24 ] - } - }, - "106c:3b11": { - "*": { - "t_vendor": 4204, - "t_product": [ 14104 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "106c:3b14": { - "*": { - "t_vendor": 4204, - "t_product": [ 14113 ], - "msg": [ 22 ] - } - }, - "1076:7f40": { - "*": { - "t_vendor": 4214, - "t_product": [ 32512 ], - "mode": "GCT", - "msg": [ ] - } - }, - "109b:f009": { - "*": { - "t_vendor": 4251, - "t_product": [ 37140 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "1199:0fff": { - "*": { - "t_vendor": 4505, - "t_product": [ 23, 24, 25, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 274, 288, 536, 544, 548, 769, 26626, 26627, 26628, 26629, 26632, 26633, 26642, 26643, 26645, 26646, 26656, 26657, 26658, 26674, 26675, 26676, 26677, 26680, 26681, 26682, 26683, 26684, 26685, 26686, 26704, 26705, 26706, 26707, 26709, 26710, 26713, 26714, 26752, 26768, 26769, 26770, 26771, 26786, 26787, 26794, 36881, 36882, 36945 ], - "mode": "Sierra", - "msg": [ ] - } - }, - "1199:9011": { - "*": { - "msg": [ ], - "config": 1 - } - }, - "1199:9013": { - "*": { - "msg": [ ], - "config": 1 - } - }, - "1199:9017": { - "*": { - "msg": [ ], - "config": 1 - } - }, - "1199:901b": { - "*": { - "msg": [ ], - "config": 1 - } - }, - "1199:901c": { - "*": { - "msg": [ ], - "config": 1 - } - }, - "1199:901f": { - "*": { - "msg": [ ], - "config": 1 - } - }, - "1199:9041": { - "*": { - "msg": [ ], - "config": 1 - } - }, - "1199:9051": { - "*": { - "msg": [ ], - "config": 1 - } - }, - "1199:9053": { - "*": { - "msg": [ ], - "config": 1 - } - }, - "1199:9063": { - "*": { - "msg": [ ], - "config": 1 - } - }, - "1266:1000": { - "*": { - "t_vendor": 4710, - "t_product": [ 4098, 4099, 4100, 4101, 4102, 4103, 4104, 4105, 4106, 4107, 4108, 4109, 4110, 4111, 4113, 4114 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "12d1:1001": { - "*": { - "t_class": 255, - "mode": "Huawei", - "msg": [ ] - } - }, - "12d1:1003": { - "*": { - "t_class": 255, - "mode": "Huawei", - "msg": [ ] - } - }, - "12d1:1009": { - "*": { - "t_class": 255, - "mode": "Huawei", - "msg": [ ] - } - }, - "12d1:1010": { - "*": { - "t_class": 255, - "mode": "Huawei", - "msg": [ ] - } - }, - "12d1:101e": { - "*": { - "t_class": 255, - "msg": [ 25 ] - } - }, - "12d1:1030": { - "*": { - "t_vendor": 4817, - "t_product": [ 4148 ], - "msg": [ 26 ] - } - }, - "12d1:1031": { - "*": { - "t_vendor": 4817, - "t_product": [ 4149 ], - "msg": [ 26 ] - } - }, - "12d1:1413": { - "*": { - "t_class": 255, - "mode": "Huawei", - "msg": [ ] - } - }, - "12d1:1414": { - "*": { - "t_class": 255, - "mode": "Huawei", - "msg": [ ] - } - }, - "12d1:1446": { - "*": { - "t_vendor": 4817, - "t_product": [ 4097, 5124, 5126, 5131, 5132, 5138, 5143, 5147, 5161, 5170, 5171, 5174, 5292, 5382, 5388, 5393 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:1449": { - "*": { - "t_vendor": 4817, - "t_product": [ 5188 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:14ad": { - "*": { - "t_vendor": 4817, - "t_product": [ 5294 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:14b5": { - "*": { - "t_vendor": 4817, - "t_product": [ 5288, 5290 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:14b7": { - "*": { - "t_vendor": 4817, - "t_product": [ 5324 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:14ba": { - "*": { - "t_vendor": 4817, - "t_product": [ 5330 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:14c1": { - "*": { - "t_vendor": 4817, - "t_product": [ 5318 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:14c3": { - "*": { - "t_vendor": 4817, - "t_product": [ 5320 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:14c4": { - "*": { - "t_vendor": 4817, - "t_product": [ 5322 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:14c5": { - "*": { - "t_vendor": 4817, - "t_product": [ 5323 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:14d1": { - "*": { - "t_vendor": 4817, - "t_product": [ 5321 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:14fe": { - "*": { - "t_vendor": 4817, - "t_product": [ 5382, 5391, 5405, 7198 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:1505": { - "*": { - "t_vendor": 4817, - "t_product": [ 5131, 5132, 5382, 5391, 5386 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:151a": { - "*": { - "t_vendor": 4817, - "t_product": [ 5403, 5405, 5406 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:1520": { - "*": { - "t_vendor": 4817, - "t_product": [ 5221 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:1521": { - "*": { - "t_vendor": 4817, - "t_product": [ 5220 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:1523": { - "*": { - "t_vendor": 4817, - "t_product": [ 5265 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:1526": { - "*": { - "t_vendor": 4817, - "t_product": [ 5327 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:1527": { - "*": { - "t_vendor": 4817, - "t_product": [ 5524 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:1553": { - "*": { - "t_vendor": 4817, - "t_product": [ 4097 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:1557": { - "*": { - "t_vendor": 4817, - "t_product": [ 5285 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:155a": { - "*": { - "t_vendor": 4817, - "t_product": [ 5325 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:155b": { - "*": { - "t_vendor": 4817, - "t_product": [ 5382 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:156a": { - "*": { - "t_vendor": 4817, - "t_product": [ 5483, 5484 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:1570": { - "*": { - "msg": [ ], - "config": 0 - } - }, - "12d1:1571": { - "*": { - "msg": [ ], - "config": 0 - } - }, - "12d1:1572": { - "*": { - "msg": [ ], - "config": 0 - } - }, - "12d1:1573": { - "*": { - "msg": [ ], - "config": 0 - } - }, - "12d1:157c": { - "*": { - "t_vendor": 4817, - "t_product": [ 5382 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:157d": { - "*": { - "t_vendor": 4817, - "t_product": [ 5339, 5340 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:1580": { - "*": { - "t_vendor": 4817, - "t_product": [ 5509 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:1581": { - "*": { - "t_vendor": 4817, - "t_product": [ 5511 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:1582": { - "*": { - "t_vendor": 4817, - "t_product": [ 5512 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:1583": { - "*": { - "t_vendor": 4817, - "t_product": [ 5513 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:1597": { - "*": { - "t_vendor": 4817, - "t_product": [ 5528 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:15bb": { - "*": { - "msg": [ ], - "config": 0 - } - }, - "12d1:15c0": { - "*": { - "msg": [ ], - "config": 0 - } - }, - "12d1:15c1": { - "*": { - "msg": [ ], - "config": 0 - } - }, - "12d1:15ca": { - "*": { - "t_vendor": 4817, - "t_product": [ 5382 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:15cd": { - "*": { - "t_vendor": 4817, - "t_product": [ 5382 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:15ce": { - "*": { - "t_vendor": 4817, - "t_product": [ 5553, 5555 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:15cf": { - "*": { - "t_vendor": 4817, - "t_product": [ 5382 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:15d0": { - "*": { - "t_vendor": 4817, - "t_product": [ 5585 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:15d2": { - "*": { - "t_vendor": 4817, - "t_product": [ 5587 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:15e7": { - "*": { - "t_vendor": 4817, - "t_product": [ 5382 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:15ec": { - "*": { - "t_vendor": 4817, - "t_product": [ 7206 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:15f0": { - "*": { - "msg": [ ], - "config": 0 - } - }, - "12d1:1805": { - "*": { - "t_class": 255, - "msg": [ 25 ] - } - }, - "12d1:1c0b": { - "*": { - "t_vendor": 4817, - "t_product": [ 7173, 7174, 7175, 7176, 7184 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:1c1b": { - "*": { - "t_vendor": 4817, - "t_product": [ 5382 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:1c24": { - "*": { - "t_vendor": 4817, - "t_product": [ 7186, 7203 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:1c25": { - "*": { - "msg": [ ], - "config": 0 - } - }, - "12d1:1d50": { - "*": { - "msg": [ ], - "config": 2 - } - }, - "12d1:1da1": { - "*": { - "t_vendor": 4817, - "t_product": [ 7433 ], - "mode": "Huawei", - "msg": [ ] - } - }, - "12d1:1f01": { - "*": { - "t_vendor": 4817, - "t_product": [ 5339, 5340 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:1f02": { - "*": { - "t_vendor": 4817, - "t_product": [ 5340 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:1f03": { - "*": { - "t_vendor": 4817, - "t_product": [ 5339 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:1f04": { - "*": { - "t_vendor": 4817, - "t_product": [ 5564 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:1f05": { - "*": { - "t_vendor": 4817, - "t_product": [ 5565 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:1f06": { - "*": { - "t_vendor": 4817, - "t_product": [ 5575 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:1f07": { - "*": { - "t_vendor": 4817, - "t_product": [ 5567 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:1f09": { - "*": { - "t_vendor": 4817, - "t_product": [ 7248 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:1f11": { - "*": { - "t_vendor": 4817, - "t_product": [ 5308 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:1f15": { - "*": { - "t_vendor": 4817, - "t_product": [ 5120, 5367 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:1f16": { - "*": { - "mode": "MBIM", - "msg": [ ] - } - }, - "12d1:1f17": { - "*": { - "t_vendor": 4817, - "t_product": [ 5494 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:1f18": { - "*": { - "t_vendor": 4817, - "t_product": [ 5495 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:1f19": { - "*": { - "t_vendor": 4817, - "t_product": [ 5370, 5493, 5496 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:1f1b": { - "*": { - "t_vendor": 4817, - "t_product": [ 5497 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:1f1c": { - "*": { - "t_vendor": 4817, - "t_product": [ 5498, 5520 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:1f1d": { - "*": { - "t_vendor": 4817, - "t_product": [ 5499, 5521 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:1f1e": { - "*": { - "t_vendor": 4817, - "t_product": [ 5503, 5522 ], - "mode": "HuaweiNew", - "msg": [ ] - } - }, - "12d1:380b": { - "*": { - "t_class": 2, - "mode": "StandardEject", - "msg": [ ] - } - }, - "1307:1169": { - "*": { - "t_vendor": 5041, - "t_product": [ 49 ], - "mode": "Cisco", - "msg": [ ] - } - }, - "1410:5010": { - "*": { - "t_vendor": 5136, - "t_product": [ 16640, 17408, 28720 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "1410:5020": { - "*": { - "t_vendor": 5136, - "t_product": [ 24576, 28673 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "1410:5023": { - "*": { - "t_vendor": 5136, - "t_product": [ 28720 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "1410:5030": { - "*": { - "t_vendor": 5136, - "t_product": [ 24576 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "1410:5031": { - "*": { - "t_vendor": 5136, - "t_product": [ 24578 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "1410:5041": { - "*": { - "t_vendor": 5136, - "t_product": [ 28673, 28675 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "1410:5055": { - "*": { - "t_vendor": 5136, - "t_product": [ 24626 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "1410:5059": { - "*": { - "t_vendor": 5136, - "t_product": [ 28721, 28738 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "1410:7001": { - "*": { - "t_class": 255, - "mode": "StandardEject", - "msg": [ ] - } - }, - "1410:9020": { - "*": { - "msg": [ ], - "config": 4 - } - }, - "148e:a000": { - "*": { - "t_class": 2, - "mode": "Sequans", - "msg": [ ] - } - }, - "148f:2578": { - "*": { - "t_vendor": 5263, - "t_product": [ 36897 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "148f:2878": { - "*": { - "t_vendor": 5263, - "t_product": [ 30209 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "15eb:7153": { - "*": { - "t_vendor": 5611, - "t_product": [ 29010 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "1614:0800": { - "*": { - "t_class": 255, - "msg": [ 27 ] - } - }, - "1614:0802": { - "*": { - "t_class": 255, - "msg": [ 27 ] - } - }, - "16d5:f000": { - "*": { - "t_vendor": 5845, - "t_product": [ 26115 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "16d8:6281": { - "*": { - "t_class": 255, - "msg": [ 28 ] - } - }, - "16d8:6803": { - "*": { - "t_class": 2, - "msg": [ 29 ] - } - }, - "16d8:6804": { - "*": { - "t_class": 255, - "msg": [ 28 ] - } - }, - "16d8:700a": { - "*": { - "t_class": 255, - "msg": [ 30 ] - } - }, - "16d8:700b": { - "*": { - "t_class": 255, - "msg": [ 30 ] - } - }, - "16d8:f000": { - "*": { - "t_vendor": 5848, - "t_product": [ 24582 ], - "msg": [ 31 ] - } - }, - "1726:1900": { - "*": { - "t_vendor": 5926, - "t_product": [ 4096 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "1726:f00e": { - "*": { - "t_vendor": 5926, - "t_product": [ 40960 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "1782:0003": { - "*": { - "msg": [ ], - "config": 2 - } - }, - "1782:0023": { - "*": { - "msg": [ ], - "config": 2 - } - }, - "198a:0003": { - "*": { - "t_vendor": 6538, - "t_product": [ 2 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "198f:bccd": { - "*": { - "t_vendor": 6543, - "t_product": [ 544 ], - "msg": [ 4 ] - } - }, - "19d2:0003": { - "*": { - "t_class": 255, - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:0026": { - "*": { - "t_vendor": 6610, - "t_product": [ 115, 148, 338 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:0033": { - "*": { - "t_class": 255, - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:0040": { - "*": { - "t_vendor": 6610, - "t_product": [ 34 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:0053": { - "*": { - "t_vendor": 6610, - "t_product": [ 49 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:0083": { - ":uPr=WCDMA": { - "t_vendor": 6610, - "t_product": [ 292 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:0090": { - "*": { - "t_vendor": 6610, - "t_product": [ 52 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:0101": { - "*": { - "t_vendor": 6610, - "t_product": [ 260 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:0103": { - "*": { - "t_vendor": 6610, - "t_product": [ 49 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:0110": { - "*": { - "t_vendor": 6610, - "t_product": [ 289 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:0115": { - "*": { - "t_vendor": 6610, - "t_product": [ 278 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:0120": { - "*": { - "t_vendor": 6610, - "t_product": [ 121 ], - "detach_storage": false, - "mode": "StandardEject", - "msg": [ ], - "response": false, - "interface": 0 - } - }, - "19d2:0146": { - "*": { - "t_vendor": 6610, - "t_product": [ 322, 323 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:0149": { - "*": { - "t_vendor": 6610, - "t_product": [ 292 ], - "mode": "StandardEject", - "msg": [ 32 ] - } - }, - "19d2:0150": { - "*": { - "t_vendor": 6610, - "t_product": [ 292 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:0154": { - "*": { - "t_vendor": 6610, - "t_product": [ 23, 279, 8195 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:0166": { - "*": { - "t_vendor": 6610, - "t_product": [ 359 ], - "msg": [ 33 ] - } - }, - "19d2:0169": { - "*": { - "t_vendor": 6610, - "t_product": [ 368 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:0198": { - "*": { - "t_vendor": 6610, - "t_product": [ 409 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:0266": { - "*": { - "t_vendor": 6610, - "t_product": [ 613 ], - "mode": "StandardEject", - "msg": [ 34 ] - } - }, - "19d2:0304": { - "*": { - "t_vendor": 6610, - "t_product": [ 841 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:0318": { - "*": { - "t_vendor": 6610, - "t_product": [ 791, 816 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:0325": { - "*": { - "t_vendor": 6610, - "t_product": [ 806 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:0388": { - "*": { - "t_vendor": 6610, - "t_product": [ 1095 ], - "msg": [ 33 ] - } - }, - "19d2:0413": { - "*": { - "t_vendor": 6610, - "t_product": [ 1042 ], - "msg": [ 34 ] - } - }, - "19d2:1001": { - "*": { - "t_vendor": 6610, - "t_product": [ 4098, 4099 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:1007": { - "*": { - "t_vendor": 6610, - "t_product": [ 4104 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:1009": { - "*": { - "t_vendor": 6610, - "t_product": [ 4112 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:1013": { - "*": { - "t_vendor": 6610, - "t_product": [ 4117 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:1017": { - "*": { - "t_vendor": 6610, - "t_product": [ 4120 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:1019": { - "*": { - "t_vendor": 6610, - "t_product": [ 4129 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:1020": { - "*": { - "t_vendor": 6610, - "t_product": [ 4129 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:1022": { - "*": { - "t_vendor": 6610, - "t_product": [ 4131, 4132 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:1026": { - "*": { - "t_vendor": 6610, - "t_product": [ 4135, 4136, 4137 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:1030": { - "*": { - "t_vendor": 6610, - "t_product": [ 4145, 4146 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:1034": { - "*": { - "t_vendor": 6610, - "t_product": [ 4149, 4150, 4151 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:1038": { - "*": { - "t_vendor": 6610, - "t_product": [ 4153, 4160 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:1042": { - "*": { - "t_vendor": 6610, - "t_product": [ 4163 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:1046": { - "*": { - "t_vendor": 6610, - "t_product": [ 4167 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:1171": { - "*": { - "t_vendor": 6610, - "t_product": [ 4467 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:1175": { - "*": { - "t_vendor": 6610, - "t_product": [ 4471 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:1179": { - "*": { - "t_vendor": 6610, - "t_product": [ 4481 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:1201": { - "*": { - "t_vendor": 6610, - "t_product": [ 4611 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:1207": { - "*": { - "t_vendor": 6610, - "t_product": [ 4616 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:1210": { - "*": { - "t_vendor": 6610, - "t_product": [ 4625 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:1216": { - "*": { - "t_vendor": 6610, - "t_product": [ 4631 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:1219": { - "*": { - "t_vendor": 6610, - "t_product": [ 4640, 4642 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:1224": { - "*": { - "t_vendor": 6610, - "t_product": [ 130 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:1225": { - "*": { - "t_vendor": 6610, - "t_product": [ 5125 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:1227": { - "*": { - "t_vendor": 6610, - "t_product": [ 4690 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:1232": { - "*": { - "t_vendor": 6610, - "t_product": [ 4712, 8195 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:1233": { - "*": { - "t_vendor": 6610, - "t_product": [ 4720 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:1237": { - "*": { - "t_vendor": 6610, - "t_product": [ 23 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:1238": { - "*": { - "t_vendor": 6610, - "t_product": [ 23 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:1420": { - "*": { - "t_vendor": 6610, - "t_product": [ 5125 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:1511": { - "*": { - "t_vendor": 6610, - "t_product": [ 5394 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:1514": { - "*": { - "t_vendor": 6610, - "t_product": [ 5397 ], - "msg": [ 35 ] - } - }, - "19d2:1517": { - "*": { - "t_vendor": 6610, - "t_product": [ 5401 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:1520": { - "*": { - "t_vendor": 6610, - "t_product": [ 322 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:1523": { - "*": { - "t_vendor": 6610, - "t_product": [ 5413 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:1528": { - "*": { - "t_vendor": 6610, - "t_product": [ 5415 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:1536": { - "*": { - "t_vendor": 6610, - "t_product": [ 5431, 5432 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:1542": { - "*": { - "t_vendor": 6610, - "t_product": [ 5444 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:1580": { - "*": { - "t_vendor": 6610, - "t_product": [ 5506 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:1588": { - "*": { - "t_vendor": 6610, - "t_product": [ 5513, 5521, 5522 ], - "mode": "StandardEject", - "msg": [ 32 ] - } - }, - "19d2:1595": { - "*": { - "t_vendor": 6610, - "t_product": [ 5428, 5522, 5526, 5632 ], - "mode": "StandardEject", - "msg": [ 32 ] - } - }, - "19d2:2000": { - "*": { - "t_vendor": 6610, - "t_product": [ 1, 2, 21, 22, 23, 25, 36, 49, 51, 55, 66, 82, 85, 97, 99, 100, 102, 145, 264, 279, 296, 337, 343, 375, 5122, 8194, 8195 ], - "mode": "StandardEject", - "msg": [ 32 ] - } - }, - "19d2:2004": { - "*": { - "t_vendor": 6610, - "t_product": [ 5122 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:bccd": { - "*": { - "t_vendor": 6610, - "t_product": [ 370 ], - "msg": [ 36 ] - } - }, - "19d2:ffde": { - "*": { - "t_vendor": 6610, - "t_product": [ 65501 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "19d2:ffe6": { - "*": { - "t_vendor": 6610, - "t_product": [ 65509 ], - "msg": [ 37 ] - } - }, - "19d2:fff5": { - "*": { - "t_vendor": 6610, - "t_product": [ 65508, 65513, 65521, 65534, 65535 ], - "msg": [ 38 ] - } - }, - "19d2:fff6": { - "*": { - "t_vendor": 6610, - "t_product": [ 65521 ], - "msg": [ 38 ] - } - }, - "1a8d:1000": { - "*": { - "t_vendor": 6797, - "t_product": [ 4098, 4103, 4105, 4109, 8198 ], - "mode": "StandardEject", - "msg": [ ], - "release_delay": 4000, - "response": true - } - }, - "1a8d:2000": { - "*": { - "t_vendor": 6797, - "t_product": [ 8198 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "1ab7:5700": { - "*": { - "t_vendor": 6839, - "t_product": [ 8192, 22321 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "1b7d:0700": { - "*": { - "t_vendor": 7037, - "t_product": [ 1 ], - "msg": [ 39 ] - } - }, - "1bbb:000f": { - "*": { - "t_vendor": 7099, - "t_product": [ 15 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "1bbb:00ca": { - "*": { - "t_class": 255, - "msg": [ 17 ] - } - }, - "1bbb:011f": { - "*": { - "t_vendor": 7099, - "t_product": [ 262 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "1bbb:022c": { - "*": { - "msg": [ ], - "config": 2 - } - }, - "1bbb:025e": { - "*": { - "t_vendor": 7099, - "t_product": [ 405 ], - "msg": [ 17 ] - } - }, - "1bbb:f000": { - "*": { - "t_vendor": 7099, - "t_product": [ 0, 23, 183, 286, 401, 405 ], - "msg": [ 17 ] - } - }, - "1bbb:f017": { - "*": { - "t_vendor": 7099, - "t_product": [ 23, 286, 515 ], - "msg": [ 17 ] - } - }, - "1bbb:f052": { - "*": { - "t_vendor": 7099, - "t_product": [ 82 ], - "msg": [ 17 ] - } - }, - "1c9e:1001": { - "*": { - "t_vendor": 7326, - "t_product": [ 24672, 24673 ], - "msg": [ 40 ] - } - }, - "1c9e:6000": { - "*": { - "t_class": 255, - "msg": [ 27 ] - } - }, - "1c9e:6061": { - ":uPr=Storage": { - "t_class": 255, - "msg": [ 40 ] - } - }, - "1c9e:9101": { - "*": { - "t_vendor": 7326, - "t_product": [ 37124 ], - "msg": [ 40 ] - } - }, - "1c9e:9200": { - "*": { - "t_vendor": 7326, - "t_product": [ 37378 ], - "msg": [ 40 ] - } - }, - "1c9e:9401": { - "*": { - "t_vendor": 7326, - "t_product": [ 37892 ], - "msg": [ 40 ] - } - }, - "1c9e:9800": { - "*": { - "t_class": 255, - "msg": [ 17 ] - } - }, - "1c9e:98ff": { - "*": { - "t_vendor": 7326, - "t_product": [ 26625, 38913, 38915 ], - "msg": [ 41 ] - } - }, - "1c9e:9bfe": { - "*": { - "t_vendor": 7326, - "t_product": [ 39681 ], - "msg": [ 40 ] - } - }, - "1c9e:9d00": { - "*": { - "t_class": 255, - "msg": [ 40 ] - } - }, - "1c9e:9e00": { - "*": { - "t_class": 255, - "msg": [ 40 ] - } - }, - "1c9e:9e08": { - "*": { - "t_vendor": 7326, - "t_product": [ 40472 ], - "mode": "Sierra", - "msg": [ ] - } - }, - "1c9e:f000": { - "*": { - "t_vendor": 7326, - "t_product": [ 36864, 38403, 38405, 38407, 39168 ], - "msg": [ 42 ], - "wait": 1 - }, - ":uMa=USB_Modem": { - "t_vendor": 7326, - "t_product": [ 36864, 38403, 38405, 38407, 39168, 39424 ], - "msg": [ 17 ], - "wait": 1 - } - }, - "1c9e:f010": { - "*": { - "t_vendor": 7326, - "t_product": [ 61697 ], - "msg": [ 40 ] - } - }, - "1d09:1000": { - "*": { - "t_vendor": 7433, - "t_product": [ 4112 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "1d09:1021": { - "*": { - "t_vendor": 7433, - "t_product": [ 4112 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "1d09:1025": { - "*": { - "t_vendor": 7433, - "t_product": [ 4134 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "1da5:f000": { - "*": { - "t_vendor": 7589, - "t_product": [ 17682 ], - "mode": "Qisda", - "msg": [ ] - } - }, - "1dbc:0669": { - "*": { - "msg": [ ], - "config": 2 - } - }, - "1dd6:1000": { - "*": { - "t_vendor": 7638, - "t_product": [ 4098 ], - "msg": [ 43 ], - "response": true - } - }, - "1de1:1101": { - "*": { - "t_vendor": 8679, - "t_product": [ 14 ], - "msg": [ 44 ] - } - }, - "1e0e:f000": { - "*": { - "t_vendor": 7694, - "t_product": [ 36864, 37120, 37376 ], - "msg": [ 14 ], - "response": true - } - }, - "1e89:f000": { - "*": { - "t_vendor": 7817, - "t_product": [ 6688 ], - "msg": [ 45 ] - } - }, - "1edf:6003": { - "*": { - "msg": [ ], - "config": 2 - } - }, - "1ee8:0003": { - "*": { - "t_vendor": 7912, - "t_product": [ 4 ], - "msg": [ 46 ], - "response": true - } - }, - "1ee8:0007": { - "*": { - "t_vendor": 7912, - "t_product": [ 11 ], - "msg": [ 46 ] - } - }, - "1ee8:0009": { - "*": { - "t_vendor": 7912, - "t_product": [ 11 ], - "msg": [ 46 ], - "response": true - } - }, - "1ee8:0013": { - "*": { - "t_vendor": 7912, - "t_product": [ 17, 18, 20 ], - "msg": [ 46 ], - "response": true - } - }, - "1ee8:0018": { - "*": { - "t_vendor": 7912, - "t_product": [ 23 ], - "msg": [ 46 ], - "response": true - } - }, - "1ee8:0040": { - "*": { - "t_vendor": 7912, - "t_product": [ 62, 63 ], - "msg": [ 46 ], - "response": true - } - }, - "1ee8:0045": { - "*": { - "t_vendor": 7912, - "t_product": [ 68 ], - "msg": [ 46 ], - "response": true - } - }, - "1ee8:0048": { - "*": { - "t_vendor": 7912, - "t_product": [ 73 ], - "msg": [ 46 ] - } - }, - "1ee8:004a": { - "*": { - "t_vendor": 7912, - "t_product": [ 73 ], - "msg": [ 46 ] - } - }, - "1ee8:004f": { - "*": { - "t_vendor": 7912, - "t_product": [ 78 ], - "msg": [ 46 ], - "response": true - } - }, - "1ee8:0054": { - "*": { - "t_vendor": 7912, - "t_product": [ 83 ], - "msg": [ 46 ], - "response": true - } - }, - "1ee8:0060": { - "*": { - "t_vendor": 7912, - "t_product": [ 95 ], - "msg": [ 47 ] - } - }, - "1ee8:0063": { - "*": { - "t_vendor": 7912, - "t_product": [ 100, 101 ], - "msg": [ 47 ] - } - }, - "1ee8:0068": { - "*": { - "t_vendor": 7912, - "t_product": [ 105 ], - "msg": [ 47 ] - } - }, - "1f28:0021": { - "*": { - "t_vendor": 7976, - "t_product": [ 32 ], - "msg": [ 48 ] - } - }, - "1fac:0032": { - "*": { - "msg": [ ], - "config": 2 - } - }, - "1fac:0130": { - "*": { - "t_vendor": 8108, - "t_product": [ 305 ], - "msg": [ 48 ] - } - }, - "1fac:0150": { - "*": { - "t_vendor": 8108, - "t_product": [ 337 ], - "msg": [ 48 ] - } - }, - "1fac:0151": { - "*": { - "msg": [ ], - "config": 2 - } - }, - "2001:00a6": { - "*": { - "t_vendor": 8193, - "t_product": [ 32002 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "2001:00a7": { - "*": { - "t_vendor": 8193, - "t_product": [ 32014 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "2001:7600": { - "*": { - "msg": [ ], - "config": 2 - } - }, - "2001:98ff": { - "*": { - "t_vendor": 8193, - "t_product": [ 32278 ], - "msg": [ 49 ], - "response": true - } - }, - "2001:a401": { - "*": { - "t_vendor": 8193, - "t_product": [ 32281 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "2001:a403": { - "*": { - "t_vendor": 8193, - "t_product": [ 32011, 32012 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "2001:a405": { - "*": { - "t_vendor": 8193, - "t_product": [ 32013 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "2001:a406": { - "*": { - "t_vendor": 8193, - "t_product": [ 32281 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "2001:a407": { - "*": { - "t_vendor": 8193, - "t_product": [ 32014 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "2001:a40a": { - "*": { - "t_vendor": 8193, - "t_product": [ 32016 ], - "msg": [ 50 ] - } - }, - "2001:a40d": { - "*": { - "t_vendor": 8193, - "t_product": [ 32312 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "2001:a706": { - "*": { - "t_vendor": 8193, - "t_product": [ 32001 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "2001:a707": { - "*": { - "t_vendor": 8193, - "t_product": [ 32002 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "2001:a708": { - "*": { - "t_vendor": 8193, - "t_product": [ 32003 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "2001:a805": { - "*": { - "t_vendor": 8193, - "t_product": [ 32274 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "2001:a809": { - "*": { - "t_vendor": 8193, - "t_product": [ 30976 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "2001:a80b": { - "*": { - "t_vendor": 8193, - "t_product": [ 32000 ], - "msg": [ 50 ], - "response": true - } - }, - "2001:ab00": { - "*": { - "t_vendor": 8193, - "t_product": [ 32309 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "2001:ac01": { - "*": { - "t_vendor": 8193, - "t_product": [ 32317 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "2015:0001": { - "*": { - "t_class": 255, - "mode": "StandardEject", - "msg": [ ] - } - }, - "201e:1023": { - "*": { - "t_vendor": 8222, - "t_product": [ 4130 ], - "msg": [ 51, 52 ], - "response": true - } - }, - "201e:2009": { - "*": { - "t_class": 255, - "mode": "StandardEject", - "msg": [ ] - } - }, - "2020:0002": { - "*": { - "t_vendor": 8224, - "t_product": [ 8192, 16384, 16400 ], - "msg": [ 53 ] - } - }, - "2020:f00e": { - "*": { - "t_vendor": 8224, - "t_product": [ 4101, 4104 ], - "mode": "StandardEject", - "msg": [ ], - "wait": 2 - } - }, - "2020:f00f": { - "*": { - "t_vendor": 8224, - "t_product": [ 4101 ], - "mode": "StandardEject", - "msg": [ ], - "wait": 2 - } - }, - "2077:1000": { - "*": { - "t_vendor": 8311, - "t_product": [ 28673, 28688, 28689 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "2077:f000": { - "*": { - "t_vendor": 8311, - "t_product": [ 36864, 36962, 40960, 40963 ], - "mode": "StandardEject", - "msg": [ 54 ] - } - }, - "20a6:f00a": { - "*": { - "t_vendor": 8358, - "t_product": [ 4096 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "20a6:f00e": { - "*": { - "t_vendor": 8358, - "t_product": [ 4357 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "20b9:1682": { - "*": { - "t_class": 255, - "mode": "StandardEject", - "msg": [ ] - } - }, - "21f5:1000": { - "*": { - "t_vendor": 8693, - "t_product": [ 8200 ], - "msg": [ 55 ] - } - }, - "21f5:3010": { - "*": { - "t_vendor": 8693, - "t_product": [ 4353 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "2262:0001": { - "*": { - "t_vendor": 8802, - "t_product": [ 2 ], - "msg": [ 56 ] - } - }, - "22de:6801": { - "*": { - "t_class": 255, - "mode": "StandardEject", - "msg": [ ] - } - }, - "22de:6802": { - "*": { - "t_class": 255, - "mode": "StandardEject", - "msg": [ ] - } - }, - "22de:6803": { - "*": { - "t_class": 255, - "mode": "StandardEject", - "msg": [ ] - } - }, - "22f4:0021": { - "*": { - "t_class": 255, - "mode": "StandardEject", - "msg": [ ] - } - }, - "230d:0001": { - "*": { - "msg": [ ], - "config": 3 - } - }, - "230d:0003": { - "*": { - "msg": [ ], - "config": 3 - } - }, - "230d:0007": { - "*": { - "msg": [ ], - "config": 3 - } - }, - "230d:000b": { - "*": { - "msg": [ ], - "config": 3 - } - }, - "230d:000c": { - "*": { - "msg": [ ], - "config": 3 - } - }, - "230d:000d": { - "*": { - "msg": [ ], - "config": 3 - } - }, - "230d:0101": { - "*": { - "msg": [ ], - "config": 2 - } - }, - "230d:0103": { - "*": { - "msg": [ ], - "config": 2 - } - }, - "2357:0200": { - "*": { - "t_vendor": 9047, - "t_product": [ 513 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "2357:f000": { - "*": { - "t_vendor": 9047, - "t_product": [ 36864 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "23a2:1010": { - "*": { - "t_vendor": 9122, - "t_product": [ 4660 ], - "msg": [ 57 ] - } - }, - "257a:a000": { - "*": { - "t_vendor": 9594, - "t_product": [ 5633, 5663, 5679, 9759, 9775, 13855, 13871 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "257a:b000": { - "*": { - "t_vendor": 9594, - "t_product": [ 5633, 5663, 5679, 9759, 9775, 13855, 13871 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "257a:c000": { - "*": { - "t_vendor": 9594, - "t_product": [ 5633, 5663, 5679, 9759, 9775, 13855, 13871 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "257a:d000": { - "*": { - "t_vendor": 9594, - "t_product": [ 5633, 5663, 5679, 9759, 9775, 13855, 13871 ], - "mode": "StandardEject", - "msg": [ ] - } - }, - "6000:1000": { - "*": { - "t_vendor": 1478, - "t_product": [ 24576 ], - "msg": [ 55 ] - } - }, - "8888:6500": { - "*": { - "t_vendor": 5848, - "t_product": [ 25907 ], - "msg": [ 58 ] - } - }, - "ed09:1021": { - "*": { - "t_vendor": 60681, - "t_product": [ 4112 ], - "mode": "StandardEject", - "msg": [ ] - } - } - } -} diff --git a/rooter/ext-rooter-basic/files/lib/netifd/proto/3x.sh b/rooter/ext-rooter-basic/files/lib/netifd/proto/3x.sh deleted file mode 100644 index 4356489..0000000 --- a/rooter/ext-rooter-basic/files/lib/netifd/proto/3x.sh +++ /dev/null @@ -1,164 +0,0 @@ -#!/bin/sh -INCLUDE_ONLY=1 - -. ../netifd-proto.sh -. ./ppp.sh -init_proto "$@" - -ROOTER=/usr/lib/rooter -ROOTER_LINK="/tmp/links" - -log() { - logger -t "Create PPP Connection" "$@" -} - -chcklog() { - OOX=$1 - CLOG=$(uci get modem.modeminfo$CURRMODEM.log) - if [ $CLOG = "1" ]; then - log "$OOX" - fi -} - -proto_3x_init_config() { - no_device=1 - available=1 - ppp_generic_init_config - proto_config_add_string "device" - proto_config_add_string "apn" - proto_config_add_string "service" - proto_config_add_string "pincode" - proto_config_add_string "dialnumber" -} - -proto_3x_setup() { - local interface="$1" - local chat - - if [ ! -f /tmp/bootend.file ]; then - return 0 - fi - - json_get_var device device - json_get_var apn apn - json_get_var service service - json_get_var pincode pincode - - CURRMODEM=$(uci get network.$interface.currmodem) - - uci set modem.modem$CURRMODEM.connected=0 - uci commit modem - jkillall getsignal$CURRMODEM - rm -f $ROOTER_LINK/getsignal$CURRMODEM - jkillall con_monitor$CURRMODEM - rm -f $ROOTER_LINK/con_monitor$CURRMODEM - - - - [ -e "$device" ] || { - proto_set_available "$interface" 0 - return 1 - } - - if [ $service = "umts" ]; then - idV=$(uci get modem.modem$CURRMODEM.idV) - if [ $idV = 12d1 ]; then - $ROOTER/gcom/gcom-locked "$device" "curc.gcom" "$CURRMODEM" - log "Unsolicited Responses Disabled" - fi - chat="/etc/chatscripts/3g.chat" - if [ -n "$pincode" ]; then - OX=$($ROOTER/gcom/gcom-locked "$device" "setpin.gcom" "$CURRMODEM") - ERROR="ERROR" - if `echo ${OX} | grep "${ERROR}" 1>/dev/null 2>&1` - then - log "Modem $CURRMODEM Failed to Unlock SIM Pin" - chcklog "$OX" - $ROOTER/signal/status.sh $CURRMODEM "$MAN $MOD" "Failed to Connect : Pin Locked" - proto_notify_error "$interface" PIN_FAILED - proto_block_restart "$interface" - return 1 - fi - fi - export SETUSER=$(uci get modem.modeminfo$CURRMODEM.user) - export SETPASS=$(uci get modem.modeminfo$CURRMODEM.pass) - export SETAUTH=$(uci get modem.modeminfo$CURRMODEM.auth) - OX=$($ROOTER/gcom/gcom-locked "$device" "connect-ppp.gcom" "$CURRMODEM") - ERROR="ERROR" - if `echo ${OX} | grep "${ERROR}" 1>/dev/null 2>&1` - then - log "Error for Modem $CURRMODEM on Authorization" - chcklog "$OX" - fi - - if [ -z "$dialnumber" ]; then - dialnumber="*99***1#" - fi - else - chat="/etc/chatscripts/evdo.chat" - fi - - connect="${apn:+USE_APN=$apn }DIALNUMBER=$dialnumber /usr/sbin/chat -t5 -v -E -f $chat" - - ppp_generic_setup "$interface" \ - noaccomp \ - nopcomp \ - novj \ - nobsdcomp \ - noauth \ - lock \ - crtscts \ - 115200 "$device" - - sleep 20 - MAN=$(uci get modem.modem$CURRMODEM.manuf) - MOD=$(uci get modem.modem$CURRMODEM.model) - $ROOTER/log/logger "Modem #$CURRMODEM Connected ($MAN $MOD)" - PROT=$(uci get modem.modem$CURRMODEM.proto) - if [ $service = "umts" ]; then - ln -s $ROOTER/signal/modemsignal.sh $ROOTER_LINK/getsignal$CURRMODEM - $ROOTER_LINK/getsignal$CURRMODEM $CURRMODEM $PROT & - fi - ln -s $ROOTER/connect/reconnect-ppp.sh $ROOTER_LINK/reconnect$CURRMODEM - ln -s $ROOTER/connect/conmon.sh $ROOTER_LINK/con_monitor$CURRMODEM - $ROOTER_LINK/con_monitor$CURRMODEM $CURRMODEM & - uci set modem.modem$CURRMODEM.connected=1 - uci set modem.modem$CURRMODEM.interface="3x-"$interface - uci commit modem - CLB=$(uci get modem.modeminfo$CURRMODEM.lb) - if [ -e /etc/config/mwan3 ]; then - INTER=$(uci get modem.modeminfo$CURRMODEM.inter) - if [ -z $INTER ]; then - INTER=0 - else - if [ $INTER = 0 ]; then - INTER=$CURRMODEM - fi - fi - if [ -e $ROOTER/timezone.sh ]; then - TZ=$(uci get modem.modeminfo$CURRMODEM.tzone) - if [ $TZ = "1" ]; then - log "Set TimeZone" - $ROOTER/timezone.sh & - fi - fi - ENB=$(uci get mwan3.wan$CURRMODEM.enabled) - if [ ! -z $ENB ]; then - if [ $CLB = "1" ]; then - uci set mwan3.wan$INTER.enabled=1 - else - uci set mwan3.wan$INTER.enabled=0 - fi - uci commit mwan3 - /usr/sbin/mwan3 restart - fi - fi - rm -f /tmp/usbwait - return 0 -} - -proto_3x_teardown() { - proto_kill_command "$interface" -} - -add_protocol 3x diff --git a/rooter/ext-rooter-basic/files/lib/upgrade/keep.d/cronfiles b/rooter/ext-rooter-basic/files/lib/upgrade/keep.d/cronfiles deleted file mode 100644 index 16cdff4..0000000 --- a/rooter/ext-rooter-basic/files/lib/upgrade/keep.d/cronfiles +++ /dev/null @@ -1,2 +0,0 @@ -/etc/cronuser -/etc/cronbase diff --git a/rooter/ext-rooter-basic/files/lib/upgrade/keep.d/rc-local b/rooter/ext-rooter-basic/files/lib/upgrade/keep.d/rc-local deleted file mode 100644 index b68cb69..0000000 --- a/rooter/ext-rooter-basic/files/lib/upgrade/keep.d/rc-local +++ /dev/null @@ -1,3 +0,0 @@ -/overlay/upper/etc/rc.local -/etc/rc.local -/usr/lib/scripts diff --git a/rooter/ext-rooter-basic/files/usr/bin/bmask128 b/rooter/ext-rooter-basic/files/usr/bin/bmask128 deleted file mode 100644 index bfd5bde..0000000 --- a/rooter/ext-rooter-basic/files/usr/bin/bmask128 +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh -# -printf "Band 128-bit bandmask\n" -LBAND=1 -BBAND=1 -while [ $LBAND -le 48 ] -do - printf "%-6s%016X%016X\n" "$LBAND" "0" "$BBAND" - LBAND=$(( $LBAND + 1 )) - BBAND=$(( $BBAND * 2 )) -done -LBAND=65 -BBAND=1 -while [ $LBAND -le 85 ] -do - printf "%-6s%016X%016X\n" "$LBAND" "$BBAND" "0" - LBAND=$(( $LBAND + 1 )) - BBAND=$(( $BBAND * 2 )) -done diff --git a/rooter/ext-rooter-basic/files/usr/bin/chan2band.sh b/rooter/ext-rooter-basic/files/usr/bin/chan2band.sh deleted file mode 100644 index 5b5bff0..0000000 --- a/rooter/ext-rooter-basic/files/usr/bin/chan2band.sh +++ /dev/null @@ -1,317 +0,0 @@ -#!/bin/sh -CHAN=$1 -CHAN=$(echo "$CHAN" | grep -o "[0-9]*") - -decode_lte() { - if [ $CHAN -lt 600 ]; then - BAND="B1" - elif [ $CHAN -lt 1200 ]; then - BAND="B2" - elif [ $CHAN -lt 1950 ]; then - BAND="B3" - elif [ $CHAN -lt 2400 ]; then - BAND="B4" - elif [ $CHAN -lt 2650 ]; then - BAND="B5" - elif [ $CHAN -lt 2750 ]; then - BAND="B6" - elif [ $CHAN -lt 3450 ]; then - BAND="B7" - elif [ $CHAN -lt 3800 ]; then - BAND="B8" - elif [ $CHAN -lt 4150 ]; then - BAND="B9" - elif [ $CHAN -lt 4750 ]; then - BAND="B10" - elif [ $CHAN -lt 4950 ]; then - BAND="B11" - elif [ $CHAN -lt 5010 ]; then - BAND="-" - elif [ $CHAN -lt 5180 ]; then - BAND="B12" - elif [ $CHAN -lt 5280 ]; then - BAND="B13" - elif [ $CHAN -lt 5380 ]; then - BAND="B14" - elif [ $CHAN -lt 5730 ]; then - BAND="-" - elif [ $CHAN -lt 5850 ]; then - BAND="B17" - elif [ $CHAN -lt 6000 ]; then - BAND="B18" - elif [ $CHAN -lt 6150 ]; then - BAND="B19" - elif [ $CHAN -lt 6450 ]; then - BAND="B20" - elif [ $CHAN -lt 6600 ]; then - BAND="B21" - elif [ $CHAN -lt 7400 ]; then - BAND="B22" - elif [ $CHAN -lt 7500 ]; then - BAND="-" - elif [ $CHAN -lt 7700 ]; then - BAND="B23" - elif [ $CHAN -lt 8040 ]; then - BAND="B24" - elif [ $CHAN -lt 8690 ]; then - BAND="B25" - elif [ $CHAN -lt 9040 ]; then - BAND="B26" - elif [ $CHAN -lt 9210 ]; then - BAND="B27" - elif [ $CHAN -lt 9660 ]; then - BAND="B28" - elif [ $CHAN -lt 9770 ]; then - BAND="B29" - elif [ $CHAN -lt 9870 ]; then - BAND="B30" - elif [ $CHAN -lt 9920 ]; then - BAND="B31" - elif [ $CHAN -lt 10400 ]; then - BAND="B32" - elif [ $CHAN -lt 36000 ]; then - BAND="-" - elif [ $CHAN -lt 36200 ]; then - BAND="B33" - elif [ $CHAN -lt 36350 ]; then - BAND="B34" - elif [ $CHAN -lt 36950 ]; then - BAND="B35" - elif [ $CHAN -lt 37550 ]; then - BAND="B36" - elif [ $CHAN -lt 37750 ]; then - BAND="B37" - elif [ $CHAN -lt 38250 ]; then - BAND="B38" - elif [ $CHAN -lt 38650 ]; then - BAND="B39" - elif [ $CHAN -lt 39650 ]; then - BAND="B40" - elif [ $CHAN -lt 41590 ]; then - BAND="B41" - elif [ $CHAN -lt 43590 ]; then - BAND="B42" - elif [ $CHAN -lt 45590 ]; then - BAND="B43" - elif [ $CHAN -lt 46590 ]; then - BAND="B44" - elif [ $CHAN -lt 46790 ]; then - BAND="B45" - elif [ $CHAN -lt 54540 ]; then - BAND="B46" - elif [ $CHAN -lt 55240 ]; then - BAND="B47" - elif [ $CHAN -lt 56740 ]; then - BAND="B48" - elif [ $CHAN -lt 58240 ]; then - BAND="B49" - elif [ $CHAN -lt 59090 ]; then - BAND="B50" - elif [ $CHAN -lt 59140 ]; then - BAND="B51" - elif [ $CHAN -lt 60140 ]; then - BAND="B52" - elif [ $CHAN -lt 60255 ]; then - BAND="B53" - elif [ $CHAN -lt 65536 ]; then - BAND="-" - elif [ $CHAN -lt 66436 ]; then - BAND="B65" - elif [ $CHAN -lt 67336 ]; then - BAND="B66" - elif [ $CHAN -lt 67536 ]; then - BAND="B67" - elif [ $CHAN -lt 67836 ]; then - BAND="B68" - elif [ $CHAN -lt 68336 ]; then - BAND="B69" - elif [ $CHAN -lt 68586 ]; then - BAND="B70" - elif [ $CHAN -lt 68936 ]; then - BAND="B71" - elif [ $CHAN -lt 68986 ]; then - BAND="B72" - elif [ $CHAN -lt 69036 ]; then - BAND="B73" - elif [ $CHAN -lt 69466 ]; then - BAND="B74" - elif [ $CHAN -lt 70316 ]; then - BAND="B75" - elif [ $CHAN -lt 70366 ]; then - BAND="B76" - elif [ $CHAN -lt 70546 ]; then - BAND="B85" - elif [ $CHAN -lt 70596 ]; then - BAND="B87" - elif [ $CHAN -lt 70646 ]; then - BAND="B88" - else - BAND="-" - fi -} - -decode_nr5g() { - if [ $CHAN -lt 123400 ]; then - BAND="-" - elif [ $CHAN -le 130400 ]; then - BAND="n71" - elif [ $CHAN -lt 143400 ]; then - BAND="-" - elif [ $CHAN -lt 145600 ]; then - BAND="n29" - elif [ $CHAN -eq 145600 ]; then - BAND="n29|n85" - elif [ $CHAN -lt 145800 ]; then - BAND="n85" - elif [ $CHAN -eq 145800 ]; then - BAND="n12|n85" - elif [ $CHAN -lt 147600 ]; then - BAND="n12|n85" - elif [ $CHAN -lt 149200 ]; then - BAND="n12|n67|n85" - elif [ $CHAN -eq 149200 ]; then - BAND="n12|n13|n67|n85" - elif [ $CHAN -le 151200 ]; then - BAND="n13|n67" - elif [ $CHAN -lt 151600 ]; then - BAND="n67" - elif [ $CHAN -eq 151600 ]; then - BAND="n14|n28|n67" - elif [ $CHAN -le 153600 ]; then - BAND="n14|n28" - elif [ $CHAN -lt 158200 ]; then - BAND="n28" - elif [ $CHAN -eq 158200 ]; then - BAND="n14|n20|n28" - elif [ $CHAN -le 160600 ]; then - BAND="n20|n28" - elif [ $CHAN -le 164200 ]; then - BAND="n20" - elif [ $CHAN -lt 171800 ]; then - BAND="-" - elif [ $CHAN -lt 172000 ]; then - BAND="n26" - elif [ $CHAN -lt 173800 ]; then - BAND="n18|n26" - elif [ $CHAN -le 175000 ]; then - BAND="n5|n18|n26" - elif [ $CHAN -le 178800 ]; then - BAND="n5|n26" - elif [ $CHAN -lt 185000 ]; then - BAND="-" - elif [ $CHAN -le 192000 ]; then - BAND="n8" - elif [ $CHAN -lt 285400 ]; then - BAND="-" - elif [ $CHAN -lt 286400 ]; then - BAND="n51|n76|n91|n93" - elif [ $CHAN -eq 286400 ]; then - BAND="n50|n51|n75|n76|n91|92|n93|94" - elif [ $CHAN -lt 295000 ]; then - BAND="n50|n75|n92|n94" - elif [ $CHAN -eq 295000 ]; then - BAND="n50|n74|n75|n92|n94" - elif [ $CHAN -le 303400 ]; then - BAND="n50|n74|n75|n92|n94" - elif [ $CHAN -le 303600 ]; then - BAND="n74" - elif [ $CHAN -lt 305000 ]; then - BAND="-" - elif [ $CHAN -le 311800 ]; then - BAND="n24" - elif [ $CHAN -lt 361000 ]; then - BAND="-" - elif [ $CHAN -lt 376000 ]; then - BAND="n3" - elif [ $CHAN -eq 376000 ]; then - BAND="n3|n39" - elif [ $CHAN -le 384000 ]; then - BAND="n39" - elif [ $CHAN -lt 386000 ]; then - BAND="-" - elif [ $CHAN -le 398000 ]; then - BAND="n2|n25" - elif [ $CHAN -lt 399000 ]; then - BAND="n25" - elif [ $CHAN -eq 399000 ]; then - BAND="n25|n70" - elif [ $CHAN -lt 402000 ]; then - BAND="n70" - elif [ $CHAN -eq 402000 ]; then - BAND="n34|n70" - elif [ $CHAN -le 404000 ]; then - BAND="n34|n70" - elif [ $CHAN -le 405000 ]; then - BAND="n34" - elif [ $CHAN -lt 422000 ]; then - BAND="-" - elif [ $CHAN -le 434000 ]; then - BAND="n1|n65|n66" - elif [ $CHAN -le 440000 ]; then - BAND="n65|n66" - elif [ $CHAN -lt 460000 ]; then - BAND="-" - elif [ $CHAN -lt 470000 ]; then - BAND="n40" - elif [ $CHAN -eq 470000 ]; then - BAND="n30|n40" - elif [ $CHAN -le 472000 ]; then - BAND="n30|n40" - elif [ $CHAN -le 480000 ]; then - BAND="n40" - elif [ $CHAN -lt 496700 ]; then - BAND="-" - elif [ $CHAN -le 499000 ]; then - BAND="n53" - elif [ $CHAN -lt 499200 ]; then - BAND="-" - elif [ $CHAN -lt 514000 ]; then - BAND="n41|n90" - elif [ $CHAN -eq 514000 ]; then - BAND="n38|n41|n90" - elif [ $CHAN -lt 524000 ]; then - BAND="n38|n41|n90" - elif [ $CHAN -eq 524000 ]; then - BAND="n7|n38|n41|n90" - elif [ $CHAN -lt 538000 ]; then - BAND="n7|n41|n90" - elif [ $CHAN -eq 538000 ]; then - BAND="n7|n90" - elif [ $CHAN -lt 620000 ]; then - BAND="-" - elif [ $CHAN -lt 636667 ]; then - BAND="n77|n78" - elif [ $CHAN -le 646666 ]; then - BAND="n48|n77|n78" - elif [ $CHAN -le 653333 ]; then - BAND="n77|n78" - elif [ $CHAN -le 680000 ]; then - BAND="n77" - elif [ $CHAN -lt 693334 ]; then - BAND="-" - elif [ $CHAN -le 733333 ]; then - BAND="n79" - elif [ $CHAN -lt 743333 ]; then - BAND="-" - elif [ $CHAN -lt 795000 ]; then - BAND="n46" - elif [ $CHAN -eq 795000 ]; then - BAND="n46|n96" - elif [ $CHAN -le 875000 ]; then - BAND="n96" - else - BAND="-" - fi -} - -if [ -z "$CHAN" ]; then - BAND="-" -elif [ "$CHAN" -lt 123400 ]; then - decode_lte -elif [ "$CHAN" -le 875000 ]; then - decode_nr5g -else - BAND="-" -fi -echo $BAND -exit diff --git a/rooter/ext-rooter-basic/files/usr/bin/encodemask b/rooter/ext-rooter-basic/files/usr/bin/encodemask deleted file mode 100644 index 6b3ed14..0000000 --- a/rooter/ext-rooter-basic/files/usr/bin/encodemask +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/lua - -mtab = {} -vtab = {1, 2, 4, 8} - -for i = 1, 32 do - mtab[i] = 0 -end - -numarg = #arg -for argval = 1, numarg do - band = arg[argval] - if tonumber(band) <= 128 then - idx = math.floor((band - 1) / 4) + 1 - idxr = 33 - idx - val = vtab[(band - ((idx - 1) * 4 ))] - mtab[idxr] = mtab[idxr] + val - end -end -for i = 1, 32 do - mtab[i] = string.format("%X", mtab[i]) -end - -print(table.concat(mtab)) diff --git a/rooter/ext-rooter-basic/files/usr/bin/jkillall b/rooter/ext-rooter-basic/files/usr/bin/jkillall deleted file mode 100644 index 3802082..0000000 --- a/rooter/ext-rooter-basic/files/usr/bin/jkillall +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -LOOKFOR=$1 -KILLLIST=$(ps | grep $LOOKFOR) -echo "$KILLLIST" | while read line; do - if `echo "$line" | grep "/$LOOKFOR" > /dev/null` ; then - PIDV=$(echo $line | grep -o "^[0-9]\{1,5\}" | grep -o "[0-9]\{1,5\}") - kill $PIDV - fi -done \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/usr/bin/rsrp2rssi b/rooter/ext-rooter-basic/files/usr/bin/rsrp2rssi deleted file mode 100644 index 06ad5b6..0000000 --- a/rooter/ext-rooter-basic/files/usr/bin/rsrp2rssi +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/lua - -rsrp = tonumber(arg[1]) -bw = tonumber(arg[2]) -if bw == 1.4 then - n = 6 -else - n = bw * 5 -end - -if tonumber(string.match(_VERSION, "%d+%.%d")) > 5.1 then - rssi = rsrp + (10 * math.log(n * 12, 10)) -else - rssi = rsrp + (10 * math.log10(n * 12)) -end -if rssi < -113 then - rssi = -113 -elseif rssi > -51 then - rssi = -51 -end -print(math.floor(rssi)) diff --git a/rooter/ext-rooter-basic/files/usr/bin/set_gpio b/rooter/ext-rooter-basic/files/usr/bin/set_gpio deleted file mode 100644 index 5fddfa7..0000000 --- a/rooter/ext-rooter-basic/files/usr/bin/set_gpio +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -PIN=$1 -VALUE=$2 - -PIN_FILE=/sys/class/gpio/gpio$PIN - -if [ -z "$PIN" -o -z "$VALUE" ]; then - exit 1 -fi - -echo $PIN >/sys/class/gpio/export - -if [ $(cat $PIN_FILE/direction) = "out" ]; then - echo $VALUE >$PIN_FILE/value -fi - -echo $PIN >/sys/class/gpio/unexport \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/usr/lib/custom/locktype.sh b/rooter/ext-rooter-basic/files/usr/lib/custom/locktype.sh deleted file mode 100644 index e0dc4f9..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/custom/locktype.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -CURRMODEM=$1 - -uVid=$(uci get modem.modem$CURRMODEM.uVid) -uPid=$(uci get modem.modem$CURRMODEM.uPid) - -if [ $uVid == "2c7c" ]; then - qc=$(uci get custom.atcmd.quectel) - echo "$qc" > /tmp/modemlock - echo " " >> /tmp/modemlock -else - if [ $uVid == "1199" ]; then - qc=$(uci get custom.atcmd.sierra) - echo "$qc" > /tmp/modemlock - echo " " >> /tmp/modemlock - else - qc=$(uci get custom.atcmd.generic) - echo "$qc" > /tmp/modemlock - echo " " >> /tmp/modemlock - fi -fi \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/usr/lib/custom/ttlx.sh b/rooter/ext-rooter-basic/files/usr/lib/custom/ttlx.sh deleted file mode 100644 index 79e52bd..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/custom/ttlx.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -log() { - logger -t "TTL Hack" "$@" -} - -cp -f /etc/firewall.user /etc/firewall.user.bk -sed /"#startTTL"/,/"#endTTL"/d /etc/firewall.user.bk > /etc/firewall.user -rm -f /etc/firewall.user.bk -/etc/init.d/firewall restart 2> /dev/null - diff --git a/rooter/ext-rooter-basic/files/usr/lib/gps/smsreply.sh b/rooter/ext-rooter-basic/files/usr/lib/gps/smsreply.sh deleted file mode 100644 index 9ca9af7..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/gps/smsreply.sh +++ /dev/null @@ -1,115 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -log() { - logger -t "GPS" "$@" -} - -CURRMODEM=$1 -SMSdest=$2 -MODTYPE=$(uci -q get modem.modem$CURRMODEM.modemtype) -if [ "$MODTYPE" == "2" -o "$MODTYPE" == "6" ]; then - COMMPORT="/dev/ttyUSB"$(uci -q get modem.modem$CURRMODEM.commport) -else - log "SMS position request from $SMSdest failed, modem $CURRMODEM is neither a Sierra nor Quectel" - exit -fi -GPSon=$(uci -q get gps.configuration.enabled) -if [ "$GPSon" != "1" -o $CURRMODEM == "2" ]; then - GPSon="0" - if [ $MODTYPE == "2" ]; then - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "AT!CUSTOM?") - GPSsel=$(echo $OX | grep "GPSSEL") - GPSenable=$(echo $OX | grep "GPSENABLE") - if [ -z "$GPSsel" -o -z "$GPSenable" ]; then - ATCMDD="AT!ENTERCND=\"A710\"" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - if [ -z "$GPSsel" ]; then - ATCMDD="at!custom=\"GPSSEL\",1" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - fi - if [ -z "$GPSenable" ]; then - ATCMDD="at!custom=\"GPSENABLE\",1" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - ATCMDD="AT+CFUN=0;+CFUN=1,1" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - sleep 30 - fi - ATCMDD="AT!ENTERCND=\"AWRONG\"" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - fi - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "AT!GPSTRACK=1,240,30,1000,5") - GPSendcmd="AT!GPSEND=0" - else - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "AT+QGPS?") - err=$(echo "$OX" | grep "+QGPS: 1") - if [ -z "$err" ]; then - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "AT+QGPS=1") - fi - ATCMDD="AT+QCFG=\"gpsdrx\"" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - err=$(echo "$OX" | grep "0") - if [ -n "$err" ]; then - ATCMDD="AT+QCFG=\"gpsdrx\",1" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - fi - GPSendcmd="AT+QGPSEND" - fi -fi -SMStime=$(($(date +%s) + 120)) -LAT="" -LON="" -while true; do - if [ $MODTYPE == "2" ]; then - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "AT!GPSLOC?") - LATx=$(echo $OX | grep -o "Lat:[^(]\+([^)]\+" | grep -o "0x.\+") - LONx=$(echo $OX | grep -o "Lon:[^(]\+([^)]\+" | grep -o "0x.\+") - if [ -n "$LATx" -a -n "$LONx" ]; then - if [ $(printf "%d" $LATx) -gt $(printf "%d" 0x7FFFFFFF) ]; then - LATx=$(( ($LATx ^ 0xFFFFFFFF) + 1 )) - LAT="-"$(lua -e "print(string.format(\"%.5f\", $LATx * (180 / 2^25)))") - else - LAT=$(lua -e "print(string.format(\"%.5f\", $LATx * (180 / 2^25)))") - fi - if [ $(printf "%d" $LONx) -gt $(printf "%d" 0x7FFFFFFF) ]; then - LONx=$(( ($LONx ^ 0xFFFFFFFF) + 1 )) - LON="-"$(lua -e "print(string.format(\"%.5f\", $LONx * (180 / 2^25)))") - else - LON=$(lua -e "print(string.format(\"%.5f\", $LONx * (180 / 2^25)))") - fi - fi - else - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "AT+QGPSLOC=2") - LAT=$(echo $OX | grep -o "+QGPSLOC:[ .0-9]\+,.\+" | cut -d, -f2) - LON=$(echo $OX | grep -o "+QGPSLOC:[ .0-9]\+,.\+" | cut -d, -f3) - fi - if [ -n "$LAT" -a -n "$LON" ]; then - SMSMODEM=$(uci -q get modem.general.smsnum) - if [ "$CURRMODEM" != "$SMSMODEM" ]; then - uci set modem.general.smsnum=$CURRMODEM - uci commit modem.general.smsnum - fi - OY=$(/usr/lib/sms/smsout.sh "$SMSdest" "$LAT $LON") - OYsent=$(echo $OY | grep -o "SMS sent") - if [ -n "$OYsent" ]; then - /usr/lib/sms/sys2sms.sh "ROOter" "GPS coordinates sent to $SMSdest" - log "GPS coordinates sent to $SMSdest" - else - log "Failed to send GPS coordinates sent to $SMSdest" - fi - if [ "$CURRMODEM" != "$SMSMODEM" ]; then - uci set modem.general.smsnum=$SMSMODEM - uci commit modem.general.smsnum - fi - break - fi - if [ $(date +%s) -gt $SMStime ]; then - log "Failed request from $SMSdest by SMS for LAT/LON, position not available" - break - fi - sleep 8 -done -if [ "$GPSon" != "1" ]; then - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$GPSendcmd") -fi diff --git a/rooter/ext-rooter-basic/files/usr/lib/lua/luci/controller/admin/modem.lua b/rooter/ext-rooter-basic/files/usr/lib/lua/luci/controller/admin/modem.lua deleted file mode 100644 index 9c0d896..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/lua/luci/controller/admin/modem.lua +++ /dev/null @@ -1,664 +0,0 @@ -module("luci.controller.admin.modem", package.seeall) - -I18N = require "luci.i18n" -translate = I18N.translate - -function index() - entry({"admin", "modem"}, firstchild(), translate("移动数据"), 25).dependent=false - entry({"admin", "modem", "prof"}, cbi("rooter/profiles"), translate("DNS / APN / 监控配置"), 2) - entry({"admin", "modem", "nets"}, template("rooter/net_status"), translate("信号状态 / 模块状态"), 30) - entry({"admin", "modem", "debug"}, template("rooter/debug"), translate("后台AT调试信息"), 50) - entry({"admin", "modem", "cust"}, cbi("rooter/customize"), translate("自定义模块端口配置"), 55) - entry({"admin", "modem", "log"}, template("rooter/log"), translate("连接日志"), 60) - entry({"admin", "modem", "misc"}, template("rooter/misc"), translate("锁频段 / 锁PCI / 切协议"), 40) - - entry({"admin", "modem", "block"}, - template("rooter/bandlock")) - - - entry({"admin", "modem", "get_csq"}, call("action_get_csq")) - entry({"admin", "modem", "change_port"}, call("action_change_port")) - entry({"admin", "modem", "change_mode"}, call("action_change_mode")) - entry({"admin", "modem", "change_modem"}, call("action_change_modem")) - entry({"admin", "modem", "change_modemdn"}, call("action_change_modemdn")) - entry({"admin", "modem", "change_misc"}, call("action_change_misc")) - entry({"admin", "modem", "change_miscdn"}, call("action_change_miscdn")) - entry({"admin", "modem", "get_log"}, call("action_get_log")) - entry({"admin", "modem", "check_misc"}, call("action_check_misc")) - entry({"admin", "modem", "pwrtoggle"}, call("action_pwrtoggle")) - entry({"admin", "modem", "disconnect"}, call("action_disconnect")) - entry({"admin", "modem", "connect"}, call("action_connect")) - entry({"admin", "modem", "get_atlog"}, call("action_get_atlog")) - entry({"admin", "modem", "send_atcmd"}, call("action_send_atcmd")) - entry({"admin", "modem", "change_rate"}, call("action_change_rate")) - entry({"admin", "modem", "change_phone"}, call("action_change_phone")) - entry({"admin", "modem", "clear_log"}, call("action_clear_log")) - entry({"admin", "modem", "externalip"}, call("action_externalip")) - entry({"admin", "modem", "send_scancmd"}, call("action_send_scancmd")) - entry({"admin", "modem", "send_lockcmd"}, call("action_send_lockcmd")) - entry({"admin", "modem", "extping"}, call("action_extping")) - entry({"admin", "modem", "change_cell"}, call("action_change_cell")) - entry({"admin", "modem", "change_proto"}, call("action_change_proto")) - entry({"admin", "modem", "setpin"}, call("action_setpin")) -end - -function trim(s) - return (s:gsub("^%s*(.-)%s*$", "%1")) -end - -function action_get_atlog() - local file - local rv ={} - - file = io.open("/tmp/atlog", "r") - if file ~= nil then - local tmp = file:read("*all") - rv["log"] = tmp - file:close() - else - rv["log"] = "No entries in log file" - end - - luci.http.prepare_content("application/json") - luci.http.write_json(rv) -end - -function action_get_log() - local file - local rv ={} - - file = io.open("/usr/lib/rooter/log/connect.log", "r") - if file ~= nil then - local tmp = file:read("*all") - rv["log"] = tmp - file:close() - else - rv["log"] = translate("No entries in log file") - end - - luci.http.prepare_content("application/json") - luci.http.write_json(rv) -end - -function action_disconnect() - local set = luci.http.formvalue("set") - os.execute("/usr/lib/rooter/connect/disconnect.sh") -end - -function action_connect() - local set = luci.http.formvalue("set") - miscnum = luci.model.uci.cursor():get("modem", "general", "miscnum") - os.execute("/tmp/links/reconnect" .. miscnum .. " " .. miscnum) -end - -function action_pwrtoggle() - local set = luci.http.formvalue("set") - os.execute("/usr/lib/rooter/pwrtoggle.sh " .. set) -end - -function action_send_atcmd() - local rv ={} - modnum = luci.model.uci.cursor():get("modem", "general", "miscnum") - local file - local set = luci.http.formvalue("set") - fixed = string.gsub(set, "\"", "~") - os.execute("/usr/lib/rooter/luci/atcmd.sh \'" .. fixed .. "\'") - - result = "/tmp/result" .. modnum .. ".at" - file = io.open(result, "r") - if file ~= nil then - rv["result"] = file:read("*all") - file:close() - os.execute("/usr/lib/rooter/luci/luaops.sh delete /tmp/result" .. modnum .. ".at") - else - rv["result"] = " " - end - - luci.http.prepare_content("application/json") - luci.http.write_json(rv) -end - -function action_check_misc() - local rv ={} - local bnd1 = {} - local bnd2 = {} - local bnd31 = {} - local bnd32 = {} - local bnd33 = {} - local at1 = {} - local at2 = {} - local file - local file1 - local active - local connect - - miscnum = luci.model.uci.cursor():get("modem", "general", "miscnum") - conn = "Modem #" .. miscnum - rv["conntype"] = conn - empty = luci.model.uci.cursor():get("modem", "modem" .. miscnum, "empty") - if empty == "1" then - active = "0" - rv["netmode"] = "-" - else - active = luci.model.uci.cursor():get("modem", "modem" .. miscnum, "active") - if active == "1" then - connect = luci.model.uci.cursor():get("modem", "modem" .. miscnum, "connected") - if connect == "0" then - active = "1" - else - active = "2" - end - uVid = luci.model.uci.cursor():get("modem", "modem" .. miscnum, "uVid") - rv["uVid"] = uVid - uPid = luci.model.uci.cursor():get("modem", "modem" .. miscnum, "uPid") - rv["uPid"] = uPid - file = io.open("/etc/fake", "r") - if file == nil then - rv["fake"] = "0" - else - rv["fake"] = "1" - file:close() - end - - rv["cenable"] = luci.model.uci.cursor():get("custom", "bandlock", "cenable" .. miscnum) - if rv["cenable"] == nil then - rv["cenable"] = "0" - end - rv["earfcn"] = luci.model.uci.cursor():get("custom", "bandlock", "earfcn" .. miscnum) - if rv["earfcn"] == nil then - rv["earfcn"] = "0" - end - rv["pci"] = luci.model.uci.cursor():get("custom", "bandlock", "pci" .. miscnum) - if rv["pci"] == nil then - rv["pci"] = "0" - end - - rv["earfcn1"] = luci.model.uci.cursor():get("custom", "bandlock", "earfcn1" .. miscnum) - if rv["earfcn1"] == nil then - rv["earfcn1"] = "0" - end - rv["pci1"] = luci.model.uci.cursor():get("custom", "bandlock", "pci1" .. miscnum) - if rv["pci1"] == nil then - rv["pci1"] = "0" - end - - rv["earfcn2"] = luci.model.uci.cursor():get("custom", "bandlock", "earfcn2" .. miscnum) - if rv["earfcn2"] == nil then - rv["earfcn2"] = "0" - end - rv["pci2"] = luci.model.uci.cursor():get("custom", "bandlock", "pci2" .. miscnum) - if rv["pci2"] == nil then - rv["pci2"] = "0" - end - - rv["earfcn3"] = luci.model.uci.cursor():get("custom", "bandlock", "earfcn3" .. miscnum) - if rv["earfcn3"] == nil then - rv["earfcn3"] = "0" - end - rv["pci3"] = luci.model.uci.cursor():get("custom", "bandlock", "pci3" .. miscnum) - if rv["pci3"] == nil then - rv["pci3"] = "0" - end - - file = io.open("/tmp/bmask", "r") - if file == nil then - rv["bndstr"] = "0" - rv["bndsup"] = "0" - else - line = file:read("*line") - rv["bndstr"] = line - line = file:read("*line") - rv["bndstr5g"] = line - line = file:read("*line") - rv["bndstr5gsa"] = line - line = file:read("*line") - rv["bndsup"] = line - line = file:read("*line") - rv["bndsup5g"] = line - line = file:read("*line") - rv["bndsup5gsa"] = line - line = file:read("*line") - ca = line - if ca ~= nil then - line = file:read("*line") - ca3 = line - end - file:close() - - indx = 0 - if ca ~= nil then - file = io.open("/usr/lib/rooter/luci/" .. ca, "r") - if file ~= nil then - line = file:read("*line") - repeat - s, e = line:find(" ") - b1 = trim(line:sub(1, s-1)) - bnd1[indx] = b1 - b2 = trim(line:sub(s+1)) - bnd2[indx] = b2 - indx = indx +1 - line = file:read("*line") - until line == nil - file:close() - end - end - rv['b1'] = bnd1 - rv['b2'] = bnd2 - rv['indx'] = tostring(indx) - - indx3 = 0 - if ca3 ~= nil then - file = io.open("/usr/lib/rooter/luci/" .. ca3, "r") - if file ~= nil then - line = file:read("*line") - repeat - s, e = line:find(" ") - b1 = trim(line:sub(1, s-1)) - bnd31[indx3] = b1 - cs, ce = line:find(" ", s+1) - b2 = trim(line:sub(s+1, cs-1)) - bnd32[indx3] = b2 - b3 = trim(line:sub(cs+1)) - bnd33[indx3] = b3 - indx3 = indx3 +1 - line = file:read("*line") - until line == nil - file:close() - end - end - rv['b31'] = bnd31 - rv['b32'] = bnd32 - rv['b33'] = bnd33 - rv['indx3'] = tostring(indx3) - - end - end - netmode = luci.model.uci.cursor():get("modem", "modem" .. miscnum, "netmode") - rv["netmode"] = netmode - end - rv["pin"] = luci.model.uci.cursor():get("modem", "general", "pin") - rv["plock"] = luci.model.uci.cursor():get("custom", "atcmd", "lock") - if rv["plock"] == "1" then - rv["atlock"] = luci.model.uci.cursor():get("custom", "menu", "full") - generic = luci.model.uci.cursor():get("custom", "atcmd", "generic") - aindx = 0 - if active == "0" then - file = io.open(generic, "r") - else - os.execute("/usr/lib/custom/locktype.sh " .. miscnum ) - file1 = io.open("/tmp/modemlock", "r") - if file1 ~= nil then - linex = file1:read("*line") - file1:close() - file = io.open(linex, "r") - else - file = io.open(generic, "r") - end - end - if file ~= nil then - line = file:read("*line") - repeat - at1[aindx] = line - line = file:read("*line") - at2[aindx] = line - aindx = aindx +1 - line = file:read("*line") - until line == nil - file:close() - rv['at1'] = at1 - rv['at2'] = at2 - rv['aindx'] = tostring(aindx) - end - end - rv["active"] = active - file = io.open("/tmp/gpiopin", "r") - if file == nil then - rv.gpio = "0" - else - rv.gpio = "1" - line = file:read("*line") - line = file:read("*line") - if line ~= nil then - rv.gpio = "2" - end - file:close() - end - file = io.open("/sys/bus/usb/drivers/usb/usb1", "r") - if file == nil then - rv["usb"] = "0" - else - io.close(file) - rv["usb"] = "1" - end - file = io.open("/sys/bus/usb/drivers/usb/usb2", "r") - if file ~= nill then - io.close(file) - rv["usb"] = "2" - end - proto = luci.model.uci.cursor():get("modem", "modem" .. miscnum, "proto") - rv["proto"] = proto - - model = luci.model.uci.cursor():get("modem", "modem" .. miscnum, "model") - rv["model"] = model - - celltype = luci.model.uci.cursor():get("modem", "modem" .. miscnum, "celltype") - rv["celltype"] = celltype - cmode = luci.model.uci.cursor():get("modem", "modem" .. miscnum, "cmode") - if cmode == "0" then - rv["netmode"] = "10" - end - - luci.http.prepare_content("application/json") - luci.http.write_json(rv) -end - -function lshift(x, by) - return x * 2 ^ by -end - -function rshift(x, by) - return math.floor(x / 2 ^ by) -end - -function action_change_mode() - local set = tonumber(luci.http.formvalue("set")) - local modemtype = rshift(set, 4) - local temp = lshift(modemtype, 4) - local netmode = set - temp - os.execute("/usr/lib/rooter/luci/modechge.sh " .. modemtype .. " " .. netmode) -end - -function action_change_port() - local set = tonumber(luci.http.formvalue("set")) - if set ~= nil and set > 0 then - if set == 1 then - os.execute("/usr/lib/rooter/luci/portchge.sh dwn") - else - os.execute("/usr/lib/rooter/luci/portchge.sh up") - end - end -end - -function action_change_misc() - os.execute("/usr/lib/rooter/luci/modemchge.sh misc 1") -end - -function action_change_miscdn() - os.execute("/usr/lib/rooter/luci/modemchge.sh misc 0") -end - -function action_change_modem() - os.execute("/usr/lib/rooter/luci/modemchge.sh modem 1") -end - -function action_change_modemdn() - os.execute("/usr/lib/rooter/luci/modemchge.sh modem 0") -end - -function action_get_csq() - modnum = luci.model.uci.cursor():get("modem", "general", "modemnum") - local file - stat = "/tmp/status" .. modnum .. ".file" - file = io.open(stat, "r") - - local rv ={} - - rv["port"] = file:read("*line") - rv["csq"] = file:read("*line") - rv["per"] = file:read("*line") - rv["rssi"] = file:read("*line") - rv["modem"] = file:read("*line") - rv["cops"] = file:read("*line") - rv["mode"] = file:read("*line") - rv["lac"] = file:read("*line") - rv["lacn"] = file:read("*line") - rv["cid"] = file:read("*line") - rv["cidn"] = file:read("*line") - rv["mcc"] = file:read("*line") - rv["mnc"] = file:read("*line") - rv["rnc"] = file:read("*line") - rv["rncn"] = file:read("*line") - rv["down"] = file:read("*line") - rv["up"] = file:read("*line") - rv["ecio"] = file:read("*line") - rv["rscp"] = file:read("*line") - rv["ecio1"] = file:read("*line") - rv["rscp1"] = file:read("*line") - rv["netmode"] = file:read("*line") - rv["cell"] = file:read("*line") - rv["modtype"] = file:read("*line") - rv["conntype"] = file:read("*line") - rv["channel"] = file:read("*line") - rv["phone"] = file:read("*line") - file:read("*line") - rv["lband"] = file:read("*line") - rv["tempur"] = file:read("*line") - rv["proto"] = file:read("*line") - rv["pci"] = file:read("*line") - rv["sinr"] = file:read("*line") - --rv["lat"] = file:read("*line") - --rv["long"] = file:read("*line") - - file:close() - - cmode = luci.model.uci.cursor():get("modem", "modem" .. modnum, "cmode") - if cmode == "0" then - rv["netmode"] = "10" - end - - rssi = rv["rssi"] - ecio = rv["ecio"] - rscp = rv["rscp"] - ecio1 = rv["ecio1"] - rscp1 = rv["rscp1"] - - if ecio == nil then - ecio = "-" - end - if ecio1 == nil then - ecio1 = "-" - end - if rscp == nil then - rscp = "-" - end - if rscp1 == nil then - rscp1 = "-" - end - - if ecio ~= "-" then - rv["ecio"] = ecio .. " dB" - end - if rscp ~= "-" then - rv["rscp"] = rscp .. " dBm" - end - if ecio1 ~= " " then - rv["ecio1"] = " (" .. ecio1 .. " dB)" - end - if rscp1 ~= " " then - rv["rscp1"] = " (" .. rscp1 .. " dBm)" - end - - if not nixio.fs.access("/etc/netspeed") then - rv["crate"] = translate("快速(每10秒更新一次)") - else - rv["crate"] = translate("缓慢(每60秒更新一次)") - end - - stat = "/tmp/msimdata" .. modnum - file = io.open(stat, "r") - if file == nil then - rv["modid"] = " " - rv["imei"] = " " - rv["imsi"] = " " - rv["iccid"] = " " - rv["host"] = "0" - else - rv["modid"] = file:read("*line") - rv["imei"] = file:read("*line") - rv["imsi"] = file:read("*line") - rv["iccid"] = file:read("*line") - rv["host"] = file:read("*line") - file:close() - end - - gpsdata = "/tmp/gpsdata1" - file = io.open(gpsdata, "r") - if file == nil then - rv["lat"] = "-" - rv["long"] = "-" - else - rv["lat"] = file:read("*line") - rv["long"] = file:read("*line") - file:close() - end - - stat = "/tmp/msimnum" .. modnum - file = io.open(stat, "r") - if file == nil then - rv["phone"] = "-" - rv["phonen"] = " " - else - rv["phone"] = file:read("*line") - rv["phonen"] = file:read("*line") - file:close() - end - - stat = "/tmp/simpin" .. modnum - file = io.open(stat, "r") - if file == nil then - rv["simerr"] = "0" - else - typ = file:read("*line") - if typ == "0" then - rv["simerr"] = "1" - else - if typ == "1" then - rv["simerr"] = "2" - else - if typ == "2" then - rv["simerr"] = "3" - else - rv["simerr"] = "4" - end - end - end - file:close() - end - - luci.http.prepare_content("application/json") - luci.http.write_json(rv) -end - -function action_change_rate() - local set = luci.http.formvalue("set") - if set == "1" then - os.execute("rm -f /etc/netspeed") - else - os.execute("echo \"0\" > /etc/netspeed") - end -end - -function action_change_phone() - local set = luci.http.formvalue("set") - s, e = string.find(set, "|") - pno = string.sub(set, 1, s-1) - pnon = string.sub(set, e+1) - modnum = luci.model.uci.cursor():get("modem", "general", "modemnum") - os.execute("/usr/lib/rooter/common/phone.sh " .. modnum .. " " .. pno .. " \"" .. pnon .. "\"") -end - -function action_clear_log() - local file - file = io.open("/usr/lib/rooter/log/connect.log", "w") - file:close() - os.execute("/usr/lib/rooter/log/logger 'Connection Log Cleared by User'") -end - -function action_externalip() - local rv ={} - - os.execute("rm -f /tmp/ipip; wget -O /tmp/ipip http://ipecho.net/plain > /dev/null 2>&1") - file = io.open("/tmp/ipip", "r") - if file == nil then - rv["extip"] = translate("Not Available") - else - rv["extip"] = file:read("*line") - if rv["extip"] == nil then - rv["extip"] = translate("Not Available") - end - file:close() - end - - luci.http.prepare_content("application/json") - luci.http.write_json(rv) -end - -function action_send_scancmd() - local rv ={} - local file - os.execute("/usr/lib/rooter/luci/scancmd.sh") - - result = "/tmp/scan" - file = io.open(result, "r") - if file ~= nil then - rv["result"] = file:read("*all") - file:close() - os.execute("/usr/lib/rooter/luci/luaops.sh delete /tmp/scan") - else - rv["result"] = " " - end - - luci.http.prepare_content("application/json") - luci.http.write_json(rv) -end - -function action_send_lockcmd() - local set = luci.http.formvalue("set") - os.execute("/usr/lib/rooter/luci/lock.sh " .. set) -end - -function action_extping() - local rv ={} - - enable = luci.model.uci.cursor():get("ping", "ping", "enable") - if enable == "0" then - rv["extping"] = translate("Not Enabled") - else - conn = luci.model.uci.cursor():get("ping", "ping", "conn") - if conn == "1" then - rv["extping"] = translate("Enabled, Waiting for Modem to Connect") - else - if conn == "2" then - rv["extping"] = translate("Enabled, Ping Test was Good") - else - if conn == "3" then - rv["extping"] = translate("Enabled, Ping Test Failed, Restarting Modem, Waiting for Reconnection") - else - if conn == "4" then - rv["extping"] = translate("Enabled, Connected, Waiting for Ping Test") - else - rv["extping"] = translate("Enabled, Unknown State") - end - end - end - end - end - - luci.http.prepare_content("application/json") - luci.http.write_json(rv) -end - -function action_change_cell() - local set = luci.http.formvalue("set") - os.execute("/usr/lib/rooter/luci/setcell.sh " .. "\"" .. set .. "\"") -end - -function action_change_proto() - local set = luci.http.formvalue("set") - os.execute("/usr/lib/rooter/luci/protochnge.sh " ..set) -end - -function action_setpin() - local set = luci.http.formvalue("set") - os.execute("uci set modem.general.pin=" .. set .. "; uci commit modem") -end diff --git a/rooter/ext-rooter-basic/files/usr/lib/lua/luci/controller/modlog.lua b/rooter/ext-rooter-basic/files/usr/lib/lua/luci/controller/modlog.lua deleted file mode 100644 index b37f797..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/lua/luci/controller/modlog.lua +++ /dev/null @@ -1,29 +0,0 @@ -module("luci.controller.modlog", package.seeall) - -I18N = require "luci.i18n" -translate = I18N.translate - -function index() - local page - page = entry({"admin", "modem", "modlog"}, template("modlog/modlog"), _(translate("模块连接日志信息")), 61) - page.dependent = true - - entry({"admin", "status", "modlog"}, call("action_modlog")) -end - -function action_modlog() - local file - local rv ={} - - file = io.open("/tmp/modlog.log", "r") - if file ~= nil then - local tmp = file:read("*all") - rv["log"] = tmp - file:close() - else - rv["log"] = translate("No entries in log file") - end - - luci.http.prepare_content("application/json") - luci.http.write_json(rv) -end diff --git a/rooter/ext-rooter-basic/files/usr/lib/lua/luci/controller/poweroff.lua b/rooter/ext-rooter-basic/files/usr/lib/lua/luci/controller/poweroff.lua deleted file mode 100644 index 77531f7..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/lua/luci/controller/poweroff.lua +++ /dev/null @@ -1,13 +0,0 @@ -module("luci.controller.poweroff", package.seeall) - -function index() - local page - page = entry({"admin", "system", "poweroff"}, template("admin_system/poweroff"), _("System Stop"), 95) - entry({"admin", "system", "do_poweroff"}, call("action_poweroff")) - page.dependent = true -end - -function action_poweroff() - local set = luci.http.formvalue("set") - os.execute("/usr/lib/rooter/shutall.sh") -end diff --git a/rooter/ext-rooter-basic/files/usr/lib/lua/luci/controller/profile.lua b/rooter/ext-rooter-basic/files/usr/lib/lua/luci/controller/profile.lua deleted file mode 100644 index fce9b46..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/lua/luci/controller/profile.lua +++ /dev/null @@ -1,40 +0,0 @@ -module("luci.controller.profile", package.seeall) -function index() - entry({"admin", "profile", "savecfg"}, call("action_savecfg")) - entry({"admin", "profile", "loadcfg"}, call("action_loadcfg")) - entry({"admin", "profile", "loadcfg1"}, call("action_loadcfg1")) - entry({"admin", "profile", "loadcfg2"}, call("action_loadcfg2")) -end - -function action_savecfg() - os.execute('/usr/lib/profile/savecfg.sh') -end - -function action_loadcfg() - local set = luci.http.formvalue("set") - local set1 = luci.http.formvalue("set1") - local tfile = io.open("/tmp/profilename", "w") - tfile:write(set, "\n") - if set1 ~= "~~" then - tfile:write(set1, "\n") - end - tfile:close() - os.execute("/usr/lib/profile/loadcfg.sh") -end - -function action_loadcfg1() - local set = luci.http.formvalue("set") - local tfile = io.open("/tmp/profilename", "w") - tfile:write(set) - tfile:close() -end - -function action_loadcfg2() - local set1 = luci.http.formvalue("set1") - if set1 ~= "~~" then - local tfile = io.open("/tmp/profilename", "a") - tfile:write(set1) - tfile:close() - end - os.execute("/usr/lib/profile/loadcfg.sh") -end \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/usr/lib/lua/luci/model/cbi/firewall/ttlx.lua b/rooter/ext-rooter-basic/files/usr/lib/lua/luci/model/cbi/firewall/ttlx.lua deleted file mode 100644 index b6001f0..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/lua/luci/model/cbi/firewall/ttlx.lua +++ /dev/null @@ -1,30 +0,0 @@ -local utl = require "luci.util" -local uci = require "luci.model.uci".cursor() - -m = Map("ttl", "Firewall - Custom TTL Settings", - translate("Enable and use a custom TTL value with modems")) - -m.on_after_save = function(self) - --luci.sys.call("/usr/lib/custom/ttlx.sh &") -end - -gw = m:section(TypedSection, "ttl", translate("Settings")) -gw.anonymous = true - -en = gw:option(Flag, "enabled", translate("Enabled :"), translate("Enable the use of custom TTL value")); -en.default="0" -en.rmempty = false; -en.optional=false; - -val = gw:option(ListValue, "value", translate("TTL Value :"), translate("Custom TTL value to be used on modems")); -val.default="65" -val:depends("enabled", "1") -val:value("63", "63") -val:value("64", "64") -val:value("65", "65") -val:value("66", "66") -val:value("67", "67") -val:value("117", "117") -val:value("0", "TTL-INC 1") - -return m \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/usr/lib/lua/luci/model/cbi/rooter/customize.lua b/rooter/ext-rooter-basic/files/usr/lib/lua/luci/model/cbi/rooter/customize.lua deleted file mode 100644 index acc7eb5..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/lua/luci/model/cbi/rooter/customize.lua +++ /dev/null @@ -1,156 +0,0 @@ -local utl = require "luci.util" - -local modemfile = "/etc/config/modem.data" -local modemdata = {} -local count -local tabdata = {} - -function process_line(xline, cnt) - local data = {} - local pline = xline - local start = 1 - for i=1,3 do - s, e = string.find(pline, " ") - data[i] = string.sub(pline, start, s-1) - pline = string.sub(pline, e+1) - end - data[4] = pline - modemdata[cnt] = data -end - -function read_modem() - count = 0 - local file = io.open(modemfile, "r") - if file == nil then - return - end - repeat - local line = file:read("*line") - if line == nil then - break - end - if string.len(line) < 5 then - break - end - count = count + 1 - process_line(line, count) - until 1==0 - file:close() -end - -function insert_modem() - local location = count + 1 - - if count > 0 then - for j=1,count do - local mdata = modemdata[j] - if mdata[1] == tabdata[1] and mdata[2] == tabdata[2] then - location = j - end - end - end - - if count == 0 then - count = 1 - else - if location > count then - count = count + 1 - end - end - modemdata[location] = tabdata -end - -function write_modem() - os.remove(modemfile) - local file = io.open(modemfile, "w") - for k=1,count do - local mdata = modemdata[k] - for l=1,3 do - file:write(mdata[l], " ") - end - file:write(mdata[4], "\n") - end - file:close() -end - -function process_tabdata() - if tabdata[1] ~= "nil" and tabdata[2] ~= "nil" then - read_modem() - insert_modem() - write_modem() - end -end - -m = Map("modem", translate("自定义4G/5G 模块支持"), translate(" 修改某个模块使用的通信端口")) - -m.on_after_commit = function(self) - -- all written config names are in self.parsechain - local sobj - for _, sobj in ipairs(self.children) do - local sids - if utl.instanceof(sobj, NamedSection) then - sids = { sobj.section } - elseif utl.instanceof(sobj, TypedSection) then - sids = sobj:cfgsections() - end - local sid, fld, fln - - if not utl.instanceof(sobj, SimpleSection) then - for _, sid in ipairs(sids) do - for fln, fld in ipairs(sobj.children) do - local val = fld:formvalue(sid) - if val == nil or string.len(val) == 0 then - val = "nil" - end - tabdata[fln] = val - end - end - end - end - process_tabdata() -end - --- --- Vid Pid Dataport Commport --- - -e = m:section(TypedSection, "new", translate("模块端口 :")) - -a1 = e:option(Value, "vid", translate("模块 VID:")); -a1.optional=false; - -b1 = e:option(Value, "pid", translate("模块 ID :")); -b1.optional=false; - -p3 = e:option(ListValue, "port", translate("PPP 拨号端口 :")) -p3:value("tty", "default") -p3:value("tty0", "/dev/ttyUSB0") -p3:value("tty1", "/dev/ttyUSB1") -p3:value("tty2", "/dev/ttyUSB2") -p3:value("tty3", "/dev/ttyUSB3") -p3:value("tty4", "/dev/ttyUSB4") -p3:value("tty5", "/dev/ttyUSB5") -p3.default = "tty" - -p4 = e:option(ListValue, "comm", translate("通讯端口 :")) -p4:value("tty", "default") -p4:value("tty0", "/dev/ttyUSB0") -p4:value("tty1", "/dev/ttyUSB1") -p4:value("tty2", "/dev/ttyUSB2") -p4:value("tty3", "/dev/ttyUSB3") -p4:value("tty4", "/dev/ttyUSB4") -p4:value("tty5", "/dev/ttyUSB5") -p4.default = "tty" - -b3 = e:option(DummyValue, "blank", " "); - -btn = e:option(Button, "_btn", translate(" ")) -btn.inputtitle = translate("删除模块端口配置") -btn.inputstyle = "apply" -function btn.write() - luci.sys.call("/usr/lib/rooter/luci/luaops.sh delete /etc/config/modem.data") -end - -m:section(SimpleSection).template = "rooter/custom" - -return m diff --git a/rooter/ext-rooter-basic/files/usr/lib/lua/luci/model/cbi/rooter/profiles.lua b/rooter/ext-rooter-basic/files/usr/lib/lua/luci/model/cbi/rooter/profiles.lua deleted file mode 100644 index 89789eb..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/lua/luci/model/cbi/rooter/profiles.lua +++ /dev/null @@ -1,828 +0,0 @@ -local utl = require "luci.util" -local uci = require "luci.model.uci".cursor() -local sys = require "luci.sys" -local fs = require "nixio.fs" - -local maxmodem = luci.model.uci.cursor():get("modem", "general", "max") -local profsave = luci.model.uci.cursor():get("custom", "profile", "save") -if profsave == nil then - profsave ="0" -end -local multilock = luci.model.uci.cursor():get("custom", "multiuser", "multi") or "0" -local rootlock = luci.model.uci.cursor():get("custom", "multiuser", "root") or "0" - -m = Map("profile", translate("模块DNS / APN 配置"),translate("")) - -m.on_after_commit = function(self) - if profsave == "1" then - luci.sys.call("/usr/lib/profile/restart.sh &") - end -end - -if profsave == "1" then - m:section(SimpleSection).template = "rooter/profile" - ds = m:section(TypedSection, "simpin", translate("SIM卡Pin码 :"), translate("如果配置文件钟没有SIM PIN码则使用")) - ds.anonymous = true - - ms = ds:option(Value, "pin", translate("PIN :")); - ms.rmempty = true; - ms.default = "" -end - - --- --- Default profile --- - -di = m:section(TypedSection, "default", translate("默认"), translate("一般只需要填写您运营商的APN即可,一般已经自动加载识别了,奇葩虚拟运营商你也可以继续填 Tips:模块下次重连后生效,如果你要现在生效,请保存后重启模块)## 华为天际通5G SA APN:5gscuiot ##")) -di.anonymous = true -di:tab("default", translate("通用")) -di:tab("advance", translate("高级")) -di:tab("connect", translate("连接状态监控")) -if (multilock == "0") or (multilock == "1" and rootlock == "1") then - di:tab("bwidth", translate("Bandwidth Reporting频宽报告")) -end - -this_tab = "default" - -ma = di:taboption(this_tab, Value, "apn", "APN :"); -ma.rmempty = true; -ma.default = "broadband" - -tt = di:taboption(this_tab, ListValue, "ttl", translate("设定TTL值 :")) -tt:value("0", translate("使用当前值")) -tt:value("1", translate("不配置TTL值")) -tt:value("63", "TTL 63") -tt:value("64", "TTL 64") -tt:value("65", "TTL 65") -tt:value("66", "TTL 66") -tt:value("67", "TTL 67") -tt:value("117", "TTL 117") -tt:value("TTL-INC 1", "TTL-INC 1") -tt.default = "0" - -ynl = di:taboption(this_tab, ListValue, "hostless", translate("设定通信模块TTL")); -ynl:value("0", "否") -ynl:value("1", translate("是")) -ynl.default=0 - -pt = di:taboption(this_tab, ListValue, "pdptype", translate("IP协议类型 :")) -pt:value("IP", "IPv4") -pt:value("IPV6", "IPv6") -pt:value("IPV4V6", "IPv4+IPv6") -pt:value("0", "默认") -pt.default = "0" - -cmcc = di:taboption(this_tab, Value, "context", translate("PDP Context for APN :")); -cmcc.optional=false; -cmcc.rmempty = true; -cmcc.datatype = "and(uinteger,min(1),max(10))" -cmcc.default = "1" - -mu = di:taboption(this_tab, Value, "user", translate("用户名 :")); -mu.optional=false; -mu.rmempty = true; - -mp = di:taboption(this_tab, Value, "passw", translate("密码 :")); -mp.optional=false; -mp.rmempty = true; -mp.password = true - -mpi = di:taboption(this_tab, Value, "pincode", translate("PIN码 :")); -mpi.optional=false; -mpi.rmempty = true; - -mau = di:taboption(this_tab, ListValue, "auth", translate("身份验证类型 :")) -mau:value("0", "None") -mau:value("1", "PAP") -mau:value("2", "CHAP") -mau.default = "0" - -mtz = di:taboption(this_tab, ListValue, "tzone", translate("自动设置时区"), translate("Tips:就是模块通网后会自动设置时区")); -mtz:value("0", "窝不要") -mtz:value("1", translate("窝要")) -mtz.default=1 - -ml = di:taboption(this_tab, ListValue, "lock", translate("阻止国际漫游选项并锁定特定运营商 :")); -ml:value("0", translate("否")) -ml:value("1", translate("强硬")) -ml:value("2", translate("软弱")) -ml.default=0 - -mcc = di:taboption(this_tab, Value, "mcc", translate("MCC :")); -mcc.optional=false; -mcc.rmempty = true; -mcc.datatype = "and(uinteger,min(1),max(999))" -mcc:depends("lock", "1") -mcc:depends("lock", "2") - -mnc = di:taboption(this_tab, Value, "mnc", translate("MNC :")); -mnc.optional=false; -mnc.rmempty = true; -mnc.datatype = "and(uinteger,min(1),max(999))" -mnc:depends("lock", "1") -mnc:depends("lock", "2") - -this_taba = "advance" - -mf = di:taboption(this_taba, ListValue, "ppp", translate("不使用常规协议,强制使用PPP拨号协议 :")); -mf:value("0", translate("启用")) -mf:value("1", translate("禁用")) -mf.default=0 - -md = di:taboption(this_taba, Value, "delay", translate("连接延时(秒为单位) :")); -md.optional=false; -md.rmempty = false; -md.default = 5 -md.datatype = "and(uinteger,min(5))" - -nl = di:taboption(this_taba, ListValue, "nodhcp", translate("强制QMI协议不使用模块的DHCP,从其他位置获取 :")); -nl:value("0", translate("禁用")) -nl:value("1", translate("启用")) -nl.default=0 - -mdns1 = di:taboption(this_taba, Value, "dns1", translate("自定义DNS 1 :")); -mdns1.rmempty = true; -mdns1.optional=false; -mdns1.datatype = "ipaddr" - -mdns2 = di:taboption(this_taba, Value, "dns2", translate("自定义DNS 2 :")); -mdns2.rmempty = true; -mdns2.optional=false; -mdns2.datatype = "ipaddr" - -mdns3 = di:taboption(this_taba, Value, "dns3", translate("自定义DNS 3 :")); -mdns3.rmempty = true; -mdns3.optional=false; -mdns3.datatype = "ipaddr" - -mdns4 = di:taboption(this_taba, Value, "dns4", translate("自定义DNS 4 :")); -mdns4.rmempty = true; -mdns4.optional=false; -mdns4.datatype = "ipaddr" - - -mlog = di:taboption(this_taba, ListValue, "log", translate("启用AT连接日志 :")); -mlog:value("0", translate("禁用")) -mlog:value("1", translate("是")) -mlog.default=0 - -if nixio.fs.access("/etc/config/mwan3") then - mlb = di:taboption(this_taba, ListValue, "lb", translate("在多个5G模块中开启流量负载均衡 :")); - mlb:value("0", translate("禁用")) - mlb:value("1", translate("启用")) - mlb.default=0 -end - -mtu = di:taboption(this_taba, Value, "mtu", translate("自定义MTU值 :"), - translate("不建议乱整,只能自定义1420到1500的范围的值")); -mtu.optional=true -mtu.rmempty = true -mtu.default = "1500" -mtu.datatype = "range(1420, 1500)" - -mat = di:taboption(this_taba, ListValue, "at", translate("连接时发送自定义AT命令 :")); -mat:value("0", translate("禁用")) -mat:value("1", translate("启用")) -mat.default=0 - -matc = di:taboption(this_taba, Value, "atc", translate("要执行的AT命令 :")); -matc.optional=false; -matc.rmempty = true; - --- --- Default Connection Monitoring --- - -this_tab = "connect" - -alive = di:taboption(this_tab, ListValue, "alive", translate("连接状态监控 :")); -alive.rmempty = true; -alive:value("0", translate("禁用")) -alive:value("1", translate("启用掉线写入系统日志")) -alive:value("2", translate("启用 5G模块掉线 则 路由自动重启")) -alive:value("3", translate("启用 5G模块掉线 则 自动重拨")) -alive:value("4", translate("启用 5G模块掉线 则 重新上电模块,需要路由GPIO支持,否则将使用其他方式重连")) -alive.default=0 - -reliability = di:taboption(this_tab, Value, "reliability", translate("监测网络稳定性 :"), - translate("范围: 1-100,必须Ping通这些IP地址,这条通信链路才会被视为联网状态")) -reliability.datatype = "range(1, 100)" -reliability.default = "1" -reliability:depends("alive", "1") -reliability:depends("alive", "2") -reliability:depends("alive", "3") -reliability:depends("alive", "4") - -count = di:taboption(this_tab, ListValue, "count", translate("监测次数(Ping) :")) -count.default = "1" -count:value("1") -count:value("2") -count:value("3") -count:value("4") -count:value("5") -count:depends("alive", "1") -count:depends("alive", "2") -count:depends("alive", "3") -count:depends("alive", "4") - -interval = di:taboption(this_tab, ListValue, "pingtime", translate("监测时间间隔 (Ping) :"), - translate("监测Ping之间间隔时间的值")) -interval.default = "10" -interval:value("5", translate("5 秒/次")) -interval:value("10", translate("10 秒/次")) -interval:value("20", translate("20 秒/次 推荐")) -interval:value("30", translate("30 秒次")) -interval:value("60", translate("1 分钟/次 ")) -interval:value("300", translate("5 分钟/次")) -interval:value("600", translate("10 分钟/次")) -interval:value("900", translate("15 分钟/次")) -interval:value("1800", translate("30 分钟/次")) -interval:value("3600", translate("1 小时/次")) -interval:depends("alive", "1") -interval:depends("alive", "2") -interval:depends("alive", "3") -interval:depends("alive", "4") - -timeout = di:taboption(this_tab, ListValue, "pingwait", translate("Ping 超时 :")) -timeout.default = "2" -timeout:value("1", translate("1 秒")) -timeout:value("2", translate("2 秒")) -timeout:value("3", translate("3 秒")) -timeout:value("4", translate("4 秒")) -timeout:value("5", translate("5 秒")) -timeout:value("6", translate("6 秒")) -timeout:value("7", translate("7 秒")) -timeout:value("8", translate("8 秒")) -timeout:value("9", translate("9 秒")) -timeout:value("10", translate("10 秒")) -timeout:depends("alive", "1") -timeout:depends("alive", "2") -timeout:depends("alive", "3") -timeout:depends("alive", "4") - -packetsize = di:taboption(this_tab, Value, "packetsize", translate("Ping报文大小(字节为单位) :"), - translate("范围值 :4-56,ping报文发送的数据字节数,可以要根据运营商进行调整")) - packetsize.datatype = "range(4, 56)" - packetsize.default = "56" - packetsize:depends("alive", "1") - packetsize:depends("alive", "2") - packetsize:depends("alive", "3") - packetsize:depends("alive", "4") - -down = di:taboption(this_tab, ListValue, "down", translate("链路状态 异常判定次数 :"), - translate("如果达到设定值次数,Ping依旧失败后,接口就会被当做异常不在线")) -down.default = "3" -down:value("1") -down:value("2") -down:value("3") -down:value("4") -down:value("5") -down:value("6") -down:value("7") -down:value("8") -down:value("9") -down:value("10") -down:depends("alive", "1") -down:depends("alive", "2") -down:depends("alive", "3") -down:depends("alive", "4") - -up = di:taboption(this_tab, ListValue, "up", translate("链路状态 正常判定次数 :"), - translate("Tips:当达到设定值次数Ping监测后,网络都能Ping设定地址后,则链路状态会被视为正常啦~~")) -up.default = "3" -up:value("1") -up:value("2") -up:value("3") -up:value("4") -up:value("5") -up:value("6") -up:value("7") -up:value("8") -up:value("9") -up:value("10") -up:depends("alive", "1") -up:depends("alive", "2") -up:depends("alive", "3") -up:depends("alive", "4") - -cb2 = di:taboption(this_tab, DynamicList, "trackip", translate("追踪 IP :"), - translate("这个IP将被拿来做链路状态检测用,简单说就是Ping它,能通那么就算链路正常,不通那就以你刚配合的方法处理")) -cb2.datatype = "ipaddr" -cb2:depends("alive", "1") -cb2:depends("alive", "2") -cb2:depends("alive", "3") -cb2:depends("alive", "4") -cb2.optional=false; -cb2.default="114.114.114.114" - -if (multilock == "0") or (multilock == "1" and rootlock == "1") then - this_tab = "bwidth" - bwday = di:taboption(this_tab, ListValue, "bwday", translate("发送监测信息的日期 :"), - translate("每月发送监测报告文件的日期,请选择在每个月的第几日发送,不需要请选择禁用")) - bwday.default = "0" - bwday:value("0", translate("禁用")) - bwday:value("1", translate("1日")) - bwday:value("2", translate("2日")) - bwday:value("3", translate("3日")) - bwday:value("4", translate("4日")) - bwday:value("5", translate("5日")) - bwday:value("6", translate("6日")) - bwday:value("7", translate("7日")) - bwday:value("8", translate("8日")) - bwday:value("9", translate("9日")) - bwday:value("10", translate("10日")) - bwday:value("11", translate("11日")) - bwday:value("12", translate("12日")) - bwday:value("13", translate("13日")) - bwday:value("14", translate("14日")) - bwday:value("15", translate("15日")) - bwday:value("16", translate("16日")) - bwday:value("17", translate("17日")) - bwday:value("18", translate("18日")) - bwday:value("19", translate("19日")) - bwday:value("20", translate("20日")) - bwday:value("21", translate("21日")) - bwday:value("22", translate("22日")) - bwday:value("23", translate("23日")) - bwday:value("24", translate("24日")) - bwday:value("25", translate("25日")) - bwday:value("26", translate("26日")) - bwday:value("27", translate("27日")) - bwday:value("28", translate("28日")) - - phone = di:taboption(this_tab, Value, "phone", translate("手机号码 :"), translate("我们将会通过这个手机号码给你发送监测日志报告,物联卡就爬吧发不了的,短信费用按你套餐资费扣,介意就别踏马用了")) - phone.default = "填入接收监测报告的手机号码,我们将会以短信方式给你发送" - - bwdelay = di:taboption(this_tab, ListValue, "bwdelay", translate("发送前延迟 :"), - translate("凌晨后几个小时发送短信给你")) - bwdelay:value("0", translate("不延迟")) - bwdelay:value("1", translate("1 小时")) - bwdelay:value("2", translate("2 小时")) - bwdelay:value("3", translate("3 小时")) - bwdelay:value("4", translate("4 小时")) - bwdelay:value("5", translate("5 小时")) - bwdelay:value("6", translate("6 小时")) - bwdelay:value("7", translate("7 小时")) - bwdelay:value("8", translate("8 小时")) - bwdelay:value("9", translate("9 小时")) - bwdelay:value("10", translate("10 小时")) - bwdelay:value("11", translate("11 小时")) - bwdelay:value("12", translate("12 小时")) -end - -if fs.stat("/usr/lib/autoapn/apn.data") then - dda = m:section(TypedSection, "disable", translate("Use Automatic APN"), translate("Enable the use of the Automatic APN selection. This disables Custom Profiles.")) - dda.anonymous = true - aenabled = dda:option(Flag, "autoapn", translate("Enabled")) - aenabled.default="0" - aenabled.optional=false; -end - -dd = m:section(TypedSection, "disable", translate("禁用自动APN :"), translate("禁用自动APN后,所有4G/5G通信模块将会使用默认配置文件,不勾选就是默认启用")) -dd.anonymous = true - -enabled = dd:option(Flag, "enabled", translate("禁用")) -enabled.default="0" -enabled.optional=false; - --- --- Custom profile --- - -s = m:section(TypedSection, "custom", translate("定制特定组合配置 :"), translate("可将某个特定配置应用在你所选中的4G/5G模块与SIM卡组合中")) -s.anonymous = true -s.addremove = true -s:tab("custom", translate("简要")) -s:tab("cadvanced", translate("高级")) -s:tab("cconnect", translate("网络异常自动处理")) -if (multilock == "0") or (multilock == "1" and rootlock == "1") then - s:tab("cbwidth", translate("通信模块频宽日志")) -end - -this_ctab = "custom" - -name = s:taboption(this_ctab, Value, "name", translate("配置名称 :")) - -enabled = s:taboption(this_ctab, Flag, "enabled", translate("启用")) -enabled.default="1" -enabled.optional=false; - -select = s:taboption(this_ctab, ListValue, "select", translate("选择对象 :")); -select:value("0", translate("模块 ID")) -select:value("1", translate("模块 IMEI")) -select:value("2", translate("模块名称")) -select:value("3", translate("SIM卡IMSI")) -select:value("4", translate("SIM卡ICCID")) -select.default=0 - -idV = s:taboption(this_ctab, Value, "vid", translate("USB VID :")); -idV.optional=false; -idV:depends("select", "0") -idV.default="xxxx" - -idP = s:taboption(this_ctab, Value, "pid", translate("USB PID :")); -idP.optional=false; -idP:depends("select", "0") -idP.default="xxxx" - -imei = s:taboption(this_ctab, Value, "imei", translate("通信模块IMEI :")); -imei.optional=false; -imei:depends("select", "1") -imei.datatype = "uinteger" -imei.default="1234567" - -model = s:taboption(this_ctab, Value, "model", translate("模块名称包含 :")); -model.optional=false; -model:depends("select", "2") -model.default="xxxx" - -imsi = s:taboption(this_ctab, Value, "imsi", translate("SIM卡IMSI :")); -imsi.optional=false; -imsi:depends("select", "3") -imsi.datatype = "uinteger" -imsi.default="1234567" - -iccid = s:taboption(this_ctab, Value, "iccid", translate("SIM卡ICCID :")); -iccid.optional=false; -iccid:depends("select", "4") -iccid.datatype = "uinteger" -iccid.default="1234567" - -select1 = s:taboption(this_ctab, ListValue, "select1", translate("选择组合对象 :")); -select1:value("0", "模块 ID") -select1:value("1", "模块 IMEI") -select1:value("2", "型号名称") -select1:value("3", "SIM卡IMSI") -select1:value("4", "SIM卡ICCID") -select1:value("10", "None") -select1.default=10 - -idV1 = s:taboption(this_ctab, Value, "vid1", translate("USB VID :")); -idV1.optional=false; -idV1:depends("select1", "0") -idV1.default="xxxx" - -idP1 = s:taboption(this_ctab, Value, "pid1", translate("USB PID :")); -idP1.optional=false; -idP1:depends("select1", "0") -idP1.default="xxxx" - -imei1 = s:taboption(this_ctab, Value, "imei1", translate("模块 IMEI :")); -imei1.optional=false; -imei1:depends("select1", "1") -imei1.datatype = "uinteger" -imei1.default="1234567" - -model1 = s:taboption(this_ctab, Value, "model1", translate("模块 名称包含 :")); -model1.optional=false; -model1:depends("select1", "2") -model1.default="xxxx" - -imsi1 = s:taboption(this_ctab, Value, "imsi1", translate("SIM卡IMSI :")); -imsi1.optional=false; -imsi1:depends("select1", "3") -imsi1.datatype = "uinteger" -imsi1.default="1234567" - -iccid1 = s:taboption(this_ctab, Value, "iccid1", translate("SIM卡ICCID :")); -iccid1.optional=false; -iccid1:depends("select1", "4") -iccid1.datatype = "uinteger" -iccid1.default="1234567" - -cma = s:taboption(this_ctab, Value, "apn", "APN :"); -cma.rmempty = true; - -tt = s:taboption(this_ctab, ListValue, "ttl", translate("自定义TTL值 :")) -tt:value("0", translate("Use Current Value")) -tt:value("1", translate("No TTL Value")) -tt:value("63", "TTL 63") -tt:value("64", "TTL 64") -tt:value("65", "TTL 65") -tt:value("66", "TTL 66") -tt:value("67", "TTL 67") -tt:value("117", "TTL 117") -tt:value("TTL-INC 1", "TTL-INC 1") -tt.default = "0" - -nl = s:taboption(this_ctab, ListValue, "hostless", translate("调整无主机(无主控)模块的TTL值 :")); -nl:value("0", translate("No")) -nl:value("1", translate("是")) -nl.default=0 - -pt = s:taboption(this_ctab, ListValue, "pdptype", translate("IP协议类型 :")) -pt:value("IP", "IPv4") -pt:value("IPv6", "IPv6") -pt:value("IPV4V6", "IPv4+IPv6") -pt:value("0", "Default") -pt.default = "0" - -cmcc = s:taboption(this_ctab, Value, "context", translate("PDP Context for APN :")); -cmcc.optional=false; -cmcc.rmempty = true; -cmcc.datatype = "and(uinteger,min(1),max(10))" -cmcc.default = "1" - -cmu = s:taboption(this_ctab, Value, "user", translate("用户名 :")); -cmu.optional=false; -cmu.rmempty = true; - -cmp = s:taboption(this_ctab, Value, "passw", translate("密码 :")); -cmp.optional=false; -cmp.rmempty = true; -cmp.password = true - -cmpi = s:taboption(this_ctab, Value, "pincode", "PIN码 :"); -cmpi.optional=false; -cmpi.rmempty = true; - -cmau = s:taboption(this_ctab, ListValue, "auth", translate("身份验证类型 :")) -cmau:value("0", "无") -cmau:value("1", "PAP") -cmau:value("2", "CHAP") -cmau.default = "0" - -cmtz = s:taboption(this_ctab, ListValue, "tzone", translate("自动设置时区"), translate("模块通网后自动设置时区")); -cmtz:value("0", translate("禁用")) -cmtz:value("1", translate("启用")) -cmtz.default=1 - -cml = s:taboption(this_ctab, ListValue, "lock", translate("是否锁定国际漫游运营商选项(国内不用管) :")); -cml:value("0", translate("否")) -cml:value("1", translate("强硬的")) -cml:value("2", translate("柔弱的")) -cml.default=0 - -cmcc = s:taboption(this_ctab, Value, "mcc", translate("MCC :")); -cmcc.optional=false; -cmcc.rmempty = true; -cmcc.datatype = "and(uinteger,min(1),max(999))" -cmcc:depends("lock", "1") -cmcc:depends("lock", "2") - -cmnc = s:taboption(this_ctab, Value, "mnc", translate("MNC :")); -cmnc.optional=false; -cmnc.rmempty = true; -cmnc.datatype = "and(uinteger,min(1),max(999))" -cmnc:depends("lock", "1") -cmnc:depends("lock", "2") - -this_ctaba = "cadvanced" - -cmf = s:taboption(this_ctaba, ListValue, "ppp", translate("强制使用3G PP协议拨号 :")); -cmf:value("0", translate("否")) -cmf:value("1", translate("是")) -cmf.default=0 - -cmw = s:taboption(this_ctaba, ListValue, "inter", translate("模块WAN口分配 :")); -cmw:value("0", "自动") -cmw:value("1", "WAN1") -cmw:value("2", "WAN2") -cmw:value("3", "关闭") -cmw.default=0 - -cmd = s:taboption(this_ctaba, Value, "delay", translate("连接延迟(以秒为单位) :")); -cmd.optional=false; -cmd.rmempty = false; -cmd.default = 5 -cmd.datatype = "and(uinteger,min(5))" - -cnl = s:taboption(this_ctaba, ListValue, "nodhcp", translate("强制QMI协议不使用模块的DHCP,从其他位置获取 :")); -cnl:value("0", translate("禁用")) -cnl:value("1", translate("启用")) -cnl.default=0 - -cmdns1 = s:taboption(this_ctaba, Value, "dns1", translate("自定义1 :")); -cmdns1.rmempty = true; -cmdns1.optional=false; -cmdns1.datatype = "ipaddr" - -cmdns2 = s:taboption(this_ctaba, Value, "dns2", translate("自定义2 :")); -cmdns2.rmempty = true; -cmdns2.optional=false; -cmdns2.datatype = "ipaddr" - -cmdns3 = s:taboption(this_ctaba, Value, "dns3", translate("自定义3 :")); -cmdns3.rmempty = true; -cmdns3.optional=false; -cmdns3.datatype = "ipaddr" - -cmdns4 = s:taboption(this_ctaba, Value, "dns4", translate("自定义4 :")); -cmdns4.rmempty = true; -cmdns4.optional=false; -cmdns4.datatype = "ipaddr" - -cmlog = s:taboption(this_ctaba, ListValue, "log", translate("启用连接日志 :")); -cmlog:value("0", translate("禁用")) -cmlog:value("1", translate("启用")) -cmlog.default=0 - -if nixio.fs.access("/etc/config/mwan3") then - cmlb = s:taboption(this_ctaba, ListValue, "lb", translate("在多个5G模块中开启流量负载均衡 :")); - cmlb:value("0", translate("禁用")) - cmlb:value("1", translate("启用")) - cmlb.default=0 -end - -mtu = s:taboption(this_ctaba, Value, "mtu", translate("自定义MTU值 :"), - translate("歪歪歪 米乱整窝,纸能自定义1420到1500的蜗 根据不同运营商进行调整的歪,理不鸡丢就不要瞎搞了蛙,等夏列个网炸嘿掉了鳖嘿来找我蜗~~")); -mtu.optional=true -mtu.rmempty = true -mtu.default = "1500" -mtu.datatype = "range(1420, 1500)" - -cmat = s:taboption(this_ctaba, ListValue, "at", translate("在连接模块时发送自定义AT命令 :")); -cmat:value("0", translate("禁用")) -cmat:value("1", translate("启用")) -cmat.default=0 - -cmatc = s:taboption(this_ctaba, Value, "atc", translate("自定义AT命令 :")); -cmatc.optional=false; -cmatc.rmempty = true; - --- --- Custom Connection Monitoring --- - -this_ctab = "cconnect" - -calive = s:taboption(this_ctab, ListValue, "alive", translate("连接状态监控 :")); -calive.rmempty = true; -calive:value("0", translate("禁用")) -calive:value("1", translate("启用掉线写入系统日志")) -calive:value("2", translate("启用 5G模块掉线 则 路由自动重启")) -calive:value("3", translate("启用 5G模块掉线 则 自动重拨")) -calive:value("4", translate("启用 5G模块掉线 则 重新上电模块,需要路由GPIO支持,否则将使用其他方式重连")) -calive.default=0 - -reliability = s:taboption(this_ctab, Value, "reliability", translate("监测网络稳定性 :"), - translate("Acceptable values: 范围: 1-100,必须Ping通这些IP地址,这条通信链路才会被视为联网状态")) -reliability.datatype = "range(1, 100)" -reliability.default = "1" -reliability:depends("alive", "1") -reliability:depends("alive", "2") -reliability:depends("alive", "3") -reliability:depends("alive", "4") - -count = s:taboption(this_ctab, ListValue, "count", translate("监测次数(Ping):")) -count.default = "1" -count:value("1") -count:value("2") -count:value("3") -count:value("4") -count:value("5") -count:depends("alive", "1") -count:depends("alive", "2") -count:depends("alive", "3") -count:depends("alive", "4") - -interval = s:taboption(this_ctab, ListValue, "pingtime", translate("监测时间间隔 (Ping) :"), - translate("监测Ping之间间隔时间的值")) -interval.default = "10" -interval:value("5", translate("5 秒")) -interval:value("10", translate("10 秒")) -interval:value("20", translate("20 秒")) -interval:value("30", translate("30 秒")) -interval:value("60", translate("1 分钟")) -interval:value("300", translate("5 分钟")) -interval:value("600", translate("10 分钟")) -interval:value("900", translate("15 分钟")) -interval:value("1800", translate("30 分钟")) -interval:value("3600", translate("1 小时")) -interval:depends("alive", "1") -interval:depends("alive", "2") -interval:depends("alive", "3") -interval:depends("alive", "4") - -timeout = s:taboption(this_ctab, ListValue, "pingwait", translate("Ping 超时 :")) -timeout.default = "2" -timeout:value("1", translate("1 秒")) -timeout:value("2", translate("2 秒")) -timeout:value("3", translate("3 秒")) -timeout:value("4", translate("4 秒")) -timeout:value("5", translate("5 秒")) -timeout:value("6", translate("6 秒")) -timeout:value("7", translate("7 秒")) -timeout:value("8", translate("8 秒")) -timeout:value("9", translate("9 秒")) -timeout:value("10", translate("10 秒")) -timeout:depends("alive", "1") -timeout:depends("alive", "2") -timeout:depends("alive", "3") -timeout:depends("alive", "4") - -packetsize = s:taboption(this_ctab, Value, "packetsize", translate("Ping报文大小(字节为单位) :"), - translate("范围值 :4-56,ping报文发送的数据字节数,可以要根据运营商进行调整")) - packetsize.datatype = "range(4, 56)" - packetsize.default = "56" - packetsize:depends("alive", "1") - packetsize:depends("alive", "2") - packetsize:depends("alive", "3") - packetsize:depends("alive", "4") - -down = s:taboption(this_ctab, ListValue, "down", translate("链路状态 异常判定次数 :"), - translate("如果达到设定值次数,Ping依旧失败后,接口就会被当做异常不在线")) -down.default = "3" -down:value("1") -down:value("2") -down:value("3") -down:value("4") -down:value("5") -down:value("6") -down:value("7") -down:value("8") -down:value("9") -down:value("10") -down:depends("alive", "1") -down:depends("alive", "2") -down:depends("alive", "3") -down:depends("alive", "4") - -up = s:taboption(this_ctab, ListValue, "up", translate("链路状态 正常判定次数"), - translate("当达到设定值次数Ping监测后,网络都能Ping设定地址后,则链路状态会被视为正常啦~~")) -up.default = "3" -up:value("1") -up:value("2") -up:value("3") -up:value("4") -up:value("5") -up:value("6") -up:value("7") -up:value("8") -up:value("9") -up:value("10") -up:depends("alive", "1") -up:depends("alive", "2") -up:depends("alive", "3") -up:depends("alive", "4") - -cb2 = s:taboption(this_ctab, DynamicList, "trackip", translate("追踪 IP :"), - translate("这个IP将被拿来做链路状态检测用,简单说就是Ping它,能通那么就算链路正常,不通那就以你刚配合的方法处理")) -cb2.datatype = "ipaddr" -cb2:depends("alive", "1") -cb2:depends("alive", "2") -cb2:depends("alive", "3") -cb2:depends("alive", "4") -cb2.optional=false; -cb2.default="114.114.114.114" - -if (multilock == "0") or (multilock == "1" and rootlock == "1") then - this_ctab = "cbwidth" - bwday = s:taboption(this_ctab, ListValue, "bwday", translate("每个月发送网络稳定日志的日期"), - translate("每月发送监测报告文件的日期,请选择在每个月的第几日发送,不需要请选择禁用")) - bwday.default = "0" - bwday:value("0", translate("禁用")) - bwday:value("1", translate("1日")) - bwday:value("2", translate("2日")) - bwday:value("3", translate("3日")) - bwday:value("4", translate("4日")) - bwday:value("5", translate("5日")) - bwday:value("6", translate("6日")) - bwday:value("7", translate("7日")) - bwday:value("8", translate("8日")) - bwday:value("9", translate("9日")) - bwday:value("10", translate("10日")) - bwday:value("11", translate("11日")) - bwday:value("12", translate("12日")) - bwday:value("13", translate("13日")) - bwday:value("14", translate("14日")) - bwday:value("15", translate("15日")) - bwday:value("16", translate("16日")) - bwday:value("17", translate("17日")) - bwday:value("18", translate("18日")) - bwday:value("19", translate("19日")) - bwday:value("20", translate("20日")) - bwday:value("21", translate("21日")) - bwday:value("22", translate("22日")) - bwday:value("23", translate("23日")) - bwday:value("24", translate("24日")) - bwday:value("25", translate("25日")) - bwday:value("26", translate("26日")) - bwday:value("27", translate("27日")) - bwday:value("28", translate("28日")) - - phone = s:taboption(this_ctab, Value, "phone", translate("手机号码 :"), translate("我们将会通过这个手机号码给你发送监测日志报告,物联卡就爬吧发不了的,短信费用按你套餐资费扣,介意就不要用了")) - phone.default = "12223334444" - - bwdelay = s:taboption(this_ctab, ListValue, "bwdelay", translate("发送前延迟 :"), - translate("凌晨后几个小时发送短信给你")) - bwdelay:value("0", translate("No Delay")) - bwdelay:value("1", translate("1 小时")) - bwdelay:value("2", translate("2 小时")) - bwdelay:value("3", translate("3 小时")) - bwdelay:value("4", translate("4 小时")) - bwdelay:value("5", translate("5 小时")) - bwdelay:value("6", translate("6 小时")) - bwdelay:value("7", translate("7 小时")) - bwdelay:value("8", translate("8 小时")) - bwdelay:value("9", translate("9 小时")) - bwdelay:value("10", translate("10 小时")) - bwdelay:value("11", translate("11 小时")) - bwdelay:value("12", translate("12 小时")) -end - -return m - - - diff --git a/rooter/ext-rooter-basic/files/usr/lib/lua/luci/view/admin_status/index/external.htm b/rooter/ext-rooter-basic/files/usr/lib/lua/luci/view/admin_status/index/external.htm deleted file mode 100644 index 9aa6023..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/lua/luci/view/admin_status/index/external.htm +++ /dev/null @@ -1 +0,0 @@ -<%+rooter/external%> \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/usr/lib/lua/luci/view/admin_system/poweroff.htm b/rooter/ext-rooter-basic/files/usr/lib/lua/luci/view/admin_system/poweroff.htm deleted file mode 100644 index 30d9333..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/lua/luci/view/admin_system/poweroff.htm +++ /dev/null @@ -1,34 +0,0 @@ -<%# - Copyright 2008 Steven Barth - Copyright 2008 Jo-Philipp Wich - Licensed to the public under the Apache License 2.0. --%> - -<%+header%> - - - - -

                          <%:System%>

                          -

                          <%:System Stop%>

                          -

                          <%:Graceful system stop. De-power then re-power to restart.%>

                          -

                          -
                            -<%+footer%> \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/usr/lib/lua/luci/view/modlog/modlog.htm b/rooter/ext-rooter-basic/files/usr/lib/lua/luci/view/modlog/modlog.htm deleted file mode 100644 index 990dc5c..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/lua/luci/view/modlog/modlog.htm +++ /dev/null @@ -1,32 +0,0 @@ -<%+header%> - - - - -
                            -

                            <%:模块连接日志%>

                            -
                            -
                            - <%:Log%> - - - - -
                            - -
                            - -
                            - -
                            - -<%+footer%> diff --git a/rooter/ext-rooter-basic/files/usr/lib/lua/luci/view/rooter/custom.htm b/rooter/ext-rooter-basic/files/usr/lib/lua/luci/view/rooter/custom.htm deleted file mode 100644 index e23d1e8..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/lua/luci/view/rooter/custom.htm +++ /dev/null @@ -1,126 +0,0 @@ -<% -local modemfile = "/etc/config/modem.data" -local modemdata = {} -local count - -function process_line(xline, cnt) - local data = {} - local pline = xline - local start = 1 - for i=1,3 do - s, e = string.find(pline, " ") - data[i] = string.sub(pline, start, s-1) - pline = string.sub(pline, e+1) - end - data[4] = pline - modemdata[cnt] = data -end - -function read_modem() - count = 0 - local file = io.open(modemfile, "r") - if file == nil then - return - end - repeat - local line = file:read("*line") - if line == nil then - break - end - if string.len(line) < 5 then - break - end - count = count + 1 - process_line(line, count) - until 1==0 - file:close() -end - -function process_family(index) - local t = { } - if count == 0 then - return t - end - local mdata = modemdata[index] - if mdata[1] ~= "nil" and mdata[2] ~= "nil" then - t[1] = mdata[1] .. ":" .. mdata[2] - if mdata[3] == "tty" then - t[2] = "default" - end - if mdata[3] == "tty0" then - t[2] = "ttyUSB0" - end - if mdata[3] == "tty1" then - t[2] = "ttyUSB1" - end - if mdata[3] == "tty2" then - t[2] = "ttyUSB2" - end - if mdata[3] == "tty3" then - t[2] = "ttyUSB3" - end - if mdata[3] == "tty4" then - t[2] = "ttyUSB4" - end - if mdata[3] == "tty5" then - t[2] = "ttyUSB5" - end - - if mdata[4] == "tty" then - t[3] = "default" - end - if mdata[4] == "tty0" then - t[3] = "ttyUSB0" - end - if mdata[4] == "tty1" then - t[3] = "ttyUSB1" - end - if mdata[4] == "tty2" then - t[3] = "ttyUSB2" - end - if mdata[4] == "tty3" then - t[3] = "ttyUSB3" - end - if mdata[4] == "tty4" then - t[3] = "ttyUSB4" - end - if mdata[4] == "tty5" then - t[3] = "ttyUSB5" - end - - end - return t -end - -read_modem() - -%> - -
                            - <%:自定义模块端口数据库%> - - - - - - - <% - if count > 0 then - for i=1,count do - t = process_family(i) %> - - - - - - <% - end - else %> - - - - <% - end %> -
                            <%:模块名称%><%:数据端口%><%:通信端口%>
                            <%=t[1]%><%=t[2]%><%=t[3]%>
                            <%:暂无数据%>  
                            -
                            - diff --git a/rooter/ext-rooter-basic/files/usr/lib/lua/luci/view/rooter/debug.htm b/rooter/ext-rooter-basic/files/usr/lib/lua/luci/view/rooter/debug.htm deleted file mode 100644 index e9f0d9c..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/lua/luci/view/rooter/debug.htm +++ /dev/null @@ -1,87 +0,0 @@ -<%+header%> - -<% -local cnt = 0 -local tt = {} - -os.execute("cat /sys/kernel/debug/usb/devices > /tmp/modstat 2>&1") -local file = io.open("/tmp/modstat", "r") -repeat - local line = file:read("*line") - if line == nil then - break - end - if string.len(line) < 3 then - line = "********************************************************************************************************" - end - tt[cnt] = line - cnt = cnt + 1 -until 1 == 0 -cnt = cnt - 1 -file:close() -os.execute("/usr/lib/rooter/luci/luaops.sh delete /tmp/modstat") -%> - - - - -
                            -

                            <%:通信模块调试信息%>

                            -
                            -
                            - <%:自动化AT指令调试日志%> - - - - -
                            - -
                            - -
                            - -
                            - <%:设备信息%> - - - - - - - <% - for i=1,cnt do - s, e = string.find(tt[i], "供应商") - s1, e = string.find(tt[i], "品牌") - s2, e = string.find(tt[i], "模块型号") - if s ~= nil or s1 ~= nil or s2 ~= nil then - %> - - - - - - <% else - %> - - - - - - <% end - end %> -
                            <%=tt[i]%>
                            <%=tt[i]%>
                            -
                            -

                            -
                            - -<%+footer%> - diff --git a/rooter/ext-rooter-basic/files/usr/lib/lua/luci/view/rooter/external.htm b/rooter/ext-rooter-basic/files/usr/lib/lua/luci/view/rooter/external.htm deleted file mode 100644 index 526e7bc..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/lua/luci/view/rooter/external.htm +++ /dev/null @@ -1,26 +0,0 @@ - - -
                            -

                            <%:公网 Internet IP 地址%>

                            - - -
                            <%:IP Address%><%:Loading%> Collecting data...
                            -
                            - diff --git a/rooter/ext-rooter-basic/files/usr/lib/lua/luci/view/rooter/log.htm b/rooter/ext-rooter-basic/files/usr/lib/lua/luci/view/rooter/log.htm deleted file mode 100644 index 842ae8c..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/lua/luci/view/rooter/log.htm +++ /dev/null @@ -1,53 +0,0 @@ -<%+header%> - - - - -
                            -
                            -

                            <%:Connection Log%>

                            -
                            - -
                            - - - - - - - -
                            - -
                            - -
                            - -
                            - -
                            -
                            -<%+footer%> \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/usr/lib/lua/luci/view/rooter/misc.htm b/rooter/ext-rooter-basic/files/usr/lib/lua/luci/view/rooter/misc.htm deleted file mode 100644 index 05a087e..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/lua/luci/view/rooter/misc.htm +++ /dev/null @@ -1,2387 +0,0 @@ -<%+header%> -<% -local sys = require "luci.sys" -local utl = require "luci.util" -local fs = require "nixio.fs" -local uci = require "luci.model.uci".cursor() -local s = uci:get("custom", "bandlock", "enabled") -local a = uci:get("custom", "atcmd", "enabled") - -local multilock = uci:get("custom", "multiuser", "multi") or "0" -local rootlock = uci:get("custom", "multiuser", "root") or "0" -nomulti=1 -if (multilock == "0") or (multilock == "1" and rootlock == "1") then - nosms = 1 - if a == "1" then - nosms = 0 - end -else - nosms = 1 - nomulti = 0 -end -block = 1 -if s == "1" then - block = 0 -end - -function showicon(lck) - if lck == 0 then - return resource .. "/icons/unlock1.png" - else - return resource .. "/icons/lock1.png" - end -end - --%> - - - -
                            -
                            -

                            <%:锁频段/锁PCI/切换协议/AT命令%>

                            -
                            <%:锁频段/锁PCI/切换协议/AT命令%>
                            - - - -
                            - <%:当前模块%> - - - - - - - -
                              - - - -
                              -
                              -
                              - <%:模块 连接/断开控制%> - - - - - - - -
                              - - - - - - - -
                              -
                              - -<% if nosms == 0 then %> -
                              - <%:AT命令终端%> - - - - - - - - - - - - - - - -
                              <%:AT命令 : %>
                              - - - -  
                              -
                              - - - - - - - - - - - - - - - - - -
                              <%:AT命令 : %>
                               
                              - - - - - -
                              - -
                              - -
                              -<% end %> - -<% if nomulti == 1 then %> -<% if block == 0 then %> -
                              - <%:4G/5G频段锁定%> - - - - - -
                               
                              - - - - - - -
                              <%:没有模块/模块未适配本插件%> 
                              - - - - - - - -
                               
                              <%:4G LTE频段%>
                               
                              - - - - -
                              - - - - - - - -
                               
                              <%:5G NSA频段%>
                               
                              - - - - -
                              - - - - - - - -
                               
                              <%:5G SA 频段%>
                               
                              - - - - -
                              - - - - - - - -
                                
                              - - - - - -
                               
                              - - - - - - -
                               
                              - - - - - -
                              <%:2 x 载波聚合%>
                              - - - - -
                              - - - - - -
                              <%:3 x 载波聚合%>
                              - - - - -
                              - - - - - -
                               
                              - - - - - - - - - -
                               
                              <%:扫描可用的频段%>
                               
                              - - - - - -
                              - -
                              - - - - - - - - - - -
                                
                              <%:锁定基站%>
                               
                              - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                              <%:功能状态 : %>
                                 
                              <%:EARFCN 1 : %>
                              <%:PCI 1 : %>
                               
                              <%:EARFCN 2 : %>
                              <%:PCI 2 : %>
                               
                              <%:EARFCN 3 : %>
                              <%:PCI 3 : %>
                               
                              <%:EARFCN 4 : %>
                              <%:PCI 4 : %>
                               
                              - - - - - - -
                               
                              - -
                              -<% end %> - -
                              - <%:模块连接协议切换%> - - - - - - - - - - - - - -
                               
                              <%:当前模块连接协议 :%>
                               
                               
                              <%:更改蜂窝模式 :%>
                              - - -
                              -
                              - -
                              - <%:网络类型选择%> - - - - - - - - - - - - - -
                              <%:当前网络类型 :%>
                               
                              <%:更改网络类型 :%>
                              - - - - -  
                              -
                              -<% end %> - -
                              - <%:GPS Message Pin%> - - - - - - - - -
                               
                              <%:Message Pin :%>
                               
                              -
                              - -
                              -
                              -<%+footer%> diff --git a/rooter/ext-rooter-basic/files/usr/lib/lua/luci/view/rooter/net_status.htm b/rooter/ext-rooter-basic/files/usr/lib/lua/luci/view/rooter/net_status.htm deleted file mode 100644 index bcab6fa..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/lua/luci/view/rooter/net_status.htm +++ /dev/null @@ -1,564 +0,0 @@ -<%+header%> -<% -local fs = require "nixio.fs" -nosms = 1 -if not fs.stat("/etc/nosim") then - nosms = 0 -end -havegps = 0 -if fs.stat("/etc/havegps") then - havegps = 1 -end --%> - - - - -
                              -
                              -

                              <%:信号状态/模块信息%>

                              -
                              请注意该插件所有功能并无适配所有5G模块,不用妄想冷门模块插上就能用(有能力者自行适配) -
                              - - - -
                              - <%:综合信息%> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                              <%:模块 :%>
                                - - - -
                                <%:ID : %>
                                    
                                  <%:运营商 : %>
                                      
                                    <%:端口 :%>
                                      - - - -
                                      <%:温度 : %>
                                          
                                        <%:协议 : %>
                                            
                                          -
                                          - -<% if nosms == 0 then %> -
                                          - <%:通信模块/SIM卡信息%> - - - - - - - - - - - - - - - - - - - - - - -
                                          - -    
                                          <%:IMEI:%>
                                              
                                            <%:IMSI:%>
                                              <%:ICCID:%>
                                                - - - - - - - - - - - - -
                                                <%:SIM卡号码 : %>
                                                - -   
                                                <%:SIM卡名称 : %>
                                                -
                                                -<% end %> - -
                                                - <%:信号状态%> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                                                <%:蜂窝网络类型 :%>
                                                   
                                                  <%:CSQ : %>
                                                     
                                                    <%:信号强度 : %>
                                                       
                                                      <%:信号接收强度 RSSI : %>
                                                         
                                                        <%:参考信号接收质量 RSRQ :%>
                                                         
                                                        <%:参考信号接收功率 RSRP :%>
                                                         
                                                        <%:信噪比 SINR : %>
                                                           
                                                          <%:连接状态监控 : %>
                                                             
                                                            -
                                                            - -
                                                            - <%:基站信息%> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                                                            <%:MCC / MNC :%>
                                                             
                                                            <%:eNB ID :%>
                                                             
                                                            <%:TAC :%>
                                                             
                                                            <%:Cell ID : %>
                                                             
                                                            <%:频段 Band : %>
                                                               
                                                              <%:频点 Channel : %>
                                                                 
                                                                <%:物理小区标识 PCI : %>
                                                                   
                                                                  <%:最大Qos级别 Maximum Qos : %>
                                                                   
                                                                  -
                                                                  - -<% if havegps == 1 then %> -
                                                                  - <%:GPS 定位%> - - - - - - - - - - - -
                                                                  <%:纬度 :%>
                                                                     
                                                                    <%:经度 :%>
                                                                       
                                                                      -
                                                                      -<% end %> -
                                                                      - <%:刷新频率%> - - - - - - - - - - - - - -
                                                                      <%:当前刷新率 :%>
                                                                       
                                                                      <%:修改刷新时间 :%>
                                                                      - -  
                                                                      -
                                                                      - -
                                                                      -
                                                                      -<%+footer%> - diff --git a/rooter/ext-rooter-basic/files/usr/lib/lua/luci/view/rooter/profile.htm b/rooter/ext-rooter-basic/files/usr/lib/lua/luci/view/rooter/profile.htm deleted file mode 100644 index 64efa21..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/lua/luci/view/rooter/profile.htm +++ /dev/null @@ -1,75 +0,0 @@ -<% - -%> - - - -
                                                                      - <%:Import/Export the Profile Data%> - - - - - - - - - - - - - - - - -
                                                                       
                                                                      <%:Export Profile Data to Computer%>
                                                                       
                                                                      <%:Import Profile Data from Computer%>
                                                                        
                                                                      <%:Page will automatically refresh after file is loaded%>
                                                                      - -
                                                                      diff --git a/rooter/ext-rooter-basic/files/usr/lib/modlog/modlogger.sh b/rooter/ext-rooter-basic/files/usr/lib/modlog/modlogger.sh deleted file mode 100644 index 4c3a531..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/modlog/modlogger.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -TEXT=$1 -DATE=$(date +%c) - -modlog="/tmp/modlog.log" -tmplog="/tmp/tmodlog" - -wc -l $modlog > /tmp/linecnt -read lcnt fle < /tmp/linecnt -rm -f /tmp/linecnt -if [ $lcnt -ge 200 ]; then - start=$((lcnt-1)) - tail +$start modlog > $tmplog - mv $tmplog $modlog -fi - -echo "$DATE : $TEXT" >> $modlog diff --git a/rooter/ext-rooter-basic/files/usr/lib/profile/loadcfg.sh b/rooter/ext-rooter-basic/files/usr/lib/profile/loadcfg.sh deleted file mode 100644 index 09648f2..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/profile/loadcfg.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -. /lib/functions.sh - -log() { - logger -t "Load" "$@" -} - -profile=$(cat /tmp/profilename) -valid=$(echo "$profile" | grep "**Profile**") -if [ ! -z "$valid" ]; then - echo "$profile" > /tmp/profile - sed -i '1d' /tmp/profile - cp /tmp/profile /etc/config/profile -fi diff --git a/rooter/ext-rooter-basic/files/usr/lib/profile/restart.sh b/rooter/ext-rooter-basic/files/usr/lib/profile/restart.sh deleted file mode 100644 index 3f632d1..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/profile/restart.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh -. /lib/functions.sh - -ROOTER=/usr/lib/rooter - -log() { - logger -t "Restart" "$@" -} - -sleep 3 - -CURRMODEM=1 -CPORT=$(uci -q get modem.modem$CURRMODEM.commport) - -$ROOTER/luci/restart.sh $CURRMODEM 11 \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/usr/lib/profile/savecfg.sh b/rooter/ext-rooter-basic/files/usr/lib/profile/savecfg.sh deleted file mode 100644 index ab8c026..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/profile/savecfg.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh -. /lib/functions.sh - -log() { - logger -t "Save" "$@" -} - -PKI_DIR="/www" -cd ${PKI_DIR} -mkdir -p package -cd .. -chmod -R 0777 ${PKI_DIR}/package - -echo "***Profile***" > ${PKI_DIR}/package/profilecfg.profile -state=$(cat /etc/config/profile) -echo "$state" >> ${PKI_DIR}/package/profilecfg.profile \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/autoapn.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/autoapn.sh deleted file mode 100644 index c461f46..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/autoapn.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -log() { - logger -t "SimLock " "$@" -} diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/cdmafind.lua b/rooter/ext-rooter-basic/files/usr/lib/rooter/cdmafind.lua deleted file mode 100644 index b1f9922..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/cdmafind.lua +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/lua - -drv = {} -idV = arg[1] -idP = arg[2] - -retval = 0 - -function trim(s) - return (s:gsub("^%s*(.-)%s*$", "%1")) -end - --- MAIN - -local i=0 -local file = io.open("/tmp/cdma", "r") -repeat - local line = file:read("*line") - if line == nil then - break - end - if string.len(line) > 5 then - s, e = line:find("Vendor=") - if s ~= nil then - cs, ce = line:find(" ", e) - m_idV = trim(line:sub(e+1, cs-1)) - s, e = line:find("ProdID=") - cs, ce = line:find(" ", e) - m_idP = trim(line:sub(e+1, cs-1)) - if m_idV == idV and m_idP == idP then - repeat - line = file:read("*line") - if line == nil then - break - end - if string.len(line) > 5 then - s, e = line:find("Product=") - if s ~= nil then - s, e = line:find(" CDMA") - if s ~= nil then - retval = 1 - break - end - end - end - until 1==0 - break - end - end - end -until 1==0 -file:close() - - -os.exit(retval) \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/chan2band.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/chan2band.sh deleted file mode 100644 index 99b1ce3..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/chan2band.sh +++ /dev/null @@ -1,273 +0,0 @@ -#!/bin/sh -CHAN=$1 -CHAN=$(echo "$CHAN" | grep -o "[0-9]*") - -decode_lte() { - if [ $CHAN -lt 600 ]; then - BAND="B1" - elif [ $CHAN -lt 1200 ]; then - BAND="B2" - elif [ $CHAN -lt 1950 ]; then - BAND="B3" - elif [ $CHAN -lt 2400 ]; then - BAND="B4" - elif [ $CHAN -lt 2650 ]; then - BAND="B5" - elif [ $CHAN -lt 2750 ]; then - BAND="B6" - elif [ $CHAN -lt 3450 ]; then - BAND="B7" - elif [ $CHAN -lt 3800 ]; then - BAND="B8" - elif [ $CHAN -lt 4150 ]; then - BAND="B9" - elif [ $CHAN -lt 4750 ]; then - BAND="B10" - elif [ $CHAN -lt 4950 ]; then - BAND="B11" - elif [ $CHAN -lt 5010 ]; then - BAND="-" - elif [ $CHAN -lt 5180 ]; then - BAND="B12" - elif [ $CHAN -lt 5280 ]; then - BAND="B13" - elif [ $CHAN -lt 5380 ]; then - BAND="B14" - elif [ $CHAN -lt 5730 ]; then - BAND="-" - elif [ $CHAN -lt 5850 ]; then - BAND="B17" - elif [ $CHAN -lt 6000 ]; then - BAND="B18" - elif [ $CHAN -lt 6150 ]; then - BAND="B19" - elif [ $CHAN -lt 6450 ]; then - BAND="B20" - elif [ $CHAN -lt 6600 ]; then - BAND="B21" - elif [ $CHAN -lt 7400 ]; then - BAND="B22" - elif [ $CHAN -lt 7500 ]; then - BAND="-" - elif [ $CHAN -lt 7700 ]; then - BAND="B23" - elif [ $CHAN -lt 8040 ]; then - BAND="B24" - elif [ $CHAN -lt 8690 ]; then - BAND="B25" - elif [ $CHAN -lt 9040 ]; then - BAND="B26" - elif [ $CHAN -lt 9210 ]; then - BAND="B27" - elif [ $CHAN -lt 9660 ]; then - BAND="B28" - elif [ $CHAN -lt 9770 ]; then - BAND="B29" - elif [ $CHAN -lt 9870 ]; then - BAND="B30" - elif [ $CHAN -lt 9920 ]; then - BAND="B31" - elif [ $CHAN -lt 10400 ]; then - BAND="B32" - elif [ $CHAN -lt 36000 ]; then - BAND="-" - elif [ $CHAN -lt 36200 ]; then - BAND="B33" - elif [ $CHAN -lt 36350 ]; then - BAND="B34" - elif [ $CHAN -lt 36950 ]; then - BAND="B35" - elif [ $CHAN -lt 37550 ]; then - BAND="B36" - elif [ $CHAN -lt 37750 ]; then - BAND="B37" - elif [ $CHAN -lt 38250 ]; then - BAND="B38" - elif [ $CHAN -lt 38650 ]; then - BAND="B39" - elif [ $CHAN -lt 39650 ]; then - BAND="B40" - elif [ $CHAN -lt 41590 ]; then - BAND="B41" - elif [ $CHAN -lt 43590 ]; then - BAND="B42" - elif [ $CHAN -lt 45590 ]; then - BAND="B43" - elif [ $CHAN -lt 46590 ]; then - BAND="B44" - elif [ $CHAN -lt 46790 ]; then - BAND="B45" - elif [ $CHAN -lt 54540 ]; then - BAND="B46" - elif [ $CHAN -lt 55240 ]; then - BAND="B47" - elif [ $CHAN -lt 56740 ]; then - BAND="B48" - elif [ $CHAN -lt 58240 ]; then - BAND="B49" - elif [ $CHAN -lt 59090 ]; then - BAND="B50" - elif [ $CHAN -lt 59140 ]; then - BAND="B51" - elif [ $CHAN -lt 60140 ]; then - BAND="B52" - elif [ $CHAN -lt 60255 ]; then - BAND="B53" - elif [ $CHAN -lt 65536 ]; then - BAND="-" - elif [ $CHAN -lt 66436 ]; then - BAND="B65" - elif [ $CHAN -lt 67336 ]; then - BAND="B66" - elif [ $CHAN -lt 67536 ]; then - BAND="B67" - elif [ $CHAN -lt 67836 ]; then - BAND="B68" - elif [ $CHAN -lt 68336 ]; then - BAND="B69" - elif [ $CHAN -lt 68586 ]; then - BAND="B70" - elif [ $CHAN -lt 68936 ]; then - BAND="B71" - elif [ $CHAN -lt 68986 ]; then - BAND="B72" - elif [ $CHAN -lt 69036 ]; then - BAND="B73" - elif [ $CHAN -lt 69466 ]; then - BAND="B74" - elif [ $CHAN -lt 70316 ]; then - BAND="B75" - elif [ $CHAN -lt 70366 ]; then - BAND="B76" - elif [ $CHAN -lt 70546 ]; then - BAND="B85" - elif [ $CHAN -lt 70596 ]; then - BAND="B87" - elif [ $CHAN -lt 70646 ]; then - BAND="B88" - else - BAND="-" - fi -} - -decode_nr5g() { - if [ $CHAN -le 123400 ]; then - BAND="-" - elif [ $CHAN -le 130400 ]; then - BAND="n71" - elif [ $CHAN -le 143400 ]; then - BAND="-" - elif [ $CHAN -le 145600 ]; then - BAND="n29" - elif [ $CHAN -le 145800 ]; then - BAND="-" - elif [ $CHAN -le 149200 ]; then - BAND="n12" - elif [ $CHAN -le 151600 ]; then - BAND="-" - elif [ $CHAN -le 153600 ]; then - BAND="n14|n28" - elif [ $CHAN -le 158200 ]; then - BAND="n28" - elif [ $CHAN -le 160600 ]; then - BAND="n20|n28" - elif [ $CHAN -le 164200 ]; then - BAND="n20" - elif [ $CHAN -le 171800 ]; then - BAND="-" - elif [ $CHAN -le 172000 ]; then - BAND="n26" - elif [ $CHAN -le 173800 ]; then - BAND="n18|n26" - elif [ $CHAN -le 175000 ]; then - BAND="n5|n18|n26" - elif [ $CHAN -le 178800 ]; then - BAND="n5|n26" - elif [ $CHAN -le 185000 ]; then - BAND="-" - elif [ $CHAN -le 192000 ]; then - BAND="n8" - elif [ $CHAN -le 285400 ]; then - BAND="-" - elif [ $CHAN -le 286400 ]; then - BAND="n51|n76|n91|n93" - elif [ $CHAN -le 295000 ]; then - BAND="n50|n75|n92|n94" - elif [ $CHAN -le 303400 ]; then - BAND="n50|n74|n75|n92|n94" - elif [ $CHAN -le 303600 ]; then - BAND="n74" - elif [ $CHAN -le 361000 ]; then - BAND="-" - elif [ $CHAN -le 376000 ]; then - BAND="n3" - elif [ $CHAN -le 384000 ]; then - BAND="n39" - elif [ $CHAN -le 386000 ]; then - BAND="-" - elif [ $CHAN -le 398000 ]; then - BAND="n2|n25" - elif [ $CHAN -le 399000 ]; then - BAND="n25" - elif [ $CHAN -le 402000 ]; then - BAND="n70" - elif [ $CHAN -le 404000 ]; then - BAND="n34|n70" - elif [ $CHAN -le 405000 ]; then - BAND="n34" - elif [ $CHAN -le 422000 ]; then - BAND="-" - elif [ $CHAN -le 434000 ]; then - BAND="n1|n65|n66" - elif [ $CHAN -le 440000 ]; then - BAND="n65|n66" - elif [ $CHAN -le 460000 ]; then - BAND="-" - elif [ $CHAN -le 470000 ]; then - BAND="n40" - elif [ $CHAN -le 472000 ]; then - BAND="n30|n40" - elif [ $CHAN -le 480000 ]; then - BAND="n40" - elif [ $CHAN -le 496700 ]; then - BAND="-" - elif [ $CHAN -le 499000 ]; then - BAND="n53" - elif [ $CHAN -le 499200 ]; then - BAND="-" - elif [ $CHAN -le 514000 ]; then - BAND="n41|n90" - elif [ $CHAN -le 524000 ]; then - BAND="n38|n41|n90" - elif [ $CHAN -le 538000 ]; then - BAND="n7|n90" - elif [ $CHAN -le 620000 ]; then - BAND="-" - elif [ $CHAN -le 636667 ]; then - BAND="n77|n78" - elif [ $CHAN -le 646666 ]; then - BAND="n48|n77|n78" - elif [ $CHAN -le 653333 ]; then - BAND="n77|n78" - elif [ $CHAN -le 680000 ]; then - BAND="n77" - elif [ $CHAN -le 693334 ]; then - BAND="-" - elif [ $CHAN -le 733333 ]; then - BAND="n79" - else - BAND="-" - fi -} - -if [ -z "$CHAN" ]; then - BAND="-" -elif [ "$CHAN" -lt 123400 ]; then - decode_lte -elif [ "$CHAN" -lt 733333 ]; then - decode_nr5g -else - BAND="-" -fi -echo $BAND -exit diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/common/fibocomdata.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/common/fibocomdata.sh deleted file mode 100644 index 8e4ef40..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/common/fibocomdata.sh +++ /dev/null @@ -1,476 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -log() { - logger -t "Fibocom Data" "$@" -} - -CURRMODEM=$1 -COMMPORT=$2 - -decode_signal() { - if [ "$CRAT" -eq 4 ]; then - RSCPs=$(($RSRP - 141)) - if [ -n "$RSCP" ]; then - RSCP=$RSCP" dBm
                                                                      "$RSCPs - else - RSCP=$RSCPs - fi - if [ -n "$ECIO" ]; then - ECIO=$ECIO" dB
                                                                      "$((($RSRQ / 2) - 20)) - else - ECIO=$((($RSRQ / 2) - 20)) - fi - elif [ "$CRAT" -eq 9 ]; then - RSCPs=$(($RSRP - 157)) - if [ -n "$RSCP" ]; then - RSCP=$RSCP" dBm
                                                                      "$RSCPs - else - RSCP=$RSCPs - fi - if [ -n "$ECIO" ]; then - ECIO=$ECIO" dB
                                                                      "$((($RSRQ / 2) - 43)) - else - ECIO=$((($RSRQ / 2) - 43)) - fi - fi -} -decode_bw() { - case $BW in - "0") - BW="1.4" ;; - "1") - BW="3" ;; - "2") - BW="5" ;; - "3") - BW="10" ;; - "4") - BW="15" ;; - "5") - BW="20" ;; - *) - BW="-";; - esac -} - -OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "fibocominfo.gcom" "$CURRMODEM") - -OX=$(echo $OX | tr 'a-z' 'A-Z') - -SERVING=$(echo $OX | grep -o "+GTCCINFO:.\+COPN:") -if [ -z "$SERVING" ]; then - SERVING=$(echo $OX | grep -o "+GTCCINFO:.\+GTRAT") -fi - -REGXa="[12],[249],[0-9]\{3\},[0-9]\{2,3\},[0-9A-F]\{0,5\},[0-9A-F]\{0,10\},[0-9A-F]\{1,8\},[0-9A-F]\{1,8\},[15][0-9]\{1,4\},[0-9]\{1,3\},[-0-9]\{1,5\},[0-9]\{1,3\},[0-9]\{1,3\},[0-9]\{1,3\}" - -REGXb="+GTCAINFO: 1,[0-9]\{1,2\},[0-9]\{3\},[0-9]\{2,3\},[0-9]\{1,5\},[0-9]\{3,9\},[0-9]\{1,3\},[0-9]\{1,3\},[0-9]\{1,3\},[-0-9]\{1,4\},[0-9]\{1,6\},[0-9]\{1,6\},[0-9]\{1,3\},[0-9]\{1,3\}" - -REGXc="+GTCAINFO: [2-9],[0-9]\{1,2\},[0-9]\{1,5\},[0-9]\{1,3\},[0-9]\{1,3\},[-0-9]\{1,4\},[0-9]\{1,5\},[0-9]\{1,5\},[0-9]\{1,3\},[0-9]\{1,3\}" - -REGXd="+XMCI: 2,[0-9]\{3\},[0-9]\{2,3\},[^,]\+,[^,]\+,[^,]\+,\"0X[0-9A-F]\{8\}\",[^,]\+,[^,]\+,[0-9]\{1,2\},[0-9]\{1,2\},[0-9]\{1,2\}" - -REGXe="+XMCI: 4,[0-9]\{3\},[0-9]\{2,3\},[^,]\+,[^,]\+,\"0X[0-9A-F]\{4\}\",\"0X[0-9A-F]\{8\}\",[^,]\+,[^,]\+,[0-9]\{1,2\},[0-9]\{1,2\},[-0-9]\{1,5\}" - -REGXf="SCC[0-9]: 1,0,[0-9]\{1,3\},1[0-9]\{2\},[0-9]\{1,6\},[0-9]\{1,3\}" - -REGXg="2,4,,,,,[0-9A-F]\{1,5\},[0-9A-F]\{1,3\},,[0-9]\{1,3\},[0-9]\{1,3\},[0-9]\{1,3\}" -REGXh="2,9,,,,,[0-9A-F]\{5\},[0-9A-F]\{1,3\},,[0-9]\{1,3\},[0-9]\{1,3\},[0-9]\{1,3\}" -REGXy="1,4,[0-9]\{3\},[0-9]\{2,3\},[0-9A-F]\{0,5\},[0-9A-F]\{0,10\},[0-9]\{1,8\}, ,[0-9]\{1,2\},[0-5], ," - -CHANNEL="-" -ECIO="-" -RSCP="-" -ECIO1=" " -RSCP1=" " -MODE="-" -NETMODE="-" -LBAND="-" -PCI="-" -CTEMP="-" -SINR="" -COPS_MCC="" - -CSQ=$(echo $OX | grep -o "+CSQ: [0-9]\{1,2\}" | grep -o "[0-9]\{1,2\}") -if [ "$CSQ" = "99" ]; then - CSQ="" -fi -if [ -n "$CSQ" ]; then - CSQ_PER=$(($CSQ * 100/31))"%" - CSQ_RSSI=$((2 * CSQ - 113))" dBm" -else - CSQ="-" - CSQ_PER="-" - CSQ_RSSI="-" -fi - -if [ -n "$SERVING" ]; then - MODE=$(echo $SERVING | grep -o "+GTCCINFO: .\+ SERVICE CELL:") - LENM=${#MODE} - if [ $LENM -gt 25 ]; then - MODE=${MODE:11:$LENM-25} - else - MODE="-" - fi - GTCCDATA=$(echo $SERVING | grep -o "$REGXa") - GTCCDATAy=$(echo $SERVING | grep -o "$REGXy") - LTENEIGH=$(echo $SERVING | grep -o "$REGXg") - NRNEIGH=$(echo $SERVING | grep -o "$REGXh") - echo "" > /tmp/scan$CURRMODEM - for NVAL in $(echo "$LTENEIGH"); do - CHAN=$(echo $NVAL | cut -d, -f7) - CHAN=$(printf "%d" 0x$CHAN) - BAND=$(/usr/lib/rooter/chan2band.sh $CHAN) - PCIx=$(echo $NVAL | cut -d, -f8) - PCIx=$(printf "%d" 0x$PCIx) - RSSI=$(echo $NVAL | cut -d, -f11) - RSSI=$(($RSSI - 141)) - echo -e "Band : $BAND\tPCI : $PCIx\tSignal : $RSSI (dBm)" >> /tmp/scan$CURRMODEM - done - for NVAL in $(echo "$NRNEIGH"); do - CHAN=$(echo $NVAL | cut -d, -f7) - CHAN=$(printf "%d" 0x$CHAN) - BAND=$(/usr/lib/rooter/chan2band.sh $CHAN) - PCIx=$(echo $NVAL | cut -d, -f8) - PCIx=$(printf "%d" 0x$PCIx) - RSSI=$(echo $NVAL | cut -d, -f11) - RSSI=$(($RSSI - 157)) - echo -e "Band : $BAND\tPCI : $PCIx\tSignal : $RSSI (dBm)" >> /tmp/scan$CURRMODEM - done - CADATA1="" - CADATA2="" - XUDATA="" - XLDATA="" -else - GTCCDATA="" - CADATA1=$(echo $OX | grep -o "$REGXb") - CADATA2=$(echo $OX | grep -o "$REGXc") - if [ -n "$CADATA2" ]; then - if [ "$(echo $CADATA2 | cut -d, -f7)" = "65535" ]; then - CADATA2="" - fi - fi - XUDATA=$(echo $OX | grep -o "$REGXd") - XLDATA=$(echo $OX | grep -o "$REGXe") -fi -CADATA3=$(echo $OX | grep -o "$REGXf") -if [ -n "$GTCCDATA" ]; then - COPS_MCC=$(echo $GTCCDATA | cut -d, -f3) - COPS_MNC=$(echo $GTCCDATA | cut -d, -f4) - COPX="" - COPN=$(echo $OX" " | grep -o "+COPN: .\+ OK " | tr " " "," | tr -d '"' ) - if [ -n "$COPN" ]; then - COPP=$(echo $COPN" " | sed "s/.*\($COPS_MCC$COPS_MNC,.*\)\,/\1/") - if [ -n "$COPP" ]; then - COPX=$(echo $COPP | cut -d, -f2) - fi - fi - - LBAND="" - CHANNEL="" - RSCP="" - ECIO="" - PCI="" - XUDATA="" - for CCVAL in $(echo "$GTCCDATA"); do - CELLTYPE=$(echo $CCVAL | cut -d, -f1) - CRAT=$(echo $CCVAL | cut -d, -f2) - BAND=$(echo $CCVAL | cut -d, -f9) - CHAN=$(echo $CCVAL | cut -d, -f7) - CHAN=$(printf "%d" 0x$CHAN) - PCID=$(echo $CCVAL | cut -d, -f8) - PCID=$(printf "%d" 0x$PCID) - BW=$(echo $CCVAL | cut -d, -f10) - if [ "$CRAT" -eq 4 ]; then - SSINR=$(echo $CCVAL | cut -d, -f11 | grep -o "[-0-9]\{1,4\}") - if [ -n "$SSINR" ] && [ "$SSINR" != "255" ]; then - SSINR=$(($SSINR / 2))" dB" - else - SSINR="-" - fi - if [ -n "$SINR" ]; then - SINR=$SINR"
                                                                      "$SSINR - else - SINR=$SSINR - fi - if [ $BW -gt 14 ]; then - BW=$(($(echo $BW) / 5)) - else - BW="1.4" - fi - BAND=${BAND:1} - if [ "$CELLTYPE" -eq 1 ]; then - BAND="B"$(($BAND + 0))" (Bandwidth: "$BW" MHz)" - else - BAND="B"$(($BAND + 0))" (CA, Bandwidth: "$BW" MHz)" - fi - fi - if [ "$CRAT" -eq 9 ]; then - SSINR=$(echo $CCVAL | cut -d, -f11 | grep -o "[0-9]\{1,3\}") - if [ -n "$SSINR" ] && [ "$SSINR" != "255" ]; then - SSINR=$((($SSINR - 47) / 2))" dB" - else - SSINR="-" - fi - if [ -n "$SINR" ]; then - SINR=$SINR"
                                                                      "$SSINR - else - SINR=$SSINR - fi - if [ "$CELLTYPE" -eq 1 ]; then - BAND="n"${BAND:2}" (Bandwidth: "$BW" MHz)" - else - BAND="n"${BAND:2}" (CA, Bandwidth: "$BW" MHz)" - fi - fi - if [ -n "$LBAND" ]; then - LBAND=$LBAND"
                                                                      "$BAND - else - LBAND=$BAND - fi - if [ -n "$CHANNEL" ]; then - CHANNEL=$CHANNEL","$CHAN - else - CHANNEL=$CHAN - fi - if [ -n "$PCI" ]; then - PCI=$PCI","$PCID - else - PCI=$PCID - fi - if [ "$CELLTYPE" -eq 1 ]; then - RSRP=$(echo $CCVAL | cut -d, -f13) - RSRQ=$(echo $CCVAL | cut -d, -f14) - if [ "$RSRP" -ne 255 ] && [ "$RSRQ" -ne 255 ]; then - decode_signal - RSSI=$(rsrp2rssi $RSCPs $BW) - CSQ_PER=$((100 - (($RSSI + 51) * 100/-62)))"%" - CSQ=$((($RSSI + 113) / 2)) - CSQ_RSSI=$RSSI" dBm" - fi - fi - done -fi - -if [ -n "$GTCCDATAy" ]; then - CHANNEL=$(echo $GTCCDATAy | cut -d, -f7) - BW=$(echo $GTCCDATAy | cut -d, -f10) - decode_bw - LBAND="B"$(echo $GTCCDATAy | cut -d, -f9)" (Bandwidth: "$BW" MHz)" - XUDATA="" -fi - -if [ -n "$XLDATA" ]; then - XLDATA=$(echo "${XLDATA//[\" ]/}") - XLEC=$(echo $OX | grep -o "+XLEC: [01],[0-9]\+,[0-5],.*BAND_LTE_[0-9]\{1,2\},[^ ]\+") - MODE="LTE" - PCI=$(echo $XLDATA | cut -d, -f6) - PCI=$(printf "%d" $PCI) - CHANNEL=$(echo $XLDATA | cut -d, -f7) - CHANNEL=$(printf "%d" $CHANNEL) - LBAND=$($ROOTER/chan2band.sh "$CHANNEL") - if [ -n "$XLEC" ]; then - BW=$(echo $XLEC | cut -d, -f3) - RAWLIST=$(echo $XLEC | grep -o "BAND_LTE_[0-9]\{1,2\}.\+" | grep -o "[,0-9]*" | tr ',' ' ') - BANDLIST="" - for BAND in $(echo "$RAWLIST"); do - if [ -n "$BAND" -a "$BAND" != "0" ]; then - if [ -n "$BANDLIST" ]; then - BANDLIST="$BANDLIST,$BAND" - else - BANDLIST="$BAND" - fi - fi - done - BAND="B"$(echo $BANDLIST | cut -d, -f1) - if [ "$BAND" = "$LBAND" ]; then - decode_bw - LBAND=$LBAND" (Bandwidth $BW MHz)" - NUMBR=$(echo $XLEC | cut -d, -f2) - for JJ in $(seq 2 $NUMBR); do - BAND=$(echo $BANDLIST | cut -d, -f$JJ) - if [ -n "$BAND" -a "$BAND" != "0" ]; then - KK=$(($JJ + 2)) - BW=$(echo $XLEC | cut -d, -f$KK) - decode_bw - if [ $BW != "-" ]; then - LBAND=$LBAND"
                                                                      B$BAND (CA, Bandwidth $BW MHz)" - fi - fi - done - fi - else - XLEC=$(echo $OX | grep -o "+XLEC: 0,[1-9],[0-5]") - if [ -n "$XLEC" ]; then - BW=$(echo $XLEC | cut -d, -f3) - decode_bw - LBAND=$LBAND" (Bandwidth $BW MHz)" - fi - fi - RSRP=$(echo $XLDATA | cut -d, -f10) - if [ $RSRP == 0 ]; then - RSRP=1 - fi - RSCP=$(($RSRP - 141)) - ECIO=$(echo $XLDATA | cut -d, -f11) - ECIO=$((($ECIO / 2) - 20)) - SINR=$(echo $XLDATA | cut -d, -f12 | grep -o "[-0-9]\{1,4\}") - if [ -n "$SINR" ] && [ "$SINR" != "255" ]; then - SINR=$(($SINR / 2))" dB" - fi - RSSI=$(rsrp2rssi $RSCP $BW) - CSQ_PER=$((100 - (($RSSI + 51) * 100/-62)))"%" - CSQ=$((($RSSI + 113) / 2)) - CSQ_RSSI=$RSSI" dBm" -fi -if [ -n "$XUDATA" ]; then - MODE="UMTS" - CHANNEL=$(echo $XUDATA | cut -d, -f7) - CHANNEL=${CHANNEL:1:10} - CHANNEL=$(printf "%d" $CHANNEL) - RSCP=$(echo $XUDATA | cut -d, -f11) - RSCP=$(($RSCP - 121)) - ECIO=$(echo $XUDATA | cut -d, -f12) - ECIO=$((($ECIO / 2) - 24)) -fi -if [ -n "$CADATA1" ]; then - RSCP="" - ECIO="" - BW=$(echo $CADATA1 | cut -d, -f13) - decode_bw - BWD=$BW - BW=$(echo $CADATA1 | cut -d, -f14) - decode_bw - BWU=$BW - LBAND="B"$(echo $CADATA1 | cut -d, -f2)" (Bandwidth $BWD MHz Down | $BWU MHz Up)" - CHANNEL=$(echo $CADATA1 | cut -d, -f11) - MODE="LTE" - CRAT="4" - RSRP=$(echo $CADATA1 | cut -d, -f8) - RSRQ=$(echo $CADATA1 | cut -d, -f9) - if [ "$RSRP" -ne 255 ] && [ "$RSRQ" -ne 255 ]; then - decode_signal - RSSI=$(rsrp2rssi $RSCPs $BWD) - CSQ_PER=$((100 - (($RSSI + 51) * 100/-62)))"%" - CSQ=$((($RSSI + 113) / 2)) - CSQ_RSSI=$RSSI" dBm" - else - RSRP="-" - RSRQ="-" - fi - PCI=$(echo $CADATA1 | cut -d, -f7) -fi -if [ -n "$CADATA2" ]; then - CADATA2=$(echo "${CADATA2//[ ]/}") - for CAVAL in $(echo "$CADATA2"); do - BW=$(echo $CAVAL | cut -d, -f9) - decode_bw - BWD=$BW - BW=$(echo $CAVAL | cut -d, -f10) - decode_bw - BWU=$BW - LBAND=$LBAND"
                                                                      B"$(echo $CAVAL | cut -d, -f2) - if [ $BWU = "-" ]; then - LBAND=$LBAND" (CA, Bandwidth: "$BWD" MHz)" - else - LBAND=$LBAND" (CA, Bandwidth $BWD MHz Down | $BWU MHz Up)" - fi - CHAN=$(echo $CAVAL | cut -d, -f7) - CHANNEL=$(echo "$CHANNEL", "$CHAN") - PCIX=$(echo $CAVAL | cut -d, -f3) - PCI=$(echo "$PCI", "$PCIX") - done -fi -if [ -n "$CADATA3" ]; then - CADATA3=$(echo "${CADATA3//[ ]/}") - for CAVAL in $(echo "$CADATA3"); do - BAND=$(echo $CAVAL | cut -d, -f3) - BAND=${BAND:1} - PCIX=$(echo $CAVAL | cut -d, -f4) - PCI=$(echo "$PCI", "$PCIX") - CHAN=$(echo $CAVAL | cut -d, -f5) - CHANNEL=$(echo "$CHANNEL", "$CHAN") - BW=$(echo $CAVAL | cut -d, -f6) - if [ $BW -gt 14 ]; then - BW=$(($(echo $BW) / 5)) - else - BW="1.4" - fi - LBAND=$LBAND"
                                                                      B"$(($BAND + 0))" (CA, Bandwidth: "$BW" MHz)" - done -fi - -MTEMP=$(echo $OX | grep -o "+MTSM: [0-9.]\{1,5\}") -if [ -n "$MTEMP" ]; then - CTEMP=$(echo $MTEMP | grep -o "[0-9.]\{1,5\}")$(printf "\xc2\xb0")"C" -fi - -MODTYPE="9" -MRAT=$(echo $OX | grep -o "+GTRAT: [0-9]\{1,2\}" | grep -o "[0-9]\{1,2\}") -if [ -n "$MRAT" ]; then -# If user inserted different SIM card, the Rat order will recover to default value (AT Commands manual) - case $MRAT in - "2" ) - NETMODE="5" ;; - "3" ) - NETMODE="7" ;; - "14" ) - NETMODE="9" ;; - "17"|"20" ) - NETMODE="8" ;; - * ) - NETMODE="1" ;; - esac -fi -XACT=$(echo $OX | grep -o "+XACT: [0-9]" | grep -o "[0-9]") -if [ -n "$XACT" ]; then - PREF=$(echo $OX | grep -o "+XACT: [0-9],[0-9]" | grep -o ",[0-9]") - case $XACT in - "1" ) - NETMODE="5" ;; - "2" ) - NETMODE="7" ;; - "4" ) - if [ "$PREF" = ",1" ]; then - NETMODE="4" - else - NETMODE="6" - fi ;; - * ) - NETMODE="6" ;; - esac -fi -CMODE=$(uci -q get modem.modem$CURRMODEM.cmode) -if [ "$CMODE" = 0 ]; then - NETMODE="10" -fi -if [ -z "$SINR" ]; then - SINR="-" -fi - -{ - echo 'CSQ="'"$CSQ"'"' - echo 'CSQ_PER="'"$CSQ_PER"'"' - echo 'CSQ_RSSI="'"$CSQ_RSSI"'"' - echo 'ECIO="'"$ECIO"'"' - echo 'RSCP="'"$RSCP"'"' - echo 'ECIO1="'"$ECIO1"'"' - echo 'RSCP1="'"$RSCP1"'"' - echo 'MODE="'"$MODE"'"' - echo 'MODTYPE="'"$MODTYPE"'"' - echo 'NETMODE="'"$NETMODE"'"' - echo 'CHANNEL="'"$CHANNEL"'"' - echo 'LBAND="'"$LBAND"'"' - echo 'PCI="'"$PCI"'"' - echo 'TEMP="'"$CTEMP"'"' - echo 'SINR="'"$SINR"'"' -} > /tmp/signal$CURRMODEM.file -if [ -n "$COPS_MCC" ]; then - echo 'COPS_MCC="'"$COPS_MCC"'"' >> /tmp/signal$CURRMODEM.file - echo 'COPS_MNC="'"$COPS_MNC"'"' >> /tmp/signal$CURRMODEM.file -fi -if [ -n "$COPX" ]; then - echo 'COPS="'"$COPX"'"' >> /tmp/signal$CURRMODEM.file -fi diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/common/gettype.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/common/gettype.sh deleted file mode 100644 index 6ac00c2..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/common/gettype.sh +++ /dev/null @@ -1,254 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -log() { - modlog "Get ICCID $CURRMODEM" "$@" -} - -echo "0" > /tmp/block - -decode_crsm() { - i=0 - while [ $i -lt $length ]; do - c1=${sstring:$i:1} - let 'j=i+1' - c2=${sstring:$j:1} - xstring=$xstring$c2$c1 - let 'i=i+2' - done -} - -CURRMODEM=$1 -CPORT=$(uci get modem.modem$CURRMODEM.commport) - -OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "gettype.gcom" "$CURRMODEM") -OX=$($ROOTER/common/processat.sh "$OX") - -MANUF=$(echo "$OX" | awk -F[:] '/Manufacturer:/ { print $2}') - -if [ -z "$MANUF" ]; then - ATCMDD="AT+CGMI" - MANUF=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - MANUF=$(echo $MANUF) - MANUF=$(echo "${MANUF//[\"]/}") - MANUF=${MANUF::-3} - MPREFIX=${MANUF::8} - if [ "$MPREFIX" = "AT+CGMI " ]; then - MANUF=$(echo $MANUF | cut -c 9-) - fi - MPREFIX=${MANUF::7} - if [ "$MPREFIX" = "+CGMI: " ]; then - MANUF=$(echo $MANUF | cut -c 8-) - fi -fi -if [ -z "$MANUF" ]; then - MANUF=$(uci get modem.modem$CURRMODEM.manuf) -fi - -MODEL=$(echo "$OX" | awk -F[,\ ] '/^\+MODEL:/ {print $2}') - -if [ -z "$MODEL" ]; then - ATCMDD="AT+CGMM" - MODEL=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - MODEL=$(echo $MODEL) - MODEL=$(echo "${MODEL//[\"]/}") - MODEL=${MODEL::-3} - MPREFIX=${MODEL::8} - if [ "$MPREFIX" = "AT+CGMM " ]; then - MODEL=$(echo $MODEL | cut -c 9-) - fi - MPREFIX=${MODEL::7} - if [ "$MPREFIX" = "+CGMM: " ]; then - MODEL=$(echo $MODEL | cut -c 8-) - fi - MODEL=$(echo $MODEL | cut -d, -f1) -fi -if [ -z "$MODEL" ]; then - MODEL=$(uci get modem.modem$CURRMODEM.model) -fi - -uci set modem.modem$CURRMODEM.manuf="$MANUF" -uci set modem.modem$CURRMODEM.model="$MODEL" -uci commit modem - -$ROOTER/signal/status.sh $CURRMODEM "$MANUF $MODEL" "Connecting" - -IMEI=$(echo "$OX" | awk -F[,\ ] '/^\IMEI:/ {print $2}') - -if [ -z "$IMEI" ]; then - ATCMDD="AT+CGSN" - IMEI=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - IMEI=$(echo $IMEI | grep -o "[0-9]\{15\}") -fi - -if [ -z "$IMEI" ]; then - ATCMDD="ATI5" - IMEI=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - IMEI=$(echo $IMEI | grep -o "[0-9]\{15\}") -fi - -if [ -n "$IMEI" ]; then - IMEI=$(echo "$IMEI" | sed -e 's/"//g') - IMEI=${IMEI:0:15} -else - IMEI="Unknown" -fi -uci set modem.modem$CURRMODEM.imei=$IMEI - -IDP=$(uci get modem.modem$CURRMODEM.idP) -IDV=$(uci get modem.modem$CURRMODEM.idV) - -echo $IDV" : "$IDP > /tmp/msimdatax$CURRMODEM -echo "$IMEI" >> /tmp/msimdatax$CURRMODEM - -lua $ROOTER/signal/celltype.lua "$MODEL" $CURRMODEM -source /tmp/celltype$CURRMODEM -rm -f /tmp/celltype$CURRMODEM - -uci set modem.modem$CURRMODEM.celltype=$CELL -uci commit modem - -$ROOTER/luci/celltype.sh $CURRMODEM - -M2=$(echo "$OX" | grep -o "+CNUM:[^,]*,[^,]*,[0-9]\{3\}")"," -M2=${M2:6} -CNUMx=$(echo "$M2" | cut -d, -f1 | cut -d\" -f2) -CNUMx=$(echo $CNUMx) -CNUM=$(echo "$M2" | cut -d, -f2 | cut -d\" -f2) -CNUMtype=$(echo "$M2" | cut -d, -f3) -if [ "${CNUM:0:1}" != "+" -a "$CNUMtype" == "145" ]; then - CNUM="+"$CNUM -fi -if [ -z "$CNUM" ]; then - CNUM="*" -fi -if [ -z "$CNUMx" ]; then - CNUMx="*" -fi - -NLEN=$(echo "$OX" | awk -F[,\ ] '/^\+CPBR:/ {print $4}') -if [ "x$NLEN" != "x" ]; then - NLEN=$(echo "$NLEN" | sed -e 's/"//g') -else - NLEN="14" -fi -echo 'NLEN="'"$NLEN"'"' > /tmp/namelen$CURRMODEM - -ATCMDD="ATE1" -OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") -ATCMDD="AT+CTZU=1" -OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") -ATCMDD="AT\$QCPBMPREF?" -OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") -PBzero=$(echo "$OX" | grep "0") -if [ -n "$PBzero" ]; then - ATCMDD="AT\$QCPBMPREF=1" - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") -fi -ATCMDD="AT+CGDCONT?" -OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") -ATCMDD="AT\$QCPDPIMSCFGE?" -OX=$OX$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") -OX=$(echo $OX | tr 'a-z' 'A-Z') -OX=$(echo "${OX//[ ]/}") -imsAPN=$(echo $OX | grep -o "+CGDCONT:2,[^,]\+,\"IMS\"") -ims_on=$(echo $OX | grep -o "\$QCPDPIMSCFGE:2,1,") -if [ -n "$imsAPN" -a -z "$ims_on" ]; then - ATCMDD="AT\$QCPDPIMSCFGE=2,1" - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") -fi -if [ "$IDV" == "2c7c" ]; then - ATCMDD="AT+QLWCFG=\"startup\"" - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - LWon=$(echo "$OX" | grep "1") - if [ -n "$LWon" ]; then - ATCMDD="AT+QLWCFG=\"startup\",0" - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - fi - ATCMDD="AT+QCFG=\"ims\"" - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - IMSon=$(echo "$OX" | grep "1") - if [ -z "$IMSon" ]; then - ATCMDD="AT+QCFG=\"ims\",1" - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - fi -fi -ATCMDD="AT+CIMI" -OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") -OX=$($ROOTER/common/processat.sh "$OX") -ERROR="ERROR" -if `echo ${OX} | grep "${ERROR}" 1>/dev/null 2>&1` -then - ATCMDD="AT+CRSM=176,28423,0,0,9" - sstring=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD" | grep -o "[0-9F]\{18\}") - if [ -n "$sstring" ]; then - length=${#sstring} - decode_crsm - IMSI=${xstring:3} - else - IMSI="Unknown" - fi -else - OX=${OX//[!0-9]/} - IMSIL=${#OX} - IMSI=${OX:0:$IMSIL} -fi -echo "$IMSI" >> /tmp/msimdatax$CURRMODEM -uci set modem.modem$CURRMODEM.imsi=$IMSI - -idV=$(uci -q get modem.modem$CURRMODEM.idV) -idP=$(uci -q get modem.modem$CURRMODEM.idP) -if [ $idV = 0e8d ]; then - ATCMDD="AT+CCID" - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - OX=$($ROOTER/common/processat.sh "$OX") - ERROR="ERROR" - if `echo ${OX} | grep "${ERROR}" 1>/dev/null 2>&1` - then - ICCID="Unknown" - else - ICCID=$(echo "$OX" | awk -F[,\ ] '/^\+CCID:/ {print $2}') - if [ "x$ICCID" != "x" ]; then - sstring=$(echo "$ICCID" | sed -e 's/"//g') - ICCID=$sstring - else - ICCID="Unknown" - fi - fi -else - ATCMDD="AT+CRSM=176,12258,0,0,10" - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - OX=$($ROOTER/common/processat.sh "$OX") - ERROR="ERROR" - if `echo ${OX} | grep "${ERROR}" 1>/dev/null 2>&1` - then - ICCID="Unknown" - else - ICCID=$(echo "$OX" | awk -F[,\ ] '/^\+CRSM:/ {print $4}') - if [ "x$ICCID" != "x" ]; then - sstring=$(echo "$ICCID" | sed -e 's/"//g') - length=${#sstring} - xstring="" - decode_crsm - ICCID=$xstring - else - ICCID="Unknown" - fi - fi -fi -uci set modem.modem$CURRMODEM.iccid=$ICCID -uci commit modem -if [ -e /etc/config/modeinfo ]; then - uci set modeinfo.global.iccid$CURRMODEM=$ICCID - uci commit modeinfo -fi -echo "$ICCID" >> /tmp/msimdatax$CURRMODEM -echo "0" >> /tmp/msimdatax$CURRMODEM -echo "$CNUM" > /tmp/msimnumx$CURRMODEM -echo "$CNUMx" >> /tmp/msimnumx$CURRMODEM - -mv -f /tmp/msimdatax$CURRMODEM /tmp/msimdata$CURRMODEM -mv -f /tmp/msimnumx$CURRMODEM /tmp/msimnum$CURRMODEM - -rm -f /tmp/block diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/common/huaweidata.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/common/huaweidata.sh deleted file mode 100644 index 8134784..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/common/huaweidata.sh +++ /dev/null @@ -1,299 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -log() { - logger -t "Huawei Data" "$@" -} - -CURRMODEM=$1 -COMMPORT=$2 - -fix_data() { - O=$($ROOTER/common/processat.sh "$OY") -} - -process_csq() { - CSQ=$(echo "$O" | awk -F[,\ ] '/^\+CSQ:/ {print $2}') - [ "x$CSQ" = "x" ] && CSQ=-1 - if [ $CSQ -ge 0 -a $CSQ -le 31 ]; then - CSQ_PER=$(($CSQ * 100/31)) - CSQ_RSSI=$((2 * CSQ - 113)) - CSQX=$CSQ_RSSI - [ $CSQ -eq 0 ] && CSQ_RSSI="<= "$CSQ_RSSI - [ $CSQ -eq 31 ] && CSQ_RSSI=">= "$CSQ_RSSI - CSQ_PER=$CSQ_PER"%" - CSQ_RSSI=$CSQ_RSSI" dBm" - else - CSQ="-" - CSQ_PER="-" - CSQ_RSSI="-" - fi -} - -process_huawei() { - CSNR=$(echo "$O" | awk -F[,\ ] '/^\^CSNR:/ {print $2}') - if [ "x$CSNR" != "x" ]; then - RSCP=$CSNR - CSNR=$(echo "$O" | awk -F[,\ ] '/^\^CSNR:/ {print $3}') - if [ "x$CSNR" != "x" ]; then - ECIO=$CSNR - else - ECIO=`expr $RSCP - $CSQX` - fi - else - EC=$(echo "$O" | awk -F[,\ ] '/^\+CSQ:/ {print $4}') - if [ "x$EC" != "x" ]; then - ECIO=$EC - EX=$(printf %.0f $ECIO) - RSCP=`expr $CSQX + $EX` - fi - fi - - HCSQ=$(echo "$O" | grep -o "\^HCSQ:[ ]*\"LTE\",[^,]*,[^,]*,[0-9]\{1,3\}") - if [ -n "$HCSQ" ]; then - SINR=$(echo $HCSQ | cut -d, -f4) - if [ $SINR -lt 255 ]; then - SINR=$((($SINR / 5) - 20)) - else - SINR="-" - fi - fi - - LTERSRP=$(echo "$O" | awk -F[,\ ] '/^\^LTERSRP:/ {print $2}') - if [ "x$LTERSRP" != "x" ]; then - RSCP=$LTERSRP - LTERSRP=$(echo "$O" | awk -F[,\ ] '/^\^LTERSRP:/ {print $3}') - if [ "x$LTERSRP" != "x" ]; then - ECIO=$LTERSRP - else - ECIO=`expr $RSCP - $CSQX` - fi - fi - LBANDS=$(echo $O | grep -o "\^HFREQINFO:[0-9,]\+") - LBAND="" - CHANNEL="" - printf '%s\n' "$LBANDS" | while read LBANDL; do - CHANN=$(echo $LBANDL | cut -d, -f4 | grep -o "[0-9]\{2,6\}") - if [ -z "$CHANN" ]; then - LBAND="" - CHANNEL="" - else - BWU=$(($(echo $LBANDL | cut -d, -f9) / 1000)) - BWD=$(($(echo $LBANDL | cut -d, -f6) / 1000)) - LBANDL=$(echo $LBANDL | cut -d, -f3) - if [ -z "$LBANDL" ]; then - LBAND="" - else - if [ -n "$LBAND" ]; then - LBAND=$LBAND" aggregated with:
                                                                      " - fi - LBAND=$LBAND"B"$LBANDL" (Bandwidth $BWD MHz Down | $BWU MHz Up)" - fi - if [ -n "$CHANN" ]; then - if [ -n "$CHANNEL" ]; then - CHANNEL=$CHANNEL", "$CHANN - else - CHANNEL=$CHANN - fi - fi - - fi - { - echo "$LBAND" - echo "$CHANNEL" - } > /tmp/lbandvar$CURRMODEM - done - if [ -e /tmp/lbandvar$CURRMODEM ]; then - { - read LBAND - read CHANNEL - } < /tmp/lbandvar$CURRMODEM - rm /tmp/lbandvar$CURRMODEM - fi - if [ -z "$LBAND" ]; then - LBAND="-" - fi - if [ -z "$CHANNEL" ]; then - CHANNEL="-" - fi - - NETMODE="0" - SYSCFG=$(echo "$O" | awk -F[,\"] '/^\^SYSCFGEX:/ {print $2}') - if [ "x$SYSCFG" != "x" ]; then - MODTYPE="3" - case $SYSCFG in - "00" ) - NETMODE="1" - ;; - "01" ) - NETMODE="3" - ;; - "02" ) - NETMODE="5" - ;; - "03" ) - NETMODE="7" - ;; - * ) - ACQ=${SYSCFG:0:2} - case $ACQ in - "01" ) - NETMODE="2" - ;; - "02" ) - NETMODE="4" - ;; - "03" ) - NETMODE="6" - ;; - esac - ;; - esac - else - SYSCFG=$(echo "$O" | awk -F[,\ ] '/^\^SYSCFG:/ {print $2}') - if [ "x$SYSCFG" != "x" ]; then - MODTYPE="4" - case $SYSCFG in - "7" ) - NETMODE="1" - ;; - "13" ) - NETMODE="3" - ;; - "14" ) - NETMODE="5" - ;; - * ) - SYSCFG=$(echo "$O" | awk -F[,\ ] '/^\^SYSCFG:/ {print $3}') - case $SYSCFG in - "0" ) - NETMODE="1" - ;; - "1" ) - NETMODE="2" - ;; - "2" ) - NETMODE="4" - ;; - esac - ;; - esac - fi - fi - - NETMODEx=$(uci get modem.modem$CURRMODEM.netmode) - if [ "$NETMODE" != "$NETMODEx" ]; then - uci set modem.modem$CURRMODEM.netmode="$NETMODE" - uci commit modem - fi - - MODE="-" - TECH=$(echo "$O" | awk -F[,] '/^\^SYSINFOEX:/ {print $9}' | sed 's/"//g') - if [ "x$TECH" != "x" ]; then - MODE="$TECH" - fi - - if [ "x$MODE" = "x-" ]; then - TECH=$(echo "$O" | awk -F[,\ ] '/^\^SYSINFO:/ {print $8}') - if [ "x$TECH" != "x" ]; then - case $TECH in - 17*) MODE="HSPA+ (64QAM)";; - 18*) MODE="HSPA+ (MIMO)";; - 1*) MODE="GSM";; - 2*) MODE="GPRS";; - 3*) MODE="EDGE";; - 4*) MODE="WCDMA";; - 5*) MODE="HSDPA";; - 6*) MODE="HSUPA";; - 7*) MODE="HSPA";; - 9*) MODE="HSPA+";; - *) MODE=$TECH;; - esac - fi - fi - - TEMP=$(echo "$O" | awk -F[,] '/^\^CHIPTEMP:/ {print $2}') - if [ "x$TEMP" != "x" ]; then - TEMP=$((TEMP / 10))$(printf "\xc2\xb0")"C" - else - TEMP="unknown" - fi - - CMODE=$(uci get modem.modem$CURRMODEM.cmode) - if [ $CMODE = 0 ]; then - NETMODE="10" - fi -} - -CSQ="-" -CSQ_PER="-" -CSQ_RSSI="-" -ECIO="-" -RSCP="-" -ECIO1=" " -RSCP1=" " -MODE="-" -CHANNEL="-" -LBAND="-" -MODETYPE="-" -NETMODE="-" -TEMP="-" -PCI="-" -SINR="-" - -OY=$($ROOTER/gcom/gcom-locked "$COMMPORT" "huaweiinfo.gcom" "$CURRMODEM") - -fix_data -process_csq -process_huawei - -{ - echo 'CSQ="'"$CSQ"'"' - echo 'CSQ_PER="'"$CSQ_PER"'"' - echo 'CSQ_RSSI="'"$CSQ_RSSI"'"' - echo 'ECIO="'"$ECIO"'"' - echo 'RSCP="'"$RSCP"'"' - echo 'ECIO1="'"$ECIO1"'"' - echo 'RSCP1="'"$RSCP1"'"' - echo 'MODE="'"$MODE"'"' - echo 'MODTYPE="'"$MODTYPE"'"' - echo 'NETMODE="'"$NETMODE"'"' - echo 'CHANNEL="'"$CHANNEL"'"' - echo 'LBAND="'"$LBAND"'"' - echo 'PCI="'"$PCI"'"' - echo 'TEMP="'"$TEMP"'"' - echo 'SINR="'"$SINR"'"' -} > /tmp/signal$CURRMODEM.file - -CONNECT=$(uci get modem.modem$CURRMODEM.connected) -if [ $CONNECT -eq 0 ]; then - exit 0 -fi - -if [ $CSQ = "-" ]; then - log "$OY" -fi - -ENB="0" -if [ -e /etc/config/failover ]; then - ENB=$(uci get failover.enabled.enabled) -fi -if [ $ENB = "1" ]; then - exit 0 -fi - -WWANX=$(uci get modem.modem$CURRMODEM.interface) -OPER=$(cat /sys/class/net/$WWANX/operstate 2>/dev/null) -rm -f "/tmp/connstat"$CURRMODEM - -if [ ! $OPER ]; then - exit 0 -fi -if echo $OPER | grep -q "unknown"; then - exit 0 -fi - -if echo $OPER | grep -q "down"; then - echo "1" > "/tmp/connstat"$CURRMODEM -fi diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/common/lockchk.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/common/lockchk.sh deleted file mode 100644 index 5d096ad..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/common/lockchk.sh +++ /dev/null @@ -1,104 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -log() { - logger -t "Lock Provider" "$@" -} - -setautocops() { - if [ "$MODTYPE" = "2" -o "$MODTYPE" = "6" -o "$MODTYPE" = "8" -o "$MODTYPE" = "11" ]; then - NETMODE=$(uci get modem.modem$CURRMODEM.netmode) - case $NETMODE in - "3") - ATCMDD="AT+COPS=0,,,0" ;; - "5") - ATCMDD="AT+COPS=0,,,2" ;; - "7") - ATCMDD="AT+COPS=0,,,7" ;; - "8") - ATCMDD="AT+COPS=0,,,13" ;; - "9") - ATCMDD="AT+COPS=0,,,12" ;; - *) - ATCMDD="AT+COPS=0" ;; - esac - else - ATCMDD="AT+COPS=0" - fi - OX=$($ROOTER/gcom/gcom-locked "$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - CLOG=$(uci get modem.modeminfo$CURRMODEM.log) - if [ $CLOG = "1" ]; then - log "$OX" - fi - exit 0 -} - -CURRMODEM=$1 -if [ -e /usr/lib/netroam/lock.sh ]; then - if [ -e /tmp/rlock ]; then - /usr/lib/netroam/lock.sh $CURRMODEM - exit 0 - fi -fi -CPORT=/dev/ttyUSB$(uci get modem.modem$CURRMODEM.commport) -MODTYPE=$(uci get modem.modem$CURRMODEM.modemtype) -LOCK=$(uci get modem.modeminfo$CURRMODEM.lock) -if [ "$LOCK" = "2" ]; then - LOCK="4" -fi -ATCMDD="AT+COPS=3,2;+COPS?" -OX=$($ROOTER/gcom/gcom-locked "$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") -COPSMODE=$(echo $OX | grep -o "+COPS:[ ]\?[014]" | grep -o "[014]") -COPSPLMN=$(echo $OX | grep -o "[0-9]\{5,6\}") - -if [ -z "$LOCK" -o "$LOCK" = "0" ]; then - if [ "$COPSMODE" = "0" ]; then - exit 0 - fi - setautocops -fi -MCC=$(uci -q get modem.modeminfo$CURRMODEM.mcc) -LMCC=${#MCC} -if [ $LMCC -ne 3 ]; then - setautocops -fi -MNC=$(uci -q get modem.modeminfo$CURRMODEM.mnc) -if [ -z $MNC ]; then - setautocops -fi -LMNC=${#MNC} -if [ $LMNC -eq 1 ]; then - MNC=0$MNC -fi -if [ "$COPSMODE$COPSPLMN" = "$LOCK$MCC$MNC" ]; then - exit 0 -fi -if [ "$MODTYPE" = "2" -o "$MODTYPE" = "6" -o "$MODTYPE" = "8" -o "$MODTYPE" = "11" ]; then - NETMODE=$(uci get modem.modem$CURRMODEM.netmode) - case $NETMODE in - "3") - ATCMDD="AT+COPS=$LOCK,2,\"$MCC$MNC\",0" ;; - "5") - ATCMDD="AT+COPS=$LOCK,2,\"$MCC$MNC\",2" ;; - "7") - ATCMDD="AT+COPS=$LOCK,2,\"$MCC$MNC\",7" ;; - "8") - ATCMDD="AT+COPS=$LOCK,2,\"$MCC$MNC\",13" ;; - "9") - ATCMDD="AT+COPS=$LOCK,2,\"$MCC$MNC\",12" ;; - *) - ATCMDD="AT+COPS=$LOCK,2,\"$MCC$MNC\"" ;; - esac -else - ATCMDD="AT+COPS=$LOCK,2,\"$MCC$MNC\"" -fi - -OX=$($ROOTER/gcom/gcom-locked "$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") -CLOG=$(uci get modem.modeminfo$CURRMODEM.log) -if [ $CLOG = "1" ]; then - log "Error While Locking to Provider" - log "$OX" -else - log "Locked to Provider $MCC $MNC" -fi diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/common/mdm9215data.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/common/mdm9215data.sh deleted file mode 100644 index c552b0a..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/common/mdm9215data.sh +++ /dev/null @@ -1,127 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -log() { - logger -t "MDM9215 Data" "$@" -} - -CURRMODEM=$1 -COMMPORT=$2 - -OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "mdm9215info.gcom" "$CURRMODEM" | tr 'a-z' 'A-Z') -O=$($ROOTER/common/processat.sh "$OX") -O=$(echo $O) - -RSRP="" -RSRQ="" -CHANNEL="-" -ECIO="-" -RSCP="-" -ECIO1=" " -RSCP1=" " -MODE="-" -MODTYPE="-" -NETMODE="-" -LBAND="-" -TEMP="-" -PCI="-" -SINR="-" - -Oup=$(echo $O | tr 'a-z' 'A-Z') - -CSQ=$(echo $O | grep -o "CSQ: [0-9]\+" | grep -o "[0-9]\+") -[ "x$CSQ" = "x" ] && CSQ=-1 - -if [ $CSQ -ge 0 -a $CSQ -le 31 ]; then - CSQ_PER=$(($CSQ * 100/31)) - CSQ_RSSI=$((2 * CSQ - 113)) - CSQX=$CSQ_RSSI - [ $CSQ -eq 0 ] && CSQ_RSSI="<= "$CSQ_RSSI - [ $CSQ -eq 31 ] && CSQ_RSSI=">= "$CSQ_RSSI - CSQ_PER=$CSQ_PER"%" - CSQ_RSSI=$CSQ_RSSI" dBm" -else - CSQ="-" - CSQ_PER="-" - CSQ_RSSI="-" -fi - -MODE="-" -WS46=$(echo $O" " | grep -o "+COPS: .\+ OK " | tr " " ",") -TECH=$(echo $WS46 | cut -d, -f5) - -if [ ! -z "$TECH" ]; then - MODE=$TECH - SGCELL=$(echo $O" " | grep -o "\$QCSQ .\+ OK " | tr " " "," | tr ",:" ",") - - WS46=$(echo $O" " | grep -o "AT\$QCSYSMODE? .\+ OK ") - WS46=$(echo "$WS46" | sed -e "s/AT\$QCSYSMODE? //g") - WS46=$(echo "$WS46" | sed -e "s/ OK//g") - - case $MODE in - *) - RSCP=$(echo $SGCELL | cut -d, -f8) - RSCP="-"$(echo $RSCP | grep -o "[0-9]\{1,3\}") - ECIO=$(echo $SGCELL| cut -d, -f5) - ECIO="-"$(echo $ECIO | grep -o "[0-9]\{1,3\}") - RSSI=$(echo $SGCELL | cut -d, -f4) - CSQ_RSSI="-"$(echo $RSSI | grep -o "[0-9]\{1,3\}")" dBm" - ;; - "7") - RSSI=$(echo $SGCELL | cut -d, -f4) - CSQ_RSSI=$(echo $RSSI | grep -o "[0-9]\{1,3\}")" dBm" - RSCP=$(echo $SGCELL | cut -d, -f8) - RSCP="-"$(echo $RSCP | grep -o "[0-9]\{1,3\}") - ECIO=$(echo $SGCELL| cut -d, -f4) - ECIO="-"$(echo $ECIO | grep -o "[0-9]\{1,3\}") - ;; - esac - - MODE=$WS46 -fi - -NETMODE="1" -MODTYPE="8" - -{ - echo 'CSQ="'"$CSQ"'"' - echo 'CSQ_PER="'"$CSQ_PER"'"' - echo 'CSQ_RSSI="'"$CSQ_RSSI"'"' - echo 'ECIO="'"$ECIO"'"' - echo 'RSCP="'"$RSCP"'"' - echo 'ECIO1="'"$ECIO1"'"' - echo 'RSCP1="'"$RSCP1"'"' - echo 'MODE="'"$MODE"'"' - echo 'MODTYPE="'"$MODTYPE"'"' - echo 'NETMODE="'"$NETMODE"'"' - echo 'CHANNEL="'"$CHANNEL"'"' - echo 'LBAND="'"$LBAND"'"' - echo 'PCI="'"$PCI"'"' - echo 'TEMP="'"$TEMP"'"' - echo 'SINR="'"$SINR"'"' -} > /tmp/signal$CURRMODEM.file - -CONNECT=$(uci get modem.modem$CURRMODEM.connected) -if [ $CONNECT -eq 0 ]; then - exit 0 -fi - -if [ "$CSQ" = "-" ]; then - log "$OX" -fi - -WWANX=$(uci get modem.modem$CURRMODEM.interface) -OPER=$(cat /sys/class/net/$WWANX/operstate 2>/dev/null) -rm -f "/tmp/connstat"$CURRMODEM - -if [ ! $OPER ]; then - exit 0 -fi -if echo $OPER | grep -q "unknown"; then - exit 0 -fi - -if echo $OPER | grep -q "down"; then - echo "1" > "/tmp/connstat"$CURRMODEM -fi diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/common/meigdata.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/common/meigdata.sh deleted file mode 100644 index 360a708..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/common/meigdata.sh +++ /dev/null @@ -1,281 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -log() { - logger -t "Meig Data" "$@" -} - -CURRMODEM=$1 -COMMPORT=$2 - -OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "meiginfo.gcom" "$CURRMODEM" | tr 'a-z' 'A-Z') - -O=$($ROOTER/common/processat.sh "$OX") -O=$(echo $O) -OX=$(echo $OX) - -RSRP="" -RSRQ="" -CHANNEL="-" -ECIO="-" -RSCP="-" -ECIO1=" " -RSCP1=" " -MODE="-" -MODTYPE="-" -NETMODE="-" -LBAND="-" -TEMP="-" -PCI="-" -SINR="-" - -CSQ=$(echo $OX | grep -o "+CSQ: [0-9]\{1,2\}" | grep -o "[0-9]\{1,2\}") -if [ "$CSQ" = "99" ]; then - CSQ="" -fi -if [ -n "$CSQ" ]; then - CSQ_PER=$(($CSQ * 100/31))"%" - CSQ_RSSI=$((2 * CSQ - 113))" dBm" -else - CSQ="-" - CSQ_PER="-" - CSQ_RSSI="-" -fi - -MODE="-" -PSRAT=$(echo $O" " | grep -o "+PSRAT: .\+ OK " | tr " " ",") -TECH=$(echo $PSRAT | cut -d, -f2) -if [ -n "$TECH" ]; then - MODE=$TECH -fi - -ATECH=$(echo $OX | grep -o "+SGCELLINFOEX:[^,]\{2,6\}," | grep -o ":[ ]\?[-A-Z5]\{2,6\}" | grep -o "[-A-Z5]\{2,6\}") -if [ -n "$ATECH" ]; then - MODE=$ATECH -fi - -SGCELL=$(echo $O" " | grep -o "+SGCELLINFO: .\+ OK " | tr " " ",") - -MODEx=$MODE -case $MODEx in - "TD-LTE"|"FDD-LTE"|"FDD" ) - RSSI=$(echo $SGCELL | cut -d, -f5) - CSQ_RSSI="-"$(echo $RSSI | grep -o "[0-9]\{1,3\}")" dBm" - RSCP=$(echo $SGCELL | cut -d, -f6) - RSCP="-"$(echo $RSCP | grep -o "[0-9]\{1,3\}") - ECIO=$(echo $SGCELL| cut -d, -f7) - ECIO="-"$(echo $ECIO | grep -o "[0-9]\{1,3\}") - SSINR=$(echo $SGCELL | cut -d, -f8 | grep -o "[0-9]\{1,3\}") - if [ -n "$SSINR" -a "$SSINR" -le "250" ]; then - SINR=$((($SSINR / 5) - 20))" dB" - fi - LBAND=$(echo $SGCELL | cut -d, -f9) - LBAND=$(echo $LBAND | grep -o "[0-9]\{1,5\}") - let LBAND=LBAND-119 - LBAND="B"$LBAND - CHANNEL=$(echo $SGCELL | cut -d, -f10) - CHANNEL=$(echo $CHANNEL | grep -o "[0-9]\{1,5\}") - ICELL=$(echo $O" " | grep -o "+CELLINFO: .\+ OK " | tr " " ",") - PCI=$(echo $ICELL | cut -d, -f18) - PCI=$(echo $PCI | grep -o "[0-9]\{1,5\}") - if [ $MODE = "FDD" ]; then - MODE="FDD LTE" - fi - ;; - "LTE"|"EN-DC" ) - SGC=$(echo $OX | grep -o "+SGCELLINFOEX:[ ]\?[-CDELNTE]\{3,5\},.\+AT+CELLINFO") - MODE=$(echo $SGC | cut -d, -f2) - PCI=$(echo $SGC | cut -d, -f6) - LBAND="B"$(echo $SGC | cut -d, -f10) - BW=$(echo $SGC | cut -d, -f11 | grep -o "[0-9]\{1,3\}") - if [ $BW -gt 14 ]; then - let BW=BW/5 - else - BW="1.4" - fi - LBAND=$LBAND" (Bandwidth $BW Mhz)" - CHANNEL=$(echo $SGC | cut -d, -f12) - RSSI=$(echo $SGC | cut -d, -f14) - CSQ_RSSI=$(echo $RSSI | grep -o "[-0-9]\{1,3\}")" dBm" - RSCP=$(echo $SGC | cut -d, -f15) - ECIO=$(echo $SGC| cut -d, -f16) - SINR=$(echo $SGC | cut -d, -f18)" dB" - if [ $MODEx == "EN-DC" ]; then - NRSINR=$(echo $SGC | cut -d, -f31 | grep -o "[-0-9]\{1,4\}") - NRBAND=$(echo $SGC | cut -d, -f32 | grep -o "[0-9]\{1,3\}") - NRCHAN=$(echo $SGC | cut -d, -f33 | grep -o "[0-9]\{6,7\}") - NRBW=$(echo $SGC | cut -d, -f34 | grep -o "[0-9]\{1,3\}") - if [ -n "$NRBAND" -a -n "$NRCHAN" -a -n "$NRBW" -a -n $NRSINR ]; then - NRRSRP=$(echo $SGC | cut -d, -f29 | grep -o "[-0-9]\{2,4\}") - NRRSRQ=$(echo $SGC | cut -d, -f30 | grep -o "[-0-9]\{2,4\}") - NRPCI=$(echo $SGC | cut -d, -f35 | grep -o "[0-9]\{1,3\}") - let NRBW=NRBW/5 - LBAND=$LBAND"
                                                                      n"$NRBAND" (Bandwidth "$NRBW" MHz)" - RSCP=$RSCP" dBm
                                                                      "$NRRSRP - ECIO=$ECIO" dBm
                                                                      "$NRRSRQ - SINR=$SINR"
                                                                      "$((($NRSINR / 5) - 20))" dB" - CHANNEL=$CHANNEL","$NRCHAN - PCI=$PCI","$NRPCI - fi - fi - ;; - "5G" ) - SGC=$(echo $OX | grep -o "+SGCELLINFOEX:[ ]\?5G,.\+AT+CELLINFO") - MODE=$(echo $SGC | cut -d, -f2) - PCI=$(echo $SGC | cut -d, -f6) - LBAND="n"$(echo $SGC | cut -d, -f8) - BW=$(echo $SGC | cut -d, -f9 | grep -o "[0-9]\{1,3\}") - let BW=BW/5 - LBAND=$LBAND" (Bandwidth $BW Mhz)" - CHANNEL=$(echo $SGC | cut -d, -f12) - RSCP=$(echo $SGC | cut -d, -f15) - ECIO=$(echo $SGC| cut -d, -f16) - SINR=$(echo $SGC | cut -d, -f17) - SINR=$((($SINR / 5) - 20))" dB" - ;; - "HSPA+"|"HSUPA"|"HSDPA"|"WCDMA" ) - if [ -n "$ATECH" ]; then - SGC=$(echo $OX | grep -o "WCDMA,[0-9]\{3\},.\+AT+CELLINFO" | tr ' ' ',') - CHANNEL=$(echo $SGC | cut -d, -f11) - ECIO=$(echo $SGC | cut -d, -f14) - RSCP=$(echo $SGC | cut -d, -f16) - else - RSCP=$(echo $SGCELL | cut -d, -f11) - RSCP="-"$(echo $RSCP | grep -o "[0-9]\{1,3\}") - ECIO=$(echo $SGCELL| cut -d, -f12) - ECIO="-"$(echo $ECIO | grep -o "[0-9]\{1,3\}") - CHANNEL=$(echo $SGCELL | cut -d, -f8) - CHANNEL=$(echo $CHANNEL | grep -o "[0-9]\{1,4\}") - RSSI=$(echo $SGCELL | cut -d, -f10) - CSQ_RSSI=$(echo $RSSI | grep -o "[0-9]\{1,3\}")" dBm" - fi - ;; - *) - RSCP=$(echo $SGCELL | cut -d, -f10) - RSCP="-"$(echo $RSCP | grep -o "[0-9]\{1,3\}") - CHANNEL=$(echo $SGCELL | cut -d, -f8) - CHANNEL=$(echo $CHANNEL | grep -o "[0-9]\{1,4\}") - RSSI=$(echo $SGCELL | cut -d, -f9) - CSQ_RSSI=$(echo $RSSI | grep -o "[0-9]\{1,3\}")" dBm" - ;; -esac - -CALIST=$(echo "${OX//[ ]/}" | grep -o "+CELLINFO:\"SCC\",[0-9],2,[0-9],[0-9]\{1,6\},[0-9]\{1,4\},[0-9]\{1,3\},[0-9]\{1,3\},[-0-9]\{1,4\},[-0-9]\{1,4\},[-0-9]\{1,4\},[-0-9]\{1,4\}") - -for CAVAL in $(echo "$CALIST"); do - if [ "$(echo $CAVAL | cut -d, -f2)" == "1" ]; then - CATYPE="CA"$(printf "\xe2\x86\x91") - else - CATYPE="CA" - fi - CHANv=$(echo $CAVAL | cut -d, -f5) - BWv=$(echo $CAVAL | cut -d, -f6) - if [ $BWv -gt 14 ]; then - let BWv=BWv/5 - else - BWv="1.4" - fi - if [ $CHANv -ge 123400 ]; then - BANDv="n"$(echo $CAVAL | cut -d, -f7) - else - BANDv="B"$(echo $CAVAL | cut -d, -f7) - fi - LBAND=$LBAND"
                                                                      "$BANDv" ($CATYPE, Bandwidth "$BWv" MHz)" - PCI=$PCI","$(echo $CAVAL | cut -d, -f8) - ECIO=$ECIO" dBm
                                                                      "$(echo $CAVAL | cut -d, -f9) - RSCP=$RSCP" dBm
                                                                      "$(echo $CAVAL | cut -d, -f10) - SINRv=$(echo $CAVAL | cut -d, -f12) - SINRv=$((($SINRv / 5) - 20))" dB" - CHANNEL=$CHANNEL","$CHANv - SINR=$SINR"
                                                                      "$SINRv -done - -NETMODE="-" -NMODE=$(echo $O" " | grep -o "+MODODR: .\+ OK " | tr " " ",") -TECH=$(echo $NMODE | cut -d, -f2) -if [ -n "$TECH" ]; then - MODTYPE="7" - case $TECH in - "2" ) - NETMODE="1" # Auto - ;; - "1" ) - NETMODE="5" # 3G only - ;; - "4" ) - NETMODE="4" # 3G preferred - ;; - "3" ) - NETMODE="3" # 2G only - ;; - "5" ) - NETMODE="7" # LTE only - ;; - * ) - NETMODE="1" - ;; - esac -fi -RATs=$(echo "$OX" | grep -o "\^SYSCFGEX: \"[0-9]\{2,6\}\"" | grep -o "[0-9]\{2,6\}") -if [ -n "$RATs" ]; then - MODTYPE="7" - case $RATs in - "02" ) - NETMODE="5" ;; - "03" ) - NETMODE="7" ;; - "04" ) - NETMODE="9" ;; - "0203" | "0204" | "020304" | "020403" ) - NETMODE="4" ;; - "0304" | "0302" | "030402" | "030204" ) - NETMODE="6" ;; - "0403" ) - NETMODE="8" ;; - * ) - NETMODE="1" ;; - esac -fi - -{ - echo 'CSQ="'"$CSQ"'"' - echo 'CSQ_PER="'"$CSQ_PER"'"' - echo 'CSQ_RSSI="'"$CSQ_RSSI"'"' - echo 'ECIO="'"$ECIO"'"' - echo 'RSCP="'"$RSCP"'"' - echo 'ECIO1="'"$ECIO1"'"' - echo 'RSCP1="'"$RSCP1"'"' - echo 'MODE="'"$MODE"'"' - echo 'MODTYPE="'"$MODTYPE"'"' - echo 'NETMODE="'"$NETMODE"'"' - echo 'CHANNEL="'"$CHANNEL"'"' - echo 'LBAND="'"$LBAND"'"' - echo 'TEMP="'"$TEMP"'"' - echo 'PCI="'"$PCI"'"' - echo 'SINR="'"$SINR"'"' -} > /tmp/signal$CURRMODEM.file - -CONNECT=$(uci get modem.modem$CURRMODEM.connected) -if [ "$CONNECT" == "0" ]; then - exit 0 -fi - -if [ "$CSQ" = "-" ]; then - log "$OX" -fi - -WWANX=$(uci get modem.modem$CURRMODEM.interface) -OPER=$(cat /sys/class/net/$WWANX/operstate 2>/dev/null) -rm -f "/tmp/connstat"$CURRMODEM - -if [ ! "$OPER" ]; then - exit 0 -fi -if echo $OPER | grep -q "unknown"; then - exit 0 -fi - -if echo $OPER | grep -q "down"; then - echo "1" > "/tmp/connstat"$CURRMODEM -fi diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/common/modemchk.lua b/rooter/ext-rooter-basic/files/usr/lib/rooter/common/modemchk.lua deleted file mode 100644 index 4598cd8..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/common/modemchk.lua +++ /dev/null @@ -1,120 +0,0 @@ -#!/usr/bin/lua - -local uvid = arg[1] -local upid = arg[2] -local dport = arg[3] -local cport = arg[4] - -local modemfile = "/etc/config/modem.data" -local modemdata = {} -local count -local retval -local cretval - -function process_line(xline, cnt) - local data = {} - local pline = xline - local start = 1 - for i=1,3 do - s, e = string.find(pline, " ") - data[i] = string.sub(pline, start, s-1) - pline = string.sub(pline, e+1) - end - data[4] = pline - modemdata[cnt] = data -end - -function read_modem() - count = 0 - local file = io.open(modemfile, "r") - if file == nil then - return - end - repeat - local line = file:read("*line") - if line == nil then - break - end - if string.len(line) < 5 then - break - end - count = count + 1 - process_line(line, count) - until 1==0 - file:close() -end - -function process_port() - for l=1,count do - local mdata = modemdata[l] - if mdata[1] == uvid and mdata[2] == upid then - retval = 0 - if mdata[3] == "tty0" then - retval = 1 - end - if mdata[3] == "tty1" then - retval = 2 - end - if mdata[3] == "tty2" then - retval = 3 - end - if mdata[3] == "tty3" then - retval = 4 - end - if mdata[3] == "tty4" then - retval = 5 - end - if mdata[3] == "tty5" then - retval = 6 - end - - cretval = 0 - if mdata[4] == "tty0" then - cretval = 1 - end - if mdata[4] == "tty1" then - cretval = 2 - end - if mdata[4] == "tty2" then - cretval = 3 - end - if mdata[4] == "tty3" then - cretval = 4 - end - if mdata[4] == "tty4" then - cretval = 5 - end - if mdata[4] == "tty5" then - cretval = 6 - end - - break - end - end -end - -read_modem() -retval = 0 -cretval = 0 -if count > 0 then - process_port() -end -if retval > 0 then - retval = retval - 1 -else - retval = tonumber(dport) -end -if cretval > 0 then - cretval = cretval - 1 -else - cretval = tonumber(cport) -end - -dret = string.format("%d", retval) -cret = string.format("%d", cretval) -local file = io.open("/tmp/parmpass", "w") -file:write("DPORT=\"" .. dret .. "\"\n") -file:write("CPORT=\"" .. cret .. "\"\n") -file:close() - -os.exit(retval) diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/common/novateldata.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/common/novateldata.sh deleted file mode 100644 index 0b189ef..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/common/novateldata.sh +++ /dev/null @@ -1,138 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -log() { - logger -t "Novatel Data" "$@" -} - -CURRMODEM=$1 -COMMPORT=$2 - -fix_data() { - OY=$(echo $OY | tr 'a-z' 'A-Z') - O=$($ROOTER/common/processat.sh "$OY") - O=$(echo $O" ") - O=$(echo "${O//[\"]/}") -} - -process_csq() { -CSQ=$(echo $OY | grep -o "+CSQ: [0-9]\{1,2\}" | grep -o "[0-9]\{1,2\}") - if [ "$CSQ" = "99" ]; then - CSQ="" - fi - if [ -n "$CSQ" ]; then - CSQ_PER=$(($CSQ * 100/31))"%" - CSQ_RSSI=$((2 * CSQ - 113))" dBm" - else - CSQ="-" - CSQ_PER="-" - CSQ_RSSI="-" - fi -} - -CSQ="-" -CSQ_PER="-" -CSQ_RSSI="-" -ECIO="-" -RSCP="-" -ECIO1=" " -RSCP1=" " -MODE="-" -MODTYPE="-" -NETMODE="-" -LBAND="-" -CHANNEL="-" -TEMP="-" -PCI="-" -SINR="-" - -OY=$($ROOTER/gcom/gcom-locked "$COMMPORT" "novatelinfo.gcom" "$CURRMODEM") - -fix_data -process_csq - -DEG=$(echo $O" " | grep -o "+NWDEGC: .\+ OK " | tr " " ",") -TMP=$(echo $DEG | cut -d, -f2) -if [ -n "$TMP" ]; then - TEMP=$TMP$(printf "\xc2\xb0")"C" -fi - -MODE="-" -PSRAT=$(echo $O" " | grep -o "\$NWRAT: .\+ OK " | tr " " ",") -TECH=$(echo $PSRAT | cut -d, -f4) -if [ -n "$TECH" ]; then - case "$TECH" in - "1"|"2"|"3") - MODE="UMTS" - ;; - "4"|"5"|"6") - MODE="GSM" - ;; - "7"|"8"|"9") - MODE="LTE" - VZWRSRP=$(echo "$O" | grep -o "VZWRSRP: [0-9]\{1,3\},[0-9]\{1,7\},[-.0-9]\{1,7\}" | tr " " ",") - PCI=$(echo "$VZWRSRP" | cut -d, -f2) - CHANNEL=$(echo "$VZWRSRP" | cut -d, -f3) - LBAND=$("$ROOTER/chan2band.sh" "$CHANNEL") - TMP=$(echo "$VZWRSRP" | cut -d, -f4) - if [ -n "$TMP" ]; then - RSCP=$TMP - fi - VZWRSRQ=$(echo "$O" | grep -o "VZWRSRQ: [0-9]\{1,3\},[0-9]\{1,7\},[-.0-9]\{1,7\}" | tr " " ",") - TMP=$(echo "$VZWRSRQ" | cut -d, -f4) - if [ -n "$TMP" ]; then - ECIO=$TMP - fi - ;; - *) - MODE="CDMA/HDR" - ;; - esac -fi - -{ - echo 'CSQ="'"$CSQ"'"' - echo 'CSQ_PER="'"$CSQ_PER"'"' - echo 'CSQ_RSSI="'"$CSQ_RSSI"'"' - echo 'ECIO="'"$ECIO"'"' - echo 'RSCP="'"$RSCP"'"' - echo 'ECIO1="'"$ECIO1"'"' - echo 'RSCP1="'"$RSCP1"'"' - echo 'MODE="'"$MODE"'"' - echo 'MODTYPE="'"$MODTYPE"'"' - echo 'NETMODE="'"$NETMODE"'"' - echo 'CHANNEL="'"$CHANNEL"'"' - echo 'LBAND="'"$LBAND"'"' - echo 'TEMP="'"$TEMP"'"' - echo 'PCI="'"$PCI"'"' - echo 'SINR="'"$SINR"'"' -} > /tmp/signal$CURRMODEM.file - -CONNECT=$(uci get modem.modem$CURRMODEM.connected) -if [ $CONNECT -eq 0 ]; then - exit 0 -fi - -ENB="0" -if [ -e /etc/config/failover ]; then - ENB=$(uci get failover.enabled.enabled) -fi -if [ $ENB = "1" ]; then - exit 0 -fi - -WWANX=$(uci get modem.modem$CURRMODEM.interface) -OPER=$(cat /sys/class/net/$WWANX/operstate 2>/dev/null) -rm -f "/tmp/connstat"$CURRMODEM - -if [ ! $OPER ]; then - exit 0 -fi -if echo $OPER | grep -q "unknown"; then - exit 0 -fi - -if echo $OPER | grep -q "down"; then - echo "1" > "/tmp/connstat"$CURRMODEM -fi diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/common/otherdata.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/common/otherdata.sh deleted file mode 100644 index af68b66..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/common/otherdata.sh +++ /dev/null @@ -1,97 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -log() { - logger -t "Other Data" "$@" -} - -CURRMODEM=$1 -COMMPORT=$2 - -fix_data() { - O=$($ROOTER/common/processat.sh "$OY") -} - -process_csq() { - CSQ=$(echo "$O" | awk -F[,\ ] '/^\+CSQ:/ {print $2}') - [ "x$CSQ" = "x" ] && CSQ=-1 - if [ $CSQ -ge 0 -a $CSQ -le 31 ]; then - CSQ_PER=$(($CSQ * 100/31)) - CSQ_RSSI=$((2 * CSQ - 113)) - CSQX=$CSQ_RSSI - [ $CSQ -eq 0 ] && CSQ_RSSI="<= "$CSQ_RSSI - [ $CSQ -eq 31 ] && CSQ_RSSI=">= "$CSQ_RSSI - CSQ_PER=$CSQ_PER"%" - CSQ_RSSI=$CSQ_RSSI" dBm" - else - CSQ="-" - CSQ_PER="-" - CSQ_RSSI="-" - fi -} - -CSQ="-" -CSQ_PER="-" -CSQ_RSSI="-" -ECIO="-" -RSCP="-" -ECIO1=" " -RSCP1=" " -MODE="-" -MODETYPE="-" -NETMODE="-" -LBAND="-" -TEMP="-" -PCI="-" -SINR="-" - -OY=$($ROOTER/gcom/gcom-locked "$COMMPORT" "otherinfo.gcom" "$CURRMODEM") - -fix_data -process_csq - -{ - echo 'CSQ="'"$CSQ"'"' - echo 'CSQ_PER="'"$CSQ_PER"'"' - echo 'CSQ_RSSI="'"$CSQ_RSSI"'"' - echo 'ECIO="'"$ECIO"'"' - echo 'RSCP="'"$RSCP"'"' - echo 'ECIO1="'"$ECIO1"'"' - echo 'RSCP1="'"$RSCP1"'"' - echo 'MODE="'"$MODE"'"' - echo 'MODTYPE="'"$MODTYPE"'"' - echo 'NETMODE="'"$NETMODE"'"' - echo 'LBAND="'"$LBAND"'"' - echo 'TEMP="'"$TEMP"'"' - echo 'PCI="'"$PCI"'"' - echo 'SINR="'"$SINR"'"' -} > /tmp/signal$CURRMODEM.file - -CONNECT=$(uci get modem.modem$CURRMODEM.connected) -if [ $CONNECT -eq 0 ]; then - exit 0 -fi - -ENB="0" -if [ -e /etc/config/failover ]; then - ENB=$(uci get failover.enabled.enabled) -fi -if [ $ENB = "1" ]; then - exit 0 -fi - -WWANX=$(uci get modem.modem$CURRMODEM.interface) -OPER=$(cat /sys/class/net/$WWANX/operstate 2>/dev/null) -rm -f "/tmp/connstat"$CURRMODEM - -if [ ! $OPER ]; then - exit 0 -fi -if echo $OPER | grep -q "unknown"; then - exit 0 -fi - -if echo $OPER | grep -q "down"; then - echo "1" > "/tmp/connstat"$CURRMODEM -fi diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/common/phone.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/common/phone.sh deleted file mode 100644 index cf0a8b9..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/common/phone.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -log() { - logger -t "Phone Change" "$@" -} - -CURRMODEM=$1 -PHONE=$2 -NAME=$3 - -CPORT=$(uci get modem.modem$CURRMODEM.commport) -PHONE=$(echo "$PHONE" | sed -e 's/ //g') - -log "Change Modem $CURRMODEM SIM phone number to $PHONE, name to $NAME" - -INTER=${PHONE:0:1} -if [ $INTER = "+" ]; then - TON="145" - PHONE=${PHONE:1} -else - TON="129" -fi - -ATCMDD="AT+CPBS=\"ON\";+CPBS?" -OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") -OX=$($ROOTER/common/processat.sh "$OX") - -ON=$(echo "$OX" | awk -F[,\ ] '/^\+CPBS:/ {print $2}') -if [ "$ON" = "\"ON\"" ]; then - ATCMDD="AT+CPBW=1,\"$PHONE\",$TON,\"$NAME\"" - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - ATCMDD="AT+CNUM" - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - OX=$($ROOTER/common/processat.sh "$OX") - M2=$(echo "$OX" | grep -o "+CNUM:[^,]*,[^,]*,[0-9]\{3\}")"," - M2=${M2:6} - CNUMx=$(echo "$M2" | cut -d, -f1 | cut -d\" -f2) - CNUMx=$(echo $CNUMx) - CNUM=$(echo "$M2" | cut -d, -f2 | cut -d\" -f2) - CNUMtype=$(echo "$M2" | cut -d, -f3) - if [ "${CNUM:0:1}" != "+" -a "$CNUMtype" == "145" ]; then - CNUM="+"$CNUM - fi - if [ -z "$CNUM" ]; then - CNUM="*" - fi - if [ -z "$CNUMx" ]; then - CNUMx="*" - fi - echo "$CNUM" > /tmp/msimnumx$CURRMODEM - echo "$CNUMx" >> /tmp/msimnumx$CURRMODEM - mv -f /tmp/msimnumx$CURRMODEM /tmp/msimnum$CURRMODEM -fi diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/common/processat.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/common/processat.sh deleted file mode 100644 index 16cba63..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/common/processat.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh - -OX=$1 - -M6=$(echo "$OX" | sed -e "s/ / /g") -M5=$(echo "$M6" | sed -e "s/ / /g") -M4=$(echo "$M5" | sed -e "s/ / /g") -M3=$(echo "$M4" | sed -e "s/ / /g") -M2=$(echo "$M3" | sed -e "s/ / /g") -M2=$(echo "$M2" | sed -e "s/TAC:/ /;s/Tx Power:/ /;s/SINR/ /;s!SYSINFOEX:!SYSINFOEX: !;s!CNTI:!CNTI: !;s!SELRAT:!SELRAT: !;s!ZSNT:!ZSNT: !") -M1=$(echo "$M2" | sed -e "s!Car0 Tot Ec/Io!+ECIOx!;s!Car1 Tot Ec/Io!+ECIO1x!;s!Car0 RSCP!+RSCPx!;s!+CGMM: !!") -M2=$(echo "$M1" | sed -e "s!Car1 RSCP!+RSCP1x!;s!CSNR:!CSNR: !;s!RSSI (dBm):!RSSI4: !;s!AirCard !AirCard!;s!USB !USB!") -M3=$(echo "$M2" | sed -e "s!RSRP (dBm):!RSRP4: !;s!RSRQ (dB):!RSRQ4: !;s!LTERSRP:!LTERSRP: !;s!Model:!+MODEL: !;s!SYSCFGEX:!SYSCFGEX: !") -M7=$(echo "$M3" | sed -e "s!RX level Carrier 0 (dBm):!RSSI3: !;s!RX level Carrier 1 (dBm):!RSSI13: !;s!SYSCFG:!SYSCFG: !;s! ! !g") -OX=$(echo "$M7" | sed -e "s!WCDMA channel:!UMTS:!;s!SYSINFO:!SYSINFO: !;s!+PSRAT:!+PSRAT: !;s!+MODODR:!+MODODR: !") -echo "$OX" \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/common/quantadata.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/common/quantadata.sh deleted file mode 100644 index 729ef12..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/common/quantadata.sh +++ /dev/null @@ -1,121 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -log() { - logger -t "Quanta Data" "$@" -} - -CURRMODEM=$1 -COMMPORT=$2 - -OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "quantainfo.gcom" "$CURRMODEM") - -OX=$(echo $OX | tr 'a-z' 'A-Z') - -RSRP="" -RSRQ="" -CHANNEL="-" -ECIO="-" -RSCP="-" -ECIO1=" " -RSCP1=" " -MODE="-" -LBAND="-" -PCI="-" -SINR="-" -TEMP="-" - -CSQ=$(echo $OX | grep -o "+CSQ: [0-9]\{1,2\}" | grep -o "[0-9]\{1,2\}") -if [ "$CSQ" = "99" ]; then - CSQ="" -fi -if [ -n "$CSQ" ]; then - CSQ_PER=$(($CSQ * 100/31))"%" - CSQ_RSSI=$((2 * CSQ - 113))" dBm" -else - CSQ="-" - CSQ_PER="-" - CSQ_RSSI="-" -fi - -REGX='*QRFINFO: \"LTE\",[0-9]\{1,2\},[0-9]\{1,5\},[.012345]\{1,3\},[0-9]\{1,3\},-[0-9]\{1,3\},[-0-9]\{1,3\},[.0-9]\{1,4\}' -LTE=$(echo $OX | grep -o "$REGX") -if [ -n "$LTE" ]; then - MODE="LTE" - BW=$(echo $LTE | cut -d, -f4) - LBAND="B"$(echo $LTE | cut -d, -f2)"(Bandwidth "$BW" MHz)" - RSCP=$(echo $LTE | cut -d, -f6) - ECIO=$(echo $LTE | cut -d, -f7) - CHANNEL=$(echo $LTE | cut -d, -f3) - PCI=$(echo $LTE | cut -d, -f5) - SINR=$(echo $LTE | cut -d, -f8)" dB" -else - REGX='*QRFINFO: \"WCDMA\",[0-9]\{1,2\},[0-9]\{1,5\},[^,],[0-9]\{1,3\},-[0-9]\{1,3\},[-0-9]\{1,3\}' - UMTS=$(echo $OX | grep -o "$REGX") - if [ -n "$UMTS" ]; then - MODE="WCDMA" - LBAND="B"$(echo $UMTS | cut -d, -f2) - RSCP=$(echo $UMTS | cut -d, -f6) - ECIO=$(echo $UMTS | cut -d, -f7) - CHANNEL=$(echo $UMTS | cut -d, -f3) - PCI=$(echo $UMTS | cut -d, -f5) - fi -fi - -TECH=$(echo $OX | grep -o "\^QCNCFG: \"[0123]\{2\}\"" | grep -o "[0123]\{2\}") -case $TECH in - "02") - NETMODE="5" - ;; - "03") - NETMODE="7" - ;; - *) - NETMODE="1" - ;; -esac - -MODTYPE="11" - -{ - echo 'CSQ="'"$CSQ"'"' - echo 'CSQ_PER="'"$CSQ_PER"'"' - echo 'CSQ_RSSI="'"$CSQ_RSSI"'"' - echo 'ECIO="'"$ECIO"'"' - echo 'RSCP="'"$RSCP"'"' - echo 'ECIO1="'"$ECIO1"'"' - echo 'RSCP1="'"$RSCP1"'"' - echo 'MODE="'"$MODE"'"' - echo 'MODTYPE="'"$MODTYPE"'"' - echo 'NETMODE="'"$NETMODE"'"' - echo 'CHANNEL="'"$CHANNEL"'"' - echo 'LBAND="'"$LBAND"'"' - echo 'PCI="'"$PCI"'"' - echo 'TEMP="'"$TEMP"'"' - echo 'SINR="'"$SINR"'"' -} > /tmp/signal$CURRMODEM.file - -CONNECT=$(uci get modem.modem$CURRMODEM.connected) -if [ $CONNECT -eq 0 ]; then - exit 0 -fi - -if [ "$CSQ" = "-" ]; then - log "$OX" -fi - -WWANX=$(uci get modem.modem$CURRMODEM.interface) -OPER=$(cat /sys/class/net/$WWANX/operstate 2>/dev/null) -rm -f "/tmp/connstat"$CURRMODEM - -if [ ! $OPER ]; then - exit 0 -fi -if echo $OPER | grep -q "unknown"; then - exit 0 -fi - -if echo $OPER | grep -q "down"; then - echo "1" > "/tmp/connstat"$CURRMODEM -fi diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/common/quecteldata.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/common/quecteldata.sh deleted file mode 100644 index aa1b1b8..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/common/quecteldata.sh +++ /dev/null @@ -1,376 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -CURRMODEM=$1 -COMMPORT=$2 - -lte_bw() { - BW=$(echo $BW | grep -o "[0-5]\{1\}") - case $BW in - "0") - BW="1.4" ;; - "1") - BW="3" ;; - "2"|"3"|"4"|"5") - BW=$((($(echo $BW) - 1) * 5)) ;; - esac -} - -nr_bw() { - BW=$(echo $BW | grep -o "[0-9]\{1,2\}") - case $BW in - "0"|"1"|"2"|"3"|"4"|"5") - BW=$((($(echo $BW) + 1) * 5)) ;; - "6"|"7"|"8"|"9"|"10"|"11"|"12") - BW=$((($(echo $BW) - 2) * 10)) ;; - "13") - BW="200" ;; - "14") - BW="400" ;; - esac -} - -OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "quectelinfo.gcom" "$CURRMODEM") - -OX=$(echo $OX | tr 'a-z' 'A-Z') - -RSRP="" -RSRQ="" -CHANNEL="-" -ECIO="-" -RSCP="-" -ECIO1=" " -RSCP1=" " -MODE="-" -MODTYPE="-" -NETMODE="-" -LBAND="-" -PCI="-" -CTEMP="-" -SINR="-" -CSQ=$(echo $OX | grep -o "+CSQ: [0-9]\{1,2\}" | grep -o "[0-9]\{1,2\}") -if [ "$CSQ" = "99" ]; then - CSQ="" -fi -if [ -n "$CSQ" ]; then - CSQ_PER=$(($CSQ * 100/31))"%" - CSQ_RSSI=$((2 * CSQ - 113))" dBm" -else - CSQ="-" - CSQ_PER="-" - CSQ_RSSI="-" -fi -NR_NSA=$(echo $OX | grep -o "+QENG:[ ]\?\"NR5G-NSA\",") -NR_SA=$(echo $OX | grep -o "+QENG: \"SERVINGCELL\",[^,]\+,\"NR5G-SA\",\"[DFT]\{3\}\",") -if [ -n "$NR_NSA" ]; then - QENG=",,"$(echo $OX" " | grep -o "+QENG: \"LTE\".\+\"NR5G-NSA\"," | tr " " ",") - QENG5=$(echo $OX | grep -o "+QENG:[ ]\?\"NR5G-NSA\",[0-9]\{3\},[0-9]\{2,3\},[0-9]\{1,5\},-[0-9]\{2,5\},[-0-9]\{1,3\},-[0-9]\{2,3\},[0-9]\{1,7\},[0-9]\{1,3\}.\{1,6\}") - if [ -z "$QENG5" ]; then - QENG5=$(echo $OX | grep -o "+QENG:[ ]\?\"NR5G-NSA\",[0-9]\{3\},[0-9]\{2,3\},[0-9]\{1,5\},-[0-9]\{2,3\},[-0-9]\{1,3\},-[0-9]\{2,3\}") - if [ -n "$QENG5" ]; then - QENG5=$QENG5",," - fi - fi -elif [ -n "$NR_SA" ]; then - QENG=$(echo $NR_SA | tr " " ",") - QENG5=$(echo $OX | grep -o "+QENG: \"SERVINGCELL\",[^,]\+,\"NR5G-SA\",\"[DFT]\{3\}\",[ 0-9]\{3,4\},[0-9]\{2,3\},[0-9A-F]\{1,10\},[0-9]\{1,5\},[0-9A-F]\{2,6\},[0-9]\{6,7\},[0-9]\{1,3\},[0-9]\{1,2\},-[0-9]\{2,5\},-[0-9]\{2,3\},[-0-9]\{1,3\}") -else - QENG=$(echo $OX" " | grep -o "+QENG: [^ ]\+ " | tr " " ",") -fi -QCA=$(echo $OX" " | grep -o "+QCAINFO: \"S[CS]\{2\}\".\+NWSCANMODE" | tr " " ",") -QNSM=$(echo $OX | grep -o "+QCFG: \"NWSCANMODE\",[0-9]") -QNWP=$(echo $OX | grep -o "+QNWPREFCFG: \"MODE_PREF\",[A-Z5:]\+" | cut -d, -f2) -QTEMP=$(echo $OX | grep -o "+QTEMP: [0-9]\{1,3\}") -if [ -z "$QTEMP" ]; then - QTEMP=$(echo $OX | grep -o "+QTEMP:[ ]\?\"XO[_-]THERM[_-][^,]\+,[\"]\?[0-9]\{1,3\}" | grep -o "[0-9]\{1,3\}") -fi -if [ -z "$QTEMP" ]; then - QTEMP=$(echo $OX | grep -o "+QTEMP:[ ]\?\"MDM-CORE-USR.\+[0-9]\{1,3\}\"" | cut -d\" -f4) -fi -if [ -z "$QTEMP" ]; then - QTEMP=$(echo $OX | grep -o "+QTEMP:[ ]\?\"MDMSS.\+[0-9]\{1,3\}\"" | cut -d\" -f4) -fi -if [ -n "$QTEMP" ]; then - CTEMP=$(echo $QTEMP | grep -o "[0-9]\{1,3\}")$(printf "\xc2\xb0")"C" -fi -RAT=$(echo $QENG | cut -d, -f4 | grep -o "[-A-Z5]\{3,7\}") -rm -f /tmp/modnetwork -case $RAT in - "GSM") - MODE="GSM" - ;; - "WCDMA") - MODE="WCDMA" - CHANNEL=$(echo $QENG | cut -d, -f9) - RSCP=$(echo $QENG | cut -d, -f12) - RSCP="-"$(echo $RSCP | grep -o "[0-9]\{1,3\}") - ECIO=$(echo $QENG | cut -d, -f13) - ECIO="-"$(echo $ECIO | grep -o "[0-9]\{1,3\}") - ;; - "LTE"|"CAT-M"|"CAT-NB") - MODE=$(echo $QENG | cut -d, -f5 | grep -o "[DFT]\{3\}") - if [ -n "$MODE" ]; then - MODE="$RAT $MODE" - else - MODE="$RAT" - fi - PCI=$(echo $QENG | cut -d, -f9) - CHANNEL=$(echo $QENG | cut -d, -f10) - LBAND=$(echo $QENG | cut -d, -f11 | grep -o "[0-9]\{1,3\}") - BW=$(echo $QENG | cut -d, -f12) - lte_bw - BWU=$BW - BW=$(echo $QENG | cut -d, -f13) - lte_bw - BWD=$BW - if [ -z "$BWD" ]; then - BWD="unknown" - fi - if [ -z "$BWU" ]; then - BWU="unknown" - fi - if [ -n "$LBAND" ]; then - LBAND="B"$LBAND" (Bandwidth $BWD MHz Down | $BWU MHz Up)" - fi - RSRP=$(echo $QENG | cut -d, -f15 | grep -o "[0-9]\{1,3\}") - if [ -n "$RSRP" ]; then - RSCP="-"$RSRP - RSRPLTE=$RSCP - fi - RSRQ=$(echo $QENG | cut -d, -f16 | grep -o "[0-9]\{1,3\}") - if [ -n "$RSRQ" ]; then - ECIO="-"$RSRQ - fi - RSSI=$(echo $QENG | cut -d, -f17 | grep -o "\-[0-9]\{1,3\}") - if [ -n "$RSSI" ]; then - CSQ_RSSI=$RSSI" dBm" - fi - SINRR=$(echo $QENG | cut -d, -f18 | grep -o "[0-9]\{1,3\}") - if [ -n "$SINRR" ]; then - if [ $SINRR -le 25 ]; then - SINR=$((($(echo $SINRR) * 2) -20))" dB" - fi - fi - - if [ -n "$NR_NSA" ]; then - MODE="LTE/NR EN-DC" - echo "0" > /tmp/modnetwork - if [ -n "$QENG5" ] && [ -n "$LBAND" ] && [ "$RSCP" != "-" ] && [ "$ECIO" != "-" ]; then - PCI="$PCI, "$(echo $QENG5 | cut -d, -f4) - SCHV=$(echo $QENG5 | cut -d, -f8) - SLBV=$(echo $QENG5 | cut -d, -f9) - BW=$(echo $QENG5 | cut -d, -f10 | grep -o "[0-9]\{1,3\}") - if [ -n "$SLBV" ]; then - LBAND=$LBAND"
                                                                      n"$SLBV - if [ -n "$BW" ]; then - nr_bw - LBAND=$LBAND" (Bandwidth $BW MHz)" - fi - if [ "$SCHV" -ge 123400 ]; then - CHANNEL=$CHANNEL", "$SCHV - else - CHANNEL=$CHANNEL", -" - fi - else - LBAND=$LBAND"
                                                                      nxx (unknown NR5G band)" - CHANNEL=$CHANNEL", -" - fi - RSCP=$RSCP" dBm
                                                                      "$(echo $QENG5 | cut -d, -f5) - SINRR=$(echo $QENG5 | cut -d, -f6 | grep -o "[0-9]\{1,3\}") - if [ -n "$SINRR" ]; then - if [ $SINRR -le 30 ]; then - SINR=$SINR"
                                                                      "$((($(echo $SINRR) * 2) -20))" dB" - fi - fi - ECIO=$ECIO" (4G) dB
                                                                      "$(echo $QENG5 | cut -d, -f7)" (5G) " - fi - fi - if [ -z "$LBAND" ]; then - LBAND="-" - else - if [ -n "$QCA" ]; then - QCA=$(echo $QCA | grep -o "\"S[CS]\{2\}\"[-0-9A-Z,\"]\+") - for QCAL in $(echo "$QCA"); do - if [ $(echo "$QCAL" | cut -d, -f7) = "2" ]; then - SCHV=$(echo $QCAL | cut -d, -f2 | grep -o "[0-9]\+") - SRATP="B" - if [ -n "$SCHV" ]; then - CHANNEL="$CHANNEL, $SCHV" - if [ "$SCHV" -gt 123400 ]; then - SRATP="n" - fi - fi - SLBV=$(echo $QCAL | cut -d, -f6 | grep -o "[0-9]\{1,2\}") - if [ -n "$SLBV" ]; then - LBAND=$LBAND"
                                                                      "$SRATP$SLBV - BWD=$(echo $QCAL | cut -d, -f3 | grep -o "[0-9]\{1,3\}") - if [ -n "$BWD" ]; then - UPDOWN=$(echo $QCAL | cut -d, -f13) - case "$UPDOWN" in - "UL" ) - CATYPE="CA"$(printf "\xe2\x86\x91") ;; - "DL" ) - CATYPE="CA"$(printf "\xe2\x86\x93") ;; - * ) - CATYPE="CA" ;; - esac - if [ $BWD -gt 14 ]; then - LBAND=$LBAND" ("$CATYPE", Bandwidth "$(($(echo $BWD) / 5))" MHz)" - else - LBAND=$LBAND" ("$CATYPE", Bandwidth 1.4 MHz)" - fi - fi - LBAND=$LBAND - fi - PCI="$PCI, "$(echo $QCAL | cut -d, -f8) - fi - done - fi - fi - if [ $RAT = "CAT-M" ] || [ $RAT = "CAT-NB" ]; then - LBAND="B$(echo $QENG | cut -d, -f11) ($RAT)" - fi - ;; - "NR5G-SA") - MODE="NR5G-SA" - echo "0" > /tmp/modnetwork - if [ -n "$QENG5" ]; then - MODE="$RAT $(echo $QENG5 | cut -d, -f4)" - PCI=$(echo $QENG5 | cut -d, -f8) - CHANNEL=$(echo $QENG5 | cut -d, -f10) - LBAND=$(echo $QENG5 | cut -d, -f11) - BW=$(echo $QENG5 | cut -d, -f12) - nr_bw - LBAND="n"$LBAND" (Bandwidth $BW MHz)" - RSCP=$(echo $QENG5 | cut -d, -f13) - ECIO=$(echo $QENG5 | cut -d, -f14) - if [ "$CSQ_PER" = "-" ]; then - RSSI=$(rsrp2rssi $RSCP $BW) - CSQ_PER=$((100 - (($RSSI + 51) * 100/-62)))"%" - CSQ=$((($RSSI + 113) / 2)) - CSQ_RSSI=$RSSI" dBm" - fi - SINRR=$(echo $QENG5 | cut -d, -f15 | grep -o "[0-9]\{1,3\}") - if [ -n "$SINRR" ]; then - if [ $SINRR -le 30 ]; then - SINR=$((($(echo $SINRR) * 2) -20))" dB" - fi - fi - fi - ;; -esac - -QRSRP=$(echo "$OX" | grep -o "+QRSRP:[^,]\+,-[0-9]\{1,5\},-[0-9]\{1,5\},-[0-9]\{1,5\}[^ ]*") -if [ -n "$QRSRP" ] && [ "$RAT" != "WCDMA" ]; then - QRSRP1=$(echo $QRSRP | cut -d, -f1 | grep -o "[-0-9]\+") - QRSRP2=$(echo $QRSRP | cut -d, -f2) - QRSRP3=$(echo $QRSRP | cut -d, -f3) - QRSRP4=$(echo $QRSRP | cut -d, -f4) - QRSRPtype=$(echo $QRSRP | cut -d, -f5) - if [ "$QRSRPtype" == "NR5G" ]; then - if [ -n "$NR_SA" ]; then - RSCP=$QRSRP1 - if [ -n "$QRSRP2" -a "$QRSRP2" != "-32768" ]; then - RSCP1="RxD "$QRSRP2 - fi - if [ -n "$QRSRP3" -a "$QRSRP3" != "-32768" -a "$QRSRP3" != "-44" ]; then - RSCP=$RSCP" dBm
                                                                      "$QRSRP3 - fi - if [ -n "$QRSRP4" -a "$QRSRP4" != "-32768" -a "$QRSRP4" != "-44" ]; then - RSCP1="RxD "$QRSRP4 - fi - else - RSCP=$RSRPLTE - if [ -n "$QRSRP1" -a "$QRSRP1" != "-32768" ]; then - RSCP=$RSCP" (4G) dBm
                                                                      "$QRSRP1 - if [ -n "$QRSRP2" -a "$QRSRP2" != "-32768" ]; then - RSCP="$RSCP,$QRSRP2" - if [ -n "$QRSRP3" -a "$QRSRP3" != "-32768" ]; then - RSCP="$RSCP,$QRSRP3" - if [ -n "$QRSRP4" -a "$QRSRP4" != "-32768" ]; then - RSCP="$RSCP,$QRSRP4" - fi - fi - RSCP=$RSCP" (5G) " - fi - fi - fi - elif [ "$QRSRP2$QRSRP3$QRSRP4" != "-44-44-44" -a -z "$QENG5" ]; then - RSCP=$QRSRP1 - if [ "$QRSRP3$QRSRP4" == "-140-140" -o "$QRSRP3$QRSRP4" == "-44-44" -o "$QRSRP3$QRSRP4" == "-32768-32768" ]; then - RSCP1="RxD "$(echo $QRSRP | cut -d, -f2) - else - RSCP=$RSCP" dBm (RxD "$QRSRP2" dBm)
                                                                      "$QRSRP3 - RSCP1="RxD "$QRSRP4 - fi - fi -fi - -QNSM=$(echo "$QNSM" | grep -o "[0-9]") -if [ -n "$QNSM" ]; then - MODTYPE="6" - case $QNSM in - "0" ) - NETMODE="1" ;; - "1" ) - NETMODE="3" ;; - "2"|"5" ) - NETMODE="5" ;; - "3" ) - NETMODE="7" ;; - esac -fi -if [ -n "$QNWP" ]; then - MODTYPE="6" - case $QNWP in - "AUTO" ) - NETMODE="1" ;; - "WCDMA" ) - NETMODE="5" ;; - "LTE" ) - NETMODE="7" ;; - "LTE:NR5G" ) - NETMODE="8" ;; - "NR5G" ) - NETMODE="9" ;; - esac -fi - -CMODE=$(uci -q get modem.modem$CURRMODEM.cmode) -if [ "$CMODE" = 0 ]; then - NETMODE="10" -fi - -{ - echo 'CSQ="'"$CSQ"'"' - echo 'CSQ_PER="'"$CSQ_PER"'"' - echo 'CSQ_RSSI="'"$CSQ_RSSI"'"' - echo 'ECIO="'"$ECIO"'"' - echo 'RSCP="'"$RSCP"'"' - echo 'ECIO1="'"$ECIO1"'"' - echo 'RSCP1="'"$RSCP1"'"' - echo 'MODE="'"$MODE"'"' - echo 'MODTYPE="'"$MODTYPE"'"' - echo 'NETMODE="'"$NETMODE"'"' - echo 'CHANNEL="'"$CHANNEL"'"' - echo 'LBAND="'"$LBAND"'"' - echo 'PCI="'"$PCI"'"' - echo 'TEMP="'"$CTEMP"'"' - echo 'SINR="'"$SINR"'"' -} > /tmp/signal$CURRMODEM.file - -WWANX=$(uci get modem.modem$CURRMODEM.interface) -OPER=$(cat /sys/class/net/$WWANX/operstate 2>/dev/null) -rm -f "/tmp/connstat"$CURRMODEM - -if [ ! $OPER ]; then - exit 0 -fi -if echo $OPER | grep -q "unknown"; then - exit 0 -fi - -if echo $OPER | grep -q "down"; then - echo "1" > "/tmp/connstat"$CURRMODEM -fi diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/common/sierradata.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/common/sierradata.sh deleted file mode 100644 index 11f1e99..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/common/sierradata.sh +++ /dev/null @@ -1,258 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -log() { - logger -t "Sierra Data" "$@" -} - -read_ssc() { - SLBAND=$(echo $OX | grep -o "LTE "$SSCx" BAND: B[0-9]\+ LTE "$SSCx" BW :") - SLBAND=$(echo $SLBAND | grep -o " BAND: B[0-9]\+ ") - if [ -n "$SLBAND" ]; then - SLBAND=$(echo $SLBAND | grep -o "[0-9]\+") - SLBAND=$(printf "
                                                                      B%d" $SLBAND) - BWD=$(echo $OX | grep -o " LTE "$SSCx" BW : [.012345]\+ [ML]") - BWD=$(echo $BWD | grep -o " BW : [.012345]\+" | grep -o "[.012345]\+") - if [ -n "$BWD" ]; then - SLBAND=$SLBAND$(printf " (CA, Bandwidth %s MHz)" $BWD) - else - SLBAND=$SLBAND$(printf " (CA, Bandwidth unknown)") - fi - LBAND=$LBAND$SLBAND - XTRACHAN=$(echo $OX | grep -o " LTE "$SSCx" CHAN: [0-9]\+") - XTRACHAN=$(echo "$XTRACHAN" | grep -o "[0-9]\{2,6\}") - if [ -n "$XTRACHAN" ]; then - CHANNEL=$(echo "$CHANNEL", "$XTRACHAN") - fi - fi -} - -CURRMODEM=$1 -COMMPORT=$2 - -OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "sierrainfo.gcom" "$CURRMODEM") - -OX=$(echo $OX | tr 'a-z' 'A-Z') - -CSQ=$(echo $OX | grep -o "+CSQ: [0-9]\{1,2\}" | grep -o "[0-9]\{1,2\}") -if [ -z "$CSQ" ] || [ "$CSQ" = "99" ]; then - CSQ="-" - CSQ_PER="-" - CSQ_RSSI="-" -else - CSQ_PER=$(($CSQ * 100/31))"%" - CSQ_RSSI=$((2 * CSQ - 113))" dBm" -fi - -MODTYPE="-" -NETMODE="-" -LBAND="-" -PCI="-" - -LTEINFO=$(echo $OX | grep -o "!LTEINFO: .\+ INTRAFREQ:" | tr " " ",") -LTEINFO=$(echo "$LTEINFO" | grep -o "[0-9]\{1,6\}\,[0-9]\{3\}\,.\+") -if [ -n "$LTEINFO" ]; then - PCI=$(echo $LTEINFO | cut -d, -f10 | grep -o "[0-9]\{1,3\}") - if [ -z "$PCI" ]; then - PCI="-" - fi -fi - -SINR=$(echo $OX | grep -o "SINR (.B): [-.0-9]\{1,5\}" | tr '\n' ' ' | cut -d' ' -f3) -if [ -n "$SINR" ]; then - SINR5=$(echo $OX | grep -o "NR5G SINR (.B): [-]*[.0-9]\{1,5\}" | cut -d' ' -f4) - if [ -n "$SINR5" ]; then - SINR=$SINR" dB, "$SINR5 - fi - SINR=$SINR" dB" -else - SINR="-" -fi -TEMP=$(echo $OX | grep -o "TEMPERATURE: [-.0-9]\+ " | grep -o "[-.0-9]\+" | tr '\n' ' ') -if [ -n "$TEMP" ]; then - TEMP=$(printf "$(echo $TEMP | cut -d' ' -f2)\xc2\xb0C") -else - TEMP="unknown" -fi - -RAT=$(echo $OX | grep -o "SYSTEM MODE: [^ ]\{3,10\}" | cut -d' ' -f3) - -MODE=$RAT -case $RAT in - "WCDMA") - MODE=$(echo $OX | grep -o " \*CNTI: 0,[^ ]\+" | cut -d, -f2) - if [ -z "$MODE" ] || [ "$MODE" = "NONE" ]; then - MODE=$RAT - fi - CHANNEL=$(echo $OX | grep -o "WCDMA CHANNEL: [0-9]\{3,5\}" | cut -d' ' -f3) - if [ -n "$CHANNEL" ]; then - LOCKCHAN=$(echo $OX | grep -o "!UMTSCHAN? ENABLE: 01 CHANNEL: [0-9]\{3,5\}") - if [ -n "$LOCKCHAN" ]; then - LOCKCHAN=$(echo $LOCKCHAN | grep -o "CHANNEL: [0-9]\+" | grep -o "[0-9]\+") - CHANNEL=$CHANNEL" (Soft locked to $LOCKCHAN)" - fi - else - CHANNEL="-" - fi - ECIO=$(echo $OX | grep -o "EC/IO: [+-]\?[.0-9]\+") - ECIO=$(echo "$ECIO") - ECIO1=$(echo "$ECIO" | cut -d' ' -f4) - ECIO=$(echo "$ECIO" | cut -d' ' -f2) - RSCP=$(echo $OX | grep -o "RSCP: -[.0-9]\+") - RSCP=$(echo "$RSCP") - RSCP1=$(echo "$RSCP" | cut -d' ' -f4) - RSCP=$(echo "$RSCP" | cut -d' ' -f2) - ;; - "LTE") - LBAND=$(echo $OX | grep -o "LTE BAND: B[0-9]\+ LTE BW: [.012345]\+ MHZ" | grep -o "[.0-9]\+") - LBAND=$(printf "B%d (Bandwidth %s MHz)" $LBAND) - CHANNEL=$(echo $OX | grep -o "LTE RX CHAN: [0-9]\{1,6\}" | grep -o "[0-9]\+") - SLBAND=$(echo $OX | grep -o " ACTIVE LTE SCELL BAND:[ ]*B[0-9]\+ LTE SCELL BW:[ ]*[.012345]\+ MHZ") - if [ -n "$SLBAND" ]; then - SLBAND=$(echo $SLBAND | grep -o "[.0-9]\+") - SLBAND=$(printf "
                                                                      B%d (CA, Bandwidth %s MHz)" $SLBAND) - LBAND=$LBAND$SLBAND - XTRACHAN=$(echo $OX | grep -o " LTE SCELL CHAN:[0-9]\+" | grep -o "[0-9]\{2,6\}") - CHANNEL=$CHANNEL", "$XTRACHAN - fi - SSCLIST=$(echo $OX | grep -o "LTE S[CS]C[0-9] STATE:[ ]\?ACTIVE" | grep -o "[0-9]") - for SSCVAL in $(echo "$SSCLIST"); do - SSCx="S[CS]C"$SSCVAL - read_ssc - done - if [ -n "$LTEINFO" ]; then - RSCP=$(echo $LTEINFO | cut -d, -f12 | grep -o "[-][.0-9]\{2,5\}") - ECIO=$(echo $LTEINFO | cut -d, -f11 | grep -o "[-.0-9]\{1,5\}") - fi - if [ -z "$RSCP" ]; then - RSCP=$(echo $OX | grep -o "PCC RXM RSRP: -[0-9]\{2,3\} " | cut -d' ' -f4) - fi - if [ -n "$RSCP" ]; then - RSCP1=$(echo $OX | grep -o "PCC RXD RSRP: -[0-9]\{2,3\} " | cut -d' ' -f4) - if [ -z "$RSCP1" ]; then - RSCP1=$(echo $OX | grep -o "PCC RXD RSSI: -[0-9]\+ RSRP (DBM): -[0-9]\{2,3\} " | cut -d' ' -f7) - fi - else - RSCP=$(echo $OX | grep -o "RSRP (DBM): -[0-9]\{2,3\} " | tr '\n' ' ' | cut -d' ' -f3) - fi - if [ -z "$ECIO" ]; then - ECIO=$(echo $OX | grep -o "RSRQ (DB): [-.0-9]\{1,5\} " | cut -d' ' -f3) - fi - ;; - "ENDC") - MODE="LTE/NR EN-DC" - LBAND=$(echo $OX | grep -o "LTE BAND: B[0-9]\+ LTE BW: [.012345]\+ MHZ" | grep -o "[.0-9]\+") - LBAND=$(printf "B%d (Bandwidth %s MHz)" $LBAND) - CHANNEL=$(echo $OX | grep -o "LTE RX CHAN: [0-9]\{1,6\}" | grep -o "[0-9]\+") - NBAND=$(echo $OX | grep -o "NR5G BAND: N[0-9]\+ NR5G BW: [0-9]\+ MHZ") - NBAND=$(echo "$NBAND" | cut -d' ' -f3)" "$(echo "$NBAND" | cut -d' ' -f6) - if [ "$NBAND" != " " ]; then - NBAND=$(echo $NBAND | grep -o "[.0-9]\+") - NBAND=$(printf "
                                                                      n%d (Bandwidth %s MHz)" $NBAND) - LBAND=$LBAND$NBAND - NCHAN=$(echo $OX | grep -o "NR5G RX CHAN: [0-9]\{6\}" | cut -d' ' -f4) - CHANNEL=$CHANNEL", "$NCHAN - fi - SSCLIST=$(echo $OX | grep -o "LTE S[CS]C[0-9] STATE:[ ]\?ACTIVE" | grep -o "[0-9]") - for SSCVAL in $(echo "$SSCLIST"); do - SSCx="S[CS]C"$SSCVAL - read_ssc - done - RSCP=$(echo $OX | grep -o "PCC RXM RSRP: -[0-9]\{2,3\} " | cut -d' ' -f4) - RSCP1=$(echo $OX | grep -o "NR5G RSRP (DBM): -[0-9]\{2,3\} " | cut -d' ' -f4) - ECIO=$(echo $OX | grep -o "RSRQ (DB): [-.0-9]\{1,5\} " | tr '\n' ' ' | cut -d' ' -f3) - ECIO1=$(echo $OX | grep -o "NR5G RSRQ (DB): [-.0-9]\{1,5\} " | cut -d' ' -f4) - ;; - "NR5G") - MODE="NR5G-SA" - NBAND=$(echo $OX | grep -o "NR5G BAND: N[0-9]\+ NR5G BW: [0-9]\+ MHZ") - NBAND=$(echo "$NBAND" | cut -d' ' -f3)" "$(echo "$NBAND" | cut -d' ' -f6) - CHANNEL=$(echo $OX | grep -o "NR5G RX CHAN: [0-9]\{1,6\}" | grep -o "[0-9]\+") - RSCP=$(echo $OX | grep -o "PCC RXM RSRP: -[0-9]\{2,3\} " | cut -d' ' -f4) - ECIO=$(echo $OX | grep -o "RSRQ (DB): [-.0-9]\{1,5\} " | cut -d' ' -f3) - ;; -esac - -SELRAT=$(echo $OX | grep -o "!SELRAT:[^0-9]\+[0-9]\{2\}" | grep -o "[0-9]\{2\}") -if [ -n "$SELRAT" ]; then - MODTYPE="2" - case $SELRAT in - "01" ) - NETMODE="5" - ;; - "02" ) - NETMODE="3" - ;; - "06" ) - NETMODE="7" - ;; - * ) - NETMODE="1" - ;; - esac -fi - -CMODE=$(uci -q get modem.modem$CURRMODEM.cmode) - -if [ "$CMODE" = 0 ]; then - NETMODE="10" -fi -if [ -z "$RSCP1" ]; then - RSCP1=" " -fi -if [ -z "$ECIO1" ]; then - ECIO1=" " -fi - -{ - echo 'CSQ="'"$CSQ"'"' - echo 'CSQ_PER="'"$CSQ_PER"'"' - echo 'CSQ_RSSI="'"$CSQ_RSSI"'"' - echo 'ECIO="'"$ECIO"'"' - echo 'RSCP="'"$RSCP"'"' - echo 'ECIO1="'"$ECIO1"'"' - echo 'RSCP1="'"$RSCP1"'"' - echo 'MODE="'"$MODE"'"' - echo 'MODTYPE="'"$MODTYPE"'"' - echo 'NETMODE="'"$NETMODE"'"' - echo 'CHANNEL="'"$CHANNEL"'"' - echo 'LBAND="'"$LBAND"'"' - echo 'PCI="'"$PCI"'"' - echo 'TEMP="'"$TEMP"'"' - echo 'SINR="'"$SINR"'"' -} > /tmp/signal$CURRMODEM.file - -CONNECT=$(uci -q get modem.modem$CURRMODEM.connected) - -if [ "$CONNECT" -eq 0 ]; then - exit 0 -fi - -if [ $CSQ = "-" ]; then - log "$OX" -fi - -ENB="0" -if [ -e /etc/config/failover ]; then - ENB=$(uci get failover.enabled.enabled) -fi - -if [ $ENB = "1" ]; then - exit 0 -fi - -WWANX=$(uci -q get modem.modem$CURRMODEM.interface) -OPER=$(cat /sys/class/net/$WWANX/operstate 2>/dev/null) -rm -f "/tmp/connstat"$CURRMODEM - -if [ ! $OPER ]; then - exit 0 -fi -if echo $OPER | grep -q "unknown"; then - exit 0 -fi - -if echo $OPER | grep -q "down"; then - echo "1" > "/tmp/connstat"$CURRMODEM -fi diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/common/simcomdata.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/common/simcomdata.sh deleted file mode 100644 index e48fdaf..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/common/simcomdata.sh +++ /dev/null @@ -1,172 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -CURRMODEM=$1 -COMMPORT=$2 - -decode_bw() { - BW=$(echo $BW | grep -o "[0-5]\{1\}") - case $BW in - "0") - BW="1.4" ;; - "1") - BW="3" ;; - "2") - BW="5" ;; - "3") - BW="10" ;; - "4") - BW="15" ;; - "5") - BW="20" ;; - esac -} - -OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "simcominfo.gcom" "$CURRMODEM") - -OX=$(echo $OX | tr 'a-z' 'A-Z') - -REGXa="+CPSI:[ ]*LTE,ONLINE,[0-9]\{3\}-[0-9]\{2,3\},0X[0-9A-F]\{1,5\},[0-9]\{3,9\},[0-9]\{1,3\},[-A-Z0-9]\+,[0-9]\{1,6\},[0-5],[0-5],-[0-9]\{1,3\},-[0-9]\{1,4\},[-0-9]\{1,5\},[0-9]\{1,2\}" - -REGXb="+CPSI:[ ]*NR5G[_ANS]*,[0-9]\{1,3\},[0-9]\{6\},-[0-9]\{1,4\},-[0-9]\{1,4\},[-0-9]\{1,4\}" - -REGXc="+CPSI:[ ]*NR5G_SA,ONLINE,[0-9]\{3\}-[0-9]\{2,3\},0X[0-9A-F]\{1,6\},[0-9]\{3,13\},[0-9]\{1,3\},[^,]\+,[0-9]\{6,7\},-[0-9]\{1,4\},-[0-9]\{1,4\},[-0-9]\{1,4\}" - -REGXz="+CMGRMI: CA_SCELL,[0-9]\{2,6\},[^,]\+,[0-9]\{1,3\},[0-5],[^,]\+,[0-9]\{1,3\},[^,]\+,[^,]\+,[^,]\+,[^,]\+,[^,]\+,1" - -CHANNEL="-" -ECIO="-" -RSCP="-" -ECIO1=" " -RSCP1=" " -MODE="-" -NETMODE="-" -LBAND="-" -PCI="-" -CTEMP="-" -MODE="" -SINR="-" - -CSQ=$(echo "$OX" | grep -o "+CSQ: [0-9]\{1,2\}" | grep -o "[0-9]\{1,2\}") -if [ $CSQ = "99" ]; then - CSQ="" -fi -if [ -n "$CSQ" ]; then - CSQ_PER=$(($CSQ * 100/31))"%" - CSQ_RSSI=$((2 * CSQ - 113))" dBm" -else - CSQ="-" - CSQ_PER="-" - CSQ_RSSI="-" -fi - -CPSIa=$(echo "$OX" | grep -o "$REGXa") -if [ -n "$CPSIa" ]; then - CPSIb=$(echo "$OX" | grep -o "$REGXb") - PCI=$(echo $CPSIa | cut -d, -f6) - LBAND=$(echo $CPSIa | cut -d, -f7 | grep -o "[0-9]\{1,3\}") - CHANNEL=$(echo $CPSIa | cut -d, -f8) - BW=$(echo $CPSIa | cut -d, -f9) - decode_bw - BWD=$BW - BW=$(echo $CPSIa | cut -d, -f10) - decode_bw - BWU=$BW - LBAND="B"$LBAND" (Bandwidth $BWD MHz Down | $BWU MHz Up)" - ECIO=$(($(echo $CPSIa | cut -d, -f11) / 10)) - RSCP=$(($(echo $CPSIa | cut -d, -f12) / 10)) - SINR=$((($(echo $CPSIa | cut -d, -f14) * 2) - 20))" dB" - if [ -n "$CPSIb" ]; then - MODE="LTE/NR EN-DC" - PCI=$PCI", "$(echo $CPSIb | cut -d, -f2) - NCHAN=$(echo $CPSIb | cut -d, -f3) - CHANNEL="$CHANNEL, $NCHAN" - NBAND=$("$ROOTER/chan2band.sh" "$NCHAN") - if [ "$NBAND" = "-" ]; then - LBAND=$LBAND"
                                                                      nxx (unknown NR5G band)" - else - LBAND=$LBAND"
                                                                      "$NBAND - fi - RSCP=$RSCP" dBm
                                                                      "$(($(echo $CPSIb | cut -d, -f4) / 10)) - ECIO=$ECIO" dB
                                                                      "$(($(echo $CPSIb | cut -d, -f5) / 10)) - SSINR=$(echo $CPSIb | cut -d, -f6) - if [ $SSINR -lt 255 ]; then - SINR=$SINR"
                                                                      "$((($SSINR / 5) - 20))" dB" - fi - else - MODE="LTE" - fi - CPSIc="" -else - CPSIc=$(echo "$OX" | grep -o "$REGXc") - if [ -n "$CPSIc" ]; then - MODE="NR5G" - PCI=$(echo $CPSIc | cut -d, -f6) - LBAND="n"$(echo $CPSIc | cut -d, -f7 | grep -o "BAND[0-9]\{1,3\}" | grep -o "[0-9]\+") - CHANNEL=$(echo $CPSIc | cut -d, -f8) - RSCP=$(($(echo $CPSIc | cut -d, -f9) / 10)) - ECIO=$(($(echo $CPSIc | cut -d, -f10) / 10)) - if [ "$CSQ_PER" = "-" ]; then - CSQ_PER=$((100 - (($RSCP + 31) * 100/-125)))"%" - fi - SINR=$(($(echo $CPSIc | cut -d, -f11) / 10))" dB" - fi - CPSIb="" -fi - -CAINFO=$(echo "$OX" | grep -o "$REGXz" | tr ' ' ':') -if [ -n "$CAINFO" ]; then - for CASV in $(echo "$CAINFO"); do - LBAND=$LBAND"
                                                                      B"$(echo "$CASV" | cut -d, -f4) - BW=$(echo "$CASV" | cut -d, -f5) - decode_bw - LBAND=$LBAND" (CA, Bandwidth $BW MHz)" - CHANNEL="$CHANNEL, "$(echo "$CASV" | cut -d, -f2) - PCI="$PCI, "$(echo "$CASV" | cut -d, -f7) - done -fi - -CNMP=$(echo "$OX" | grep -o "+CNMP:[ ]*[0-9]\{1,3\}" | grep -o "[0-9]\{1,3\}") -TEMP=$(echo "$OX" | grep -o "+CPMUTEMP:[ ]*[-0-9]\+" | grep -o "[-0-9]\{1,4\}") - -if [ -n "$CNMP" ]; then - case $CNMP in - "2"|"55" ) - NETMODE="1" ;; - "13" ) - NETMODE="3" ;; - "14" ) - NETMODE="5" ;; - "38" ) - NETMODE="7" ;; - "71" ) - NETMODE="9" ;; - "109" ) - NETMODE="8" ;; - * ) - NETMODE="0" ;; - esac -fi -if [ -n "$TEMP" ]; then - TEMP=$(echo $TEMP)$(printf "\xc2\xb0")"C" -fi -MODTYPE="10" - -{ - echo 'CSQ="'"$CSQ"'"' - echo 'CSQ_PER="'"$CSQ_PER"'"' - echo 'CSQ_RSSI="'"$CSQ_RSSI"'"' - echo 'ECIO="'"$ECIO"'"' - echo 'RSCP="'"$RSCP"'"' - echo 'ECIO1="'"$ECIO1"'"' - echo 'RSCP1="'"$RSCP1"'"' - echo 'MODE="'"$MODE"'"' - echo 'MODTYPE="'"$MODTYPE"'"' - echo 'NETMODE="'"$NETMODE"'"' - echo 'CHANNEL="'"$CHANNEL"'"' - echo 'LBAND="'"$LBAND"'"' - echo 'PCI="'"$PCI"'"' - echo 'TEMP="'"$TEMP"'"' - echo 'SINR="'"$SINR"'"' -} > /tmp/signal$CURRMODEM.file diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/common/t77data.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/common/t77data.sh deleted file mode 100644 index 5c7ad2e..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/common/t77data.sh +++ /dev/null @@ -1,236 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -log() { - logger -t "T77 Data" "$@" -} - -CURRMODEM=$1 -COMMPORT=$2 - -OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "t77info.gcom" "$CURRMODEM") - -OX=$(echo $OX | tr 'a-z' 'A-Z') -O=$($ROOTER/common/processat.sh "$OX") -O=$(echo $O) - -REGXca="BAND:[0-9]\{1,3\} BW:[0-9.]\+MHZ EARFCN:[0-9]\+ PCI:[0-9]\+ RSRP:[^R]\+RSRQ:[^R]\+RSSI:[^S]\+SNR[^D]\+" -REGXrxd="RX_DIVERSITY:[^(]\+([^)]\+" - -RSRP="" -RSRQ="" -CHANNEL="-" -ECIO="-" -RSCP="-" -ECIO1=" " -RSCP1=" " -MODE="-" -MODTYPE="-" -NETMODE="-" -LBAND="-" -PCI="-" -SINR="-" - -CSQ=$(echo $OX | grep -o "+CSQ: [0-9]\{1,2\}" | grep -o "[0-9]\{1,2\}") -if [ "$CSQ" = "99" ]; then - CSQ="" -fi -if [ -n "$CSQ" ]; then - CSQ_PER=$(($CSQ * 100/31))"%" - CSQ_RSSI=$((2 * CSQ - 113))" dBm" -else - CSQ="-" - CSQ_PER="-" - CSQ_RSSI="-" -fi - -TEMP=$(echo $OX | grep -o "TSENS_TZ_SENSOR[0-9]:[0-9]\{1,3\}") -if [ -n "$TEMP" ]; then - TEMP=${TEMP:17:3} -fi -if [ -z "$TEMP" ]; then - TEMP=$(echo $OX | grep -o "XO_THERM_BUF:[0-9]\{1,3\}") - if [ -n "$TEMP" ]; then - TEMP=${TEMP:13:3} - fi -fi -if [ -z "$TEMP" ]; then - TEMP=$(echo $OX | grep -o "TSENS: [0-9]\{1,3\}C") -fi -if [ -n "$TEMP" ]; then - TEMP=$(echo $TEMP | grep -o "[0-9]\{1,3\}")$(printf "\xc2\xb0")"C" -else - TEMP="-" -fi -TECH=$(echo $O" " | grep -o "+COPS: .,.,[^,]\+,[027]") -TECH="${TECH: -1}" - -if [ -n "$TECH" ]; then - RSSI=$(echo $O | grep -o " RSSI: [^D]\+D" | grep -o "[-0-9\.]\+") - if [ -n "$RSSI" ]; then - CSQ_RSSI=$(echo $RSSI)" dBm" - fi - case $TECH in - "7") - MODE="LTE" - ECIO=$(echo $O | grep -o " RSRQ: [^D]\+D" | grep -o "[-0-9\.]\+") - SINR=$(echo $OX | grep -o "RS-S[I]*NR: [^D]\+D") - SINR=${SINR:8} - SINR=$(echo "$SINR" | grep -o "[-0-9.]\{1,3\}")" dB" - LBAND="B"$(echo $O | grep -o " BAND: [0-9]\+" | grep -o "[0-9]\+") - DEBUGv1=$(echo $O | grep -o "EARFCN(DL/UL):") - DEBUGv2=$(echo $O | grep -o "LTE ENGINEERING") - if [ -n "$DEBUGv1" ]; then - RSCP=$(echo $O | grep -o "[^G] RSRP: [^D]\+D" | grep -o "[-0-9\.]\+") - RSRPlist=$(echo $OX | grep -o "$REGXrxd" | grep -o "\-[.0-9]\{4,5\}" | tr "\n" ",") - if [ -n "$RSRPlist" ]; then - RSCP=$(echo $RSRPlist | cut -d, -f1) - MIMO=$(echo $OX | grep -o "$REGXrxd" | cut -d" " -f2) - if [ "$MIMO" == "3" ]; then - RSCP="(2xMIMO) $RSCP" - fi - for IDX in 2 3 4; do - RSCPval=$(echo $RSRPlist | cut -d, -f$IDX) - if [ -n "$RSCPval" -a "$RSCPval" != "-256.0" ]; then - RSCP="$RSCP dBm, $RSCPval" - fi - done - fi - CHANNEL=$(echo $O | grep -o " EARFCN(DL/UL): [0-9]\+" | grep -o "[0-9]\+") - BWD=$(echo $O | grep -o " BW: [0-9\.]\+ MHZ" | grep -o "[0-9\.]\+") - if [ "$BWD" != "1.4" ]; then - BWD=${BWD/.*} - fi - LBAND=$LBAND" (Bandwidth $BWD MHz)" - PCI=$(echo $OX | grep -o " ENB ID(PCI): [^(]\+([0-9]\{1,3\})" | grep -o "([0-9]\+)" | grep -o "[0-9]\+") - fi - if [ -n "$DEBUGv2" ]; then - RSCP=$(echo $O | grep -o "RSRP: [^D]\+D" | grep -o "[-0-9\.]\+") - CHANNEL=$(echo $O | grep -o " DL CHANNEL: [0-9]\+" | grep -o "[0-9]\+") - PCI=$(echo $OX | grep -o " PCI: [0-9]\{1,3\}" | grep -o "[0-9]\+") - fi - SCC=$(echo $OX | grep -o " SCELL[1-9]:") - if [ -n "$SCC" ]; then - SCCn=$(echo $SCC | grep -o [0-9]) - for SCCx in $(echo "$SCCn"); do - SCCv=$(echo $OX | grep -o "SCELL$SCCx: $REGXca" | tr ' ' ',') - if [ -n "$SCCv" ]; then - SLBV=B$(echo $SCCv | cut -d, -f2 | grep -o "[0-9]\{1,3\}") - SBWV=$(echo $SCCv | cut -d, -f3 | grep -o "[0-9][^M]\+") - if [ "$SBWV" != "1.4" ]; then - SBWV=${SBWV%.*} - fi - LBAND=$LBAND"
                                                                      "$SLBV" (CA, Bandwidth "$SBWV" MHz)" - CHANNEL=$CHANNEL", "$(echo $SCCv | cut -d, -f4 | grep -o "[0-9]\+") - PCI=$PCI", "$(echo $SCCv | cut -d, -f5 | grep -o "[0-9]\+") - RSCP=$RSCP" dBm, "$(echo $SCCv | cut -d, -f6 | grep -o "[-0-9.]\+") - ECIO=$ECIO" dB, "$(echo $SCCv | cut -d, -f7 | grep -o "[-0-9.]\+") - CSQ_RSSI=$CSQ_RSSI", "$(echo $SCCv | cut -d, -f8 | grep -o "[-0-9.]\+")" dBm" - SINR=$SINR", "$(echo $SCCv | cut -d, -f9 | grep -o "[-0-9.]\+")" dB" - fi - done - else - SCC=$(echo $O | grep -o " SCC[1-9][^M]\+MHZ") - if [ -n "$SCC" ]; then - printf '%s\n' "$SCC" | while read SCCX; do - SCCX=$(echo $SCCX | tr " " ",") - SLBV=$(echo $SCCX | cut -d, -f5 | grep -o "B[0-9]\{1,3\}") - SBWV=$(echo $SCCX | cut -d, -f9) - if [ "$SBWV" != "1.4" ]; then - SBWV=${SBWV/.*} - fi - LBAND=$LBAND"
                                                                      "$SLBV" (CA, Bandwidth "$SBWV" MHz)" - echo "$LBAND" > /tmp/lbandvar$CURRMODEM - done - if [ -e /tmp/lbandvar$CURRMODEM ]; then - read LBAND < /tmp/lbandvar$CURRMODEM - rm /tmp/lbandvar$CURRMODEM - fi - fi - fi - ;; - "2") - MODE="WCDMA" - DEBUGv1=$(echo $O | grep -o "RAT:WCDMA") - if [ -n "$DEBUGv1" ]; then - RSCP=$(echo $O | grep -o "RSCP:[^)]\+" | grep -o "[-0-9\.]\+DBM," | grep -o "[^DBM,]\+") - ECIO=$(echo $O | grep -o " ECIO:[^D]\+D" | grep -o "[-0-9\.]\+") - ECIO=$(echo $ECIO) - CHANNEL=$(echo $O | grep -o " CHANNEL (DL): [0-9]\+" | grep -o "[0-9]\+") - LBAND="B"$(echo $O | grep -o " BAND: [0-9]\+" | grep -o "[0-9]\+") - BW=$(echo $O | grep -o " BW: [0-9\.]\+ MHZ" | grep -o "[0-9\.]\+") - BW=$(printf "%.0f" $BW ) - LBAND=$LBAND" (Bandwidth $BW MHz)" - PCI=$(echo $OX | grep -o "PSC:.\?[0-9]\{1,3\}" | grep -o "[0-9]\+") - else - QCSQ=$(echo $O | grep -o "\$QCSQ: -[0-9]\{2,3\},[-0-9]\{1,3\},[-0-9]\{1,3\},") - if [ -n "$QCSQ" ]; then - RSCP=$(echo $QCSQ | cut -d, -f1 | grep -o "[-0-9]*") - ECIO=$(echo $QCSQ | cut -d, -f2) - fi - fi - ;; - *) - MODE="GSM" - ;; - esac -fi - -SCFG=$(echo $OX | grep -o "\^SYSCONFIG: [0-9]\{1,2\}" | grep -o "[0-9]\{1,2\}") -if [ -n "$SCFG" ]; then - case $SCFG in - "13" ) - NETMODE="3" ;; - "14" ) - NETMODE="5" ;; - "17" ) - NETMODE="7" ;; - * ) - NETMODE="1" ;; - esac -fi - -MODTYPE="8" - -{ - echo 'CSQ="'"$CSQ"'"' - echo 'CSQ_PER="'"$CSQ_PER"'"' - echo 'CSQ_RSSI="'"$CSQ_RSSI"'"' - echo 'ECIO="'"$ECIO"'"' - echo 'RSCP="'"$RSCP"'"' - echo 'ECIO1="'"$ECIO1"'"' - echo 'RSCP1="'"$RSCP1"'"' - echo 'MODE="'"$MODE"'"' - echo 'MODTYPE="'"$MODTYPE"'"' - echo 'NETMODE="'"$NETMODE"'"' - echo 'CHANNEL="'"$CHANNEL"'"' - echo 'LBAND="'"$LBAND"'"' - echo 'PCI="'"$PCI"'"' - echo 'TEMP="'"$TEMP"'"' - echo 'SINR="'"$SINR"'"' -} > /tmp/signal$CURRMODEM.file - -CONNECT=$(uci get modem.modem$CURRMODEM.connected) -if [ $CONNECT -eq 0 ]; then - exit 0 -fi - -if [ "$CSQ" = "-" ]; then - log "$OX" -fi - -WWANX=$(uci get modem.modem$CURRMODEM.interface) -OPER=$(cat /sys/class/net/$WWANX/operstate 2>/dev/null) -rm -f "/tmp/connstat"$CURRMODEM - -if [ ! $OPER ]; then - exit 0 -fi -if echo $OPER | grep -q "unknown"; then - exit 0 -fi - -if echo $OPER | grep -q "down"; then - echo "1" > "/tmp/connstat"$CURRMODEM -fi diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/common/telitdata.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/common/telitdata.sh deleted file mode 100644 index 8b677f5..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/common/telitdata.sh +++ /dev/null @@ -1,241 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -CURRMODEM=$1 -COMMPORT=$2 - -log() { - logger -t "Telit Data" "$@" -} -decode_bw() { - case $BW in - "0") - BW="1.4" - ;; - "1") - BW="3" - ;; - "2") - BW="5" - ;; - "3") - BW="10" - ;; - "4") - BW="15" - ;; - "5") - BW="20" - ;; - *) - BW="" - ;; - esac -} -decode_band() { - if [ "$SLBV" -lt 134 ]; then - SLBV=$(($SLBV - 119)) - elif [ "$SLBV" -eq 134 ]; then - SLBV="17" - elif [ "$SLBV" -lt 143 ]; then - SLBV=$(($SLBV - 102)) - elif [ "$SLBV" -lt 147 ]; then - SLBV=$(($SLBV - 125)) - elif [ "$SLBV" -lt 149 ]; then - SLBV=$(($SLBV - 123)) - elif [ "$SLBV" -lt 152 ]; then - SLBV=$(($SLBV - 108)) - elif [ "$SLBV" -eq 152 ]; then - SLBV="23" - elif [ "$SLBV" -eq 153 ]; then - SLBV="26" - elif [ "$SLBV" -eq 154 ]; then - SLBV="32" - elif [ "$SLBV" -lt 158 ]; then - SLBV=$(($SLBV - 30)) - elif [ "$SLBV" -lt 161 ]; then - SLBV=$(($SLBV - 130)) - elif [ "$SLBV" -eq 161 ]; then - SLBV="66" - elif [ "$SLBV" -eq 162 ]; then - SLBV="250" - elif [ "$SLBV" -eq 163 ]; then - SLBV="46" - elif [ "$SLBV" -eq 166 ]; then - SLBV="71" - else - SLBV="??" - fi - -} - -idV=$(uci get modem.modem$CURRMODEM.idV) -idP=$(uci get modem.modem$CURRMODEM.idP) - -if [ $idP = 1040 -o $idP = 1041 ]; then - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "telitinfo.gcom" "$CURRMODEM" | tr 'a-z' 'A-Z') -else - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "telitinfoln.gcom" "$CURRMODEM" | tr 'a-z' 'A-Z') -fi - -O=$($ROOTER/common/processat.sh "$OX") -O=$(echo $O) - -RSRP="" -RSRQ="" -CHANNEL="-" -ECIO="-" -RSCP="-" -ECIO1=" " -RSCP1=" " -MODE="-" -MODTYPE="-" -NETMODE="-" -LBAND="-" -TEMP="-" -PCI="-" -SINR="-" - -CSQ=$(echo $O | grep -o "CSQ: [0-9]\+" | grep -o "[0-9]\+") -[ "x$CSQ" = "x" ] && CSQ=-1 - -if [ $CSQ -ge 0 -a $CSQ -le 31 ]; then - CSQ_PER=$(($CSQ * 100/31)) - CSQ_RSSI=$((2 * CSQ - 113)) - CSQX=$CSQ_RSSI - [ $CSQ -eq 0 ] && CSQ_RSSI="<= "$CSQ_RSSI - [ $CSQ -eq 31 ] && CSQ_RSSI=">= "$CSQ_RSSI - CSQ_PER=$CSQ_PER"%" - CSQ_RSSI=$CSQ_RSSI" dBm" -else - CSQ="-" - CSQ_PER="-" - CSQ_RSSI="-" -fi - -TMP=$(echo $O" " | grep -o "#TEMPSENS: .\+ OK " | tr " " ",") -if [ -n "$TMP" ]; then - TEMP=$(echo $TMP | cut -d, -f3)$(printf "\xc2\xb0")"C" -fi - -MODE="-" -WS46=$(echo $O | grep -o "+COPS:.\+AT#RFSTS" | grep -o "+COPS: [0-3],[0-3],\"[^\"].\+\",[027]") -TECH=$(echo $WS46 | cut -d, -f4) -if [ -n "$TECH" ]; then - MODE=$TECH - case $MODE in - "7") - MODE="LTE" - CAINFO=$(echo $OX | grep -o "#CAINFO: 1.\+OK") - SGCELL=$(echo $OX | grep -o "[#^]RFSTS: \"[ 0-9]\{5,7\}\",[0-9]\{1,5\},.\+,\"[0-9]\{15\}\",\"[^\"]*\",[0-3],[0-9]\{1,2\}[,0-9]\{0,4\}") - if [ -n "$SGCELL" ]; then - RSCP=$(echo $SGCELL | cut -d, -f3) - ECIO=$(echo $SGCELL | cut -d, -f5) - RSSI=$(echo $SGCELL | cut -d, -f4) - CSQ_RSSI=$(echo "$RSSI dBm") - CHANNEL=$(echo $SGCELL | cut -d, -f2) - if [ $(echo ${SGCELL:0:1}) = "#" ]; then - LBAND="B"$(echo $SGCELL | cut -d, -f16 | grep -o "[0-9]\{1,2\}") - else - LBAND="B"$(echo $SGCELL | cut -d, -f15) - SSINR=$(echo $SGCELL | cut -d, -f16) - if [ -n "$SSINR" ]; then - SINR=$((($(echo $SSINR) / 5) - 20))" dB" - fi - fi - BW=$(echo $CAINFO | cut -d, -f3) - decode_bw - if [ -n "$BW" ];then - LBAND=$LBAND" (Bandwidth $BW MHz)" - fi - if [ -n "$CAINFO" ]; then - SCCLIST=$(echo $CAINFO | grep -o "1[2-6][0-9],[0-9]\{1,5\},[0-5],[0-9]\{1,3\},-[0-9]\+,-[0-9]\+,-[0-9]\+,[0-9]\{1,3\},2,[0-5],") - if [ -n "$SCCLIST" ]; then - SSINR=$(echo $CAINFO | grep -o "#CAINFO: [^,]\+,[^,]\+,[^,]\+,[^,]\+,[^,]\+,[^,]\+,[^,]\+,[0-9]\{1,3\},") - SINR=$((($(echo $SSINR | cut -d, -f8) / 5) - 20))" dB" - printf '%s\n' "$SCCLIST" | while read SCCVAL; do - PCI=$(echo $SCCVAL | cut -d, -f4) - SLBV=$(echo $SCCVAL | cut -d, -f1) - decode_band - LBAND=$LBAND"
                                                                      B"$SLBV - BW=$(echo $SCCVAL | cut -d, -f3) - decode_bw - LBAND=$LBAND" (CA, Bandwidth $BW MHz)" - SCHV=$(echo $SCCVAL | cut -d, -f2) - CHANNEL=$(echo "$CHANNEL", "$SCHV") - { - echo "$LBAND" - echo "$CHANNEL" - } > /tmp/lbandvar$CURRMODEM - done - fi - fi - if [ -e /tmp/lbandvar$CURRMODEM ]; then - { - read LBAND - read CHANNEL - } < /tmp/lbandvar$CURRMODEM - rm /tmp/lbandvar$CURRMODEM - fi - fi - ;; - 2) - MODE="UMTS" - SGCELL=$(echo $O | grep -o "[#^]RFSTS: \"[ 0-9]\{5,7\}\",[0-9]\{1,5\},.\+,\"[0-9]\{15\}\",") - if [ -n "$SGCELL" ]; then - RSSI=$(echo $SGCELL | cut -d, -f6) - CSQ_RSSI=$(echo "$RSSI dBm") - RSCP=$(echo $SGCELL | cut -d, -f5) - ECIO=$(echo $SGCELL| cut -d, -f4) - CHANNEL=$(echo $SGCELL | cut -d, -f2) - fi - ;; - esac -fi - -NETMODE="1" -MODTYPE="8" - -{ - echo 'CSQ="'"$CSQ"'"' - echo 'CSQ_PER="'"$CSQ_PER"'"' - echo 'CSQ_RSSI="'"$CSQ_RSSI"'"' - echo 'ECIO="'"$ECIO"'"' - echo 'RSCP="'"$RSCP"'"' - echo 'ECIO1="'"$ECIO1"'"' - echo 'RSCP1="'"$RSCP1"'"' - echo 'MODE="'"$MODE"'"' - echo 'MODTYPE="'"$MODTYPE"'"' - echo 'NETMODE="'"$NETMODE"'"' - echo 'CHANNEL="'"$CHANNEL"'"' - echo 'LBAND="'"$LBAND"'"' - echo 'PCI="'"$PCI"'"' - echo 'TEMP="'"$TEMP"'"' - echo 'SINR="'"$SINR"'"' -} > /tmp/signal$CURRMODEM.file - -CONNECT=$(uci get modem.modem$CURRMODEM.connected) - -if [ $CONNECT -eq 0 ]; then - exit 0 -fi - -if [ "$CSQ" = "-" ]; then - log "$OX" -fi - -WWANX=$(uci get modem.modem$CURRMODEM.interface) -OPER=$(cat /sys/class/net/$WWANX/operstate 2>/dev/null) -rm -f "/tmp/connstat"$CURRMODEM - -if [ ! $OPER ]; then - exit 0 -fi -if echo $OPER | grep -q "unknown"; then - exit 0 -fi - -if echo $OPER | grep -q "down"; then - echo "1" > "/tmp/connstat"$CURRMODEM -fi diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/common/ubloxdata.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/common/ubloxdata.sh deleted file mode 100644 index 6f9a4ec..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/common/ubloxdata.sh +++ /dev/null @@ -1,250 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -log() { - logger -t "ublox Data" "$@" -} - -CURRMODEM=$1 -COMMPORT=$2 - -get_ublox() { - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "ubloxinfo.gcom" "$CURRMODEM" | tr 'a-z' 'A-Z') -} - -get_ublox - -UCGED=$(echo $OX | grep -o "+UCGED: 2") -if [ -z "$UCGED" ]; then - ATCMDD="AT+UCGED=2" - UCGED=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - get_ublox -fi -OX=$(echo $OX) - -RSRP="" -RSRQ="" -CHANNEL="-" -ECIO="-" -RSCP="-" -ECIO1=" " -RSCP1=" " -MODE="-" -MODTYPE="-" -NETMODE="-" -LBAND="-" -TEMP="-" -PCI="-" -SINR="-" - -CSQ=$(echo $OX | grep -o "+CSQ: .\+ +CESQ" | tr " " ",") -CESQ=$(echo $OX | grep -o "+CESQ: .\+ +URAT" | tr " " ",") -URAT=$(echo $OX | grep -o "+URAT: .\+ +UCGED" | tr " " ",") -UCGED=$(echo $OX" " | grep -o "+UCGED: .\+ OK " | tr " " ",") - -CSQ=$(echo $CSQ | cut -d, -f2) -CSQ=$(echo $CSQ | grep -o "[0-9]\{1,2\}") - -if [ "$CSQ" -eq "99" ]; then - CSQ="" -fi -if [ -n "$CSQ" ]; then - CSQ_PER=$(($CSQ * 100/31))"%" - CSQ_RSSI=$((2 * CSQ - 113))" dBm" -else - CSQ="-" - CSQ_PER="-" - CSQ_RSSI="-" -fi - -RAT=$(echo $UCGED | cut -d, -f3) -case "$RAT" in - "2") - MODE="GSM" - LAC=$(echo $UCGED | cut -d, -f11) - LAC=$(echo $LAC | grep -o "[0-9A-F]\{4\}") - CID=$(echo $UCGED | cut -d, -f9) - CID=$(echo $CID | grep -o "[0-9A-F]\{4\}") - ;; - "3") - MODE="UMTS" - CHANNEL=$(echo $UCGED | cut -d, -f7) - LAC=$(echo $UCGED | cut -d, -f10) - LAC=$(echo $LAC | grep -o "[0-9A-F]\{4\}") - CID=$(echo $UCGED | cut -d, -f9) - CID=$(echo $CID | grep -o "[0-9A-F]\{5,8\}") - RSCP=$(echo $CESQ | cut -d, -f4) - RSCP=$(echo $RSCP | grep -o "[0-9]\{1,3\}") - if [ "$RSCP" -eq "255" ]; then - RSCP="" - fi - if [ -n "$RSCP" ]; then - RSCP=$(($RSCP - 121)) - fi - ECIO=$(echo $CESQ | cut -d, -f5) - ECIO=$(echo $ECIO | grep -o "[0-9]\{1,3\}") - if [ "$ECIO" -eq "255" ]; then - ECIO="" - fi - if [ -n "$ECIO" ]; then - ECIO=$((($ECIO / 2) - 24)) - fi - ;; - "4") - MODE="LTE" - LBAND=$(echo $UCGED | cut -d, -f8) - if [ "$LBAND" -eq "255" ]; then - LBAND="" - fi - BWU=$(echo $UCGED | cut -d, -f9) - BWU=$(echo $BWU | grep -o "[0-9]\{1,3\}") - BWD=$(echo $UCGED | cut -d, -f10) - BWD=$(echo $BWD | grep -o "[0-9]\{1,3\}") - if [ -z "$BWD" ]; then - LBAND="" - fi - if [ -z "$BWU" ]; then - LBAND="" - fi - if [ -z "$LBAND" ]; then - LBAND="-" - else - if [ "$BWU" = "6" ]; then - BWU="1.4" - else - BWU=$(($(echo $BWU) / 5)) - fi - if [ "$BWD" = "6" ]; then - BWD="1.4" - else - BWD=$(($(echo $BWD) / 5)) - fi - LBAND="B"$LBAND" (Bandwidth $BWD MHz Down | $BWU MHz Up)" - fi - LAC=$(echo $UCGED | cut -d, -f11) - LAC=$(echo $LAC | grep -o "[0-9A-F]\{4\}") - CID=$(echo $UCGED | cut -d, -f12) - CID=$(echo $CID | grep -o "[0-9A-F]\{5,8\}") - RSRP=$(echo $CESQ | cut -d, -f7) - RSRP=$(echo $RSRP | grep -o "[0-9]\{1,3\}") - if [ "$RSRP" -eq "255" ]; then - RSRP="" - fi - if [ -n "$RSRP" ]; then - RSRP=$(($RSRP - 141)) - RSCP=$RSRP - fi - RSRQ=$(echo $CESQ | cut -d, -f6) - RSRQ=$(echo $RSRQ | grep -o "[0-9]\{1,3\}") - if [ "$RSRQ" -eq "255" ]; then - RSRQ="" - fi - if [ -n "$RSRQ" ]; then - RSRQ=$((($RSRQ / 2) - 19)) - ECIO=$RSRQ - fi - ;; -esac - -if [ $RAT -eq "2" ]; then - if [ -n "$CID" ]; then - CID_NUM=$(printf "%d" 0x$CID) - CID=$CID" ("$CID_NUM")" - fi -else - CID=$(echo $CID | grep -o "[0-9A-F]\{5,8\}") - if [ -n "$CID" ]; then - LCID=$(printf "%08X" 0x$CID) - LCID_NUM=$(printf "%d" 0x$LCID) - if [ "$RAT" -eq "4" ]; then - RNC=$(printf "${LCID:1:5}") - CID=$(printf "${LCID:6:2}") - else - RNC=$(printf "${LCID:1:3}") - CID=$(printf "${LCID:4:4}") - fi - CID_NUM=$(printf "%d" 0x$CID) - CID=$CID" ("$CID_NUM")" - RNC_NUM=" ("$(printf "%d" 0x$RNC)")" - fi -fi - -if [ -n "$LAC" ]; then - LAC_NUM=$(printf "%d" 0x$LAC) - LAC=$LAC" ("$LAC_NUM")" -else - LAC="-" - LAC_NUM="-" -fi - -URAT1=$(echo $URAT | cut -d, -f2) -URAT2=$(echo $URAT | cut -d, -f3) -if [ -n "$URAT1" ]; then - MODTYPE="5" - case $URAT1 in - "0" ) - NETMODE="3" - ;; - "2" ) - NETMODE="5" - ;; - "3" ) - NETMODE="7" - ;; - * ) - case $URAT2 in - "0" ) - NETMODE="2" - ;; - "2" ) - NETMODE="4" - ;; - "3" ) - NETMODE="1" - ;; - esac - ;; - esac -fi - -echo 'CSQ="'"$CSQ"'"' > /tmp/signal$CURRMODEM.file -echo 'CSQ_PER="'"$CSQ_PER"'"' >> /tmp/signal$CURRMODEM.file -echo 'CSQ_RSSI="'"$CSQ_RSSI"'"' >> /tmp/signal$CURRMODEM.file -echo 'ECIO="'"$ECIO"'"' >> /tmp/signal$CURRMODEM.file -echo 'RSCP="'"$RSCP"'"' >> /tmp/signal$CURRMODEM.file -echo 'ECIO1="'"$ECIO1"'"' >> /tmp/signal$CURRMODEM.file -echo 'RSCP1="'"$RSCP1"'"' >> /tmp/signal$CURRMODEM.file -echo 'MODE="'"$MODE"'"' >> /tmp/signal$CURRMODEM.file -echo 'MODTYPE="'"$MODTYPE"'"' >> /tmp/signal$CURRMODEM.file -echo 'NETMODE="'"$NETMODE"'"' >> /tmp/signal$CURRMODEM.file -echo 'CHANNEL="'"$CHANNEL"'"' >> /tmp/signal$CURRMODEM.file -echo 'LBAND="'"$LBAND"'"' >> /tmp/signal$CURRMODEM.file -echo 'LAC="'"$LAC"'"' >> /tmp/signal$CURRMODEM.file -echo 'LAC_NUM="'""'"' >> /tmp/signal$CURRMODEM.file -echo 'CID="'"$CID"'"' >> /tmp/signal$CURRMODEM.file -echo 'CID_NUM="'""'"' >> /tmp/signal$CURRMODEM.file -echo 'RNC="'"$RNC"'"' >> /tmp/signal$CURRMODEM.file -echo 'RNC_NUM="'"$RNC_NUM"'"' >> /tmp/signal$CURRMODEM.file -echo 'TEMP="'"$TEMP"'"' >> /tmp/signal$CURRMODEM.file -echo 'PCI="'"$PCI"'"' >> /tmp/signal$CURRMODEM.file -echo 'SINR="'"$SINR"'"' >> /tmp/signal$CURRMODEM.file - -if [ "$CSQ" = "-" ]; then - log "$OX" -fi - -WWANX=$(uci get modem.modem$CURRMODEM.interface) -OPER=$(cat /sys/class/net/$WWANX/operstate 2>/dev/null) -rm -f "/tmp/connstat"$CURRMODEM - -if [ ! $OPER ]; then - exit 0 -fi -if echo $OPER | grep -q "unknown"; then - exit 0 -fi - -if echo $OPER | grep -q "down"; then - echo "1" > "/tmp/connstat"$CURRMODEM -fi diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/common/ztedata.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/common/ztedata.sh deleted file mode 100644 index 2800901..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/common/ztedata.sh +++ /dev/null @@ -1,193 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -log() { - logger -t "ZTE Data" "$@" -} - -CURRMODEM=$1 -COMMPORT=$2 - -fix_data() { - O=$($ROOTER/common/processat.sh "$OY") -} - -process_csq() { - CSQ=$(echo "$O" | awk -F[,\ ] '/^\+CSQ:/ {print $2}') - [ "x$CSQ" = "x" ] && CSQ=-1 - if [ $CSQ -ge 0 -a $CSQ -le 31 ]; then - CSQ_PER=$(($CSQ * 100/31)) - CSQ_RSSI=$((2 * CSQ - 113)) - CSQX=$CSQ_RSSI - [ $CSQ -eq 0 ] && CSQ_RSSI="<= "$CSQ_RSSI - [ $CSQ -eq 31 ] && CSQ_RSSI=">= "$CSQ_RSSI - CSQ_PER=$CSQ_PER"%" - CSQ_RSSI=$CSQ_RSSI" dBm" - else - CSQ="-" - CSQ_PER="-" - CSQ_RSSI="-" - fi -} - -process_zte() { - ZRSSI=$(echo "$O" | awk -F[,\ ] '/^\+ZRSSI:/ {print $2}') - if [ "x$ZRSSI" != "x" ]; then - TMP_RSSI=$CSQ_RSSI - CSQ_RSSI="-"$ZRSSI" dBm" - ECI=$(echo "$O" | awk -F[,\ ] '/^\+ZRSSI:/ {print $3}') - if [ "x$ECI" != "x" ]; then - ECIO=`expr $ECI / 2` - ECIO="-"$ECIO - RSCP=$(echo "$O" | awk -F[,\ ] '/^\+ZRSSI:/ {print $4}') - if [ "x$RSCP" != "x" ]; then - RSCP=`expr $RSCP / 2` - RSCP="-"$RSCP - else - CSQ_RSSI=$TMP_RSSI - RSCP=$ZRSSI - ECIO=$ECI - fi - else - RSCP=$ZRSSI - CSQ_RSSI=$TMP_RSSI - ECIO=`expr $RSCP - $CSQX` - fi - fi - - MODE="-" - TECH=$(echo "$O" | awk -F[,\ ] '/^\+ZPAS:/ {print $2}' | sed 's/"//g') - if [ "x$TECH" != "x" -a "x$TECH" != "xNo" ]; then - MODE="$TECH" - fi - - ZSNT=$(echo "$O" | awk -F[,\ ] '/^\+ZSNT:/ {print $2}') - if [ "x$ZSNT" != "x" ]; then - MODTYPE="1" - if [ $ZSNT = "0" ]; then - ZSNTX=$(echo "$O" | awk -F[,\ ] '/^\+ZSNT:/ {print $4}') - case $ZSNTX in - "0" ) - NETMODE="1" - ;; - "1" ) - NETMODE="2" - ;; - "2" ) - NETMODE="4" - ;; - "6" ) - NETMODE="6" - ;; - esac - else - case $ZSNT in - "1" ) - NETMODE="3" - ;; - "2" ) - NETMODE="5" - ;; - "6" ) - NETMODE="7" - ;; - esac - fi - fi - - ZCELLINFO=$(echo $O | grep -o "+ZCELLINFO: .\+ OK") - if [ -n "$ZCELLINFO" ]; then - LBAND=$(echo $ZCELLINFO | cut -d, -f3 | grep -o "LTE B[0-9]\{1,2\}") - CHANNEL=$(echo $ZCELLINFO | cut -d, -f4 | grep -o "[0-9]\+") - if [ -n "$LBAND" ]; then - LBAND="B"$(echo $LBAND | grep -o "[0-9]\+") - else - LBAND="-" - CHANNEL="-" - fi - fi - - ZSINR=$(echo $OY | grep -o "+ZSINR: [-0-9]\{1,3\},[0-9],") - if [ -n "$ZSINR" ]; then - ZSINR=${ZSINR:8} - SINR=$(echo $ZSINR | cut -d, -f1)"."$(echo $ZSINR | cut -d, -f2)" dB" - fi - - CMODE=$(uci get modem.modem$CURRMODEM.cmode) - if [ $CMODE = 0 ]; then - NETMODE="10" - fi -} - -CSQ="-" -CSQ_PER="-" -CSQ_RSSI="-" -ECIO="-" -RSCP="-" -ECIO1=" " -RSCP1=" " -MODE="-" -MODETYPE="-" -NETMODE="-" -LBAND="-" -CHANNEL="-" -TEMP="-" -PCI="-" -SINR="-" - -OY=$($ROOTER/gcom/gcom-locked "$COMMPORT" "zteinfo.gcom" "$CURRMODEM") - -fix_data -process_csq -process_zte - -{ - echo 'CSQ="'"$CSQ"'"' > /tmp/signal$CURRMODEM.file - echo 'CSQ_PER="'"$CSQ_PER"'"' - echo 'CSQ_RSSI="'"$CSQ_RSSI"'"' - echo 'ECIO="'"$ECIO"'"' - echo 'RSCP="'"$RSCP"'"' - echo 'ECIO1="'"$ECIO1"'"' - echo 'RSCP1="'"$RSCP1"'"' - echo 'MODE="'"$MODE"'"' - echo 'MODTYPE="'"$MODTYPE"'"' - echo 'NETMODE="'"$NETMODE"'"' - echo 'LBAND="'"$LBAND"'"' - echo 'CHANNEL="'"$CHANNEL"'"' - echo 'TEMP="'"$TEMP"'"' - echo 'PCI="'"$PCI"'"' - echo 'SINR="'"$SINR"'"' -} > /tmp/signal$CURRMODEM.file - -CONNECT=$(uci get modem.modem$CURRMODEM.connected) -if [ $CONNECT -eq 0 ]; then - exit 0 -fi - -if [ $CSQ = "-" ]; then - log "$OY" -fi - -ENB="0" -if [ -e /etc/config/failover ]; then - ENB=$(uci get failover.enabled.enabled) -fi -if [ $ENB = "1" ]; then - exit 0 -fi - -WWANX=$(uci get modem.modem$CURRMODEM.interface) -OPER=$(cat /sys/class/net/$WWANX/operstate 2>/dev/null) -rm -f "/tmp/connstat"$CURRMODEM - -if [ ! $OPER ]; then - exit 0 -fi -if echo $OPER | grep -q "unknown"; then - exit 0 -fi - -if echo $OPER | grep -q "down"; then - echo "1" > "/tmp/connstat"$CURRMODEM -fi diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/connect/bandmask b/rooter/ext-rooter-basic/files/usr/lib/rooter/connect/bandmask deleted file mode 100644 index 8051d05..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/connect/bandmask +++ /dev/null @@ -1,483 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -log() { - modlog "Band Mask $CURRMODEM" "$@" -} - -CURRMODEM=$1 -MODTYPE=$2 - -CPORT=$(uci get modem.modem$CURRMODEM.commport) - -sierrabandmask() { - enb=$(uci -q get custom.bandlock.enabled) - ATCMDD='AT!ENTERCND="A710";!BAND?' - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - if [ $enb == "1" ]; then - log " " - log "Sierra Response : $OX" - log " " - fi - OX=$(echo $OX | tr " " '\x0a') - line=$OX - Unk=$(echo $line | grep "Unknown") - if [ "$Unk" ]; then - BND=$(echo $line | cut -d, -f6 | tr " " ",") - if [ $enb == "1" ]; then - log "Unknw : $BND" - fi - L1=$(echo $BND | cut -d, -f11) - GW=$(echo $BND | cut -d, -f10) - L2=$(echo $BND | cut -d, -f13) - else - all=$(echo $line | grep "L Band Mask 2") - if [ "$all" ]; then - BND=$(echo $line | cut -d, -f4 | tr " " ",") - if [ $enb == "1" ]; then - log "EM7511 : $BND" - fi - OK=8 - EOK=$(echo $BND | cut -d, -f$OK) - while [ $EOK != "OK" ]; do - OK=$(( OK + 1 )) - EOK=$(echo $BND | cut -d, -f$OK) - done - if [ $enb == "1" ]; then - log "$OK" - fi - ex1=$(( OK - 5 )) - ex2=$(( OK - 6 )) - ex3=$(( OK - 3 )) - L1=$(echo $BND | cut -d, -f$ex1) - GW=$(echo $BND | cut -d, -f$ex2) - L2=$(echo $BND | cut -d, -f$ex3) - else - BND=$(echo $line | cut -d, -f5 | tr " " ",") - if [ $enb == "1" ]; then - log "$BND" - fi - L1=$(echo $BND | cut -d, -f3) - GW=$(echo $BND | cut -d, -f2) - L2=$(echo $BND | cut -d, -f5) - fi - fi - if [ ! $L2 ]; then - L2="0000000000000000" - fi - if [ $L2 = "OK" ]; then - L2="0000000000000000" - fi - if [ $enb == "1" ]; then - log " " - log "LTE Band Mask : $L2$L1" - log " " - fi - uci set modem.modem$CURRMODEM.GW="$GW" - uci set modem.modem$CURRMODEM.L1="0x$L2$L1" - uci set modem.modem$CURRMODEM.L1X="$L1" - uci set modem.modem$CURRMODEM.L2="$L2" - uci commit modem - ATCMDD='AT!ENTERCND="AWRONG"' - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") -} - -quebandmask() { - enb=$(uci -q get custom.bandlock.enabled) - idP=$(uci get modem.modem$CURRMODEM.idP) - CPORT=$(uci get modem.modem$CURRMODEM.commport) - ATCMDD="AT+CGMM" - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - model=$(echo "$OX" | tr '\n' ' ' | cut -d' ' -f2) - uci set modem.modem$CURRMODEM.model=$model - ATCMDD='AT+QCFG="band"' - EM160=0 - if [ $enb == "1" ]; then - log " " - log "Modem PID : $idP" - log "Modem Model : $model" - log " " - fi - if [ $idP = "0620" -o $idP = "0800" -o $idP = "030b" -o $idP = "0900" -o $idP = "0801" ]; then - EM20=$(echo $model | grep "EM20") - if [ -z "$EM20" ]; then - EM160=1 - ATCMDD='AT+QNWPREFCFG="lte_band"' - fi - fi - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - if [ $enb == "1" ]; then - log " " - log "Quectel Response : $OX" - log " " - fi - L5="" - L6="" - EMT=0 - - if [ $EM160 = $EMT ]; then - qm=$(echo $OX" " | grep "+QCFG:" | tr -d '"' | tr " " ",") - if [ $enb == "1" ]; then - log "$qm" - log " " - fi - L1=$(echo $qm | cut -d, -f5) - GW=$(echo $qm | cut -d, -f4) - L2="0" - else - qm=$(echo $OX" " | grep "+QNWPREFCFG:" | tr -d '"' | tr " " ":" | tr "," ":") - if [ $enb == "1" ]; then - log "$qm" - log " " - fi - bd=5 - msk="" - L1=$(echo $qm | cut -d: -f"$bd") - while [ $L1 != "OK" ] - do - msk=$msk$L1" " - bd=$((bd+1)) - L1=$(echo $qm | cut -d: -f"$bd") - done - L1=$(encodemask $msk) - if [ -z "$L1" ]; then - L1="0" - fi - L2="0" - GW="0" - EMT=0800 - - if [ $idP = $EMT -o $idP = 0900 -o $idP = "0801" ]; then - ATCMDD='AT+QNWPREFCFG="nsa_nr5g_band"' - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - qm=$(echo $OX" " | grep "+QNWPREFCFG:" | tr -d '"' | tr " " ":" | tr "," ":") - if [ $enb == "1" ]; then - log "EM160/RM500 $qm" - fi - bd=5 - msk="" - L5=$(echo $qm | cut -d: -f"$bd") - - while [ $L5 != "OK" ] - do - msk=$msk$L5" " - bd=$((bd+1)) - L5=$(echo $qm | cut -d: -f"$bd") - done - if [ -z "$msk" -o $msk = "0" ]; then - L5="0" - else - L5=$(encodemask $msk) - fi - - ATCMDD='AT+QNWPREFCFG="nr5g_band"' - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - qm=$(echo $OX" " | grep "+QNWPREFCFG:" | tr -d '"' | tr " " ":" | tr "," ":") - if [ $enb == "1" ]; then - log "EM160/RM500 $qm" - fi - bd=5 - msk="" - L6=$(echo $qm | cut -d: -f"$bd") - - while [ $L6 != "OK" ] - do - msk=$msk$L6" " - bd=$((bd+1)) - L6=$(echo $qm | cut -d: -f"$bd") - done - if [ -z "$msk" -o $msk = "0" ]; then - L6="0" - else - L6=$(encodemask $msk) - fi - $ROOTER/luci/celltype.sh $CURRMODEM - netmode=$(uci -q get modem.modem$CURRMODEM.netmode) - NET="0" - if [ -e /etc/qfake ]; then - if [ $netmode = "7" ]; then - NET=8 - fi - else - if [ $netmode = "8" ]; then - NET=8 - fi - if [ $netmode = "9" ]; then - NET=9 - fi - fi - uci set modem.modem$CURRMODEM.NET="$NET" - if [ $NET = "8" -a $L1 = "0" ]; then - if [ $enb == "1" ]; then - log "NSA no LTE" - fi - fi - fi - fi - if [ $enb == "1" ]; then - log " " - log "LTE Band Mask : $L1" - log "5G NSA Band Mask : $L5" - log "5G NA Band Mask : $L6" - log " " - fi - uci set modem.modem$CURRMODEM.GW="$GW" - uci set modem.modem$CURRMODEM.L1="$L1" - uci set modem.modem$CURRMODEM.L2="$L2" - uci set modem.modem$CURRMODEM.L5="$L5" - uci set modem.modem$CURRMODEM.L6="$L6" - uci commit modem -} - -fibomask() { - enb=$(uci -q get custom.bandlock.enabled) - CPORT=$(uci get modem.modem$CURRMODEM.commport) - msk="" - NRsupport=false - ATCMDD='AT+GTACT=?' - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - OX=$(echo $OX | grep -o "+GTACT:[^)]\+") - if [ -n "$OX" ]; then - RATlist=$(echo $OX | grep -o "[0-9]\{2\}") - for RATval in $(echo "$RATlist"); do - if [ $RATval == "14" -o $RATval == "16" -o $RATval == "17" -o $RATval == "20" ]; then - NRsupport=true - fi - done - ATCMDD='AT+GTACT?' - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - OX=$(echo $OX" " | grep "+GTACT:" | tr -d '"' | tr " " ",") - else - ATCMDD='AT+XACT?' - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - OX=$(echo $OX" " | grep "+XACT:" | tr -d '"' | tr " " ",") - if [ -z "$OX" ]; then - ATCMDD="" - OX="No AT command found to read bands" - fi - fi - LTEbands=$(echo "$OX" | grep -o "1[0-9]\{2\}") - NRbands=$(echo "$OX" | grep -o "50[0-9]\{1,3\}") - for bandval in $(echo "$LTEbands"); do - msk=$msk$((bandval-100))" " - done - if [ -n "$msk" ]; then - L1=$(encodemask $msk) - else - L1="0" - fi - msk="" - for bandval in $(echo "$NRbands"); do - msk=$msk${bandval:2}" " - done - if [ $enb == "1" ]; then - log " " - log "Get Current Bands : $ATCMDD" - log "Current Bands : $OX" - log " " - fi - if [ -z "$msk" ]; then - if $NRsupport; then - L5="0x0" - else - L5="" - fi - else - L5="0x"$(encodemask $msk) - fi - if [ -n "$L1$L5" ]; then - if [ $enb == "1" ]; then - log " " - log "LTE Band Mask : $L1" - log "5G Band Mask : $L5" - log " " - fi - uci set modem.modem$CURRMODEM.L1="0x$L1" - uci set modem.modem$CURRMODEM.L5="$L5" - uci commit modem - fi -} - -t77mask() { - enb=$(uci -q get custom.bandlock.enabled) - ATCMDD='AT^SLBAND?' - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - if [ $enb == "1" ]; then - log " " - log "T77 Response : $OX" - log " " - fi - lte=$(echo $OX" " | tr "," ":" | tr " " ",") - if [ $enb == "1" ]; then - log " " - log "T77 Response : $lte" - log " " - fi - qm=$(echo $lte | cut -d, -f5) - log "$qm" - bd=3 - msk="" - L1=$(echo $qm | cut -d: -f"$bd") - while [ $L1 != "OK" ] - do - msk=$msk$L1" " - bd=$((bd+1)) - L1=$(echo $qm | cut -d: -f"$bd") - done - L1=$(encodemask $msk) - if [ -z "$L1" ]; then - L1="0" - fi - if [ $enb == "1" ]; then - log " " - log "LTE Band Mask : $L1" - log " " - fi - uci set modem.modem$CURRMODEM.L1="0x$L1" - uci commit modem -} - -reversebit() { - LX=$1 - length=${#LX} - jx="${LX:2:length-2}" - length=${#jx} - str="" - i=$((length-1)) - while [ $i -ge 0 ] - do - dgt="0x"${jx:$i:1} - DecNum=`printf "%d" $dgt` - Binary= - Number=$DecNum - while [ $DecNum -ne 0 ] - do - Bit=$(expr $DecNum % 2) - Binary=$Bit$Binary - DecNum=$(expr $DecNum / 2) - done - if [ -z $Binary ]; then - Binary="0000" - fi - len=${#Binary} - while [ $len -lt 4 ] - do - Binary="0"$Binary - len=${#Binary} - done - revstr="" - length=${#Binary} - ii=$((length-1)) - while [ $ii -ge 0 ] - do - revstr=$revstr${Binary:$ii:1} - ii=$((ii-1)) - done - str=$str$revstr - i=$((i-1)) - done - revstr=$str"0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" -} - -reverse() { - REV="" - BNDD=$1 - strlen=${#BNDD} - i=$((strlen-1)) - while [ $i -ge 0 ] - do - REV=$REV${BNDD:$i:1} - i=$((i-1)) - done -} - -telitbandmask() { - enb=$(uci -q get custom.bandlock.enabled) - ATCMDD='AT#BND?' - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - if [ $enb == "1" ]; then - log " " - log "Telit Response : $OX" - log " " - fi - OX=$(echo $OX | tr " " '\x0a') - line=$OX - bnd=$(echo $line | grep "BND: ") - if [ ! -z "$bnd" ]; then - line=$(echo $bnd | tr " " ',') - if [ $enb == "1" ]; then - log "$line" - fi - BND=$(echo $line | cut -d, -f5) - ext=$(echo $line | cut -d, -f6) - reverse $BND - revs=$REV"0000000000000000" - revs=${revs:0:16} - reverse $revs - EXT="" - if [ "$ext" != "OK" -a "$ext" != "0" ]; then - EXT=$ext - fi - revs=$EXT$REV - if [ $enb == "1" ]; then - log " " - log "LTE Band Mask : $revs" - log " " - fi - ATCMDD='AT#BND=?' - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - OX=$(echo $OX | tr " " '\x0a') - OX=$(echo ${OX//),(/!}) - BND=$(echo $OX"!!" | cut -d! -f3) - extt=$(echo $OX"!!" | cut -d! -f4) - if [ ! -z "$extt" ]; then - extt=$(echo $extt | tr "(" ',') - extt=$(echo $extt | tr ")" ',') - extt=$(echo $extt",," | cut -d, -f1) - fi - BND=$(echo $BND | tr "(" ',') - BND=$(echo $BND | tr ")" ',') - BND=$(echo $BND",," | cut -d, -f1) - reverse $BND - revx=$REV"0000000000000000" - revx=${revx:0:16} - reverse $revx - revx=$extt$REV - revx=${revx:0:18} - reversebit "0x"$revx - revstr=${revstr:0:72} - if [ $enb == "1" ]; then - log " " - log "LTE Bit Mask : $revstr" - log " " - fi - - uci set modem.modem$CURRMODEM.GW="0" - uci set modem.modem$CURRMODEM.L1="0x$revs" - uci set modem.modem$CURRMODEM.L1X="$revstr" - uci set modem.modem$CURRMODEM.LEXT="$extt" - uci set modem.modem$CURRMODEM.L2="0" - uci commit modem - fi -} - -case $MODTYPE in - "0" ) - sierrabandmask - ;; - "1" ) - quebandmask - ;; - "2" ) - fibomask - ;; - "3" ) - t77mask - ;; - "4" ) - telitbandmask - ;; -esac - -$ROOTER/luci/mask.sh diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/connect/conmon.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/connect/conmon.sh deleted file mode 100644 index fece3af..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/connect/conmon.sh +++ /dev/null @@ -1,188 +0,0 @@ -#!/bin/sh -. /lib/functions.sh - -ROOTER=/usr/lib/rooter -ROOTER_LINK="/tmp/links" - -log() { - modlog "Connection Monitor $CURRMODEM" "$@" -} - -CURRMODEM=$1 - -power_toggle() { - if [ -f "/tmp/gpiopin" ]; then - source /tmp/gpiopin - echo "$GPIOPIN" > /sys/class/gpio/export - if [ $? -eq 0 ]; then - $ROOTER/pwrtoggle.sh 3 - else - $ROOTER/pwrtoggle.sh $CURRMODEM - fi - else - if [ $ACTIVE = 4 ]; then -# GPIO power-toggle not supported so re-bind USB driver, but only if power toggle is configured in connection monitoring - if [ $(uci -q get modem.pinginfo$CURRMODEM.alive) = 4 ]; then - $ROOTER/pwrtoggle.sh $CURRMODEM - fi -# if [ -L /sys/bus/usb/drivers/usb/usb1 ]; then -# if [ $(uci get modem.pinginfo1.alive) = 4 ]; then -# $ROOTER/pwrtoggle.sh 1 -# fi -# fi -# if [ -L /sys/bus/usb/drivers/usb/usb2 ]; then -# if [ $(uci get modem.pinginfo2.alive) = 4 ]; then -# $ROOTER/pwrtoggle.sh 2 -# fi -# fi - fi - fi -} - -do_down() { - echo 'MONSTAT="'"DOWN$1"'"' > /tmp/monstat$CURRMODEM - case $ACTIVE in - "1" ) - log "Modem $CURRMODEM Connection is Down$1" - ;; - "2" ) - log "Modem $CURRMODEM Connection is Down$1" - reboot -f - ;; - "3" ) - log "Modem $CURRMODEM Connection is Down$1" - PROT=$(uci get modem.modem$CURRMODEM.proto) - if [ $PROT -eq "30" ]; then - CPORT=$(uci get modem.modem$CURRMODEM.commport) - ATCMDD="AT+CFUN=4;+CFUN=1,1" - $ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD" - echo "1" > /tmp/modgone - log "Setting Modem Removal flag" - sleep 60 - else - if [ -f $ROOTER_LINK/reconnect$CURRMODEM ]; then - $ROOTER_LINK/reconnect$CURRMODEM $CURRMODEM & - fi - fi - ;; - "4" ) - log "Modem $CURRMODEM Connection is Down$1" - power_toggle - ;; - esac -} - -CURSOR="-" - -log "Start Connection Monitor for Modem $CURRMODEM" - -sleep 30 - -while [ 1 = 1 ]; do - CP=$(uci -q get ping.ping.enable) - if [ $CP = "1" ]; then - echo 'MONSTAT="'"Custom Ping Test"'"' > /tmp/monstat$CURRMODEM - sleep 60 - else - ACTIVE=$(uci get modem.pinginfo$CURRMODEM.alive) - if [ $ACTIVE = "0" ]; then - echo 'MONSTAT="'"Disabled"'"' > /tmp/monstat$CURRMODEM - sleep 60 - else - track_ips= - IFNAME=$(uci get modem.modem$CURRMODEM.interface) - TIMEOUT=$(uci get modem.pinginfo$CURRMODEM.pingwait) - INTERVAL=$(uci get modem.pinginfo$CURRMODEM.pingtime) - RELIAB=$(uci get modem.pinginfo$CURRMODEM.reliability) - DOWN=$(uci get modem.pinginfo$CURRMODEM.down) - UP=$(uci get modem.pinginfo$CURRMODEM.up) - COUNT=$(uci get modem.pinginfo$CURRMODEM.count) - PACKETSIZE=$(uci get modem.pinginfo$CURRMODEM.packetsize) - INTERF=$(uci get modem.modeminfo$CURRMODEM.inter) - - list_track_ips() { - track_ips="$1 $track_ips" - } - - config_load modem - config_list_foreach "pinginfo$CURRMODEM" "trackip" list_track_ips - - if [ -f "/tmp/connstat$CURRMODEM" ]; then - do_down " from Modem" - rm -f /tmp/connstat$CURRMODEM - sleep 20 - else - ENB="0" - if [ -e /etc/config/failover ]; then - ENB=$(uci get failover.enabled.enabled) - fi - if [ $ENB = "1" ]; then - if [ -e /tmp/mdown$CURRMODEM ]; then - do_down " (using Failover)" - else - echo 'MONSTAT="'"Up ($CURSOR) (using Failover)"'"' > /tmp/monstat$CURRMODEM - fi - sleep 20 - else - # check to see if modem iface has an IP address, if not try a reconnect/power toggle - OX=$(ip address show $IFNAME 2>&1) - ip4=$(echo "$OX" | grep 'inet ' | cut -d' ' -f6) - ip6=$(echo "$OX" | grep 'inet6' | grep global | cut -d' ' -f6) - if [ -z "$ip4" -a -z "$ip6" ]; then - do_down " (no IP address)" - fi - - UPDWN="0" - host_up_count=0 - score_up=$UP - score_dwn=$DOWN - lost=0 - while true; do - if [ ! -z "$track_ips" ]; then - for track_ip in $track_ips; do - ping -I $IFNAME -c $COUNT -W $TIMEOUT -s $PACKETSIZE -q $track_ip &> /dev/null - if [ $? -eq 0 ]; then - let host_up_count++ - else - let lost++ - fi - done - if [ $host_up_count -lt $RELIAB ]; then - let score_dwn-- - score_up=$UP - if [ $score_dwn -eq 0 ]; then - UPDWN="1" - break - fi - else - let score_up-- - score_dwn=$DOWN - if [ $score_up -eq 0 ]; then - UPDWN="0" - break - fi - fi - else - UPDWN="0" - exit - fi - host_up_count=0 - sleep $INTERVAL - done - if [ $UPDWN = "1" ]; then - do_down " (using Ping Test)" - else - echo 'MONSTAT="'"UP ($CURSOR) (using Ping Test)"'"' > /tmp/monstat$CURRMODEM - fi - sleep $INTERVAL - - fi - fi - if [ $CURSOR = "-" ]; then - CURSOR="+" - else - CURSOR="-" - fi - fi - fi -done diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/connect/create_connect.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/connect/create_connect.sh deleted file mode 100644 index 263fab6..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/connect/create_connect.sh +++ /dev/null @@ -1,1367 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter -ROOTER_LINK="/tmp/links" - -log() { - modlog "Create Connection $CURRMODEM" "$@" -} - -ifname1="ifname" -if [ -e /etc/newstyle ]; then - ifname1="device" -fi - -handle_timeout(){ - local wget_pid="$1" - local count=0 - TIMEOUT=70 - res=1 - if [ -d /proc/${wget_pid} ]; then - res=0 - fi - while [ "$res" = 0 -a $count -lt "$((TIMEOUT))" ]; do - sleep 1 - count=$((count+1)) - res=1 - if [ -d /proc/${wget_pid} ]; then - res=0 - fi - done - - if [ "$res" = 0 ]; then - log "Killing process on timeout" - kill "$wget_pid" 2> /dev/null - res=1 - if [ -d /proc/${wget_pid} ]; then - res=0 - fi - if [ "$res" = 0 ]; then - log "Killing process on timeout" - kill -9 $wget_pid 2> /dev/null - fi - fi -} - -set_dns() { - local pDNS1=$(uci -q get modem.modeminfo$CURRMODEM.dns1) - local pDNS2=$(uci -q get modem.modeminfo$CURRMODEM.dns2) - local pDNS3=$(uci -q get modem.modeminfo$CURRMODEM.dns3) - local pDNS4=$(uci -q get modem.modeminfo$CURRMODEM.dns4) - - local aDNS="$pDNS1 $pDNS2 $pDNS3 $pDNS4" - local bDNS="" - - echo "$aDNS" | grep -o "[[:graph:]]" &>/dev/null - if [ $? = 0 ]; then - log "Using DNS settings from the Connection Profile" - pdns=1 - for DNSV in $(echo "$aDNS"); do - if [ "$DNSV" != "0.0.0.0" ] && [ -z "$(echo "$bDNS" | grep -o "$DNSV")" ]; then - [ -n "$(echo "$DNSV" | grep -o ":")" ] && continue - bDNS="$bDNS $DNSV" - fi - done - - bDNS=$(echo $bDNS) - if [ $DHCP = 1 ]; then - uci set network.wan$INTER.peerdns=0 - uci set network.wan$INTER.dns="$bDNS" - fi - echo "$bDNS" > /tmp/v4dns$INTER - - bDNS="" - for DNSV in $(echo "$aDNS"); do - if [ "$DNSV" != "0:0:0:0:0:0:0:0" ] && [ -z "$(echo "$bDNS" | grep -o "$DNSV")" ]; then - [ -z "$(echo "$DNSV" | grep -o ":")" ] && continue - bDNS="$bDNS $DNSV" - fi - done - echo "$bDNS" > /tmp/v6dns$INTER - else - log "Using Provider assigned DNS" - pdns=0 - rm -f /tmp/v[46]dns$INTER - fi -} - -set_dns2() { - local pDNS1=$(uci -q get modem.modeminfo$CURRMODEM.dns1) - local pDNS2=$(uci -q get modem.modeminfo$CURRMODEM.dns2) - local pDNS3=$(uci -q get modem.modeminfo$CURRMODEM.dns3) - local pDNS4=$(uci -q get modem.modeminfo$CURRMODEM.dns4) - - local _DNS1 _DNS2 _DNS3 _DNS4 aDNS bDNS - - echo "$pDNS1 $pDNS2 $pDNS3 $pDNS4" | grep -o "[[:graph:]]" &>/dev/null - if [ $? = 0 ]; then - log "Using DNS settings from the Connection Profile" - pdns=1 - _DNS1=$pDNS1 - _DNS2=$pDNS2 - _DNS3=$pDNS3 - _DNS4=$pDNS4 - else - log "Using Provider assigned DNS" - pdns=0 - _DNS1=$DNS1 - _DNS2=$DNS2 - _DNS3=$DNS3 - _DNS4=$DNS4 - fi - - aDNS="$_DNS1 $_DNS2 $_DNS3 $_DNS4" - - bDNS="" - for DNSV in $(echo "$aDNS"); do - if [ "$DNSV" != "0.0.0.0" ] && [ "$DNSV" != "0:0:0:0:0:0:0:0" ] && [ -z "$(echo "$bDNS" | grep -o "$DNSV")" ]; then - [ -n "$(echo "$DNSV" | grep -o ":")" ] && [ -z "$ip6" ] && continue - bDNS="$bDNS $DNSV" - fi - done - - bDNS=$(echo $bDNS) - uci set network.wan$INTER.dns="$bDNS" -} - -check_apn() { - IPVAR="IP" - local COMMPORT="/dev/ttyUSB"$CPORT - if [ -e /etc/nocops ]; then - echo "0" > /tmp/block - fi - ATCMDD="AT+CGDCONT=?" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - - [ "$PDPT" = "0" ] && PDPT="" - for PDP in "$PDPT" IPV4V6; do - if [[ "$(echo $OX | grep -o "$PDP")" ]]; then - IPVAR="$PDP" - break - fi - done - - uci set modem.modem$CURRMODEM.pdptype=$IPVAR - uci commit modem - - log "PDP Type selected in the Connection Profile: \"$PDPT\", active: \"$IPVAR\"" - - if [ "$idV" = "12d1" ]; then - CFUNOFF="0" - else - CFUNOFF="4" - fi - - ATCMDD="AT+CGDCONT?;+CFUN?" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - CGDCONT2=$(echo $OX | grep "+CGDCONT: 2,") - if [ -z "$CGDCONT2" ]; then - ATCMDD="AT+CGDCONT=2,\"$IPVAR\",\"ims\"" - OXy=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - fi - if `echo $OX | grep "+CGDCONT: $CID,\"$IPVAR\",\"$NAPN\"," 1>/dev/null 2>&1` - then - if [ -z "$(echo $OX | grep -o "+CFUN: 1")" ]; then - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "AT+CFUN=1") - fi - else - ATCMDD="AT+CGDCONT=$CID,\"$IPVAR\",\"$NAPN\"" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "AT+CFUN=$CFUNOFF") - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "AT+CFUN=1") - sleep 5 - fi - if [ -e /etc/nocops ]; then - rm -f /tmp/block - fi -} - -save_variables() { - echo 'MODSTART="'"$MODSTART"'"' > /tmp/variable.file - echo 'WWAN="'"$WWAN"'"' >> /tmp/variable.file - echo 'USBN="'"$USBN"'"' >> /tmp/variable.file - echo 'ETHN="'"$ETHN"'"' >> /tmp/variable.file - echo 'WDMN="'"$WDMN"'"' >> /tmp/variable.file - echo 'BASEPORT="'"$BASEPORT"'"' >> /tmp/variable.file -} - -chcklog() { - OOX=$1 - CLOG=$(uci -q get modem.modeminfo$CURRMODEM.log) - if [ $CLOG = "1" ]; then - log "$OOX" - fi -} - -get_connect() { - NAPN=$(uci -q get modem.modeminfo$CURRMODEM.apn) - NUSER=$(uci -q get modem.modeminfo$CURRMODEM.user) - NPASS=$(uci -q get modem.modeminfo$CURRMODEM.passw) - NAUTH=$(uci -q get modem.modeminfo$CURRMODEM.auth) - spin=$(uci -q get custom.simpin.pin) # SIM Pin - if [ -z "$spin" ]; then - spin=$(uci -q get modem.modeminfo$CURRMODEM.pincode) # Profile Pin - if [ -z "$spin" ]; then - spin=$(uci -q get profile.simpin.pin) # Default profile Pin - fi - fi - PINC=$spin - uci set modem.modeminfo$CURRMODEM.pincode=$PINC - uci commit modem - PDPT=$(uci -q get modem.modeminfo$CURRMODEM.pdptype) -# -# QMI and MBIM can't handle nil -# - case $PROT in - "2"|"3"|"30"|"88" ) - if [ -z "$NUSER" ]; then - NUSER="NIL" - fi - if [ -z "$NPASS" ]; then - NPASS="NIL" - fi - ;; - esac - - uci set modem.modem$CURRMODEM.apn=$NAPN - uci set modem.modem$CURRMODEM.user=$NUSER - uci set modem.modem$CURRMODEM.passw=$NPASS - uci set modem.modem$CURRMODEM.auth=$NAUTH - uci set modem.modem$CURRMODEM.pin=$PINC - uci commit modem -} - -chksierra() { - SIERRAID=0 - if [ $idV = 1199 ]; then - case $idP in - "68aa"|"68a2"|"68a3"|"68a9"|"68b0"|"68b1" ) - SIERRAID=1 - ;; - "68c0"|"9040"|"9041"|"9051"|"9054"|"9056"|"90d3" ) - SIERRAID=1 - ;; - "9070"|"907b"|"9071"|"9079"|"901c"|"9091"|"901f"|"90b1" ) - SIERRAID=1 - ;; - esac - elif [ $idV = 114f -a $idP = 68a2 ]; then - SIERRAID=1 - elif [ $idV = 413c -a $idP = 81a8 ]; then - SIERRAID=1 - elif [ $idV = 413c -a $idP = 81b6 ]; then - SIERRAID=1 - fi -} - -chktelitmbim() { - TELITMBIM=0 - if [ $idV = 1bc7 -a $idP = 0032 ]; then - TELITMBIM=1 - fi -} - -chkT77() { - T77=0 - if [ $idV = 413c -a $idP = 81d7 ]; then - T77=1 - elif [ $idV = 413c -a $idP = 81d8 ]; then - T77=1 - elif [ $idV = 0489 -a $idP = e0b4 ]; then - T77=1 - elif [ $idV = 0489 -a $idP = e0b5 ]; then - T77=1 - elif [ $idV = 1bc7 -a $idP = 1910 ]; then - T77=1 - fi - if [ $T77 = 1 ]; then - [ -n "$TTYDEVS" ] || T77=0 - fi -} - -chkraw() { - RAW=0 - if [ $idV = 03f0 -a $idP = 0857 ]; then - RAW=1 - elif [ $idV = 1bc7 -a $idP = 1900 ]; then - RAW=1 - elif [ $idV = 1bc7 -a $idP = 1910 ]; then - RAW=1 - elif [ $idV = 19d2 -a $idP = 1432 ]; then - RAW=1 - elif [ $idV = 1e0e -a $idP = 9001 ]; then - RAW=1 - elif [ $idV = 2c7c ]; then - RAW=1 - elif [ $idV = 05c6 -a $idP = 9025 ]; then - [ $MAN = "Telit" ] || RAW=1 - elif [ $idV = 05c6 -a $idP = 90db ]; then - RAW=1 - elif [ $idV = 05c6 -a $idP = f601 ]; then - RAW=1 - elif [ $idV = 2cb7 -a $idP = 0104 ]; then - RAW=1 - elif [ $idV = 413c -a $idP = 81d7 ]; then - RAW=1 - elif [ $idV = 413c -a $idP = 81e0 ]; then - RAW=1 - elif [ $idV = 12d1 -a $idP = 1506 ]; then - RAW=1 - fi -} - -chkreg() { - local OX REGV REGST REGCMD - local COMMPORT="/dev/ttyUSB"$CPORT - ATCMDD="AT+CEREG?;+CREG?" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - for REGCMD in +CEREG +CREG; do - REGV=$(echo "$OX" | grep -o "$REGCMD: [0-3],[0-9]") - if [ -n "$REGV" ]; then - REGST=$(echo "$REGV" | cut -d, -f2) - case $REGST in - "0" ) - continue - ;; - "1"|"5"|"6"|"7" ) - REGOK=1 - break - ;; - * ) - REGOK=0 - ;; - esac - fi - done -} - -addv6() { - . /lib/functions.sh - . /lib/netifd/netifd-proto.sh - local interface=wan$INTER - local zone="$(fw3 -q network "$interface" 2>/dev/null)" - - log "Adding IPv6 dynamic interface" - json_init - json_add_string name "${interface}_6" - json_add_string ${ifname1} "@$interface" - json_add_string proto "dhcpv6" - json_add_string extendprefix 1 - [ -n "$zone" ] && json_add_string zone "$zone" - [ "$pdns" = 1 ] && json_add_boolean peerdns 0 - [ "$nat46" = 1 ] || json_add_string iface_464xlat 0 - proto_add_dynamic_defaults - json_close_object - ubus call network add_dynamic "$(json_dump)" -} - -get_tty() { -# $1 is bInterfaceNumber value - local IFNUM OX - IFNUM=$1 - for TTYD in $(echo "$TTYDEVS"); do - if [ ! "$ACM" = 1 ]; then - OX=$(cat /sys/class/tty/$TTYD/../../../bInterfaceNumber | grep "$IFNUM") - else - OX=$(cat /sys/class/tty/$TTYD/../../bInterfaceNumber | grep "$IFNUM") - fi - if [ $? = 0 ]; then - CPORT=$(echo $TTYD | grep -o "[[:digit:]]\+") - break - else - CPORT="" - fi - done -} - -get_tty_fix() { -# $1 is fixed ttyUSB or ttyACM port number - local POS - POS=`expr 1 + $1` - CPORT=$(echo "$TTYDEVS" | cut -d' ' -f"$POS" | grep -o "[[:digit:]]\+") -} - -get_tty_ncm() { - local IFPROT OX - PROTS="12 62 02 2" # PC UI interface bInterfaceProtocol value - for IFPROT in $PROTS; do - for TTYD in $(echo "$TTYDEVS"); do - OX=$(cat /sys/class/tty/$TTYD/../../../bInterfaceProtocol | grep -w "$IFPROT") - if [ $? = 0 ]; then - CPORT=$(echo $TTYD | grep -o "[[:digit:]]\+") - break 2 - else - CPORT="" - fi - done - done -} - -mbimcport() { - lua $ROOTER/common/modemchk.lua "$idV" "$idP" "$CPORT" "$CPORT" - source /tmp/parmpass - uci set modem.modem$CURRMODEM.commport=$CPORT - uci set modem.modem$CURRMODEM.proto="30" - log "MBIM Comm Port : /dev/ttyUSB$CPORT" -} - -CURRMODEM=$1 -RECON=$2 -SIERRAID=0 - -MAN=$(uci -q get modem.modem$CURRMODEM.manuf) -MOD=$(uci -q get modem.modem$CURRMODEM.model) -PROT=$(uci -q get modem.modem$CURRMODEM.proto) -idV=$(uci -q get modem.modem$CURRMODEM.idV) -idP=$(uci -q get modem.modem$CURRMODEM.idP) - -if [ ! -z "$RECON" ]; then - $ROOTER/signal/status.sh $CURRMODEM "$MAN $MOD" "ReConnecting" - uci set modem.modem$CURRMODEM.active=1 - uci set modem.modem$CURRMODEM.connected=0 - uci commit modem - INTER=$(uci -q get modem.modeminfo$CURRMODEM.inter) - jkillall getsignal$CURRMODEM - rm -f $ROOTER_LINK/getsignal$CURRMODEM - jkillall con_monitor$CURRMODEM - rm -f $ROOTER_LINK/con_monitor$CURRMODEM - jkillall mbim_monitor$CURRMODEM - rm -f $ROOTER_LINK/mbim_monitor$CURRMODEM - ifdown wan$INTER - CPORT=$(uci -q get modem.modem$CURRMODEM.commport) - WWANX=$(uci -q get modem.modem$CURRMODEM.wwan) - WDMNX=$(uci -q get modem.modem$CURRMODEM.wdm) - if [ "$RECON" = "1" ]; then - $ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "reset.gcom" "$CURRMODEM" - fi -else - - DELAY=$(uci -q get modem.modem$CURRMODEM.delay) - if [ -z "$DELAY" ]; then - DELAY=5 - fi - -rm -f /tmp/usbwait - -MATCH="$(uci get modem.modem$CURRMODEM.maxcontrol | cut -d/ -f3- | xargs dirname)" - -case $PROT in - # Sierra Direct-IP data interface - - "1" ) - OX="$(for a in /sys/class/net/*; do readlink $a; done | grep "$MATCH")" - ifname=$(basename $OX) - WWANX=$(echo $ifname | grep -o "[[:digit:]]") - log "Modem $CURRMODEM Sierra Direct-IP Device : $ifname" - - uci set modem.modem$CURRMODEM.wwan=$WWANX - uci set modem.modem$CURRMODEM.interface=$ifname - uci commit modem - ;; - - # QMI, NCM and MBIM use cdc-wdm - - "2"|"3"|"30"|"4"|"6"|"7" ) - OX="$(for a in /sys/class/usbmisc/*; do readlink $a; done | grep "$MATCH")" - devname=$(basename $OX) - log "Modem $CURRMODEM WDM Device : $devname" - WDMNX=$(echo $devname | grep -o "[[:digit:]]") - ifname="$(ls /sys/class/usbmisc/$devname/device/net/)" - WWANX=$(echo $ifname | grep -o "[[:digit:]]") - - uci set modem.modem$CURRMODEM.wdm=$WDMNX - uci set modem.modem$CURRMODEM.wwan=$WWANX - uci set modem.modem$CURRMODEM.interface=$ifname - uci commit modem - ;; -esac - -OX=$(for a in /sys/class/tty/*; do readlink $a; done | grep "$MATCH" | tr '\n' ' ' | xargs -r -n1 basename) -TTYDEVS=$(echo "$OX" | grep -o ttyUSB[0-9]) -if [ $? -ne 0 ]; then - TTYDEVS=$(echo "$OX" | grep -o ttyACM[0-9]) - [ $? -eq 0 ] && ACM=1 -fi -TTYDEVS=$(echo "$TTYDEVS" | tr '\n' ' ') -TTYDEVS=$(echo $TTYDEVS) -if [ -n "$TTYDEVS" ]; then - log Modem $CURRMODEM is a parent of $TTYDEVS -else - log "No Comm Ports" -fi - -get_tty_fix 0 -if [ -n "$CPORT" ]; then - uci set modem.modem$CURRMODEM.baseport=$CPORT -else - uci set modem.modem$CURRMODEM.baseport="" -fi -uci commit modem.modem$CURRMODEM - - case $PROT in -# -# Sierra Direct-IP modem comm port -# - "1" ) - log "Start Direct-IP Connection" - get_tty 03 - lua $ROOTER/common/modemchk.lua "$idV" "$idP" "$CPORT" "$CPORT" - source /tmp/parmpass - log "Sierra Comm Port : /dev/ttyUSB$CPORT" - ;; -# -# QMI modem comm port -# - "2"|"88" ) - log "Start QMI (RMNET) Connection" - sleep $DELAY - - chksierra - if [ $SIERRAID -eq 1 ]; then - get_tty 03 - elif [ $idV = 1bc7 ]; then - get_tty 03 - else - if [ $idV = 2c7c ]; then - QUEIF2="0121 0125 0306 0296 0512 0620 0800 030b 0801 0900" - if [[ $(echo "$QUEIF2" | grep -o -i "$idP") ]]; then - TPORT=2 - fi - elif [ $idV = 05c6 -a $idP = 9025 ]; then - [ $MAN = "Telit" ] || TPORT=2 - elif [ $idV = 1e0e -a $idP = 9001 ]; then - TPORT=2 - else - TPORT=1 - fi - get_tty_fix $TPORT - fi - - lua $ROOTER/common/modemchk.lua "$idV" "$idP" "$CPORT" "$CPORT" - source /tmp/parmpass - - log "Modem $CURRMODEM QMI (RMNET) Comm Port : /dev/ttyUSB$CPORT" - chkraw - ;; - "3"|"30" ) - log "Start MBIM Connection" - sleep $DELAY - - chksierra - if [ $SIERRAID -eq 1 ]; then - SIERRAIF2='1199:90b1' - if [[ $(echo $SIERRAIF2 | grep -o -i "$idV:$idP") ]]; then - IFNUM=02 - else - IFNUM=03 - fi - get_tty $IFNUM - if [ -z "$CPORT" ]; then - if [ $idP = "90d3" ]; then - get_tty_fix 0 - lua $ROOTER/common/modemchk.lua "$idV" "$idP" "$CPORT" "$CPORT" - source /tmp/parmpass - uci set modem.modem$CURRMODEM.commport=$CPORT - if [ -n "$CPORT" ]; then - uci set modem.modem$CURRMODEM.proto="30" - fi - log "Modem $CURRMODEM MBIM Comm Port : /dev/ttyUSB$CPORT" - else - uci set modem.modem$CURRMODEM.commport="" - uci set modem.modem$CURRMODEM.proto="3" - log "No MBIM Comm Port" - fi - else - mbimcport - fi - else - chktelitmbim - if [ $TELITMBIM -eq 1 ]; then - get_tty 00 - lua $ROOTER/common/modemchk.lua "$idV" "$idP" "$CPORT" "$CPORT" - source /tmp/parmpass - ACMPORT=$CPORT - CPORT=9$ACMPORT - ln -fs /dev/ttyACM$ACMPORT /dev/ttyUSB$CPORT - uci set modem.modem$CURRMODEM.commport=$CPORT - if [ -n "$CPORT" ]; then - uci set modem.modem$CURRMODEM.proto="30" - fi - log "Modem $CURRMODEM MBIM Comm Port : /dev/ttyUSB$CPORT" - else - chkT77 - if [ $T77 -eq 1 ]; then - get_tty 02 - mbimcport - else - case $idV in - "2c7c"|"05c6" ) - get_tty_fix 2 - mbimcport - ;; - "03f0" ) - get_tty 02 - mbimcport - ;; - "1bc7" ) - if [ "$idP" = "1041" ]; then - get_tty 07 - else - get_tty 02 - fi - mbimcport - ;; - "2cb7" ) - get_tty_fix 0 - lua $ROOTER/common/modemchk.lua "$idV" "$idP" "$CPORT" "$CPORT" - source /tmp/parmpass - ACMPORT=$CPORT - CPORT="8$ACMPORT" - ln -fs /dev/ttyACM$ACMPORT /dev/ttyUSB$CPORT - - uci set modem.modem$CURRMODEM.commport=$CPORT - uci set modem.modem$CURRMODEM.proto="30" - log "Modem $CURRMODEM MBIM Comm Port : /dev/ttyUSB$CPORT" - ;; - * ) - uci set modem.modem$CURRMODEM.commport="" - log "No MBIM Comm Port" - ;; - esac - fi - fi - fi - uci commit modem - ;; -# -# Huawei NCM -# - "4"|"6"|"7"|"24"|"26"|"27" ) - if [ "$idV" = "2c7c" -a "$idP" = "0900" ]; then - ATCMDD='AT+QCFG="usbnet",2' - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB2" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - ATCMDD='AT+CFUN=1,1' - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB2" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - reboot -f - fi - log "Start NCM Connection" - sleep $DELAY - - get_tty_ncm - lua $ROOTER/common/modemchk.lua "$idV" "$idP" "$CPORT" "$CPORT" - source /tmp/parmpass - - log "NCM Comm Port : /dev/ttyUSB$CPORT" - ;; - "28" ) - log "Start Fibocom NCM Connection" - get_tty_fix 2 - lua $ROOTER/common/modemchk.lua "$idV" "$idP" "$CPORT" "$CPORT" - source /tmp/parmpass - ACMPORT=$CPORT - CPORT="8$ACMPORT" - ln -fs /dev/ttyACM$ACMPORT /dev/ttyUSB$CPORT - log "Modem $CURRMODEM Fibocom NCM Comm Port : /dev/ttyUSB$CPORT" - ;; - esac - - uci set modem.modem$CURRMODEM.commport=$CPORT - uci commit modem - -fi -if [ $PROT = "3" ]; then -# May have got changed to 30 above - PROT=$(uci -q get modem.modem$CURRMODEM.proto) -fi -if [ -z "$idV" ]; then - idV=$(uci -q get modem.modem$CURRMODEM.idV) -fi -QUECTEL=false -if [ "$idV" = "2c7c" ]; then - QUECTEL=true -elif [ "$idV" = "05c6" ]; then - QUELST="9090,9003,9215" - if [[ $(echo "$QUELST" | grep -o "$idP") ]]; then - QUECTEL=true - fi -fi - -if [ -e $ROOTER/connect/preconnect.sh ]; then - if [ "$RECON" != "2"|"88" ]; then - $ROOTER/connect/preconnect.sh $CURRMODEM - fi -fi - -if $QUECTEL; then - if [ "$RECON" != "2"|"88" ]; then - ATCMDD="AT+CNMI?" - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - if `echo $OX | grep -o "+CNMI: [0-3],2," >/dev/null 2>&1`; then - ATCMDD="AT+CNMI=0,0,0,0,0" - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - fi - ATCMDD="AT+QINDCFG=\"smsincoming\"" - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - if `echo $OX | grep -o ",1" >/dev/null 2>&1`; then - ATCMDD="AT+QINDCFG=\"smsincoming\",0,1" - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - fi - ATCMDD="AT+QINDCFG=\"all\"" - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - if `echo $OX | grep -o ",1" >/dev/null 2>&1`; then - ATCMDD="AT+QINDCFG=\"all\",0,1" - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - fi - log "Quectel Unsolicited Responses Disabled" - fi - $ROOTER/connect/bandmask $CURRMODEM 1 - clck=$(uci -q get custom.bandlock.cenable$CURRMODEM) - if [ $clck = "1" ]; then - ear=$(uci -q get custom.bandlock.earfcn$CURRMODEM) - pc=$(uci -q get custom.bandlock.pci$CURRMODEM) - ear1=$(uci -q get custom.bandlock.earfcn1$CURRMODEM) - pc1=$(uci -q get custom.bandlock.pci1$CURRMODEM) - ear2=$(uci -q get custom.bandlock.earfcn2$CURRMODEM) - pc2=$(uci -q get custom.bandlock.pci2$CURRMODEM) - ear3=$(uci -q get custom.bandlock.earfcn3$CURRMODEM) - pc3=$(uci -q get custom.bandlock.pci3$CURRMODEM) - cnt=1 - earcnt=$ear","$pc - if [ $ear1 != "0" -a $pc1 != "0" ]; then - earcnt=$earcnt","$ear1","$pc1 - let cnt=cnt+1 - fi - if [ $ear2 != "0" -a $pc2 != "0" ]; then - earcnt=$earcnt","$ear2","$pc2 - let cnt=cnt+1 - fi - if [ $ear3 != "0" -a $pc3 != "0" ]; then - earcnt=$earcnt","$ear3","$pc3 - let cnt=cnt+1 - fi - earcnt=$cnt","$earcnt - ATCMDD="at+qnwlock=\"common/4g\"" - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - log "$OX" - if `echo $OX | grep "ERROR" 1>/dev/null 2>&1` - then - ATCMDD="at+qnwlock=\"common/lte\",2,$ear,$pc" - else - ATCMDD=$ATCMDD","$earcnt - fi - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - log "Cell Lock $OX" - sleep 10 - fi -fi -$ROOTER/luci/celltype.sh $CURRMODEM -if [ $SIERRAID -eq 1 ]; then - $ROOTER/connect/bandmask $CURRMODEM 0 - $ROOTER/luci/celltype.sh $CURRMODEM -fi -if [ $idV = "2dee" ]; then - ATC="AT^MODE=0" - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATC") -fi -if [ $idV = "2cb7" -o $idV = "8087" ]; then - $ROOTER/connect/bandmask $CURRMODEM 2 -fi - -chkT77 -if [ $T77 -eq 1 ]; then - $ROOTER/connect/bandmask $CURRMODEM 3 -fi - -if [ $idV = "1bc7" ]; then - if [ $idP = "1040" -o $idP = "1041" ]; then - $ROOTER/connect/bandmask $CURRMODEM 4 - fi -fi - -CHKPORT=$(uci -q get modem.modem$CURRMODEM.commport) -if [ -n "$CHKPORT" ]; then - $ROOTER/common/gettype.sh $CURRMODEM - $ROOTER/connect/get_profile.sh $CURRMODEM - if [ -e $ROOTER/simlock.sh ]; then - $ROOTER/simlock.sh $CURRMODEM - fi - - if [ -e /tmp/simpin$CURRMODEM ]; then - log " SIM Error" - exit 0 - fi - if [ -e /usr/lib/gps/gps.sh ]; then - /usr/lib/gps/gps.sh $CURRMODEM & - fi - INTER=$(uci -q get modem.modeminfo$CURRMODEM.inter) - [ $INTER = 3 ] && log "Modem $CURRMODEM disabled in Connection Profile" && exit 1 - $ROOTER/sms/check_sms.sh $CURRMODEM & - get_connect - if [ -z "$INTER" ]; then - INTER=$CURRMODEM - else - if [ $INTER = 0 ]; then - INTER=$CURRMODEM - fi - fi - log "Profile for Modem $CURRMODEM sets interface to WAN$INTER" - OTHER=1 - if [ $CURRMODEM = 1 ]; then - OTHER=2 - fi - EMPTY=$(uci -q get modem.modem$OTHER.empty) - if [ $EMPTY = 0 ]; then - OINTER=$(uci -q get modem.modem$OTHER.inter) - if [ ! -z "$OINTER" ]; then - if [ $INTER = $OINTER ]; then - INTER=1 - if [ $OINTER = 1 ]; then - INTER=2 - fi - log "Switched Modem $CURRMODEM to WAN$INTER as Modem $OTHER is using WAN$OINTER" - fi - fi - fi - uci set modem.modem$CURRMODEM.inter=$INTER - uci commit modem - log "Modem $CURRMODEM is using WAN$INTER" - - CID=$(uci -q get modem.modeminfo$CURRMODEM.context) - [ -z "$CID" ] && CID=1 - - DHCP=1 - if [ $PROT = 28 ]; then - DHCP=0 - elif [ $PROT = 2 -a $idV = 05c6 -a $idP = 9025 ]; then - [ $MAN = "Telit" ] || DHCP=0 - fi - NODHCP=$(uci -q get modem.modeminfo$CURRMODEM.nodhcp) - if [ $idV = "2c7c" -a $idP = "0801" ]; then - NODHCP="1" - fi - if [ "$NODHCP" = "1" ]; then - DHCP=0 - log "Using QMI without DHCP" - fi - - if [ $DHCP = 1 ]; then - uci delete network.wan$INTER - uci set network.wan$INTER=interface - uci set network.wan$INTER.proto=dhcp - uci set network.wan$INTER.${ifname1}=$ifname - uci set network.wan$INTER._orig_bridge=false - uci set network.wan$INTER.metric=$INTER"0" - set_dns - uci commit network - else - set_dns - fi - - ttl=$(uci -q get modem.modeminfo$CURRMODEM.ttl) - if [ -z "$ttl" ]; then - ttl="0" - fi - $ROOTER/connect/handlettl.sh $CURRMODEM "$ttl" & - - if [ -e $ROOTER/changedevice.sh ]; then - $ROOTER/changedevice.sh $ifname - fi - - autoapn=$(uci -q get profile.disable.autoapn) - imsi=$(uci -q get modem.modem$CURRMODEM.imsi) - mcc6=${imsi:0:6} - mcc5=${imsi:0:5} - apd=0 - if [ -e /usr/lib/autoapn/apn.data ]; then - apd=1 - fi - if [ "$autoapn" = "1" -a $apd -eq 1 ]; then - isplist=$(grep -F "$mcc6" '/usr/lib/autoapn/apn.data') - if [ -z "$isplist" ]; then - isplist=$(grep -F "$mcc5" '/usr/lib/autoapn/apn.data') - if [ -z "$isplist" ]; then - isplist="000000,$NAPN,Default,$NPASS,$CID,$NUSER,$NAUTH" - fi - fi - else - isplist="000000,$NAPN,Default,$NPASS,$CID,$NUSER,$NAUTH" - fi - - uci set modem.modeminfo$CURRMODEM.isplist="$isplist" - uci commit modem - - if [ $idV = 12d1 ]; then - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "curc.gcom" "$CURRMODEM") - log "Huawei Unsolicited Responses Disabled" - ATCMDD="AT^USSDMODE=0" - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - fi - FORCE=$(uci -q get modem.modeminfo$CURRMODEM.ppp) - if [ -n "$FORCE" ]; then - if [ $FORCE = 1 ]; then - log "Forcing PPP mode" - case $idV in - "12d1" ) - retval=10 - ;; - * ) - retval=11 - ;; - esac - uci set modem.modem$CURRMODEM.proto=$retval - rm -f $ROOTER_LINK/create_proto$CURRMODEM - log "Forced Protcol Value : $retval" - log "Connecting a PPP Modem" - ln -fs $ROOTER/ppp/create_ppp.sh $ROOTER_LINK/create_proto$CURRMODEM - $ROOTER_LINK/create_proto$CURRMODEM $CURRMODEM & - exit 0 - fi - fi -fi - -if $QUECTEL; then - ATCMDD="AT+QINDCFG=\"all\",1" - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") -fi - -modis=$(uci -q get basic.basic.modem) -if [ ! -z $modis ]; then - if [ $modis = "0" ]; then - log "Modem Disabled" - exit 0 - fi -fi - -for isp in $isplist -do - NAPN=$(echo $isp | cut -d, -f2) - NPASS=$(echo $isp | cut -d, -f4) - CID=$(echo $isp | cut -d, -f5) - NUSER=$(echo $isp | cut -d, -f6) - NAUTH=$(echo $isp | cut -d, -f7) - if [ "$NPASS" = "nil" ]; then - NPASS="NIL" - fi - if [ "$NUSER" = "nil" ]; then - NUSER="NIL" - fi - if [ "$NAUTH" = "nil" ]; then - NAUTH="0" - fi - export SETAPN=$NAPN - export SETUSER=$NUSER - export SETPASS=$NPASS - export SETAUTH=$NAUTH - export PINCODE=$PINC - - uci set modem.modem$CURRMODEM.apn=$NAPN - uci set modem.modem$CURRMODEM.user=$NUSER - uci set modem.modem$CURRMODEM.passw=$NPASS - uci set modem.modem$CURRMODEM.auth=$NAUTH - uci set modem.modem$CURRMODEM.pin=$PINC - uci commit modem - - concount=1 - while [ "$concount" -lt 3 ]; do - case $PROT in - "1" ) - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "auto.gcom" "$CURRMODEM") - chcklog "$OX" - M7=$(echo "$OX" | sed -e "s/SCPROF:/SCPROF: /;s! ! !g") - AU=$(echo "$M7" | awk -F[,\ ] '/^\!SCPROF:/ {print $4}') - if [ $AU = "1" ]; then - AUTO="1" - log "Autoconnect is Enabled" - else - AUTO="0" - log "Autoconnect is not Enabled" - fi - ;; - esac - uci set modem.modem$CURRMODEM.auto=$AUTO - uci commit modem - - case $PROT in - # - # Check provider Lock - # - "1"|"2"|"4"|"6"|"7"|"24"|"26"|"27"|"30"|"28"|"88" ) - $ROOTER/common/lockchk.sh $CURRMODEM - ;; - * ) - log "No Provider Lock Done" - ;; - esac - - case $PROT in - # - # Sierra and NCM uses separate Pincode setting - # - "1"|"4"|"6"|"7"|"24"|"26"|"27"|"28" ) - if [ -n "$PINC" ]; then - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "setpin.gcom" "$CURRMODEM") - chcklog "$OX" - ERROR="ERROR" - if `echo $OX | grep "$ERROR" 1>/dev/null 2>&1` - then - log "Modem $CURRMODEM Failed to Unlock SIM Pin" - $ROOTER/signal/status.sh $CURRMODEM "$MAN $MOD" "Failed to Connect : Pin Locked" - exit 0 - fi - fi - ;; - * ) - log "Pincode in script" - ;; - esac - $ROOTER/log/logger "Attempting to Connect Modem #$CURRMODEM" - log "Attempting to Connect Modem $CURRMODEM" - - if [ -e $ROOTER/modem-led.sh ]; then - $ROOTER/modem-led.sh $CURRMODEM 2 - fi - - BRK=0 - case $PROT in - # - # Sierra connect script - # - "1" ) - if [ $AUTO = "0" ]; then - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "connect-directip.gcom" "$CURRMODEM") - chcklog "$OX" - ERROR="ERROR" - if `echo $OX | grep "$ERROR" 1>/dev/null 2>&1` - then - BRK=1 - $ROOTER/signal/status.sh $CURRMODEM "$MAN $MOD" "Failed to Connect : Retrying" - fi - M7=$(echo "$OX" | sed -e "s/SCACT:/SCACT: /;s! ! !g") - SCACT="!SCACT: 1,1" - if `echo ${M7} | grep "$SCACT" 1>/dev/null 2>&1` - then - BRK=0 - ifup wan$INTER - sleep 20 - else - BRK=1 - $ROOTER/signal/status.sh $CURRMODEM "$MAN $MOD" "Failed to Connect : Retrying" - fi - else - ifup wan$INTER - sleep 20 - fi - ;; - # - # QMI connect script - # - "2" ) - check_apn - $ROOTER/qmi/connectqmi.sh $CURRMODEM cdc-wdm$WDMNX $NAUTH $NAPN $NUSER $NPASS $RAW $DHCP $PINC - if [ $? = 0 ]; then - ifup wan$INTER - [ -f /tmp/ipv6supp$INTER ] && addv6 - else - #log "Restart Modem" - #/usr/lib/rooter/luci/restart.sh $CURRMODEM - exit 0 - fi - ;; - # - # NCM connect script - # - "4"|"6"|"7"|"24"|"26"|"27" ) - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "ati") - E5372=$(echo $OX | grep "E5372") - R215=$(echo $OX | grep "R215") - E5787=$(echo $OX | grep "E5787") - check_apn - if [ -n "$E5372" -o -n "$R215" -o -n "$E5787" ]; then - ifup wan$INTER - BRK=0 - else - OX=$($ROOTER/gcom/gcom-locked "/dev/cdc-wdm$WDMNX" "connect-ncm.gcom" "$CURRMODEM") - chcklog "$OX" - ERROR="ERROR" - if `echo $OX | grep "$ERROR" 1>/dev/null 2>&1` - then - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "connect-ncm.gcom" "$CURRMODEM") - chcklog "$OX" - fi - ERROR="ERROR" - if `echo $OX | grep "$ERROR" 1>/dev/null 2>&1` - then - BRK=1 - $ROOTER/signal/status.sh $CURRMODEM "$MAN $MOD" "Failed to Connect : Retrying" - else - ifup wan$INTER - sleep 25 - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "cgpaddr.gcom" "$CURRMODEM") - chcklog "$OX" - OX=$($ROOTER/common/processat.sh "$OX") - STATUS=$(echo "$OX" | awk -F[,\ ] '/^\^SYSINFOEX:/ {print $2}' | sed 's/"//g') - DOMAIN=$(echo "$OX" | awk -F[,\ ] '/^\^SYSINFOEX:/ {print $3}' | sed 's/"//g') - if [ "x$STATUS" = "x" ]; then - STATUS=$(echo "$OX" | awk -F[,\ ] '/^\^SYSINFO:/ {print $2}') - DOMAIN=$(echo "$OX" | awk -F[,\ ] '/^\^SYSINFO:/ {print $3}') - fi - CGPADDR="+CGPADDR:" - if `echo $OX | grep "$CGPADDR" 1>/dev/null 2>&1` - then - if [ $STATUS = "2" ]; then - if [ $DOMAIN = "1" ]; then - BRK=0 - else - if [ $DOMAIN = "2" ]; then - BRK=0 - else - if [ $DOMAIN = "3" ]; then - BRK=0 - else - BRK=1 - $ROOTER/signal/status.sh $CURRMODEM "$MAN $MOD" "Network Error : Retrying" - fi - fi - fi - else - BRK=1 - $ROOTER/signal/status.sh $CURRMODEM "$MAN $MOD" "Network Error : Retrying" - fi - else - BRK=1 - $ROOTER/signal/status.sh $CURRMODEM "$MAN $MOD" "No IP Address : Retrying" - fi - fi - fi - [ $BRK = 0 ] && addv6 - ;; - # - # Fibocom NCM connect - # - "28" ) - OX="$(for a in /sys/class/net/*; do readlink $a; done | grep "$MATCH" | grep ".6/net/")" - ifname=$(basename $OX) - log "Modem $CURRMODEM Fibocom NCM Data Port : $ifname" - COMMPORT="/dev/ttyUSB"$CPORT - ATCMDD="AT+CGACT=0,$CID" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - check_apn - ATCMDD="AT+CGPIAF=1,0,0,0;+XDNS=$CID,1;+XDNS=$CID,2" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - ATCMDD="AT+CGACT=1,$CID" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - ERROR="ERROR" - if [ -e /tmp/simerr$CURRMODEM ]; then - SIMFAIL=1 - log "SIM card error" - else - chkreg - [ "$REGOK" != 1 ] && log "Subscriber registration failed" - fi - if [ "$SIMFAIL" = 1 -o "$REGOK" != 1 ]; then - BRK=1 - $ROOTER/signal/status.sh $CURRMODEM "$MAN $MOD" "Failed to Connect : Retrying" - elif `echo "$OX" | grep -q "$ERROR"`; then - BRK=1 - $ROOTER/signal/status.sh $CURRMODEM "$MAN $MOD" "Failed to Connect : Retrying" - else - ATCMDD="AT+CGCONTRDP=$CID" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - if `echo "$OX" | grep -q "$ERROR"`; then - log "Failed to get IP information for context $CID" - BRK=1 - $ROOTER/signal/status.sh $CURRMODEM "$MAN $MOD" "Failed to get IP information : Retrying" - else - OX=$(echo "${OX//[\" ]/}") - ip=$(echo $OX | cut -d, -f4 | grep -o "[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}") - ip=$(echo $ip | cut -d' ' -f1) - DNS1=$(echo $OX | cut -d, -f6) - DNS2=$(echo $OX | cut -d, -f7) - OX6=$(echo $OX | grep -o "+CGCONTRDP:$CID,[0-9]\+,[^,]\+,[0-9A-F]\{1,4\}:[0-9A-F]\{1,4\}.\+") - ip6=$(echo $OX6 | grep -o "[0-9A-F]\{1,4\}:[0-9A-F]\{1,4\}:[0-9A-F]\{1,4\}:[0-9A-F]\{1,4\}:[0-9A-F]\{1,4\}:[0-9A-F]\{1,4\}:[0-9A-F]\{1,4\}:[0-9A-F]\{1,4\}") - ip6=$(echo $ip6 | cut -d' ' -f1) - DNS3=$(echo "$OX6" | cut -d, -f6) - DNS4=$(echo "$OX6" | cut -d, -f7) - - log "IP address(es): $ip $ip6" - log "DNS servers 1&2: $DNS1 $DNS2" - log "DNS servers 3&4: $DNS3 $DNS4" - - if [[ $(echo "$ip6" | grep -o "^[23]") ]]; then - # Global unicast IP acquired - v6cap=1 - elif [[ $(echo "$ip6" | grep -o "^[0-9a-fA-F]\{1,4\}:") ]]; then - # non-routable address - v6cap=2 - else - v6cap=0 - fi - - if [ -n "$ip6" -a -z "$ip" ]; then - log "Running IPv6-only mode" - nat46=1 - fi - - ATCMDD="AT+XDATACHANNEL=1,1,\"/USBCDC/2\",\"/USBHS/NCM/0\",2,$CID" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - RDNS=$(uci -q get network.wan$INTER.dns) - - log "Applying IP settings to wan$INTER" - uci delete network.wan$INTER - uci set network.wan$INTER=interface - uci set network.wan$INTER.proto=static - uci set network.wan$INTER.${ifname1}=$ifname - uci set network.wan$INTER.metric=$INTER"0" - if [ -n "$ip" ]; then - uci set network.wan$INTER.ipaddr=$ip/32 - uci set network.wan$INTER.gateway='0.0.0.0' - fi - if [ "$v6cap" -gt 0 ]; then - uci set network.wan$INTER.ip6addr=$ip6/128 - fi - - if [ -n "$RDNS" ]; then - uci set network.wan$INTER.dns="$RDNS" - else - set_dns2 - fi - - uci commit network - uci set modem.modem$CURRMODEM.interface=$ifname - uci commit modem - ip link set dev $ifname arp off - ATCMDD="AT+CGDATA=\"M-RAW_IP\",$CID" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "raw-ip.gcom" "$CURRMODEM" "$ATCMDD") - RESP=$(echo $OX | sed "s/AT+CGDATA=\"M-RAW_IP\",$CID //") - log "Final Modem $CURRMODEM result code is \"$RESP\"" - if [ "$RESP" = "OK CONNECT" ]; then - ifup wan$INTER - if [ -e /sys/class/net/$ifname/cdc_ncm/tx_timer_usecs ]; then - echo "0" > /sys/class/net/$ifname/cdc_ncm/tx_timer_usecs - fi - [ $v6cap = 2 ] && addv6 - sleep 2 - BRK=0 - else - BRK=1 - $ROOTER/signal/status.sh $CURRMODEM "$MAN $MOD" "Failed to Connect : Retrying" - fi - fi - fi - ;; - # - # MBIM connect script - # - "3"|"30" ) - if [ -n "$CPORT" ]; then - check_apn - fi - log "Using Netifd Method" - uci delete network.wan$INTER - uci set network.wan$INTER=interface - uci set network.wan$INTER.proto=mbim - uci set network.wan$INTER.device=/dev/cdc-wdm$WDMNX - uci set network.wan$INTER.metric=$INTER"0" - uci set network.wan$INTER.currmodem=$CURRMODEM - uci -q commit network - rm -f /tmp/usbwait - ifup wan$INTER - MIFACE=$(uci -q get modem.modem$CURRMODEM.interface) - if [ -e /sys/class/net/$MIFACE/cdc_ncm/tx_timer_usecs ]; then - echo "0" > /sys/class/net/$MIFACE/cdc_ncm/tx_timer_usecs - fi - exit 0 - ;; - esac - - if [ $BRK = 1 ]; then - ATCMDD="AT+COPS=0" - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - $ROOTER/log/logger "Retry Connection with Modem #$CURRMODEM" - log "Retry Connection" - sleep 10 - concount=$((concount+1)) - else - $ROOTER/log/logger "Modem #$CURRMODEM Connected" - log "Modem $CURRMODEM Connected" - break - fi - done - if [ $BRK = 0 ]; then - break - fi -done - -if [ $BRK = 1 ]; then - exit 0 -fi - -if [ -e $ROOTER/modem-led.sh ]; then - $ROOTER/modem-led.sh $CURRMODEM 3 -fi - -case $PROT in -# -# Sierra, NCM and QMI use modemsignal.sh and reconnect.sh -# - "1"|"2"|"4"|"6"|"7"|"24"|"26"|"27"|"28"|"88" ) - ln -fs $ROOTER/signal/modemsignal.sh $ROOTER_LINK/getsignal$CURRMODEM - ln -fs $ROOTER/connect/reconnect.sh $ROOTER_LINK/reconnect$CURRMODEM - # send custom AT startup command - if [ $(uci -q get modem.modeminfo$CURRMODEM.at) -eq "1" ]; then - ATCMDD=$(uci -q get modem.modeminfo$CURRMODEM.atc) - if [ ! -z "$ATCMDD" ]; then - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - OX=$($ROOTER/common/processat.sh "$OX") - ERROR="ERROR" - if `echo $OX | grep "$ERROR" 1>/dev/null 2>&1` - then - log "Error sending custom AT command: $ATCMDD with result: $OX" - else - log "Sent custom AT command: $ATCMDD with result: $OX" - fi - fi - fi - ;; -esac - - $ROOTER_LINK/getsignal$CURRMODEM $CURRMODEM $PROT & - ln -fs $ROOTER/connect/conmon.sh $ROOTER_LINK/con_monitor$CURRMODEM - $ROOTER_LINK/con_monitor$CURRMODEM $CURRMODEM & - uci set modem.modem$CURRMODEM.connected=1 - uci commit modem - - if [ -e $ROOTER/connect/postconnect.sh ]; then - $ROOTER/connect/postconnect.sh $CURRMODEM - fi - - if [ -e /etc/bandlock ]; then - M1='AT+COPS=?' - export TIMEOUT="120" - #OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$M1") - export TIMEOUT="5" - fi - - if [ -e $ROOTER/timezone.sh ]; then - TZ=$(uci -q get modem.modeminfo$CURRMODEM.tzone) - if [ "$TZ" = "1" ]; then - log "Set TimeZone" - $ROOTER/timezone.sh & - fi - fi - - CLB=$(uci -q get modem.modeminfo$CURRMODEM.lb) - CLB=1 - if [ -e /etc/config/mwan3 ]; then - ENB=$(uci -q get mwan3.wan$INTER.enabled) - if [ ! -z "$ENB" ]; then - if [ $CLB = "1" ]; then - uci set mwan3.wan$INTER.enabled=1 - else - uci set mwan3.wan$INTER.enabled=0 - fi - uci commit mwan3 - /usr/sbin/mwan3 restart - fi - fi - diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/connect/create_hostless.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/connect/create_hostless.sh deleted file mode 100644 index 18d10c3..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/connect/create_hostless.sh +++ /dev/null @@ -1,713 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter -ROOTER_LINK="/tmp/links" - -log() { - modlog "Create Hostless Connection $CURRMODEM" "$@" -} - -ifname1="ifname" -if [ -e /etc/newstyle ]; then - ifname1="device" -fi - -handle_timeout(){ - local wget_pid="$1" - local count=0 - ps | grep -v grep | grep $wget_pid - res="$?" - while [ "$res" = 0 -a $count -lt "$((TIMEOUT))" ]; do - sleep 1 - count=$((count+1)) - ps | grep -v grep | grep $wget_pid - res="$?" - done - - if [ "$res" = 0 ]; then - log "Killing process on timeout" - kill "$wget_pid" 2> /dev/null - ps | grep -v grep | grep $wget_pid - res="$?" - if [ "$res" = 0 ]; then - log "Killing process on timeout" - kill -9 $wget_pid 2> /dev/null - fi - fi -} - -check_apn() { - IPVAR="IP" - local COMMPORT="/dev/ttyUSB"$CPORT - if [ -e /etc/nocops ]; then - echo "0" > /tmp/block - fi - ATCMDD="AT+CGDCONT=?" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - - [ "$PDPT" = "0" ] && PDPT="" - for PDP in "$PDPT" IPV4V6; do - if [[ "$(echo $OX | grep -o "$PDP")" ]]; then - IPVAR="$PDP" - break - fi - done - - uci set modem.modem$CURRMODEM.pdptype=$IPVAR - uci commit modem - - log "PDP Type selected in the Connection Profile: \"$PDPT\", active: \"$IPVAR\"" - - if [ "$idV" = "12d1" ]; then - CFUNOFF="0" - else - CFUNOFF="4" - fi - ATCMDD="AT+CGDCONT?;+CFUN?" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - CGDCONT2=$(echo $OX | grep "+CGDCONT: 2,") - if [ -z "$CGDCONT2" ]; then - ATCMDD="AT+CGDCONT=2,\"$IPVAR\",\"ims\"" - OXy=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - fi - CGDCONT=$(echo $OX | grep -o "$CID,[^,]\+,[^,]\+,[^,]\+,0,0,1") - IPCG=$(echo $CGDCONT | cut -d, -f4) - if [ "$CGDCONT" == "$CID,\"$IPVAR\",\"$NAPN\",$IPCG,0,0,1" ]; then - if [ -z "$(echo $OX | grep -o "+CFUN: 1")" ]; then - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "AT+CFUN=1") - fi - else - ATCMDD="AT+CGDCONT=$CID,\"$IPVAR\",\"$NAPN\",,0,0,1" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "AT+CFUN=$CFUNOFF") - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "AT+CFUN=1") - sleep 5 - fi -} - -set_dns() { - local pDNS1=$(uci -q get modem.modeminfo$CURRMODEM.dns1) - local pDNS2=$(uci -q get modem.modeminfo$CURRMODEM.dns2) - local pDNS3=$(uci -q get modem.modeminfo$CURRMODEM.dns3) - local pDNS4=$(uci -q get modem.modeminfo$CURRMODEM.dns4) - - local aDNS="$pDNS1 $pDNS2 $pDNS3 $pDNS4" - local bDNS="" - - echo "$aDNS" | grep -o "[[:graph:]]" &>/dev/null - if [ $? = 0 ]; then - log "Using DNS settings from the Connection Profile" - pdns=1 - for DNSV in $(echo "$aDNS"); do - if [ "$DNSV" != "0.0.0.0" ] && [ -z "$(echo "$bDNS" | grep -o "$DNSV")" ]; then - [ -n "$(echo "$DNSV" | grep -o ":")" ] && continue - bDNS="$bDNS $DNSV" - fi - done - - bDNS=$(echo $bDNS) - uci set network.wan$INTER.peerdns=0 - uci set network.wan$INTER.dns="$bDNS" - echo "$bDNS" > /tmp/v4dns$INTER - - bDNS="" - for DNSV in $(echo "$aDNS"); do - if [ "$DNSV" != "0:0:0:0:0:0:0:0" ] && [ -z "$(echo "$bDNS" | grep -o "$DNSV")" ]; then - [ -z "$(echo "$DNSV" | grep -o ":")" ] && continue - bDNS="$bDNS $DNSV" - fi - done - echo "$bDNS" > /tmp/v6dns$INTER - else - log "Using Hostless Modem as a DNS relay" - pdns=0 - rm -f /tmp/v[46]dns$INTER - fi -} - -set_network() { - uci delete network.wan$INTER - uci set network.wan$INTER=interface - uci set network.wan$INTER.proto=dhcp - uci set network.wan$INTER.${ifname1}=$1 - uci set network.wan$INTER.metric=$INTER"0" - set_dns - uci commit network - sleep 5 -} - -save_variables() { - echo 'MODSTART="'"$MODSTART"'"' > /tmp/variable.file - echo 'WWAN="'"$WWAN"'"' >> /tmp/variable.file - echo 'USBN="'"$USBN"'"' >> /tmp/variable.file - echo 'ETHN="'"$ETHN"'"' >> /tmp/variable.file - echo 'WDMN="'"$WDMN"'"' >> /tmp/variable.file - echo 'BASEPORT="'"$BASEPORT"'"' >> /tmp/variable.file -} - -chcklog() { - OOX=$1 - CLOG=$(uci -q get modem.modeminfo$CURRMODEM.log) - if [ $CLOG = "1" ]; then - log "$OOX" - fi -} - -get_connect() { - NAPN=$(uci -q get modem.modeminfo$CURRMODEM.apn) - PDPT=$(uci -q get modem.modeminfo$CURRMODEM.pdptype) - uci set modem.modem$CURRMODEM.apn="$NAPN" - uci commit modem -} - -get_tty_fix() { -# $1 is fixed ttyUSB or ttyACM port number - local POS - POS=`expr 1 + $1` - CPORT=$(echo "$TTYDEVS" | cut -d' ' -f"$POS" | grep -o "[[:digit:]]\+") -} - -get_ip() { - ATCMDD="AT+CGPIAF=1,1,1,0;+CGPADDR" - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - OX=$(echo "$OX" | grep "^+CGPADDR: $CID," | cut -d'"' -f2) - ip4=$(echo $OX | cut -d, -f1 | grep "\.") - ip6=$(echo $OX | cut -d, -f2 | grep ":") - log "IP address(es) obtained: $ip4 $ip6" -} - -check_ip() { - if [[ $(echo "$ip6" | grep -o "^[23]") ]]; then - # Global unicast IP acquired - v6cap=1 - elif [[ $(echo "$ip6" | grep -o "^[0-9a-fA-F]\{1,4\}:") ]]; then - # non-routable address - v6cap=2 - else - v6cap=0 - fi - - if [ -n "$ip6" -a -z "$ip4" ]; then - log "Running IPv6-only mode" - nat46=1 - fi -} - -addv6() { - . /lib/functions.sh - . /lib/netifd/netifd-proto.sh - local interface=wan$INTER - local zone="$(fw3 -q network "$interface" 2>/dev/null)" - - log "Adding IPv6 dynamic interface" - json_init - json_add_string name "${interface}_6" - json_add_string ${ifname1} "@$interface" - json_add_string proto "dhcpv6" - json_add_string extendprefix 1 - [ -n "$zone" ] && json_add_string zone "$zone" - [ "$pdns" = 1 ] && json_add_boolean peerdns 0 - [ "$nat46" = 1 ] || json_add_string iface_464xlat 0 - proto_add_dynamic_defaults - json_close_object - ubus call network add_dynamic "$(json_dump)" -} - -CURRMODEM=$1 - -MAN=$(uci -q get modem.modem$CURRMODEM.manuf) -MOD=$(uci -q get modem.modem$CURRMODEM.model) -$ROOTER/signal/status.sh $CURRMODEM "$MAN $MOD" "Connecting" -$ROOTER/log/logger "Attempting to Connect Modem #$CURRMODEM ($MAN $MOD)" - -BASEP=$(uci -q get modem.modem$CURRMODEM.baseport) -idV=$(uci -q get modem.modem$CURRMODEM.idV) -idP=$(uci -q get modem.modem$CURRMODEM.idP) -log " " -log "Hostless ID $idV:$idP" -log " " - -MATCH="$(uci -q get modem.modem$CURRMODEM.maxcontrol | cut -d/ -f3- | xargs dirname)" -OX=$(for a in /sys/class/tty/*; do readlink $a; done | grep "$MATCH" | tr '\n' ' ' | xargs -r -n1 basename) -TTYDEVS=$(echo "$OX" | grep -o ttyUSB[0-9]) -if [ $? -ne 0 ]; then - TTYDEVS=$(echo "$OX" | grep -o ttyACM[0-9]) - [ $? -eq 0 ] && ACM=1 -fi -TTYDEVS=$(echo "$TTYDEVS" | tr '\n' ' ') -TTYDEVS=$(echo $TTYDEVS) -if [ -n "$TTYDEVS" ]; then - log Modem $CURRMODEM is a parent of $TTYDEVS -else - log "No ECM Comm Port" -fi - -if [ $idV = 1546 -a $idP = 1146 ]; then - SP=1 -elif [ $idV = 19d2 -a $idP = 1476 ]; then - SP=2 -elif [ $idV = 1410 -a $idP = 9022 ]; then - SP=3 -elif [ $idV = 1410 -a $idP = 9032 ]; then - SP=3 -elif [ $idV = 2cb7 -o $idV = 1508 ]; then - sleep 5 - log "Fibocom ECM" - SP=4 -elif [ $idV = 2c7c ]; then - SP=5 -elif [ $idV = 12d1 -a $idP = 15c1 ]; then - SP=6 -elif [ $idV = 2cd2 ]; then - log "MikroTik R11e ECM" - SP=7 -elif [ $idV = 0e8d -a $idP = 7127 ]; then - log "RM350 ECM" - SP=8 -elif [ $idV = 0e8d -a $idP = 7126 ]; then - log "RM350 ECM" - SP=9 -else - SP=0 -fi - -log " " -log "Modem Type $SP" -log " " -if [ $SP -gt 0 ]; then - if [ $SP -eq 3 ]; then - PORTN=0 - elif [ $SP -eq 4 ]; then - PORTN=2 - elif [ $SP -eq 5 ]; then - [ $idP = 6026 ] && PORTN=1 || PORTN=2 - elif [ $SP -eq 6 ]; then - PORTN=2 - elif [ $SP -eq 7 ]; then - PORTN=0 - elif [ $SP -eq 8 ]; then - PORTN=3 - elif [ $SP -eq 9 ]; then - PORTN=1 - else - PORTN=1 - fi - get_tty_fix $PORTN - lua $ROOTER/common/modemchk.lua "$idV" "$idP" "$CPORT" "$CPORT" - source /tmp/parmpass - - if [ "$ACM" = 1 ]; then - ACMPORT=$CPORT - CPORT="7$ACMPORT" - ln -fs /dev/ttyACM$ACMPORT /dev/ttyUSB$CPORT - fi - - log "Modem $CURRMODEM ECM Comm Port : /dev/ttyUSB$CPORT" - uci set modem.modem$CURRMODEM.commport=$CPORT - uci commit modem - - $ROOTER/sms/check_sms.sh $CURRMODEM & - - if [ -e $ROOTER/connect/preconnect.sh ]; then - $ROOTER/connect/preconnect.sh $CURRMODEM - fi - - if [ $SP = 5 ]; then - clck=$(uci -q get custom.bandlock.cenable$CURRMODEM) - if [ "$clck" = "1" ]; then - ear=$(uci -q get custom.bandlock.earfcn$CURRMODEM) - pc=$(uci -q get custom.bandlock.pci$CURRMODEM) - ear1=$(uci -q get custom.bandlock.earfcn1$CURRMODEM) - pc1=$(uci -q get custom.bandlock.pci1$CURRMODEM) - ear2=$(uci -q get custom.bandlock.earfcn2$CURRMODEM) - pc2=$(uci -q get custom.bandlock.pci2$CURRMODEM) - ear3=$(uci -q get custom.bandlock.earfcn3$CURRMODEM) - pc3=$(uci -q get custom.bandlock.pci3$CURRMODEM) - cnt=1 - earcnt=$ear","$pc - if [ "$ear1" != "0" -a $pc1 != "0" ]; then - earcnt=$earcnt","$ear1","$pc1 - let cnt=cnt+1 - fi - if [ "$ear2" != "0" -a $pc2 != "0" ]; then - earcnt=$earcnt","$ear2","$pc2 - let cnt=cnt+1 - fi - if [ "$ear3" != "0" -a $pc3 != "0" ]; then - earcnt=$earcnt","$ear3","$pc3 - let cnt=cnt+1 - fi - earcnt=$cnt","$earcnt - ATCMDD="at+qnwlock=\"common/4g\"" - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - log "$OX" - if `echo $OX | grep "ERROR" 1>/dev/null 2>&1` - then - ATCMDD="at+qnwlock=\"common/lte\",2,$ear,$pc" - else - ATCMDD=$ATCMDD","$earcnt - fi - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - log "Cell Lock $OX" - sleep 10 - fi - $ROOTER/connect/bandmask $CURRMODEM 1 - uci commit modem - fi - - - if [ $SP = 4 ]; then - if [ -e /etc/interwave ]; then - idP=$(uci -q get modem.modem$CURRMODEM.idP) - idPP=${idP:1:1} - if [ "$idPP" = "1" ]; then - ATC="AT+GTRAT=17" - else - ATC="AT+XACT=4,2" - fi - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATC") - fi - $ROOTER/connect/bandmask $CURRMODEM 2 - uci commit modem - fi -fi - -if [ -e $ROOTER/modem-led.sh ]; then - $ROOTER/modem-led.sh $CURRMODEM 2 -fi - -$ROOTER/common/gettype.sh $CURRMODEM -$ROOTER/connect/get_profile.sh $CURRMODEM -if [ $SP -gt 0 ]; then - if [ -e $ROOTER/simlock.sh ]; then - $ROOTER/simlock.sh $CURRMODEM - fi - - if [ -e /tmp/simpin$CURRMODEM ]; then - log " SIM Error" - #exit 0 - fi - if [ -e /usr/lib/gps/gps.sh ]; then - /usr/lib/gps/gps.sh $CURRMODEM & - fi -fi - -INTER=$(uci -q get modem.modeminfo$CURRMODEM.inter) -if [ -z "$INTER" ]; then - INTER=$CURRMODEM -else - if [ "$INTER" = 0 ]; then - INTER=$CURRMODEM - fi -fi -log "Profile for Modem $CURRMODEM sets interface to WAN$INTER" -OTHER=1 -if [ $CURRMODEM = 1 ]; then - OTHER=2 -fi -EMPTY=$(uci -q get modem.modem$OTHER.empty) -if [ "$EMPTY" = 0 ]; then - OINTER=$(uci -q get modem.modem$OTHER.inter) - if [ ! -z "$OINTER" ]; then - if [ $INTER = $OINTER ]; then - INTER=1 - if [ "$OINTER" = 1 ]; then - INTER=2 - fi - log "Switched Modem $CURRMODEM to WAN$INTER as Modem $OTHER is using WAN$OINTER" - fi - fi -fi -uci set modem.modem$CURRMODEM.inter=$INTER -uci commit modem -log "Modem $CURRMODEM is using WAN$INTER" - -CID=$(uci -q get modem.modeminfo$CURRMODEM.context) -[ -z "$CID" ] && CID=1 - -log "Checking Network Interface" -ifname="$(if [ "$MATCH" ]; then for a in /sys/class/net/*; do readlink $a; done | grep "$MATCH"; fi | xargs -r basename)" - -if [ "$ifname" ]; then - log "Modem $CURRMODEM ECM Data Port : $ifname" - set_network "$ifname" - uci set modem.modem$CURRMODEM.interface=$ifname - if [ -e $ROOTER/changedevice.sh ]; then - $ROOTER/changedevice.sh $ifname - fi -else - log "Modem $CURRMODEM - No ECM Data Port found" -fi -uci commit modem - -ttl=$(uci -q get modem.modeminfo$CURRMODEM.ttl) -if [ -z "$ttl" ]; then - ttl="0" -fi -hostless=$(uci -q get modem.modeminfo$CURRMODEM.hostless) -if [ "$ttl" != "0" -a "$ttl" != "1" -a "$ttl" != "TTL-INC 1" -a "$hostless" = "1" ]; then - let "ttl=$ttl+1" -fi -$ROOTER/connect/handlettl.sh $CURRMODEM "$ttl" - -if [ $SP -eq 2 ]; then - get_connect - export SETAPN=$NAPN - BRK=1 - - while [ $BRK -eq 1 ]; do - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "connect-zecm.gcom" "$CURRMODEM") - chcklog "$OX" - ERROR="ERROR" - if `echo ${OX} | grep "${ERROR}" 1>/dev/null 2>&1` - then - $ROOTER/signal/status.sh $CURRMODEM "$MAN $MOD" "Failed to Connect : Retrying" - else - BRK=0 - fi - done -fi - -if [ $SP -eq 4 ]; then - get_connect - export SETAPN=$NAPN - BRK=1 - - while [ $BRK -eq 1 ]; do - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "connect-fecm.gcom" "$CURRMODEM") - chcklog "$OX" - log " " - log "Fibocom Connect : $OX" - log " " - ERROR="ERROR" - if `echo ${OX} | grep "${ERROR}" 1>/dev/null 2>&1` - then - $ROOTER/signal/status.sh $CURRMODEM "$MAN $MOD" "Failed to Connect : Retrying" - else - BRK=0 - get_ip - fi - done -fi - -if [ $SP = 8 -o $SP = 9 ]; then - log "FM350 Connection Command" - $ROOTER/connect/bandmask $CURRMODEM 2 - uci commit modem - get_connect - export SETAPN=$NAPN - BRK=1 - - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "connect-fecm.gcom" "$CURRMODEM") - chcklog "$OX" - log " " - log "Fibocom Connect : $OX" - log " " - ERROR="ERROR" - if `echo ${OX} | grep "${ERROR}" 1>/dev/null 2>&1` - then - $ROOTER/signal/status.sh $CURRMODEM "$MAN $MOD" "Failed to Connect : Retrying" - log "Failed to Connect" - else - BRK=0 - get_ip - check_ip - fi -fi - -if [ $SP = 5 ]; then - get_connect - if [ -n "$NAPN" ]; then - $ROOTER/common/lockchk.sh $CURRMODEM - if [ $idP = 6026 ]; then - IPN=1 - case "$PDPT" in - "IPV6" ) - IPN=2 - ;; - "IPV4V6" ) - IPN=3 - ;; - esac - ATCMDD="AT+QICSGP=$CID,$IPN,\"$NAPN\"" - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - ATCMDD="AT+QNETDEVCTL=2,$CID,1" - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - else - check_apn - fi - fi - ATCMDD="AT+CNMI?" - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - if `echo $OX | grep -o "+CNMI: [0-3],2," >/dev/null 2>&1`; then - ATCMDD="AT+CNMI=0,0,0,0,0" - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - fi - ATCMDD="AT+QINDCFG=\"smsincoming\"" - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - if `echo $OX | grep -o ",1" >/dev/null 2>&1`; then - ATCMDD="AT+QINDCFG=\"smsincoming\",0,1" - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - fi - ATCMDD="AT+QINDCFG=\"all\"" - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - if `echo $OX | grep -o ",1" >/dev/null 2>&1`; then - ATCMDD="AT+QINDCFG=\"all\",0,1" - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - fi - log "Quectel Unsolicited Responses Disabled" - $ROOTER/luci/celltype.sh $CURRMODEM - ATCMDD="AT+QINDCFG=\"all\",1" - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - - get_ip - if [ -n "$ip6" ]; then - check_ip - if [ "$v6cap" -gt 0 ]; then - addv6 - fi - fi -fi - -if [ $SP -eq 6 ]; then - get_connect - export SETAPN=$NAPN - BRK=1 - - while [ $BRK -eq 1 ]; do - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "connect-ncm.gcom" "$CURRMODEM") - chcklog "$OX" - ERROR="ERROR" - if `echo ${OX} | grep "${ERROR}" 1>/dev/null 2>&1` - then - $ROOTER/signal/status.sh $CURRMODEM "$MAN $MOD" "Failed to Connect : Retrying" - else - BRK=0 - fi - done -fi - -if [ $SP -eq 7 ]; then - get_connect - export SETAPN=$NAPN - BRK=1 - - if [ -n "$NAPN" ]; then - check_apn - fi - - while [ $BRK -eq 1 ]; do - ATCMDD="AT\$ECMCALL=1" - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - chcklog "$OX" - ERROR="ERROR" - if `echo ${OX} | grep "${ERROR}" 1>/dev/null 2>&1` - then - $ROOTER/signal/status.sh $CURRMODEM "$MAN $MOD" "Failed to Connect : Retrying" - else - BRK=0 - get_ip - if [ -n "$ip6" ]; then - check_ip - if [ "$v6cap" -gt 0 ]; then - addv6 - fi - fi - fi - done -fi - -rm -f /tmp/usbwait - -ifup wan$INTER -while `ifstatus wan$INTER | grep -q '"up": false\|"pending": true'`; do - sleep 1 -done -wan_ip=$(expr "`ifstatus wan$INTER | grep '"nexthop":'`" : '.*"nexthop": "\(.*\)"') -if [ $? -ne 0 ] ; then - wan_ip=192.168.0.1 -fi -uci set modem.modem$CURRMODEM.ip=$wan_ip -uci commit modem - -if [ -e $ROOTER/modem-led.sh ]; then - $ROOTER/modem-led.sh $CURRMODEM 3 -fi - -$ROOTER/log/logger "HostlessModem #$CURRMODEM Connected with IP $wan_ip" - -PROT=5 - -if [ $SP -gt 1 ]; then - ln -s $ROOTER/signal/modemsignal.sh $ROOTER_LINK/getsignal$CURRMODEM - $ROOTER_LINK/getsignal$CURRMODEM $CURRMODEM $PROT & -else - VENDOR=$(uci -q get modem.modem$CURRMODEM.idV) - case $VENDOR in - "19d2" ) - TIMEOUT=3 - wget -O /tmp/connect.file http://$wan_ip/goform/goform_set_cmd_process?goformId=CONNECT_NETWORK & - handle_timeout "$!" - ln -s $ROOTER/signal/ztehostless.sh $ROOTER_LINK/getsignal$CURRMODEM - $ROOTER_LINK/getsignal$CURRMODEM $CURRMODEM $PROT & - ;; - "12d1" ) - log "Huawei Hostless" - ln -s $ROOTER/signal/huaweihostless.sh $ROOTER_LINK/getsignal$CURRMODEM - $ROOTER_LINK/getsignal$CURRMODEM $CURRMODEM $PROT & - ;; - * ) - log "Other Hostless" - ln -s $ROOTER/signal/otherhostless.sh $ROOTER_LINK/getsignal$CURRMODEM - $ROOTER_LINK/getsignal$CURRMODEM $CURRMODEM $PROT & - ;; -esac -fi - -ln -s $ROOTER/connect/conmon.sh $ROOTER_LINK/con_monitor$CURRMODEM -$ROOTER_LINK/con_monitor$CURRMODEM $CURRMODEM & -uci set modem.modem$CURRMODEM.connected=1 -uci commit modem - -if [ $SP -gt 0 ]; then - if [ -e $ROOTER/connect/postconnect.sh ]; then - $ROOTER/connect/postconnect.sh $CURRMODEM - fi - if [ $(uci -q get modem.modeminfo$CURRMODEM.at) -eq "1" ]; then - ATCMDD=$(uci -q get modem.modeminfo$CURRMODEM.atc) - if [ -n "$ATCMDD" ]; then - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - OX=$($ROOTER/common/processat.sh "$OX") - ERROR="ERROR" - if `echo $OX | grep "$ERROR" 1>/dev/null 2>&1` - then - log "Error sending custom AT command: $ATCMDD with result: $OX" - else - log "Sent custom AT command: $ATCMDD with result: $OX" - fi - fi - fi - - if [ -e $ROOTER/timezone.sh ]; then - TZ=$(uci -q get modem.modeminfo$CURRMODEM.tzone) - if [ "$TZ" = "1" ]; then - log "Set TimeZone" - $ROOTER/timezone.sh & - fi - fi -fi - -#CLB=$(uci -q get modem.modeminfo$CURRMODEM.lb) -CLB=1 -if [ -e /etc/config/mwan3 ]; then - ENB=$(uci -q get mwan3.wan$INTER.enabled) - if [ ! -z "$ENB" ]; then - if [ "$CLB" = "1" ]; then - uci set mwan3.wan$INTER.enabled=1 - else - uci set mwan3.wan$INTER.enabled=0 - fi - uci commit mwan3 - /usr/sbin/mwan3 restart - fi -fi diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/connect/create_iphone.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/connect/create_iphone.sh deleted file mode 100644 index c9fda31..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/connect/create_iphone.sh +++ /dev/null @@ -1,223 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter -ROOTER_LINK="/tmp/links" - -log() { - modlog "Create iPhone Connection $CURRMODEM" "$@" -} - - -ifname1="ifname" -if [ -e /etc/newstyle ]; then - ifname1="device" -fi - -handle_timeout(){ - local wget_pid="$1" - local count=0 - ps | grep -v grep | grep $wget_pid - res="$?" - while [ "$res" = 0 -a $count -lt "$((TIMEOUT))" ]; do - sleep 1 - count=$((count+1)) - ps | grep -v grep | grep $wget_pid - res="$?" - done - - if [ "$res" = 0 ]; then - log "Killing process on timeout" - kill "$wget_pid" 2> /dev/null - ps | grep -v grep | grep $wget_pid - res="$?" - if [ "$res" = 0 ]; then - log "Killing process on timeout" - kill -9 $wget_pid 2> /dev/null - fi - fi -} - -set_dns() { - local pDNS1=$(uci -q get modem.modeminfo$CURRMODEM.dns1) - local pDNS2=$(uci -q get modem.modeminfo$CURRMODEM.dns2) - local pDNS3=$(uci -q get modem.modeminfo$CURRMODEM.dns3) - local pDNS4=$(uci -q get modem.modeminfo$CURRMODEM.dns4) - - local aDNS="$pDNS1 $pDNS2 $pDNS3 $pDNS4" - local bDNS="" - - echo "$aDNS" | grep -o "[[:graph:]]" &>/dev/null - if [ $? = 0 ]; then - log "Using DNS settings from the Connection Profile" - pdns=1 - for DNSV in $(echo "$aDNS"); do - if [ "$DNSV" != "0.0.0.0" ] && [ -z "$(echo "$bDNS" | grep -o "$DNSV")" ]; then - [ -n "$(echo "$DNSV" | grep -o ":")" ] && continue - bDNS="$bDNS $DNSV" - fi - done - - bDNS=$(echo $bDNS) - uci set network.wan$INTER.peerdns=0 - uci set network.wan$INTER.dns="$bDNS" - echo "$bDNS" > /tmp/v4dns$INTER - - bDNS="" - for DNSV in $(echo "$aDNS"); do - if [ "$DNSV" != "0:0:0:0:0:0:0:0" ] && [ -z "$(echo "$bDNS" | grep -o "$DNSV")" ]; then - [ -z "$(echo "$DNSV" | grep -o ":")" ] && continue - bDNS="$bDNS $DNSV" - fi - done - echo "$bDNS" > /tmp/v6dns$INTER - else - log "Using Hostless Modem as a DNS" - pdns=0 - rm -f /tmp/v[46]dns$INTER - fi -} - -set_network() { - uci delete network.wan$INTER - uci set network.wan$INTER=interface - uci set network.wan$INTER.proto=dhcp - uci set network.wan$INTER.${ifname1}=$1 - uci set network.wan$INTER.metric=$INTER"0" - set_dns - uci commit network - sleep 5 -} - -save_variables() { - echo 'MODSTART="'"$MODSTART"'"' > /tmp/variable.file - echo 'WWAN="'"$WWAN"'"' >> /tmp/variable.file - echo 'USBN="'"$USBN"'"' >> /tmp/variable.file - echo 'ETHN="'"$ETHN"'"' >> /tmp/variable.file - echo 'WDMN="'"$WDMN"'"' >> /tmp/variable.file - echo 'BASEPORT="'"$BASEPORT"'"' >> /tmp/variable.file -} - -chcklog() { - OOX=$1 - CLOG=$(uci -q get modem.modeminfo$CURRMODEM.log) - if [ $CLOG = "1" ]; then - log "$OOX" - fi -} - - -CURRMODEM=$1 - -MAN=$(uci get modem.modem$CURRMODEM.manuf) -MOD=$(uci get modem.modem$CURRMODEM.model) -$ROOTER/signal/status.sh $CURRMODEM "$MAN $MOD" "Connecting" -$ROOTER/log/logger "Attempting to Connect Modem #$CURRMODEM ($MAN $MOD)" - -BASEP=$(uci -q get modem.modem$CURRMODEM.baseport) -idV=$(uci get modem.modem$CURRMODEM.idV) -idP=$(uci get modem.modem$CURRMODEM.idP) - -$ROOTER/connect/get_profile.sh $CURRMODEM - -INTER=$(uci get modem.modeminfo$CURRMODEM.inter) -if [ -z $INTER ]; then - INTER=$CURRMODEM -else - if [ $INTER = 0 ]; then - INTER=$CURRMODEM - fi -fi -log "Profile for Modem $CURRMODEM sets interface to WAN$INTER" -OTHER=1 -if [ $CURRMODEM = 1 ]; then - OTHER=2 -fi -EMPTY=$(uci get modem.modem$OTHER.empty) -if [ $EMPTY = 0 ]; then - OINTER=$(uci get modem.modem$OTHER.inter) - if [ ! -z $OINTER ]; then - if [ $INTER = $OINTER ]; then - INTER=1 - if [ $OINTER = 1 ]; then - INTER=2 - fi - log "Switched Modem $CURRMODEM to WAN$INTER as Modem $OTHER is using WAN$OINTER" - fi - fi -fi -uci set modem.modem$CURRMODEM.inter=$INTER -uci commit modem -log "Modem $CURRMODEM is using WAN$INTER" - -log "Checking Network Interface" -MATCH="$(uci get modem.modem$CURRMODEM.maxcontrol | cut -d/ -f3- | xargs dirname)" -ifname="$(if [ "$MATCH" ]; then for a in /sys/class/net/*; do readlink $a; done | grep "$MATCH"; fi | xargs -r basename)" - -if [ "$ifname" ]; then - log "Modem $CURRMODEM - iPhone - Data Port : $ifname" - set_network "$ifname" - uci set modem.modem$CURRMODEM.interface=$ifname -else - log "Modem $CURRMODEM - No iPhone Data Port found" -fi -uci commit modem - -rm -f /tmp/usbwait - -ifup wan$INTER -while `ifstatus wan$INTER | grep -q '"up": false\|"pending": true'`; do - sleep 1 -done -wan_ip=$(expr "`ifstatus wan$INTER | grep '"nexthop":'`" : '.*"nexthop": "\(.*\)"') -if [ $? -ne 0 ] ; then - wan_ip=192.168.0.1 -fi -uci set modem.modem$CURRMODEM.ip=$wan_ip -uci commit modem - -log "saving Trusted locks" -for file in `ls /var/lib/lockdown | grep -v SystemConfiguration.plist`; -do - if [ ! -f "/etc/lockdown/locks/$file" ];then - cp /var/lib/lockdown/$file /etc/lockdown/locks/ - else - new_md5=`md5sum /var/lib/lockdown/$file | awk -F" " '{print $1}'` - old_md5=`md5sum /etc/lockdown/locks/$file | awk -F" " '{print $1}'` - if [ "$new_md5" != "$old_md5" ];then - cp /var/lib/lockdown/$file /etc/lockdown/locks/ - fi - fi -done - -$ROOTER/log/logger "iPhone #$CURRMODEM Connected with IP $wan_ip" - -ln -s $ROOTER/signal/otherhostless.sh $ROOTER_LINK/getsignal$CURRMODEM -$ROOTER_LINK/getsignal$CURRMODEM $CURRMODEM $PROT & - -ln -s $ROOTER/connect/conmon.sh $ROOTER_LINK/con_monitor$CURRMODEM -$ROOTER_LINK/con_monitor$CURRMODEM $CURRMODEM & -uci set modem.modem$CURRMODEM.connected=1 -uci commit modem - -if [ -e $ROOTER/timezone.sh ]; then - TZ=$(uci -q get modem.modeminfo$CURRMODEM.tzone) - if [ "$TZ" = "1" ]; then - log "Set TimeZone" - $ROOTER/timezone.sh & - fi -fi - -#CLB=$(uci -q get modem.modeminfo$CURRMODEM.lb) -CLB=1 -if [ -e /etc/config/mwan3 ]; then - ENB=$(uci -q get mwan3.wan$INTER.enabled) - if [ ! -z $ENB ]; then - if [ $CLB = "1" ]; then - uci set mwan3.wan$INTER.enabled=1 - else - uci set mwan3.wan$INTER.enabled=0 - fi - uci commit mwan3 - /usr/sbin/mwan3 restart - fi -fi diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/connect/disablemw3.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/connect/disablemw3.sh deleted file mode 100644 index 9cef8b9..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/connect/disablemw3.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -CURRMODEM=$1 - -if [ -e /etc/config/mwan3 ]; then - INTER=$(uci get modem.modeminfo$CURRMODEM.inter) - ENB=$(uci get mwan3.wan$INTER.enabled) - if [ ! -z $ENB ]; then - uci set mwan3.wan$INTER.enabled=0 - uci commit mwan3 - fi -fi \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/connect/disconnect.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/connect/disconnect.sh deleted file mode 100644 index bde1749..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/connect/disconnect.sh +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter -ROOTER_LINK="/tmp/links" -TIMEOUT=10 - -log() { - modlog "Disconnect Modem $CURRMODEM" "$@" -} - -handle_timeout(){ - local wget_pid="$1" - local count=0 - res=1 - if [ -d /proc/${wget_pid} ]; then - res=0 - fi - while [ "$res" = 0 -a $count -lt "$((TIMEOUT))" ]; do - sleep 1 - count=$((count+1)) - res=1 - if [ -d /proc/${wget_pid} ]; then - res=0 - fi - done - - if [ "$res" = 0 ]; then - log "Killing process on timeout" - kill "$wget_pid" 2> /dev/null - res=1 - if [ -d /proc/${wget_pid} ]; then - res=0 - fi - if [ "$res" = 0 ]; then - log "Killing process on timeout" - kill -9 $wget_pid 2> /dev/null - fi - fi -} - -CURRMODEM=$(uci get modem.general.miscnum) -uci set modem.modem$CURRMODEM.connected=0 -uci commit modem -INTER=$(uci get modem.modeminfo$CURRMODEM.inter) - -jkillall getsignal$CURRMODEM -rm -f $ROOTER_LINK/getsignal$CURRMODEM -jkillall con_monitor$CURRMODEM -rm -f $ROOTER_LINK/con_monitor$CURRMODEM -ifdown wan$INTER - -MAN=$(uci get modem.modem$CURRMODEM.manuf) -MOD=$(uci get modem.modem$CURRMODEM.model) -$ROOTER/signal/status.sh $CURRMODEM "$MAN $MOD" "Disconnected" - -PROT=$(uci get modem.modem$CURRMODEM.proto) -CPORT=$(uci get modem.modem$CURRMODEM.commport) - -case $PROT in -"30" ) - ATCMDD="AT+CFUN=0" - $ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD" - ;; -"3" ) - WDMNX=$(uci get modem.modem$CURRMODEM.wdm) - umbim -n -t 3 -d /dev/cdc-wdm$WDMNX disconnect - ;; -* ) - $ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "reset.gcom" "$CURRMODEM" - ;; -esac - -$ROOTER/log/logger "Modem #$CURRMODEM was Manually Disconnected" diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/connect/get_profile.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/connect/get_profile.sh deleted file mode 100644 index 89c5194..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/connect/get_profile.sh +++ /dev/null @@ -1,423 +0,0 @@ -#!/bin/sh - -. /lib/functions.sh - -ROOTER=/usr/lib/rooter -ROOTER_LINK="/tmp/links" - -log() { - modlog "Get Profile $CURRMODEM" "$@" -} - -CURRMODEM=$1 - -MODEL=$(uci get modem.modem$CURRMODEM.model) -MANUF=$(uci get modem.modem$CURRMODEM.manuf) -idV=$(uci get modem.modem$CURRMODEM.idV) -idP=$(uci get modem.modem$CURRMODEM.idP) -IMEI=$(uci get modem.modem$CURRMODEM.imei) -IMSI=$(uci -q get modem.modem$CURRMODEM.imsi) -ICCID=$(uci get modem.modem$CURRMODEM.iccid) - -log "Modem $CURRMODEM is $MANUF $MODEL" - -rm -f /tmp/profile$CURRMODEM - -if [ "$IMSI" = "Unknown" ]; then - log "Warning: IMSI cannot be read - SIM card missing or locked?" - touch /tmp/simerr$CURRMODEM -else - rm -f /tmp/simerr$CURRMODEM -fi - -MATCH=0 - -do_custom() { - local config=$1 - local select name enabled select1 - local model - local imsi - local vid - local pid - - if [ $MATCH -eq 0 ]; then - config_get select $1 select - config_get name $1 name - config_get enabled $1 enabled - if [ -z "$enabled" ]; then - enabled=1 - fi - if [ -z "$name" ]; then - name="Not Named" - fi - if [ $enabled -eq 1 ]; then - case $select in - "0" ) - config_get vid $1 vid - config_get pid $1 pid - if [ $idV = $vid -a $idP = $pid ]; then - MATCH=1 - log "Modem ID Profile - "$name"" - fi - ;; - "1" ) - config_get imei $1 imei - case $IMEI in - "$imei"*) - MATCH=1 - log "SIM IMEI Profile - "$name"" - ;; - esac - ;; - "2" ) - config_get model $1 model - if [ "$MODEL" == "$model" ]; then - MATCH=1 - log "Modem Model Profile - "$name"" - fi - ;; - "3" ) - config_get imsi $1 imsi - case $IMSI in - "$imsi"*) - MATCH=1 - log "SIM IMSI Profile - "$name"" - ;; - esac - ;; - "4" ) - config_get iccid $1 iccid - case $ICCID in - "$iccid"*) - MATCH=1 - log "SIM ICCID Profile - "$name"" - ;; - esac - ;; - esac - if [ $MATCH = 1 ]; then - config_get select1 $1 select1 - if [ $select1 -ne 10 ]; then - MATCH=0 - case $select1 in - "0" ) - config_get vid1 $1 vid1 - config_get pid1 $1 pid1 - if [ $idV = $vid1 -a $idP = $pid1 ]; then - MATCH=1 - log "Modem ID Profile - "$name"" - fi - ;; - "1" ) - config_get imei1 $1 imei1 - case $IMEI in - "$imei"*) - MATCH=1 - log "SIM IMEI Profile - "$name"" - ;; - esac - ;; - "2" ) - config_get model1 $1 model1 - if [ "$MODEL" == "$model1" ]; then - MATCH=1 - log "Modem Model Profile - "$name"" - fi - ;; - "3" ) - config_get imsi1 $1 imsi1 - case $IMSI in - "$imsi1"*) - MATCH=1 - log "SIM IMSI Profile - "$name"" - ;; - esac - ;; - "4" ) - config_get iccid1 $1 iccid1 - case $ICCID in - "$iccid1"*) - MATCH=1 - log "SIM ICCID Profile - "$name"" - ;; - esac - ;; - esac - fi - if [ $MATCH = 1 ]; then - local apn user passw pincode auth ppp delay lock mcc mnc - local dns1 dns2 dns3 dns4 log lb at atc - config_get apn $1 apn - dapn=$(echo "$apn" | grep "|") - if [ -z $dapn ]; then - apn2="" - else - fapn=$apn"|" - fapn=$(echo $fapn" " | tr "|" ",") - apn=$(echo $fapn | cut -d, -f1) - apn2=$(echo $fapn | cut -d, -f2) - fi - uci set modem.modeminfo$CURRMODEM.apn=$apn - uci set modem.modeminfo$CURRMODEM.apn2=$apn2 - config_get mtu $1 mtu - uci set modem.modeminfo$CURRMODEM.mtu=$mtu - config_get context $1 context - uci set modem.modeminfo$CURRMODEM.context=$context - config_get user $1 user - uci set modem.modeminfo$CURRMODEM.user=$user - config_get passw $1 passw - uci set modem.modeminfo$CURRMODEM.passw=$passw - config_get pincode $1 pincode - uci set modem.modeminfo$CURRMODEM.pincode=$pincode - config_get auth $1 auth - uci set modem.modeminfo$CURRMODEM.auth=$auth - config_get ppp $1 ppp - uci set modem.modeminfo$CURRMODEM.ppp=$ppp - config_get inter $1 inter - uci set modem.modeminfo$CURRMODEM.inter=$inter - config_get delay $1 delay - uci set modem.modeminfo$CURRMODEM.delay=$delay - config_get lock $1 lock - uci set modem.modeminfo$CURRMODEM.lock=$lock - config_get mcc $1 mcc - uci set modem.modeminfo$CURRMODEM.mcc=$mcc - config_get mnc $1 mnc - uci set modem.modeminfo$CURRMODEM.mnc=$mnc - config_get dns1 $1 dns1 - uci set modem.modeminfo$CURRMODEM.dns1=$dns1 - config_get dns2 $1 dns2 - uci set modem.modeminfo$CURRMODEM.dns2=$dns2 - config_get dns3 $1 dns3 - uci set modem.modeminfo$CURRMODEM.dns3=$dns3 - config_get dns4 $1 dns4 - uci set modem.modeminfo$CURRMODEM.dns4=$dns4 - config_get log $1 log - uci set modem.modeminfo$CURRMODEM.log=$log - config_get lb $1 lb - uci set modem.modeminfo$CURRMODEM.lb=$lb - config_get at $1 at - uci set modem.modeminfo$CURRMODEM.at=$at - config_get atc $1 atc - uci set modem.modeminfo$CURRMODEM.atc=$atc - config_get tzone $1 tzone - uci set modem.modeminfo$CURRMODEM.tzone=$tzone - config_get nodhcp $1 nodhcp - uci set modem.modeminfo$CURRMODEM.nodhcp=$nodhcp - config_get pdptype $1 pdptype - if [ $pdptype = "0" ]; then - pdptype="" - fi - uci set modem.modeminfo$CURRMODEM.pdptype=$pdptype - config_get ttl $1 ttl - if [ -z "$ttl" ]; then - ttl="0" - fi - uci set modem.modeminfo$CURRMODEM.ttl="$ttl" - config_get hostless $1 hostless - if [ -z "$hostless" ]; then - hostless="0" - fi - uci set modem.modeminfo$CURRMODEM.hostless="$hostless" - config_get bwday $1 bwday - if [ -z $bwday ]; then - bwday="0" - fi - uci set modem.modeminfo$CURRMODEM.bwday=$bwday - config_get phone $1 phone - if [ -z $phone ]; then - phone="0" - fi - uci set modem.modeminfo$CURRMODEM.bwphone=$phone - config_get bwdelay $1 bwdelay - if [ -z $bwdelay ]; then - bwdelay="0" - fi - uci set modem.modeminfo$CURRMODEM.bwdelay=$bwdelay - - [ -n "$apn" ] || log "This profile has no APN configured !!!" - - config_get alive $1 alive - uci delete modem.pinginfo$CURRMODEM - uci set modem.pinginfo$CURRMODEM=pinfo$CURRMODEM - uci set modem.pinginfo$CURRMODEM.alive=$alive - if [ $alive -ne 0 ]; then - local reliability count pingtime pingwait packetsize down up - - handle_trackip() { - local value="$1" - uci add_list modem.pinginfo$CURRMODEM.trackip=$value - } - config_list_foreach "$config" trackip handle_trackip - TIP=$(uci get modem.pinginfo$CURRMODEM.trackip) - if [ -z "$TIP" ]; then - uci add_list modem.pinginfo$CURRMODEM.trackip="1.1.1.1" - fi - config_get reliability $1 reliability - uci set modem.pinginfo$CURRMODEM.reliability=$reliability - config_get count $1 count - uci set modem.pinginfo$CURRMODEM.count=$count - config_get pingtime $1 pingtime - uci set modem.pinginfo$CURRMODEM.pingtime=$pingtime - config_get pingwait $1 pingwait - uci set modem.pinginfo$CURRMODEM.pingwait=$pingwait - config_get packetsize $1 packetsize - uci set modem.pinginfo$CURRMODEM.packetsize=$packetsize - config_get down $1 down - uci set modem.pinginfo$CURRMODEM.down=$down - config_get up $1 up - uci set modem.pinginfo$CURRMODEM.up=$up - fi - - uci commit modem - fi - fi - fi - fi -} - -autoapn=$(uci -q get profile.disable.autoapn) -apd=0 -if [ -e /usr/lib/autoapn/apn.data ]; then - apd=1 -fi - -if [ $autoapn = "1" -a $apd -eq 1 ]; then - MATCH=0 -else - autod=$(uci -q get profile.disable.enabled) - if [ $autod = "1" ]; then - MATCH=0 - else - config_load profile - config_foreach do_custom custom - fi -fi - -if [ $MATCH = 0 ]; then - if [ $autod = "1" ]; then - if [ -e /etc/config/isp ]; then - MATCH=1 - fi - fi - if [ $MATCH = 1 ]; then - isp=$(uci -q get isp.general.current) - apn=$(uci -q get isp.$isp.apn) - apn2="" - else - apn=$(uci -q get profile.default.apn) - dapn=$(echo "$apn" | grep "|") - if [ -z $dapn ]; then - apn2="" - else - fapn=$apn"|" - fapn=$(echo $fapn" " | tr "|" ",") - apn=$(echo $fapn | cut -d, -f1) - apn2=$(echo $fapn | cut -d, -f2) - fi - fi - uci set modem.modeminfo$CURRMODEM.apn=$apn - uci set modem.modeminfo$CURRMODEM.apn2=$apn2 - if [ -n "$ICCID" ]; then - iccid="891490" - case $ICCID in - "$iccid"*) - uci set modem.modeminfo$CURRMODEM.apn2="" - uci set modem.modeminfo$CURRMODEM.apn="internet.freedommobile.ca" - ;; - esac - fi - - uci set modem.modeminfo$CURRMODEM.user=$(uci -q get profile.default.user) - uci set modem.modeminfo$CURRMODEM.passw=$(uci -q get profile.default.passw) - uci set modem.modeminfo$CURRMODEM.pincode=$(uci -q get profile.default.pincode) - uci set modem.modeminfo$CURRMODEM.context=$(uci -q get profile.default.context) - uci set modem.modeminfo$CURRMODEM.auth=$(uci get profile.default.auth) - uci set modem.modeminfo$CURRMODEM.ppp=$(uci get profile.default.ppp) - uci set modem.modeminfo$CURRMODEM.inter=0 - uci set modem.modeminfo$CURRMODEM.delay=$(uci get profile.default.delay) - uci set modem.modeminfo$CURRMODEM.lock=$(uci get profile.default.lock) - uci set modem.modeminfo$CURRMODEM.mcc=$(uci -q get profile.default.mcc) - uci set modem.modeminfo$CURRMODEM.mnc=$(uci -q get profile.default.mnc) - uci set modem.modeminfo$CURRMODEM.dns1=$(uci -q get profile.default.dns1) - uci set modem.modeminfo$CURRMODEM.dns2=$(uci -q get profile.default.dns2) - uci set modem.modeminfo$CURRMODEM.dns3=$(uci -q get profile.default.dns3) - uci set modem.modeminfo$CURRMODEM.dns4=$(uci -q get profile.default.dns4) - uci set modem.modeminfo$CURRMODEM.log=$(uci get profile.default.log) - uci set modem.modeminfo$CURRMODEM.lb=$(uci get profile.default.lb) - uci set modem.modeminfo$CURRMODEM.at=$(uci -q get profile.default.at) - uci set modem.modeminfo$CURRMODEM.atc=$(uci -q get profile.default.atc) - uci set modem.modeminfo$CURRMODEM.tzone=$(uci -q get profile.default.tzone) - uci set modem.modeminfo$CURRMODEM.mtu=$(uci -q get profile.default.mtu) - uci set modem.modeminfo$CURRMODEM.nodhcp=$(uci -q get profile.default.nodhcp) - pdp=$(uci -q get profile.default.pdptype) - if [ $pdp = "0" ]; then - pdp="" - fi - uci set modem.modeminfo$CURRMODEM.pdptype=$pdp - ttl=$(uci -q get profile.default.ttl) - if [ -z "$ttl" ]; then - ttl="0" - fi - uci set modem.modeminfo$CURRMODEM.ttl="$ttl" - hostless=$(uci -q get profile.default.hostless) - if [ -z "$hostless" ]; then - hostless="0" - fi - uci set modem.modeminfo$CURRMODEM.hostless="$hostless" - bwday=$(uci -q get profile.default.bwday) - if [ -z $bwday ]; then - bwday="0" - fi - uci set modem.modeminfo$CURRMODEM.bwday=$bwday - phone=$(uci -q get profile.default.phone) - if [ -z $phone ]; then - phone="0" - fi - uci set modem.modeminfo$CURRMODEM.bwphone=$phone - bwdelay=$(uci -q get profile.default.bwdelay) - if [ -z $bwdelay ]; then - bwdelay="0" - fi - uci set modem.modeminfo$CURRMODEM.bwdelay=$bwdelay - - alive=$(uci get profile.default.alive) - uci delete modem.pinginfo$CURRMODEM - uci set modem.pinginfo$CURRMODEM=pinfo$CURRMODEM - uci set modem.pinginfo$CURRMODEM.alive=$alive - if [ $alive -ne 0 ]; then - - handle_trackip1() { - local value="$1" - uci add_list modem.pinginfo$CURRMODEM.trackip=$value - } - config_list_foreach "default" trackip handle_trackip1 - TIP=$(uci get modem.pinginfo$CURRMODEM.trackip) - if [ -z "$TIP" ]; then - uci add_list modem.pinginfo$CURRMODEM.trackip="1.1.1.1" - fi - uci set modem.pinginfo$CURRMODEM.reliability=$(uci get profile.default.reliability) - uci set modem.pinginfo$CURRMODEM.count=$(uci get profile.default.count) - uci set modem.pinginfo$CURRMODEM.pingtime=$(uci get profile.default.pingtime) - uci set modem.pinginfo$CURRMODEM.pingwait=$(uci get profile.default.pingwait) - uci set modem.pinginfo$CURRMODEM.packetsize=$(uci get profile.default.packetsize) - uci set modem.pinginfo$CURRMODEM.down=$(uci get profile.default.down) - uci set modem.pinginfo$CURRMODEM.up=$(uci get profile.default.up) - fi - - uci commit modem - if [ "$autoapn" = "1" -a $apd -eq 1 ]; then - log "Automatic APN Used" - else - log "Default Profile Used" - [ -n "$(uci -q get profile.default.apn)" ] || log "Default profile has no APN configured" - fi -fi - -if [ ! -e /etc/config/isp ]; then - if [ "$autoapn" != "1" -a $apd -eq 1 ]; then - APN=$(uci -q get modem.modeminfo$CURRMODEM.apn) - log "APN of profile used is $APN" - fi -fi - -touch /tmp/profile$CURRMODEM diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/connect/handlettl.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/connect/handlettl.sh deleted file mode 100644 index fe216c6..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/connect/handlettl.sh +++ /dev/null @@ -1,106 +0,0 @@ -#!/bin/sh - -log() { - modlog "TTL Settings $CURRMODEM" "$@" -} - -delTTL() { - FLG="0" - exst=$(cat /etc/ttl.user | grep "#startTTL$CURRMODEM") - if [ ! -z "$exst" ]; then - cp /etc/ttl.user /etc/ttl.user.bk - sed -i -e "s!iptables -t mangle -I POSTROUTING -o $IFACE!iptables -t mangle -D POSTROUTING -o $IFACE!g" /etc/ttl.user.bk - sed -i -e "s!iptables -t mangle -I PREROUTING -i $IFACE!iptables -t mangle -D PREROUTING -i $IFACE!g" /etc/ttl.user.bk - sed -i -e "s!ip6tables -t mangle -I POSTROUTING -o $IFACE!iptables -t mangle -D POSTROUTING -o $IFACE!g" /etc/ttl.user.bk - sed -i -e "s!ip6tables -t mangle -I PREROUTING -i $IFACE!iptables -t mangle -D PREROUTING -i $IFACE!g" /etc/ttl.user.bk - - rm -f /tmp/ttl.user - run=0 - while IFS= read -r line; do - if [ $run = "0" ]; then - sttl=$line - stx=$(echo "$sttl" | grep "#startTTL$CURRMODEM") - if [ ! -z $stx ]; then - run=1 - fi - else - sttl=$line - stx=$(echo "$sttl" | grep "#endTTL$CURRMODEM") - if [ ! -z $stx ]; then - chmod 777 /tmp/ttl.user - /tmp/ttl.user - break - fi - echo "$sttl" >> /tmp/ttl.user - fi - done < /etc/ttl.user.bk - cp /etc/ttl.user /etc/ttl.user.bk - - sed /"#startTTL$CURRMODEM"/,/"#endTTL$CURRMODEM"/d /etc/ttl.user.bk > /etc/ttl.user - FLG="1" - fi -} - -CURRMODEM=$1 -TTL="$2" -if [ $CURRMODEM = "0" ]; then - IFACE="wan" -else - IFACE=$(uci -q get modem.modem$CURRMODEM.interface) -fi - -if [ "$TTL" = "0" ]; then - ENB=$(uci -q get ttl.ttl.enabled) - if [ $ENB = "1" ]; then - TTL=$(uci -q get ttl.ttl.value) - if [ -z "$TTL" ]; then - TTL=65 - fi - else - delTTL - log "Deleting TTL on interface $IFACE" - exit 0 - fi -fi - -if [ "$TTL" = "1" ]; then - delTTL - log "Deleting TTL on interface $IFACE" - exit 0 -fi - -delTTL -VALUE="$TTL" -echo "#startTTL$CURRMODEM" >> /etc/ttl.user -log "Setting TTL $VALUE on interface $IFACE" -if [ "$TTL" = "TTL-INC 1" ]; then - TTL="0" -fi - -if [ $VALUE = "0" ]; then - echo "iptables -t mangle -I POSTROUTING -o $IFACE -j TTL --ttl-inc 1" >> /etc/ttl.user - echo "iptables -t mangle -I PREROUTING -i $IFACE -j TTL --ttl-inc 1" >> /etc/ttl.user - iptables -t mangle -I POSTROUTING -o $IFACE -j TTL --ttl-inc 1 - iptables -t mangle -I PREROUTING -i $IFACE -j TTL --ttl-inc 1 - if [ -e /usr/sbin/ip6tables ]; then - echo "ip6tables -t mangle -I POSTROUTING -o $IFACE -j HL --hl-inc 1" >> /etc/ttl.user - echo "ip6tables -t mangle -I PREROUTING -i $IFACE -j HL --hl-inc 1" >> /etc/ttl.user - ip6tables -t mangle -I POSTROUTING -o $IFACE -j HL --hl-inc 1 - ip6tables -t mangle -I PREROUTING -i $IFACE -j HL --hl-inc 1 - fi -else - echo "iptables -t mangle -I POSTROUTING -o $IFACE -j TTL --ttl-set $VALUE" >> /etc/ttl.user - echo "iptables -t mangle -I PREROUTING -i $IFACE -j TTL --ttl-set $VALUE" >> /etc/ttl.user - iptables -t mangle -I POSTROUTING -o $IFACE -j TTL --ttl-set $VALUE - iptables -t mangle -I PREROUTING -i $IFACE -j TTL --ttl-set $VALUE - if [ -e /usr/sbin/ip6tables ]; then - echo "ip6tables -t mangle -I POSTROUTING -o $IFACE -j HL --hl-set $VALUE" >> /etc/ttl.user - echo "ip6tables -t mangle -I PREROUTING -i $IFACE -j HL --hl-set $VALUE" >> /etc/ttl.user - ip6tables -t mangle -I POSTROUTING -o $IFACE -j HL --hl-set $VALUE - ip6tables -t mangle -I PREROUTING -i $IFACE -j HL --hl-set $VALUE - fi -fi -echo "#endTTL$CURRMODEM" >> /etc/ttl.user - - - diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/connect/postconnect.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/connect/postconnect.sh deleted file mode 100644 index 12ec93e..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/connect/postconnect.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter -ROOTER_LINK="/tmp/links" - -log() { - modlog "PostConnect $CURRMODEM" "$@" -} - -CURRMODEM=$1 -idV=$(uci -q get modem.modem$CURRMODEM.idV) -idP=$(uci -q get modem.modem$CURRMODEM.idP) -CPORT=$(uci get modem.modem$CURRMODEM.commport) - -log "Running PostConnect script" - -if [ -e /usr/lib/scan/emailchk.sh ]; then - /usr/lib/scan/emailchk.sh & -fi \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/connect/preconnect.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/connect/preconnect.sh deleted file mode 100644 index 92bef6f..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/connect/preconnect.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter -ROOTER_LINK="/tmp/links" - -log() { - modlog "PreConnect $CURRMODEM" "$@" -} - -CURRMODEM=$1 -idV=$(uci -q get modem.modem$CURRMODEM.idV) -idP=$(uci -q get modem.modem$CURRMODEM.idP) -CPORT=$(uci get modem.modem$CURRMODEM.commport) - -log "Running PreConnect script" \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/connect/reconnect-ppp.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/connect/reconnect-ppp.sh deleted file mode 100644 index 26e6ccf..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/connect/reconnect-ppp.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter -ROOTER_LINK="/tmp/links" - -log() { - logger -t "Reconnect Modem" "$@" -} - -CURRMODEM=$1 -uci set modem.modem$CURRMODEM.connected=0 -uci commit modem - -INTER=$(uci get modem.modeminfo$CURRMODEM.inter) - -jkillall getsignal$CURRMODEM -rm -f $ROOTER_LINK/getsignal$CURRMODEM -jkillall con_monitor$CURRMODEM -rm -f $ROOTER_LINK/con_monitor$CURRMODEM -ifdown wan$INTER -MAN=$(uci get modem.modem$CURRMODEM.manuf) -MOD=$(uci get modem.modem$CURRMODEM.model) -$ROOTER/signal/status.sh $CURRMODEM "$MAN $MOD" "Reconnecting" -PROT=$(uci get modem.modem$CURRMODEM.proto) - -CPORT=$(uci get modem.modem$CURRMODEM.commport) - -SEVR=$(uci get modem.modem$CURRMODEM.service) - -if [ $SEVR = 0 ]; then - COUNTER=1 - while [ $COUNTER -lt 6 ]; do - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "reset.gcom" "$CURRMODEM") - ERROR="ERROR" - if `echo ${OX} | grep "${ERROR}" 1>/dev/null 2>&1` - then - log "Retry Reset" - sleep 3 - let COUNTER=COUNTER+1 - else - log "Modem Reset" - sleep 3 - $ROOTER/common/lockchk.sh $CURRMODEM - break - fi - done - if [ $COUNTER -lt 6 ]; then - ifup wan$INTER - else - log "Reset Failed for Modem $CURRMODEM" - $ROOTER/signal/status.sh $CURRMODEM "$MAN $MOD" "Failed to Reset" - fi -else - ifup wan$INTER -fi - - - - diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/connect/reconnect.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/connect/reconnect.sh deleted file mode 100644 index 98ba291..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/connect/reconnect.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -ROOTER_LINK="/tmp/links" - -log() { - modlog "Reconnect Modem $CURRMODEM" "$@" -} - -CURRMODEM=$1 -log "Re-starting Connection for Modem $CURRMODEM" -$ROOTER_LINK/create_proto$CURRMODEM $CURRMODEM 1 - diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/customname.lua b/rooter/ext-rooter-basic/files/usr/lib/rooter/customname.lua deleted file mode 100644 index 464217d..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/customname.lua +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/lua - -mfile = "/tmp/sysinfo/model" -nfile="/etc/custom" -local file = io.open(nfile, "r") -if file == nil then - return -end -linex = file:read("*line") -file:close() -file = io.open(mfile, "w") -if file == nil then - return -end - -file:write(linex,"\n") -file:close() \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/auto.gcom b/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/auto.gcom deleted file mode 100644 index 73544d9..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/auto.gcom +++ /dev/null @@ -1,31 +0,0 @@ -opengt - set com 115200n81 - set comecho off - set senddelay 0.05 - waitquiet 1 0.2 - -:start -let $g=$env("TIMEOUT") -if $g = "" let f=25 -else let f = val($g) - -send "AT!SCPROF?1^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s -:continue -exit 0 - -:getresult -get 1 "^m" $s -let x=len($s) -if x=0 let $s="^mTIMEOUT ERROR" -else print $s -if $s="^jOK" return -if $mid($s,0,6)="^jERROR" return -if $mid($s,0,8)="^jCOMMAND" return -if $mid($s,0,11)="^j+CME ERROR" return -if time()>t return -goto getresult - print $s - return diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/baseinfo.gcom b/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/baseinfo.gcom deleted file mode 100644 index 84149d6..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/baseinfo.gcom +++ /dev/null @@ -1,33 +0,0 @@ -opengt - set com 115200n81 - set comecho off - set senddelay 0.02 - waitquiet 1 0.2 - -let $g=$env("TIMEOUT") -if $g = "" let f=25 -else let f = val($g) - -send "ATI^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT+CGEQNEG=1^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - - exit 0 - -:getresult -get 1 "^m" $s -let x=len($s) -if x=0 let $s="^mTIMEOUT ERROR" -else print $s -if $s="^jOK" return -if $mid($s,0,6)="^jERROR" return -if $mid($s,0,8)="^jCOMMAND" return -if $mid($s,0,11)="^j+CME ERROR" return -if time()>t return -goto getresult diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/cellinfo.gcom b/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/cellinfo.gcom deleted file mode 100644 index 6ced05d..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/cellinfo.gcom +++ /dev/null @@ -1,50 +0,0 @@ -opengt - set com 115200n81 - set comecho off - set senddelay 0.02 - waitquiet 0.2 0.2 - -let $g=$env("TIMEOUT") -if $g = "" let f=25 -else let f = val($g) - -send "AT+CREG=2;+CREG?;+CREG=0^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT+CEREG=2;+CEREG?;+CEREG=0^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT+C5GREG=2;+C5GREG?;+C5GREG=0^m" -let t=time()+f -gosub noerror -if $s="^mTIMEOUT ERROR" print $s - - exit 0 - -:getresult -get 1 "^m" $s -let x=len($s) -if x=0 let $s="^mTIMEOUT ERROR" -else print $s -if $s="^jOK" return -if $mid($s,0,6)="^jERROR" return -if $mid($s,0,8)="^jCOMMAND" return -if $mid($s,0,11)="^j+CME ERROR" return -if time()>t return -goto getresult - -:noerror -get 1 "^m" $s -if $mid($s,0,6)="^jERROR" return -let x=len($s) -if x=0 let $s="^mTIMEOUT ERROR" -else print $s -if $s="^jOK" return -if $mid($s,0,8)="^jCOMMAND" return -if $mid($s,0,11)="^j+CME ERROR" return -if time()>t return -goto noerror diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/cellinfo0.gcom b/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/cellinfo0.gcom deleted file mode 100644 index 4a72dd0..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/cellinfo0.gcom +++ /dev/null @@ -1,45 +0,0 @@ -opengt - set com 115200n81 - set comecho off - set senddelay 0.02 - waitquiet 0.2 0.2 - -let $g=$env("TIMEOUT") -if $g = "" let f=25 -else let f = val($g) - -send "AT+COPS=3,0;+COPS?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT+COPS=3,2;+COPS?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - - exit 0 - -:getresult -get 1 "^m" $s -let x=len($s) -if x=0 let $s="^mTIMEOUT ERROR" -else print $s -if $s="^jOK" return -if $mid($s,0,6)="^jERROR" return -if $mid($s,0,8)="^jCOMMAND" return -if $mid($s,0,11)="^j+CME ERROR" return -if time()>t return -goto getresult - -:noerror -get 1 "^m" $s -if $mid($s,0,6)="^jERROR" return -let x=len($s) -if x=0 let $s="^mTIMEOUT ERROR" -else print $s -if $s="^jOK" return -if $mid($s,0,8)="^jCOMMAND" return -if $mid($s,0,11)="^j+CME ERROR" return -if time()>t return -goto noerror diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/cgpaddr.gcom b/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/cgpaddr.gcom deleted file mode 100644 index 126aef6..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/cgpaddr.gcom +++ /dev/null @@ -1,46 +0,0 @@ -opengt - set com 115200n81 - set comecho off - set senddelay 0.05 - waitquiet 1 0.2 - -:start -let $g=$env("TIMEOUT") -if $g = "" let f=25 -else let f = val($g) - -send "AT+CGPADDR=1^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT\^SYSINFOEX^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT\^SYSINFO^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT\^NDISSTATQRY?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - - -:continue - exit 0 - -:getresult -get 1 "^m" $s -let x=len($s) -if x=0 let $s="^mTIMEOUT ERROR" -else print $s -if $s="^jOK" return -if $mid($s,0,6)="^jERROR" return -if $mid($s,0,8)="^jCOMMAND" return -if $mid($s,0,11)="^j+CME ERROR" return -if time()>t return -goto getresult diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/connect-directip.gcom b/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/connect-directip.gcom deleted file mode 100644 index 00bc9e4..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/connect-directip.gcom +++ /dev/null @@ -1,64 +0,0 @@ -opengt - set com 115200n81 - set comecho off - set senddelay 0.05 - waitquiet 1 0.2 - -:start -let $g=$env("TIMEOUT") -if $g = "" let f=25 -else let f = val($g) - -send "AT!SCACT=0,1^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT!SCDFTPROF=1^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -let $x=$env("SETAPN") -let $y=$env("SETUSER") -let $z=$env("SETPASS") -let $a=$env("SETAUTH") -send "AT+CGDCONT=1,\"IP\",\"" -send $x -send "\"^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT$QCPDPP=1," -send $a -if $a="0" send "^m" -else send ",\"" send $z send "\",\"" send $y send "\"^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT!SCACT=1,1^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT!SCACT?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -:continue - exit 0 - -:getresult -get 1 "^m" $s -let x=len($s) -if x=0 let $s="^mTIMEOUT ERROR" -else print $s -if $s="^jOK" return -if $mid($s,0,6)="^jERROR" return -if $mid($s,0,8)="^jCOMMAND" return -if $mid($s,0,11)="^j+CME ERROR" return -if time()>t return -goto getresult diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/connect-fecm.gcom b/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/connect-fecm.gcom deleted file mode 100644 index 653f601..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/connect-fecm.gcom +++ /dev/null @@ -1,45 +0,0 @@ -opengt - set com 115200n81 - set comecho off - set senddelay 0.05 - waitquiet 1 0.2 - -:start -let $g=$env("TIMEOUT") -if $g = "" let f=25 -else let f = val($g) - -send "AT+GTRNDIS=0,1" -send "^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -let $x=$env("SETAPN") -send "AT+CGDCONT=1,\"IP\",\"" -send $x -send "\"^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT+GTRNDIS=1,1" -send "^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -:continue - exit 0 - -:getresult -get 1 "^m" $s -let x=len($s) -if x=0 let $s="^mTIMEOUT ERROR" -else print $s -if $s="^jOK" return -if $mid($s,0,6)="^jERROR" return -if $mid($s,0,8)="^jCOMMAND" return -if $mid($s,0,11)="^j+CME ERROR" return -if time()>t return -goto getresult diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/connect-ncm.gcom b/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/connect-ncm.gcom deleted file mode 100644 index 1fd4893..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/connect-ncm.gcom +++ /dev/null @@ -1,48 +0,0 @@ -opengt - set com 115200n81 - set comecho off - set senddelay 0.05 - waitquiet 1 0.2 - -:start -let $g=$env("TIMEOUT") -if $g = "" let f=25 -else let f = val($g) - -send "AT^^NDISDUP=1,0^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -let $x=$env("SETAPN") -let $y=$env("SETUSER") -let $z=$env("SETPASS") -let $a=$env("SETAUTH") -send "AT^^NDISDUP=1,1,\"" -send $x -if $a="0" send "\"^m" -else send "\",\"" send $y send "\",\"" send $z send "\"," send $a send "^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT\^NDISSTATQRY?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -:continue - exit 0 - -:getresult -get 1 "^m" $s -let x=len($s) -if x=0 let $s="^mTIMEOUT ERROR" -else print $s -if $s="^jOK" return -if $mid($s,0,6)="^jERROR" return -if $mid($s,0,8)="^jCOMMAND" return -if $mid($s,0,11)="^j+CME ERROR" return -if time()>t return -goto getresult - diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/connect-ppp.gcom b/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/connect-ppp.gcom deleted file mode 100644 index fadf2d8..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/connect-ppp.gcom +++ /dev/null @@ -1,36 +0,0 @@ -opengt - set com 115200n81 - set comecho off - set senddelay 0.05 - waitquiet 1 0.2 - -:start -let $g=$env("TIMEOUT") -if $g = "" let f=25 -else let f = val($g) - -let $y=$env("SETUSER") -let $z=$env("SETPASS") -let $a=$env("SETAUTH") -send "AT$QCPDPP=1," -send $a -if $a="0" send "^m" -else send ",\"" send $z send "\",\"" send $y send "\"^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -:continue - exit 0 - -:getresult -get 1 "^m" $s -let x=len($s) -if x=0 let $s="^mTIMEOUT ERROR" -else print $s -if $s="^jOK" return -if $mid($s,0,6)="^jERROR" return -if $mid($s,0,8)="^jCOMMAND" return -if $mid($s,0,11)="^j+CME ERROR" return -if time()>t return -goto getresult diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/connect-zecm.gcom b/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/connect-zecm.gcom deleted file mode 100644 index fd14d94..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/connect-zecm.gcom +++ /dev/null @@ -1,45 +0,0 @@ -opengt - set com 115200n81 - set comecho off - set senddelay 0.05 - waitquiet 1 0.2 - -:start -let $g=$env("TIMEOUT") -if $g = "" let f=25 -else let f = val($g) - -send "AT+ZECMCALL=0" -send "^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -let $x=$env("SETAPN") -send "AT+CGDCONT=1,\"IP\",\"" -send $x -send "\"^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT+ZECMCALL=1" -send "^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -:continue - exit 0 - -:getresult -get 1 "^m" $s -let x=len($s) -if x=0 let $s="^mTIMEOUT ERROR" -else print $s -if $s="^jOK" return -if $mid($s,0,6)="^jERROR" return -if $mid($s,0,8)="^jCOMMAND" return -if $mid($s,0,11)="^j+CME ERROR" return -if time()>t return -goto getresult diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/curc.gcom b/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/curc.gcom deleted file mode 100644 index 59f79da..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/curc.gcom +++ /dev/null @@ -1,31 +0,0 @@ -opengt - set com 115200n81 - set comecho off - set senddelay 0.05 - waitquiet 1 0.2 - -:start -let $g=$env("TIMEOUT") -if $g = "" let f=25 -else let f = val($g) - -send "AT\^CURC=0^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -:continue - exit 0 - -:getresult -get 1 "^m" $s -let x=len($s) -if x=0 let $s="^mTIMEOUT ERROR" -else print $s -if $s="^jOK" return -if $mid($s,0,6)="^jERROR" return -if $mid($s,0,8)="^jCOMMAND" return -if $mid($s,0,11)="^j+CME ERROR" return -if time()>t return -goto getresult - diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/fibocominfo.gcom b/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/fibocominfo.gcom deleted file mode 100644 index 72126b5..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/fibocominfo.gcom +++ /dev/null @@ -1,65 +0,0 @@ -opengt -set com 115200n81 -set comecho off -set senddelay 0.02 -waitquiet 0.2 0.2 - -let $g=$env("TIMEOUT") -if $g = "" let f=25 -else let f = val($g) - -send "AT+CSQ^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT+GTCCINFO?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s -if $s="^jERROR" goto gtrat - -send "AT+COPN^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -:gtrat -send "AT+GTRAT?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT+GTCAINFO?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT+XACT?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT+XMCI=1;+XLEC?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT+MTSM=1^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -exit 0 - -:getresult -get 1 "^m" $s -let x=len($s) -if x=0 let $s="^mTIMEOUT ERROR" -else print $s -if $s="^jOK" return -if $mid($s,0,6)="^jERROR" return -if $mid($s,0,8)="^jCOMMAND" return -if $mid($s,0,11)="^j+CME ERROR" return -if time()>t return -goto getresult diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/gcom-locked b/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/gcom-locked deleted file mode 100644 index ff816e2..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/gcom-locked +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh - -log() { - logger -t "gcom-locked " "$@" -} - -ROOTER_GCOM="/usr/lib/rooter/gcom/" - - -PORT=$1 -GCOM=$2 -CURRMODEM=$3 -ATC=$4 - -LOCKDIR="/tmp/lockgcom$CURRMODEM" -PIDFILE="${LOCKDIR}/PID" - -while [ 1 -lt 6 ]; do - if mkdir "${LOCKDIR}" &>/dev/null; then - echo "$$" > "${PIDFILE}" - if [ ! -z "$ATC" ]; then - export ATCMD="$ATC" - fi - OX=$(gcom -d $PORT -s $ROOTER_GCOM$GCOM 2>/dev/null) - if [ ! -e /tmp/block ]; then - /usr/lib/rooter/log/at-logger "$PORT $OX" - fi - break - else - OTHERPID="$(cat "${PIDFILE}" 2>/dev/null)" - if [ $? = 0 ]; then - if ! kill -0 $OTHERPID &>/dev/null; then - rm -rf "${LOCKDIR}" - fi - fi - sleep 1 - fi -done - -rm -rf "${LOCKDIR}" -echo "$OX" \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/gettype.gcom b/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/gettype.gcom deleted file mode 100644 index 77d733b..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/gettype.gcom +++ /dev/null @@ -1,43 +0,0 @@ -opengt - set com 115200n81 - set comecho off - set senddelay 0.02 - waitquiet 0.2 0.2 - -let $g=$env("TIMEOUT") -if $g = "" let f=25 -else let f = val($g) - -send "AT+CFUN=1^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "ATI^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT+CNUM^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT+CPBR=?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - - exit 0 - -:getresult -get 1 "^m" $s -let x=len($s) -if x=0 let $s="^mTIMEOUT ERROR" -else print $s -if $s="^jOK" return -if $mid($s,0,6)="^jERROR" return -if $mid($s,0,8)="^jCOMMAND" return -if $mid($s,0,11)="^j+CME ERROR" return -if time()>t return -goto getresult diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/huaweiinfo.gcom b/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/huaweiinfo.gcom deleted file mode 100644 index cd9a091..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/huaweiinfo.gcom +++ /dev/null @@ -1,74 +0,0 @@ -opengt - set com 115200n81 - set comecho off - set senddelay 0.02 - waitquiet 0.2 0.2 - -let $g=$env("TIMEOUT") -if $g = "" let f=25 -else let f = val($g) - -send "AT+CSQ^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT\^CSNR?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT\^HCSQ?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT\^SYSINFOEX^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT\^SYSCFGEX?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT\^SYSCFG?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT\^SYSINFO^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT\^HFREQINFO?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT\^LTERSRP?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT\^CHIPTEMP?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - - exit 0 - -:getresult -get 1 "^m" $s -let x=len($s) -if x=0 let $s="^mTIMEOUT ERROR" -else print $s -if $s="^jOK" return -if $mid($s,0,6)="^jERROR" return -if $mid($s,0,8)="^jCOMMAND" return -if $mid($s,0,11)="^j+CME ERROR" return -if time()>t return -goto getresult - diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/lock-prov.gcom b/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/lock-prov.gcom deleted file mode 100644 index 332890a..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/lock-prov.gcom +++ /dev/null @@ -1,38 +0,0 @@ -opengt - set com 115200n81 - set comecho off - set senddelay 0.05 - waitquiet 1 0.2 - -:start -let $g=$env("TIMEOUT") -if $g = "" let f=25 -else let f = val($g) - -send "AT+COPS=0^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -let $x=$env("MCCMNC") -send "AT+COPS=1,2,\"" -send $x -send "\",2^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -:continue - exit 0 - -:getresult -get 1 "^m" $s -let x=len($s) -if x=0 let $s="^mTIMEOUT ERROR" -else print $s -if $s="^jOK" return -if $mid($s,0,6)="^jERROR" return -if $mid($s,0,8)="^jCOMMAND" return -if $mid($s,0,11)="^j+CME ERROR" return -if time()>t return -goto getresult diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/mdm9215info.gcom b/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/mdm9215info.gcom deleted file mode 100644 index a647dac..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/mdm9215info.gcom +++ /dev/null @@ -1,43 +0,0 @@ -opengt - set com 115200n81 - set comecho off - set senddelay 0.02 - waitquiet 0.2 0.2 - -let $g=$env("TIMEOUT") -if $g = "" let f=25 -else let f = val($g) - -send "AT+CSQ^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT+COPS?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT$QCSQ^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT$QCSYSMODE?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - - exit 0 - -:getresult -get 1 "^m" $s -let x=len($s) -if x=0 let $s="^mTIMEOUT ERROR" -else print $s -if $s="^jOK" return -if $mid($s,0,6)="^jERROR" return -if $mid($s,0,8)="^jCOMMAND" return -if $mid($s,0,11)="^j+CME ERROR" return -if time()>t return -goto getresult diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/meiginfo.gcom b/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/meiginfo.gcom deleted file mode 100644 index 556874f..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/meiginfo.gcom +++ /dev/null @@ -1,69 +0,0 @@ -opengt - set com 115200n81 - set comecho off - set senddelay 0.02 - waitquiet 0.2 0.2 - -let $g=$env("TIMEOUT") -if $g = "" let f=25 -else let f = val($g) - -send "AT+CSQ^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT+PSRAT^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -if $s="^jERROR" goto newmodel - -send "AT+MODODR?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT+CELLINFO^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT+SGCELLINFO^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -exit 0 - -:newmodel - -send "AT\^SYSCFGEX?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT+SGCELLINFOEX^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT+CELLINFO=3^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -exit 0 - -:getresult -get 1 "^m" $s -let x=len($s) -if x=0 let $s="^mTIMEOUT ERROR" -else print $s -if $s="^jOK" return -if $mid($s,0,6)="^jERROR" return -if $mid($s,0,8)="^jCOMMAND" return -if $mid($s,0,11)="^j+CME ERROR" return -if time()>t return -goto getresult diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/novatelinfo.gcom b/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/novatelinfo.gcom deleted file mode 100644 index e1a58e8..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/novatelinfo.gcom +++ /dev/null @@ -1,48 +0,0 @@ -opengt - set com 115200n81 - set comecho off - set senddelay 0.02 - waitquiet 0.2 0.2 - -let $g=$env("TIMEOUT") -if $g = "" let f=25 -else let f = val($g) - -send "AT+CSQ^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT$NWRAT?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT$NWDEGC^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT+VZWRSRP?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT+VZWRSRQ?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - - exit 0 - -:getresult -get 1 "^m" $s -let x=len($s) -if x=0 let $s="^mTIMEOUT ERROR" -else print $s -if $s="^jOK" return -if $mid($s,0,6)="^jERROR" return -if $mid($s,0,8)="^jCOMMAND" return -if $mid($s,0,11)="^j+CME ERROR" return -if time()>t return -goto getresult diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/otherinfo.gcom b/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/otherinfo.gcom deleted file mode 100644 index 6f851cd..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/otherinfo.gcom +++ /dev/null @@ -1,28 +0,0 @@ -opengt - set com 115200n81 - set comecho off - set senddelay 0.02 - waitquiet 0.2 0.2 - -let $g=$env("TIMEOUT") -if $g = "" let f=25 -else let f = val($g) - -send "AT+CSQ^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - - exit 0 - -:getresult -get 1 "^m" $s -let x=len($s) -if x=0 let $s="^mTIMEOUT ERROR" -else print $s -if $s="^jOK" return -if $mid($s,0,6)="^jERROR" return -if $mid($s,0,8)="^jCOMMAND" return -if $mid($s,0,11)="^j+CME ERROR" return -if time()>t return -goto getresult diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/quantainfo.gcom b/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/quantainfo.gcom deleted file mode 100644 index 2ae0303..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/quantainfo.gcom +++ /dev/null @@ -1,38 +0,0 @@ -opengt - set com 115200n81 - set comecho off - set senddelay 0.02 - waitquiet 0.2 0.2 - -let $g=$env("TIMEOUT") -if $g = "" let f=25 -else let f = val($g) - -send "AT+CSQ^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT*QRFINFO?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT\^QCNCFG?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - - exit 0 - -:getresult -get 1 "^m" $s -let x=len($s) -if x=0 let $s="^mTIMEOUT ERROR" -else print $s -if $s="^jOK" return -if $mid($s,0,6)="^jERROR" return -if $mid($s,0,8)="^jCOMMAND" return -if $mid($s,0,11)="^j+CME ERROR" return -if time()>t return -goto getresult diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/quectelinfo.gcom b/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/quectelinfo.gcom deleted file mode 100644 index 286acb9..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/quectelinfo.gcom +++ /dev/null @@ -1,76 +0,0 @@ -opengt -set com 115200n81 -set comecho off -set senddelay 0.02 -waitquiet 0.2 0.2 - -let $g=$env("TIMEOUT") -if $g = "" let f=25 -else let f = val($g) - -send "AT+CSQ^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT+QENG=\"servingcell\"^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT+QRSRP^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT+QCAINFO^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT+QCFG=\"nwscanmode\"^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s -if $s="^jERROR" goto qnwpref -goto temp - -:qnwpref -send "AT+QNWPREFCFG=\"mode_pref\"^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -:temp -send "AT+QTEMP^m" -let t=time()+1 -gosub gettemp - -send "AT+QENG=\"neighbourcell\"^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -exit 0 - -:getresult -get 1 "^m" $s -let x=len($s) -if x=0 let $s="^mTIMEOUT ERROR" -else print $s -if $s="^jOK" return -if $mid($s,0,6)="^jERROR" return -if $mid($s,0,8)="^jCOMMAND" return -if $mid($s,0,11)="^j+CME ERROR" return -if time()>t return -goto getresult - -:gettemp -get 1 "^m" $s -let x=len($s) -if x>0 print $s -if $mid($s,0,6)="^jERROR" return -if $mid($s,0,8)="^jCOMMAND" return -if $mid($s,0,11)="^j+CME ERROR" return -if time()>t return -goto gettemp diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/raw-ip.gcom b/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/raw-ip.gcom deleted file mode 100644 index cbdbf3e..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/raw-ip.gcom +++ /dev/null @@ -1,31 +0,0 @@ -opengt - set com 115200n81 - set comecho off - set senddelay 0.05 - waitquiet 1 0.2 - -:start -let $g=$env("TIMEOUT") -if $g = "" let f=25 -else let f = val($g) - -let $x=$env("ATCMD") -send $x -send "^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -:continue - exit 0 - -:getresult -get 1 "^m" $s -let x=len($s) -if x=0 let $s="^mTIMEOUT ERROR" -else print $s -if $s="^jCONNECT" return -if $mid($s,0,6)="^jERROR" return -if $mid($s,0,11)="^j+CME ERROR" return -if time()>t return -goto getresult diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/reset.gcom b/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/reset.gcom deleted file mode 100644 index 09e46f5..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/reset.gcom +++ /dev/null @@ -1,25 +0,0 @@ -opengt - set com 115200n81 - set comecho off - set senddelay 0.05 - waitquiet 1 0.2 - -//send "ate0^m" -//waitquiet 1 0.2 -send "AT+COPS=2;+CFUN=4^m" -waitfor 5 "OK" -sleep 5 -send "AT+CFUN?^m" -waitfor 5 "+CME ERROR:","+CFUN:" -if % = 0 goto cme_err -get 2 " " $s -if $left($s,1) = "1" goto end -sleep 5 -send "AT+CFUN=1^m" -waitquiet 1 0.2 -exit 0 - -:cme_err -print "+CME ERROR" -:end -exit 0 diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/run-at.gcom b/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/run-at.gcom deleted file mode 100644 index b40dd6e..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/run-at.gcom +++ /dev/null @@ -1,31 +0,0 @@ -opengt - set com 115200n81 - set comecho off - set senddelay 0.05 - waitquiet 1 0.2 - -:start -let $g=$env("TIMEOUT") -if $g="" let f=25 -else let f=val($g) - -let $x=$env("ATCMD") -send $x -send "^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s -:continue -exit 0 - -:getresult -get 1 "^m" $s -let x=len($s) -if x=0 let $s="^mTIMEOUT ERROR" -else print $s -if $s="^jOK" return -if $mid($s,0,6)="^jERROR" return -if $mid($s,0,8)="^jCOMMAND" return -if $mid($s,0,11)="^j+CME ERROR" return -if time()>t return -goto getresult diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/sendsms-at.gcom b/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/sendsms-at.gcom deleted file mode 100644 index 7203af5..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/sendsms-at.gcom +++ /dev/null @@ -1,45 +0,0 @@ -opengt - set com 115200n81 - set comecho off - set senddelay 0.05 - waitquiet 1 0.2 - -:start - -let $x=$env("ATCMD") -let $j=$left($x,1) -if $j = "0" let $j=$mid($x,1,2) -else let $j=$left($x,3) -let $r=$mid($x,4,4) -let k=len($x)-9 -let $p=$right($x,k) -send "AT+CMGF=0^m" -waitfor 2 "OK" -send "AT+CMGS=" -send $j -send "^m" -waitfor 3 ">" -send $p -send "^z" -waitfor 20 "+CMGS:" - -if % = 0 gosub sentsub -else gosub failsub - -get 1 "" $s - -:continue - exit 0 - -:sentsub -get 2 "^m^j" $s -let $c=$s -print "SMS sent, reference: "+$c -let $c='echo "SMS sent, reference: "'+$c+' > /tmp/smssendstatus'+$r -system $c -return - -:failsub -system 'echo "SMS sending failed" > /tmp/smssendstatus'+$r -print "SMS sending failed" -return diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/setapn.gcom b/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/setapn.gcom deleted file mode 100644 index 9b29c50..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/setapn.gcom +++ /dev/null @@ -1,45 +0,0 @@ -opengt - set com 115200n81 - set comecho off - set senddelay 0.05 - waitquiet 1 0.2 - -:start -let $g=$env("TIMEOUT") -if $g = "" let f=25 -else let f = val($g) - -let $x=$env("SETAPN") -let $y=$env("SETUSER") -let $z=$env("SETPASS") -let $a=$env("SETAUTH") -send "AT+CGDCONT=1,\"IP\",\"" -send $x -send "\"^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT$QCPDPP=1," -send $a -if $a="0" send "^m" -else send ",\"" send $z send "\",\"" send $y send "\"^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -:continue - exit 0 - -:getresult -get 1 "^m" $s -let x=len($s) -if x=0 let $s="^mTIMEOUT ERROR" -else print $s -if $s="^jOK" return -if $mid($s,0,6)="^jERROR" return -if $mid($s,0,8)="^jCOMMAND" return -if $mid($s,0,11)="^j+CME ERROR" return -if time()>t return -goto getresult - diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/setpin.gcom b/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/setpin.gcom deleted file mode 100644 index 9084557..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/setpin.gcom +++ /dev/null @@ -1,53 +0,0 @@ -# set pin code from evnironment "$PINCODE" -opengt - set com 115200n81 - set senddelay 0.05 - waitquiet 3 0.5 - flash 0.1 - - let c=0 -:start - send "AT+CPIN?^m" - waitfor 15 "SIM PUK","SIM PIN","READY","ERROR","ERR" - if % = -1 goto timeout - if % = 0 goto ready - if % = 1 goto setpin - if % = 2 goto ready - if % = 3 goto checkrepeat - if % = 4 goto checkrepeat - -:checkrepeat - inc c - if c>3 goto pinerror - waitquiet 12 0.5 - goto start - -:timeout - print "ERROR" - exit 1 - -:ready - goto continue - exit 0 - -:setpin - # check if output was "SIM PIN2", that's ok. - waitfor 1 "2" - if % = 0 goto ready - - send "AT+CPIN=\"" - send $env("PINCODE") - send "\"^m" - - waitfor 20 "OK","ERR" - if % = -1 goto pinerror - if % = 0 goto continue - if % = 1 goto pinerror - -:pinerror - print "ERROR" - exit 1 - -:continue - print "OK" - exit 0 diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/sierrainfo.gcom b/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/sierrainfo.gcom deleted file mode 100644 index e24780c..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/sierrainfo.gcom +++ /dev/null @@ -1,68 +0,0 @@ -opengt - set com 115200n81 - set comecho off - set senddelay 0.02 - waitquiet 0.2 0.2 - -let $g=$env("TIMEOUT") -if $g = "" let f=25 -else let f = val($g) - -send "AT+CSQ;+CESQ^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT*CNTI=0^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT!SELRAT?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT+ECIO?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT+RSCP?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT!UMTSCHAN?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT!LTEINFO?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT!GSTATUS?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT!PCTEMP?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - - exit 0 - -:getresult -get 1 "^m" $s -let x=len($s) -if x=0 let $s="^mTIMEOUT ERROR" -else print $s -if $s="^jOK" return -if $mid($s,0,6)="^jERROR" return -if $mid($s,0,8)="^jCOMMAND" return -if $mid($s,0,11)="^j+CME ERROR" return -if time()>t return -goto getresult diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/simcominfo.gcom b/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/simcominfo.gcom deleted file mode 100644 index 50e45c9..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/simcominfo.gcom +++ /dev/null @@ -1,48 +0,0 @@ -opengt -set com 115200n81 -set comecho off -set senddelay 0.02 -waitquiet 0.2 0.2 - -let $g=$env("TIMEOUT") -if $g = "" let f=25 -else let f = val($g) - -send "AT+CSQ^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT+CPSI?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT+CNMP?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT+CMGRMI=4^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT+CPMUTEMP^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -exit 0 - -:getresult -get 1 "^m" $s -let x=len($s) -if x=0 let $s="^mTIMEOUT ERROR" -else print $s -if $s="^jOK" return -if $mid($s,0,6)="^jERROR" return -if $mid($s,0,8)="^jCOMMAND" return -if $mid($s,0,11)="^j+CME ERROR" return -if time()>t return -goto getresult diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/smschk.gcom b/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/smschk.gcom deleted file mode 100644 index f5d9e82..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/smschk.gcom +++ /dev/null @@ -1,36 +0,0 @@ -opengt - set com 115200n81 - set comecho off - set senddelay 0.05 - waitquiet 1 0.2 - -:start -let $g=$env("TIMEOUT") -if $g = "" let f=25 -else let f = val($g) - -send "AT+CMGS=?;+CMGL=?;+CMGR=?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send 'AT+CPMS="SM","SM","SM"^m' -waitfor 5 "OK" - -send 'AT+CGSMS=2^m' -waitfor 5 "OK" - -:continue - exit 0 - -:getresult -get 1 "^m" $s -let x=len($s) -if x=0 let $s="^mTIMEOUT ERROR" -else print $s -if $s="^jOK" return -if $mid($s,0,6)="^jERROR" return -if $mid($s,0,8)="^jCOMMAND" return -if $mid($s,0,11)="^j+CME ERROR" return -if time()>t return -goto getresult diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/smswrite.gcom b/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/smswrite.gcom deleted file mode 100644 index a65bb3c..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/smswrite.gcom +++ /dev/null @@ -1,39 +0,0 @@ -opengt - set com 115200n81 - set comecho off - set senddelay 0.05 - waitquiet 1 0.2 - -:start - -let $x=$env("ATCMD") -let $j=$left($x,1) -if $j = "0" let $j=$mid($x,1,2) -else let $j=$left($x,3) -let $d=$mid($x,4,2) -let $t=$mid($x,7,1) -let k=len($x)-9 -let $p=$right($x,k) -send "AT+CMGF=0^m" -waitfor 2 "OK" -send 'AT+CPMS="SM"' -send ',"' -send $d -send '"^m' -waitfor 2 "OK" -send "AT+CMGW=" -send $j -send "," -send $t -send "^m" -waitfor 3 ">" -send $p -send "^z" -waitfor 25 "+CMGW:" -if % = 0 print "+CMGW:" -else print "AT+CMGW - TIMEOUT" -get 1 "" $s -print $s - -:continue - exit 0 diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/t77info.gcom b/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/t77info.gcom deleted file mode 100644 index f47d378..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/t77info.gcom +++ /dev/null @@ -1,70 +0,0 @@ -opengt - set com 115200n81 - set comecho off - set senddelay 0.02 - waitquiet 0.2 0.2 - -let $g=$env("TIMEOUT") -if $g = "" let f=25 -else let f = val($g) - -send "AT+CSQ^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT+COPS?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT\^CA_INFO?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT\^DEBUG?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT$DEBUG?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT\^SYSCONFIG?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT$QCSQ^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT+TEMP?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -if $s!="^jERROR" exit 0 - -send "AT\^TEMP?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - - exit 0 - -:getresult -get 1 "^m" $s -let x=len($s) -if x=0 let $s="^mTIMEOUT ERROR" -else print $s -if $s="^jOK" return -if $mid($s,0,6)="^jERROR" return -if $mid($s,0,8)="^jCOMMAND" return -if $mid($s,0,11)="^j+CME ERROR" return -if time()>t return -goto getresult diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/telitinfo.gcom b/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/telitinfo.gcom deleted file mode 100644 index 5eaff94..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/telitinfo.gcom +++ /dev/null @@ -1,48 +0,0 @@ -opengt - set com 115200n81 - set comecho off - set senddelay 0.02 - waitquiet 0.2 0.2 - -let $g=$env("TIMEOUT") -if $g = "" let f=25 -else let f = val($g) - -send "AT+CSQ^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT#TEMPSENS=2^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT+COPS?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT#RFSTS^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT#CAINFO?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - - exit 0 - -:getresult -get 1 "^m" $s -let x=len($s) -if x=0 let $s="^mTIMEOUT ERROR" -else print $s -if $s="^jOK" return -if $mid($s,0,6)="^jERROR" return -if $mid($s,0,8)="^jCOMMAND" return -if $mid($s,0,11)="^j+CME ERROR" return -if time()>t return -goto getresult diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/telitinfoln.gcom b/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/telitinfoln.gcom deleted file mode 100644 index eb9bcbd..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/telitinfoln.gcom +++ /dev/null @@ -1,43 +0,0 @@ -opengt - set com 115200n81 - set comecho off - set senddelay 0.02 - waitquiet 0.2 0.2 - -let $g=$env("TIMEOUT") -if $g = "" let f=25 -else let f = val($g) - -send "AT+CSQ^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT+COPS?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT^RFSTS?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT#CAINFO?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - - exit 0 - -:getresult -get 1 "^m" $s -let x=len($s) -if x=0 let $s="^mTIMEOUT ERROR" -else print $s -if $s="^jOK" return -if $mid($s,0,6)="^jERROR" return -if $mid($s,0,8)="^jCOMMAND" return -if $mid($s,0,11)="^j+CME ERROR" return -if time()>t return -goto getresult diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/ubloxinfo.gcom b/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/ubloxinfo.gcom deleted file mode 100644 index 9ebe9dc..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/ubloxinfo.gcom +++ /dev/null @@ -1,43 +0,0 @@ -opengt - set com 115200n81 - set comecho off - set senddelay 0.02 - waitquiet 0.2 0.2 - -let $g=$env("TIMEOUT") -if $g = "" let f=25 -else let f = val($g) - -send "AT+CSQ^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT+CESQ^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT+URAT?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT+UCGED?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - - exit 0 - -:getresult -get 1 "^m" $s -let x=len($s) -if x=0 let $s="^mTIMEOUT ERROR" -else print $s -if $s="^jOK" return -if $mid($s,0,6)="^jERROR" return -if $mid($s,0,8)="^jCOMMAND" return -if $mid($s,0,11)="^j+CME ERROR" return -if time()>t return -goto getresult diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/ussd.gcom b/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/ussd.gcom deleted file mode 100644 index 254da89..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/ussd.gcom +++ /dev/null @@ -1,29 +0,0 @@ -opengt - set com 115200n81 - set comecho off - set senddelay 0.05 - waitquiet 1 0.2 -:start -let f=20 -let $x=$env("ATCMD") -send $x+"^m" -waitfor 2 "OK" -let t=time()+f -let $s="" -gosub getresult -let x=len($s) -if x<2 let $s="^mUSSD TIMEOUT ERROR" -print $s -:continue -exit 0 -:getresult -get 1 "^m" $u -let x=len($u) -let $v=$s -if x>0 let $s=$v+$u -if $right(" "+$s,4) = '",15' return -if $right(" "+$s,4) = '",72' return -if $right(" "+$s,4) = '",68' return -if $mid($s,0,30)="^j+CME ERROR:" return -if time()>t return -goto getresult diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/zteinfo.gcom b/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/zteinfo.gcom deleted file mode 100644 index 013447c..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/gcom/zteinfo.gcom +++ /dev/null @@ -1,58 +0,0 @@ -opengt - set com 115200n81 - set comecho off - set senddelay 0.02 - waitquiet 0.2 0.2 - -let $g=$env("TIMEOUT") -if $g = "" let f=25 -else let f = val($g) - -send "AT+CSQ^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT+ZPAS?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT+ZRSSI^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT+ZRSSI?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT+ZSINR^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT+ZSNT?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - -send "AT+ZCELLINFO?^m" -let t=time()+f -gosub getresult -if $s="^mTIMEOUT ERROR" print $s - - exit 0 - -:getresult -get 1 "^m" $s -let x=len($s) -if x=0 let $s="^mTIMEOUT ERROR" -else print $s -if $s="^jOK" return -if $mid($s,0,6)="^jERROR" return -if $mid($s,0,8)="^jCOMMAND" return -if $mid($s,0,11)="^j+CME ERROR" return -if time()>t return -goto getresult diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/gpio-set.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/gpio-set.sh deleted file mode 100644 index 9ec628e..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/gpio-set.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh - -GPIO=$1 # name or number (without "gpio" prefix) -VAL=$2 # 0 or 1 -WAIT=$3 # delay in seconds, optional - -log() { - modlog "GPIO Set" "$@" -} - - -[ -n "$WAIT" ] && sleep $WAIT - -if `echo "$GPIO" | grep -q "^[0-9]*$"`; then - GPIO=gpio$GPIO -fi - -if [ -w /sys/class/gpio/$GPIO/value ]; then - echo "$VAL" > /sys/class/gpio/$GPIO/value - log "GPIO $GPIO has been set to $VAL" -else - log "GPIO $GPIO is not writable" -fi diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/gpiomodel.lua b/rooter/ext-rooter-basic/files/usr/lib/rooter/gpiomodel.lua deleted file mode 100644 index fe63096..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/gpiomodel.lua +++ /dev/null @@ -1,221 +0,0 @@ -#!/usr/bin/lua - -mfile = "/tmp/sysinfo/model" -echo = 1 -model = {} -gpio = {} -gpio2 = {} -gpio3 = {} -gpio4 = {} -gpioname = {} -gpioname2 = {} -gpioname3 = {} -gpioname4 = {} - -pin = nil -pin2 = nil - -model[1] = "10u" -gpio[1] = 18 -model[2] = "11u" -gpio[2] = 8 -model[3] = "13u" -gpio[3] = 18 -model[4] = "mr3020" -gpio[4] = 8 -model[5] = "3040" -gpio[5] = 18 -model[6] = "3220" -gpio[6] = 6 -model[7] = "3420" -gpio[7] = 6 -model[8] = "wdr3500" -gpio[8] = 12 -gpioname[8] = "tp-link:power:usb" -model[9] = "wdr3600" -gpio[9] = 22 -gpioname[9] = "tp-link:power:usb1" -gpio2[9] = 21 -gpioname2[9] = "tp-link:power:usb2" -model[10] = "wdr4300" -gpio[10] = 22 -gpioname[10] = "tp-link:power:usb1" -gpio2[10] = 21 -gpioname2[10] = "tp-link:power:usb2" -model[11] = "wdr4310" -gpio[11] = 22 -gpioname2[11] = "tp-link:power:usb2" -gpioname[11] = "tp-link:power:usb1" -gpio2[11] = 21 -model[12] = "wdr4900" -gpio[12] = 10 -model[13] = "703n" -gpio[13] = 8 -model[14] = "710n" -gpio[14] = 8 -model[15] = "720" -gpio[15] = 8 -model[16] = "842" -gpio[16] = 6 -gpioname[16] = "tp-link:power:usb" -model[17] = "1043" -gpio[17] = 21 -gpioname[17] = "tp-link:power:usb" -model[18] = "4530" -gpio[18] = 22 -model[19] = "archer" -gpio[19] = 22 -gpio2[19] = 21 -gpioname2[19] = "tp-link:power:usb2" -gpioname[19] = "tp-link:power:usb1" -model[20] = "ar150" -gpio[20] = 6 -model[21] = "domino" -gpio[21] = 6 -model[22] = "300a" -gpio[22] = 0 -model[23] = "mt300n" -gpio[23] = 0 -model[24] = "ar750s" -gpio[24] = 7 -model[25] = "oolite" -gpio[25] = 18 -model[26] = "7800" -gpio[26] = 15 -gpio2[26] = 16 -model[27] = "m11g" -gpio[27] = 9 -gpioname[27] = "gpio9" -model[28] = "m33g" -gpio[28] = 9 -gpio2[28] = 10 -gpio3[28] = 11 -gpio4[28] = 12 -gpioname[28] = "pcie0_power" -gpioname2[28] = "pcie1_power" -gpioname3[28] = "pcie2_power" -gpioname4[28] = "usb_power" -model[29] = "rbsxtr" -gpio[29] = 13 -model[30] = "ap147" -gpio[30] = 13 -model[31] = "gigamod" -gpio[31] = 16 -gpioname[31] = "power_usb" -model[32] = "turbomod" -gpio[32] = 17 -gpioname[32] = "power_usb" -model[33] = "mk01" -gpio[33] = 6 - -numodel = 33 - -local file = io.open(mfile, "r") -if file == nil then - return -end - -name = nil -name2 = nil -line = file:read("*line") -file:close() -line = line:lower() - -for i=1,numodel do - start, ends = line:find(model[i]) - if start ~= nil then - if model[i] == "3420" then - start, ends = line:find("v1") - if start ~= nil then - pin = gpio[i] - pin2 = nil - else - pin = 4 - pin2 = nil - end - elseif model[i] == "3220" then - start, ends = line:find("v1") - if start ~= nil then - pin = gpio[i] - pin2 = nil - else - pin = 8 - pin2 = nil - end - elseif model[i] == "1043" then - start, ends = line:find("v2") - if start ~= nil then - pin = gpio[i] - pin2 = nil - name = gpioname[i] - name2 = nil - end - elseif model[i] == "842" then - start, ends = line:find("v3") - if start == nil then - start, ends = line:find("v2") - if start == nil then - pin = gpio[i] - pin2 = gpio2[i] - name = gpioname[i] - name2 = gpioname2[i] - else - pin = 4 - pin2 = nil - name = gpioname[i] - name2 = nil - end - end - elseif model[i] == "archer" then - start, ends = line:find("c20") - if start == nil then - pin = gpio[i] - pin2 = gpio2[i] - name = gpioname[i] - name2 = gpioname2[i] - end - elseif model[i] == "mt300n" then - start, ends = line:find("v2") - if start ~= nil then - pin = 11 - pin2 = nil - name = "usb" - name2 = nil - else - pin = gpio[i] - pin2 = nil - name = gpioname[i] - name2 = nil - end - else - pin = gpio[i] - pin2 = gpio2[i] - name = gpioname[i] - name2 = gpioname2[i] - end - break - end -end - -if pin ~= nil then - local tfile = io.open("/tmp/gpiopin", "w") - if pin2 ~= nil then - tfile:write("GPIOPIN=\"", pin, "\"\n") - tfile:write("GPIOPIN2=\"", pin2, "\"") - else - tfile:write("GPIOPIN=\"", pin, "\"") - end - tfile:close() -end -if name ~= nil then - local tfile = io.open("/tmp/gpioname", "w") - if name2 ~= nil then - tfile:write("GPIONAME=\"", name, "\"\n") - tfile:write("GPIONAME2=\"", name2, "\"") - else - tfile:write("GPIONAME=\"", name, "\"") - end - tfile:close() -else - os.remove("/tmp/gpioname") -end diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/idown.lua b/rooter/ext-rooter-basic/files/usr/lib/rooter/idown.lua deleted file mode 100644 index cda3061..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/idown.lua +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/lua - -cmd = arg[1] -interface = arg[2] - -function trim(s) - return (s:gsub("^%s*(.-)%s*$", "%1")) -end - -if interface ~= "wan" and interface ~= "wwan" then - s, e = interface:find("wan") - if s ~= nil then - mnum = trim(interface:sub(e+1)) - if cmd == "1" then - os.execute("/usr/lib/rooter/connect/disablemw3.sh " .. mnum) - line = "echo \"0\" > /tmp/mdown" .. mnum - else - line = "rm -f /tmp/mdown" .. mnum - end - os.execute(line) - end -end \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/initialize.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/initialize.sh deleted file mode 100644 index ff26398..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/initialize.sh +++ /dev/null @@ -1,295 +0,0 @@ -#!/bin/sh -. /lib/functions.sh - -ROOTER=/usr/lib/rooter -ROOTER_LINK="/tmp/links" - -CODENAME="ROOter " -if [ -f "/etc/codename" ]; then - source /etc/codename -fi - -# -# Set the maximum number of modems supported -# -MAX_MODEMS=2 -MODCNT=$MAX_MODEMS - -log() { - modlog "ROOter Initialize" "$@" -} - -do_zone() { - local config=$1 - local name - local network - - config_get name $1 name - config_get network $1 network - newnet=$network - if [ $name = wan ]; then - WAN1=$(echo $network | grep "wan1") - if [ -z $WAN1 ]; then - COUNTER=1 - while [ $COUNTER -le $MODCNT ]; do - newnet="$newnet wan$COUNTER" - let COUNTER=COUNTER+1 - done - uci_set firewall "$config" network "$newnet" - uci_commit firewall - /etc/init.d/firewall restart - fi - fi -} - -firstboot() { - HO=$(uci get system.@system[-1].hostname) - if [ $HO = "OpenWrt" ]; then - uci set system.@system[-1].hostname="OpenWrt" - echo "OpenWrt" > /proc/sys/kernel/hostname - fi - if [ $HO = "LEDE" ]; then - uci set system.@system[-1].hostname="LEDE" - echo "LEDE" > /proc/sys/kernel/hostname - fi - uci set system.@system[-1].cronloglevel="9" - uci commit system - - AP=$(uci -q get profile.default.apn) - if [ -z "$AP" ]; then - uci set profile.default.apn="internet" - uci commit profile - fi - - log "ROOter First Boot finalized" - - config_load firewall - config_foreach do_zone zone - - source /etc/openwrt_release - if [ $DISTRIB_RELEASE = "SNAPSHOT" ]; then - DISTRIB_RELEASE="master" - fi - tone=$(echo "$DISTRIB_RELEASE" | grep "master") -} - -if [ -e /tmp/installing ]; then - exit 0 -fi - - -log " Initializing Rooter" - -sed -i -e 's|/etc/savevar|#removed line|g' /etc/rc.local - -[ -f "/etc/firstboot" ] || { - firstboot -} - -mkdir -p $ROOTER_LINK - -uci delete modem.Version -uci set modem.Version=version -uci set modem.Version.ver=$CODENAME -uci commit modem - -source /etc/openwrt_release -rm -f /etc/openwrt_release -if [ $DISTRIB_RELEASE = "SNAPSHOT" ]; then - DISTRIB_RELEASE="master" -fi -if [ -e /etc/custom ]; then - lua $ROOTER/customname.lua - DISTRIB_DESCRIPTION=$(uci get modem.Version.ver) - DISTRIB_REVISION=" " -else - DISTRIB_DESCRIPTION=$(uci get modem.Version.ver)" ( "$DISTRIB_ID" "$DISTRIB_RELEASE" )" - DISTRIB_REVISION=" " -fi -echo "$(uci get modem.Version.ver)" > /etc/revision -echo 'DISTRIB_ID="'"$DISTRIB_ID"'"' >> /etc/openwrt_release -echo 'DISTRIB_RELEASE="'"$DISTRIB_RELEASE"'"' >> /etc/openwrt_release -echo 'DISTRIB_REVISION="'"$DISTRIB_REVISION"'"' >> /etc/openwrt_release -echo 'DISTRIB_CODENAME="'"$DISTRIB_CODENAME"'"' >> /etc/openwrt_release -echo 'DISTRIB_TARGET="'"$DISTRIB_TARGET"'"' >> /etc/openwrt_release -echo 'DISTRIB_DESCRIPTION="'"$DISTRIB_DESCRIPTION"'"' >> /etc/openwrt_release - -MODSTART=1 -WWAN=0 -USBN=0 -ETHN=1 -BASEPORT=0 -WDMN=0 -if - ifconfig eth1 &>/dev/null -then - if [ -e "/sys/class/net/eth1/device/bInterfaceProtocol" ]; then - ETHN=1 - else - ETHN=2 - fi -fi - -echo 'MODSTART="'"$MODSTART"'"' > /tmp/variable.file -echo 'WWAN="'"$WWAN"'"' >> /tmp/variable.file -echo 'USBN="'"$USBN"'"' >> /tmp/variable.file -echo 'ETHN="'"$ETHN"'"' >> /tmp/variable.file -echo 'WDMN="'"$WDMN"'"' >> /tmp/variable.file -echo 'BASEPORT="'"$BASEPORT"'"' >> /tmp/variable.file - -echo 'MODCNTX="'"$MODCNT"'"' > /tmp/modcnt -uci set modem.general.max=$MODCNT -uci set modem.general.modemnum=1 -uci set modem.general.smsnum=1 -uci set modem.general.miscnum=1 - -OPING=$(uci -q get modem.ping.alive) -if [ ! -z $OPING ]; then - uci delete modem.ping -fi - -ifname1="ifname" -if [ -n "$tone" -o -e /etc/newstyle ]; then - ifname1="device" -fi - -COUNTER=1 -while [ $COUNTER -le $MODCNT ]; do - uci delete modem.modem$COUNTER - uci set modem.modem$COUNTER=modem - uci set modem.modem$COUNTER.empty=1 - - IPEX=$(uci get modem.pinginfo$COUNTER.alive) - if [ -z $IPEX ]; then - uci set modem.pinginfo$COUNTER=pinfo$COUNTER - uci set modem.pinginfo$COUNTER.alive="0" - fi - - INEX=$(uci get modem.modeminfo$COUNTER) - if [ -z $INEX ]; then - uci set modem.modeminfo$COUNTER=minfo$COUNTER - fi - - rm -f $ROOTER_LINK/getsignal$COUNTER - rm -f $ROOTER_LINK/reconnect$COUNTER - rm -f $ROOTER_LINK/create_proto$COUNTER - $ROOTER/signal/status.sh $COUNTER "No Modem Present" - - uci -q delete network.wan$COUNTER - uci set network.wan$COUNTER=interface - uci set network.wan$COUNTER.proto=dhcp - uci set network.wan$COUNTER.metric=$COUNTER"0" - uci set network.wan$COUNTER.${ifname1}="wan"$COUNTER - - if [ -e /etc/config/mwan3 ]; then - ENB=$(uci -q get mwan3.wan$COUNTER.enabled) - if [ ! -z $ENB ]; then - uci set mwan3.wan$COUNTER.enabled=0 - fi - fi - - if [ -e /etc/config/failover ]; then - uci delete failover.Modem$COUNTER - uci set failover.Modem$COUNTER=member - fi - - let COUNTER=COUNTER+1 -done - -if [ -e /etc/config/failover ]; then - uci delete failover.Wan - EXX=$(uci get network.wan) - if [ ! -z $EXX ]; then - uci set failover.Wan=member - fi - uci delete failover.Hotspot - uci set failover.Hotspot=member - uci commit failover - ENB=$(uci get failover.enabled.enabled) - if [ $ENB = "1" ]; then - if [ -e $ROOTER/connect/failover.sh ]; then - log "Starting Failover System" - $ROOTER/connect/failover.sh & - fi - fi -fi - -PRO=$(uci -q get network.wan.proto) -if [ ! -z $PRO ]; then - uci set network.wan.metric="1" -fi - -SM=$(uci get modem.sms) -if [ -z $SM ]; then - uci set modem.sms="sms" - uci set modem.sms.menable="0" - uci set modem.sms.slots="0" -fi - -uci commit modem -uci commit network -if [ -e /etc/config/mwan3 ]; then - uci commit mwan3 -fi - -if [ -e $ROOTER/removeipv6.sh ]; then - $ROOTER/removeipv6.sh -fi - -if [ -e /etc/hotplug.d/10-motion ]; then - rm -f /etc/hotplug.d/10-motion -fi -if [ -e /etc/hotplug.d/20-mjpg-streamer ]; then - rm -f /etc/hotplug.d/20-mjpg-streamer -fi -if [ -e /etc/hotplug.d/50-printer ]; then - rm -f /etc/hotplug.d/50-printer -fi -if [ -e $ROOTER/special.sh ]; then - $ROOTER/special.sh -fi - -lua $ROOTER/gpiomodel.lua - -HO=$(uci get system.@system[-1].hostname) -if [ $HO = "OpenWrt" ]; then - uci set system.@system[-1].hostname="OpenWrt" - uci commit system -fi - -if [ -e /usr/lib/lua/luci/model/cbi/admin_system/cronnew.lua ]; then - mv -f /usr/lib/lua/luci/model/cbi/admin_system/cronnew.lua /usr/lib/lua/luci/model/cbi/admin_system/crontab.lua -fi - - -if [ -f "/etc/firstboot" ]; then - echo 'FIRSTBOOT="'"1"'"' > /etc/firstboot -else - echo 'FIRSTBOOT="'"0"'"' > /etc/firstboot - echo 'BOOTTIME="'"$(date +%s)"'"' > /tmp/boottime -fi - -# -# Added modems to various drivers -# -#source /etc/flash -#if [ "$FLASH" = "4" ]; then -#fi -#echo "413c 81b6" > /sys/bus/usb-serial/drivers/option1/new_id -echo "1546 1146" > /sys/bus/usb-serial/drivers/option1/new_id -echo "106c 3718" > /sys/bus/usb-serial/drivers/option1/new_id -#echo "1199 9091" > /sys/bus/usb-serial/drivers/option1/new_id - -# end of bootup -echo "0" > /tmp/bootend.file - -/etc/init.d/dnsmasq restart - -chown -R root:root /etc/dropbear/ -chmod 700 /etc/dropbear/ -chmod 644 /etc/dropbear/authorized_keys 2>/dev/null - -if [ ! -z $tone ]; then - [ -e /etc/newstyle ] || touch /etc/newstyle - #reboot -f -fi diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/log/at-logger b/rooter/ext-rooter-basic/files/usr/lib/rooter/log/at-logger deleted file mode 100644 index ca7d6e6..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/log/at-logger +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -TEXT=$1 -DATE=$(date +%c) - -echo " " >> /tmp/atlog -echo "$DATE : $TEXT" >> /tmp/atlog -lua $ROOTER/log/rotate.lua /tmp/atlog /tmp/attlog -mv /tmp/attlog /tmp/atlog - diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/log/logger b/rooter/ext-rooter-basic/files/usr/lib/rooter/log/logger deleted file mode 100644 index e78b574..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/log/logger +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -TEXT=$1 -DATE=$(date +%c) - -wc -l $ROOTER/log/connect.log > /tmp/linecnt -read lcnt fle < /tmp/linecnt -rm -f /tmp/linecnt -if [ $lcnt -ge 20 ]; then - start=$((lcnt-1)) - tail +$start $ROOTER/log/connect.log > /tmp/connect.log - mv /tmp/connect.log $ROOTER/log/connect.log -fi - -echo "$DATE : $TEXT" >> $ROOTER/log/connect.log diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/log/modlogger.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/log/modlogger.sh deleted file mode 100644 index fde69f7..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/log/modlogger.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -TEXT=$1 -DATE=$(date +%c) - -modlog="/tmp/modlog.log" -tmplog="/tmp/tmodlog" - -echo "$DATE : $TEXT" >> $modlog -lua $ROOTER/log/mrotate.lua $modlog $tmplog -mv $tmplog $modlog - -exit 0 - -wc -l $modlog > /tmp/linecnt -read lcnt fle < /tmp/linecnt -rm -f /tmp/linecnt -if [ $lcnt -ge 200 ]; then - start=$((lcnt-1)) - tail +$start modlog > $tmplog - mv $tmplog $modlog -fi - -echo "$DATE : $TEXT" >> $modlog diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/log/mrotate.lua b/rooter/ext-rooter-basic/files/usr/lib/rooter/log/mrotate.lua deleted file mode 100644 index 0a5317d..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/log/mrotate.lua +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/lua - -local uci = require "luci.model.uci".cursor() - -logfile = {} -infile = arg[1] -outfile = arg[2] - -i=0 -ifile = io.open(infile, "r") -if ifile == nil then - return -end -repeat - local line = ifile:read("*line") - if line == nil then - break - end - if string.len(line) > 1 then - i = i + 1 - logfile[i] = line - end -until 1==0 -ifile:close() - -maxs = 195 - -if i < maxs then - j = 1 -else - j = i - maxs - 1 -end -ofile = io.open(outfile, "w") -for k=j,i do - if logfile[k] ~= nil then - ofile:write(logfile[k] .. "\n") - end -end -ofile:close() \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/log/rotate.lua b/rooter/ext-rooter-basic/files/usr/lib/rooter/log/rotate.lua deleted file mode 100644 index f866446..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/log/rotate.lua +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/lua - -local uci = require "luci.model.uci".cursor() - -logfile = {} -infile = arg[1] -outfile = arg[2] - -i=0 -ifile = io.open(infile, "r") -if ifile == nil then - return -end -repeat - local line = ifile:read("*line") - if line == nil then - break - end - if string.len(line) > 1 then - i = i + 1 - logfile[i] = line - end -until 1==0 -ifile:close() - -bff = uci:get("variable", "info", "buffersize") -if bff == nil then - maxs = 50 -else - maxs = tonumber(bff) -end -if i < maxs then - j = 1 -else - j = i - maxs - 1 -end -ofile = io.open(outfile, "w") -for k=j,i do - if logfile[k] ~= nil then - ofile:write(logfile[k] .. "\n") - end -end -ofile:close() \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/logprint.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/logprint.sh deleted file mode 100644 index 779337f..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/logprint.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -# - -modlog "Log Print " "$1 $2 $3 $4 $5 $6" -exit 0 diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/atcmd.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/atcmd.sh deleted file mode 100644 index efda95d..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/atcmd.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter -ATCMDD=$1 - -CURRMODEM=$(uci get modem.general.miscnum) -COMMPORT="/dev/ttyUSB"$(uci get modem.modem$CURRMODEM.commport) - -M2=$(echo "$ATCMDD" | sed -e "s#~#\"#g") -COPS="+cops=?" -QOPS="+qops?" -M3=$(echo "$M2" | awk '{print tolower($0)}') -if `echo ${M3} | grep "${COPS}" 1>/dev/null 2>&1`; then - export TIMEOUT="120" -elif `echo ${M3} | grep "${QOPS}" 1>/dev/null 2>&1`; then - export TIMEOUT="120" -else - export TIMEOUT="5" -fi -OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$M2") -echo "$OX" > /tmp/result$CURRMODEM.at diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/celltype.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/celltype.sh deleted file mode 100644 index d1b3fb1..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/celltype.sh +++ /dev/null @@ -1,495 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -log() { - modlog "Cell type $CURRMODEM" "$@" -} - -zte_type() { - ATCMDD="AT+ZSNT?" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - OX=$($ROOTER/common/processat.sh "$OX") - ZSNT=$(echo "$OX" | awk -F[,\ ] '/^\+ZSNT:/ {print $2}') - if [ "x$ZSNT" != "x" ]; then - NETMODE="-" - if [ $ZSNT = "0" ]; then - ZSNTX=$(echo "$OX" | awk -F[,\ ] '/^\+ZSNT:/ {print $4}') - case $ZSNTX in - "0" ) - NETMODE="1" - ;; - "1" ) - NETMODE="2" - ;; - "2" ) - NETMODE="4" - ;; - "6" ) - NETMODE="6" - ;; - esac - else - case $ZSNT in - "1" ) - NETMODE="3" - ;; - "2" ) - NETMODE="5" - ;; - "6" ) - NETMODE="7" - ;; - esac - fi - fi - uci set modem.modem$CURRMODEM.modemtype="1" - uci set modem.modem$CURRMODEM.netmode=$NETMODE - uci commit modem -} - -sierra_type() { - ATCMDD="AT!SELRAT?" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - SELRAT=$(echo $OX | grep -o "!SELRAT:[^0-9]\+[0-9]\{2\}" | grep -o "[0-9]\{2\}") - if [ -n "$SELRAT" ]; then - case $SELRAT in - "01" ) - NETMODE="5" - ;; - "02" ) - NETMODE="3" - ;; - "06" ) - NETMODE="7" - ;; - * ) - NETMODE="1" - ;; - esac - fi - uci set modem.modem$CURRMODEM.modemtype="2" - uci set modem.modem$CURRMODEM.netmode=$NETMODE - uci commit modem -} - -huawei_type() { - ATCMDD="AT^SYSCFGEX?" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - OX=$($ROOTER/common/processat.sh "$OX") - SYSCFG=$(echo "$OX" | awk -F[,\"] '/^\^SYSCFGEX:/ {print $2}') - if [ "x$SYSCFG" != "x" ]; then - NETMODE="-" - case $SYSCFG in - "00" ) - NETMODE="1" - ;; - "01" ) - NETMODE="3" - ;; - "02" ) - NETMODE="5" - ;; - "03" ) - NETMODE="7" - ;; - * ) - ACQ=${SYSCFG:0:2} - case $ACQ in - "01" ) - NETMODE="2" - ;; - "02" ) - NETMODE="4" - ;; - "03" ) - NETMODE="6" - ;; - esac - ;; - esac - uci set modem.modem$CURRMODEM.modemtype="3" - else - ATCMDD="AT^SYSCFG?" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - OX=$($ROOTER/common/processat.sh "$OX") - SYSCFG=$(echo "$OX" | awk -F[,\ ] '/^\^SYSCFG:/ {print $2}') - if [ "x$SYSCFG" != "x" ]; then - NETMODE="-" - case $SYSCFG in - "7" ) - NETMODE="1" - ;; - "13" ) - NETMODE="3" - ;; - "14" ) - NETMODE="5" - ;; - * ) - SYSCFG=$(echo "$OX" | awk -F[,\ ] '/^\^SYSCFG:/ {print $3}') - case $SYSCFG in - "0" ) - NETMODE="1" - ;; - "1" ) - NETMODE="2" - ;; - "2" ) - NETMODE="4" - ;; - esac - ;; - esac - uci set modem.modem$CURRMODEM.modemtype="4" - fi - fi - uci set modem.modem$CURRMODEM.netmode=$NETMODE - uci commit modem -} - -ublox_type() { - ATCMDD="AT+URAT?" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - URAT=$(echo $OX" " | grep -o "+URAT: .\+ OK " | tr " " ",") - URAT1=$(echo $URAT | cut -d, -f2) - URAT2=$(echo $URAT | cut -d, -f3) - if [ -n "$URAT1" ]; then - NETMODE="-" - case $URAT1 in - "0" ) - NETMODE="3" - ;; - "2" ) - NETMODE="5" - ;; - "3" ) - NETMODE="7" - ;; - * ) - case $URAT2 in - "0" ) - NETMODE="2" - ;; - "2" ) - NETMODE="4" - ;; - "3" ) - NETMODE="1" - ;; - esac - ;; - esac - uci set modem.modem$CURRMODEM.modemtype="5" - fi - uci set modem.modem$CURRMODEM.netmode=$NETMODE - uci commit modem -} - -quectel_type() { - idVidP=$idV":"$idP - ATCMDD="AT+CGMM" - model=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - EM20=$(echo "$model" | grep "EM20") - if [ $EM20 ]; then - idVidP=$idV":"$idP"0" - fi - if [ "$idVidP" == "2c7c:0800" -o "$idVidP" == "2c7c:0620" -o "$idVidP" == "2c7c:030b" -o "$idVidP" == "2c7c:0801" -o "$idVidP" == "2c7c:0900" ]; then - ATCMDD="AT+QNWPREFCFG=\"mode_pref\"" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - QNSM=$(echo $OX | grep -o ",[AUTOLENR5GWCDM:]\+" | tr ',' ' ') - QNSM=$(echo $QNSM) - if [ -n "$QNSM" ]; then - case $QNSM in - "AUTO" ) - NETMODE="1" - ;; - "LTE" ) - NETMODE="7" - ;; - "LTE:NR5G" ) - NETMODE="8" - ;; - "NR5G" ) - NETMODE="9" - ;; - "WCDMA" ) - NETMODE="5" - ;; - esac - uci set modem.modem$CURRMODEM.modemtype="6" - fi - else - ATCMDD="AT+QCFG=\"nwscanmode\"" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - QNSM=$(echo $OX | grep -o "+QCFG: \"nwscanmode\",[0-9]" | grep -o "[0-9]") - if [ -n "$QNSM" ]; then - case $QNSM in - "0" ) - NETMODE="1" - ;; - "1" ) - NETMODE="3" - ;; - "2"|"5" ) - NETMODE="5" - ;; - "3" ) - NETMODE="7" - ;; - esac - uci set modem.modem$CURRMODEM.modemtype="6" - fi - fi - uci set modem.modem$CURRMODEM.netmode=$NETMODE - uci commit modem -} - -meig_type() { - if [ $idV == "2dee" ]; then - ATCMDD="AT^SYSCFGEX?" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - RATs=$(echo "$OX" | grep -o "\^SYSCFGEX: \"[0-9]\{2,6\}\"" | grep -o "[0-9]\{2,6\}") - if [ -n "$RATs" ]; then - case $RATs in - "02" ) - NETMODE="5" ;; - "03" ) - NETMODE="7" ;; - "04" ) - NETMODE="9" ;; - "0203" | "0204" | "020304" | "020403" ) - NETMODE="4" ;; - "0304" | "0302" | "030402" | "030204" ) - NETMODE="6" ;; - "0403" ) - NETMODE="8" ;; - * ) - NETMODE="1" ;; - esac - fi - else - ATCMDD="AT+MODODR?" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - MODODR=$(echo $OX | grep -o "[0-9]") - if [ -n "$MODODR" ]; then - case $MODODR in - "1"|"8" ) - NETMODE="5" ;; - "2" ) - NETMODE="1" ;; - "3" ) - NETMODE="3" ;; - "5" ) - NETMODE="7" ;; - esac - fi - fi - uci set modem.modem$CURRMODEM.modemtype="7" - uci set modem.modem$CURRMODEM.netmode=$NETMODE - uci commit modem -} - -telit_type() { - ATCMDD="AT^SYSCONFIG?" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - SCFG=$(echo $OX | grep -o "\^SYSCONFIG: [0-9]\{1,2\}" | grep -o "[0-9]\{1,2\}") - if [ -n "$SCFG" ]; then - PREF=$(echo $OX | grep -o "\^SYSCONFIG: 2,[0-9]" | grep -o ",[0-9]") - case $SCFG in - "13" ) - NETMODE="3" ;; - "14" ) - NETMODE="5" ;; - "17" ) - NETMODE="7" ;; - * ) - NETMODE="1" ;; - esac - uci set modem.modem$CURRMODEM.modemtype="8" - fi - uci set modem.modem$CURRMODEM.netmode=$NETMODE - uci commit modem -} - -fibocom_type() { - NETMODE="" - idPP=${idP:1:1} - if [ "$idPP" = "1" ]; then - ATCMDD="AT+GTRAT?" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - MRAT=$(echo $OX | grep -o "+GTRAT: [0-9]\{1,2\}" | grep -o "[0-9]\{1,2\}") - if [ -n "$MRAT" ]; then - case $MRAT in - "2" ) - NETMODE="5" ;; - "3" ) - NETMODE="7" ;; - "14" ) - NETMODE="9" ;; - "17" ) - NETMODE="8" ;; - * ) - NETMODE="1" ;; - esac - fi - else - ATCMDD="AT+XACT?" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - XACT=$(echo $OX | grep -o "+XACT: [0-9]" | grep -o "[0-9]") - if [ -n "$XACT" ]; then - PREF=$(echo $OX | grep -o "+XACT: [0-9],[0-9]" | grep -o ",[0-9]") - case $XACT in - "1" ) - NETMODE="5" ;; - "2" ) - NETMODE="7" ;; - "4" ) - if [ "$PREF" = ",1" ]; then - NETMODE="4" - else - NETMODE="6" - fi ;; - * ) - NETMODE="6" ;; - esac - - fi - fi - uci set modem.modem$CURRMODEM.modemtype="9" - uci set modem.modem$CURRMODEM.netmode=$NETMODE - uci commit modem -} - -simcom_type() { - ATCMDD="AT+CNMP?" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - CNMP=$(echo "$OX" | grep -o "+CNMP:[ ]*[0-9]\{1,3\}" | grep -o "[0-9]\{1,3\}") - if [ -n "$CNMP" ]; then - case $CNMP in - "2"|"55" ) - NETMODE="1" ;; - "13" ) - NETMODE="3" ;; - "14" ) - NETMODE="5" ;; - "38" ) - NETMODE="7" ;; - "71" ) - NETMODE="9" ;; - "109" ) - NETMODE="8" ;; - * ) - NETMODE="0" ;; - esac - fi - uci set modem.modem$CURRMODEM.modemtype="10" - uci set modem.modem$CURRMODEM.netmode=$NETMODE - uci commit modem -} - -quanta_type() { - ATCMDD="AT^QCNCFG?" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - TECH=$(echo $OX | grep -o "\^QCNCFG: \"[0123]\{2\}\"" | grep -o "[0123]\{2\}") - case $TECH in - "02") - NETMODE="5" - ;; - "03") - NETMODE="7" - ;; - *) - NETMODE="1" - ;; - esac - uci set modem.modem$CURRMODEM.modemtype="11" - uci set modem.modem$CURRMODEM.netmode=$NETMODE - uci commit modem -} - -CURRMODEM=$1 -COMMPORT="/dev/ttyUSB"$(uci get modem.modem$CURRMODEM.commport) - -idV=$(uci get modem.modem$CURRMODEM.idV) -idP=$(uci -q get modem.modem$CURRMODEM.idP) -NETMODE="-" - -# This case statement should be kept in sync with: $ROOTER/signal/modemsignal.sh -case $idV in -"1199"|"0f3d" ) - sierra_type - ;; -"19d2" ) - if [ $idP = 1432 ]; then - telit_type - else - zte_type - fi - ;; -"12d1" ) - huawei_type - ;; -"2c7c" ) - quectel_type - ;; -"2cb7"|"1508"|"8087" ) - fibocom_type - ;; -"2dee" ) - meig_type - ;; -"05c6" ) - case $idP in - "f601" ) - meig_type - ;; - "5042" ) - telit_type - ;; - "9090"|"9003"|"9215" ) - quectel_type - ;; - "90db" ) - simcom_type - ;; - * ) - : - ;; - esac - ;; -"1bc7" ) - telit_type - ;; -"1410" ) - : - ;; -"413c" ) - case $idP in - "81d7"|"81d8" ) - telit_type - ;; - * ) - sierra_type - ;; - esac - ;; -"0489" |"03f0" ) - telit_type - ;; -"1e0e" ) - simcom_type - ;; -"8087" ) - if [ $idP = "095a" ]; then - fibocom_type - fi - ;; -"0408" ) - quanta_type - ;; -* ) - : - ;; -esac -exit diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/em060-2xbands b/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/em060-2xbands deleted file mode 100644 index aa600ca..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/em060-2xbands +++ /dev/null @@ -1,29 +0,0 @@ -2 2 -2 5 -2 12 -2 13 -2 39 -4 4 -4 5 -4 12 -4 13 -4 29 -5 5 -5 7 -5 25 -5 30 -5 66 -7 7 -7 12 -7 26 -12 12 -12 25 -12 30 -12 66 -13 66 -25 25 -25 26 -30 29 -66 29 -66 66 -41 41 diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/em12-2xbands b/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/em12-2xbands deleted file mode 100644 index 307919e..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/em12-2xbands +++ /dev/null @@ -1,46 +0,0 @@ -1 3 -1 5 -1 18 -1 19 -1 20 -1 26 -2 2 -2 4 -2 5 -2 12 -2 13 -2 17 -2 29 -2 30 -2 66 -3 3 -3 5 -2 7 -3 8 -3 19 -3 20 -3 28 -4 4 -4 5 -4 12 -4 13 -4 17 -4 19 -4 30 -5 7 -5 30 -5 66 -7 7 -7 20 -7 28 -12 30 -13 66 -19 21 -20 32 -29 30 -38 38 -39 39 -39 41 -40 40 -41 41 -66 66 \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/em12-3xbands b/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/em12-3xbands deleted file mode 100644 index 43f7600..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/em12-3xbands +++ /dev/null @@ -1,43 +0,0 @@ -1 3 5 -1 3 7 -1 3 8 -1 3 19 -1 3 20 -1 3 28 -1 7 20 -2 4 5 -2 4 13 -2 5 30 -2 12 30 -2 29 30 -3 7 20 -3 7 28 -3 7 8 -4 5 30 -4 12 30 -4 29 30 -5 66 2 -13 66 2 -66 12 30 -66 29 30 -66 5 30 -2 14 66 -2 2 5 -2 2 13 -3 3 7 -3 7 7 -3 3 20 -3 3 28 -3 3 1 -4 4 5 -4 4 13 -7 7 28 -5 66 66 -13 66 66 -66 66 2 -14 66 66 -39 39 41 -39 41 41 -40 40 40 -41 41 41 -66 66 66 \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/em20-2xbands b/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/em20-2xbands deleted file mode 100644 index 74a2677..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/em20-2xbands +++ /dev/null @@ -1,50 +0,0 @@ -1 3 -1 5 -1 18 -1 19 -1 20 -1 26 -2 2 -2 4 -2 5 -2 12 -2 13 -2 14 -2 17 -2 29 -2 30 -2 66 -3 3 -3 5 -2 7 -3 8 -3 19 -3 20 -3 28 -4 4 -4 5 -4 12 -4 13 -4 17 -4 19 -4 30 -5 7 -5 30 -5 66 -7 7 -7 20 -7 28 -12 30 -13 66 -14 30 -14 66 -29 30 -38 38 -39 39 -39 41 -40 40 -41 41 -66 5 -66 12 -66 29 -66 30 \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/em20-3xbands b/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/em20-3xbands deleted file mode 100644 index 701af64..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/em20-3xbands +++ /dev/null @@ -1,41 +0,0 @@ -1 3 5 -1 3 7 -1 3 19 -1 3 20 -1 3 28 -1 7 20 -2 4 5 -2 4 13 -2 5 30 -2 12 30 -2 29 30 -3 7 20 -3 7 28 -3 7 8 -4 5 30 -4 12 30 -4 29 30 -5 66 2 -13 66 2 -66 12 30 -66 29 30 -66 5 30 -2 14 66 -2 2 5 -2 2 13 -3 3 7 -3 7 7 -3 3 20 -3 3 28 -4 4 5 -4 4 13 -7 7 28 -5 66 66 -13 66 66 -39 39 41 -39 41 41 -40 40 40 -41 41 41 -66 66 2 -14 66 66 -66 66 66 \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/em20-4xbands b/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/em20-4xbands deleted file mode 100644 index 5489ad5..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/em20-4xbands +++ /dev/null @@ -1,8 +0,0 @@ -1 1 3 28 0 -1 3 40 40 0 -1 3 7 7 0 -1 3 3 7 7 -1 3 3 40 40 -1 3 7 7 28 -2 13 66 66 0 -3 3 7 7 28 \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/em7411-2xbands b/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/em7411-2xbands deleted file mode 100644 index 4667685..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/em7411-2xbands +++ /dev/null @@ -1,29 +0,0 @@ -2 2 -2 5 -2 7 -2 12 -2 13 -2 14 -2 71 -4 4 -4 5 -4 7 -4 12 -4 13 -4 71 -5 5 -5 66 -7 7 -7 12 -12 66 -13 66 -14 66 -25 25 -25 26 -26 41 -41 41 -42 42 -43 43 -48 48 -66 66 -66 71 \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/em7411-3xbands b/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/em7411-3xbands deleted file mode 100644 index a50f0f9..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/em7411-3xbands +++ /dev/null @@ -1,8 +0,0 @@ -2 2 2 -7 7 7 -12 12 12 -41 41 41 -42 42 42 -43 43 43 -48 48 48 -66 66 66 \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/em7511-2xbands b/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/em7511-2xbands deleted file mode 100644 index ea770ac..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/em7511-2xbands +++ /dev/null @@ -1,60 +0,0 @@ -1 3 -1 5 -1 7 -1 8 -1 18 -1 19 -1 20 -1 26 -1 41 -1 42 -2 2 -2 4 -2 5 -2 12 -2 13 -2 28 -2 29 -2 30 -2 46 -2 66 -3 3 -3 5 -3 7 -3 8 -3 19 -3 20 -3 28 -3 41 -3 42 -4 4 -4 5 -4 7 -4 12 -4 13 -4 28 -4 29 -4 30 -4 46 -5 5 -5 7 -5 30 -5 46 -5 66 -7 7 -7 20 -7 28 -12 30 -12 66 -13 46 -13 66 -19 42 -20 32 -28 42 -29 30 -29 66 -30 66 -41 41 -41 42 -42 42 -48 48 \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/em7511-3xbands b/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/em7511-3xbands deleted file mode 100644 index f64b670..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/em7511-3xbands +++ /dev/null @@ -1,55 +0,0 @@ -1 3 5 -1 3 7 -1 3 8 -1 3 19 -1 3 20 -1 3 28 -1 5 7 -1 7 20 -1 7 7 -1 42 42 -2 2 5 -2 2 12 -2 2 13 -2 4 5 -2 4 7 -2 4 12 -2 4 13 -2 4 29 -2 5 30 -2 5 66 -2 7 7 -2 7 12 -2 12 30 -2 13 66 -2 29 30 -2 66 66 -3 3 5 -3 3 7 -3 7 7 -3 7 20 -3 7 28 -3 41 42 -3 41 41 -3 42 42 -4 4 5 -4 4 12 -4 4 13 -4 4 30 -4 5 30 -4 7 7 -4 7 12 -4 12 30 -4 29 30 -5 30 66 -5 66 66 -7 7 28 -12 30 66 -13 66 66 -19 42 42 -29 30 66 -41 42 42 -41 41 42 -41 41 41 -48 48 48 -66 66 66 \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/em7565-2xbands b/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/em7565-2xbands deleted file mode 100644 index 3ff2f85..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/em7565-2xbands +++ /dev/null @@ -1,14 +0,0 @@ -1 18 -1 26 -1 41 -2 2 -2 28 -2 46 -4 28 -4 46 -5 5 -5 46 -20 32 -41 41 -42 42 -48 48 \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/em7565-3xbands b/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/em7565-3xbands deleted file mode 100644 index 61b39c8..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/em7565-3xbands +++ /dev/null @@ -1,51 +0,0 @@ -1 3 5 -1 3 7 -1 3 8 -1 3 19 -1 3 20 -1 3 28 -1 42 42 -2 2 5 -2 2 12 -2 2 13 -2 4 5 -2 4 7 -2 4 12 -2 4 13 -2 4 29 -2 5 30 -2 5 66 -2 7 7 -2 7 12 -2 12 30 -2 13 66 -2 29 30 -2 66 66 -3 3 5 -3 3 7 -3 3 20 -3 3 28 -3 7 7 -3 7 20 -3 7 28 -3 41 42 -3 41 41 -3 42 42 -4 4 5 -4 4 12 -4 4 13 -4 4 30 -4 7 7 -4 7 12 -4 12 30 -4 29 30 -5 30 66 -5 66 66 -7 7 28 -12 30 66 -13 66 66 -29 30 66 -41 42 41 -41 41 42 -48 48 48 -66 66 66 \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/ep06a-bands b/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/ep06a-bands deleted file mode 100644 index e9565cd..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/ep06a-bands +++ /dev/null @@ -1,27 +0,0 @@ -2 2 -5 5 -2 12 -2 13 -2 29 -4 4 -4 5 -4 12 -4 13 -4 29 -7 5 -7 7 -7 12 -7 26 -25 5 -25 12 -25 25 -25 26 -30 5 -30 12 -30 29 -41 41 -66 5 -66 12 -66 13 -66 29 -66 66 \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/ep06e-bands b/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/ep06e-bands deleted file mode 100644 index 0937585..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/ep06e-bands +++ /dev/null @@ -1,32 +0,0 @@ -1 5 -1 8 -1 20 -1 28 -1 1 -3 5 -3 7 -3 8 -3 20 -3 28 -3 3 -5 38 -5 40 -5 41 -7 5 -7 8 -7 20 -7 28 -7 7 -8 38 -8 40 -8 41 -20 32 -20 38 -20 40 -20 41 -28 38 -28 40 -28 41 -38 38 -40 40 -41 41 diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/l850-2xbands b/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/l850-2xbands deleted file mode 100644 index 540bd0a..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/l850-2xbands +++ /dev/null @@ -1,35 +0,0 @@ -1 3 -1 5 -1 18 -1 19 -1 20 -1 21 -1 26 -2 4 -2 5 -2 12 -2 13 -2 17 -2 29 -2 30 -2 66 -3 5 -3 7 -3 8 -3 19 -3 20 -3 28 -4 5 -4 12 -4 13 -4 17 -4 29 -4 30 -5 7 -5 30 -5 66 -7 20 -7 28 -12 30 -13 66 -29 30 \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/l850-3xbands b/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/l850-3xbands deleted file mode 100644 index 29632c3..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/l850-3xbands +++ /dev/null @@ -1,27 +0,0 @@ -1 3 7 -1 3 19 -1 3 20 -1 19 21 -2 4 5 -2 4 13 -2 5 30 -2 12 30 -2 29 30 -3 7 20 -3 7 28 -4 5 30 -4 12 30 -4 29 30 -5 66 2 -13 66 2 -2 2 5 -2 2 13 -3 3 7 -3 7 7 -3 3 20 -4 4 5 -4 4 13 -5 66 66 -13 66 66 -66 66 2 -66 66 66 \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/lock.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/lock.sh deleted file mode 100644 index 236576c..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/lock.sh +++ /dev/null @@ -1,395 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter -ROOTER_LINK="/tmp/links" - -log() { - modlog "Lock Band $CURRMODEM" "$@" -} - -RESTART="1" - -ifname1="ifname" -if [ -e /etc/newstyle ]; then - ifname1="device" -fi - -fibdecode() { - j=$1 - tdec=$2 - mod=$3 - length=${#j} - jx=$j - length=${#jx} - - str="" - i=$((length-1)) - while [ $i -ge 0 ] - do - dgt="0x"${jx:$i:1} - DecNum=`printf "%d" $dgt` - Binary= - Number=$DecNum - while [ $DecNum -ne 0 ] - do - Bit=$(expr $DecNum % 2) - Binary=$Bit$Binary - DecNum=$(expr $DecNum / 2) - done - if [ -z $Binary ]; then - Binary="0000" - fi - len=${#Binary} - while [ $len -lt 4 ] - do - Binary="0"$Binary - len=${#Binary} - done - revstr="" - length=${#Binary} - ii=$((length-1)) - while [ $ii -ge 0 ] - do - revstr=$revstr${Binary:$ii:1} - ii=$((ii-1)) - done - str=$str$revstr - i=$((i-1)) - done - - len=${#str} - ii=0 - lst="" - sep="," - hun=101 - if [ $mod = "1" ]; then - sep=":" - hun=1 - fi - if [ $mod = "2" ]; then - sep="," - hun=1 - fi - while [ $ii -lt $len ] - do - bnd=${str:$ii:1} - if [ $bnd -eq 1 ]; then - if [ $tdec -eq 1 ]; then - jj=$((ii+hun)) - else - if [ $ii -lt 9 ]; then - jj=$((ii+501)) - else - jj=$((ii+5001)) - fi - fi - if [ -z "$lst" ]; then - lst=$jj - else - lst=$lst$sep$jj - fi - fi - ii=$((ii+1)) - done - if [ -z $lst ]; then - lst="0" - fi -} - -encode() { - maskz=$1 - length=${#maskz} - i=0 - ii=1 - lst="" - ij=$((length-1)) - while [ $i -le $ij ] - do - dgt=${maskz:$i:1} - if [ $dgt == "1" ]; then - lst=$lst$ii" " - fi - i=$((i+1)) - ii=$((ii+1)) - done - maskz=$(encodemask $lst) - maskz=$(echo $maskz | sed 's/^0*//') -} - -maskx=$1 -mask64=$(echo "$maskx""," | cut -c1-64 | cut -d, -f1) -maskl2=$(echo ${maskx:64}"," | cut -d, -f1) -maskc=$(echo "$maskx" | grep ",") -if [ ! -z "$maskc" ]; then - mask=$(echo $maskx"," | cut -d, -f1) - mask5g=$(echo $maskx"," | cut -d, -f2) - mask5gsa=$(echo $maskx"," | cut -d, -f3) -else - mask=$maskx - mask5g="" - mask5gsa="" -fi - -#log "$mask" -#log "$mask5g" -#log "$mask5gsa" - -encode $mask -mask=$maskz -encode $mask5g -mask5g=$maskz -encode $mask5gsa -mask5gsa=$maskz -encode $mask64 -mask64=$maskz -encode $maskl2 -if [ -z $maskz ]; then - maskl2="0" -else - maskl2=$maskz -fi -if [ -z $mask64 ]; then - mask64="0" -fi - -if [ -z "$2" ]; then - CURRMODEM=$(uci get modem.general.miscnum) -else - CURRMODEM=1 -fi -COMMPORT="/dev/ttyUSB"$(uci get modem.modem$CURRMODEM.commport) -CPORT=$(uci -q get modem.modem$CURRMODEM.commport) -model=$(uci get modem.modem$CURRMODEM.model) -uVid=$(uci get modem.modem$CURRMODEM.uVid) -uPid=$(uci get modem.modem$CURRMODEM.uPid) -GW=$(uci -q get modem.modem$CURRMODEM.GW) - -export TIMEOUT="5" -case $uVid in - "2c7c" ) - MODT="1" - if [ -z "$2" ]; then - RESTART="1" - fi - M5="" - M2='AT+QCFG="band",0,'$mask',0,1' - if [ $uPid = 0620 ]; then - EM20=$(echo $model | grep "EM20") - if [ -z "$EM20" ]; then #EM160 - if [ ! -z $mask ]; then - fibdecode $mask 1 1 - else - lst="0" - fi - M2='AT+QNWPREFCFG="lte_band",'$lst - else # Fake EM160 RM500 - if [ -e /etc/qfake ]; then - if [ ! -z $mask ]; then - fibdecode $mask 1 1 - else - lst="0" - fi - M2F='AT+QNWPREFCFG="lte_band",'$lst - if [ ! -z $mask5g ]; then - fibdecode $mask5g 1 1 - else - lst="0" - fi - M5F='AT+QNWPREFCFG="nsa_nr5g_band",'$lst - NET=$(uci -q get modem.modem$CURRMODEM.netmode) - if [ $NET = "9" ]; then - M5F='AT+QNWPREFCFG="nr5g_band",'$lst - fi - log " " - log "Fake LTE Locking Cmd : $M2F" - log "Fake 5G Locking Cmd : $M5F" - log " " - #rm -f /tmp/bmask - exit 0 - fi - fi - fi - if [ $uPid = 030b ]; then - if [ ! -z $mask ]; then - fibdecode $mask 1 1 - else - lst="0" - fi - M2='AT+QNWPREFCFG="lte_band",'$lst - fi - if [ $uPid = 0306 ]; then - RESTART="1" - fi - if [ $uPid = 0800 -o $uPid = 0900 -o $uPid = 0801 ]; then - if [ ! -z "$mask" ]; then - fibdecode $mask 1 1 - else - lst="0" - fi - M2='AT+QNWPREFCFG="lte_band",'$lst - if [ ! -z "$mask5g" ]; then - fibdecode $mask5g 1 1 - else - lst="0" - fi - M5='AT+QNWPREFCFG="nsa_nr5g_band",'$lst - if [ ! -z "$mask5gsa" ]; then - fibdecode $mask5gsa 1 1 - else - lst="0" - fi - M6='AT+QNWPREFCFG="nr5g_band",'$lst - fi - log " " - log "Locking Cmd : $M2" - log "Locking Cmd : $M5" - log "Locking Cmd : $M6" - log " " - - ATCMDD="AT" - NOCFUN=$uVid - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$M2") - if [ ! -z "$M5" ]; then - OX5=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$M5") - fi - if [ ! -z "$M6" ]; then - OX6=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$M6") - fi - log "Locking Cmd Response : $OX" - log "Locking Cmd Response : $OX5" - log "Locking Cmd Response : $OX6" - log " " - if [ $RESTART = "1" ]; then - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - sleep 10 - fi - ;; - "1199" ) - MODT="0" - M1='AT!ENTERCND="A710"' - if [ -z $mask64 ]; then - mask64="0" - fi - case $uPid in - - "68c0"|"9041"|"901f" ) # MC7354 EM/MC7355 - M2='AT!BAND=11,"Test",0,'$mask64,0 - ;; - "9070"|"9071"|"9078"|"9079"|"907a"|"907b" ) # EM/MC7455 - M2='AT!BAND=11,"Test",0,'$mask64,0 - if [ -e /etc/fake ]; then - M2='AT!BAND=11,"Test",0,'$mask64','$maskl2',0,0,0' - fi - ;; - "9090"|"9091"|"90b1" ) - M2='AT!BAND=11,"Test",0,'$mask64','$maskl2',0,0,0' - ;; - esac - log "$M2" - if [ -e /etc/fake ]; then - exit 0 - fi - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$M1") - log "$OX" - ATCMDD="AT+CFUN=1,1" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$M2") - log "$OX" - M2='AT!BAND=00;!BAND=11' - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$M2") - log "$OX" - if [ $RESTART = "1" ]; then - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - ATCMDD='AT!ENTERCND="AWRONG"' - fi - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - ;; - "8087"|"2cb7" ) - MODT="2" - FM150="" - if [ $uVid = 2cb7 ]; then - FM150=$(echo $model | grep "FM150") - if [ -z $FM150 ]; then - COMM="XACT" - else - COMM="GTACT" - fi - else - COMM="XACT" - fi - ATCMDD='AT+'$COMM'?' - log " " - log " Get Current Bands : $ATCMDD" - log " " - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - log " " - log " Get Current Bands Response : $OX" - log " " - - lte="" - if [ ! -z $mask ]; then - fibdecode $mask 1 0 - lte=","$lst - fi - L1="4,2,1" - lst="" - if [ ! -z $FM150 ]; then - L1="17,6," - if [ ! -z $mask5g ]; then - fibdecode $mask5g 5 0 - lst=","$lst - else - L1="4,3," - fi - fi - ATCMDD="AT+""$COMM"="$L1$lte$lst" - log " " - log "Lock Command : $ATCMDD" - log " " - - #exit 0 - - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - log " " - log "Lock Response : $OX" - log " " - if [ $RESTART = "1" ]; then - ATCMDD="AT+CFUN=1,1" - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - fi - ;; - "413c" ) - MODT="3" - case $uPid in - - "81d7"|"81d8"|"e0b4" |"e0b5"|"1910") - if [ ! -z $mask ]; then - fibdecode $mask 1 2 - ATCMDD="AT^SLBAND=LTE,2,""$lst" - log "$ATCMDD" - else - exit 0 - fi - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - log " " - log "Lock Response : $OX" - log " " - if [ $RESTART = "1" ]; then - ATCMDD="AT+CFUN=1,1" - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - fi - ;; - esac - ;; - * ) - exit 0 - ;; -esac - -if [ $RESTART = "0" ]; then - /usr/lib/rooter/connect/bandmask $CURRMODEM $MODT - exit 0 -fi -rm -f /tmp/bmask -/usr/lib/rooter/luci/restart.sh $CURRMODEM -/usr/lib/rooter/connect/bandmask $CURRMODEM $MODT -exit 0 diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/luaops.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/luaops.sh deleted file mode 100644 index b05855f..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/luaops.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -COMMAND=$1 -FILE=$2 - -if [ $COMMAND = delete ]; then - rm -f $FILE -fi \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/mask.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/mask.sh deleted file mode 100644 index 40a868d..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/mask.sh +++ /dev/null @@ -1,332 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -log() { - modlog "BandMasking $CURRMODEM" "$@" -} - -# -# remove for band locking -# -enb=$(uci -q get custom.bandlock.enabled) -if [ $enb == "0" ]; then - exit 0 -fi - -reverse() { - LX=$1 - length=${#LX} - jx="${LX:2:length-2}" - length=${#jx} - str="" - i=$((length-1)) - while [ $i -ge 0 ] - do - dgt="0x"${jx:$i:1} - DecNum=`printf "%d" $dgt` - Binary= - Number=$DecNum - while [ $DecNum -ne 0 ] - do - Bit=$(expr $DecNum % 2) - Binary=$Bit$Binary - DecNum=$(expr $DecNum / 2) - done - if [ -z $Binary ]; then - Binary="0000" - fi - len=${#Binary} - while [ $len -lt 4 ] - do - Binary="0"$Binary - len=${#Binary} - done - revstr="" - length=${#Binary} - ii=$((length-1)) - while [ $ii -ge 0 ] - do - revstr=$revstr${Binary:$ii:1} - ii=$((ii-1)) - done - str=$str$revstr - i=$((i-1)) - done - revstr=$str"0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" -} - -rm -f /tmp/bmask -CURRMODEM=$(uci get modem.general.miscnum) -CPORT="/dev/ttyUSB"$(uci get modem.modem$CURRMODEM.commport) -uVid=$(uci get modem.modem$CURRMODEM.uVid) -uPid=$(uci get modem.modem$CURRMODEM.uPid) -ATCMDD="AT+CGMM" -model=$($ROOTER/gcom/gcom-locked "$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") -L1=$(uci -q get modem.modem$CURRMODEM.L1) -L5=$(uci -q get modem.modem$CURRMODEM.L5) -L6=$(uci -q get modem.modem$CURRMODEM.L6) - -if [ ! $L1 ]; then - exit 0 -fi - -CA3="" -M5="x" -M6="x" -case $uVid in - "2c7c" ) - case $uPid in - "0125" ) # EC25 - #EUX EC25EUXGAR B1/B3/B7/B8/B20/B28A/B38/B40/B41 - #EU EC25EUGAR B1/B3/B7/B8/B20/B28A/B38/B40/B41 - #EC EC25ECGAR - #E EC25EFAR B1/B3/B5/B7/B8/B20/B38/B40/B41 - #AU EC25AUGCR - #AF-FD EC25AFFDR B2/B4/B5/B12/B13/B14/B66/B71 - #AF EC25AFFAR B2/B4/B5/B12/B13/B14/B66/B71 - #A EC25AFAR - CA="" - M1='ATI' - OX=$($ROOTER/gcom/gcom-locked "$CPORT" "run-at.gcom" "$CURRMODEM" "$M1") - REV=$(echo $OX" " | grep -o "Revision: .\+ OK " | tr " " ",") - MODL=$(echo $REV | cut -d, -f2) - EC25AF=$(echo $MODL | grep "EC25AFF") - if [ ! -z "$EC25AF" ]; then # EC25-AF - M2='01011000000111000000000000000000000000000000000000000000000000000100001' - else - EC25AF=$(echo $MODL | grep "EC25E") - if [ ! -z "$EC25AF" ]; then # EC25-E - M2='1010101100000000000100000000000000000101100' - else - EC25AF=$(echo $MODL | grep "EC25AU") - if [ ! -z "$EC25AF" ]; then # EC25-AU - M2='111110110000000000000000000100000000000100' - else # EC25-A - M2='01010000000100' - fi - fi - fi - ;; - "0306" ) # EP06-A - M1='AT+GMR' - OX=$($ROOTER/gcom/gcom-locked "$CPORT" "run-at.gcom" "$CURRMODEM" "$M1") - EP06E=$(echo $OX | grep "EP06E") - if [ ! -z "$EP06E" ]; then # EP06E - M2='101010110000000000010000000100010000010110' - CA="ep06e-bands" - else # EP06A - M2='010110100001100010000000110011000000000010000000000000000000000001' - CA="ep06a-bands" - fi - ;; - "030b" ) # EM060 - M2='111110110001110001110000110111000100011111100101000000000000000001000010' - CA="em060-2xbands" - CA3="" - ;; - "0512" ) # EM12-G - EM12=$(echo $model | grep "EG18") - if [ -z "$EM12" ]; then - M2='111110111001110011111000110111010000011110000000000000000000000001' - CA="em12-2xbands" - CA3="em12-3xbands" - else # EG18 - EM12=$(echo $model | grep "EA") - if [ -z "$EM12" ]; then # NA - M2='01011001000111001000000011001100000000001000000000000000000000000000001000010' - else # EA - M2='101010110000000000010000000100000000010110' - fi - CA="" - CA3="" - fi - ;; - "0620" ) # EM20-G - EM20=$(echo $model | grep "EM20") - if [ ! -z "$EM20" ]; then - M2='111110110001110011110000110111000000011111100101000000000000000001' - CA="em20-2xbands" - CA3="em20-3xbands" - CA4="em20-4xbands" - if [ -e /etc/qfake ]; then - M2='1111101100011100011100001101110101000111111000010000000000000000010000100' - M5='0000000000000000000000000000000000000100100000000000000000000000000000000000111' - M6='1110101100010000000100001001000000000101100000010000000000000000010000100000111' - $ROOTER/luci/celltype.sh $CURRMODEM - NET=$(uci -q get modem.modem$CURRMODEM.netmode) - if [ $NET != "7" ]; then - M5=$M6 # SA mode - L5=$L6 - fi - CA="" - CA3="" - CA4="" - fi - - else - M2='111110110001110011110000110111010000011111100101000000000000000001' - CA="em20-2xbands" - CA3="em20-3xbands" - CA4="em20-4xbands" - fi - ;; - "0801" ) #RM520 - GL=$(echo $model | grep "GL") - if [ ! -z "$GL" ]; then #RM520N-GL - M2='1111101100011100111100001101110101000111111001010000000000000000010000100' - M5='11101011000111000101000011011100000001011000000100000000000000000100011000111110' - M6=$M5 - CA="" - CA3="" - else #RM520N-EU - M2='1010101100000000000100000001000100000101111001000000000000000000000000100' - M5='101010110000000000010000000100000000010110000000000000000000000000000010001111' - M6=$M5 - CA="" - CA3="" - fi - ;; - "0900" ) - M2='111010110000000000010000000100000100011110' - M5='1000000000000000000000000001000000000000100000000000000000000000000000000000111' - M6=$M5 - CA="" - CA3="" - ;; - "0800") # RM500 - f2=$(echo $model | grep "500") - if [ -z "$f2" ]; then #RM502/505/510 - M2='1111101100011100111100001101110101000111111001010000000000000000010000100' - M5='1110101100010100000100001001000000000101100000010000000000000000010000100000111' - M6=$M5 - else - GL=$(echo $model | grep "GL") - if [ ! -z "$GL" ]; then #RM500-GL - M2='1111101100011100111100001101110101000111111001010000000000000000010000100' - M5='0000000000000000000000000000000000000000100000000000000000000000000000000000111' - M6='1110101100010000000100001001000000000101100000010000000000000000010000100000111' - else # RM500-AE - M2='1111101100011100111100001101110101000111111001010000000000000000010000100' - M5='11101011000100000001000010010000000001011000000100000000000000000100001000001110' - M6=$M5 - fi - fi - CA="" - CA3="" - ;; - esac - ;; - "1199" ) - case $uPid in - "68a2" ) # MC7700 - M2='1001000000000000100000000' - CA="" - ;; - "68c0"|"9041"|"901f" ) # MC7354 EM/MC7355 - M2='0101100000001000100000001' - CA="" - ;; - "9070"|"9071"|"9078"|"9079"|"907a"|"907b" ) # EM/MC7455 - M2='11111011000110000001000011000100000000001' - if [ -e /etc/fake ]; then - M2='1111101100011100011100000100110100000000110001010000000000000000010' - fi - CA="mc7455-bands" - ;; - "9090"|"9091"|"90b1" ) - EM7565=$(echo "$model" | grep "7565") - if [ ! -z "$EM7565" ]; then # EM7565 - M2='111110111001100001110000010111010000000011100101000000000000000001' - CA="em7565-2xbands" - CA3="em7565-3xbands" - else - EM7511=$(echo "$model" | grep "7511") - if [ ! -z "$EM7511" ]; then # EM7511 - M2='1111101100011100011100000100110100000000110001010000000000000000010' - CA="em7511-2xbands" - CA3="em7511-3xbands" - else # EM7411 - M2='0101101000011100000000001100000000000000111000010000000000000000010000100' - CA="em7411-2xbands" - CA3="em7411-3xbands" - fi - fi - ;; - esac - ;; - "8087" ) - M2='111110110001100011110000010111000000011110000000000000000000000001' - CA="l850-2xbands" - CA3="l850-3xbands" - ;; - "2cb7" ) - FM150=$(echo "$model" | grep "FM150") - if [ -z "$FM150" ]; then - M2='111110110001100011110000010111000000011110000000000000000000000001' - CA="l850-2xbands" - CA3="l850-3xbands" - else - M2='01011000000100000000000010001100000000000000000000000000000000000100001' - M5='00001000000100000000000000000000000000001000000000000000000000000100001' - CA="" - CA3="" - fi - ;; - "413c" ) - case $uPid in - - "81d7"|"81d8"|"e0b4" |"e0b5"|"1910") - M2='11111011000111001111000011011101000001111110010100000000000000000100' - CA="" - CA3="" - ;; - esac - ;; - "1bc7" ) - case $uPid in - - "1040"|"1041") - L1X=$(uci -q get modem.modem$CURRMODEM.L1X) - M2=$L1X - CA="" - CA3="" - ;; - esac - ;; - * ) - exit 0 - ;; -esac - -reverse $L1 -echo $revstr > /tmp/bmask1 -if [ ! -z $L5 ]; then - reverse $L5 -else - revstr="x" -fi -echo $revstr >> /tmp/bmask1 -if [ ! -z $L6 ]; then - reverse $L6 -else - revstr="x" -fi -echo $revstr >> /tmp/bmask1 -echo $M2 >> /tmp/bmask1 -echo $M5 >> /tmp/bmask1 -if [ -z "$M6" ]; then - M6="x" -fi -echo $M6 >> /tmp/bmask1 -if [ $CA ]; then - echo $CA >> /tmp/bmask1 - if [ $CA3 ]; then - echo $CA3 >> /tmp/bmask1 - if [ $CA4 ]; then - echo $CA4 >> /tmp/bmask1 - fi - fi -fi -mv /tmp/bmask1 /tmp/bmask - diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/mc7455-bands b/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/mc7455-bands deleted file mode 100644 index 3114071..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/mc7455-bands +++ /dev/null @@ -1,14 +0,0 @@ -1 8 -2 2 -2 5 -2 12 -2 13 -3 7 -3 20 -4 4 -4 5 -4 12 -4 13 -7 7 -7 20 -41 41 \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/modechge.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/modechge.sh deleted file mode 100644 index 7a8bf5e..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/modechge.sh +++ /dev/null @@ -1,276 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -MODEMTYPE=$1 -NETMODE=$2 - -# log() { - modlog "ModeChange $CURRMODEM" "$@" -# } - -CURRMODEM=$(uci get modem.general.miscnum) -uci set modem.modem$CURRMODEM.cmode="0" -uci set modem.modem$CURRMODEM.netmode="10" -uci commit modem - -MODEMTYPE=$(uci get modem.modem$CURRMODEM.modemtype) -COMMPORT="/dev/ttyUSB"$(uci get modem.modem$CURRMODEM.commport) - -# ZTE -if [ $MODEMTYPE -eq 1 ]; then - case $NETMODE in - 1*) - ATC="AT+ZSNT=0,0,0" ;; - 2*) - ATC="AT+ZSNT=0,0,1" ;; - 3*) - ATC="AT+ZSNT=1,0,0" ;; - 4*) - ATC="AT+ZSNT=0,0,2" ;; - 5*) - ATC="AT+ZSNT=2,0,0" ;; - 6*) - ATC="AT+ZSNT=0,0,6" ;; - 7*) - ATC="AT+ZSNT=6,0,0" ;; - esac - ATC=$ATC";+ZBANDI=0" -fi - -# Sierra -if [ $MODEMTYPE -eq 2 ]; then - case $NETMODE in - "3" ) - ATC="AT!SELRAT=2" ;; - "5" ) - ATC="AT!SELRAT=1" ;; - "7" ) - ATC="AT!SELRAT=6" ;; - * ) - ATC="AT!SELRAT=0" ;; - esac -fi - -# Huawei LTE -if [ $MODEMTYPE -eq 3 ]; then - case $NETMODE in - 1*) - ATC="AT^SYSCFGEX=\"00\",40000000,2,4,40000000,," ;; - 2*) - ATC="AT^SYSCFGEX=\"010203\",40000000,2,4,40000000,," ;; - 3*) - ATC="AT^SYSCFGEX=\"01\",40000000,2,4,40000000,," ;; - 4*) - ATC="AT^SYSCFGEX=\"020301\",40000000,2,4,40000000,," ;; - 5*) - ATC="AT^SYSCFGEX=\"02\",40000000,2,4,40000000,," ;; - 6*) - ATC="AT^SYSCFGEX=\"030201\",40000000,2,4,40000000,," ;; - 7*) - ATC="AT^SYSCFGEX=\"03\",40000000,2,4,40000000,," ;; - esac -fi - -# Huawei legacy -if [ $MODEMTYPE -eq 4 ]; then - case $NETMODE in - 1*) - ATC="AT^SYSCFG=2,0,40000000,2,4" ;; - 2*) - ATC="AT^SYSCFG=2,1,40000000,2,4" ;; - 3*) - ATC="AT^SYSCFG=13,1,40000000,2,4" ;; - 4*) - ATC="AT^SYSCFG=2,2,40000000,2,4" ;; - 5*) - ATC="AT^SYSCFG=14,2,40000000,2,4" ;; - esac -fi - -# ublox -if [ $MODEMTYPE -eq 5 ]; then - case $NETMODE in - 1*) - ATC="AT+CFUN=4;+URAT=4,3;+CFUN=1,1" ;; - 2*) - ATC="AT+CFUN=4;+URAT=4,0;+CFUN=1,1" ;; - 3*) - ATC="AT+CFUN=4;+URAT=0;+CFUN=1,1" ;; - 4*) - ATC="AT+CFUN=4;+URAT=4,2;+CFUN=1,1" ;; - 5*) - ATC="AT+CFUN=4;+URAT=2;+CFUN=1,1" ;; - 6*) - ATC="AT+CFUN=4;+URAT=4,3;+CFUN=1,1" ;; - 7*) - ATC="AT+CFUN=4;+URAT=4,3;+CFUN=1,1" ;; - esac -fi - -# Quectel -if [ $MODEMTYPE -eq 6 ]; then - CURRMODEM=$(uci -q get modem.general.modemnum) - idV=$(uci -q get modem.modem$CURRMODEM.idV) - idP=$(uci -q get modem.modem$CURRMODEM.idP) - ATCMDD="AT+CGMM" - model=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - EM20=$(echo "$model" | grep "EM20") - if [ $EM20 ]; then - idP="0" - fi - NEWFMT=false - if [ "$idV" = "2c7c" ]; then - if [ "$idP" = "0800" -o "$idP" = "0620" -o "$idP" = "030b" -o "$idP" = "0801" -o "$idP" = "0900" ]; then - NEWFMT=true - fi - fi - case $NETMODE in - "3") - ATC="AT+QCFG=\"nwscanmode\",1" ;; - "5") - if $NEWFMT; then - ATC="AT+QNWPREFCFG=\"mode_pref\",WCDMA" - else - ATC="AT+QCFG=\"nwscanmode\",2" - fi - ;; - "7") - if $NEWFMT; then - ATC="AT+QNWPREFCFG=\"mode_pref\",LTE" - else - ATC="AT+QCFG=\"nwscanmode\",3" - fi - ;; - "8") - ATC="AT+QNWPREFCFG=\"mode_pref\",LTE:NR5G" ;; - "9") - ATC="AT+QNWPREFCFG=\"mode_pref\",NR5G" ;; - *) - if $NEWFMT; then - ATC="AT+QNWPREFCFG=\"mode_pref\",AUTO" - else - ATC="AT+QCFG=\"nwscanmode\",0" - fi - ;; - esac -fi - -# MEIG -if [ $MODEMTYPE -eq 7 ]; then - CURRMODEM=$(uci -q get modem.general.modemnum) - idV=$(uci -q get modem.modem$CURRMODEM.idV) - if [ $idV == "2dee" ]; then - case $NETMODE in - "4") - ATC="AT^SYSCFGEX=\"020304\"" ;; - "5") - ATC="AT^SYSCFGEX=\"02\"" ;; - "6") - ATC="AT^SYSCFGEX=\"030402\"" ;; - "7") - ATC="AT^SYSCFGEX=\"03\"" ;; - "8") - ATC="AT^SYSCFGEX=\"0403\"" ;; - "9") - ATC="AT^SYSCFGEX=\"04\"" ;; - *) - ATC="AT^SYSCFGEX=\"00\"" ;; - esac - else - case $NETMODE in - "3") - ATC="AT+MODODR=3" ;; - "5") - ATC="AT+MODODR=1" ;; - "7") - ATC="AT+MODODR=5" ;; - *) - ATC="AT+MODODR=2" ;; - esac - fi -fi - -# Telit, Foxconn, etc. -if [ $MODEMTYPE -eq 8 ]; then - case $NETMODE in - "3" ) - ATC="AT\$QCNSP=1,0,0" ;; - "5" ) - ATC="AT\$QCNSP=2,0,0" ;; - "7" ) - ATC="AT\$QCNSP=6,0,0" ;; - * ) - ATC="AT\$QCNSP=0,0,0" ;; - esac -fi - -# Fibocom -if [ $MODEMTYPE -eq 9 ]; then - CURRMODEM=$(uci -q get modem.general.modemnum) - idV=$(uci -q get modem.modem$CURRMODEM.idV) - idP=$(uci -q get modem.modem$CURRMODEM.idP) - idPP=${idP:1:1} - if [ "$idPP" = "1" ]; then - case $NETMODE in - "7") - ATC="AT+GTRAT=3" ;; - "8") - ATC="AT+GTRAT=17" ;; - "9") - ATC="AT+GTRAT=14" ;; - *) - ATC="AT+GTRAT=10" ;; - esac - else - case $NETMODE in - "4") - ATC="AT+XACT=4,1" ;; - "5") - ATC="AT+XACT=1" ;; - "7") - ATC="AT+XACT=2" ;; - *) - ATC="AT+XACT=4,2" ;; - esac - fi -fi - -# SIMCom -if [ $MODEMTYPE -eq 10 ]; then - case $NETMODE in - "3") - ATC="AT+CNMP=13" ;; - "5") - ATC="AT+CNMP=14" ;; - "7") - ATC="AT+CNMP=38" ;; - "8") - ATC="AT+CNMP=109" ;; - "9") - ATC="AT+CNMP=71" ;; - *) - ATC="AT+CNMP=2" ;; - esac -fi - -# Quanta, Megafon -if [ $MODEMTYPE -eq 11 ]; then - case $NETMODE in - "5") - ATC="AT^QCNCFG=02" ;; - "7") - ATC="AT^QCNCFG=03" ;; - *) - ATC="AT^QCNCFG=00" ;; - esac -fi - -ATCMDD="$ATC" -OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - -$ROOTER/luci/celltype.sh $CURRMODEM -uci set modem.modem$CURRMODEM.cmode="1" -uci commit modem - -$ROOTER/luci/restart.sh $CURRMODEM 11 diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/modemchge.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/modemchge.sh deleted file mode 100644 index a0fd3e9..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/modemchge.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/sh - -TYPE=$1 -DIREC=$2 -source /tmp/modcnt -MODCNT=$MODCNTX - -case $TYPE in -"modem" ) - MODENUM=$(uci get modem.general.modemnum) - ;; -"sms" ) - MODENUM=$(uci get modem.general.smsnum) - ;; -"misc" ) - MODENUM=$(uci get modem.general.miscnum) - ;; -esac - -if [ $DIREC -eq 1 ]; then - let MODENUM=MODENUM+1 - if [ $MODENUM -gt $MODCNT ]; then - MODENUM=1 - fi -else - if [ $MODENUM -eq 1 ]; then - MODENUM=$MODCNT - else - let MODENUM=MODENUM-1 - fi -fi -case $TYPE in -"modem" ) - uci set modem.general.modemnum=$MODENUM - ;; -"sms" ) - uci set modem.general.smsnum=$MODENUM - ;; -"misc" ) - uci set modem.general.miscnum=$MODENUM - uci commit modem - /usr/lib/rooter/luci/mask.sh - ;; -esac -uci commit modem - diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/portchge.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/portchge.sh deleted file mode 100644 index 928b60d..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/portchge.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh - -DIR=$1 - -log() { - modlog "Port change $CURRMODEM" "$@" -} - - -CURRMODEM=$(uci get modem.general.modemnum) -BASEP=$(uci get modem.modem$CURRMODEM.baseport) -MAXP=$(uci get modem.modem$CURRMODEM.maxport) -PORT=$(uci get modem.modem$CURRMODEM.commport) - -log "$DIR" - -if [ $DIR = "up" ]; then - if [ $PORT -lt $MAXP ]; then - PORT=`expr $PORT + 1` - echo 'PORT="'"$PORT"'"' > /tmp/port$CURRMODEM.file - fi -else - if [ $PORT -gt $BASEP ]; then - PORT=`expr $PORT - 1` - echo 'PORT="'"$PORT"'"' > /tmp/port$CURRMODEM.file - fi -fi - diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/protochnge.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/protochnge.sh deleted file mode 100644 index f831521..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/protochnge.sh +++ /dev/null @@ -1,155 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -NEWMOD=$1 - - log() { - modlog "ProtoChange $CURRMODEM" "$@" - } - -ifname1="ifname" -if [ -e /etc/newstyle ]; then - ifname1="device" -fi - - change_bconf() { - local devname=$1 - local conf=$2 - local mode=$3 - local unconf=0 - log "Switching Modem at $devname to $mode by selecting Cfg# $conf" - echo $unconf >/sys/bus/usb/devices/$devname/bConfigurationValue - sleep 1 - echo $conf >/sys/bus/usb/devices/$devname/bConfigurationValue -} - - chkT77() { - T77=0 - if [ $idV = 413c -a $idP = 81d7 ]; then - T77=1 - elif [ $idV = 413c -a $idP = 81d8 ]; then - T77=1 - elif [ $idV = 0489 -a $idP = e0b4 ]; then - T77=1 - elif [ $idV = 0489 -a $idP = e0b5 ]; then - T77=1 - elif [ $idV = 1bc7 -a $idP = 1910 ]; then - T77=1 - fi -} - - chksierra() { - SIERRAID=0 - if [ $idV = 1199 ]; then - case $idP in - "68aa"|"68a2"|"68a3"|"68a9"|"68b0"|"68b1" ) - SIERRAID=1 - ;; - "68c0"|"9040"|"9041"|"9051"|"9054"|"9056"|"90d3" ) - SIERRAID=1 - ;; - "9070"|"907b"|"9071"|"9079"|"901c"|"9091"|"901f"|"90b1" ) - SIERRAID=1 - ;; - esac - elif [ $idV = 114f -a $idP = 68a2 ]; then - SIERRAID=1 - elif [ $idV = 413c -a $idP = 81a8 ]; then - SIERRAID=1 - elif [ $idV = 413c -a $idP = 81b6 ]; then - SIERRAID=1 - fi -} - -chkquectel() { - QUECTEL=false - if [ "$idV" = "2c7c" ]; then - QUECTEL=true - elif [ "$idV" = "05c6" ]; then - QUELST="9090,9003,9215" - if [[ $(echo "$QUELST" | grep -o "$idP") ]]; then - QUECTEL=true - fi - fi -} - -log "Protocol Change to $NEWMOD" - -CURRMODEM=$(uci get modem.general.modemnum) -CPORT=$(uci get modem.modem$CURRMODEM.commport) -idV=$(uci get modem.modem$CURRMODEM.uVid) -idP=$(uci get modem.modem$CURRMODEM.uPid) - -chkquectel -if $QUECTEL; then - case $NEWMOD in - "1" ) - ATCMDD='AT+QCFG="usbnet",0' - ;; - "2" ) - ATCMDD='AT+QCFG="usbnet",2' - ;; - "3" ) - ATCMDD='AT+QCFG="usbnet",1' - ;; - esac - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") -fi - - chksierra - if [ $SIERRAID -eq 1 ]; then - ATCMDD='AT!ENTERCND="A710"' - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - - case $idP in - "68c0"|"9041"|"901f" ) # MC7354 EM/MC7355 - case $NEWMOD in - "1" ) - ATCMDD='at!UDUSBCOMP=6' - ;; - "2" ) - ATCMDD='at!UDUSBCOMP=8' - ;; - esac - ;; - "9070"|"9071"|"9078"|"9079"|"907a"|"907b" ) # EM/MC7455 - case $NEWMOD in - "1" ) - ATCMDD='at!usbcomp=1,1,10d' - ;; - "2" ) - ATCMDD='at!usbcomp=1,1,1009' - ;; - esac - ;; - "9090"|"9091"|"90b1" ) # EM7565 - case $NEWMOD in - "1" ) - ATCMDD='at!usbcomp=1,3,10d' - ;; - "2" ) - ATCMDD='AT!USBCOMP=1,3,1009' - ;; - esac - ;; - esac - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - ATCMDD='AT!ENTERCND="AWRONG"' - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - fi - - chkT77 - if [ $T77 = "1" ]; then - DEVICE=$(uci get modem.modem$CURRMODEM.device) - if [ $NEWMOD = "1" ]; then - change_bconf $DEVICE 1 QMI - else - change_bconf $DEVICE 2 MBIM - fi - log "T77 $NEWMOD $DEVICE" - fi -sleep 5 - -/usr/lib/rooter/luci/restart.sh $CURRMODEM "9" - diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/restart.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/restart.sh deleted file mode 100644 index 60482da..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/restart.sh +++ /dev/null @@ -1,83 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter -ROOTER_LINK="/tmp/links" - -log() { - modlog "Modem Restart/Diisconnect $CURRMODEM" "$@" -} - -ifname1="ifname" -if [ -e /etc/newstyle ]; then - ifname1="device" -fi - -CURRMODEM=$1 -CPORT=$(uci -q get modem.modem$CURRMODEM.commport) -INTER=$(uci get modem.modeminfo$CURRMODEM.inter) - -if [ "$2" != "9" -a "$2" != "11" ]; then - PROTO=$(uci get modem.modem$CURRMODEM.proto) - if [ "$PROTO" = "3" -o "$PROTO" = "30" ]; then - mdevice=$(uci -q get modem.modem$CURRMODEM.mdevice) - mapn=$(uci -q get modem.modem$CURRMODEM.mapn) - mipt=$(uci -q get modem.modem$CURRMODEM.mipt) - nauth=$(uci -q get modem.modem$CURRMODEM.mauth) - nusername=$(uci -q get modem.modem$CURRMODEM.musername) - mpassword=$(uci -q get modem.modem$CURRMODEM.mpassword) - log "Disconnect Network" - umbim -t 1 -d "$mdevice" disconnect - sleep 1 - exit 0 - fi - - if [ "$PROTO" = "2" ]; then - mdevice=$(uci -q get modem.modem$CURRMODEM.mdevice) - mapn=$(uci -q get modem.modem$CURRMODEM.mapn) - mcid=$(uci -q get modem.modem$CURRMODEM.mcid) - nauth=$(uci -q get modem.modem$CURRMODEM.mauth) - nusername=$(uci -q get modem.modem$CURRMODEM.musername) - mpassword=$(uci -q get modem.modem$CURRMODEM.mpassword) - uqmi -s -d "$device" --stop-network 0xffffffff --autoconnect > /dev/null & sleep 1 ; kill -9 $! - exit 0 - fi - if [ "$2" = "10" ]; then - exit 0 - fi -fi - -if [ "$2" != "9" -a "$2" != "11" ]; then # disconnect - uci set modem.modem$CURRMODEM.connected=0 - uci commit modem - jkillall getsignal$CURRMODEM - rm -f $ROOTER_LINK/getsignal$CURRMODEM - jkillall con_monitor$CURRMODEM - rm -f $ROOTER_LINK/con_monitor$CURRMODEM - ifdown wan$INTER - $ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "reset.gcom" "$CURRMODEM" -else # restart - uVid=$(uci get modem.modem$CURRMODEM.uVid) - uPid=$(uci get modem.modem$CURRMODEM.uPid) - #if [ $uVid != "2c7c" ]; then - if [ ! -z "$CPORT" ]; then - ATCMDD="AT+CFUN=1,1" - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - fi - log "Hard modem reset done" - #fi - ifdown wan$INTER - uci delete network.wan$CURRMODEM - uci set network.wan$CURRMODEM=interface - uci set network.wan$CURRMODEM.proto=dhcp - uci set network.wan$CURRMODEM.${ifname1}="wan"$CURRMODEM - uci set network.wan$CURRMODEM.metric=$CURRMODEM"0" - uci commit network - /etc/init.d/network reload - echo "1" > /tmp/modgone - log "Hard USB reset done" - - PORT="usb$CURRMODEM" - echo $PORT > /sys/bus/usb/drivers/usb/unbind - sleep 35 - echo $PORT > /sys/bus/usb/drivers/usb/bind -fi diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/scancmd.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/scancmd.sh deleted file mode 100644 index dc6e96d..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/scancmd.sh +++ /dev/null @@ -1,412 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -log() { - modlog "Scan Command $CURRMODEM" "$@" -} - -fibdecode() { - j=$1 - tdec=$2 - mod=$3 - length=${#j} - jx=$j - length=${#jx} - - str="" - i=$((length-1)) - while [ $i -ge 0 ] - do - dgt="0x"${jx:$i:1} - DecNum=`printf "%d" $dgt` - Binary= - Number=$DecNum - while [ $DecNum -ne 0 ] - do - Bit=$(expr $DecNum % 2) - Binary=$Bit$Binary - DecNum=$(expr $DecNum / 2) - done - if [ -z $Binary ]; then - Binary="0000" - fi - len=${#Binary} - while [ $len -lt 4 ] - do - Binary="0"$Binary - len=${#Binary} - done - revstr="" - length=${#Binary} - ii=$((length-1)) - while [ $ii -ge 0 ] - do - revstr=$revstr${Binary:$ii:1} - ii=$((ii-1)) - done - str=$str$revstr - i=$((i-1)) - done - len=${#str} - ii=0 - lst="" - sep="," - hun=101 - if [ $mod = "1" ]; then - sep=":" - hun=1 - fi - while [ $ii -lt $len ] - do - bnd=${str:$ii:1} - if [ $bnd -eq 1 ]; then - if [ $tdec -eq 1 ]; then - jj=$((ii+hun)) - else - if [ $ii -lt 9 ]; then - jj=$((ii+501)) - else - jj=$((ii+5001)) - fi - fi - if [ -z $lst ]; then - lst=$jj - else - lst=$lst$sep$jj - fi - fi - ii=$((ii+1)) - done -} - -CURRMODEM=$(uci get modem.general.miscnum) -COMMPORT="/dev/ttyUSB"$(uci get modem.modem$CURRMODEM.commport) -uVid=$(uci get modem.modem$CURRMODEM.uVid) -uPid=$(uci get modem.modem$CURRMODEM.uPid) -model=$(uci get modem.modem$CURRMODEM.model) -ACTIVE=$(uci get modem.pinginfo$CURRMODEM.alive) -uci set modem.pinginfo$CURRMODEM.alive='0' -uci commit modem -L1=$(uci get modem.modem$CURRMODEM.L1) -length=${#L1} -L1="${L1:2:length-2}" -L1=$(echo $L1 | sed 's/^0*//') -L2=$(uci get modem.modem$CURRMODEM.L2) -L1X=$(uci get modem.modem$CURRMODEM.L1X) -if [ -z $L1X ]; then - L1X="0" -fi - -case $uVid in - "2c7c" ) - M2='AT+QENG="neighbourcell"' - M5="" - case $uPid in - "0125" ) # EC25-A - EC25=$(echo $model | grep "EC25-AF") - if [ ! -z $EC25 ]; then - MX='400000000000003818' - else - MX='81a' - fi - M4='AT+QCFG="band",0,'$MX',0' - ;; - "0306" ) - M1='AT+GMR' - OX=$($ROOTER/gcom/gcom-locked "$CPORT" "run-at.gcom" "$CURRMODEM" "$M1") - EP06E=$(echo $OX | grep "EP06E") - if [ ! -z $EP06E ]; then # EP06E - M3='1a080800d5' - else # EP06-A - M3="2000001003300185A" - fi - M4='AT+QCFG="band",0,'$M3',0' - ;; - "030b" ) # EM060 - M3="420000A7E23B0E38DF" - M4='AT+QCFG="band",0,'$M3',0' - ;; - "0512" ) # EM12-G - EM12=$(echo $model | grep "EG18") - if [ -z "$EM12" ]; then - M3="2000001E0BB1F39DF" - else # EG18 - EM12=$(echo $model | grep "EA") - if [ -z "$EM12" ]; then # NA - M3="4200000100330138A" - else # EA - M3="1A0080800C5" - fi - fi - M4='AT+QCFG="band",0,'$M3',0' - ;; - "0620" ) # EM20-G - EM20=$(echo $model | grep "EM20") - if [ ! -z $EM20 ]; then # EM20 - M3="20000A7E03B0F38DF" - M4='AT+QCFG="band",0,'$M3',0' - if [ -e /etc/qfake ]; then - mask="42000087E2BB0F38DF" - fibdecode $mask 1 1 - M4F='AT+QNWPREFCFG="lte_band",'$lst - log "Fake RM500 $M4F" - fi - - else # EM160 - mask="20000A7E0BB0F38DF" - fibdecode $mask 1 1 - M4='AT+QNWPREFCFG="lte_band",'$lst - fi - ;; - "0800"|"0900"|"0801" ) - - ;; - * ) - M3="AT" - M4='AT+QCFG="band",0,'$M3',0' - ;; - esac - - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$M4") - log "$OX" - if [ ! -z $M5 ]; then - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$M5") - log "$OX" - fi - sleep 5 - ;; - "1199" ) - M2='AT!LTEINFO?' - case $uPid in - - "68c0"|"9041"|"901f" ) # MC7354 EM/MC7355 - M3="101101A" - M3X="0" - M4='AT!BAND=11,"Test",0,'$M3,$M3X - ;; - "9070"|"9071"|"9078"|"9079"|"907a"|"907b" ) # EM/MC7455 - M3="100030818DF" - M3X="0" - M4='AT!BAND=11,"Test",0,'$M3,$M3X - if [ -e /etc/fake ]; then - M4='AT!BAND=11,"Test",0,A300BA0E38DF,2,0,0,0' - fi - ;; - "9090"|"9091"|"90b1" ) # EM7565 - EM7565=$(echo "$model" | grep "7565") - if [ ! -z $EM7565 ]; then - M3="A300BA0E38DF" - M3X="2" - M4='AT!BAND=11,"Test",0,'$M3","$M3X",0,0,0" - else - EM7511=$(echo "$model" | grep "7511") - if [ ! -z $EM7511 ]; then # EM7511 - M3="A300BA0E38DF" - M3X="2" - M4='AT!BAND=11,"Test",0,'$M3","$M3X",0,0,0" - else - M3="87000300385A" - M3X="42" - M4='AT!BAND=11,"Test",0,'$M3","$M3X",0,0,0" - fi - fi - - ;; - * ) - M3="AT" - ;; - esac - log "Set full : $M4" - if [ -e /etc/fake ]; then - M4='AT!BAND=11,"Test",0,'$M3,$M3X - fi - M1='AT!ENTERCND="A710"' - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$M1") - log "$OX" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$M4") - log "$OX" - M4='AT!BAND=00;!BAND=11' - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$M4") - log "$OX" - ATCMDD='AT!ENTERCND="AWRONG"' - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - ;; - "8087"|"2cb7" ) - rm -f /tmp/scan - echo "Cell Scanner Start ..." > /tmp/scan - echo " " >> /tmp/scan - if [ -e /tmp/scan$CURRMODEM ]; then - SCX=$(cat /tmp/scan$CURRMODEM) - echo "$SCX" >> /tmp/scan - else - echo "No Neighbouring cells were found" >> /tmp/scan - fi - echo " " >> /tmp/scan - echo "Done" >> /tmp/scan - exit 0 - ;; - * ) - rm -f /tmp/scanx - echo "Scan for Neighbouring cells not supported" >> /tmp/scan - uci set modem.pinginfo$CURRMODEM.alive=$ALIVE - uci commit modem - exit 0 - ;; -esac - -export TIMEOUT="10" -OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$M2") -OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$M2") -log "$OX" -ERR=$(echo "$OX" | grep "ERROR") -if [ ! -z $ERR ]; then - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$M2") - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$M2") - log "$OX" -fi -if [ ! -z $ERR ]; then - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$M2") - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$M2") - log "$OX" -fi -log "$OX" -echo "$OX" > /tmp/scanx -rm -f /tmp/scan -echo "Cell Scanner Start ..." > /tmp/scan -echo " " >> /tmp/scan -flg=0 -while IFS= read -r line -do - case $uVid in - "2c7c" ) - qm=$(echo $line" " | grep "+QENG:" | tr -d '"' | tr " " ",") - if [ "$qm" ]; then - INT=$(echo $qm | cut -d, -f3) - BND=$(echo $qm | cut -d, -f5) - PCI=$(echo $qm | cut -d, -f6) - RSSI=$(echo $qm | cut -d, -f9) - BAND=$(/usr/bin/chan2band.sh $BND) - if [ "$INT" = "intra" ]; then - echo "Band : $BAND Signal : $RSSI (dBm) EARFCN : $BND PCI : $PCI (current)" >> /tmp/scan - else - echo "Band : $BAND Signal : $RSSI (dBm) EARFCN : $BND PCI : $PCI" >> /tmp/scan - fi - flg=1 - fi - ;; - "1199" ) - qm=$(echo $line" " | grep "Serving:" | tr -d '"' | tr " " ",") - if [ "$qm" ]; then - read -r line - qm=$(echo $line" " | tr -d '"' | tr " " ",") - BND=$(echo $qm | cut -d, -f1) - PCI=$(echo $qm | cut -d, -f10) - BAND=$(/usr/bin/chan2band.sh $BND) - RSSI=$(echo $qm | cut -d, -f13) - echo "Band : $BAND Signal : $RSSI (dBm) EARFCN : $BND PCI : $PCI (current)" >> /tmp/scan - flg=1 - else - qm=$(echo $line" " | grep "InterFreq:" | tr -d '"' | tr " " ",") - log "$line" - if [ "$qm" ]; then - while [ 1 = 1 ] - do - read -r line - log "$line" - qm="" - qm=$(echo $line" " | grep ":" | tr -d '"' | tr " " ",") - if [ "$qm" ]; then - break - fi - qm=$(echo $line" " | grep "OK" | tr -d '"' | tr " " ",") - if [ "$qm" ]; then - break - fi - qm=$(echo $line" " | tr -d '"' | tr " " ",") - if [ "$qm" = "," ]; then - break - fi - BND=$(echo $qm | cut -d, -f1) - PCI=$(echo $qm | cut -d, -f10) - BAND=$(/usr/bin/chan2band.sh $BND) - RSSI=$(echo $qm | cut -d, -f8) - echo "Band : $BAND Signal : $RSSI (dBm) EARFCN : $BND PCI : $PCI" >> /tmp/scan - flg=1 - done - break - fi - fi - ;; - * ) - - ;; - esac -done < /tmp/scanx - -rm -f /tmp/scanx -if [ $flg -eq 0 ]; then - echo "No Neighbouring cells were found" >> /tmp/scan -fi -echo " " >> /tmp/scan -echo "Done" >> /tmp/scan - -case $uVid in - "2c7c" ) - if [ $uPid != "0800" ]; then - if [ $uPid = 0620 -o $uPid = "0800" -o $uPid = "030b" ]; then - EM20=$(echo $model | grep "EM20") - if [ ! -z $EM20 ]; then # EM20 - M2='AT+QCFG="band",0,'$L1',0' - if [ -e /etc/fake ]; then - fibdecode $L1 1 1 - M2F='AT+QNWPREFCFG="lte_band",'$lst - log "Fake EM160 Band Set "$M2F - fi - else - fibdecode $L1 1 1 - M2='AT+QNWPREFCFG="lte_band",'$lst - fi - else - M4='AT+QCFG="band",0,'$L1',0' - fi - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$M4") - log "$OX" - fi - ;; - "1199" ) - M1='AT!ENTERCND="A710"' - case $uPid in - - "68c0"|"9041"|"901f" ) # MC7354 EM/MC7355 - M4='AT!BAND=11,"Test",0,'$L1X,0 - ;; - "9070"|"9071"|"9078"|"9079"|"907a"|"907b" ) # EM/MC7455 - M4='AT!BAND=11,"Test",0,'$L1X,0 - if [ -e /etc/fake ]; then - M4='AT!BAND=11,"Test",0,'$L1X','$L2',0,0,0' - fi - ;; - "9090"|"9091"|"90b1" ) - M4='AT!BAND=11,"Test",0,'$L1X','$L2',0,0,0' - ;; - esac - log "Set back : $M4" - if [ -e /etc/fake ]; then - M4='AT!BAND=11,"Test",0,00000100030818DF,0' - fi - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$M1") - log "$OX" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$M4") - log "$OX" - M4='AT!BAND=00;!BAND=11' - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$M4") - log "$OX" - ATCMDD='AT!ENTERCND="AWRONG"' - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - ;; -esac -uci set modem.pinginfo$CURRMODEM.alive=$ACTIVE -uci commit modem - -log "Finished Scan" diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/setcell.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/setcell.sh deleted file mode 100644 index 4b8a488..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/setcell.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -log() { - modlog "Lock Cell $CURRMODEM" "$@" -} - -dat="$1" - -CURRMODEM=$(uci -q get modem.general.miscnum) - -dat1=$(echo $dat | tr "|" ",") -dat2=$(echo $dat1 | cut -d, -f1) -if [ $dat2 = "0" ]; then - uci set custom.bandlock.cenable$CURRMODEM='0' -else - ear=$(echo $dat1 | cut -d, -f2) - pc=$(echo $dat1 | cut -d, -f3) - ear1=$(echo $dat1 | cut -d, -f4) - pc1=$(echo $dat1 | cut -d, -f5) - ear2=$(echo $dat1 | cut -d, -f6) - pc2=$(echo $dat1 | cut -d, -f7) - ear3=$(echo $dat1 | cut -d, -f8) - pc3=$(echo $dat1 | cut -d, -f9) - uci set custom.bandlock.cenable$CURRMODEM='1' - uci set custom.bandlock.earfcn$CURRMODEM=$ear - uci set custom.bandlock.pci$CURRMODEM=$pc - uci set custom.bandlock.earfcn1$CURRMODEM=$ear1 - uci set custom.bandlock.pci1$CURRMODEM=$pc1 - uci set custom.bandlock.earfcn2$CURRMODEM=$ear2 - uci set custom.bandlock.pci2$CURRMODEM=$pc2 - uci set custom.bandlock.earfcn3$CURRMODEM=$ear3 - uci set custom.bandlock.pci3$CURRMODEM=$pc3 -fi -uci commit custom - -ifname1="ifname" -if [ -e /etc/newstyle ]; then - ifname1="device" -fi - - -CURRMODEM=$(uci get modem.general.miscnum) -COMMPORT="/dev/ttyUSB"$(uci get modem.modem$CURRMODEM.commport) -CPORT=$(uci -q get modem.modem$CURRMODEM.commport) - -ATCMDD="at+qnwlock=\"common/4g\"" -OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") -if `echo $OX | grep "ERROR" 1>/dev/null 2>&1` -then - ATCMDD="at+qnwlock=\"common/lte\",0" -else - ATCMDD=$ATCMDD",0" -fi -OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") -log "$OX" -sleep 5 -/usr/lib/rooter/luci/restart.sh $CURRMODEM "9" diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/wifiradio.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/wifiradio.sh deleted file mode 100644 index 1f791a0..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/luci/wifiradio.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh -. /lib/functions.sh - -config_cb() { - local type="$1" - local name="$2" - if [ ! -z $type ]; then - if [ $type = "wifi-device" ]; then - echo $name >> /tmp/wifi-device - fi - fi -} - -rm -f /tmp/wifi-device -config_load wireless diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/mbimfind.lua b/rooter/ext-rooter-basic/files/usr/lib/rooter/mbimfind.lua deleted file mode 100644 index 7e7e67b..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/mbimfind.lua +++ /dev/null @@ -1,92 +0,0 @@ -#!/usr/bin/lua - -drv = {} -idV = arg[1] -idP = arg[2] - -retval = 0 -echo = 0 - -printf = function(s,...) - if pflag ~= 0 then - io.write(s:format(...)) - local ss = s:format(...) - if echo == 1 then - os.execute("/usr/lib/rooter/logprint.sh " .. ss) - end - end -end - -function trim(s) - return (s:gsub("^%s*(.-)%s*$", "%1")) -end - --- MAIN --- C: #Ifs= 3 Cfg#= 3 Atr=a0 MxPwr=500mA - -Cfgs = 1 -local i=0 -local file = io.open("/tmp/prembim", "r") -repeat - local line = file:read("*line") - if line == nil then - break - end - if string.len(line) > 5 then - s, e = line:find("D:") - if s ~= nil then - cs, ce = line:find("#Cfgs= ") - Cfgs = trim(line:sub(ce+1)) - --printf("Cfgs = %s\n", Cfgs) - end - - s, e = line:find("Vendor=") - if s ~= nil then - cs, ce = line:find(" ", e) - m_idV = trim(line:sub(e+1, cs-1)) - s, e = line:find("ProdID=") - cs, ce = line:find(" ", e) - m_idP = trim(line:sub(e+1, cs-1)) - --printf("%s %s\n", m_idV, m_idP) - if m_idV == idV and m_idP == idP then - if Cfgs == "1" then - break - end - Inter = 0 - repeat - line = file:read("*line") - if line == nil then - break - end - if string.len(line) > 5 then - s, e = line:find("C:") - if s ~= nil then - s, e = line:find("Cfg#= ") - cs, ce = line:find(" ", e+1) - Inter = trim(line:sub(e+1, cs)) - --printf("Inter = %s\n", Inter) - end - s, e = line:find("T:") - if s ~= nil then - break - end - s, e = line:find("Cls=02") - if s ~= nil then - s, e = line:find("Sub=0e Prot=00 Driver=") - if s ~= nil then - retval=tonumber(Inter) - --printf("retval = %d\n", retval) - break - end - end - end - until 1==0 - break - end - end - end -until 1==0 -file:close() - - -os.exit(retval) \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/modeswitch.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/modeswitch.sh deleted file mode 100644 index 58f40e8..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/modeswitch.sh +++ /dev/null @@ -1,620 +0,0 @@ -#!/bin/sh -. /lib/functions/procd.sh - -MODCNT=6 - -ROOTER=/usr/lib/rooter -ROOTER_LINK="/tmp/links" - -modeswitch="/usr/bin/usb_modeswitch" - -log() { - modlog "usb-modeswitch $CURRMODEM" "$@" -} - -sanitize() { - sed -e 's/[[:space:]]\+$//; s/[[:space:]]\+/_/g' "$@" -} - -find_usb_attrs() { - local usb_dir="/sys$DEVPATH" - [ -f "$usb_dir/idVendor" ] || usb_dir="${usb_dir%/*}" - - uVid=$(cat "$usb_dir/idVendor") - uPid=$(cat "$usb_dir/idProduct") - uMa=$(sanitize "$usb_dir/manufacturer") - uPr=$(sanitize "$usb_dir/product") - uSe=$(sanitize "$usb_dir/serial") -} - -display_top() { - log "*****************************************************************" - log "*" -} - -display_bottom() { - log "*****************************************************************" -} - - -display() { - local line1=$1 - log "* $line1" - log "*" -} - -# -# Save Interface variables -# -save_variables() { - echo 'MODSTART="'"$MODSTART"'"' > /tmp/variable.file - echo 'WWAN="'"$WWAN"'"' >> /tmp/variable.file - echo 'USBN="'"$USBN"'"' >> /tmp/variable.file - echo 'ETHN="'"$ETHN"'"' >> /tmp/variable.file - echo 'WDMN="'"$WDMN"'"' >> /tmp/variable.file - echo 'BASEPORT="'"$BASEPORT"'"' >> /tmp/variable.file -} -# -# delay until ROOter Initialization done -# -bootdelay() { - if [ ! -f /tmp/bootend.file ]; then - log "Delay for boot up" - sleep 10 - while [ ! -f /tmp/bootend.file ]; do - sleep 1 - done - sleep 10 - fi -} - -# -# return modem number based on port number -# 0 is not found -# -find_device() { - DEVN=$1 - COUNTER=1 - while [ $COUNTER -le $MODCNT ]; do - EMPTY=$(uci get modem.modem$COUNTER.empty) - if [ $EMPTY -eq 0 ]; then - DEVS=$(uci get modem.modem$COUNTER.device) - if [ $DEVN = $DEVS ]; then - retresult=$COUNTER - return - fi - fi - let COUNTER=COUNTER+1 - done - retresult=0 -} - -# -# check if all modems are inactive or empty -# delete all if nothing active -# -check_all_empty() { - COUNTER=1 - while [ $COUNTER -le $MODCNT ]; do - EMPTY=$(uci get modem.modem$COUNTER.empty) - if [ $EMPTY -eq 0 ]; then - ACTIVE=$(uci get modem.modem$COUNTER.active) - if [ $ACTIVE -eq 1 ]; then - return - fi - fi - let COUNTER=COUNTER+1 - done - COUNTER=1 - while [ $COUNTER -le $MODCNT ]; do - uci delete modem.modem$COUNTER - uci set modem.modem$COUNTER=modem - uci set modem.modem$COUNTER.empty=1 - let COUNTER=COUNTER+1 - done - uci set modem.general.modemnum=1 - uci commit modem - MODSTART=1 - WWAN=0 - USBN=0 - ETHN=1 - WDMN=0 - BASEPORT=0 - if - ifconfig eth1 - then - if [ -e "/sys/class/net/eth1/device/bInterfaceProtocol" ]; then - ETHN=1 - else - ETHN=2 - fi - fi - save_variables - display_top; display "No Modems present"; display_bottom -} - -change_bconf() { - local devname=$1 - local conf=$2 - local mode=$3 - local unconf=0 - log "Switching Modem at $DEVICENAME to $mode by selecting Cfg# $bestcfg" - echo $unconf >/sys/bus/usb/devices/$devname/bConfigurationValue - sleep 1 - echo $conf >/sys/bus/usb/devices/$devname/bConfigurationValue -} - - -# -# Add Modem and connect -# -if [ "$ACTION" = add ]; then - bootdelay - CNTR=0 - while [ -e /tmp/modgone ]; do - sleep 1 - CNTR=`expr $CNTR + 1` - if [ $CNTR -gt 10 ]; then - rm -f /tmp/modgone - break - fi - done - find_usb_attrs - - if echo $DEVICENAME | grep -q ":" ; then - exit 0 - fi - - if [ -z $uMa ]; then - log "Ignoring Unnamed Hub" - exit 0 - fi - - UPR=${uPr} - CT=`echo $UPR | tr '[A-Z]' '[a-z]'` - if echo $CT | grep -q "hub" ; then - log "Ignoring Named Hub" - exit 0 - fi - - if [ $uVid = 1d6b ]; then - log "Ignoring Linux Hub" - exit 0 - fi - -# -# Ignore Ethernet adapters -# - if [ $uVid = 13b1 -a $uPid = 0041 ]; then - exit 0 - elif [ $uVid = 2357 -a $uPid = 0601 ]; then - exit 0 - elif [ $uVid = 0b95 -a $uPid = 772b ]; then - exit 0 - elif [ $uVid = 0b95 -a $uPid = 1790 ]; then - exit 0 - elif [ $uVid = 0bda -a $uPid = 8152 ]; then - exit 0 - fi - - bNumConfs=$(cat /sys/bus/usb/devices/$DEVICENAME/bNumConfigurations) - bNumIfs=$(cat /sys/bus/usb/devices/$DEVICENAME/bNumInterfaces) - - # Uncomment the next line to ignore USB-Serial adapters and similar single-port devices - # if [ $bNumConfs = 1 -a $bNumIfs = 1 ] && exit 0 - - $ROOTER/proto.sh $uVid $uPid $DEVICENAME 0 - source /tmp/proto - rm -f /tmp/proto - #cat /sys/kernel/debug/usb/devices > /tmp/wdrv - #lua $ROOTER/protofind.lua $uVid $uPid 0 - #retval=$? - - if [ -e /etc/config/mjpg-streamer ]; then - if [ $retval -eq 99 ]; then - log "Start MJPEG Streamer $DEVICENAME" - /etc/init.d/mjpg-streamer start - uci delete mjpg-streamer.camera - uci set mjpg-streamer.camera=mjpg-stream - uci set mjpg-streamer.camera.idv=$DEVICENAME - uci commit mjpg-streamer - exit 0 - fi - fi - if [ -e /etc/config/p910nd ]; then - if [ $retval -eq 98 ]; then - # Check if lp device is plugged in and p910nd is not already started - log "USB Printer device plugged in, starting p910nd" - /etc/init.d/p910nd start - uci delete p910nd.printer - uci set p910nd.printer=printer - uci set p910nd.printer.idv=$DEVICENAME - uci commit p910nd - exit 0 - fi - fi - if [ $retval -eq 97 ]; then - if grep "$uVid:$uPid" /etc/usb-mode.json > /dev/null ; then - log "Modem found" - else - log "Found USB Storage" - exit 0 - fi - fi - - DELAY=1 - if [ -f /tmp/usbwait ]; then - log "Delay for previous modem" - while [ -f /tmp/usbwait ]; do - sleep 1 - let DELAY=$DELAY+1 - if [ $DELAY -gt 15 ]; then - break - fi - done - fi - echo "1" > /tmp/usbwait - - source /tmp/variable.file - source /tmp/modcnt - MODCNT=$MODCNTX - - reinsert=0 - find_device $DEVICENAME - if [ $retresult -gt 0 ]; then - ACTIVE=$(uci get modem.modem$retresult.active) - if [ $ACTIVE = 1 ]; then - rm -f /tmp/usbwait - exit 0 - else - IDP=$(uci get modem.modem$retresult.uPid) - IDV=$(uci get modem.modem$retresult.uVid) - if [ $uVid = $IDV -a $uPid = $IDP ]; then - reinsert=1 - CURRMODEM=$retresult - MODSTART=$retresult - WWANX=$(uci get modem.modem$CURRMODEM.wwan) - if [ -n "$WWANX" ]; then - WWAN=$WWANX - save_variables - fi - WDMNX=$(uci get modem.modem$CURRMODEM.wdm) - if [ -n "$WDMNX" ]; then - WDMN=$WDMNX - save_variables - fi - else - display_top; display "Reinsert of different Modem not allowed"; display_bottom - rm -f /tmp/usbwait - exit 0 - fi - fi - fi - - log "Add : $DEVICENAME: Manufacturer=${uMa:-?} Product=${uPr:-?} Serial=${uSe:-?} $uVid $uPid" - - if [ $MODSTART -gt $MODCNT ]; then - display_top; display "Exceeded Maximun Number of Modems"; display_bottom - exit 0 - fi - - if [ $reinsert = 0 ]; then - CURRMODEM=$MODSTART - fi - - FILEN=$uVid:$uPid - display_top; display "Start of Modem Detection and Connection Information" - display "Product=${uPr:-?} $uVid $uPid"; display_bottom - cat /sys/kernel/debug/usb/devices > /tmp/prembim - lua $ROOTER/mbimfind.lua $uVid $uPid - retval=$? - rm -f /tmp/prembim - if [ ! -e /sbin/umbim ]; then - retval=0 - fi - - while : ; do - bConfig=$(cat /sys/bus/usb/devices/$DEVICENAME/bConfigurationValue) - if [ -n "$bConfig" -a -n "$bNumConfs" ]; then - log "Found Modem at $DEVICENAME in Cfg#= $bConfig from $bNumConfs available" - break - else - sleep 1 - fi - done - - FORCEQMI='03f0:0857 1bc7:1900' - if echo $FORCEQMI | grep -q -i "$FILEN"; then - bestcfg=1 - if [ $bConfig -ne $bestcfg ]; then - change_bconf $DEVICENAME $bestcfg QMI - fi - else - if [ $retval -ne 0 ]; then - display_top; display "Found MBIM Modem at $DEVICENAME with Config of $retval"; display_bottom - if [ $FILEN = "12d1:15c1" ]; then - bestcfg=2 - if [ $bConfig -ne $bestcfg ]; then - change_bconf $DEVICENAME $bestcfg ECM - fi - elif [ $FILEN = "413c:81d7" -o $FILEN = "05c6:9025" ]; then - bestcfg=1 - case $bNumConfs in - "3" ) - change_bconf $DEVICENAME $bestcfg QMI - ;; - "2" ) - if [ $bNumIfs -lt 4 ]; then - change_bconf $DEVICENAME $bestcfg QMI - fi - ;; - esac - elif [ $FILEN = "03f0:9d1d" -a $bNumConfs -eq 3 ]; then - bestcfg=1 - change_bconf $DEVICENAME $bestcfg QMI - else - if [ $bConfig -ne $retval ]; then - change_bconf $DEVICENAME $retval MBIM - fi - fi - else - if grep "$FILEN" /etc/usb-mode.json > /dev/null ; then - procd_open_service "usbmode" - procd_open_instance - procd_set_param command "/sbin/usbmode" -s - procd_close_instance - procd_close_service - else - display_top; display "Device at $DEVICENAME does not have a switch data file"; display_bottom - fi - fi - fi - sleep 10 - usb_dir="/sys$DEVPATH" - idV="$(sanitize "$usb_dir/idVendor")" - idP="$(sanitize "$usb_dir/idProduct")" - display_top; display "Modem at $DEVICENAME switched to : $idV:$idP"; display_bottom - - if [ $idV = 2357 -a $idP = 9000 ]; then - sleep 10 - fi - - #cat /sys/kernel/debug/usb/devices > /tmp/wdrv - #lua $ROOTER/protofind.lua $idV $idP 1 - $ROOTER/proto.sh $uVid $uPid $DEVICENAME 1 - source /tmp/proto - rm -f /tmp/proto - #retval=$? - if [ $idV = 8087 -a $idP = 095a ]; then - retval=28 - fi - if [ $idV = 2cb7 -a $idP = 000b ]; then - retval=28 - fi - display_top; display "ProtoFind returns : $retval"; display_bottom - rm -f /tmp/wdrv - - if [ $reinsert = 0 ]; then - BASEP=$BASEPORT - if [ -f /tmp/drv ]; then - source /tmp/drv - BASEPORT=`expr $PORTN + $BASEPORT` - fi - fi - rm -f /tmp/drv - - if [ $retval -ne 0 ]; then - log "Found Modem $CURRMODEM" - if [ $reinsert = 0 ]; then - uci set modem.modem$CURRMODEM.empty=0 - uci set modem.modem$CURRMODEM.uVid=$uVid - uci set modem.modem$CURRMODEM.uPid=$uPid - uci set modem.modem$CURRMODEM.idV=$idV - uci set modem.modem$CURRMODEM.idP=$idP - uci set modem.modem$CURRMODEM.device=$DEVICENAME - uci set modem.modem$CURRMODEM.baseport=$BASEP - uci set modem.modem$CURRMODEM.maxport=$BASEPORT - uci set modem.modem$CURRMODEM.proto=$retval - uci set modem.modem$CURRMODEM.maxcontrol=/sys$DEVPATH/descriptors - find_usb_attrs - uci set modem.modem$CURRMODEM.manuf=$uMa - uci set modem.modem$CURRMODEM.model=$uPr - uci set modem.modem$CURRMODEM.serial=$uSe - uci set modem.modem$CURRMODEM.celltype="-" - fi - uci set modem.modem$CURRMODEM.active=1 - uci set modem.modem$CURRMODEM.connected=0 - uci commit modem - if [ -e $ROOTER/modem-led.sh ]; then - $ROOTER/modem-led.sh $CURRMODEM 1 - fi - fi - - if [ $reinsert = 0 -a $retval != 0 ]; then - MODSTART=`expr $MODSTART + 1` - save_variables - fi - -# -# Handle specific modem models -# - case $retval in - "0" ) - # - # ubox GPS module - # - if [ $idV = 1546 ]; then - if echo $uPr | grep -q "GPS"; then - SYMLINK="gps0" - BASEX=`expr 1 + $BASEP` - ln -s /dev/ttyUSB$BASEX /dev/${SYMLINK} - display_top ; display "Hotplug Symlink from /dev/ttyUSB$BASEX to /dev/${SYMLINK} created" - display_bottom - fi - fi - rm -f /tmp/usbwait - exit 0 - ;; - "1" ) - log "Connecting a Sierra Modem" - ln -s $ROOTER/connect/create_connect.sh $ROOTER_LINK/create_proto$CURRMODEM - $ROOTER_LINK/create_proto$CURRMODEM $CURRMODEM & - ;; - "2" ) - log "Connecting a QMI Modem" - ln -s $ROOTER/connect/create_connect.sh $ROOTER_LINK/create_proto$CURRMODEM - $ROOTER_LINK/create_proto$CURRMODEM $CURRMODEM & - ;; - "88" ) - log "Connecting a RMNET Modem" - ln -s $ROOTER/connect/create_connect.sh $ROOTER_LINK/create_proto$CURRMODEM - $ROOTER_LINK/create_proto$CURRMODEM $CURRMODEM & - ;; - "3" ) - log "Connecting a MBIM Modem" - ln -s $ROOTER/connect/create_connect.sh $ROOTER_LINK/create_proto$CURRMODEM - $ROOTER_LINK/create_proto$CURRMODEM $CURRMODEM & - ;; - "6"|"4"|"7"|"24"|"26"|"27" ) - log "Connecting a Huawei NCM Modem" - ln -s $ROOTER/connect/create_connect.sh $ROOTER_LINK/create_proto$CURRMODEM - $ROOTER_LINK/create_proto$CURRMODEM $CURRMODEM & - ;; - "28" ) - log "Connecting a Fibocom NCM Modem" - ln -s $ROOTER/connect/create_connect.sh $ROOTER_LINK/create_proto$CURRMODEM - $ROOTER_LINK/create_proto$CURRMODEM $CURRMODEM & - ;; - "5" ) - log "Connecting a Hostless Modem or Phone" - ln -s $ROOTER/connect/create_hostless.sh $ROOTER_LINK/create_proto$CURRMODEM - $ROOTER_LINK/create_proto$CURRMODEM $CURRMODEM & - ;; - "10"|"11"|"12"|"13"|"14"|"15"|"16" ) - log "Connecting a PPP Modem" - ln -s $ROOTER/ppp/create_ppp.sh $ROOTER_LINK/create_proto$CURRMODEM - $ROOTER_LINK/create_proto$CURRMODEM $CURRMODEM - ;; - "9" ) - log "Connecting an iPhone" - ln -s $ROOTER/connect/create_iphone.sh $ROOTER_LINK/create_proto$CURRMODEM - $ROOTER_LINK/create_proto$CURRMODEM $CURRMODEM - ;; - esac - -fi - -# -# Remove Modem -# -if [ "$ACTION" = remove ]; then - find_usb_attrs - - if echo $DEVICENAME | grep -q ":" ; then - exit 0 - fi - find_device $DEVICENAME - if [ $retresult -gt 0 ]; then - IDP=$(uci get modem.modem$retresult.idP) - IDV=$(uci get modem.modem$retresult.idV) - if [ $uVid = $IDV ]; then - exit 0 - else - INTER=$(uci get modem.modem$retresult.inter) - if [ -z $INTER ]; then - INTER=$retresult - fi - if [ -e $ROOTER/modem-led.sh ]; then - $ROOTER/modem-led.sh $retresult 0 - fi - uci set modem.modem$retresult.active=0 - uci set modem.modem$retresult.connected=0 - uci commit modem - if [ -e /etc/config/mwan3 ]; then - ENB=$(uci get mwan3.wan$retresult.enabled) - if [ ! -z $ENB ]; then - uci set mwan3.wan$INTER.enabled=0 - uci commit mwan3 - fi - fi - SMS=$(uci get modem.modem$CURRMODEM.sms) - if [ $SMS = 1 ]; then - if [ -e /usr/lib/sms/stopsms ]; then - /usr/lib/sms/stopsms $CURRMODEM - fi - fi - ifdown wan$INTER - uci delete network.wan$INTER - uci set network.wan$INTER=interface - uci set network.wan$INTER.proto=dhcp - ifname1="ifname" - if [ -e /etc/newstyle ]; then - ifname1="device" - fi - uci set network.wan$INTER.${ifname1}=" " - uci set network.wan$INTER.metric=$INTER"0" - uci commit network - /etc/init.d/network reload - ifdown wan$INTER - PID=$(ps |grep "getsignal$retresult" | grep -v grep |head -n 1 | awk '{print $1}') - kill -9 $PID - rm -f $ROOTER_LINK/getsignal$retresult - PID=$(ps |grep "reconnect$retresult" | grep -v grep |head -n 1 | awk '{print $1}') - kill -9 $PID - rm -f $ROOTER_LINK/reconnect$retresult - PID=$(ps |grep "create_proto$retresult" | grep -v grep |head -n 1 | awk '{print $1}') - kill -9 $PID - rm -f $ROOTER_LINK/create_proto$retresult - PID=$(ps |grep "processsms$retresult" | grep -v grep |head -n 1 | awk '{print $1}') - kill -9 $PID - rm -f $ROOTER_LINK/processsms$retresult - PID=$(ps |grep "con_monitor$retresult" | grep -v grep |head -n 1 | awk '{print $1}') - kill -9 $PID - rm -f $ROOTER_LINK/con_monitor$retresult - PID=$(ps |grep "mbim_monitor$retresult" | grep -v grep |head -n 1 | awk '{print $1}') - kill -9 $PID - rm -f $ROOTER_LINK/mbim_monitor$retresult - if [ -e /usr/lib/gps/gpskill.sh ]; then - /usr/lib/gps/gpskill.sh $retresult - fi - $ROOTER/signal/status.sh $retresult "No Modem Present" - $ROOTER/log/logger "Disconnect (Removed) Modem #$retresult" - display_top; display "Remove : $DEVICENAME : Modem $retresult"; display_bottom - check_all_empty - rm -f /tmp/usbwait - rm -f /tmp/mdown$retresult - rm -f /tmp/msimdata$retresult - rm -f /tmp/msimnum$retresult - rm -f /tmp/modgone - rm -f /tmp/bmask - rm -f /tmp/simpin$retresult - fi - else - IDV=$(uci get mjpg-streamer.camera.idv) - if [ ! -z $IDV ]; then - if [ $DEVICENAME = $IDV ]; then - uci delete mjpg-streamer.camera - uci commit mjpg-streamer - /etc/init.d/mjpg-streamer stop - log "Stop MJPEG-Streamer" - fi - fi - IDV=$(uci get p910nd.printer.idv) - if [ ! -z $IDV ]; then - if [ $DEVICENAME = $IDV ]; then - uci delete p910nd.printer - uci commit p910nd - if [ ! -d /sys$DEVPATH/*/lp0 -a -f /var/run/p9100d.pid ]; then - log "USB Printer device unplugged, stopping p910nd" - /etc/init.d/p910nd stop - # p910nd does not seem to remove .pid file when stopped, removing it manually - rm /var/run/p9100d.pid - fi - fi - fi - fi -fi - -if [ "$ACTION" = "motion" ]; then - logger webcam motion event -fi diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/ncmfind.lua b/rooter/ext-rooter-basic/files/usr/lib/rooter/ncmfind.lua deleted file mode 100644 index 3e39cb3..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/ncmfind.lua +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/lua - -drv = {} -idV = arg[1] -idP = arg[2] - -printf = function(s,...) - io.write(s:format(...)) -end - -function trim(s) - return (s:gsub("^%s*(.-)%s*$", "%1")) -end - -local Inter=0 -local file = io.open("/tmp/wdrv", "r") -repeat - local line = file:read("*line") - if line == nil then - break - end - if string.len(line) > 5 then - s, e = line:find("Vendor=") - if s ~= nil then - cs, ce = line:find(" ", e) - m_idV = trim(line:sub(e+1, cs-1)) - s, e = line:find("ProdID=") - cs, ce = line:find(" ", e) - m_idP = trim(line:sub(e+1, cs-1)) - if m_idV == idV and m_idP == idP then - repeat - line = file:read("*line") - if line == nil then - break - end - if string.len(line) > 5 then - s, e = line:find("Prot=") - if s ~= nil then - cs, ce = line:find(" ", e+1) - proto = trim(line:sub(e+1, cs)) - if proto == "2" or proto == "02" or proto == "12" or proto == "32" or proto == "42" or proto == "62" or proto == "72" then - break - else - s, e = line:find("=option") - if s ~= nil then - Inter = Inter + 1 - end - end - end - s, e = line:find("T:") - if s ~= nil then - break - end - end - until 1==0 - break - end - end - end -until 1==0 -file:close() - -os.exit(Inter) \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/nitz2sys.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/nitz2sys.sh deleted file mode 100644 index 1a00770..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/nitz2sys.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh - -log() { - logger -t "NITZ set time" "$@" -} - -CURRMODEM=$(uci -q get modem.general.modemnum) -COMMPORT="/dev/ttyUSB"$(uci -q get modem.modem$CURRMODEM.commport) -ROOTER=/usr/lib/rooter - -ATCMDD="AT+CTZU?;+CCLK?" -OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") -OX=$OX -SUCCESS=1 -NITZstat=$(echo "$OX" | grep "+CTZU: 1") -if [ -n "$NITZstat" ]; then - DTG=$(echo "$OX" | grep -o "+CCLK:.*" | cut -d\" -f2) - DTGyymmdd=$(echo "$DTG" | cut -d, -f1 | tr '/' '-') - DTGhhmmss=$(echo "$DTG" | cut -d, -f2) - DTGhhmmss=${DTGhhmmss:0:8} - DTGtz=$(echo "$DTG" | grep -o "[-+][0-9]\{1,2\}") - if [ -n "$DTGtz" ]; then - DTGif=$(date +%s -u -s "$DTGyymmdd $DTGhhmmss") - OX=$(date -s @$DTGif) - log "$OX" - SUCCESS=0 - fi -fi -exit $SUCCESS diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/portchge.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/portchge.sh deleted file mode 100644 index 968f039..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/portchge.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh - -DIR=$1 - -log() { - logger -t "port change" "$@" -} - - -CURRMODEM=$(uci get modem.general.modemnum) -BASEP=$(uci get modem.modem$CURRMODEM.baseport) -MAXP=$(uci get modem.modem$CURRMODEM.maxport) -PORT=$(uci get modem.modem$CURRMODEM.commport) - -log "$DIR" - -if [ $DIR = "up" ]; then - if [ $PORT -lt $MAXP ]; then - PORT=`expr $PORT + 1` - echo 'PORT="'"$PORT"'"' > /tmp/port$CURRMODEM.file - fi -else - if [ $PORT -gt $BASEP ]; then - PORT=`expr $PORT - 1` - echo 'PORT="'"$PORT"'"' > /tmp/port$CURRMODEM.file - fi -fi - diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/ppp/create_ppp.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/ppp/create_ppp.sh deleted file mode 100644 index e018901..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/ppp/create_ppp.sh +++ /dev/null @@ -1,247 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter -ROOTER_LINK="/tmp/links" - -log() { - modlog "Create Connection $CURRMODEM" "$@" -} - -ifname1="ifname" -if [ -e /etc/newstyle ]; then - ifname1="device" -fi - -set_dns() { - local pDNS1=$(uci -q get modem.modeminfo$CURRMODEM.dns1) - local pDNS2=$(uci -q get modem.modeminfo$CURRMODEM.dns2) - local pDNS3=$(uci -q get modem.modeminfo$CURRMODEM.dns3) - local pDNS4=$(uci -q get modem.modeminfo$CURRMODEM.dns4) - - local aDNS="$pDNS1 $pDNS2 $pDNS3 $pDNS4" - local bDNS="" - - echo "$aDNS" | grep -o "[[:graph:]]" &>/dev/null - if [ $? = 0 ]; then - log "Using DNS settings from the Connection Profile" - pdns=1 - for DNSV in $(echo "$aDNS"); do - if [ "$DNSV" != "0.0.0.0" ] && [ -z "$(echo "$bDNS" | grep -o "$DNSV")" ]; then - [ -n "$(echo "$DNSV" | grep -o ":")" ] && continue - bDNS="$bDNS $DNSV" - fi - done - - bDNS=$(echo $bDNS) - if [ $DHCP = 1 ]; then - uci set network.wan$INTER.peerdns=0 - uci set network.wan$INTER.dns="$bDNS" - fi - echo "$bDNS" > /tmp/v4dns$INTER - - bDNS="" - for DNSV in $(echo "$aDNS"); do - if [ "$DNSV" != "0:0:0:0:0:0:0:0" ] && [ -z "$(echo "$bDNS" | grep -o "$DNSV")" ]; then - [ -z "$(echo "$DNSV" | grep -o ":")" ] && continue - bDNS="$bDNS $DNSV" - fi - done - echo "$bDNS" > /tmp/v6dns$INTER - else - log "Using Provider assigned DNS" - pdns=0 - rm -f /tmp/v[46]dns$INTER - fi -} - -save_variables() { - echo 'MODSTART="'"$MODSTART"'"' > /tmp/variable.file - echo 'WWAN="'"$WWAN"'"' >> /tmp/variable.file - echo 'USBN="'"$USBN"'"' >> /tmp/variable.file - echo 'ETHN="'"$ETHN"'"' >> /tmp/variable.file - echo 'WDMN="'"$WDMN"'"' >> /tmp/variable.file - echo 'BASEPORT="'"$BASEPORT"'"' >> /tmp/variable.file -} - -get_connect() { - NAPN=$(uci get modem.modeminfo$CURRMODEM.apn) - NUSER=$(uci get modem.modeminfo$CURRMODEM.user) - NPASS=$(uci get modem.modeminfo$CURRMODEM.passw) - NAUTH=$(uci get modem.modeminfo$CURRMODEM.auth) - PINC=$(uci get modem.modeminfo$CURRMODEM.pincode) - - uci set modem.modem$CURRMODEM.apn=$NAPN - uci set modem.modem$CURRMODEM.user=$NUSER - uci set modem.modem$CURRMODEM.pass=$NPASS - uci set modem.modem$CURRMODEM.auth=$NAUTH - uci set modem.modem$CURRMODEM.pin=$PINC - uci commit modem -} - -CURRMODEM=$1 -source /tmp/variable.file - -MAN=$(uci get modem.modem$CURRMODEM.manuf) -MOD=$(uci get modem.modem$CURRMODEM.model) -BASEP=$(uci get modem.modem$CURRMODEM.baseport) -$ROOTER/signal/status.sh $CURRMODEM "$MAN $MOD" "Connecting" -PROT=$(uci get modem.modem$CURRMODEM.proto) - -DELAY=$(uci get modem.modem$CURRMODEM.delay) -if [ -z $DELAY ]; then - DELAY=5 -fi - -idV=$(uci get modem.modem$CURRMODEM.idV) -idP=$(uci get modem.modem$CURRMODEM.idP) - -cat /sys/kernel/debug/usb/devices > /tmp/cdma -lua $ROOTER/cdmafind.lua $idV $idP -retval=$? -rm -f /tmp/cdma -if [ $retval -eq 1 ]; then - log "Found CDMA modem" -fi - -case $PROT in -"10" ) - if [ $retval -eq 0 ]; then - DP=0 - CP=2 - else - DP=0 - CP=0 - fi - ;; -"11"|"12" ) - if [ $retval -eq 0 ]; then - DP=2 - CP=1 - else - DP=0 - CP=0 - fi - ;; -"13" ) - if [ $retval -eq 0 ]; then - DP=4 - CP=3 - else - DP=0 - CP=0 - fi - ;; -"14" ) - if [ $retval -eq 0 ]; then - DP=3 - CP=2 - else - DP=0 - CP=0 - fi - ;; -"15" ) - if [ $retval -eq 0 ]; then - DP=1 - CP=2 - else - DP=0 - CP=0 - fi - ;; -"16" ) - if [ $retval -eq 0 ]; then - DP=2 - CP=0 - ln -s /dev/ttyACM$CP /dev/ttyUSB$CP - ln -s /dev/ttyACM$DP /dev/ttyUSB$DP - else - DP=0 - CP=0 - fi - ;; -esac -$ROOTER/common/modemchk.lua "$idV" "$idP" "$DP" "$CP" -source /tmp/parmpass - -CPORT=`expr $CPORT + $BASEP` -DPORT=`expr $DPORT + $BASEP` -uci set modem.modem$CURRMODEM.commport=$CPORT -uci set modem.modem$CURRMODEM.dataport=$DPORT -uci set modem.modem$CURRMODEM.service=$retval -uci commit modem - -$ROOTER/common/gettype.sh $CURRMODEM -$ROOTER/connect/get_profile.sh $CURRMODEM -get_connect - -INTER=$(uci get modem.modeminfo$CURRMODEM.inter) -if [ -z $INTER ]; then - INTER=$CURRMODEM -else - if [ $INTER = 0 ]; then - INTER=$CURRMODEM - fi -fi -log "Profile for Modem $CURRMODEM sets interface to WAN$INTER" -OTHER=1 -if [ $CURRMODEM = 1 ]; then - OTHER=2 -fi -EMPTY=$(uci get modem.modem$OTHER.empty) -if [ $EMPTY = 0 ]; then - OINTER=$(uci get modem.modem$OTHER.inter) - if [ ! -z $OINTER ]; then - if [ $INTER = $OINTER ]; then - INTER=1 - if [ $OINTER = 1 ]; then - INTER=2 - fi - log "Switched Modem $CURRMODEM to WAN$INTER as Modem $OTHER is using WAN$OINTER" - fi - fi -fi -uci set modem.modem$CURRMODEM.inter=$INTER -uci commit modem -log "Modem $CURRMODEM is using WAN$INTER" -uci delete network.wan$INTER -uci set network.wan$INTER=interface -uci set network.wan$INTER.${ifname1}=3x-wan$INTER -uci set network.wan$INTER.proto=3x -if [ $retval -eq 0 ]; then - uci set network.wan$INTER.service=umts -else - uci set network.wan$INTER.service=cdma -fi -uci set network.wan$INTER.keepalive=10 -uci set network.wan$INTER.device=/dev/ttyUSB$DPORT -uci set network.wan$INTER.apn=$NAPN -uci set network.wan$INTER.username=$NUSER -uci set network.wan$INTER.auth=$NAUTH -uci set network.wan$INTER.password=$NPASS -uci set network.wan$INTER.pincode=$PINC -uci set network.wan$INTER.metric=$CURRMODEM"0" -uci set network.wan$INTER.currmodem=$CURRMODEM -uci set network.wan$INTER.pppd_options="debug noipdefault" -set_dns -uci commit network - -log "PPP Comm Port : /dev/ttyUSB$CPORT" -log "PPP Data Port : /dev/ttyUSB$DPORT" - -if [ $retval -eq 0 ]; then - case $idV in - "1199"|"0f3d"|"413c"|"2c7c"|"05c6" ) - $ROOTER/luci/celltype.sh $CURRMODEM - ;; - esac - $ROOTER/common/lockchk.sh $CURRMODEM - $ROOTER/sms/check_sms.sh $CURRMODEM & -fi - -if [ -e $ROOTER/modem-led.sh ]; then - $ROOTER/modem-led.sh $CURRMODEM 2 -fi - -rm -f /tmp/usbwait -ifup wan$INTER diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/proto.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/proto.sh deleted file mode 100644 index f4afc7f..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/proto.sh +++ /dev/null @@ -1,107 +0,0 @@ -#!/bin/sh - -log() { - modlog "Protofind $idV/$idP" "$@" -} - -idV=$1 -idP=$2 -DEVICENAME=$3 -path="/sys/bus/usb/devices/$DEVICENAME/" -cnfg=$(cat $path"bConfigurationValue") -ipath="$DEVICENAME:$cnfg." - -cntr=$(cat $path"bNumInterfaces") -cntr=$(echo "$cntr" | sed 's/[[:space:]]//g') -if [ $4 -eq 1 ]; then - log "Number Interfaces w/drivers : $cntr" -fi -serialcnt=0 -retval=0 -fcntr=0 - -while [ true ]; do - if [ -e $path$ipath$fcntr ]; then - DRIVER="" - cat $path$ipath$fcntr"/uevent" > /tmp/uevent$DEVICENAME - source /tmp/uevent$DEVICENAME - rm -f /tmp/uevent$DEVICENAME - if [ $4 -eq 1 ]; then - log "Driver Name : $fcntr $DRIVER" - fi - if [ "$DRIVER" = "option" -o "$DRIVER" = "qcserial" -o "$DRIVER" = "usb_serial" -o drv[j] == "usb_serial" -o "$DRIVER" = "sierra" ]; then - let serialcnt=$serialcnt+1 - fi - let cntr=$cntr-1 - if [ "$cntr" -lt 1 ]; then - break - fi - fi - let fcntr=$fcntr+1 -done -cntr=$(cat $path"bNumInterfaces") -cntr=$(echo "$cntr" | sed 's/[[:space:]]//g') -fcntr=0 -while [ true ]; do - if [ -e $path$ipath$fcntr ]; then - cat $path$ipath$fcntr"/uevent" > /tmp/uevent$DEVICENAME - source /tmp/uevent$DEVICENAME - rm -f /tmp/uevent$DEVICENAME - case $DRIVER in - "sierra_net" ) - retval=1 - break - ;; - "qmi_wwan" ) - retval=2 - break - ;; - "qmi_wwan_q" ) - retval=88 - break - ;; - "cdc_mbim" ) - retval=3 - break - ;; - "huawei_cdc_ncm" ) - retval=4 - break - ;; - "cdc_ncm" ) - retval=24 - break - ;; - "cdc_ether"|"rndis_host" ) - retval=5 - break - ;; - "ipheth" ) - retval=9 - break - ;; - "uvcvideo" ) - retval=99 - break - ;; - "usblp" ) - retval=98 - break - ;; - "usb-storage" ) - retval=97 - break - ;; - esac - let cntr=$cntr-1 - if [ "$cntr" -lt 1 ]; then - break - fi - fi - let fcntr=$fcntr+1 -done -if [ $serialcnt -gt 0 -a $retval -eq 0 ]; then - retval=88 -fi -echo 'retval="'"$retval"'"' > /tmp/proto - diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/protofind.lua b/rooter/ext-rooter-basic/files/usr/lib/rooter/protofind.lua deleted file mode 100644 index 1df86c6..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/protofind.lua +++ /dev/null @@ -1,247 +0,0 @@ -#!/usr/bin/lua - -drv = {} -idV = arg[1] -idP = arg[2] -pflag = arg[3] -if pflag == nil then - pflag = 1 -end - -special = {} --- PPP special cases --- VID PID port # -special[1] = "1bbb" ; special[2] = "0017" ; special[3] = 13 -special[4] = "12d1" ; special[5] = nil ; special[6] = 10 -special[7] = "1546" ; special[8] = "01a6" ; special[9] = 0 -special[10] = "1546" ; special[11] = "01a5" ; special[12] = 0 -special[13] = "1199" ; special[14] = "68a3" ; special[15] = 14 -special[16] = "2001" ; special[17] = "7e35" ; special[18] = 15 - - -retval = 0 -echo = 1 - -printf = function(s,...) - if pflag ~= 0 then - io.write(s:format(...)) - local ss = s:format(...) - if echo == 1 then - os.execute("/usr/lib/rooter/logprint.sh " .. ss) - end - end -end - -function trim(s) - return (s:gsub("^%s*(.-)%s*$", "%1")) -end - -function checkserial() - local got = 0 - j = 1 - repeat - if drv[j] ~= nil then - if drv[j] == "option" or drv[j] == "qcserial" or drv[j] == "usb_serial" or drv[j] == "sierra" then - got = 1 - break - end - j = j + 1 - end - until drv[j] == nil - return got -end - -function countserial() - local got = 0 - j = 1 - repeat - if drv[j] ~= nil then - if drv[j] == "option" or drv[j] == "sierra" or drv[j] == "usb_serial" or drv[j] == "qcserial" then - got = got + 1 - end - j = j + 1 - end - until drv[j] == nil - return got -end - --- MAIN - -local t = {} - -local i=0 -local file = io.open("/tmp/wdrv", "r") -repeat - local line = file:read("*line") - if line == nil then - break - end - if string.len(line) > 5 then - s, e = line:find("Vendor=") - if s ~= nil then - cs, ce = line:find(" ", e) - m_idV = trim(line:sub(e+1, cs-1)) - s, e = line:find("ProdID=") - cs, ce = line:find(" ", e) - m_idP = trim(line:sub(e+1, cs-1)) - if m_idV == idV and m_idP == idP then - repeat - line = file:read("*line") - if line == nil then - break - end - if string.len(line) > 5 then - s, e = line:find("T:") - if s ~= nil then - break - end - s, e = line:find("Cls=02") - if s ~= nil then - t[i] = trim(line:sub(63)) - i = i + 1 - end - s, e = line:find("Cls=ff") - if s ~= nil then - t[i] = trim(line:sub(63)) - i = i + 1 - end - s, e = line:find("1 Cls=e0") - if s ~= nil then - t[i] = trim(line:sub(63)) - i = i + 1 - end - s, e = line:find("Cls=0a") - if s ~= nil then - t[i] = trim(line:sub(63)) - i = i + 1 - end - s, e = line:find("Cls=0e") - if s ~= nil then - t[i] = trim(line:sub(63)) - i = i + 1 - end - s, e = line:find("Cls=07") - if s ~= nil then - t[i] = trim(line:sub(63)) - i = i + 1 - end - s, e = line:find("Cls=08") - if s ~= nil then - t[i] = trim(line:sub(63)) - i = i + 1 - end - end - until 1==0 - break - end - end - end -until 1==0 -file:close() -if i > 0 then - file = io.open("/tmp/drv", "w") - for j=0,i-1 do - drv[j+1] = t[j] - drver = string.format("%s%d%s%q", "DRIVER", j+1, "=", t[j]) - file:write(drver .. "\n") - end - ports = countserial() - drver = string.format("%s%s%d%s", "PORTN", "=\"", ports, "\"") - file:write(drver .. "\n") - file:close() -end - -i = 1 -repeat - if drv[i] ~= nil then - printf("Driver Name : %d %s\n", i, drv[i]) - i = i + 1 - end -until drv[i] == nil - -i = 1 -repeat - if drv[i] ~= nil then - if drv[i] == "sierra_net" then - retval = 1 - break - end - if drv[i] == "qmi_wwan" then - retval = 2 - break - end - if drv[i] == "cdc_mbim" then - retval = 3 - break - end - if drv[i] == "huawei_cdc_ncm" then - if i == 2 then - retval = 4 - else - if i == 3 then - retval = 6 - else - retval = 7 - end - end - break - end - if drv[i] == "cdc_ncm" then - if i == 2 then - retval = 24 - else - if i == 3 then - retval = 26 - else - retval = 27 - end - end - break - end - if drv[i] == "cdc_ether" or drv[i] == "rndis_host" then - retval = 5 - break - end - if drv[i] == "ipheth" then - retval = 9 - break - end - if drv[i] == "uvcvideo" then - retval = 99 - break - end - if drv[i] == "usblp" then - retval = 98 - break - end - if drv[i] == "usb-storage" then - retval = 97 - end - i = i + 1 - end -until drv[i] == nil - -if retval == 0 then - if checkserial() == 1 then - retval = 11 - k = 1 - vendor = special[k] - while vendor ~= nil do - if idV == vendor then - if special[k+1] == nil then - retval = special[k+2] - break - else - if special[k+1] == idP then - retval = special[k+2] - break - end - end - end - k = k + 3 - vendor = special[k] - end - end -end - -os.exit(retval) diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/pwrtoggle.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/pwrtoggle.sh deleted file mode 100644 index aaa15c7..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/pwrtoggle.sh +++ /dev/null @@ -1,181 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter -ROOTER_LINK="/tmp/links" - -log() { - modlog "Power Toggle $CURRMODEM" "$@" -} - -ifname1="ifname" -if [ -e /etc/newstyle ]; then - ifname1="device" -fi - -waitfor() { - CNTR=0 - while [ -e /tmp/modgone ]; do - sleep 1 - CNTR=`expr $CNTR + 1` - if [ $CNTR -gt 35 ]; then - rm -f /tmp/modgone - break - fi - done -} - -rebind() { - CFUNDONE=false - ARG=$1 - CURRMODEM=$(echo "${ARG: -1}") - PROT=$(uci -q get modem.modem$CURRMODEM.proto) - CPORT=$(uci -q get modem.modem$CURRMODEM.commport) - if [ -n "$CPORT" ]; then - VENDOR=$(uci -q get modem.modem$CURRMODEM.idV) - PRODUCT=$(uci -q get modem.modem$CURRMODEM.idP) - # list vendors that do not fully support 3GPP +CFUN - NOCFUN="2c7c" # Quectel will stuck after CFUN, so not using that method at all - case $VENDOR in - "12d1" ) - ATCMDD="AT^RESET" - ;; - "2c7c" ) - ATCMDD="AT" - ;; - * ) - ATCMDD="AT+CFUN=1,1" - ;; - esac - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - if `echo ${OX} | grep "OK" 1>/dev/null 2>&1` && \ - [[ ! `echo $NOCFUN | grep -o "$VENDOR"` ]]; then - CFUNDONE=true - log "Hard modem reset done on /dev/ttyUSB$CPORT to reload drivers" - ifdown wan$CURRMODEM - uci delete network.wan$CURRMODEM - uci set network.wan$CURRMODEM=interface - uci set network.wan$CURRMODEM.proto=dhcp - uci set network.wan$CURRMODEM.${ifname1}="wan"$CURRMODEM - uci set network.wan$CURRMODEM.metric=$CURRMODEM"0" - uci commit network - /etc/init.d/network reload - ifdown wan$CURRMODEM - echo "1" > /tmp/modgone - log "Setting Modem Removal flag (1)" - fi - fi - if ! $CFUNDONE; then - PORT=$1 - log "Re-binding USB driver on $PORT to reset modem" - echo $PORT > /sys/bus/usb/drivers/usb/unbind - sleep 35 - echo $PORT > /sys/bus/usb/drivers/usb/bind - ifdown wan$CURRMODEM - uci delete network.wan$CURRMODEM - uci set network.wan$CURRMODEM=interface - uci set network.wan$CURRMODEM.proto=dhcp - uci set network.wan$CURRMODEM.${ifname1}="wan"$CURRMODEM - uci set network.wan$CURRMODEM.metric=$CURRMODEM"0" - uci commit network - /etc/init.d/network reload - ifdown wan$CURRMODEM - echo "1" > /tmp/modgone - log "Setting Modem Removal flag (2)" - if [[ -n "$CPORT" ]] && [[ ! `echo $NOCFUN | grep -o "$VENDOR"` ]]; then - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - sleep 30 - else - if [ -f $ROOTER_LINK/reconnect$CURRMODEM ]; then - $ROOTER_LINK/reconnect$CURRMODEM $CURRMODEM & - fi - fi - fi -} - -power_toggle() { - MODE=$1 - REBIND=false - if [ -f "/tmp/gpiopin" ]; then - rm -f /tmp/modgone - source /tmp/gpiopin - if [ -f "/tmp/gpioname" ]; then - source /tmp/gpioname - else - echo "$GPIOPIN" > /sys/class/gpio/unexport - echo "$GPIOPIN" > /sys/class/gpio/export - if [ $? -eq 0 ]; then - echo "out" > /sys/class/gpio/gpio$GPIOPIN/direction - if [ $? -ne 0 ]; then - REBIND=true - fi - else - REBIND=true - fi - fi - if ! $REBIND; then - if [ -z $GPIOPIN2 ]; then - if [ -z $GPIONAME ]; then - GPIOT="gpio$GPIOPIN" - else - GPIOT=$GPIONAME - fi - echo 0 > /sys/class/gpio/$GPIOT/value - waitfor - echo 1 > /sys/class/gpio/$GPIOT/value - else - if [ -z $GPIONAME2 ]; then - echo "$GPIOPIN2" > /sys/class/gpio/unexport - echo "$GPIOPIN2" > /sys/class/gpio/export - echo "out" > /sys/class/gpio/gpio$GPIOPIN2/direction - - GPIOT2="gpio$GPIOPIN2" - else - GPIOT2=$GPIONAME2 - fi - if [ -z $GPIONAME ]; then - GPIOT="gpio$GPIOPIN" - else - GPIOT=$GPIONAME - fi - if [ $MODE = 1 ]; then - echo 0 > /sys/class/gpio/$GPIOT/value - waitfor - echo 1 > /sys/class/gpio/$GPIOT/value - fi - if [ $MODE = 2 ]; then - echo 0 > /sys/class/gpio/$GPIOT2/value - waitfor - echo 1 > /sys/class/gpio/$GPIOT2/value - fi - if [ $MODE = 3 ]; then - echo 0 > /sys/class/gpio/$GPIOT/value - echo 0 > /sys/class/gpio/$GPIOT2/value - waitfor - echo 1 > /sys/class/gpio/$GPIOT/value - echo 1 > /sys/class/gpio/$GPIOT2/value - fi - sleep 2 - fi - echo "1" > /tmp/modgone - log "Power Toggle Modem" - log "Setting Modem Removal flag (3)" - fi - else - REBIND=true - fi - if $REBIND; then - # unbind/bind driver from USB to reset modem when power toggle is selected, but not available - if [ $MODE = 1 ]; then - PORT="usb1" - rebind $PORT - fi - if [ $MODE = 2 ]; then - PORT="usb2" - rebind $PORT - fi - echo "1" > /tmp/modgone - log "Setting Modem Removal flag (4)" - fi -} - -power_toggle $1 diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/shutall.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/shutall.sh deleted file mode 100644 index 32aabd9..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/shutall.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter -CURRMODEM=1 -COMMPORT=$(uci get modem.modem$CURRMODEM.commport) -if [ -n "$COMMPORT" ]; then - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$COMMPORT" "run-at.gcom" "$CURRMODEM" "AT+CFUN=0") -fi -CURRMODEM=2 -COMMPORT=$(uci get modem.modem$CURRMODEM.commport) -if [ -n "$COMMPORT" ]; then - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$COMMPORT" "run-at.gcom" "$CURRMODEM" "AT+CFUN=0") -fi -poweroff diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/signal/basedata.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/signal/basedata.sh deleted file mode 100644 index 4b0a31e..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/signal/basedata.sh +++ /dev/null @@ -1,78 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -log() { - logger -t "basedata" "$@" -} - -CURRMODEM=$1 -COMMPORT=$2 - -get_base() { - echo "0" > /tmp/block - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "baseinfo.gcom" "$CURRMODEM") - O=$($ROOTER/common/processat.sh "$OX") - rm -f /tmp/block -} - -get_base - -DOWN=$(echo "$O" | awk -F[,] '/\+CGEQNEG:/ {printf "%s", $4}') -if [ "x$DOWN" != "x" ]; then - UP=$(echo "$O" | awk -F[,] '/\+CGEQNEG:/ {printf "%s", $3}') - DOWN=$DOWN" kbps Down | " - UP=$UP" kbps Up" -else - DOWN="-" - UP="-" -fi - -MANUF=$(echo "$O" | awk -F[:] '/Manufacturer:/ { print $2}') -if [ "x$MANUF" = "x" ]; then - MANUF=$(uci get modem.modem$CURRMODEM.manuf) -fi - -MODEL=$(echo "$O" | awk -F[,\ ] '/^\+MODEL:/ {print $2}') -if [ "x$MODEL" != "x" ]; then - MODEL=$(echo "$MODEL" | sed -e 's/"//g') - if [ $MODEL = 0 ]; then - MODEL = "mf820" - fi -else - MODEL=$(uci get modem.modem$CURRMODEM.model) -fi -MODEM=$MANUF" "$MODEL - -pval=$(uci get modem.modem$CURRMODEM.proto) -case $pval in -"1" ) - PROTO="Direct-IP" - ;; -"88" ) - PROTO="(QMI-RMNET)" - ;; -"2" ) - PROTO="QMI" - ;; -"3"|"30" ) - PROTO="MBIM" - ;; -"6"|"4"|"7"|"24"|"26"|"27"|"28" ) - PROTO="NCM" - ;; -"10"|"11"|"12"|"13"|"14"|"15" ) - PROTO="PPP" - ;; -"5" ) - PROTO="Ethernet" - ;; -"9" ) - PROTO="ipheth" - ;; -esac - -echo 'MODEM="'"$MODEM"'"' >> /tmp/base$CURRMODEM.file -echo 'DOWN="'"$DOWN"'"' >> /tmp/base$CURRMODEM.file -echo 'UP="'"$UP"'"' >> /tmp/base$CURRMODEM.file -echo 'PROTO="'"$PROTO"'"' >> /tmp/base$CURRMODEM.file diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/signal/celldata.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/signal/celldata.sh deleted file mode 100644 index 4e163f7..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/signal/celldata.sh +++ /dev/null @@ -1,136 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -CURRMODEM=$1 -COMMPORT=$2 - -if [ -e /etc/nocops ]; then - echo "0" > /tmp/block - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "cellinfo0.gcom" "$CURRMODEM") - rm -f /tmp/block -else - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "cellinfo0.gcom" "$CURRMODEM") -fi -OY=$($ROOTER/gcom/gcom-locked "$COMMPORT" "cellinfo.gcom" "$CURRMODEM") -OXx=$OX - -OX=$(echo $OX | tr 'a-z' 'A-Z') -OY=$(echo $OY | tr 'a-z' 'A-Z') -OX=$OX" "$OY - -COPS="-" -COPS_MCC="-" -COPS_MNC="-" -COPSX=$(echo $OXx | grep -o "+COPS: [01],0,.\+," | cut -d, -f3 | grep -o "[^\"]\+") - -if [ "x$COPSX" != "x" ]; then - COPS=$COPSX -fi - -COPSX=$(echo $OX | grep -o "+COPS: [01],2,.\+," | cut -d, -f3 | grep -o "[^\"]\+") - -if [ "x$COPSX" != "x" ]; then - COPS_MCC=${COPSX:0:3} - COPS_MNC=${COPSX:3:3} - if [ "$COPS" = "-" ]; then - COPS=$(awk -F[\;] '/'$COPS'/ {print $2}' $ROOTER/signal/mccmnc.data) - [ "x$COPS" = "x" ] && COPS="-" - fi -fi - -if [ "$COPS" = "-" ]; then - COPS=$(echo "$O" | awk -F[\"] '/^\+COPS: 0,0/ {print $2}') - if [ "x$COPS" = "x" ]; then - COPS="-" - COPS_MCC="-" - COPS_MNC="-" - fi -fi -COPS_MNC=" "$COPS_MNC - -OX=$(echo "${OX//[ \"]/}") - -CID="" -CID5="" -RAT="" -REGV=$(echo "$OX" | grep -o "+C5GREG:2,[0-9],[A-F0-9]\{2,6\},[A-F0-9]\{5,10\},[0-9]\{1,2\}") -if [ -n "$REGV" ]; then - LAC5=$(echo "$REGV" | cut -d, -f3) - LAC5=$LAC5" ($(printf "%d" 0x$LAC5))" - CID5=$(echo "$REGV" | cut -d, -f4) - CID5L=$(printf "%010X" 0x$CID5) - RNC5=${CID5L:1:6} - RNC5=$RNC5" ($(printf "%d" 0x$RNC5))" - CID5=${CID5L:7:3} - CID5="Short $(printf "%X" 0x$CID5) ($(printf "%d" 0x$CID5)), Long $(printf "%X" 0x$CID5L) ($(printf "%d" 0x$CID5L))" - RAT=$(echo "$REGV" | cut -d, -f5) -fi -REGV=$(echo "$OX" | grep -o "+CEREG:2,[0-9],[A-F0-9]\{2,4\},[A-F0-9]\{5,8\}") -REGFMT="3GPP" -if [ -z "$REGV" ]; then - REGV=$(echo "$OX" | grep -o "+CEREG:2,[0-9],[A-F0-9]\{2,4\},[A-F0-9]\{1,3\},[A-F0-9]\{5,8\}") - REGFMT="SW" -fi -if [ -n "$REGV" ]; then - LAC=$(echo "$REGV" | cut -d, -f3) - LAC=$(printf "%04X" 0x$LAC)" ($(printf "%d" 0x$LAC))" - if [ $REGFMT = "3GPP" ]; then - CID=$(echo "$REGV" | cut -d, -f4) - else - CID=$(echo "$REGV" | cut -d, -f5) - fi - CIDL=$(printf "%08X" 0x$CID) - RNC=${CIDL:1:5} - RNC=$RNC" ($(printf "%d" 0x$RNC))" - CID=${CIDL:6:2} - CID="Short $(printf "%X" 0x$CID) ($(printf "%d" 0x$CID)), Long $(printf "%X" 0x$CIDL) ($(printf "%d" 0x$CIDL))" - -else - REGV=$(echo "$OX" | grep -o "+CREG:2,[0-9],[A-F0-9]\{2,4\},[A-F0-9]\{2,8\}") - if [ -n "$REGV" ]; then - LAC=$(echo "$REGV" | cut -d, -f3) - CID=$(echo "$REGV" | cut -d, -f4) - if [ ${#CID} -gt 4 ]; then - LAC=$(printf "%04X" 0x$LAC)" ($(printf "%d" 0x$LAC))" - CIDL=$(printf "%08X" 0x$CID) - RNC=${CIDL:1:3} - CID=${CIDL:4:4} - CID="Short $(printf "%X" 0x$CID) ($(printf "%d" 0x$CID)), Long $(printf "%X" 0x$CIDL) ($(printf "%d" 0x$CIDL))" - else - LAC="" - fi - else - LAC="" - fi -fi -REGSTAT=$(echo "$REGV" | cut -d, -f2) -if [ "$REGSTAT" == "5" -a "$COPS" != "-" ]; then - COPS_MNC=$COPS_MNC" (Roaming)" -fi -if [ -n "$CID" -a -n "$CID5" ] && [ "$RAT" == "13" -o "$RAT" == "10" ]; then - LAC="4G $LAC, 5G $LAC5" - CID="4G $CID
                                                                      5G $CID5" - RNC="4G $RNC, 5G $RNC5" -elif [ -n "$CID5" ]; then - LAC=$LAC5 - CID=$CID5 - RNC=$RNC5 -fi -if [ -z "$LAC" ]; then - LAC="-" - CID="-" - RNC="-" -fi - -{ - echo 'COPS="'"$COPS"'"' - echo 'COPS_MCC="'"$COPS_MCC"'"' - echo 'COPS_MNC="'"$COPS_MNC"'"' - echo 'LAC="'"$LAC"'"' - echo 'LAC_NUM="'""'"' - echo 'CID="'"$CID"'"' - echo 'CID_NUM="'""'"' - echo 'RNC="'"$RNC"'"' - echo 'RNC_NUM="'""'"' -} > /tmp/cell$CURRMODEM.file diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/signal/celltype.lua b/rooter/ext-rooter-basic/files/usr/lib/rooter/signal/celltype.lua deleted file mode 100644 index 62b8ab5..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/signal/celltype.lua +++ /dev/null @@ -1,142 +0,0 @@ -#!/usr/bin/lua - -modem = arg[1] -numb = arg[2] -echo = 0 - -datalist = {} -celllist = {} - -datalist[1] = "320u" -celllist[1] = 2 -datalist[2] = "330u" -celllist[2] = 2 -datalist[3] = "e3276" -celllist[3] = 3 -datalist[4] = "e398" -celllist[4] = 3 -datalist[5] = "e389" -celllist[5] = 3 -datalist[6] = "e392" -celllist[6] = 3 -datalist[7] = "e397" -celllist[7] = 3 -datalist[8] = "e8278" -celllist[8] = 3 -datalist[9] = "mf820" -celllist[9] = 3 -datalist[10] = "mf821" -celllist[10] = 3 -datalist[11] = "k5005" -celllist[11] = 3 -datalist[12] = "k5007" -celllist[12] = 3 -datalist[13] = "l800" -celllist[13] = 3 -datalist[14] = "e398" -celllist[14] = 3 -datalist[15] = "mf880" -celllist[15] = 3 -datalist[16] = "e3272" -celllist[16] = 3 -datalist[17] = "e3372" -celllist[17] = 3 -datalist[18] = "lte" -celllist[18] = 3 -datalist[19] = "340u" -celllist[19] = 2 -datalist[20] = "mf91d" -celllist[20] = 3 -datalist[21] = "mf825a" -celllist[21] = 3 -datalist[22] = "mf826" -celllist[22] = 3 -datalist[23] = "313u" -celllist[23] = 2 -datalist[24] = "341u" -celllist[24] = 2 -datalist[25] = "em74" -celllist[25] = 2 -datalist[26] = "mc74" -celllist[26] = 2 -datalist[27] = "em75" -celllist[27] = 2 -datalist[28] = "ec2" -celllist[28] = 3 -datalist[29] = "em06" -celllist[29] = 2 -datalist[30] = "ep06" -celllist[30] = 2 -datalist[31] = "slm750" -celllist[31] = 3 -datalist[32] = "bg96" -celllist[32] = 3 -datalist[33] = "em12" -celllist[33] = 2 -datalist[34] = "em20" -celllist[34] = 2 -datalist[35] = "rm5" -celllist[35] = 4 -datalist[36] = "l850" -celllist[36] = 2 -datalist[37] = "l860" -celllist[37] = 2 -datalist[38] = "fm15" -celllist[38] = 4 -datalist[39] = "em18" -celllist[39] = 2 -datalist[40] = "4105" -celllist[40] = 2 -datalist[41] = "em919" -celllist[41] = 4 -datalist[42] = "em16" -celllist[42] = 2 -datalist[43] = "sim820" -celllist[43] = 4 -datalist[44] = "mc73" -celllist[44] = 2 -datalist[45] = "eg25" -celllist[45] = 2 -datalist[46] = "srm8" -celllist[46] = 4 -datalist[47] = "4087" -celllist[47] = 3 -datalist[48] = "rg5" -celllist[48] = 4 -datalist[49] = "eg12" -celllist[49] = 2 -datalist[50] = "eg18" -celllist[50] = 2 -datalist[51] = "megafon" -celllist[51] = 2 -datalist[52] = "ln9" -celllist[52] = 2 - -printf = function(s,...) - if echo == 0 then - io.write(s:format(...)) - else - ss = s:format(...) - os.execute("/usr/lib/rooter/logprint.sh " .. ss) - end -end - -found = 3 -index = 1 -line = datalist[index] -data = string.lower(modem) - -while line ~= nil do - s, e = string.find(data, line) - if s ~= nil then - found = celllist[index] - break - end - index = index + 1 - line = datalist[index] -end - -file = io.open("/tmp/celltype" .. numb, "w") -cell = string.format("%s%s%s%s", "CELL", "=\"", found, "\"") -file:write(cell.. "\n") -file:close() diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/signal/huaweihostless.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/signal/huaweihostless.sh deleted file mode 100644 index aa3fd3f..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/signal/huaweihostless.sh +++ /dev/null @@ -1,205 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -log() { - logger -t "hostless " "$@" -} - -TMPFILE="/tmp/XXXXXX" - -handle_timeout(){ - local wget_pid="$1" - local count=0 - ps | grep -v grep | grep $wget_pid - res="$?" - while [ "$res" = 0 -a $count -lt "$((TIMEOUT))" ]; do - sleep 1 - count=$((count+1)) - ps | grep -v grep | grep $wget_pid - res="$?" - done - - if [ "$res" = 0 ]; then - log "Killing process on timeout" - kill "$wget_pid" 2> /dev/null - ps | grep -v grep | grep $wget_pid - res="$?" - if [ "$res" = 0 ]; then - log "Killing process on timeout" - kill -9 $wget_pid 2> /dev/null - fi - fi -} - -make_status() { - echo "$IP" > /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "$CSQ" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "$MODEM" >> /tmp/status$CURRMODEM.file - echo "$COPS" >> /tmp/status$CURRMODEM.file - echo "$NETWORK" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "$COPS_MCC" >> /tmp/status$CURRMODEM.file - echo "$COPS_MNC" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo " " >> /tmp/status$CURRMODEM.file - echo " " >> /tmp/status$CURRMODEM.file - echo "$MONSTAT" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "$CONN" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "Hostless/Phone" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file -} - -get_signal() { - TIMEOUT=3 - wget http://$IP/api/monitoring/status --load-cookies cookie -O $TMPFILE > /dev/null 2>&1 & - handle_timeout "$!" - local in_CurrentNetworkType="`cat $TMPFILE | grep \"\" | cut -d \">\" -f 2 | cut -d \"<\" -f 1`" - if [ -z $in_CurrentNetworkType ]; then - NETWORK="-" - else - [ "$in_CurrentNetworkType" = "19" ] && NETWORK="LTE" # LTE - [ "$in_CurrentNetworkType" = "9" ] && NETWORK="HSPA+" # HSPA+ - [ "$in_CurrentNetworkType" = "7" ] && NETWORK="HSPA" # HSPA - [ "$in_CurrentNetworkType" = "6" ] && NETWORK="HSUPA" # HSUPA - [ "$in_CurrentNetworkType" = "5" ] && NETWORK="HSDPA" # HSDPA - [ "$in_CurrentNetworkType" = "4" ] && NETWORK="WCDMA" # WCDMA - [ "$in_CurrentNetworkType" = "3" ] && NETWORK="EDGE" # EDGE - [ "$in_CurrentNetworkType" = "2" ] && NETWORK="GPRS" # GPRS - [ "$in_CurrentNetworkType" = "1" ] && NETWORK="GSM" # GSM - fi - SIGNAL="" - local in_SignalStrength="`cat $TMPFILE | grep \"\" | cut -d \">\" -f 2 | cut -d \"<\" -f 1`" - [ "$in_SignalStrength" != "" ] && SIGNAL="$in_SignalStrength" - - if [ "$SIGNAL" = "" ]; then - in_SignalStrength="`cat $TMPFILE | grep \"\" | cut -d \">\" -f 2 | cut -d \"<\" -f 1`" - [ "$in_SignalStrength" != "" ] && SIGNAL="$((in_SignalStrength*20))" - fi - [ -z $SIGNAL ] && SIGNAL=0 - rm -f $TMPFILE -} - -CURRMODEM=$1 -PROTO=$2 -CONN="Modem #"$CURRMODEM - -MANUF=$(uci get modem.modem$CURRMODEM.manuf) -MODEL=$(uci get modem.modem$CURRMODEM.model) -MODEM=$MANUF" "$MODEL -IP=$(uci get modem.modem$CURRMODEM.ip) - -STARTIMEX=$(date +%s) -MONSTAT="Unknown" -rm -f /tmp/monstat$CURRMODEM - -sleep 5 -TIMEOUT=5 -wget -q http://$IP/html/home.html -O nul --save-cookies cookie --keep-session-cookies -sleep 5 -wget http://$IP/api/net/current-plmn -O $TMPFILE --load-cookies cookie > /dev/null 2>&1 & -handle_timeout "$!" - -wget http://$IP/api/device/information -O $TMPFILE --load-cookies cookie > /dev/null 2>&1 & -handle_timeout "$!" -in_mod="`cat $TMPFILE | grep \"\" | cut -d \">\" -f 2 | cut -d \"<\" -f 1`" -if [ "$in_mod" != "" ]; then - MODEM=$MANUF" "$in_mod -fi -IMEI="Unknown" -IMSI="Unknown" -ICCID="Unknown" -CNUM="*" -CNUMx="*" -in_im="`cat $TMPFILE | grep \"\" | cut -d \">\" -f 2 | cut -d \"<\" -f 1`" -if [ "$in_im" != "" ]; then - IMEI=$in_im -fi -in_im="`cat $TMPFILE | grep \"\" | cut -d \">\" -f 2 | cut -d \"<\" -f 1`" -if [ "$in_im" != "" ]; then - IMSI=$in_im -fi -in_im="`cat $TMPFILE | grep \"\" | cut -d \">\" -f 2 | cut -d \"<\" -f 1`" -if [ "$in_im" != "" ]; then - ICCID=$in_im -fi -in_im="`cat $TMPFILE | grep \"\" | cut -d \">\" -f 2 | cut -d \"<\" -f 1`" -if [ "$in_im" != "" ]; then - CNUM=$in_im -fi - - -IDP=$(uci get modem.modem$CURRMODEM.idP) -IDV=$(uci get modem.modem$CURRMODEM.idV) - -echo $IDV" : "$IDP > /tmp/msimdatax$CURRMODEM -echo "$IMEI" >> /tmp/msimdatax$CURRMODEM -echo "$IMSI" >> /tmp/msimdatax$CURRMODEM -echo "$ICCID" >> /tmp/msimdatax$CURRMODEM -echo "1" >> /tmp/msimdatax$CURRMODEM -mv -f /tmp/msimdatax$CURRMODEM /tmp/msimdata$CURRMODEM -echo "$CNUM" > /tmp/msimnumx$CURRMODEM -echo "$CNUMx" >> /tmp/msimnumx$CURRMODEM -mv -f /tmp/msimnumx$CURRMODEM /tmp/msimnum$CURRMODEM - -sleep 20 -TIMEOUT=20 -wget http://$IP/api/net/current-plmn -O $TMPFILE --load-cookies cookie > /dev/null 2>&1 & -handle_timeout "$!" -COPS="" -in_provider="`cat $TMPFILE | grep \"\" | cut -d \">\" -f 2 | cut -d \"<\" -f 1`" -[ "$in_provider" != "" ] && COPS="$in_provider" - -if [ "$COPS" = "" ]; then - COPS="-" - in_provider="`cat $TMPFILE | grep \"\" | cut -d \">\" -f 2 | cut -d \"<\" -f 1`" - [ "$in_provider" != "" ] && COPS="$in_provider)" -fi -COPS_MCC="-" -COPS_MNC="-" -in_mcc="`cat $TMPFILE | grep \"\" | cut -d \">\" -f 2 | cut -d \"<\" -f 1`" -if [ "$in_mcc" != "" ]; then - COPS_MCC=${in_mcc:0:3} - COPS_MNC=${in_mcc:3:3} -fi -COPS_MNC=" "$COPS_MNC -TIMEOUT=5 - -while [ 1 = 1 ]; do - get_signal - CSQ="$SIGNAL" - if [ -e /tmp/monstat$CURRMODEM ]; then - source /tmp/monstat$CURRMODEM - fi - if [ -z $MONSTAT ]; then - MONSTAT="Unknown" - fi - make_status - CURRTIME=$(date +%s) - let ELAPSE=CURRTIME-STARTIMEX - while [ $ELAPSE -lt 10 ]; do - sleep 2 - CURRTIME=$(date +%s) - let ELAPSE=CURRTIME-STARTIMEX - done - STARTIMEX=$CURRTIME -done diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/signal/mccmnc.data b/rooter/ext-rooter-basic/files/usr/lib/rooter/signal/mccmnc.data deleted file mode 100644 index b4cdb19..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/signal/mccmnc.data +++ /dev/null @@ -1,11 +0,0 @@ -50501;Telstra -50502;Optus -50503;Vodafone -50506;3 -302220;Telus -302610;Bell -302720;Rogers Communication -24004;SWEDEN -24005;Sweden 3G -24008;Telenor SE -51503;Smart \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/signal/modemsignal.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/signal/modemsignal.sh deleted file mode 100644 index 09ea6a6..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/signal/modemsignal.sh +++ /dev/null @@ -1,287 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -log() { - logger -t "modem signal" "$@" -} - -CURRMODEM=$1 -PROTO=$2 -CONN="Modem #"$CURRMODEM -STARTIME=$(date +%s) -STARTIMEX=$(date +%s) -SMSTIME=0 -COMMPORT="/dev/ttyUSB"$(uci get modem.modem$CURRMODEM.commport) -NUMB=0 -MONSTAT="Unknown" -rm -f /tmp/monstat$CURRMODEM - -make_connect() { - { - echo "Changing Port" - echo "-" - echo "-" - echo "-" - echo "$MODEM" - echo "-" - echo "-" - echo "-" - echo "-" - echo "-" - echo "-" - echo "-" - echo "-" - echo "-" - echo "-" - echo "-" - echo "-" - echo "-" - echo "-" - echo " " - echo " " - echo "-" - echo "-" - echo "-" - echo "$CONN" - echo "-" - echo "-" - echo "-" - echo "-" - echo "-" - echo "-" - echo "-" - echo "-" - echo "-" - echo "-" - } > /tmp/statusx$CURRMODEM.file - mv -f /tmp/statusx$CURRMODEM.file /tmp/status$CURRMODEM.file -} - -make_signal() { - { - if [ -e $ROOTER/provchk.sh ]; then - $ROOTER/provchk.sh $COPS $CURRMODEM - source /tmp/cops$CURRMODEM.file - rm -f /tmp/cops$CURRMODEM.file - fi - echo "$COMMPORT" - echo "$CSQ" - echo "$CSQ_PER" - echo "$CSQ_RSSI" - echo "$MODEM" - echo "$COPS" - echo "$MODE" - echo "$LAC" - echo "$LAC_NUM" - echo "$CID" - echo "$CID_NUM" - echo "$COPS_MCC" - echo "$COPS_MNC" - echo "$RNC" - echo "$RNC_NUM" - echo "$DOWN" - echo "$UP" - echo "$ECIO" - echo "$RSCP" - echo "$ECIO1" - echo "$RSCP1" - echo "$MONSTAT" - echo "$CELL" - echo "$MODTYPE" - echo "$CONN" - echo "$CHANNEL" - echo "$CNUM" - echo "$CNAM" - echo "$LBAND" - echo "$TEMP" - echo "$PROTO" - echo "$PCI" - echo "$SINR" - echo "$LATITUDE" - echo "$LONGITUDE" - } > /tmp/statusx$CURRMODEM.file - mv -f /tmp/statusx$CURRMODEM.file /tmp/status$CURRMODEM.file - if [ -e $ROOTER/modem-led.sh ]; then - $ROOTER/modem-led.sh $CURRMODEM 4 $CSQ - fi -} - -get_basic() { - $ROOTER/signal/basedata.sh $CURRMODEM $COMMPORT - if [ -e /tmp/base$CURRMODEM.file ]; then - source /tmp/base$CURRMODEM.file - rm -f /tmp/base$CURRMODEM.file - fi - $ROOTER/signal/celldata.sh $CURRMODEM $COMMPORT - if [ -e /tmp/cell$CURRMODEM.file ]; then - source /tmp/cell$CURRMODEM.file - rm -f /tmp/cell$CURRMODEM.file - fi - lua $ROOTER/signal/celltype.lua "$MODEM" $CURRMODEM - if [ -e /tmp/celltype$CURRMODEM ]; then - source /tmp/celltype$CURRMODEM - rm -f /tmp/celltype$CURRMODEM - fi -} - -get_basic -while [ 1 = 1 ]; do - get_basic - if [ -e /tmp/port$CURRMODEM.file ]; then - source /tmp/port$CURRMODEM.file - rm -f /tmp/port$CURRMODEM.file - COMMPORT="/dev/ttyUSB"$PORT - uci set modem.modem$CURRMODEM.commport=$PORT - make_connect - get_basic - STARTIME=$(date +%s) - else - CURRTIME=$(date +%s) - let ELAPSE=CURRTIME-STARTIME - if [ $ELAPSE -ge 60 ]; then - STARTIME=$CURRTIME - $ROOTER/signal/celldata.sh $CURRMODEM $COMMPORT - if [ -e /tmp/cell$CURRMODEM.file ]; then - source /tmp/cell$CURRMODEM.file - rm -f /tmp/cell$CURRMODEM.file - fi - fi - if [ -e /tmp/port$CURRMODEM.file ]; then - source /tmp/port$CURRMODEM.file - rm -f /tmp/port$CURRMODEM.file - COMMPORT="/dev/ttyUSB"$PORT - uci set modem.modem$CURRMODEM.commport=$PORT - make_connect - get_basic - STARTIME=$(date +%s) - else - VENDOR=$(uci get modem.modem$CURRMODEM.idV) - PROD=$(uci get modem.modem$CURRMODEM.idP) -# This case statement should be kept in sync with: $ROOTER/luci/celltype.sh - case $VENDOR in - "1199"|"0f3d" ) - $ROOTER/common/sierradata.sh $CURRMODEM $COMMPORT - ;; - "19d2" ) - if [ $PROD = 1432 ]; then - $ROOTER/common/mdm9215data.sh $CURRMODEM $COMMPORT - else - $ROOTER/common/ztedata.sh $CURRMODEM $COMMPORT - fi - ;; - "12d1" ) - $ROOTER/common/huaweidata.sh $CURRMODEM $COMMPORT - ;; - "2c7c" ) - $ROOTER/common/quecteldata.sh $CURRMODEM $COMMPORT - ;; - "2cb7"|"1508" ) - $ROOTER/common/fibocomdata.sh $CURRMODEM $COMMPORT - ;; - "2dee" ) - $ROOTER/common/meigdata.sh $CURRMODEM $COMMPORT - ;; - "05c6" ) - case $PROD in - "f601" ) - $ROOTER/common/meigdata.sh $CURRMODEM $COMMPORT - ;; - "5042" ) - $ROOTER/common/mdm9215data.sh $CURRMODEM $COMMPORT - ;; - "9090"|"9003"|"9215" ) - $ROOTER/common/quecteldata.sh $CURRMODEM $COMMPORT - ;; - "90db" ) - $ROOTER/common/simcomdata.sh $CURRMODEM $COMMPORT - ;; - * ) - $ROOTER/common/otherdata.sh $CURRMODEM $COMMPORT - ;; - esac - ;; - "1bc7" ) - case $PROD in - "1900"|"1901"|"1910"|"1911" ) - $ROOTER/common/t77data.sh $CURRMODEM $COMMPORT - ;; - * ) - $ROOTER/common/telitdata.sh $CURRMODEM $COMMPORT - ;; - esac - ;; - "1410" ) - $ROOTER/common/novateldata.sh $CURRMODEM $COMMPORT - ;; - "413c" ) - case $PROD in - "81d7"|"81d8"|"81e0" ) - $ROOTER/common/t77data.sh $CURRMODEM $COMMPORT - ;; - * ) - $ROOTER/common/sierradata.sh $CURRMODEM $COMMPORT - ;; - esac - ;; - "0489" |"03f0" ) - $ROOTER/common/t77data.sh $CURRMODEM $COMMPORT - ;; - "1e0e" ) - $ROOTER/common/simcomdata.sh $CURRMODEM $COMMPORT - ;; - "8087" ) - if [ $PROD = "095a" ]; then - $ROOTER/common/fibocomdata.sh $CURRMODEM $COMMPORT - fi - ;; - "0408" ) - $ROOTER/common/quantadata.sh $CURRMODEM $COMMPORT - ;; - * ) - $ROOTER/common/otherdata.sh $CURRMODEM $COMMPORT - ;; - esac - CHANNEL="-" - PCI="-" - LBAND="-" - TEMP="-" - SINR="-" - LATITUDE="-" - LONGITUDE="-" - if [ -e /tmp/signal$CURRMODEM.file ]; then - source /tmp/signal$CURRMODEM.file - rm -f /tmp/signal$CURRMODEM.file - fi - if [ -e /tmp/phonenumber$CURRMODEM ]; then - source /tmp/phonenumber$CURRMODEM - rm -f /tmp/phonenumber$CURRMODEM - fi - if [ -e /tmp/gpsdata ]; then - source /tmp/gpsdata - fi - make_signal - uci set modem.modem$CURRMODEM.cmode="1" - uci commit modem - if [ -e /tmp/monstat$CURRMODEM ]; then - source /tmp/monstat$CURRMODEM - fi - if [ -z "$MONSTAT" ]; then - MONSTAT="Unknown" - fi - fi - fi - if [ -e /etc/netspeed ]; then - NETSPEED=60 - else - NETSPEED=10 - fi - CURRTIME=$(date +%s) - let ELAPSE=CURRTIME-STARTIMEX - while [ $ELAPSE -lt $NETSPEED ]; do - sleep 2 - CURRTIME=$(date +%s) - let ELAPSE=CURRTIME-STARTIMEX - done - STARTIMEX=$CURRTIME -done diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/signal/otherhostless.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/signal/otherhostless.sh deleted file mode 100644 index 621d626..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/signal/otherhostless.sh +++ /dev/null @@ -1,160 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -log() { - logger -t "hostless " "$@" -} - -get_basic() { - # get basic data here - # - # how it is done with other modems - # - COMMPORT="/dev/ttyUSB"$(uci get modem.modem$CURRMODEM.commport) - $ROOTER/signal/basedata.sh $CURRMODEM $COMMPORT - source /tmp/base$CURRMODEM.file - rm -f /tmp/base$CURRMODEM.file - $ROOTER/signal/celldata.sh $CURRMODEM $COMMPORT - source /tmp/cell$CURRMODEM.file - rm -f /tmp/cell$CURRMODEM.file - lua $ROOTER/signal/celltype.lua "$MODEM" $CURRMODEM - source /tmp/celltype$CURRMODEM - rm -f /tmp/celltype$CURRMODEM -} - -make_signal() { - # get signal data here - # - # how it is done with other modems (Sierra) - # - COMMPORT="/dev/ttyUSB"$(uci get modem.modem$CURRMODEM.commport) - MANUF=$(uci get modem.modem$CURRMODEM.manuf) - MODEL=$(uci get modem.modem$CURRMODEM.model) - MODEM=$MANUF" "$MODEL - $ROOTER/common/ubloxdata.sh $CURRMODEM $COMMPORT - source /tmp/signal$CURRMODEM.file - rm -f /tmp/signal$CURRMODEM.file - echo "$COMMPORT" > /tmp/statusx$CURRMODEM.file - echo "$CSQ" >> /tmp/statusx$CURRMODEM.file - echo "$CSQ_PER" >> /tmp/statusx$CURRMODEM.file - echo "$CSQ_RSSI" >> /tmp/statusx$CURRMODEM.file - echo "$MODEM" >> /tmp/statusx$CURRMODEM.file - echo "$COPS" >> /tmp/statusx$CURRMODEM.file - echo "$MODE" >> /tmp/statusx$CURRMODEM.file - echo "$LAC" >> /tmp/statusx$CURRMODEM.file - echo "$LAC_NUM" >> /tmp/statusx$CURRMODEM.file - echo "$CID" >> /tmp/statusx$CURRMODEM.file - echo "$CID_NUM" >> /tmp/statusx$CURRMODEM.file - echo "$COPS_MCC" >> /tmp/statusx$CURRMODEM.file - echo "$COPS_MNC" >> /tmp/statusx$CURRMODEM.file - echo "$RNC" >> /tmp/statusx$CURRMODEM.file - echo "$RNC_NUM" >> /tmp/statusx$CURRMODEM.file - echo "$DOWN" >> /tmp/statusx$CURRMODEM.file - echo "$UP" >> /tmp/statusx$CURRMODEM.file - echo "$ECIO" >> /tmp/statusx$CURRMODEM.file - echo "$RSCP" >> /tmp/statusx$CURRMODEM.file - echo "$ECIO1" >> /tmp/statusx$CURRMODEM.file - echo "$RSCP1" >> /tmp/statusx$CURRMODEM.file - echo "$MONSTAT" >> /tmp/statusx$CURRMODEM.file - echo "$CELL" >> /tmp/statusx$CURRMODEM.file - echo "$MODTYPE" >> /tmp/statusx$CURRMODEM.file - echo "$CONN" >> /tmp/statusx$CURRMODEM.file - echo "$CHANNEL" >> /tmp/statusx$CURRMODEM.file - echo "$CNUM" >> /tmp/statusx$CURRMODEM.file - echo "$CNAM" >> /tmp/statusx$CURRMODEM.file - echo "$LBAND" >> /tmp/statusx$CURRMODEM.file - echo "$TEMP" >> /tmp/statusx$CURRMODEM.file - echo "$PROTO" >> /tmp/statusx$CURRMODEM.file - echo "$PCI" >> /tmp/statusx$CURRMODEM.file - echo "-" >> /tmp/statusx$CURRMODEM.file - echo "-" >> /tmp/statusx$CURRMODEM.file - mv -f /tmp/statusx$CURRMODEM.file /tmp/status$CURRMODEM.file -} - -CURRMODEM=$1 -PROTO=$2 -CONN="Modem #"$CURRMODEM - -MANUF=$(uci get modem.modem$CURRMODEM.manuf) -MODEL=$(uci get modem.modem$CURRMODEM.model) -MODEM=$MANUF" "$MODEL -IP=$(uci get modem.modem$CURRMODEM.ip) -MONSTAT="Unknown" -rm -f /tmp/monstat$CURRMODEM - -idV=$(uci get modem.modem$CURRMODEM.idV) -idP=$(uci get modem.modem$CURRMODEM.idP) -if [ $idV = 1546 -a $idP = 1146 ]; then - get_basic -fi - - -STARTIMEX=$(date +%s) -MONSTAT="Unknown" -rm -f /tmp/monstat$CURRMODEM - -while [ 1 = 1 ]; do - if [ $idV = 1546 -a $idP = 1146 ]; then -# ublox - make_signal - else - echo "$IP" > /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "$MODEM" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo " " >> /tmp/status$CURRMODEM.file - echo " " >> /tmp/status$CURRMODEM.file - echo "$MONSTAT" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "$CONN" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "Hostless/Phone" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - fi - if [ -e /tmp/monstat$CURRMODEM ]; then - source /tmp/monstat$CURRMODEM - fi - if [ -z $MONSTAT ]; then - MONSTAT="Unknown" - fi - CURRTIME=$(date +%s) - - if [ -e /etc/netspeed ]; then - NETSPEED=60 - else - NETSPEED=10 - fi - - - - let ELAPSE=CURRTIME-STARTIMEX - while [ $ELAPSE -lt $NETSPEED ]; do - sleep 2 - CURRTIME=$(date +%s) - let ELAPSE=CURRTIME-STARTIMEX - done - STARTIMEX=$CURRTIME -done diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/signal/status.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/signal/status.sh deleted file mode 100644 index 2b61da8..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/signal/status.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/sh - -CURRMODEM=$1 -MSG=$2 -MSG1=$3 -COMMPORT="/dev/ttyUSB"$(uci -q get modem.modem$CURRMODEM.commport) -if [ -z $MSG1 ]; then - MSG1="-" - COMMPORT="-" -fi - -echo "$COMMPORT" > /tmp/status$CURRMODEM.file -echo "-" >> /tmp/status$CURRMODEM.file -echo "-" >> /tmp/status$CURRMODEM.file -echo "-" >> /tmp/status$CURRMODEM.file -echo "$MSG" >> /tmp/status$CURRMODEM.file -echo "$MSG1" >> /tmp/status$CURRMODEM.file -echo "-" >> /tmp/status$CURRMODEM.file -echo "-" >> /tmp/status$CURRMODEM.file -echo "-" >> /tmp/status$CURRMODEM.file -echo "-" >> /tmp/status$CURRMODEM.file -echo "-" >> /tmp/status$CURRMODEM.file -echo "-" >> /tmp/status$CURRMODEM.file -echo "-" >> /tmp/status$CURRMODEM.file -echo "-" >> /tmp/status$CURRMODEM.file -echo "-" >> /tmp/status$CURRMODEM.file -echo "-" >> /tmp/status$CURRMODEM.file -echo "-" >> /tmp/status$CURRMODEM.file -echo "-" >> /tmp/status$CURRMODEM.file -echo "-" >> /tmp/status$CURRMODEM.file -echo " " >> /tmp/status$CURRMODEM.file -echo " " >> /tmp/status$CURRMODEM.file -echo "-" >> /tmp/status$CURRMODEM.file -echo "-" >> /tmp/status$CURRMODEM.file -echo "-" >> /tmp/status$CURRMODEM.file -echo "Modem $CURRMODEM" >> /tmp/status$CURRMODEM.file -echo "-" >> /tmp/status$CURRMODEM.file -echo "-" >> /tmp/status$CURRMODEM.file -echo "-" >> /tmp/status$CURRMODEM.file -echo "-" >> /tmp/status$CURRMODEM.file -echo "-" >> /tmp/status$CURRMODEM.file -echo "-" >> /tmp/status$CURRMODEM.file -echo "-" >> /tmp/status$CURRMODEM.file -echo "-" >> /tmp/status$CURRMODEM.file -echo "-" >> /tmp/status$CURRMODEM.file -echo "-" >> /tmp/status$CURRMODEM.file diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/signal/ztehostless.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/signal/ztehostless.sh deleted file mode 100644 index cedd8e9..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/signal/ztehostless.sh +++ /dev/null @@ -1,215 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -log() { - logger -t "hostless " "$@" -} - -TMPFILE="/tmp/XXXXXX" -TMPFILE1="/tmp/XXXXXX1" - -make_status() { - echo "$IP" > /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "$CSQ" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "$MODEM" >> /tmp/status$CURRMODEM.file - echo "$PROV" >> /tmp/status$CURRMODEM.file - echo "$NETWORK" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo " " >> /tmp/status$CURRMODEM.file - echo " " >> /tmp/status$CURRMODEM.file - echo "$MONSTAT" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "$CONN" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "Hostless/Phone" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file - echo "-" >> /tmp/status$CURRMODEM.file -} - -handle_timeout(){ - local wget_pid="$1" - local count=0 - ps | grep -v grep | grep $wget_pid - res="$?" - while [ "$res" = 0 -a $count -lt "$((TIMEOUT))" ]; do - sleep 1 - count=$((count+1)) - ps | grep -v grep | grep $wget_pid - res="$?" - done - - if [ "$res" = 0 ]; then - log "Killing process on timeout" - kill "$wget_pid" 2> /dev/null - ps | grep -v grep | grep $wget_pid - res="$?" - if [ "$res" = 0 ]; then - log "Killing process on timeout" - kill -9 $wget_pid 2> /dev/null - fi - fi -} - -get_zte_model() { - uci set modem.modem$CURRMODEM.ztemodel=UNKNOWN - uci commit modem - SERIAL=$(uci get modem.modem$CURRMODEM.serial) - if [ $PROD = 1405 ]; then - if [ "`echo $SERIAL | grep P680A1ZTED`" != "" ]; then - uci set modem.modem$CURRMODEM.ztemodel=MF669 - uci set modem.modem$CURRMODEM.model=MF669/MF70 - uci commit modem - else - uci set modem.modem$CURRMODEM.ztemodel=V5 - uci set modem.modem$CURRMODEM.model=MF823/MF825/MF93D - uci commit modem - fi - fi - if [ $PROD = 0349 ]; then - uci set modem.modem$CURRMODEM.ztemodel=MF821D - uci set modem.modem$CURRMODEM.model=MF821D - uci commit modem - fi - if [ $PROD = 0166 ]; then - if [ "`echo $MODEL | grep MF91`" != "" ]; then - uci set modem.modem$CURRMODEM.ztemodel=MF91D - uci set modem.modem$CURRMODEM.model=MF91D - uci commit modem - else - if [ "`echo $MODEL | grep MF91`" != "" ]; then - uci set modem.modem$CURRMODEM.ztemodel=MF91 - uci set modem.modem$CURRMODEM.model=MF91 - uci commit modem - fi - fi - fi - if [ $PROD = 1408 ]; then - if [ "`echo $SERIAL | grep P680A1ZTED`" != "" ]; then - uci set modem.modem$CURRMODEM.ztemodel=V5 - uci set modem.modem$CURRMODEM.model=MF93D - uci commit modem - fi - fi -} - -get_basic(){ - ZTEMOD=$(uci get modem.modem$CURRMODEM.ztemodel) - TIMEOUT=3 - case $ZTEMOD in - "MF669" ) - wget http://$IP/logo_data.asp -O $TMPFILE > /dev/null 2>&1 & - handle_timeout "$!" - LUCKNUM="`cat $TMPFILE | grep lucknum | cut -d \' -f 2`" - ;; - "V5" ) - wget "http://$IP/goform/goform_get_cmd_process?isTest=false&cmd=network_type%2Cwan_ipaddr%2Cppp_status%2Cprefer_dns_auto%2Cstandby_dns_auto%2Csignalbar&multi_data=1&_=1376406501348" -O $TMPFILE > /dev/null 2>&1 & - handle_timeout "$!" - ;; - "MF821D"|"MF91D"|"MF91" ) - wget http://$IP/goform/status_update -O $TMPFILE > /dev/null 2>&1 & - handle_timeout "$!" - ;; - esac - PROV="`cat $TMPFILE | grep network_provider | cut -d \' -f 2`" - [ -z $PROV ] && PROV="-" - rm -f $TMPFILE -} - -get_signal(){ - TIMEOUT=3 - case $ZTEMOD in - "MF669" ) - wget http://$IP/logo_data.asp -O $TMPFILE > /dev/null 2>&1 & - handle_timeout "$!" - SIGNAL="`cat $TMPFILE | grep signalbar | cut -d \' -f 2`" - NETWORK="`cat $TMPFILE | grep network_type | cut -d \' -f 2`" - ;; - "V5" ) - wget "http://$IP/goform/goform_get_cmd_process?isTest=false&cmd=signalbar,wan_csq,network_type,network_provider,ppp_status,modem_main_state,rmcc,rmnc,,domain_stat,cell_id,rssi,rscp,lte_rssi,lte_rsrq,lte_rsrp,lte_snr,ecio,sms_received_flag,sts_received_flag,simcard_roam&multi_data=1&sms_received_flag_flag=0&sts_received_flag_flag=0" -O $TMPFILE > /dev/null 2>&1 & - handle_timeout "$!" - SIGNAL="`cat $TMPFILE | grep signalbar'\"\:\"[^\"]*' -o | cut -d'"' -f 3`" - NETWORK="`cat $TMPFILE | grep network_type'\"\:\"[^\"]*' -o | cut -d'"' -f 3`" - ;; - "MF821D"|"MF91D"|"MF91" ) - wget http://$IP/goform/status_update -O $TMPFILE > /dev/null 2>&1 & - handle_timeout "$!" - SIGNAL="`cat $TMPFILE | cut -d \; -f 1-1`" - net="`cat $TMPFILE | cut -d \; -f 4-4`" - if [ -z $net ]; then - NETWORK="-" - else - [ "$net" = "0" ] && NETWORK="No Service" - [ "$net" = "1" ] && NETWORK="LTE" - [ "$net" = "2" ] && NETWORK="EVDO" - [ "$net" = "3" ] && NETWORK="CDMA" - [ "$net" = "4" ] && NETWORK="WCDMA" - [ "$net" = "5" ] && NETWORK="GSM" - [ "$net" = "6" ] && NETWORK="HSDPA" - [ "$net" = "7" ] && NETWORK="HUSPA" - [ "$net" = "8" ] && NETWORK="HSPA+" - [ "$net" = "10" ] && NETWORK="EDGE" - [ "$net" = "11" ] && NETWORK="GPRS" - fi - ;; - esac - [ -z $SIGNAL ] && SIGNAL=0 - [ -z $NETWORK ] && NETWORK="-" - rm -f $TMPFILE -} - -CURRMODEM=$1 -PROTO=$2 -CONN="Modem #"$CURRMODEM - -PROD=$(uci get modem.modem$CURRMODEM.idP) -get_zte_model -MANUF=$(uci get modem.modem$CURRMODEM.manuf) -MODEL=$(uci get modem.modem$CURRMODEM.model) -MODEM=$MANUF" "$MODEL -IP=$(uci get modem.modem$CURRMODEM.ip) - -get_basic - -STARTIMEX=$(date +%s) -MONSTAT="Unknown" -rm -f /tmp/monstat$CURRMODEM - -while [ 1 = 1 ]; do - get_signal - CSQ="$SIGNAL Bars" - if [ -e /tmp/monstat$CURRMODEM ]; then - source /tmp/monstat$CURRMODEM - fi - if [ -z $MONSTAT ]; then - MONSTAT="Unknown" - fi - make_status - CURRTIME=$(date +%s) - let ELAPSE=CURRTIME-STARTIMEX - while [ $ELAPSE -lt 10 ]; do - sleep 2 - CURRTIME=$(date +%s) - let ELAPSE=CURRTIME-STARTIMEX - done - STARTIMEX=$CURRTIME -done diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/simlock.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/simlock.sh deleted file mode 100644 index 4148ad8..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/simlock.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter - -log() { - modlog "SimLock $CURRMODEM" "$@" -} - -CURRMODEM=$1 -CPORT=$(uci get modem.modem$CURRMODEM.commport) - -ATCMDD="at+cpin?" -OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") -ERR=$(echo "$OX" | grep "ERROR") -if [ ! -z "$ERR" ]; then # No SIM - log "No SIM" - echo "2" > /tmp/simpin$CURRMODEM - exit 0 -fi -RDY=$(echo "$OX" | grep "READY") -if [ -z "$RDY" ]; then # SIM Locked - spin=$(uci -q get custom.simpin.pin) # SIM Pin - if [ -z "$spin" ]; then - spin=$(uci -q get modem.modeminfo$CURRMODEM.pincode) # Profile Pin - if [ -z "$spin" ]; then - spin=$(uci -q get profile.simpin.pin) # Default profile Pin - if [ -z "$spin" ]; then - echo "0" > /tmp/simpin$CURRMODEM # Locked/No Pin - log "Locked/No Pin" - exit 0 - fi - fi - fi - export PINCODE="$spin" # Use Pin to unlock - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "setpin.gcom" "$CURRMODEM") - sleep 5 - ATCMDD="at+cpin?" - OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") - RDY=$(echo "$OX" | grep "READY") - if [ -z "$RDY" ]; then # sim locked - echo "1" > /tmp/simpin$CURRMODEM # Incorrect Pin - log "Incorrect Pin" - exit 0 - fi - log "Correct Pin" - $ROOTER/common/gettype.sh $CURRMODEM -else - log "Not Locked" - sblk=$(uci -q get custom.simpin.block) - if [ "$sblk" = "1" ]; then - echo "4" > /tmp/simpin$CURRMODEM - log "Unlocked not allowed" - exit 0 - fi -fi -rm -f /tmp/simpin$CURRMODEM # not locked - diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/simlockc.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/simlockc.sh deleted file mode 100644 index af4651d..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/simlockc.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter -ROOTER_LINK="/tmp/links" - -log() { - logger -t "SIM Lock" "$@" -} diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/sms/check_sms.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/sms/check_sms.sh deleted file mode 100644 index 0475e85..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/sms/check_sms.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh - -ROOTER=/usr/lib/rooter -ROOTER_LINK="/tmp/links" - -CURRMODEM=$1 - -if [ -e /etc/nosms ]; then - uci set modem.modem$CURRMODEM.sms=0 - uci commit modem - exit 0 -fi - -CPORT=$(uci get modem.modem$CURRMODEM.commport) -sleep 10 -OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "smschk.gcom" "$CURRMODEM") - -ERROR="ERROR" -if `echo ${OX} | grep "${ERROR}" 1>/dev/null 2>&1` -then - uci set modem.modem$CURRMODEM.sms=0 - uci commit modem -else - uci set modem.modem$CURRMODEM.sms=1 - uci commit modem - if [ -e /usr/lib/sms/processsms ]; then - if [ ! -e $ROOTER_LINK/processsms$CURRMODEM ]; then - ln -s /usr/lib/sms/processsms $ROOTER_LINK/processsms$CURRMODEM - $ROOTER_LINK/processsms$CURRMODEM $CURRMODEM & - fi - fi -fi diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/timezone.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/timezone.sh deleted file mode 100644 index a0f1800..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/timezone.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -sleep 10 -rm -f /tmp/timez -wget --no-check-certificate -O /tmp/timez http://ip-api.com/json > /dev/null 2>&1 -OX=$(cat /tmp/timez) - -TZ=$(echo $OX" " | tr -d '"' | grep -o 'timezone:[^;]*' | tr ":" ",") -ZONEN=$(echo "$TZ" | cut -d, -f2) - -/usr/lib/rooter/tzone.lua "$ZONEN" -source /tmp/tzone - -uci set system.@system[-1].timezone="$ZNAME" -uci set system.@system[-1].zonename="$ZONEN" -uci commit system -/etc/init.d/system restart - - diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/tzone.lua b/rooter/ext-rooter-basic/files/usr/lib/rooter/tzone.lua deleted file mode 100644 index 279ad3c..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/tzone.lua +++ /dev/null @@ -1,478 +0,0 @@ -#!/usr/bin/lua - -TZ = { - { 'Africa/Abidjan', 'GMT0' }, - { 'Africa/Accra', 'GMT0' }, - { 'Africa/Addis Ababa', 'EAT-3' }, - { 'Africa/Algiers', 'CET-1' }, - { 'Africa/Asmara', 'EAT-3' }, - { 'Africa/Bamako', 'GMT0' }, - { 'Africa/Bangui', 'WAT-1' }, - { 'Africa/Banjul', 'GMT0' }, - { 'Africa/Bissau', 'GMT0' }, - { 'Africa/Blantyre', 'CAT-2' }, - { 'Africa/Brazzaville', 'WAT-1' }, - { 'Africa/Bujumbura', 'CAT-2' }, - { 'Africa/Cairo', 'EET-2' }, - { 'Africa/Casablanca', '<+01>-1' }, - { 'Africa/Ceuta', 'CET-1CEST,M3.5.0,M10.5.0/3' }, - { 'Africa/Conakry', 'GMT0' }, - { 'Africa/Dakar', 'GMT0' }, - { 'Africa/Dar es Salaam', 'EAT-3' }, - { 'Africa/Djibouti', 'EAT-3' }, - { 'Africa/Douala', 'WAT-1' }, - { 'Africa/El Aaiun', '<+01>-1' }, - { 'Africa/Freetown', 'GMT0' }, - { 'Africa/Gaborone', 'CAT-2' }, - { 'Africa/Harare', 'CAT-2' }, - { 'Africa/Johannesburg', 'SAST-2' }, - { 'Africa/Juba', 'EAT-3' }, - { 'Africa/Kampala', 'EAT-3' }, - { 'Africa/Khartoum', 'CAT-2' }, - { 'Africa/Kigali', 'CAT-2' }, - { 'Africa/Kinshasa', 'WAT-1' }, - { 'Africa/Lagos', 'WAT-1' }, - { 'Africa/Libreville', 'WAT-1' }, - { 'Africa/Lome', 'GMT0' }, - { 'Africa/Luanda', 'WAT-1' }, - { 'Africa/Lubumbashi', 'CAT-2' }, - { 'Africa/Lusaka', 'CAT-2' }, - { 'Africa/Malabo', 'WAT-1' }, - { 'Africa/Maputo', 'CAT-2' }, - { 'Africa/Maseru', 'SAST-2' }, - { 'Africa/Mbabane', 'SAST-2' }, - { 'Africa/Mogadishu', 'EAT-3' }, - { 'Africa/Monrovia', 'GMT0' }, - { 'Africa/Nairobi', 'EAT-3' }, - { 'Africa/Ndjamena', 'WAT-1' }, - { 'Africa/Niamey', 'WAT-1' }, - { 'Africa/Nouakchott', 'GMT0' }, - { 'Africa/Ouagadougou', 'GMT0' }, - { 'Africa/Porto-Novo', 'WAT-1' }, - { 'Africa/Sao Tome', 'GMT0' }, - { 'Africa/Tripoli', 'EET-2' }, - { 'Africa/Tunis', 'CET-1' }, - { 'Africa/Windhoek', 'CAT-2' }, - { 'America/Adak', 'HST10HDT,M3.2.0,M11.1.0' }, - { 'America/Anchorage', 'AKST9AKDT,M3.2.0,M11.1.0' }, - { 'America/Anguilla', 'AST4' }, - { 'America/Antigua', 'AST4' }, - { 'America/Araguaina', '<-03>3' }, - { 'America/Argentina/Buenos Aires', '<-03>3' }, - { 'America/Argentina/Catamarca', '<-03>3' }, - { 'America/Argentina/Cordoba', '<-03>3' }, - { 'America/Argentina/Jujuy', '<-03>3' }, - { 'America/Argentina/La Rioja', '<-03>3' }, - { 'America/Argentina/Mendoza', '<-03>3' }, - { 'America/Argentina/Rio Gallegos', '<-03>3' }, - { 'America/Argentina/Salta', '<-03>3' }, - { 'America/Argentina/San Juan', '<-03>3' }, - { 'America/Argentina/San Luis', '<-03>3' }, - { 'America/Argentina/Tucuman', '<-03>3' }, - { 'America/Argentina/Ushuaia', '<-03>3' }, - { 'America/Aruba', 'AST4' }, - { 'America/Asuncion', '<-04>4<-03>,M10.1.0/0,M3.4.0/0' }, - { 'America/Atikokan', 'EST5' }, - { 'America/Bahia', '<-03>3' }, - { 'America/Bahia Banderas', 'CST6CDT,M4.1.0,M10.5.0' }, - { 'America/Barbados', 'AST4' }, - { 'America/Belem', '<-03>3' }, - { 'America/Belize', 'CST6' }, - { 'America/Blanc-Sablon', 'AST4' }, - { 'America/Boa Vista', '<-04>4' }, - { 'America/Bogota', '<-05>5' }, - { 'America/Boise', 'MST7MDT,M3.2.0,M11.1.0' }, - { 'America/Cambridge Bay', 'MST7MDT,M3.2.0,M11.1.0' }, - { 'America/Campo Grande', '<-04>4' }, - { 'America/Cancun', 'EST5' }, - { 'America/Caracas', '<-04>4' }, - { 'America/Cayenne', '<-03>3' }, - { 'America/Cayman', 'EST5' }, - { 'America/Chicago', 'CST6CDT,M3.2.0,M11.1.0' }, - { 'America/Chihuahua', 'MST7MDT,M4.1.0,M10.5.0' }, - { 'America/Costa Rica', 'CST6' }, - { 'America/Creston', 'MST7' }, - { 'America/Cuiaba', '<-04>4' }, - { 'America/Curacao', 'AST4' }, - { 'America/Danmarkshavn', 'GMT0' }, - { 'America/Dawson', 'MST7' }, - { 'America/Dawson Creek', 'MST7' }, - { 'America/Denver', 'MST7MDT,M3.2.0,M11.1.0' }, - { 'America/Detroit', 'EST5EDT,M3.2.0,M11.1.0' }, - { 'America/Dominica', 'AST4' }, - { 'America/Edmonton', 'MST7MDT,M3.2.0,M11.1.0' }, - { 'America/Eirunepe', '<-05>5' }, - { 'America/El Salvador', 'CST6' }, - { 'America/Fort Nelson', 'MST7' }, - { 'America/Fortaleza', '<-03>3' }, - { 'America/Glace Bay', 'AST4ADT,M3.2.0,M11.1.0' }, - { 'America/Goose Bay', 'AST4ADT,M3.2.0,M11.1.0' }, - { 'America/Grand Turk', 'EST5EDT,M3.2.0,M11.1.0' }, - { 'America/Grenada', 'AST4' }, - { 'America/Guadeloupe', 'AST4' }, - { 'America/Guatemala', 'CST6' }, - { 'America/Guayaquil', '<-05>5' }, - { 'America/Guyana', '<-04>4' }, - { 'America/Halifax', 'AST4ADT,M3.2.0,M11.1.0' }, - { 'America/Havana', 'CST5CDT,M3.2.0/0,M11.1.0/1' }, - { 'America/Hermosillo', 'MST7' }, - { 'America/Indiana/Indianapolis', 'EST5EDT,M3.2.0,M11.1.0' }, - { 'America/Indiana/Knox', 'CST6CDT,M3.2.0,M11.1.0' }, - { 'America/Indiana/Marengo', 'EST5EDT,M3.2.0,M11.1.0' }, - { 'America/Indiana/Petersburg', 'EST5EDT,M3.2.0,M11.1.0' }, - { 'America/Indiana/Tell City', 'CST6CDT,M3.2.0,M11.1.0' }, - { 'America/Indiana/Vevay', 'EST5EDT,M3.2.0,M11.1.0' }, - { 'America/Indiana/Vincennes', 'EST5EDT,M3.2.0,M11.1.0' }, - { 'America/Indiana/Winamac', 'EST5EDT,M3.2.0,M11.1.0' }, - { 'America/Inuvik', 'MST7MDT,M3.2.0,M11.1.0' }, - { 'America/Iqaluit', 'EST5EDT,M3.2.0,M11.1.0' }, - { 'America/Jamaica', 'EST5' }, - { 'America/Juneau', 'AKST9AKDT,M3.2.0,M11.1.0' }, - { 'America/Kentucky/Louisville', 'EST5EDT,M3.2.0,M11.1.0' }, - { 'America/Kentucky/Monticello', 'EST5EDT,M3.2.0,M11.1.0' }, - { 'America/Kralendijk', 'AST4' }, - { 'America/La Paz', '<-04>4' }, - { 'America/Lima', '<-05>5' }, - { 'America/Los Angeles', 'PST8PDT,M3.2.0,M11.1.0' }, - { 'America/Lower Princes', 'AST4' }, - { 'America/Maceio', '<-03>3' }, - { 'America/Managua', 'CST6' }, - { 'America/Manaus', '<-04>4' }, - { 'America/Marigot', 'AST4' }, - { 'America/Martinique', 'AST4' }, - { 'America/Matamoros', 'CST6CDT,M3.2.0,M11.1.0' }, - { 'America/Mazatlan', 'MST7MDT,M4.1.0,M10.5.0' }, - { 'America/Menominee', 'CST6CDT,M3.2.0,M11.1.0' }, - { 'America/Merida', 'CST6CDT,M4.1.0,M10.5.0' }, - { 'America/Metlakatla', 'AKST9AKDT,M3.2.0,M11.1.0' }, - { 'America/Mexico City', 'CST6CDT,M4.1.0,M10.5.0' }, - { 'America/Miquelon', '<-03>3<-02>,M3.2.0,M11.1.0' }, - { 'America/Moncton', 'AST4ADT,M3.2.0,M11.1.0' }, - { 'America/Monterrey', 'CST6CDT,M4.1.0,M10.5.0' }, - { 'America/Montevideo', '<-03>3' }, - { 'America/Montserrat', 'AST4' }, - { 'America/Nassau', 'EST5EDT,M3.2.0,M11.1.0' }, - { 'America/New York', 'EST5EDT,M3.2.0,M11.1.0' }, - { 'America/Nipigon', 'EST5EDT,M3.2.0,M11.1.0' }, - { 'America/Nome', 'AKST9AKDT,M3.2.0,M11.1.0' }, - { 'America/Noronha', '<-02>2' }, - { 'America/North Dakota/Beulah', 'CST6CDT,M3.2.0,M11.1.0' }, - { 'America/North Dakota/Center', 'CST6CDT,M3.2.0,M11.1.0' }, - { 'America/North Dakota/New Salem', 'CST6CDT,M3.2.0,M11.1.0' }, - { 'America/Nuuk', '<-03>3<-02>,M3.5.0/-2,M10.5.0/-1' }, - { 'America/Ojinaga', 'MST7MDT,M3.2.0,M11.1.0' }, - { 'America/Panama', 'EST5' }, - { 'America/Pangnirtung', 'EST5EDT,M3.2.0,M11.1.0' }, - { 'America/Paramaribo', '<-03>3' }, - { 'America/Phoenix', 'MST7' }, - { 'America/Port of Spain', 'AST4' }, - { 'America/Port-au-Prince', 'EST5EDT,M3.2.0,M11.1.0' }, - { 'America/Porto Velho', '<-04>4' }, - { 'America/Puerto Rico', 'AST4' }, - { 'America/Punta Arenas', '<-03>3' }, - { 'America/Rainy River', 'CST6CDT,M3.2.0,M11.1.0' }, - { 'America/Rankin Inlet', 'CST6CDT,M3.2.0,M11.1.0' }, - { 'America/Recife', '<-03>3' }, - { 'America/Regina', 'CST6' }, - { 'America/Resolute', 'CST6CDT,M3.2.0,M11.1.0' }, - { 'America/Rio Branco', '<-05>5' }, - { 'America/Santarem', '<-03>3' }, - { 'America/Santiago', '<-04>4<-03>,M9.1.6/24,M4.1.6/24' }, - { 'America/Santo Domingo', 'AST4' }, - { 'America/Sao Paulo', '<-03>3' }, - { 'America/Scoresbysund', '<-01>1<+00>,M3.5.0/0,M10.5.0/1' }, - { 'America/Sitka', 'AKST9AKDT,M3.2.0,M11.1.0' }, - { 'America/St Barthelemy', 'AST4' }, - { 'America/St Johns', 'NST3:30NDT,M3.2.0,M11.1.0' }, - { 'America/St Kitts', 'AST4' }, - { 'America/St Lucia', 'AST4' }, - { 'America/St Thomas', 'AST4' }, - { 'America/St Vincent', 'AST4' }, - { 'America/Swift Current', 'CST6' }, - { 'America/Tegucigalpa', 'CST6' }, - { 'America/Thule', 'AST4ADT,M3.2.0,M11.1.0' }, - { 'America/Thunder Bay', 'EST5EDT,M3.2.0,M11.1.0' }, - { 'America/Tijuana', 'PST8PDT,M3.2.0,M11.1.0' }, - { 'America/Toronto', 'EST5EDT,M3.2.0,M11.1.0' }, - { 'America/Tortola', 'AST4' }, - { 'America/Vancouver', 'PST8PDT,M3.2.0,M11.1.0' }, - { 'America/Whitehorse', 'MST7' }, - { 'America/Winnipeg', 'CST6CDT,M3.2.0,M11.1.0' }, - { 'America/Yakutat', 'AKST9AKDT,M3.2.0,M11.1.0' }, - { 'America/Yellowknife', 'MST7MDT,M3.2.0,M11.1.0' }, - { 'Antarctica/Casey', '<+08>-8' }, - { 'Antarctica/Davis', '<+07>-7' }, - { 'Antarctica/DumontDUrville', '<+10>-10' }, - { 'Antarctica/Macquarie', '<+11>-11' }, - { 'Antarctica/Mawson', '<+05>-5' }, - { 'Antarctica/McMurdo', 'NZST-12NZDT,M9.5.0,M4.1.0/3' }, - { 'Antarctica/Palmer', '<-03>3' }, - { 'Antarctica/Rothera', '<-03>3' }, - { 'Antarctica/Syowa', '<+03>-3' }, - { 'Antarctica/Troll', '<+00>0<+02>-2,M3.5.0/1,M10.5.0/3' }, - { 'Antarctica/Vostok', '<+06>-6' }, - { 'Arctic/Longyearbyen', 'CET-1CEST,M3.5.0,M10.5.0/3' }, - { 'Asia/Aden', '<+03>-3' }, - { 'Asia/Almaty', '<+06>-6' }, - { 'Asia/Amman', 'EET-2EEST,M3.5.4/24,M10.5.5/1' }, - { 'Asia/Anadyr', '<+12>-12' }, - { 'Asia/Aqtau', '<+05>-5' }, - { 'Asia/Aqtobe', '<+05>-5' }, - { 'Asia/Ashgabat', '<+05>-5' }, - { 'Asia/Atyrau', '<+05>-5' }, - { 'Asia/Baghdad', '<+03>-3' }, - { 'Asia/Bahrain', '<+03>-3' }, - { 'Asia/Baku', '<+04>-4' }, - { 'Asia/Bangkok', '<+07>-7' }, - { 'Asia/Barnaul', '<+07>-7' }, - { 'Asia/Beirut', 'EET-2EEST,M3.5.0/0,M10.5.0/0' }, - { 'Asia/Bishkek', '<+06>-6' }, - { 'Asia/Brunei', '<+08>-8' }, - { 'Asia/Chita', '<+09>-9' }, - { 'Asia/Choibalsan', '<+08>-8' }, - { 'Asia/Colombo', '<+0530>-5:30' }, - { 'Asia/Damascus', 'EET-2EEST,M3.5.5/0,M10.5.5/0' }, - { 'Asia/Dhaka', '<+06>-6' }, - { 'Asia/Dili', '<+09>-9' }, - { 'Asia/Dubai', '<+04>-4' }, - { 'Asia/Dushanbe', '<+05>-5' }, - { 'Asia/Famagusta', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, - { 'Asia/Gaza', 'EET-2EEST,M3.5.5/0,M10.5.6/1' }, - { 'Asia/Hebron', 'EET-2EEST,M3.5.5/0,M10.5.6/1' }, - { 'Asia/Ho Chi Minh', '<+07>-7' }, - { 'Asia/Hong Kong', 'HKT-8' }, - { 'Asia/Hovd', '<+07>-7' }, - { 'Asia/Irkutsk', '<+08>-8' }, - { 'Asia/Jakarta', 'WIB-7' }, - { 'Asia/Jayapura', 'WIT-9' }, - { 'Asia/Jerusalem', 'IST-2IDT,M3.4.4/26,M10.5.0' }, - { 'Asia/Kabul', '<+0430>-4:30' }, - { 'Asia/Kamchatka', '<+12>-12' }, - { 'Asia/Karachi', 'PKT-5' }, - { 'Asia/Kathmandu', '<+0545>-5:45' }, - { 'Asia/Khandyga', '<+09>-9' }, - { 'Asia/Kolkata', 'IST-5:30' }, - { 'Asia/Krasnoyarsk', '<+07>-7' }, - { 'Asia/Kuala Lumpur', '<+08>-8' }, - { 'Asia/Kuching', '<+08>-8' }, - { 'Asia/Kuwait', '<+03>-3' }, - { 'Asia/Macau', 'CST-8' }, - { 'Asia/Magadan', '<+11>-11' }, - { 'Asia/Makassar', 'WITA-8' }, - { 'Asia/Manila', 'PST-8' }, - { 'Asia/Muscat', '<+04>-4' }, - { 'Asia/Nicosia', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, - { 'Asia/Novokuznetsk', '<+07>-7' }, - { 'Asia/Novosibirsk', '<+07>-7' }, - { 'Asia/Omsk', '<+06>-6' }, - { 'Asia/Oral', '<+05>-5' }, - { 'Asia/Phnom Penh', '<+07>-7' }, - { 'Asia/Pontianak', 'WIB-7' }, - { 'Asia/Pyongyang', 'KST-9' }, - { 'Asia/Qatar', '<+03>-3' }, - { 'Asia/Qostanay', '<+06>-6' }, - { 'Asia/Qyzylorda', '<+05>-5' }, - { 'Asia/Riyadh', '<+03>-3' }, - { 'Asia/Sakhalin', '<+11>-11' }, - { 'Asia/Samarkand', '<+05>-5' }, - { 'Asia/Seoul', 'KST-9' }, - { 'Asia/Shanghai', 'CST-8' }, - { 'Asia/Singapore', '<+08>-8' }, - { 'Asia/Srednekolymsk', '<+11>-11' }, - { 'Asia/Taipei', 'CST-8' }, - { 'Asia/Tashkent', '<+05>-5' }, - { 'Asia/Tbilisi', '<+04>-4' }, - { 'Asia/Tehran', '<+0330>-3:30<+0430>,J79/24,J263/24' }, - { 'Asia/Thimphu', '<+06>-6' }, - { 'Asia/Tokyo', 'JST-9' }, - { 'Asia/Tomsk', '<+07>-7' }, - { 'Asia/Ulaanbaatar', '<+08>-8' }, - { 'Asia/Urumqi', '<+06>-6' }, - { 'Asia/Ust-Nera', '<+10>-10' }, - { 'Asia/Vientiane', '<+07>-7' }, - { 'Asia/Vladivostok', '<+10>-10' }, - { 'Asia/Yakutsk', '<+09>-9' }, - { 'Asia/Yangon', '<+0630>-6:30' }, - { 'Asia/Yekaterinburg', '<+05>-5' }, - { 'Asia/Yerevan', '<+04>-4' }, - { 'Atlantic/Azores', '<-01>1<+00>,M3.5.0/0,M10.5.0/1' }, - { 'Atlantic/Bermuda', 'AST4ADT,M3.2.0,M11.1.0' }, - { 'Atlantic/Canary', 'WET0WEST,M3.5.0/1,M10.5.0' }, - { 'Atlantic/Cape Verde', '<-01>1' }, - { 'Atlantic/Faroe', 'WET0WEST,M3.5.0/1,M10.5.0' }, - { 'Atlantic/Madeira', 'WET0WEST,M3.5.0/1,M10.5.0' }, - { 'Atlantic/Reykjavik', 'GMT0' }, - { 'Atlantic/South Georgia', '<-02>2' }, - { 'Atlantic/St Helena', 'GMT0' }, - { 'Atlantic/Stanley', '<-03>3' }, - { 'Australia/Adelaide', 'ACST-9:30ACDT,M10.1.0,M4.1.0/3' }, - { 'Australia/Brisbane', 'AEST-10' }, - { 'Australia/Broken Hill', 'ACST-9:30ACDT,M10.1.0,M4.1.0/3' }, - { 'Australia/Currie', 'AEST-10AEDT,M10.1.0,M4.1.0/3' }, - { 'Australia/Darwin', 'ACST-9:30' }, - { 'Australia/Eucla', '<+0845>-8:45' }, - { 'Australia/Hobart', 'AEST-10AEDT,M10.1.0,M4.1.0/3' }, - { 'Australia/Lindeman', 'AEST-10' }, - { 'Australia/Lord Howe', '<+1030>-10:30<+11>-11,M10.1.0,M4.1.0' }, - { 'Australia/Melbourne', 'AEST-10AEDT,M10.1.0,M4.1.0/3' }, - { 'Australia/Perth', 'AWST-8' }, - { 'Australia/Sydney', 'AEST-10AEDT,M10.1.0,M4.1.0/3' }, - { 'Etc/GMT', 'GMT0' }, - { 'Etc/GMT+1', '<-01>1' }, - { 'Etc/GMT+10', '<-10>10' }, - { 'Etc/GMT+11', '<-11>11' }, - { 'Etc/GMT+12', '<-12>12' }, - { 'Etc/GMT+2', '<-02>2' }, - { 'Etc/GMT+3', '<-03>3' }, - { 'Etc/GMT+4', '<-04>4' }, - { 'Etc/GMT+5', '<-05>5' }, - { 'Etc/GMT+6', '<-06>6' }, - { 'Etc/GMT+7', '<-07>7' }, - { 'Etc/GMT+8', '<-08>8' }, - { 'Etc/GMT+9', '<-09>9' }, - { 'Etc/GMT-1', '<+01>-1' }, - { 'Etc/GMT-10', '<+10>-10' }, - { 'Etc/GMT-11', '<+11>-11' }, - { 'Etc/GMT-12', '<+12>-12' }, - { 'Etc/GMT-13', '<+13>-13' }, - { 'Etc/GMT-14', '<+14>-14' }, - { 'Etc/GMT-2', '<+02>-2' }, - { 'Etc/GMT-3', '<+03>-3' }, - { 'Etc/GMT-4', '<+04>-4' }, - { 'Etc/GMT-5', '<+05>-5' }, - { 'Etc/GMT-6', '<+06>-6' }, - { 'Etc/GMT-7', '<+07>-7' }, - { 'Etc/GMT-8', '<+08>-8' }, - { 'Etc/GMT-9', '<+09>-9' }, - { 'Europe/Amsterdam', 'CET-1CEST,M3.5.0,M10.5.0/3' }, - { 'Europe/Andorra', 'CET-1CEST,M3.5.0,M10.5.0/3' }, - { 'Europe/Astrakhan', '<+04>-4' }, - { 'Europe/Athens', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, - { 'Europe/Belgrade', 'CET-1CEST,M3.5.0,M10.5.0/3' }, - { 'Europe/Berlin', 'CET-1CEST,M3.5.0,M10.5.0/3' }, - { 'Europe/Bratislava', 'CET-1CEST,M3.5.0,M10.5.0/3' }, - { 'Europe/Brussels', 'CET-1CEST,M3.5.0,M10.5.0/3' }, - { 'Europe/Bucharest', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, - { 'Europe/Budapest', 'CET-1CEST,M3.5.0,M10.5.0/3' }, - { 'Europe/Busingen', 'CET-1CEST,M3.5.0,M10.5.0/3' }, - { 'Europe/Chisinau', 'EET-2EEST,M3.5.0,M10.5.0/3' }, - { 'Europe/Copenhagen', 'CET-1CEST,M3.5.0,M10.5.0/3' }, - { 'Europe/Dublin', 'IST-1GMT0,M10.5.0,M3.5.0/1' }, - { 'Europe/Gibraltar', 'CET-1CEST,M3.5.0,M10.5.0/3' }, - { 'Europe/Guernsey', 'GMT0BST,M3.5.0/1,M10.5.0' }, - { 'Europe/Helsinki', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, - { 'Europe/Isle of Man', 'GMT0BST,M3.5.0/1,M10.5.0' }, - { 'Europe/Istanbul', '<+03>-3' }, - { 'Europe/Jersey', 'GMT0BST,M3.5.0/1,M10.5.0' }, - { 'Europe/Kaliningrad', 'EET-2' }, - { 'Europe/Kiev', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, - { 'Europe/Kirov', '<+03>-3' }, - { 'Europe/Lisbon', 'WET0WEST,M3.5.0/1,M10.5.0' }, - { 'Europe/Ljubljana', 'CET-1CEST,M3.5.0,M10.5.0/3' }, - { 'Europe/London', 'GMT0BST,M3.5.0/1,M10.5.0' }, - { 'Europe/Luxembourg', 'CET-1CEST,M3.5.0,M10.5.0/3' }, - { 'Europe/Madrid', 'CET-1CEST,M3.5.0,M10.5.0/3' }, - { 'Europe/Malta', 'CET-1CEST,M3.5.0,M10.5.0/3' }, - { 'Europe/Mariehamn', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, - { 'Europe/Minsk', '<+03>-3' }, - { 'Europe/Monaco', 'CET-1CEST,M3.5.0,M10.5.0/3' }, - { 'Europe/Moscow', 'MSK-3' }, - { 'Europe/Oslo', 'CET-1CEST,M3.5.0,M10.5.0/3' }, - { 'Europe/Paris', 'CET-1CEST,M3.5.0,M10.5.0/3' }, - { 'Europe/Podgorica', 'CET-1CEST,M3.5.0,M10.5.0/3' }, - { 'Europe/Prague', 'CET-1CEST,M3.5.0,M10.5.0/3' }, - { 'Europe/Riga', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, - { 'Europe/Rome', 'CET-1CEST,M3.5.0,M10.5.0/3' }, - { 'Europe/Samara', '<+04>-4' }, - { 'Europe/San Marino', 'CET-1CEST,M3.5.0,M10.5.0/3' }, - { 'Europe/Sarajevo', 'CET-1CEST,M3.5.0,M10.5.0/3' }, - { 'Europe/Saratov', '<+04>-4' }, - { 'Europe/Simferopol', 'MSK-3' }, - { 'Europe/Skopje', 'CET-1CEST,M3.5.0,M10.5.0/3' }, - { 'Europe/Sofia', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, - { 'Europe/Stockholm', 'CET-1CEST,M3.5.0,M10.5.0/3' }, - { 'Europe/Tallinn', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, - { 'Europe/Tirane', 'CET-1CEST,M3.5.0,M10.5.0/3' }, - { 'Europe/Ulyanovsk', '<+04>-4' }, - { 'Europe/Uzhgorod', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, - { 'Europe/Vaduz', 'CET-1CEST,M3.5.0,M10.5.0/3' }, - { 'Europe/Vatican', 'CET-1CEST,M3.5.0,M10.5.0/3' }, - { 'Europe/Vienna', 'CET-1CEST,M3.5.0,M10.5.0/3' }, - { 'Europe/Vilnius', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, - { 'Europe/Volgograd', '<+04>-4' }, - { 'Europe/Warsaw', 'CET-1CEST,M3.5.0,M10.5.0/3' }, - { 'Europe/Zagreb', 'CET-1CEST,M3.5.0,M10.5.0/3' }, - { 'Europe/Zaporozhye', 'EET-2EEST,M3.5.0/3,M10.5.0/4' }, - { 'Europe/Zurich', 'CET-1CEST,M3.5.0,M10.5.0/3' }, - { 'Indian/Antananarivo', 'EAT-3' }, - { 'Indian/Chagos', '<+06>-6' }, - { 'Indian/Christmas', '<+07>-7' }, - { 'Indian/Cocos', '<+0630>-6:30' }, - { 'Indian/Comoro', 'EAT-3' }, - { 'Indian/Kerguelen', '<+05>-5' }, - { 'Indian/Mahe', '<+04>-4' }, - { 'Indian/Maldives', '<+05>-5' }, - { 'Indian/Mauritius', '<+04>-4' }, - { 'Indian/Mayotte', 'EAT-3' }, - { 'Indian/Reunion', '<+04>-4' }, - { 'Pacific/Apia', '<+13>-13<+14>,M9.5.0/3,M4.1.0/4' }, - { 'Pacific/Auckland', 'NZST-12NZDT,M9.5.0,M4.1.0/3' }, - { 'Pacific/Bougainville', '<+11>-11' }, - { 'Pacific/Chatham', '<+1245>-12:45<+1345>,M9.5.0/2:45,M4.1.0/3:45' }, - { 'Pacific/Chuuk', '<+10>-10' }, - { 'Pacific/Easter', '<-06>6<-05>,M9.1.6/22,M4.1.6/22' }, - { 'Pacific/Efate', '<+11>-11' }, - { 'Pacific/Enderbury', '<+13>-13' }, - { 'Pacific/Fakaofo', '<+13>-13' }, - { 'Pacific/Fiji', '<+12>-12<+13>,M11.2.0,M1.2.3/99' }, - { 'Pacific/Funafuti', '<+12>-12' }, - { 'Pacific/Galapagos', '<-06>6' }, - { 'Pacific/Gambier', '<-09>9' }, - { 'Pacific/Guadalcanal', '<+11>-11' }, - { 'Pacific/Guam', 'ChST-10' }, - { 'Pacific/Honolulu', 'HST10' }, - { 'Pacific/Kiritimati', '<+14>-14' }, - { 'Pacific/Kosrae', '<+11>-11' }, - { 'Pacific/Kwajalein', '<+12>-12' }, - { 'Pacific/Majuro', '<+12>-12' }, - { 'Pacific/Marquesas', '<-0930>9:30' }, - { 'Pacific/Midway', 'SST11' }, - { 'Pacific/Nauru', '<+12>-12' }, - { 'Pacific/Niue', '<-11>11' }, - { 'Pacific/Norfolk', '<+11>-11<+12>,M10.1.0,M4.1.0/3' }, - { 'Pacific/Noumea', '<+11>-11' }, - { 'Pacific/Pago Pago', 'SST11' }, - { 'Pacific/Palau', '<+09>-9' }, - { 'Pacific/Pitcairn', '<-08>8' }, - { 'Pacific/Pohnpei', '<+11>-11' }, - { 'Pacific/Port Moresby', '<+10>-10' }, - { 'Pacific/Rarotonga', '<-10>10' }, - { 'Pacific/Saipan', 'ChST-10' }, - { 'Pacific/Tahiti', '<-10>10' }, - { 'Pacific/Tarawa', '<+12>-12' }, - { 'Pacific/Tongatapu', '<+13>-13' }, - { 'Pacific/Wake', '<+12>-12' }, - { 'Pacific/Wallis', '<+12>-12' }, -} - -name = arg[1] -TM = nil - -array = {} -i = 1 -repeat - array = TZ[i] - if array[1] == name then - TM = array[2] - break - end - i = i+1 -until(array == nil) - -local tfile = io.open("/tmp/tzone", "w") -if TM ~= nil then - tfile:write("ZNAME=\"", TM, "\"\n") - tfile:write("ZONEN=\"", name, "\"\n") -end -tfile:close() - diff --git a/rooter/ext-rooter-basic/files/usr/lib/rooter/ussd.sh b/rooter/ext-rooter-basic/files/usr/lib/rooter/ussd.sh deleted file mode 100644 index fb685b0..0000000 --- a/rooter/ext-rooter-basic/files/usr/lib/rooter/ussd.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/sh - -CURRMODEM=$(uci get modem.general.modemnum) -COMMPORT="/dev/ttyUSB"$(uci get modem.modem$CURRMODEM.commport) -ROOTER=/usr/lib/rooter - -if [ -n "$1" ]; then - echo "$1" > /tmp/ussd_arg$CURRMODEM -fi - -while true; do - if [ -e /tmp/ussd_arg$CURRMODEM ]; then - read USSDSTR < /tmp/ussd_arg$CURRMODEM - rm /tmp/ussd_arg$CURRMODEM - fi - if [ -n "$USSDSTR" ]; then - ATCMDD="AT+CUSD=1,\"$USSDSTR\",15" - OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "ussd.gcom" "$CURRMODEM" "$ATCMDD" | tr "\n" "\v") - USSD=$(echo "$OX" | grep -o "+CUSD: .\+\",[0-9]\+" | tr "\v" "\n") - USSDL=${#USSD} - USSDLx=$((USSDL - 2)) - DCS=$(printf "${USSD:$USSDLx:2}") - if [ $USSDL -ge 14 ]; then - USSDL=$((USSDL - 14)) - USSD=$(printf "${USSD:10:$USSDL}") - if [ $DCS -eq "72" ]; then - USSDx="" - USSDL=${#USSD} - nV=0 - until [ $nV -ge $USSDL ]; do - UU=$(printf "%d" "0x"${USSD:$nV:4}) - if [[ $UU -lt 128 ]]; then - USSDx="$USSDx"$(printf "%b" "\\$(printf "0%o" "$UU")") - elif [[ $UU -lt 2048 ]]; then - UUU=$(((($UU & 1984) >> 6) | 192)) - USSDx="$USSDx"$(printf "%b" "\\$(printf "0%o" "$UUU")") - UUU=$((($UU & 63) | 128)) - USSDx="$USSDx"$(printf "%b" "\\$(printf "0%o" "$UUU")") - else - UUU=$(((($UU & 61440) >> 12) | 224)) - USSDx="$USSDx"$(printf "%b" "\\$(printf "0%o" "$UUU")") - UUU=$(((($UU & 4032) >> 6) | 128)) - USSDx="$USSDx"$(printf "%b" "\\$(printf "0%o" "$UUU")") - UUU=$((($UU & 63) | 128)) - USSDx="$USSDx"$(printf "%b" "\\$(printf "0%o" "$UUU")") - fi - nV=$(( $nV + 4 )) - done - USSD="$USSDx" - fi - else - USSD=$(echo "$OX" | tr "\v" "\n") - fi - echo - echo "-----------------------------------------------------------" - echo "$USSD" - echo "-----------------------------------------------------------" - echo - fi - printf "Enter blank to quit, or a USSD string to send: "; read USSDSTR - if [ -z "$USSDSTR" ]; then - break - fi -done -ATCMDD="AT+CUSD=2" -OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD") -exit 0 diff --git a/rooter/ext-rooter-basic/files/usr/sbin/modlog b/rooter/ext-rooter-basic/files/usr/sbin/modlog deleted file mode 100644 index 46a614f..0000000 --- a/rooter/ext-rooter-basic/files/usr/sbin/modlog +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -name=$1 -text=$2 - -logger -t "$name" "$text" -/usr/lib/rooter/log/modlogger.sh "$name $text" \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/www/luci-static/background/main_bg.jpg b/rooter/ext-rooter-basic/files/www/luci-static/background/main_bg.jpg deleted file mode 100644 index 66222dc..0000000 Binary files a/rooter/ext-rooter-basic/files/www/luci-static/background/main_bg.jpg and /dev/null differ diff --git a/rooter/ext-rooter-basic/files/www/luci-static/css/cascade.css b/rooter/ext-rooter-basic/files/www/luci-static/css/cascade.css deleted file mode 100644 index a04fe19..0000000 --- a/rooter/ext-rooter-basic/files/www/luci-static/css/cascade.css +++ /dev/null @@ -1,3305 +0,0 @@ -@import url(fonts.css?v=3); - -@import url(pure-min.css?v=1); - -:root { - --primary: #5e72e4; - --dark-primary: #483d8b; - --main-color: #09c; - --header-bg: #09c; - --header-color: #fff; - --bar-bg: #5e72e4; - --menu-bg-color: #fff; - --menu-color: #5f6368; - --menu-color-hover: #202124; - --main-menu-color: #202124; - --submenu-bg-hover: #d4d4d4; - --submenu-bg-hover-active: #09c; - --blue: #5e72e4; - --indigo: #5603ad; - --purple: #8965e0; - --pink: #f3a4b5; - --red: #f5365c; - --orange: #fb6340; - --yellow: #ffd600; - --green: #2dce89; - --teal: #11cdef; - --cyan: #2bffc6; - --gray: #8898aa; - --gray-dark: #32325d; - --lighter: #e9ecef; - --secondary: #f7fafc; - --success: #2dce89; - --info: #11cdef; - --warning: #fb6340; - --danger: #f5365c; - --light: #adb5bd; - --dark: #212529; - --default: #172b4d; - --white: #fff; - --neutral: #fff; - --darker: #000; - --background-color: #f4f5f7; - --login-form-bg-color: rgba(244,245,247,0.8); - --breakpoint-xs: 0; - --breakpoint-sm: 576px; - --breakpoint-md: 768px; - --breakpoint-lg: 992px; - --breakpoint-xl: 1200px; - --blur-radius: 10px; - --blur-opacity: .5; - --blur-radius-dark: 10px; - --blur-opacity-dark: .5; - --font-family-sans-serif: "Google Sans","Microsoft Yahei","WenQuanYi Micro Hei",sans-serif,"Helvetica Neue",Helvetica,"Hiragino Sans GB"; - --font-family-monospace: SFMono-Regular,Menlo,Monaco,Consolas,'Liberation Mono','Courier New',monospace; - --font-family-normal: Open Sans,PingFangSC-Regular,Microsoft Yahei,WenQuanYi Micro Hei,"Helvetica Neue",Helvetica,Hiragino Sans GB,sans-serif; -} - -html,body { - height: 100%; - font-size: 16px; - font-family: var(--font-family-sans-serif); - margin: 0px; - padding: 0px; -} - -html { - -webkit-text-size-adjust: 100%; - -ms-text-size-adjust: 100%; -} - -body { - font-size: .875rem; - background-color: var(--background-color); - color: var(--gray-dark); -} - -* { - box-sizing: border-box; - margin: 0; - padding: 0; -} - -::selection { - background-color: var(--primary); - color: var(--white); -} - -a:link,a:visited,a:active { - color: var(--primary); - text-decoration: none; -} - -a:hover { - text-decoration: underline; -} - -li { - list-style-type: none; -} - -.table { - position: relative; - display: table; -} - -.tr { - display: table-row; -} - -.thead { - display: table-header-group; -} - -.tbody { - display: table-row-group; -} - -.tfoot { - display: table-footer-group; -} - -.td,.th { - line-height: normal; - display: table-cell; - text-align: center; - vertical-align: middle; - padding: .5em; -} - -.th { - font-weight: 700; - white-space: nowrap; -} - -.tr.placeholder { - height: 4em; -} - -.tr.placeholder>.td { - line-height: 3; - position: absolute; - right: 0; - bottom: 0; - left: 0; - text-align: center!important; - background: inherit; - padding: .4rem 0!important; -} - -.td[width="33%"] { - padding: 1.1em 1.5rem; -} - -.table[width="33%"],.th[width="33%"],.td[width="33%"] { - width: 33%; -} - -.col-1 { - flex: 1 1 30px!important; -} - -.col-2 { - flex: 2 2 60px!important; -} - -.col-3 { - flex: 3 3 90px!important; -} - -.col-4 { - flex: 4 4 120px!important; -} - -.col-5 { - flex: 5 5 150px!important; -} - -.col-6 { - flex: 6 6 180px!important; -} - -.col-7 { - flex: 7 7 210px!important; -} - -.col-8 { - flex: 8 8 240px!important; -} - -.col-9 { - flex: 9 9 270px!important; -} - -.col-10 { - flex: 10 10 300px!important; -} - -.h1,.h2,.h3,.h4,.h5,.h6,h1,h2,h3,h4,h5,h6 { - font-family: inherit; - font-weight: 400; - line-height: 1.1!important; - color: inherit; -} - -select { - color: #555; - border: thin solid #ccc; - background-color: #fff; - background-image: none; - padding: .36rem .8rem; -} - -.btn,button,select,input,.cbi-dropdown { - line-height: 1.5rem; - color: #8898aa; - border: 1px solid #dee2e6; - border-radius: .25rem; - outline: 0; - background-image: none; - box-shadow: none; - transition: box-shadow .15s ease; - margin: .25rem .1rem; - padding: .5rem .75rem; -} - -select,.cbi-dropdown { - width: inherit; - cursor: default; -} - -select:not([multiple="multiple"]):focus,input:not(.cbi-button):focus,.cbi-dropdown:focus { - box-shadow: 0 3px 9px rgba(50,50,9,0),3px 4px 8px rgba(94,114,228,0.1); - border-color: var(--primary); -} - -pre { - overflow: auto; -} - -code { - font-size: 1rem; - font-size-adjust: .35; - color: #101010; - border-radius: 2px; - background: #ddd; - padding: 1px 3px; -} - -abbr { - cursor: help; - text-decoration: underline; - color: var(--primary); -} - -hr { - opacity: .1; - border-color: #eee; - margin: 1rem 0; -} - -.login-page { - height: 95vh; - width: 95vw; -} - -.login-page .video { - position: absolute; - width: 100%; - height: 100%; - display: flex; - align-items: center; - justify-content: center; - background-color: var(--darker); - overflow: hidden; -} - -.login-page .video video { - width: 100%; - height: auto; -} - -.login-page .volume-control { - position: fixed; - right: 1rem; - top: 1rem; - width: 1.5rem; - height: 1.5rem; - z-index: 5000; - cursor: pointer; - background-size: contain; - background-image: url(../img/volume_high.svg); -} - -.login-page .volume-control.mute { - background-image: url(../img/volume_off.svg); -} - -.login-page .main-bg { - position: absolute; - width: 101vw; - height: 101vh; - left: 0; - top: 0; - background-image: url(../img/blank.png); - background-repeat: no-repeat; - background-position: center; - background-size: cover; - transition: all .5s; - background-color: rgba(255,255,255,1); -} - - -.login-page .status-container { - height: 100%; - position: absolute; - top: 0px; - - right: 0px; - display: flex; - flex-direction: column; - -webkit-box-pack: center; - justify-content: center; - align-items: flex-start; - min-height: 100%; - z-index: 2; - width: 800px; - box-shadow: rgba(0,0,0,0.75) 0 0 35px -5px; - margin-left: 5%; - background: transparent; -} - -.login-page .status-container .status-form { - display: flex; - flex-direction: column; - -webkit-box-align: center; - align-items: right; - position: absolute; - top: 0px; - width: 100%; - min-height: 100%; - max-width: 800px; - background-color: rgba(224,224,224,0); -} - -.login-page .login-container { - height: 100%; - position: absolute; - top: 0px; - display: flex; - flex-direction: column; - -webkit-box-pack: center; - justify-content: center; - align-items: flex-start; - min-height: 100%; - z-index: 2; - width: 20vw; - box-shadow: rgba(0,0,0,0.75) 0 0 35px -5px; - margin-left: 4%; - background: transparent; -} - -/* color of login panel */ -.login-page .login-container .login-form { - display: flex; - flex-direction: column; - -webkit-box-align: center; - align-items: center; - position: absolute; - top: 0px; - width: 100%; - min-height: 100%; - max-width: 100%; - background-color: rgba(224,224,224,0.7); -} - -/* change for login box */ -.login-page .login-container .login-form .brand { - display: flex; - -webkit-box-align: center; - align-items: center; - color: var(--default); - margin: 20px auto 5px 10px; -} - -.login-page .login-container .login-form .brandim { - display: flex; - -webkit-box-align: center; - align-items: center; - color: var(--default); - margin: 12vh 0px 30px 0px; -} - -.login-page .login-container .login-form .brandim .icon-im { - width: 19vw; - height: auto; - margin-right: 0px; -} - -.login-page .login-iframem { - height: 76vh; - position: absolute; - - left: 40vw; - top: 0; - display: flex; - flex-direction: column; - -webkit-box-pack: center; - justify-content: center; - align-items: flex-start; - min-height: 76vh; - z-index: 2; - width: 50vw; - margin-left: 1vw; - background: transparent; -} -.login-page .login-iframem .login-iform { - display: flex; - flex-direction: column; - -webkit-box-align: center; - align-items: center; - position: absolute; - top: 0px; - width: 100%; - min-height: 76vh; - max-width: 100%; -} - -.login-page .login-iframem .login-iform .ifframe { - width: 100vw; - max-width: 100%; - height: 76vh; - max-height: 100%; - left: 0px; - position: absolute; - top: 0px; -} - -.login-page .login-iframe { - height: 12vh; - position: absolute; - top: 85vh; - left: 0; - display: flex; - flex-direction: column; - -webkit-box-pack: center; - justify-content: center; - align-items: flex-start; - min-height: 12vh; - z-index: 2; - width: 18vw; - margin-left: 1vw; - background: transparent; -} -.login-page .login-iframe .login-iform { - display: flex; - flex-direction: column; - -webkit-box-align: center; - align-items: center; - position: absolute; - top: 0px; - width: 100%; - min-height: 12vh; - max-width: 100%; -} - -.login-page .login-iframe .login-iform .ifframe { - width: 100vw; - max-width: 100%; - height: 50vh; - max-height: 100%; - left: 0px; - position: absolute; - top: 0px; -} - -.login-page .login-bframe { - height: 45vh; - position: absolute; - top: 52vh; - left: 0; - display: flex; - flex-direction: column; - -webkit-box-pack: center; - justify-content: center; - align-items: flex-start; - min-height: 45vh; - z-index: 2; - width: 24vw; - margin-left: -2vw; - background: transparent; -} -.login-page .login-bframe .login-bform { - display: flex; - flex-direction: column; - -webkit-box-align: center; - align-items: center; - position: absolute; - top: 0px; - width: 100%; - min-height: 45vh; - max-width: 100%; -} - -.login-page .login-bframe .login-bform .ibframe { - width: 100vw; - max-width: 100%; - height: 50vh; - max-height: 100%; - left: 0px; - position: absolute; - top: 0px; -} - -/* size of logo displayed */ -.login-page .login-container .login-form .brand .icon-lg { - width: 19vw; - height: auto; - margin-right: 10px; -} - -.login-page .login-container .login-form .brand .icon { - width: 7vw; - height: auto; - margin-right: 10px; -} - -.login-page .login-container .login-form .brand .brand-text { - font-size: 1.2vw; - font-weight: 700; - font-family: TypoGraphica; -} - -.login-page .login-container .login-form .brand .brand-textlg { - font-size: 1.2vw; - font-weight: 700; - font-family: TypoGraphica; - margin-left: 2vw; -} - -.login-page .login-container .login-form .form-login { - width: 100%; - box-sizing: border-box; - padding: 20px 50px; -} - -.login-page .login-container .login-form .form-login .errorbox { - text-align: center; - color: var(--warning); - padding-bottom: 2rem; -} - -.login-page .login-container .login-form .form-login .input-group { - margin-bottom: 1.25rem; - position: relative; -} - -.login-page .login-container .login-form .form-login .input-group::before { - font-family: argon!important; - font-style: normal; - font-weight: 400; - font-variant: normal; - text-transform: none; - line-height: 1; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; - color: var(--default); - font-size: 1.5rem; - position: absolute; - z-index: 100; - left: 10px; - top: 10px; -} - -.login-page .login-container .login-form .form-login .input-group .border { - position: absolute; - width: 100%; - height: 1px; - bottom: 0; - border-bottom: 1px var(--primary) solid; - transform: scaleX(0); - transition: transform .3s; -} - -.login-page .login-container .login-form .form-login .input-group input { - font-size: 1rem; - line-height: 1.5em; - display: block; - width: 100%; - box-sizing: border-box; - transition: all .3s cubic-bezier(.68,-0.55,.265,1.55); - color: var(--default); - border: 0; - border-radius: 0; - border-bottom: 1px solid var(--white); - background-color: transparent; - background-clip: padding-box; - box-shadow: 0 3px 2px rgba(233,236,239,0.05); - outline: none; - margin: .825rem 0; - padding: .5rem .75rem .5rem 3rem; -} - -.login-page .login-container .login-form .form-login .input-group input:focus+.border { - transform: scaleX(1); -} - -.login-page .login-container .login-form .form-login .input-group .cbi-input-password { - margin-bottom: 2rem; - position: relative; -} - -.login-page .login-container .login-form .form-login .user-icon::before { - content: "\e971"; -} - -.login-page .login-container .login-form .form-login .pass-icon::before { - content: "\e910"; -} - -.login-page .login-container .login-form .cbi-button-apply { - width: 100%!important; - box-shadow: rgba(0,0,0,0.1) 0 0 50px 0; - font-weight: 600; - font-size: 15px; - color: var(--white); - text-align: center; - cursor: pointer; - min-height: 50px; - background-color: var(--primary)!important; - border-radius: 6px; - outline: none; - border-image: initial; - transition: all .3s!important; - letter-spacing: .8rem; - border-color: initial; - border-style: none; - border-width: initial; - margin: 30px 0px 20px; - padding: 10px 0px; -} - -.login-page .login-container .login-form .cbi-button-apply:hover,.login-page .login-container .login-form .cbi-button-apply :focus { - opacity: .9; -} - -.login-page .login-container footer { - box-sizing: border-box; - width: 100%; - text-align: center; - line-height: 1.6rem; - display: flex; - justify-content: space-evenly; - margin-top: auto; - z-index: 10; - color: var(--default); - position: absolute; - bottom: 0; - padding: 0px 0px 30px; -} - -.login-page .login-container footer .ftc { - position: absolute; - bottom: 30px; - width: 100%; -} - -footer { - font-size: .8rem; - overflow: hidden; - text-align: right; - white-space: nowrap; - color: #aaa; - padding: 1rem; -} - -footer>a { - text-decoration: none; - color: #aaa; -} - -small { - font-size: 90%; - line-height: 1.42857143; - white-space: normal; -} - -.main { - position: relative; - top: 0; - bottom: 0; - overflow-y: auto; - height: 100%; -} - -.main-left { - top: 0; - float: left; - width: calc(0% + 15rem); - height: 100%; - background-color: var(--menu-bg-color); - box-shadow: rgba(0,0,0,0.75) 0 0 15px -5px; - overflow-x: auto; - position: fixed; - z-index: 100; -} - -.main-left .sidenav-header { - text-align: center; - padding: 1.5rem; -} - -.main-left .sidenav-header .brand { - font-size: 1.8rem; - color: var(--primary); - font-family: TypoGraphica; - text-decoration: none; - text-align: center; - cursor: default; - vertical-align: text-bottom; - white-space: nowrap; -} - -.main-left::-webkit-scrollbar { - width: 5px; - height: 1px; -} - -.main-right { - float: right; - width: calc(100% - 15rem); - height: 100%; - transition: all .2s; -} - -.main-right>#maincontent { - position: relative; - z-index: 50; -} - -.pull-right { - float: right; -} - -.nowrap:not(.td) { - white-space: nowrap; -} - -[disabled="disabled"] { - pointer-events: none; -} - -header { - color: var(--header-color); - position: relative; - padding: 0; -} - -header.bg-primary { - background-color: var(--primary)!important; -} - -header::after { - content: ""; - position: absolute; - height: 2rem; - width: 100%; - background-color: var(--primary)!important; -} - -header .fill { - border-bottom: 0 solid rgba(255,255,255,0.08)!important; - padding: .8rem 0; -} - -header .fill .container { - height: 2rem; - padding: 0 1.25rem; -} - -header .fill .container .showSide { - display: none; - color: #fff; - font-size: 1.4rem; -} - -header .fill .container .brand { - font-size: 1.5rem; - color: #fff; - font-family: TypoGraphica; - text-decoration: none; - padding-left: 1rem; - cursor: default; - vertical-align: text-bottom; - display: none; -} - -header .fill .container .pull-right { - float: right; - margin-top: 0rem; - display: flex; -} - -header .fill .status { - position: absolute; - top: 25%; - right: 1.25rem; - float: right; -} - -header .fill .status span[data-indicator="poll-status"] { - display: block; - font-size: .8rem; - font-weight: 700; - white-space: nowrap; - text-decoration: none; - text-transform: uppercase; - text-shadow: none; - border-radius: 3px; - cursor: pointer; - transition: all .3s; - padding: .3rem .8rem; -} - -header .fill .status span[data-style="active"] { - color: #32325d!important; - background-color: #fff; -} - -header .fill .status span[data-style="inactive"] { - color: #FFF!important; - background-color: #32325d; -} - -#xhr_poll_status { - display: flex; - margin-left: .5rem; -} - -div[style="width:100%;height:300px;border:1px solid #000;background:#fff"] { - border: 0!important; -} - -.danger { - background-color: #ff7d60!important; -} - -.warning { - background-color: #f0e68c!important; -} - -.success { - background-color: #5cb85c!important; -} - -.notice { - background-color: #11cdef!important; - color: #fff; -} - -.error { - color: red; -} - -.alert,.alert-message { - font-weight: 700; - margin-bottom: 1em; - border: 0; - border-radius: .375rem!important; - background-color: #fff; - box-shadow: 0 2px 2px 0 rgba(0,0,0,0.16),0 0 2px 0 rgba(0,0,0,0.12); - text-shadow: 1px 1px rgba(0,0,0,0.1); - padding: 1rem; -} - -.alert.error,.alert-message.error { - background-color: #ffd600; -} - -.alert h4,.alert-message h4 { - padding: 0 1.5rem .75rem 0; -} - -.alert-message>h4 { - font-size: 110%; - font-weight: 700; -} - -.alert-message>* { - margin: .5rem 0; -} - -.alert-message .btn { - padding: .3rem .6rem; -} - -.main .main-left { - transition: all .2s; -} - -.main .main-left .nav li { - cursor: pointer; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; - padding: 0; -} - -.main .main-left .nav li a { - display: block; - color: var(--menu-color); -} - -.main .main-left .nav li.slide .slide-menu { - margin: 0 .5rem 0 2.5rem; - padding: 0 .5rem; -} - -.main .main-left .nav li.slide .slide-menu li { - position: relative; - border-radius: .375rem; - background: none; - list-style: none; - margin: 0; - padding: .5rem 0; -} - -.main .main-left .nav li.slide .slide-menu li a { - white-space: nowrap; - text-decoration: none; -} - -.main .main-left .nav li.slide .slide-menu li::after { - content: ""; - position: absolute; - left: 0; - bottom: 0; - width: 0; - height: 2px; - background-color: var(--primary); - transition: all .2s; -} - -.main .main-left .nav li.slide .slide-menu .active { - background: none; - color: var(--menu-color); -} - -.main .main-left .nav li.slide .slide-menu .active a { - color: var(--menu-color); -} - -.main .main-left .nav li.slide .slide-menu .active::after { - content: ""; - position: absolute; - left: 0; - bottom: 0; - width: 100%; - height: 2px; - background-color: var(--primary); - transition: all .2s; -} - -.main .main-left .nav li .menu::after { - position: absolute; - right: .5rem; - top: .8rem; - font-family: argon!important; - font-style: normal; - font-weight: 400; - font-variant: normal; - text-transform: none; - line-height: 1; - -moz-osx-font-smoothing: grayscale; - content: '\e90f'; - color: #ced4da; - text-rendering: auto; - -webkit-font-smoothing: antialiased; - transition: all .3s; -} - -.main .main-left .nav li .menu[data-title=Status]:before { - content: "\e906"; - color: var(--primary); -} - -.main .main-left .nav li .menu[data-title=System]:before { - content: "\e90a"; - color: #fb6340; -} - -.main .main-left .nav li .menu[data-title=Services]:before { - content: "\e909"; - color: #11cdef; -} - -.main .main-left .nav li .menu[data-title=NAS]:before { - content: "\e90c"; - color: #f3a4b5; -} - -.main .main-left .nav li .menu[data-title=VPN]:before { - content: "\e90b"; - color: #8965e0; -} - -.main .main-left .nav li .menu[data-title=Network]:before { - content: "\e908"; - color: #8965e0; -} - -.main .main-left .nav li .menu[data-title=Bandwidth_Monitor]:before { - content: "\e90d"; - color: #2dce89; -} - -.main .main-left .nav li .menu[data-title=Docker]:before { - content: "\e911"; - color: #69F; -} - -.main .main-left .nav li .menu[data-title=Statistics]:before { - content: "\e913"; - color: #8965e0; -} - -.main .main-left .nav li .menu[data-title=Control]:before { - content: "\e912"; - color: var(--primary); -} - -.main .main-left .nav li .menu[data-title=Asterisk]:before { - content: "\e914"; - color: #fb6340; -} - -.main .main-left .nav li a[data-title=Logout]:before { - content: "\e907"; - color: #adb5bd; -} - -.lg { - margin: 0; - padding: 0!important; -} - -.logout { - display: block; - border-radius: .375rem; - text-decoration: none; - font-size: 1rem; - transition: all .2s; - position: relative; - margin: .8rem .5rem .1rem; - padding: .675rem 0 .675rem 2.5rem; -} - -.logout:before { - font-family: argon!important; - font-style: normal; - font-weight: 400; - font-variant: normal; - text-transform: none; - line-height: 1; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; - position: absolute; - left: .8rem; - padding-top: 3px; - transition: all .3s; - content: "\e907"; - color: #32325d!important; -} - -body[class*="node-"]>.main>.main-left>.nav>.slide>.menu::before { - transition: transform .1s ease-in-out; -} - -body[class*="node-"]>.main>.main-left>.nav>.slide>.menu.active::before { - transition: transform .2s ease-in-out; -} - -#maincontent>.container { - margin: 0 1.25rem 1rem; -} - -ul { - line-height: normal; -} - -h1 { - font-size: 2rem; - padding-bottom: 10px; - border-bottom: thin solid #eee; -} - -h2 { - font-size: 1.25rem; - letter-spacing: .1rem; - color: #32325d; - border-radius: .375rem; - background: #fff; - box-shadow: 0 4px 8px rgba(0,0,0,0.03); - margin: 0 0 1rem; - padding: 1rem 1.5rem; -} - -h3 { - font-size: 1.1rem; - line-height: 1; - display: block; - width: 100%; - color: var(--gray-dark); - border-radius: .375rem; - background: #fff; - margin: 0; - padding: .8755rem 1.5rem; -} - -h4 { - font-size: .7rem; - font-weight: 600; - color: #525f7f; - background-color: var(--lighter); - margin: 0; - padding: .75rem 1.5rem; -} - -h4 em { - padding: 0 .5rem; -} - -h5 { - font-size: 1rem; - padding-bottom: 10px; - margin: 2rem 0 0; -} - -.cbi-section,.cbi-section-error,#iptables,.Firewall form,#cbi-network>.cbi-section-node,#cbi-wireless>.cbi-section-node,#cbi-wireless>#wifi_assoclist_table,[data-tab-title],[data-page^="admin-system-admin"]:not(.node-main-login) .cbi-map:not(#cbi-dropbear),[data-page="admin-system-opkg"] #maincontent>.container { - font-family: inherit; - font-weight: 400; - font-style: normal; - line-height: normal; - min-width: inherit; - border: 0; - border-radius: .375rem; - background-color: #fff; - box-shadow: 0 0 1rem 0 rgba(136,152,170,0.15); - margin: 1.5rem 0; - padding: 0rem; -} - -.cbi-modal .cbi-section,.cbi-section .cbi-section { - box-shadow: none; - padding: 0; -} - -.cbi-modal .cbi-tabmenu { - margin-left: 0; -} - -.cbi-map-descr,.cbi-section-descr { - font-size: small; - line-height: 1.42857143; - padding: .5rem 1.5rem; -} - -.cbi-map-descr>abbr { - cursor: help; - text-decoration: underline; -} - -.cbi-section>legend { - display: none!important; -} - -fieldset>fieldset,.cbi-section>.cbi-section { - border: 0; - box-shadow: none; - margin: 0; - padding: 0; -} - -.cbi-section>h3:first-child,.panel-title { - font-size: 1.1rem; - line-height: 1; - display: block; - width: 100%; - color: var(--gray-dark); - margin: 0; - padding: .8755rem 1.5rem; -} - -table { - border-spacing: 0; - border-collapse: collapse; -} - -table,.table { - overflow-y: hidden; - width: 100%; - font-size: 90%; -} - -.table .table-titles th { - background-color: var(--lighter); -} - -.container>.cbi-section:first-of-type>.table[width="100%"]>.tr>.td { - padding: .6rem; -} - -.cbi-section-table-cell { - line-height: 1.1; - align-self: flex-end; - flex: 1 1 auto; -} - -tr>td,tr>th,.tr>.td,.tr>.th,.cbi-section-table-row::before,#cbi-wireless>#wifi_assoclist_table>.tr:nth-child(2) { - border-top: thin solid #ddd; - padding: 1.1em 1.5rem; -} - -#cbi-wireless .td,#cbi-network .tr:first-child>.td,.table[width="100%"]>.tr:first-child>.td,[data-page="admin-network-diagnostics"] .tr>.td,.tr.table-titles>.th,.tr.cbi-section-table-titles>.th { - border-top: 0!important; - background-color: #f6f9fc; - line-height: 1.3rem; - padding: 1.1em 1.5rem; -} - -.table[width="100%"]>.tr:first-child>.td { - margin: auto 0; -} - -.cbi-section-table-row { - margin-bottom: 1rem; - text-align: center!important; - background: #f4f4f4; -} - -.cbi-section-table-row:last-child { - margin-bottom: 0; -} - -.cbi-section-table-row>.cbi-value-field [data-dynlist]>input,.cbi-section-table-row>.cbi-value-field input.cbi-input-password { - width: calc(100% - 1.5rem); -} - -table table,.table .table,.cbi-value-field table,.cbi-value-field .table,td>table>tbody>tr>td,.td>.table>.tbody>.tr>.td,.cbi-value-field>table>tbody>tr>td,.cbi-value-field>.table>.tbody>.tr>.td { - border: 0; -} - -.btn,.cbi-button,.item::after { - font-size: .8rem; - display: inline-block; - width: auto!important; - cursor: pointer; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; - transition: all .2s ease-in-out; - text-align: center; - vertical-align: middle; - white-space: nowrap; - text-decoration: none; - text-transform: uppercase; - color: rgba(0,0,0,0.87); - border: 0; - border-radius: .2rem; - background-color: #f0f0f0; - background-image: none; - -webkit-appearance: none; - -ms-touch-action: manipulation; - touch-action: manipulation; - padding: .45rem .8rem; -} - -.cbi-button-up,.cbi-button-down { - font-size: 1.2rem; - display: inline-block; - min-width: 0; - color: transparent!important; - background: url(../icon/arrow.svg) no-repeat center; - background-size: 12px 20px; - padding: .2rem .3rem; -} - -.cbi-button-up { - transform: scaleY(-1); -} - -.cbi-button:not(select) { - -webkit-appearance: none!important; -} - -.btn:hover,.btn:focus,.btn:active,.cbi-button:hover,.cbi-button:focus,.cbi-button:active,.item:hover::after,.item:focus::after,.item:active::after,.cbi-page-actions .cbi-button-apply+.cbi-button-save:hover,.cbi-page-actions .cbi-button-apply+.cbi-button-save:focus,.cbi-page-actions .cbi-button-apply+.cbi-button-save:active { - text-decoration: none; - outline: 0; -} - -.btn:hover,.btn:focus,.cbi-button:hover,.cbi-button:focus,.item:hover::after,.item:focus::after { - box-shadow: 0 0 2px rgba(0,0,0,0.12),0 2px 2px rgba(0,0,0,0.2); -} - -.btn:active,.cbi-button:active,.item:active::after { - box-shadow: 0 10px 20px rgba(0,0,0,0.19),0 6px 6px rgba(0,0,0,0.23); -} - -.cbi-button-up:hover,.cbi-button-up:focus { - box-shadow: 0 0 2px rgba(0,0,0,0.12),0 -2px 2px rgba(0,0,0,0.2); -} - -.cbi-button-up:active { - box-shadow: 0 -10px 20px rgba(0,0,0,0.19),0 -6px 6px rgba(0,0,0,0.23); -} - -.btn:disabled,.cbi-button:disabled { - cursor: not-allowed; - pointer-events: none; - opacity: .5; - box-shadow: none; -} - -.alert-message [class="btn"],.modal div[class="btn"],.cbi-button-find,.cbi-button-link,.cbi-button-up,.cbi-button-down,.cbi-button-neutral,.cbi-button[name="zero"],.cbi-button[name="restart"],.cbi-button[onclick="hide_empty(this)"] { - font-weight: 700; - color: #fff; - border: thin solid #8898aa; - background-color: #8898aa; -} - -.btn.danger,.cbi-section-remove>.cbi-button,.cbi-button-remove,.cbi-button-reset,.cbi-button-negative,.cbi-button[value="Stop"],.cbi-button[value="Kill"],.cbi-button[onclick="reboot(this)"],.cbi-button-neutral[value="Restart"] { - font-weight: 400; - color: #fff; - border: thin solid var(--red); - background-color: var(--red); -} - -.btn[value="Dismiss"],.cbi-button[value="Terminate"],.cbi-button[value="Reset"],.cbi-button[value="Disabled"],.cbi-button[onclick^="iface_reconnect"],.cbi-button[onclick="handleReset(event)"],.cbi-button-neutral[value="Disable"] { - font-weight: 400; - color: #fff; - border: thin solid #eea236; - background-color: #f0ad4e; -} - -.cbi-button-success,.cbi-button-download,.cbi-button[name="backup"],.cbi-button[value="Download"],.cbi-button[value="Save mtdblock"] { - font-weight: 400; - color: #fff; - border: thin solid #4cae4c; - background-color: #5cb85c; -} - -.cbi-value-field .cbi-button-add { - font-weight: 700; - display: flex; - align-items: center; - margin: 4px 0 4px 3px; - padding: 1px 6px; -} - -.tabs { - background-color: #FFF; - border-radius: .375rem; - box-shadow: 0 4px 8px rgba(0,0,0,0.03); - white-space: nowrap; - overflow-x: auto; - margin: 0 0 1rem; - padding: 0 1rem; -} - -.tabs li[class~="active"],.tabs li:hover { - cursor: pointer; - border-bottom: .18751rem solid var(--primary); - color: var(--primary); - background-color: #dce1fe; - margin-bottom: 0; - border-radius: 0; -} - -.tabs li { - font-size: .875rem; - display: inline-block; - border-bottom: .18751rem solid rgba(0,0,0,0); - margin: 0 .2rem; - padding: .875rem 0; -} - -.tabs li:hover { - border-bottom: .18751rem solid var(--primary); -} - -.cbi-tabmenu { - color: #fff; - white-space: nowrap; - overflow-x: auto; - padding: .5rem 1rem 0; -} - -.cbi-tabmenu li { - background: #dce3e9; - display: inline-block; - font-size: .875rem; - border-top-left-radius: .25rem; - border-top-right-radius: .25rem; - border-bottom: .18751rem solid rgba(0,0,0,0); - margin: 0 .2rem; - padding: .5rem 0; -} - -.cbi-tabmenu li:hover { - cursor: pointer; - border-bottom: .18751rem solid var(--primary); - color: var(--primary); - background-color: #dce1fe; - margin-bottom: 0; -} - -.cbi-tabmenu li:hover a { - color: #525f7f; -} - -.cbi-tabmenu li[class~="cbi-tab"] { - border-bottom: .18751rem solid var(--primary); - color: var(--primary); - background-color: #dce1fe; - margin-bottom: 0; -} - -.cbi-tab-descr { - padding: .5rem 1.5rem; -} - -[data-tab-title] { - overflow: hidden; - height: 0; - opacity: 0; - margin: 0; - padding: 0rem!important; -} - -[data-tab-title] p { - margin-left: 1rem; - margin-bottom: 1rem; -} - -[data-tab-active="true"] { - overflow: visible; - height: auto; - opacity: 1; - transition: opacity .25s ease-in; - margin: inherit!important; -} - -.cbi-section-node-tabbed { - margin-top: 0; - border: 0 solid #d4d4d4; - border-radius: .375rem; - padding: 0; -} - -.cbi-value-field,.cbi-value-description { - line-height: 1.25; - display: table-cell; -} - -.cbi-value-field abbr,.cbi-value-description abbr { - color: var(--gray-dark); -} - -.cbi-value-description { - font-size: small; - opacity: .5; - padding: .5rem; -} - -.cbi-value-title { - display: table-cell; - float: left; - width: 23rem; - padding-top: .25rem; - padding-right: 2rem; - text-align: right; - word-wrap: break-word; -} - -.cbi-value { - display: inline-block; - width: 100%; - line-height: 2.4rem; - padding: .35rem 1rem .2rem; -} - -.cbi-value ul { - line-height: 1.25; -} - -.cbi-value-field .cbi-dropdown,.cbi-value-field .cbi-input-select,.cbi-value input[type="text"],.cbi-value input[type="password"] { - min-width: 18rem; -} - -.cbi-value input[type="password"] { - border-bottom-right-radius: 0; - border-top-right-radius: 0; - margin-right: 0; -} - -.cbi-value input[type="password"]+.cbi-button-neutral { - height: 42px; - border-bottom-left-radius: 0; - border-top-left-radius: 0; - margin-left: 0; - border: 0; -} - -#cbi-firewall-zone .cbi-input-select,#cbi-network-switch_vlan .cbi-input-select { - min-width: 11rem; -} - -#cbi-network-switch_vlan .cbi-input-text { - max-width: 3rem; -} - -.cbi-input-invalid { - color: #f5365c; - border-bottom-color: #f5365c; -} - -.cbi-section-error { - font-weight: 700; - line-height: 1.42857143; - border: thin solid #f5365c; - border-radius: 3px; - background-color: #fce6e6; - margin: 18px; - padding: 6px; -} - -.cbi-section-error ul { - margin: 0 0 0 20px; -} - -.cbi-section-error ul li { - font-weight: 700; - color: #f5365c; -} - -.td[data-title]::before { - font-weight: 700; - display: none; - content: attr(data-title) ":\20"; - text-align: left; - white-space: nowrap; - padding: .25rem 0; -} - -.tr[data-title]::before,.tr.cbi-section-table-titles.named::before { - font-weight: 700; - display: table-cell; - align-self: center; - flex: 1 1 5%; - content: attr(data-title) "\20"; - text-align: center; - vertical-align: middle; - white-space: normal; - word-wrap: break-word; - padding: .25rem; -} - -.cbi-rowstyle-2 { - background-color: #eee; -} - -.cbi-rowstyle-2 .cbi-button-up,.cbi-rowstyle-2 .cbi-button-down,body:not(.Interfaces) .cbi-rowstyle-2:first-child { - background-color: #fff!important; -} - -.cbi-section-table .cbi-section-table-titles .cbi-section-table-cell { - width: auto!important; -} - -.td.cbi-section-actions { - text-align: right!important; - vertical-align: middle; -} - -.td.cbi-section-actions>* { - display: inline-flex; -} - -.td.cbi-section-actions>*>*,.td.cbi-section-actions>*>form>* { - display: flex; - align-items: center; - margin: 0 5px; -} - -.td.cbi-section-actions>*>form { - display: inline-flex; - margin: 0; -} - -.cbi-checkbox { - margin: 0 .25rem; -} - -.cbi-dynlist { - line-height: 1.3; - flex-direction: column; - min-height: 30px; - cursor: text; -} - -.cbi-dynlist>.item { - position: relative; - max-width: 25rem; - pointer-events: none; - color: #8898aa; - outline: 0; -} - -.cbi-dynlist[name="sshkeys"]>.item { - max-width: none; -} - -.cbi-dynlist>.item::after { - position: absolute; - width: 2.2rem!important; - height: calc(100% - .5rem - 2px); - right: 0; - bottom: 0; - content: "\00D7"; - pointer-events: auto; - background-color: var(--red); - font-weight: 400; - font-size: 1.2rem; - display: flex; - align-items: center; - justify-content: center; - line-height: 1.5rem; - color: #fff; - border: 1px solid #f5365c; - border-radius: .25rem; - outline: 0; - background-image: none; - box-shadow: none; - border-top-left-radius: 0; - border-bottom-left-radius: 0; - margin: .25rem .1rem .25rem 0; - padding: 0; -} - -.cbi-dynlist>.item>span { - white-space: normal; - word-break: break-word; - line-height: 1.5rem; - color: #8898aa; - border: 1px solid #dee2e6; - border-radius: .25rem; - outline: 0; - background-image: none; - box-shadow: none; - display: block; - transition: box-shadow .15s ease; - box-sizing: border-box; - min-width: 15rem; - margin: .25rem .1rem; - padding: .5rem; -} - -.cbi-dynlist>.add-item { - display: inline-flex; - align-items: center; - width: 100%; - min-width: 16rem; -} - -.cbi-dynlist>.add-item input { - border-top-right-radius: 0; - border-bottom-right-radius: 0; - margin-right: 0; - border-right: none; -} - -.cbi-dynlist>.add-item .cbi-button-add { - font-weight: 400; - font-size: 1.2rem; - display: flex; - align-items: center; - line-height: 1.5rem; - color: #fff; - border: 1px solid var(--primary); - border-radius: .25rem; - outline: 0; - background-image: none; - box-shadow: none; - border-top-left-radius: 0; - border-bottom-left-radius: 0; - margin: .25rem .1rem .25rem 0; - padding: .5rem .75rem; -} - -.cbi-dynlist>.add-item:not([ondrop])>input { - overflow: hidden; - width: 100%; - min-width: 15rem; - white-space: nowrap; - text-overflow: ellipsis; -} - -.cbi-dynlist>.add-item[ondrop]>input { - min-width: 13rem; -} - -.cbi-dynlist,.cbi-dropdown { - position: relative; - display: inline-flex; - padding: .2rem; -} - -.cbi-dropdown[placeholder*="select"] { - max-width: 25rem; - height: auto; - margin-top: -3px; -} - -.cbi-dropdown>ul { - display: flex; - overflow-x: hidden; - overflow-y: auto; - width: 100%; - list-style: none; - outline: 0; - margin: 0!important; - padding: 0; -} - -.cbi-dropdown>.open { - flex-basis: 15px; -} - -.cbi-dropdown>.open,.cbi-dropdown>.more { - font-size: 1rem; - font-weight: 900; - line-height: 2; - display: flex; - flex-direction: column; - flex-grow: 0; - flex-shrink: 0; - justify-content: center; - cursor: default; - text-align: center; - outline: 0; - padding: 0 .25em; -} - -.cbi-dropdown>.more,.cbi-dropdown>ul>li[placeholder] { - font-weight: 700; - display: none; - color: #777; - text-shadow: 1px 1px 0 #fff; -} - -.cbi-dropdown>ul>li { - display: none; - overflow: hidden; - align-items: center; - align-self: center; - flex-grow: 1; - flex-shrink: 1; - min-height: 20px; - white-space: nowrap; - text-overflow: ellipsis; - padding: .25em; -} - -.cbi-dropdown>ul>li[display]:not([display="0"]) { - border-left: thin solid #ccc; -} - -.cbi-dropdown[empty]>ul { - max-width: 1px; -} - -.cbi-dropdown>ul>li>form { - display: none; - pointer-events: none; - margin: 0; - padding: 0; -} - -.cbi-dropdown>ul>li img { - margin-right: .25em; - vertical-align: middle; -} - -.cbi-dropdown>ul>li>form>input[type="checkbox"] { - height: auto; - margin: 0; -} - -.cbi-dropdown>ul>li input[type="text"] { - height: 20px; -} - -.cbi-dropdown[open]>ul.dropdown { - position: absolute; - z-index: 1100; - display: block; - width: auto; - min-width: 100%; - max-width: none; - max-height: 200px!important; - border: 0 solid #918e8c; - background: #FFF; - box-shadow: 0 0 4px #918e8c; - border-bottom-left-radius: .35rem; - border-bottom-right-radius: .35rem; - color: var(--main-menu-color); - margin-left: -0.2rem!important; -} - -.cbi-dropdown[open]>ul.dropdown li { - color: #000; -} - -.cbi-dropdown>ul>li[display],.cbi-dropdown[open]>ul.preview,.cbi-dropdown[open]>ul.dropdown>li,.cbi-dropdown[multiple]>ul>li>label,.cbi-dropdown[multiple][open]>ul.dropdown>li,.cbi-dropdown[multiple][more]>.more,.cbi-dropdown[multiple][empty]>.more { - display: flex; - align-items: center; - flex-grow: 1; -} - -.cbi-dropdown[open]>ul.dropdown>li { - border-bottom: thin solid #ccc; - padding: .5rem .8rem; -} - -.cbi-dropdown[open]>ul.dropdown>li[selected] { - background: #dce1fe; -} - -.cbi-dropdown[open]>ul.dropdown>li.focus { - background: #dce1fe; - outline: none; -} - -.cbi-dropdown[open]>ul.dropdown>li:last-child { - margin-bottom: 0; - border-bottom: 0; -} - -.cbi-dropdown[open]>ul.dropdown>li[unselectable] { - opacity: .7; -} - -.cbi-dropdown[disabled] { - pointer-events: none; - opacity: .6; -} - -.cbi-dropdown[open] .zonebadge { - width: auto; -} - -.cbi-progressbar { - position: relative; - min-width: 170px; - height: 20px; - border: thin solid #999; - background: #eee; - border-radius: .2rem; - overflow: hidden; - margin: 6px 0; -} - -.cbi-progressbar>div { - width: 0; - height: 100%; - transition: width .25s ease-in; - background: var(--bar-bg); -} - -.cbi-progressbar::after { - font-family: monospace; - font-size: 1em; - font-weight: 700; - font-size-adjust: .38; - line-height: normal; - position: absolute; - top: 2px; - right: 0; - bottom: 2px; - left: 0; - overflow: hidden; - content: attr(title); - text-align: center; - white-space: pre; - text-overflow: ellipsis; -} - -#modal_overlay { - position: fixed; - z-index: 900; - top: 0; - right: 10000px; - bottom: 0; - left: -10000px; - overflow-y: scroll; - transition: opacity .125s ease-in; - opacity: 0; - background: rgba(0,0,0,0.7); - -webkit-overflow-scrolling: touch; -} - -.modal { - display: flex; - align-items: center; - flex-wrap: wrap; - width: 90%; - min-width: 270px; - max-width: 600px; - min-height: 32px; - border-radius: 3px!important; - background: #fff; - box-shadow: 0 2px 2px 0 rgba(0,0,0,0.16),0 0 2px 0 rgba(0,0,0,0.12); - margin: 5em auto; - padding: 1em; -} - -.modal>* { - line-height: normal; - flex-basis: 100%; - margin-bottom: .5em; - max-width: 100%; -} - -.modal>pre,.modal>textarea { - font-size: 1rem; - font-size-adjust: .35; - overflow: auto; - margin-bottom: .5em; - cursor: auto; - white-space: pre-wrap; - color: #eee; - outline: 0; - background-color: #101010; - box-shadow: 0 2px 2px 0 rgba(0,0,0,0.16),0 0 2px 0 rgba(0,0,0,0.12); - padding: 8.5px; -} - -.modal>h4 { - margin: .5em 0; -} - -.modal ul { - margin-left: 2.2em; -} - -.modal li { - list-style-type: square; - color: gray; -} - -.modal p { - word-break: break-word; -} - -.modal .label { - font-size: .6rem; - font-weight: 400; - cursor: default; - border-radius: 0; - padding: .1rem .3rem 0; -} - -.modal .label.warning { - background-color: #f0ad4e!important; -} - -.modal .btn { - padding: .45rem .8rem; -} - -.modal.cbi-modal { - max-width: 90%; - max-height: none; -} - -body.modal-overlay-active { - overflow: hidden; - height: 100vh; -} - -body.modal-overlay-active #modal_overlay { - right: 0; - left: 0; - opacity: 1; -} - -.spinning { - position: relative; - padding-left: 32px!important; -} - -.spinning::before { - position: absolute; - top: 0; - bottom: 0; - left: .2em; - width: 32px; - content: ""; - background: url(/luci-static/resources/icons/loading.gif) no-repeat center; - background-size: 16px; -} - -.left,.left::before { - text-align: left!important; -} - -.right,.right::before { - text-align: right!important; -} - -.top { - align-self: flex-start!important; - vertical-align: top!important; -} - -.bottom { - align-self: flex-end!important; - vertical-align: bottom!important; -} - -.inline { - display: inline; -} - -.cbi-page-actions { - padding-top: 1rem; - text-align: right; -} - -.cbi-page-actions>form[method="post"] { - display: inline-block; -} - -.th[data-type="button"],.td[data-type="button"],.th[data-type="fvalue"],.td[data-type="fvalue"] { - flex: 1 1 2em; - text-align: center; -} - -.ifacebadge { - display: inline-flex; - border-bottom: thin solid #ccc; - background: #eee; - box-shadow: inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05); - padding: .5rem .8rem; -} - -td>.ifacebadge,.td>.ifacebadge { - font-size: .8rem; - background-color: #f0f0f0; -} - -.ifacebadge>em,.ifacebadge>img { - display: inline-block; - align-self: flex-start; - margin: 0 .2rem; -} - -.ifacebadge>img+img { - margin: 0 .2rem 0 0; -} - -.network-status-table .ifacebox { - flex-grow: 1; - margin: .5em; -} - -.network-status-table .ifacebox-body { - display: flex; - flex-direction: column; - height: 100%; -} - -.network-status-table .ifacebox-body>span { - flex: 10 10 auto; - height: 100%; -} - -.network-status-table .ifacebox-body .ifacebadge { - align-items: center; - flex: 1 1 auto; - min-width: 220px; - background-color: #fff; - margin: .5em 0 0; - padding: .5em; -} - -.cbi-input-textarea { - font-family: monospace; - width: 100%; - font-size: .875rem; - min-height: 14rem; - color: #000; - padding: .8rem; -} - -#syslog { - font-size: small; - line-height: 1.25; - overflow-y: hidden; - width: 100%; - min-height: 15rem; - resize: none; - color: #242424; - border: 0; - border-radius: .375rem; - background-color: #FFF; - box-shadow: 0 2px 2px 0 rgba(0,0,0,0.16),0 0 2px 0 rgba(0,0,0,0.12); - padding: 1rem; -} - -#syslog:focus { - outline: 0; -} - -.uci-change-list { - font-family: monospace; -} - -.uci-change-list ins,.uci-change-legend-label ins { - display: block; - text-decoration: none; - border: thin solid #0f0; - background-color: #cfc; - padding: 2px; -} - -.uci-change-list del,.uci-change-legend-label del { - font-style: normal; - display: block; - text-decoration: none; - border: thin solid red; - background-color: #fcc; - padding: 2px; -} - -.uci-change-list var,.uci-change-legend-label var { - font-style: normal; - display: block; - text-decoration: none; - border: thin solid #ccc; - background-color: #eee; - padding: 2px; -} - -.uci-change-list var ins,.uci-change-list var del { - font-style: normal; - white-space: pre; - border: 0; - padding: 0; -} - -.uci-change-legend { - padding: 5px; -} - -.uci-change-legend-label { - float: left; - width: 150px; -} - -.uci-change-legend-label>ins,.uci-change-legend-label>del,.uci-change-legend-label>var { - display: block; - float: left; - width: 10px; - height: 10px; - margin-right: 4px; -} - -.uci-change-legend-label var ins,.uci-change-legend-label var del { - line-height: .4; - border: 0; -} - -#iwsvg,#iwsvg2,#bwsvg { - border: thin solid #d4d4d4!important; -} - -#iwsvg,[data-page="admin-status-realtime-bandwidth"] #bwsvg { - border-top: 0!important; -} - -.ifacebox { - line-height: 1.25; - display: inline-flex; - flex-direction: column; - min-width: 100px; - border-bottom: thin solid #ccc; - background-color: #f9f9f9; - box-shadow: inset 0 1px 0 rgba(255,255,255,0.4),0 1px 2px rgba(0,0,0,0.2); -} - -.ifacebox-head { - background: #eee; - padding: .25em; -} - -.ifacebox-head.active { - background: var(--primary); -} - -.ifacebox-head.active * { - color: var(--white); -} - -.ifacebox-body { - line-height: 1.6em; - padding: .5em 1rem; -} - -.zonebadge { - display: inline-block; - padding: .2rem .5rem; -} - -.zonebadge .ifacebadge { - border: thin solid #6c6c6c; - margin: .1rem .2rem; - padding: .2rem .3rem; -} - -.zonebadge>input[type="text"] { - min-width: 10rem; - margin-top: .3rem; - padding: .16rem 1rem; -} - -.zonebadge>em,.zonebadge>strong { - display: inline-block; - margin: 0 .2rem; -} - -.cbi-value-field .cbi-input-checkbox,.cbi-value-field .cbi-input-radio { - margin-top: .1rem; -} - -.cbi-value-field>ul>li { - display: flex; -} - -.cbi-value-field>ul>li .ifacebadge { - margin-top: -0.5rem; - margin-left: .4rem; - background-color: #eee; -} - -.cbi-section-table-row>.cbi-value-field .cbi-dropdown { - min-width: 7rem; -} - -.cbi-section-create { - display: inline-flex; - align-items: center; - margin: .25rem 0 .25rem 1rem; -} - -.cbi-section-create>* { - margin: .5rem; -} - -div.cbi-value var,td.cbi-value-field var,.td.cbi-value-field var { - font-style: italic; - color: #0069d6; -} - -.cbi-optionals { - border-top: thin solid #ccc; - padding: 1rem 1rem 0; -} - -.cbi-dropdown-container { - position: relative; -} - -.cbi-tooltip-container,span[data-tooltip],span[data-tooltip] .label { - cursor: help!important; -} - -.cbi-tooltip { - position: absolute; - z-index: 1000; - left: -1000px; - transition: opacity .25s ease-out; - white-space: pre; - pointer-events: none; - opacity: 0; - border-radius: 3px; - background: #fff; - box-shadow: 0 0 2px #444; - padding: 2px 5px; -} - -.cbi-tooltip-container:hover .cbi-tooltip { - left: auto; - transition: opacity .25s ease-in; - opacity: 1; -} - -.zonebadge .cbi-tooltip { - background: inherit; - margin: -1.5rem 0 0 -0.5rem; - padding: .25rem; -} - -.zonebadge-empty { - color: #404040; - background: repeating-linear-gradient(45deg,rgba(204,204,204,0.5),rgba(204,204,204,0.5) 5px,rgba(255,255,255,0.5) 5px,rgba(255,255,255,0.5) 10px); -} - -.zone-forwards { - display: flex; - min-width: 10rem; -} - -.zone-forwards>* { - flex: 1 1 45%; -} - -.zone-forwards>span { - flex-basis: 10%; - text-align: center; - padding: 0 .25rem; -} - -.zone-forwards .zone-src,.zone-forwards .zone-dest { - display: flex; - flex-direction: column; -} - -.label { - font-size: .8rem; - font-weight: 700; - white-space: nowrap; - text-decoration: none; - text-transform: uppercase; - color: #fff!important; - border-radius: 3px; - background-color: #bfbfbf; - text-shadow: none; - padding: .3rem .8rem; -} - -label>input[type="checkbox"],label>input[type="radio"] { - position: relative; - top: .4rem; - right: .2rem; - vertical-align: bottom; - margin: 0; -} - -label[data-index][data-depends] { - padding-right: 2em; -} - -.darkMask { - position: fixed; - z-index: 99; - display: none; - width: 100%; - height: 100%; - content: ""; - top: 0; - background-color: rgba(0,0,0,0.56); -} - -#diag-rc-output>pre,#command-rc-output>pre,[data-page="admin-services-wol"] .notice code { - font-size: 1.2rem; - font-size-adjust: .35; - line-height: normal; - display: block; - overflow-y: hidden; - width: 100%; - white-space: pre; - color: #eee; - background-color: #101010; - box-shadow: 0 2px 2px 0 rgba(0,0,0,0.16),0 0 2px 0 rgba(0,0,0,0.12); - padding: 8.5px; -} - -[data-page="admin-network-diagnostics"] .table { - box-shadow: none; -} - -input[name="ping"],input[name="traceroute"],input[name="nslookup"] { - width: 80%; -} - -.node-status-overview>.main fieldset:nth-child(4) .td:nth-child(2),.node-status-processes>.main .table .tr .td:nth-child(3) { - white-space: normal; -} - -[data-page="admin-system-reboot"] .cbi-button { - background: #fb6340!important; -} - -[data-page="admin-system-reboot"] p>span { - position: relative; - top: .1rem; - left: 1rem; -} - -[data-page="admin-vpn-passwall"] h4 { - background: transparent; -} - -#cbi-samba [data-tab="template"] .cbi-value-title { - width: auto; - padding-bottom: .6rem; -} - -.controls { - margin: .5em 1rem 1em!important; -} - -.controls>*>.btn:not([aria-label$="page"]) { - flex-grow: initial!important; - margin-top: .25rem; -} - -.controls>#pager>.btn[aria-label$="page"] { - font-size: 1.4rem; - font-weight: 700; -} - -.controls>*>label { - margin-bottom: .2rem; -} - -[data-page="admin-system-opkg"] div.btn { - line-height: 3; - display: inline; - padding: .3rem .6rem; -} - -[data-page^="admin-system-admin"]:not(.node-main-login) .cbi-map:not(#cbi-dropbear),[data-page="admin-system-opkg"] #maincontent>.container { - margin-top: 2rem; - padding-top: .1rem; -} - -[data-page="admin-system-opkg"] #maincontent>.container { - margin: 0 1.25rem 1rem; -} - -.td.version,.td.size { - white-space: normal!important; - word-break: break-word; -} - -[data-page="admin-system-crontab"] #view p { - margin-bottom: 1rem; -} - -[data-page="admin-system-flash"] .cbi-map-tabbed { - border-radius: .375rem; -} - -[data-page="admin-system-flash"] legend { - display: block!important; - font-size: 1.2rem; - width: 100%; - border-bottom: 1px solid rgba(0,0,0,0.05); - line-height: 1.5; - margin-bottom: 0rem; - letter-spacing: .1rem; - color: #32325d; - font-weight: 700; - padding: 1rem 0 1rem 1.5rem; -} - -[data-page="admin-system-flash"] .cbi-section-descr { - font-weight: 600; - color: #525f7f; - padding: 1rem 0 1rem 1.5rem; -} - -[data-page="admin-system-flash"] .modal label>input[type="checkbox"] { - top: -0.35rem; -} - -[data-page="admin-system-flash"] .modal .btn { - white-space: normal!important; -} - -#cbi-wireless>#wifi_assoclist_table>.tr { - box-shadow: inset 1px -1px 0 #ddd,inset -1px -1px 0 #ddd; -} - -#cbi-wireless>#wifi_assoclist_table>.tr.placeholder>.td { - right: 33px; - bottom: 33px; - left: 33px; - border-top: thin solid #ddd!important; -} - -#cbi-wireless>#wifi_assoclist_table>.tr.table-titles { - box-shadow: inset 1px 0 0 #ddd,inset -1px 0 0 #ddd; -} - -#cbi-wireless>#wifi_assoclist_table>.tr.table-titles>.th { - border-bottom: thin solid #ddd; - box-shadow: 0 -1px 0 0 #ddd; -} - -#wifi_assoclist_table>.tr>.td[data-title="RX Rate / TX Rate"] { - width: 23rem; -} - -[data-page="admin-network-dhcp"] [data-tab-active="true"] { - padding: 1rem 0!important; -} - -#iptables { - margin: 0; -} - -.Firewall form { - box-shadow: none; - margin: 2rem 2rem 0 0; - padding: 0; -} - -#cbi-firewall-redirect table *,#cbi-network-switch_vlan table *,#cbi-firewall-zone table * { - font-size: small; -} - -#cbi-firewall-redirect table input[type="text"],#cbi-network-switch_vlan table input[type="text"],#cbi-firewall-zone table input[type="text"] { - width: 5rem; -} - -#cbi-firewall-redirect table select,#cbi-network-switch_vlan table select,#cbi-firewall-zone table select { - min-width: 3.5rem; -} - -#cbi-network-switch_vlan .th,#cbi-network-switch_vlan .td { - flex-basis: 12%; -} - -[data-page="admin-network-firewall-custom"] #view p,[data-page="admin-status-routes"] #view p { - margin-bottom: 1rem; - padding: 0 1.5rem; -} - -[data-page="admin-network-firewall-custom"] #view p textarea,[data-page="admin-status-routes"] #view p textarea { - border-radius: .375rem; - padding: 1rem; -} - -#applyreboot-container { - margin: 2rem; -} - -#applyreboot-section { - line-height: 300%; - margin: 2rem; -} - -.OpenVPN a { - line-height: initial!important; -} - -.commandbox { - width: 24%!important; - border-bottom: thin solid #ccc; - background: #eee; - box-shadow: inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05); - margin: 10px 0 0 10px!important; - padding: .5rem 1rem; -} - -.commandbox h3 { - line-height: normal!important; - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; - margin: 6px 0!important; -} - -.commandbox div { - left: auto!important; -} - -.commandbox code { - position: absolute; - overflow: hidden; - max-width: 60%; - margin-left: 4px; - white-space: nowrap; - text-overflow: ellipsis; - padding: 2px 3px; -} - -.commandbox code:hover { - overflow-y: auto; - max-height: 50px; - white-space: normal; -} - -.commandbox p:first-of-type { - margin-top: -6px; -} - -.commandbox p:nth-of-type(2) { - margin-top: 2px; -} - -#command-rc-output .alert-message { - line-height: 1.42857143; - position: absolute; - top: 40px; - right: 32px; - max-width: 40%; - animation: anim-fade-in 1.5s forwards; - word-break: break-word; - opacity: 0; - margin: 0; -} - -input[type="checkbox"] { - appearance: none!important; - -webkit-appearance: none!important; - border: 1px solid #dee2e6; - width: 16px!important; - height: 16px!important; - cursor: pointer; - transition: all .2s; - margin: 1rem 0 0; - padding: 0; -} - -input[type="checkbox"]:checked { - border: 1px solid var(--primary); - background-image: url('data:image/svg+xml,%3csvg xmlns=\'http://www.w3.org/2000/svg\' viewBox=\'0 0 8 8\'%3e%3cpath fill=\'%23fff\' d=\'M6.564.75l-3.59 3.612-1.538-1.55L0 4.26 2.974 7.25 8 2.193z\'/%3e%3c/svg%3e')!important; - background-color: var(--primary); - background-size: 70%; - background-repeat: no-repeat; - background-position: center; -} - -.fb-container .cbi-button { - height: auto!important; -} - -#cbi-usb_printer-printer em { - display: block; - text-align: center; - padding: 1rem; -} - -pre.command-output { - padding: 1.5rem; -} - -[data-page="admin-nlbw-display"] .cbi-section[data-tab="export"] { - padding: 1.5rem!important; -} - -[data-page="admin-status-iptables"] .right { - margin-bottom: 0!important; -} - -.table[width="100%"],.th[width="100%"],.td[width="100%"],header,.main,.main .main-left .nav li.slide .slide-menu li:hover::after,.main .main-left .nav li.slide .slide-menu .active:hover::after,.cbi-section-table-row>.cbi-value-field .cbi-dropdown,.cbi-section-table-row>.cbi-value-field .cbi-input-select,.cbi-section-table-row>.cbi-value-field .cbi-input-text,.cbi-section-table-row>.cbi-value-field .cbi-input-password,.cbi-dropdown[open]>ul.dropdown>li>input.create-item-input:first-child:last-child,.cbi-dropdown .zonebadge,#cbi-firewall-zone .td,#cbi-network-switch_vlan .td { - width: 100%; -} - -.cbi-dropdown,select[multiple="multiple"],.alert .btn,.alert-message .btn { - height: auto; -} - -.login-page .login-container .login-form .brand:hover,header .fill .container .showSide:hover,.a-to-btn { - text-decoration: none; -} - -.login-page .login-container footer .luci-link,.cbi-dropdown[empty]>ul>li,.cbi-dropdown[optional][open]>ul.dropdown>li[placeholder],.cbi-dropdown[multiple][open]>ul.dropdown>li>form,#cbi-samba [data-tab="template"] .cbi-value-field,#cbi-firewall-zone .table,#cbi-network-switch_vlan .table { - display: block; -} - -.main-left::-webkit-scrollbar-thumb,.tabs::-webkit-scrollbar-thumb,.cbi-tabmenu::-webkit-scrollbar-thumb { - background-color: #f6f9fc; -} - -.main-left::-webkit-scrollbar-track,.tabs::-webkit-scrollbar-track,.cbi-tabmenu::-webkit-scrollbar-track { - background-color: #fff; -} - -.pull-left,.cbi-page-actions .cbi-button-link:first-child { - float: left; -} - -#xhr_poll_status *,.cbi-button-apply>ul.preview li,.cbi-button-apply>ul:first-child li { - color: #fff; -} - -.container .alert,.container .alert-message,.cbi-map-descr+fieldset { - margin-top: 1rem; -} - -.main .main-left .nav,.cbi-value-field>ul>li>label { - margin-top: .5rem; -} - -.main .main-left .nav>li>a:first-child,.main .main-left .nav li .menu { - border-radius: .375rem; - cursor: default; - display: block; - font-size: 1rem; - position: relative; - text-decoration: none; - transition: all .2s; - margin: .1rem .5rem; - padding: .675rem 0 .675rem 2.5rem; -} - -.main .main-left .nav>li>a:first-child.active,.main .main-left .nav li .menu.active { - background: var(--primary); - color: #fff; -} - -.main .main-left .nav>li>a:first-child.active::before,.main .main-left .nav>li>a:first-child:hover::before,.main .main-left .nav li .menu.active::before,.main .main-left .nav li .menu:hover::before { - color: #fff!important; -} - -.main .main-left .nav>li>a:first-child.active::after,.main .main-left .nav li .menu.active::after { - color: #fff!important; - transform: rotate(90deg); -} - -.main .main-left .nav>li>a:first-child:hover,.main .main-left .nav li .menu:hover { - background: var(--primary); - color: #fff; - cursor: pointer; -} - -.main .main-left .nav>li>a:first-child::before,.main .main-left .nav li .menu::before { - -moz-osx-font-smoothing: grayscale; - -webkit-font-smoothing: antialiased; - color: var(--primary); - content: "\e915"; - font-family: argon!important; - font-style: normal; - font-variant: normal; - font-weight: 400; - left: .8rem; - line-height: 1; - padding-top: 3px; - position: absolute; - text-transform: none; - transition: all .3s; -} - -.main .main-left .nav li.slide,[data-page="admin-system-flash"] .cbi-value,[data-page="admin-network-dhcp"] .cbi-value { - padding: 0; -} - -.main .main-left .nav li.slide ul,.main>.main-left[style*="overflow: hidden"]>.nav>.slide>.menu::before,.tr.placeholder .td[data-title]::before,.cbi-dropdown>ul.preview,.cbi-button-apply>ul.preview,.cbi-dropdown>ul>li .hide-close,.cbi-dropdown[open]>ul.dropdown>li .hide-open,.hidden,.showSide,[data-page^="admin-system-commands"] .panel-title,[data-page^="command-cfg"] .mobile-hide,[data-page^="command-cfg"] .showSide { - display: none; -} - -.main .main-left .nav li.slide:hover,.main .main-left .nav li.slide .slide-menu li:hover,.main .main-left .nav li.slide .slide-menu .active:hover { - background: none; -} - -.cbi-section>h3:first-child,.cbi-section>h4:first-child,.cbi-section>p:first-child,[data-tab-title]>h3:first-child,[data-tab-title]>h4:first-child,[data-tab-title]>p:first-child,.cbi-section p { - padding: 1rem; -} - -table>tbody>tr>td,table>tbody>tr>th,table>tfoot>tr>td,table>tfoot>tr>th,table>thead>tr>td,table>thead>tr>th,.table>.tbody>.tr>.td,.table>.tbody>.tr>.th,.table>.tfoot>.tr>.td,.table>.tfoot>.tr>.th,.table>.thead>.tr>.td,.table>.thead>.tr>.th,.table>.tr>.td.cbi-value-field,.table>.tr>.th.cbi-section-table-cell,.uci-change-list var,.uci-change-list del,.uci-change-list ins,.cbi-section-remove { - padding: .5rem; -} - -.cbi-section-table-row .td,.center,.center::before { - text-align: center!important; -} - -div>table>tbody>tr:nth-of-type(2n),div>.table>.tr:nth-of-type(2n),.cbi-section .cbi-section-remove:nth-of-type(2n),.container>.cbi-section .cbi-section-node:nth-of-type(2n),.cbi-section[id] .cbi-section-remove:nth-of-type(4n+3),.cbi-section[id] .cbi-section-node:nth-of-type(4n+4),.cbi-tabcontainer>.cbi-value:nth-of-type(2n),.cbi-rowstyle-1 { - background-color: #f9f9f9; -} - -.btn.primary,.cbi-page-actions .cbi-button-save,.cbi-page-actions .cbi-button-apply+.cbi-button-save,.cbi-button-add,.cbi-button-save,.cbi-button-positive,.cbi-button-link,.cbi-button[value="Enable"],.cbi-button[value="Scan"],.cbi-button[value^="Back"],.cbi-button-neutral[onclick="handleConfig(event)"],.cbi-page-actions .cbi-button-apply,.cbi-section-actions .cbi-button-edit,.cbi-button-edit,.cbi-button-apply,.cbi-button-reload,.cbi-button-action,.cbi-button[value="Submit"],.cbi-button[value="Upload"],.cbi-button[value$="Apply"],.cbi-button[onclick="addKey(event)"] { - background-color: var(--primary); - border: thin solid var(--primary); - color: #fff!important; - font-weight: 400; -} - -.tabs::-webkit-scrollbar,.cbi-tabmenu::-webkit-scrollbar { - height: 5px; - width: 1px; -} - -.tabs li[class~="active"] a,.tabs li:hover a,.cbi-tabmenu li[class~="cbi-tab"] a { - color: var(--primary); -} - -.tabs li a,.cbi-tabmenu li a { - color: #404040; - text-decoration: none; - padding: .5rem .8rem; -} - -.cbi-dropdown>ul>li .hide-open,.cbi-dropdown[open]>ul.dropdown>li .hide-close { - display: initial; -} - -.cbi-dropdown[open]>ul.dropdown>li label,.cbi-image-button { - margin-left: .5rem; -} - -.network-status-table,.network-status-table .ifacebox-body>div { - display: flex; - flex-wrap: wrap; -} - -[data-page="admin-system-reboot"] p,[data-page="admin-nlbw-backup"] form { - padding-left: 1.5rem; -} - -[data-page="admin-system-admin"] .cbi-map h2,[data-page="admin-system-admin-password"] .cbi-map h2,[data-page="admin-system-admin"] .cbi-map .cbi-map-descr,[data-page="admin-system-admin-password"] .cbi-map .cbi-map-descr,[data-page="admin-system-opkg"] h2 { - color: var(--gray-dark); - margin-left: 0; -} - -.cbi-tabmenu+.cbi-section,[data-page="admin-system-flash"] .cbi-section .cbi-section { - margin-top: 0; -} - -@keyframes anim-fade-in { - 100% { - opacity: 1; - } -} - -@media all and (-ms-high-contrast:none) { - .main>.main-left>.nav>.slide>.menu::before { - top: 30.25%; - } - - .main>.main-left>.nav>li:last-child::before { - top: 20%; - } - - .showSide::before { - top: -12px; - } -} - -@media screen and (max-width:1600px) { - header>.fill>.container>#logo { - margin: 0 2.5rem 0 .5rem; - } - - .main-left { - width: calc(0% + 13rem); - } - - .main-right { - width: calc(100% - 13rem); - } - - .btn:not(button),.cbi-button { - font-size: .8rem; - } - - .label { - padding: .2rem .6rem; - } - - .cbi-value-title { - width: 15rem; - padding-right: .6rem; - } - - .cbi-value-field .cbi-dropdown,.cbi-value-field .cbi-input-select,.cbi-value input[type="text"],.cbi-value input[type="password"] { - min-width: 18rem; - } - - #cbi-firewall-zone .cbi-input-select { - min-width: 9rem; - } - - .cbi-input-textarea { - font-size: small; - } - - .node-admin-status>.main fieldset li>a { - padding: .3rem .6rem; - } -} - -@media screen and (max-width:1366px) { - header>.fill>.container { - cursor: default; - } - - .main-left { - width: calc(0% + 13rem); - } - - .main-right { - width: calc(100% - 13rem); - } - - .tabs>li>a,.cbi-tabmenu>li>a { - padding: .2rem .8rem; - } - - .panel-title { - font-size: 1.1rem; - padding-bottom: 1rem; - } - - table { - font-size: .7rem!important; - width: 100%!important; - } - - .table .cbi-input-text { - width: 100%; - } - - .cbi-value-field .cbi-dropdown,.cbi-value-field .cbi-input-select,.cbi-value input[type="text"],.cbi-value input[type="password"] { - min-width: 16rem; - } - - #cbi-firewall-zone .cbi-input-select { - min-width: 4rem; - } - - .main>.main-left>.nav>li,.main>.main-left>.nav>li>a,.main .main-left .nav>li>a:first-child,.main>.main-left>.nav>.slide>.menu,.main>.main-left>.nav>li>[data-title="Logout"] { - font-size: .9rem; - } - - .main>.main-left>.nav>.slide>.slide-menu>li>a { - font-size: .7rem; - } - - #modal_overlay { - top: 0rem; - } - - [data-page="admin-network-firewall-forwards"] .table:not(.cbi-section-table) { - display: block; - } - - [data-page="admin-network-firewall-forwards"] .table:not(.cbi-section-table),[data-page="admin-network-firewall-rules"] .table:not(.cbi-section-table),[data-page="admin-network-hosts"] .table,[data-page="admin-network-routes"] .table { - overflow-y: visible; - } - - .commandbox { - width: 32%!important; - } - - .btn:not(button),.cbi-button { - font-size: .8rem; - } -} - -@media screen and (max-width:1152px) { - header>.fill>.container>.brand { - position: relative; - } - - html,.main { - overflow-y: visible; - } - - .main>.loading>span { - top: 25%; - } - - .main-left { - width: calc(0% + 13rem); - } - - .main-right { - width: calc(100% - 13rem); - } - - body:not(.logged-in) .showSide { - visibility: hidden; - width: 0; - margin: 0; - } - - .cbi-value-title { - width: 12rem; - padding-right: 1rem; - } - - .cbi-value-field .cbi-dropdown,.cbi-value-field .cbi-input-select,.cbi-value input[type="text"] { - width: 16rem; - min-width: 16rem; - } - - .cbi-value input[name^="pw"],.cbi-value input[data-update="change"]:nth-child(2) { - width: 13rem!important; - min-width: 13rem; - } - - #diag-rc-output>pre,#command-rc-output>pre,[data-page="admin-services-wol"] .notice code { - font-size: 1rem; - } - - .Interfaces .table { - overflow-x: hidden; - } - - #packages.table { - display: grid; - } - - .tr { - display: flex; - flex-direction: row; - flex-wrap: wrap; - } - - .Overview .table[width="100%"]>.tr { - flex-wrap: nowrap; - } - - .tr.placeholder { - border-bottom: thin solid #ddd; - } - - .tr.placeholder>.td,#cbi-firewall .tr>.td,#cbi-network .tr:nth-child(2)>.td,.cbi-section #wifi_assoclist_table .tr>.td { - border-top: 0; - } - - .th,.td { - display: inline-block; - align-self: flex-start; - flex: 2 2 10%; - text-overflow: ellipsis; - word-wrap: break-word; - } - - .td select,.td input[type="text"] { - width: 100%; - word-wrap: normal; - } - - .td [data-dynlist]>input,.td input.cbi-input-password { - width: calc(100% - 1.5rem); - } - - .td[data-type="button"],.td[data-type="fvalue"] { - flex: 1 1 12.5%; - text-align: left; - } - - .th.cbi-value-field,.td.cbi-value-field,.th.cbi-section-table-cell,.td.cbi-section-table-cell { - flex-basis: auto; - padding-top: 1rem; - } - - .cbi-section-table-row { - display: flex; - flex-direction: row; - flex-wrap: wrap; - justify-content: space-between; - box-shadow: 0 2px 2px 0 rgba(0,0,0,0.16),0 0 2px 0 rgba(0,0,0,0.12); - } - - .td.cbi-value-field,.cbi-section-table-cell { - display: inline-block; - flex: 10 10 auto; - flex-basis: 50%; - text-align: center; - } - - .td.cbi-section-actions { - vertical-align: bottom; - } - - .tr[data-title]::before,.tr.cbi-section-table-titles.named::before { - font-size: .9rem; - display: block; - flex: 1 1 100%; - border-bottom: thin solid rgba(0,0,0,0.26); - background: #e9ecef; - } - - .cbi-button+.cbi-button { - margin-left: 0; - } - - .td.cbi-section-actions>*>*,.td.cbi-section-actions>*>form>* { - margin: 2.1px 3px; - } - - .Firewall form { - position: static!important; - box-shadow: 0 2px 2px 0 rgba(0,0,0,0.16),0 0 2px 0 rgba(0,0,0,0.12); - margin: 0 0 2rem; - padding: 2rem; - } - - .Firewall form input { - width: 100%!important; - margin: 1rem 0 0; - } - - .Firewall .center,.Firewall .center::before { - text-align: left!important; - } - - .commandbox { - width: 100%!important; - margin-left: 0!important; - } - - .btn:not(button),.cbi-button { - font-size: .8rem; - } - - header>.fill>.container>#logo,.tr.table-titles,.tr.cbi-section-table-titles,.tr.cbi-section-table-descr { - display: none; - } - - .node-main-login>.main .cbi-value-title,.td[data-title],[data-page^="admin-status-realtime"] .td[id] { - text-align: left; - } - - .table,.td[data-title]::before { - display: block; - } -} - -@media screen and (max-width:768px) { - .cbi-progressbar::after { - font-size: .5rem; - line-height: 1.5; - } - - .main-left { - position: fixed; - z-index: 100; - width: 0; - } - - .main-right { - width: 100%; - } - - .showSide { - position: relative; - z-index: 99; - display: inline-block!important; - padding: .1rem; - } - - .showSide::before { - font-family: argon!important; - font-style: normal!important; - font-weight: 400!important; - font-variant: normal!important; - text-transform: none!important; - line-height: 1; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; - content: "\e20e"; - font-size: 1.7rem; - } - - header>.fill>.container>.brand { - display: inline-block; - } - - body,.main>.main-left>.nav>.slide>.slide-menu>li>a { - font-size: .8rem; - } -} - -@media screen and (max-width:600px) { - #maincontent>.container { - margin: 0 1rem 1rem; - } - - .cbi-value-title { - text-align: left; - } - - [data-page="admin-system-flash"] .cbi-value { - padding: 0 1rem; - } - - [data-page="admin-network-dhcp"] [data-tab-active="true"] { - padding: 1rem!important; - } - - .cbi-dynlist p { - padding: .5rem 1rem; - } - - body { - overflow-x: hidden; - } - - .node-main-login .main .main-right #maincontent .container .cbi-map .cbi-section .cbi-section-node .cbi-value .cbi-value-field { - width: 16rem; - } - - .tabs::-webkit-scrollbar,.cbi-tabmenu::-webkit-scrollbar { - width: 0px; - height: 0px; - } - - .cbi-value-field,.cbi-value-description { - display: block!important; - padding-left: 0!important; - padding-right: 0!important; - } - - [data-page="admin-system-admin-password"] .cbi-value-field { - display: table-cell!important; - } - - .modal.cbi-modal { - max-width: 100%; - max-height: none; - } - - .modal { - display: flex; - align-items: center; - flex-wrap: wrap; - width: 100%; - min-width: 270px; - max-width: 600px; - min-height: 32px; - border-radius: 3px!important; - background: #fff; - box-shadow: 0 2px 2px 0 rgba(0,0,0,0.16),0 0 2px 0 rgba(0,0,0,0.12); - margin: 5em auto; - padding: 1em; - } - - .cbi-dropdown[open]>ul.dropdown { - left: .2rem!important; - right: 0!important; - margin-bottom: 1rem; - } - - .mobile-hide,.node-main-login footer { - display: none; - } - - [data-page="admin-system-flash"] legend,[data-page="admin-system-flash"] .cbi-section-descr { - padding: 1rem 0 1rem 1rem; - } -} - -@media screen and (min-width:600px) { - ::-webkit-scrollbar { - width: 10px; - height: 10px; - } - - ::-webkit-scrollbar,::-webkit-scrollbar-corner { - background: transparent; - } - - ::-webkit-scrollbar-thumb { - background: #9e9e9e; - } - - ::-webkit-scrollbar-thumb:hover { - background: #757575; - } - - ::-webkit-scrollbar-thumb:active { - background: #424242; - } -} - -@media screen and (max-width:480px) { - .mobile-hide { - display: none; - } - - .login-page .login-container { - margin-left: 0rem!important; - width: 100%; - } - - .login-page .login-container .login-form .form-login .input-group::before { - color: #525461; - } - - .login-page .login-container .login-form .form-login .input-group input { - color: #525461; - border-bottom: var(--white) 1px solid; - border-radius: 0; - } -} \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/www/luci-static/css/dark.css b/rooter/ext-rooter-basic/files/www/luci-static/css/dark.css deleted file mode 100644 index 885b575..0000000 --- a/rooter/ext-rooter-basic/files/www/luci-static/css/dark.css +++ /dev/null @@ -1 +0,0 @@ -body{background:#1e1e1e;color:#CCC}.login-page .login-container .login-form .form-login .input-group input{background-color:transparent!important;color:#adb5bd;border-bottom:#adb5bd 1px solid!important;border-radius:0!important;border-top:none!important;border-left:none!important;border-right:none!important;box-shadow:none}.login-page .login-container .login-form .form-login .cbi-button-apply:hover,.login-page .login-container .login-form .form-login .cbi-button-apply:focus{opacity:.9}.main .main-left{background-color:#333!important;box-shadow:0 0 .5rem 0 rgba(0,0,0,0.15)}.main .main-left .nav .slide .slide-menu li a:hover{background:none!important}.main .main-left .nav li a{color:#CCC!important}.main .main-left::-webkit-scrollbar-thumb{background-color:#252526!important}h2{color:#ccc;background:#333}h3{color:#ccc;border-bottom:0;background:#333}a:-webkit-any-link{cursor:pointer;color:var(--dark-primary)}input:-webkit-autofill{background-color:#3c3c3c!important}.cbi-value-field .cbi-input-apply,.cbi-button-apply,.cbi-button-edit{color:#fff!important;background-color:var(--dark-primary)!important;border-color:var(--dark-primary)!important}.cbi-section{background:none;box-shadow:0 0 .5rem 0 rgba(0,0,0,0.35)}.panel-title{color:#ccc;background-color:#333;border-bottom:0px}table>tbody>tr>td,table>tfoot>tr>td,table>thead>tr>td{color:#ccc;border-top:1px solid #252526}.node-system-packages>.main .cbi-section-node:first-child .cbi-value-last{line-height:1.8em}.node-system-packages>.main .cbi-section-node:first-child .cbi-value-last div[style="margin:3px 0; width:300px; height:10px; border:1px solid #000000; background-color:#80C080"]{border:1px solid #999!important;background-color:transparent!important}tr>td,tr>th,.tr>.td,.tr>.th,.cbi-section-table-row::before,#cbi-wireless>#wifi_assoclist_table>.tr:nth-child(2){border-top:0}.cbi-section>h3:first-child,.panel-title,h3{color:#ccc;border-bottom:0;border-bottom-left-radius:0;border-bottom-right-radius:0}.cbi-progressbar{position:relative;min-width:170px;height:20px;border:thin solid #999;background:transparent;border-radius:.2rem;overflow:hidden;margin:6px 0}.cbi-button{color:#ccc!important;background-color:var(--dark-primary)}.cbi-section-node{background:none;border-radius:0 0 .375rem .375rem;padding:0rem}#content_syslog{box-shadow:0 0 .5rem 0 rgba(0,0,0,0.35)}#iwsvg,#iwsvg2,#bwsvg{overflow:hidden;box-shadow:0 0 .5rem 0 rgba(0,0,0,0.35);background-color:#1e1e1e!important}.tabs>li[class~="active"],.tabs>li:hover{border-bottom:.18751rem solid var(--dark-primary);color:#ccc;background-color:#181819}.cbi-tabmenu>li{background:#2d2d2d}.cbi-tabmenu>li:hover{color:#ccc;background:#2d2d2d}.cbi-tabmenu>li[class~="cbi-tab"]{background-color:#181819}select,input{color:#ccc;background-color:transparent!important;border:1px solid #252526;box-shadow:none}select:not([multiple="multiple"]):focus,input:focus{outline:0;border-color:var(--dark-primary)!important}.cbi-section-node .cbi-value{padding:1rem 1rem .3rem}.ifacebox{background-color:none;border:1px solid #1e1e1e}.ifacebox-head{color:#666}.zonebadge strong{color:#333}.node-services-vssr .block{background-color:#3c3c3c!important;box-shadow:0 0 .5rem 0 rgba(0,0,0,0.35)}.node-services-vssr .status-bar{color:#ccc;box-shadow:0 0 .5rem 0 rgba(0,0,0,0.35);background-color:#1e1e1e}.node-services-vssr .cbi-section-table-row{color:#ccc;background-color:#3c3c3c!important;box-shadow:0 0 5px 0 rgba(0,0,0,0.35)}.node-services-vssr .cbi-section-table-row.fast{background:var(--dark-primary)!important;color:#fff}.node-services-vssr .incon:nth-child(2){border-right:#1e1e1e 1px solid}.cbi-input-find,.cbi-input-save,.cbi-button-add,.cbi-button-save,.cbi-button-find,.cbi-input-reload,.cbi-button-reload{color:#fff!important;background:#556B2F!important;border-color:#556B2F!important}.cbi-button-reset,.cbi-input-remove{color:#fff!important;background-color:#FF8C00!important;border-color:#FF8C00!important}.cbi-page-actions .cbi-button-apply,.cbi-section-actions .cbi-button-edit,.cbi-button-edit.important,.cbi-button-apply.important,.cbi-button-reload.important,.cbi-button-action.important{border:1px var(--dark-primary) solid!important}.btn[value="Dismiss"],.cbi-button[value="Terminate"],.cbi-button[value="Reset"],.cbi-button[value="Disabled"],.cbi-button[onclick^="iface_reconnect"],.cbi-button[onclick="handleReset(event)"],.cbi-button-neutral[value="Disable"]{font-weight:400;color:#fff;border:thin solid #FF8C00!important;background-color:#FF8C00!important}#detail-bubble>div{border:1px solid #ccc;border-radius:2px;background:#252525;padding:5px}.network-status-table .ifacebox-body .ifacebadge{background-color:#252526;border-bottom:0;box-shadow:none}td>.ifacebadge,.td>.ifacebadge{background-color:var(--dark-primary);border:0}.cbi-section,.cbi-section-error,#iptables,.Firewall form,#cbi-network>.cbi-section-node,#cbi-wireless>.cbi-section-node,#cbi-wireless>#wifi_assoclist_table,[data-tab-title],[data-page^="admin-system-admin"]:not(.node-main-login) .cbi-map:not(#cbi-dropbear),[data-page="admin-system-opkg"] #maincontent>.container{background:#1e1e1e!important;box-shadow:0 0 .5rem 0 rgba(0,0,0,0.35)}div[style="width:100%;height:300px;border:1px solid #000;background:#fff"]{background:transparent!important}[data-page="admin-system-flash"] .modal label>input[type="checkbox"]{top:-0.35rem}[data-page="admin-system-flash"] .modal .btn{white-space:normal!important;background-color:#8FBC8F}[data-page="admin-system-flash"] .modal .alert-message{background-color:transparent!important}.cbi-button-positive{color:#fff!important;background-color:#556B2F!important}.logout:before{color:#adb5bd!important}.cbi-dropdown[open]{border-color:var(--dark-primary)!important}.cbi-dropdown[open]>ul.dropdown{background:#252526!important;color:#ccc!important;box-shadow:none;border:1px solid #3c3c3c!important}.cbi-dropdown[open]>ul.dropdown li{color:#ccc;border-bottom:1px solid #3c3c3c!important}.cbi-dropdown[open]>ul.dropdown>li[selected]{background-color:var(--dark-primary)!important;border-bottom:1px solid #3c3c3c!important}.cbi-dropdown[open]>ul.dropdown>li.focus{background:var(--dark-primary);outline:none}.cbi-page-actions .cbi-button-apply,.cbi-section-actions .cbi-button-edit,.cbi-button-edit,.cbi-button-apply,.cbi-button-reload,.cbi-button-action,.cbi-button[value="Submit"],.cbi-button[value="Upload"],.cbi-button[value$="Apply"],.cbi-button[onclick="addKey(event)"]{background:var(--dark-primary)!important}.btn.primary,.cbi-page-actions .cbi-button-save,.cbi-page-actions .cbi-button-apply+.cbi-button-save,.cbi-button-add,.cbi-button-save,.cbi-button-positive,.cbi-button-link,.cbi-button[value="Enable"],.cbi-button[value="Scan"],.cbi-button[value^="Back"],.cbi-button-neutral[onclick="handleConfig(event)"]{background:var(--dark-primary)}.login-page .login-container .login-form,.main .main-right,.cbi-rowstyle-2,.cbi-section-remove:nth-of-type(2n),.cbi-section-node:nth-of-type(2n),.modal{background-color:#1e1e1e}.login-page .login-container .login-form .brand,.login-page .login-container .login-form .form-login .input-group::before{color:#adb5bd}.login-page .login-container .login-form .form-login .cbi-button-apply,.notice,.cbi-value input[type="password"]+.cbi-button-neutral{background-color:var(--dark-primary)!important}header::after,header.bg-primary,select,.cbi-section-table-row{background-color:#1e1e1e!important}.main .main-left .sidenav-header .brand,.cbi-section em,.cbi-map-descr,.tabs>li[class~="active"]>a,.cbi-tabmenu>li>a,.tabs>li>a,.cbi-tabmenu>li>a:hover,.tabs>li>a:hover,.cbi-tabmenu li[class~="cbi-tab"] a,.cbi-value-title,.cbi-section-descr,.node-system-packages>.main table tr td:nth-last-child(1),.node-services-vssr .ssr-button,[data-page="admin-system-admin"] .cbi-map h2,[data-page="admin-system-admin-password"] .cbi-map h2,[data-page="admin-system-admin"] .cbi-map .cbi-map-descr,[data-page="admin-system-admin-password"] .cbi-map .cbi-map-descr,.cbi-dropdown .preview,[data-page="admin-system-flash"] legend{color:#ccc}.main .main-left .nav .slide .slide-menu .active a,.main .main-left .nav .slide .slide-menu li a{color:#CCC}.main .main-left .nav .slide .slide-menu .active a::after,.main .main-left .nav .slide .menu.active a::after{background-color:#CCC!important}.main .main-left .nav .slide .menu.active,.main .main-left .nav li a:hover{background-color:var(--dark-primary)!important;color:#CCC!important}.main .main-left::-webkit-scrollbar-track,.ifacebox-body,fieldset[id^="cbi-apply-"],.ifacebadge{background-color:#333}div>table>tbody>tr:nth-of-type(2n),div>.table>.tr:nth-of-type(2n),fieldset>table>tbody>tr:nth-of-type(2n),.cbi-rowstyle-1,div>table>tbody>tr:nth-of-type(2n),div>.table>.tbody>.tr:nth-of-type(2n),.tabs,.cbi-tabcontainer>.cbi-value:nth-of-type(2n){background-color:#252526}#swaptotal>div>div,#swapfree>div>div,#memfree>div>div,#membuff>div>div,#conns>div>div,#memtotal>div>div,.node-system-packages>.main .cbi-section-node:first-child .cbi-value-last div[style="margin:3px 0; width:300px; height:10px; border:1px solid #000000; background-color:#80C080"] div,.cbi-progressbar div,.ifacebox-head.active{background-color:#32325d!important}#swaptotal>div>div>div>small,#swapfree>div>div>div>small,#memfree>div>div>div>small,#membuff>div>div>div>small,#conns>div>div>div>small,#memtotal>div>div>div>small,#cbi-dropbear h2,#cbi-dropbear .cbi-map-descr,#cbi-dropbear .cbi-map-descr abbr,#cbi-rc h2,#cbi-rc .cbi-map-descr,#cbi-distfeedconf h2,#cbi-distfeedconf .cbi-map-descr,#cbi-customfeedconf h2,#cbi-customfeedconf .cbi-map-descr,#cbi-download h2,#cbi-filelist h2,.node-services-vssr .block h4,[data-page="admin-system-opkg"] h2{color:#ccc!important}table>tbody>tr>th,table>tfoot>tr>th,table>thead>tr>th,#cbi-wireless .td,#cbi-network .tr:first-child>.td,.table[width="100%"]>.tr:first-child>.td,[data-page="admin-network-diagnostics"] .tr>.td,.tr.table-titles>.th,.tr.cbi-section-table-titles>.th{background-color:#252526;border-bottom:#000 1px solid!important}h4,.cbi-section-table .cbi-section-table-titles .cbi-section-table-cell{background-color:#1e1e1f}abbr,div.cbi-value var,td.cbi-value-field var{color:#5e72e4}.cbi-value-field>ul>li .ifacebadge,.zonebadge>.ifacebadge{background-color:#3c3c3c}.cbi-input-textarea,#syslog,#diag-rc-output>pre{background-color:#1e1e1e;color:#ccc}#xhr_poll_status>.label.success,header .fill .status span[data-style="active"]{background-color:#556B2F!important;color:#ccc!important}.btn.danger,.cbi-section-remove>.cbi-button,.cbi-button-remove,.cbi-button-reset,.cbi-button-negative,.cbi-button[value="Stop"],.cbi-button[value="Kill"],.cbi-button[onclick="reboot(this)"],.cbi-button-neutral[value="Restart"],[data-page="admin-system-flash"] .modal .danger{background-color:#FF8C00!important;border:thin solid #FF8C00!important}.btn,button,select,input,.cbi-dropdown,.cbi-dynlist>.item>span{border:1px solid #3c3c3c!important}@media screen and (max-width:480px){.node-status-iptables>.main div>.cbi-map>form{background-color:#1e1e1e;box-shadow:0 0 .5rem 0 rgba(0,0,0,0.35)}} \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/www/luci-static/css/fonts.css b/rooter/ext-rooter-basic/files/www/luci-static/css/fonts.css deleted file mode 100644 index 20dd22e..0000000 --- a/rooter/ext-rooter-basic/files/www/luci-static/css/fonts.css +++ /dev/null @@ -1 +0,0 @@ -@font-face{font-family:argon;src:url(../fonts/argon.eot?u6kthm#iefix) format('embedded-opentype'),url(../fonts/argon.ttf?u6kthm) format('truetype'),url(../fonts/argon.woff?u6kthm) format('woff'),url(../fonts/argon.svg?u6kthm#argon) format('svg');font-weight:400;font-style:normal;font-display:block}[class^="icon-"],[class*=" icon-"]{font-family:argon!important;font-style:normal;font-weight:400;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.icon-expand_more:before{content:"\e20b"}.icon-menu:before{content:"\e20e"}.icon-favorite:before{content:"\e291"}.icon-spinner:before{content:"\e603"}.icon-delete:before{content:"\e900"}.icon-edit:before{content:"\e901"}.icon-use:before{content:"\e902"}.icon-loading:before{content:"\e903"}.icon-switch:before{content:"\e904"}.icon-error:before{content:"\e905"}.icon-dashboard:before{content:"\e906"}.icon-logout:before{content:"\e907"}.icon-Network:before{content:"\e908"}.icon-services:before{content:"\e909"}.icon-system:before{content:"\e90a"}.icon-vpn:before{content:"\e90b"}.icon-storage:before{content:"\e90c"}.icon-statistics:before{content:"\e90d"}.icon-hello-world:before{content:"\e90e"}.icon-angle-right:before{content:"\e90f"}.icon-password:before{content:"\e910"}.icon-user:before{content:"\e971"}.icon-question:before{content:"\f059"}.icon-docker:before{content:"\e911"}.icon-control:before{content:"\e912"}.icon-statistics1:before{content:"\e913"}.icon-asterisk:before{content:"\e914"}.icon-app:before{content:"\e915"} \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/www/luci-static/css/pure-min.css b/rooter/ext-rooter-basic/files/www/luci-static/css/pure-min.css deleted file mode 100644 index 43786a7..0000000 --- a/rooter/ext-rooter-basic/files/www/luci-static/css/pure-min.css +++ /dev/null @@ -1 +0,0 @@ -html{line-height:1.15;-webkit-text-size-adjust:100%;font-family:sans-serif}body{margin:0}h1{font-size:2em;margin:.67em 0}hr{-webkit-box-sizing:content-box;box-sizing:content-box;height:0;overflow:visible}abbr[title]{border-bottom:none;-webkit-text-decoration:underline dotted;text-decoration:underline dotted}b,strong{font-weight:bolder}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}img{border-style:none}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0}button,input{overflow:visible}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{border-style:none;padding:0}[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring,button:-moz-focusring{outline:1px dotted ButtonText}fieldset{padding:.35em .75em .625em}legend{-webkit-box-sizing:border-box;box-sizing:border-box;color:inherit;display:table;max-width:100%;white-space:normal;padding:0}progress{vertical-align:baseline}textarea{overflow:auto}[type=checkbox],[type=radio]{-webkit-box-sizing:border-box;box-sizing:border-box;padding:0}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}.hidden,[hidden]{display:none!important}.pure-img{max-width:100%;height:auto}.pure-g{letter-spacing:-.31em;text-rendering:optimizespeed;font-family:FreeSans,Arimo,"Droid Sans",Helvetica,Arial,sans-serif;display:flex;-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-flow:row wrap;flex-flow:row wrap;-ms-flex-line-pack:start;align-content:flex-start}.pure-g [class*=pure-u]{font-family:sans-serif}.pure-u-1-24{width:4.1667%}.pure-u-1-12,.pure-u-2-24{width:8.3333%}.pure-u-1-8,.pure-u-3-24{width:12.5%}.pure-u-1-6,.pure-u-4-24{width:16.6667%}.pure-u-1-5{width:20%}.pure-u-5-24{width:20.8333%}.pure-u-7-24{width:29.1667%}.pure-u-1-3,.pure-u-8-24{width:33.3333%}.pure-u-3-8,.pure-u-9-24{width:37.5%}.pure-u-2-5{width:40%}.pure-u-10-24,.pure-u-5-12{width:41.6667%}.pure-u-11-24{width:45.8333%}.pure-u-13-24{width:54.1667%}.pure-u-14-24,.pure-u-7-12{width:58.3333%}.pure-u-3-5{width:60%}.pure-u-15-24,.pure-u-5-8{width:62.5%}.pure-u-16-24,.pure-u-2-3{width:66.6667%}.pure-u-17-24{width:70.8333%}.pure-u-19-24{width:79.1667%}.pure-u-4-5{width:80%}.pure-u-20-24,.pure-u-5-6{width:83.3333%}.pure-u-21-24,.pure-u-7-8{width:87.5%}.pure-u-11-12,.pure-u-22-24{width:91.6667%}.pure-u-23-24{width:95.8333%}.pure-button{display:inline-block;line-height:normal;white-space:nowrap;vertical-align:middle;text-align:center;cursor:pointer;-webkit-user-drag:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-box-sizing:border-box;box-sizing:border-box;font-family:inherit;font-size:100%;color:rgba(0,0,0,.8);border:none transparent;background-color:#e6e6e6;text-decoration:none;border-radius:2px;padding:.5em 1em}.pure-button::-moz-focus-inner{border:0;padding:0}.pure-button-group{letter-spacing:-.31em;text-rendering:optimizespeed}.pure-button-group .pure-button{letter-spacing:normal;word-spacing:normal;vertical-align:top;text-rendering:auto;border-radius:0;border-right:1px solid rgba(0,0,0,.2);margin:0}.pure-button-hover,.pure-button:focus,.pure-button:hover{background-image:linear-gradient(transparent,rgba(0,0,0,.05) 40%,rgba(0,0,0,.1))}.pure-button:focus{outline:0}.pure-button-active,.pure-button:active{-webkit-box-shadow:0 0 0 1px rgba(0,0,0,.15) inset,0 0 6px rgba(0,0,0,.2) inset;box-shadow:0 0 0 1px rgba(0,0,0,.15) inset,0 0 6px rgba(0,0,0,.2) inset;border-color:#000}.pure-button-disabled,.pure-button-disabled:active,.pure-button-disabled:focus,.pure-button-disabled:hover,.pure-button[disabled]{border:none;background-image:none;opacity:.4;cursor:not-allowed;-webkit-box-shadow:none;box-shadow:none;pointer-events:none}.pure-button-primary,.pure-button-selected,a.pure-button-primary,a.pure-button-selected{background-color:#0078e7;color:#fff}.pure-button-group .pure-button:first-child{border-top-left-radius:2px;border-bottom-left-radius:2px}.pure-button-group .pure-button:last-child{border-top-right-radius:2px;border-bottom-right-radius:2px;border-right:none}.pure-form input[type=color],.pure-form input[type=date],.pure-form input[type=datetime-local],.pure-form input[type=datetime],.pure-form input[type=email],.pure-form input[type=month],.pure-form input[type=number],.pure-form input[type=password],.pure-form input[type=search],.pure-form input[type=tel],.pure-form input[type=text],.pure-form input[type=time],.pure-form input[type=url],.pure-form input[type=week],.pure-form select,.pure-form textarea{display:inline-block;border:1px solid #ccc;-webkit-box-shadow:inset 0 1px 3px #ddd;box-shadow:inset 0 1px 3px #ddd;border-radius:4px;vertical-align:middle;-webkit-box-sizing:border-box;box-sizing:border-box;padding:.5em .6em}.pure-form input:not([type]){display:inline-block;border:1px solid #ccc;-webkit-box-shadow:inset 0 1px 3px #ddd;box-shadow:inset 0 1px 3px #ddd;border-radius:4px;-webkit-box-sizing:border-box;box-sizing:border-box;padding:.5em .6em}.pure-form input[type=color]{padding:.2em .5em}.pure-form input[type=checkbox]:focus,.pure-form input[type=file]:focus,.pure-form input[type=radio]:focus{outline:1px auto #129fea}.pure-form .pure-checkbox,.pure-form .pure-radio{display:block;margin:.5em 0}.pure-form input[readonly],.pure-form select[readonly],.pure-form textarea[readonly]{background-color:#eee;color:#777;border-color:#ccc}.pure-form input:focus:invalid,.pure-form select:focus:invalid,.pure-form textarea:focus:invalid{color:#b94a48;border-color:#e9322d}.pure-form input[type=checkbox]:focus:invalid:focus,.pure-form input[type=file]:focus:invalid:focus,.pure-form input[type=radio]:focus:invalid:focus{outline-color:#e9322d}.pure-form select{height:2.25em;border:1px solid #ccc;background-color:#fff}.pure-form label{margin:.5em 0 .2em}.pure-form fieldset{border:0;margin:0;padding:.35em 0 .75em}.pure-form legend{display:block;width:100%;margin-bottom:.3em;color:#333;border-bottom:1px solid #e5e5e5;padding:.3em 0}.pure-form-aligned textarea{vertical-align:top}.pure-form-aligned .pure-control-group{margin-bottom:.5em}.pure-form-aligned .pure-control-group label{text-align:right;display:inline-block;vertical-align:middle;width:10em;margin:0 1em 0 0}.pure-form-aligned .pure-controls{margin:1.5em 0 0 11em}.pure-form .pure-input-rounded,.pure-form input.pure-input-rounded{border-radius:2em;padding:.5em 1em}.pure-form .pure-group fieldset{margin-bottom:10px}.pure-form .pure-group input,.pure-form .pure-group textarea{display:block;border-radius:0;position:relative;top:-1px;margin:0 0 -1px;padding:10px}.pure-form .pure-group input:focus,.pure-form .pure-group textarea:focus{z-index:3}.pure-form .pure-group input:first-child,.pure-form .pure-group textarea:first-child{top:1px;border-radius:4px 4px 0 0;margin:0}.pure-form .pure-group input:first-child:last-child,.pure-form .pure-group textarea:first-child:last-child{top:1px;border-radius:4px;margin:0}.pure-form .pure-group input:last-child,.pure-form .pure-group textarea:last-child{top:-2px;border-radius:0 0 4px 4px;margin:0}.pure-form .pure-group button{margin:.35em 0}.pure-form .pure-input-2-3{width:66%}.pure-form .pure-input-1-3{width:33%}.pure-form-message-inline{display:inline-block;padding-left:.3em;color:#666;vertical-align:middle;font-size:.875em}.pure-form-message{display:block;color:#666;font-size:.875em}.pure-menu{-webkit-box-sizing:border-box;box-sizing:border-box}.pure-menu-fixed{position:fixed;left:0;top:0;z-index:3}.pure-menu-item,.pure-menu-list{position:relative}.pure-menu-list{list-style:none;margin:0;padding:0}.pure-menu-item{height:100%;margin:0;padding:0}.pure-menu-heading,.pure-menu-link{display:block;text-decoration:none;white-space:nowrap}.pure-menu-horizontal{width:100%;white-space:nowrap}.pure-menu-children{display:none;position:absolute;left:100%;top:0;z-index:3;background-color:#fff;margin:0;padding:0}.pure-menu-horizontal .pure-menu-children{left:0;top:auto;width:inherit}.pure-menu-active>.pure-menu-children,.pure-menu-allow-hover:hover>.pure-menu-children{display:block;position:absolute}.pure-menu-has-children>.pure-menu-link:after{padding-left:.5em;content:"\25B8";font-size:small}.pure-menu-horizontal .pure-menu-has-children>.pure-menu-link:after{content:"\25BE"}.pure-menu-scrollable{overflow-y:scroll;overflow-x:hidden}.pure-menu-horizontal.pure-menu-scrollable{white-space:nowrap;overflow-y:hidden;overflow-x:auto;padding:.5em 0}.pure-menu-horizontal .pure-menu-children .pure-menu-separator,.pure-menu-separator{background-color:#ccc;height:1px;margin:.3em 0}.pure-menu-horizontal .pure-menu-separator{width:1px;height:1.3em;margin:0 .3em}.pure-menu-horizontal .pure-menu-children .pure-menu-separator{display:block;width:auto}.pure-menu-heading{text-transform:uppercase;color:#565d64}.pure-menu-link{color:#777}.pure-menu-disabled,.pure-menu-heading,.pure-menu-link{padding:.5em 1em}.pure-menu-disabled{opacity:.5}.pure-menu-active>.pure-menu-link,.pure-menu-link:focus,.pure-menu-link:hover{background-color:#eee}.pure-menu-selected>.pure-menu-link,.pure-menu-selected>.pure-menu-link:visited{color:#000}.pure-table{border-collapse:collapse;border-spacing:0;empty-cells:show;border:1px solid #cbcbcb}.pure-table caption{color:#000;font:italic 85%/1 arial,sans-serif;text-align:center;padding:1em 0}.pure-table td,.pure-table th{border-left:1px solid #cbcbcb;font-size:inherit;overflow:visible;border-width:0 0 0 1px;margin:0;padding:.5em 1em}.pure-table thead{background-color:#e0e0e0;color:#000;text-align:left;vertical-align:bottom}.pure-table-bordered td{border-bottom:1px solid #cbcbcb}.pure-table-horizontal td,.pure-table-horizontal th{border-bottom:1px solid #cbcbcb;border-width:0 0 1px}main,details,.pure-menu-item .pure-menu-item,.pure-menu-scrollable .pure-menu-list{display:block}pre,code,kbd,samp{font-family:monospace,monospace;font-size:1em}a,.pure-menu-disabled .pure-menu-link:hover,.pure-table td{background-color:transparent}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button,.pure-form select[multiple]{height:auto}template,[hidden],.pure-button-hidden{display:none}.opera-only :-o-prefocus,.pure-g,.opera-only :-o-prefocus,.pure-button-group{word-spacing:-.43em}.pure-u,.pure-u-1,.pure-u-1-1,.pure-u-1-12,.pure-u-1-2,.pure-u-1-24,.pure-u-1-3,.pure-u-1-4,.pure-u-1-5,.pure-u-1-6,.pure-u-1-8,.pure-u-10-24,.pure-u-11-12,.pure-u-11-24,.pure-u-12-24,.pure-u-13-24,.pure-u-14-24,.pure-u-15-24,.pure-u-16-24,.pure-u-17-24,.pure-u-18-24,.pure-u-19-24,.pure-u-2-24,.pure-u-2-3,.pure-u-2-5,.pure-u-20-24,.pure-u-21-24,.pure-u-22-24,.pure-u-23-24,.pure-u-24-24,.pure-u-3-24,.pure-u-3-4,.pure-u-3-5,.pure-u-3-8,.pure-u-4-24,.pure-u-4-5,.pure-u-5-12,.pure-u-5-24,.pure-u-5-5,.pure-u-5-6,.pure-u-5-8,.pure-u-6-24,.pure-u-7-12,.pure-u-7-24,.pure-u-7-8,.pure-u-8-24,.pure-u-9-24{display:inline-block;letter-spacing:normal;text-rendering:auto;vertical-align:top;word-spacing:normal}.pure-u-1-4,.pure-u-6-24,.pure-form .pure-input-1-4{width:25%}.pure-u-1-2,.pure-u-12-24,.pure-form .pure-input-1-2{width:50%}.pure-u-18-24,.pure-u-3-4,.pure-form .pure-input-3-4{width:75%}.pure-u-1,.pure-u-1-1,.pure-u-24-24,.pure-u-5-5,.pure-form .pure-input-1{width:100%}.pure-form input[type=color]:focus,.pure-form input[type=date]:focus,.pure-form input[type=datetime-local]:focus,.pure-form input[type=datetime]:focus,.pure-form input[type=email]:focus,.pure-form input[type=month]:focus,.pure-form input[type=number]:focus,.pure-form input[type=password]:focus,.pure-form input[type=search]:focus,.pure-form input[type=tel]:focus,.pure-form input[type=text]:focus,.pure-form input[type=time]:focus,.pure-form input[type=url]:focus,.pure-form input[type=week]:focus,.pure-form select:focus,.pure-form textarea:focus,.pure-form input:not([type]):focus{outline:0;border-color:#129fea}.pure-form input[type=color][disabled],.pure-form input[type=date][disabled],.pure-form input[type=datetime-local][disabled],.pure-form input[type=datetime][disabled],.pure-form input[type=email][disabled],.pure-form input[type=month][disabled],.pure-form input[type=number][disabled],.pure-form input[type=password][disabled],.pure-form input[type=search][disabled],.pure-form input[type=tel][disabled],.pure-form input[type=text][disabled],.pure-form input[type=time][disabled],.pure-form input[type=url][disabled],.pure-form input[type=week][disabled],.pure-form select[disabled],.pure-form textarea[disabled],.pure-form input:not([type])[disabled]{background-color:#eaeded;color:#cad2d3;cursor:not-allowed}.pure-form-stacked input[type=color],.pure-form-stacked input[type=date],.pure-form-stacked input[type=datetime-local],.pure-form-stacked input[type=datetime],.pure-form-stacked input[type=email],.pure-form-stacked input[type=file],.pure-form-stacked input[type=month],.pure-form-stacked input[type=number],.pure-form-stacked input[type=password],.pure-form-stacked input[type=search],.pure-form-stacked input[type=tel],.pure-form-stacked input[type=text],.pure-form-stacked input[type=time],.pure-form-stacked input[type=url],.pure-form-stacked input[type=week],.pure-form-stacked label,.pure-form-stacked select,.pure-form-stacked textarea,.pure-form-stacked input:not([type]){display:block;margin:.25em 0}.pure-form-aligned input,.pure-form-aligned select,.pure-form-aligned textarea,.pure-form-message-inline,.pure-menu-horizontal .pure-menu-heading,.pure-menu-horizontal .pure-menu-item,.pure-menu-horizontal .pure-menu-separator{display:inline-block;vertical-align:middle}.pure-menu-horizontal .pure-menu-list,.pure-menu-horizontal.pure-menu-scrollable .pure-menu-list{display:inline-block}.pure-table-odd td,.pure-table-striped tr:nth-child(2n-1) td{background-color:#f2f2f2}.pure-table-bordered tbody>tr:last-child>td,.pure-table-horizontal tbody>tr:last-child>td{border-bottom-width:0}@media all and (-ms-high-contrast:none),(-ms-high-contrast:active){table .pure-g{display:block}}@media only screen and (max-width :480px){.pure-form button[type=submit]{margin:.7em 0 0}.pure-form input:not([type]),.pure-form input[type=color],.pure-form input[type=date],.pure-form input[type=datetime-local],.pure-form input[type=datetime],.pure-form input[type=email],.pure-form input[type=month],.pure-form input[type=number],.pure-form input[type=password],.pure-form input[type=search],.pure-form input[type=tel],.pure-form input[type=text],.pure-form input[type=time],.pure-form input[type=url],.pure-form input[type=week],.pure-form label{margin-bottom:.3em;display:block}.pure-group input:not([type]),.pure-group input[type=color],.pure-group input[type=date],.pure-group input[type=datetime-local],.pure-group input[type=datetime],.pure-group input[type=email],.pure-group input[type=month],.pure-group input[type=number],.pure-group input[type=password],.pure-group input[type=search],.pure-group input[type=tel],.pure-group input[type=text],.pure-group input[type=time],.pure-group input[type=url],.pure-group input[type=week]{margin-bottom:0}.pure-form-aligned .pure-control-group label{margin-bottom:.3em;text-align:left;display:block;width:100%}.pure-form-aligned .pure-controls{margin:1.5em 0 0}.pure-form-message,.pure-form-message-inline{display:block;font-size:.75em;padding:.2em 0 .8em}} \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/www/luci-static/fonts/Roboto-Medium-webfont.woff b/rooter/ext-rooter-basic/files/www/luci-static/fonts/Roboto-Medium-webfont.woff deleted file mode 100644 index 9024fae..0000000 Binary files a/rooter/ext-rooter-basic/files/www/luci-static/fonts/Roboto-Medium-webfont.woff and /dev/null differ diff --git a/rooter/ext-rooter-basic/files/www/luci-static/fonts/Roboto-Regular-webfont.woff b/rooter/ext-rooter-basic/files/www/luci-static/fonts/Roboto-Regular-webfont.woff deleted file mode 100644 index 5413a37..0000000 Binary files a/rooter/ext-rooter-basic/files/www/luci-static/fonts/Roboto-Regular-webfont.woff and /dev/null differ diff --git a/rooter/ext-rooter-basic/files/www/luci-static/fonts/TypoGraphica.eot b/rooter/ext-rooter-basic/files/www/luci-static/fonts/TypoGraphica.eot deleted file mode 100644 index efce636..0000000 Binary files a/rooter/ext-rooter-basic/files/www/luci-static/fonts/TypoGraphica.eot and /dev/null differ diff --git a/rooter/ext-rooter-basic/files/www/luci-static/fonts/TypoGraphica.svg b/rooter/ext-rooter-basic/files/www/luci-static/fonts/TypoGraphica.svg deleted file mode 100644 index c555b75..0000000 --- a/rooter/ext-rooter-basic/files/www/luci-static/fonts/TypoGraphica.svg +++ /dev/null @@ -1,1191 +0,0 @@ - - - - -Created by FontForge 20090622 at Tue Jul 23 03:29:07 2019 - By deploy user -TypoGraphica ©Sharkshock Productions 2015. All Rights Reserved - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/rooter/ext-rooter-basic/files/www/luci-static/fonts/TypoGraphica.ttf b/rooter/ext-rooter-basic/files/www/luci-static/fonts/TypoGraphica.ttf deleted file mode 100644 index e11f89a..0000000 Binary files a/rooter/ext-rooter-basic/files/www/luci-static/fonts/TypoGraphica.ttf and /dev/null differ diff --git a/rooter/ext-rooter-basic/files/www/luci-static/fonts/TypoGraphica.woff b/rooter/ext-rooter-basic/files/www/luci-static/fonts/TypoGraphica.woff deleted file mode 100644 index fef38ca..0000000 Binary files a/rooter/ext-rooter-basic/files/www/luci-static/fonts/TypoGraphica.woff and /dev/null differ diff --git a/rooter/ext-rooter-basic/files/www/luci-static/fonts/advancedtomato.eot b/rooter/ext-rooter-basic/files/www/luci-static/fonts/advancedtomato.eot deleted file mode 100644 index f85324a..0000000 Binary files a/rooter/ext-rooter-basic/files/www/luci-static/fonts/advancedtomato.eot and /dev/null differ diff --git a/rooter/ext-rooter-basic/files/www/luci-static/fonts/advancedtomato.svg b/rooter/ext-rooter-basic/files/www/luci-static/fonts/advancedtomato.svg deleted file mode 100644 index a4ae739..0000000 --- a/rooter/ext-rooter-basic/files/www/luci-static/fonts/advancedtomato.svg +++ /dev/null @@ -1,53 +0,0 @@ - - - -Generated by Fontastic.me - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/rooter/ext-rooter-basic/files/www/luci-static/fonts/advancedtomato.ttf b/rooter/ext-rooter-basic/files/www/luci-static/fonts/advancedtomato.ttf deleted file mode 100644 index 0f59478..0000000 Binary files a/rooter/ext-rooter-basic/files/www/luci-static/fonts/advancedtomato.ttf and /dev/null differ diff --git a/rooter/ext-rooter-basic/files/www/luci-static/fonts/advancedtomato.woff b/rooter/ext-rooter-basic/files/www/luci-static/fonts/advancedtomato.woff deleted file mode 100644 index 4251248..0000000 Binary files a/rooter/ext-rooter-basic/files/www/luci-static/fonts/advancedtomato.woff and /dev/null differ diff --git a/rooter/ext-rooter-basic/files/www/luci-static/fonts/argon.eot b/rooter/ext-rooter-basic/files/www/luci-static/fonts/argon.eot deleted file mode 100644 index e28f6db..0000000 Binary files a/rooter/ext-rooter-basic/files/www/luci-static/fonts/argon.eot and /dev/null differ diff --git a/rooter/ext-rooter-basic/files/www/luci-static/fonts/argon.svg b/rooter/ext-rooter-basic/files/www/luci-static/fonts/argon.svg deleted file mode 100644 index 1e12b5f..0000000 --- a/rooter/ext-rooter-basic/files/www/luci-static/fonts/argon.svg +++ /dev/null @@ -1,38 +0,0 @@ - - - -Generated by IcoMoon - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/www/luci-static/fonts/argon.ttf b/rooter/ext-rooter-basic/files/www/luci-static/fonts/argon.ttf deleted file mode 100644 index 3d062dc..0000000 Binary files a/rooter/ext-rooter-basic/files/www/luci-static/fonts/argon.ttf and /dev/null differ diff --git a/rooter/ext-rooter-basic/files/www/luci-static/fonts/argon.woff b/rooter/ext-rooter-basic/files/www/luci-static/fonts/argon.woff deleted file mode 100644 index ef1e9c2..0000000 Binary files a/rooter/ext-rooter-basic/files/www/luci-static/fonts/argon.woff and /dev/null differ diff --git a/rooter/ext-rooter-basic/files/www/luci-static/fonts/font.eot b/rooter/ext-rooter-basic/files/www/luci-static/fonts/font.eot deleted file mode 100644 index 9e6ffc9..0000000 Binary files a/rooter/ext-rooter-basic/files/www/luci-static/fonts/font.eot and /dev/null differ diff --git a/rooter/ext-rooter-basic/files/www/luci-static/fonts/font.svg b/rooter/ext-rooter-basic/files/www/luci-static/fonts/font.svg deleted file mode 100644 index d38d057..0000000 --- a/rooter/ext-rooter-basic/files/www/luci-static/fonts/font.svg +++ /dev/null @@ -1,16 +0,0 @@ - - - -Generated by IcoMoon - - - - - - - - - - - - \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/www/luci-static/fonts/font.ttf b/rooter/ext-rooter-basic/files/www/luci-static/fonts/font.ttf deleted file mode 100644 index 8466932..0000000 Binary files a/rooter/ext-rooter-basic/files/www/luci-static/fonts/font.ttf and /dev/null differ diff --git a/rooter/ext-rooter-basic/files/www/luci-static/fonts/font.woff b/rooter/ext-rooter-basic/files/www/luci-static/fonts/font.woff deleted file mode 100644 index 00cf84e..0000000 Binary files a/rooter/ext-rooter-basic/files/www/luci-static/fonts/font.woff and /dev/null differ diff --git a/rooter/ext-rooter-basic/files/www/luci-static/fonts/fonts.css b/rooter/ext-rooter-basic/files/www/luci-static/fonts/fonts.css deleted file mode 100644 index bff3e98..0000000 --- a/rooter/ext-rooter-basic/files/www/luci-static/fonts/fonts.css +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Font generate by Icomoon - */ - -@font-face { - font-family: 'Roboto'; - src: local('Roboto Medium'), local('Roboto-Medium'), url('Roboto-Medium-webfont.woff') format('woff'); - font-weight: 500; - font-style: normal; -} - -@font-face { - font-family: 'Roboto'; - src: local('Roboto'), local('Roboto Regular'), local('Roboto-Regular'), url('Roboto-Regular-webfont.woff') format('woff'); - font-weight: normal; - font-style: normal; -} - -@font-face { - font-family: 'icomoon'; - src: url('font.eot'); - src: url('font.eot') format('embedded-opentype'), - url('font.ttf') format('truetype'), - url('font.woff') format('woff'), - url('font.svg') format('svg'); - font-weight: normal; - font-style: normal; -} -@font-face { - font-family: "advancedtomato"; - src:url("advancedtomato.eot"); - src:url("advancedtomato.eot?#iefix") format("embedded-opentype"), - url("advancedtomato.woff") format("woff"), - url("advancedtomato.ttf") format("truetype"), - url("advancedtomato.svg#advancedtomato") format("svg"); - font-weight: normal; - font-style: normal; -} diff --git a/rooter/ext-rooter-basic/files/www/luci-static/icon/android-icon-192x192.png b/rooter/ext-rooter-basic/files/www/luci-static/icon/android-icon-192x192.png deleted file mode 100644 index 7c17009..0000000 Binary files a/rooter/ext-rooter-basic/files/www/luci-static/icon/android-icon-192x192.png and /dev/null differ diff --git a/rooter/ext-rooter-basic/files/www/luci-static/icon/apple-icon-144x144.png b/rooter/ext-rooter-basic/files/www/luci-static/icon/apple-icon-144x144.png deleted file mode 100644 index 5308d66..0000000 Binary files a/rooter/ext-rooter-basic/files/www/luci-static/icon/apple-icon-144x144.png and /dev/null differ diff --git a/rooter/ext-rooter-basic/files/www/luci-static/icon/apple-icon-60x60.png b/rooter/ext-rooter-basic/files/www/luci-static/icon/apple-icon-60x60.png deleted file mode 100644 index f18dfa4..0000000 Binary files a/rooter/ext-rooter-basic/files/www/luci-static/icon/apple-icon-60x60.png and /dev/null differ diff --git a/rooter/ext-rooter-basic/files/www/luci-static/icon/apple-icon-72x72.png b/rooter/ext-rooter-basic/files/www/luci-static/icon/apple-icon-72x72.png deleted file mode 100644 index bb3e242..0000000 Binary files a/rooter/ext-rooter-basic/files/www/luci-static/icon/apple-icon-72x72.png and /dev/null differ diff --git a/rooter/ext-rooter-basic/files/www/luci-static/icon/browserconfig.xml b/rooter/ext-rooter-basic/files/www/luci-static/icon/browserconfig.xml deleted file mode 100644 index c554148..0000000 --- a/rooter/ext-rooter-basic/files/www/luci-static/icon/browserconfig.xml +++ /dev/null @@ -1,2 +0,0 @@ - -#ffffff \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/www/luci-static/icon/favicon-16x16.png b/rooter/ext-rooter-basic/files/www/luci-static/icon/favicon-16x16.png deleted file mode 100644 index 308843a..0000000 Binary files a/rooter/ext-rooter-basic/files/www/luci-static/icon/favicon-16x16.png and /dev/null differ diff --git a/rooter/ext-rooter-basic/files/www/luci-static/icon/favicon-32x32.png b/rooter/ext-rooter-basic/files/www/luci-static/icon/favicon-32x32.png deleted file mode 100644 index bfcd097..0000000 Binary files a/rooter/ext-rooter-basic/files/www/luci-static/icon/favicon-32x32.png and /dev/null differ diff --git a/rooter/ext-rooter-basic/files/www/luci-static/icon/favicon-96x96.png b/rooter/ext-rooter-basic/files/www/luci-static/icon/favicon-96x96.png deleted file mode 100644 index d0fe1ed..0000000 Binary files a/rooter/ext-rooter-basic/files/www/luci-static/icon/favicon-96x96.png and /dev/null differ diff --git a/rooter/ext-rooter-basic/files/www/luci-static/icon/manifest.json b/rooter/ext-rooter-basic/files/www/luci-static/icon/manifest.json deleted file mode 100644 index 2817bc8..0000000 --- a/rooter/ext-rooter-basic/files/www/luci-static/icon/manifest.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "name": "Openwrt", - "icons": [ - { - "src": "\/android-icon-36x36.png", - "sizes": "36x36", - "type": "image\/png", - "density": "0.75" - }, - { - "src": "\/android-icon-48x48.png", - "sizes": "48x48", - "type": "image\/png", - "density": "1.0" - }, - { - "src": "\/android-icon-72x72.png", - "sizes": "72x72", - "type": "image\/png", - "density": "1.5" - }, - { - "src": "\/android-icon-96x96.png", - "sizes": "96x96", - "type": "image\/png", - "density": "2.0" - }, - { - "src": "\/android-icon-144x144.png", - "sizes": "144x144", - "type": "image\/png", - "density": "3.0" - }, - { - "src": "\/android-icon-192x192.png", - "sizes": "192x192", - "type": "image\/png", - "density": "4.0" - } - ] -} \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/www/luci-static/icon/ms-icon-144x144.png b/rooter/ext-rooter-basic/files/www/luci-static/icon/ms-icon-144x144.png deleted file mode 100644 index 5308d66..0000000 Binary files a/rooter/ext-rooter-basic/files/www/luci-static/icon/ms-icon-144x144.png and /dev/null differ diff --git a/rooter/ext-rooter-basic/files/www/luci-static/icons/arrow.svg b/rooter/ext-rooter-basic/files/www/luci-static/icons/arrow.svg deleted file mode 100644 index be864c5..0000000 --- a/rooter/ext-rooter-basic/files/www/luci-static/icons/arrow.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/www/luci-static/icons/logout.svg b/rooter/ext-rooter-basic/files/www/luci-static/icons/logout.svg deleted file mode 100644 index d529b94..0000000 --- a/rooter/ext-rooter-basic/files/www/luci-static/icons/logout.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/www/luci-static/icons/menu.svg b/rooter/ext-rooter-basic/files/www/luci-static/icons/menu.svg deleted file mode 100644 index 46bd0ae..0000000 --- a/rooter/ext-rooter-basic/files/www/luci-static/icons/menu.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/www/luci-static/icons/spinner.svg b/rooter/ext-rooter-basic/files/www/luci-static/icons/spinner.svg deleted file mode 100644 index 6ddd3b3..0000000 --- a/rooter/ext-rooter-basic/files/www/luci-static/icons/spinner.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/www/luci-static/img/argon.svg b/rooter/ext-rooter-basic/files/www/luci-static/img/argon.svg deleted file mode 100644 index 654e2fe..0000000 --- a/rooter/ext-rooter-basic/files/www/luci-static/img/argon.svg +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/rooter/ext-rooter-basic/files/www/luci-static/img/blank.png b/rooter/ext-rooter-basic/files/www/luci-static/img/blank.png deleted file mode 100644 index 9f4100e..0000000 Binary files a/rooter/ext-rooter-basic/files/www/luci-static/img/blank.png and /dev/null differ diff --git a/rooter/ext-rooter-basic/files/www/luci-static/img/open.png b/rooter/ext-rooter-basic/files/www/luci-static/img/open.png deleted file mode 100644 index 7c92fbe..0000000 Binary files a/rooter/ext-rooter-basic/files/www/luci-static/img/open.png and /dev/null differ diff --git a/rooter/ext-rooter-basic/files/www/luci-static/img/volume_high.svg b/rooter/ext-rooter-basic/files/www/luci-static/img/volume_high.svg deleted file mode 100644 index f01ad5c..0000000 --- a/rooter/ext-rooter-basic/files/www/luci-static/img/volume_high.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/www/luci-static/img/volume_off.svg b/rooter/ext-rooter-basic/files/www/luci-static/img/volume_off.svg deleted file mode 100644 index 0598d58..0000000 --- a/rooter/ext-rooter-basic/files/www/luci-static/img/volume_off.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/rooter/ext-rooter-basic/files/www/luci-static/resources/buttons/buttons.css b/rooter/ext-rooter-basic/files/www/luci-static/resources/buttons/buttons.css deleted file mode 100644 index 9f4b624..0000000 --- a/rooter/ext-rooter-basic/files/www/luci-static/resources/buttons/buttons.css +++ /dev/null @@ -1,702 +0,0 @@ -/* Buttons CSS */ - -:root { - --green-color: rgb(44,187,99); - --red-color: rgb(218,42,42); -} - -/* -
                                                                      <%:Exit%>
                                                                      -*/ - -.button-73 { - appearance: none; - background-color: #FFFFFF; - border-radius: 40em; - border-style: none; - box-shadow: #ADCFFF 0 -12px 6px inset; - box-sizing: border-box; - color: #000000; - cursor: pointer; - display: inline-block; - font-family: -apple-system,sans-serif; - font-size: 1.2rem; - font-weight: 700; - letter-spacing: -.24px; - margin: 0; - outline: none; - padding: 1rem 1.3rem; - quotes: auto; - text-align: center; - text-decoration: none; - transition: all .15s; - user-select: none; - -webkit-user-select: none; - touch-action: manipulation; -} - -.button-73:hover { - background-color: #FFC229; - box-shadow: #FF6314 0 -6px 8px inset; - transform: scale(1.125); -} - -.button-73:active { - transform: scale(1.025); -} - -@media (min-width: 768px) { - .button-73 { - font-size: 1.5rem; - padding: .75rem 2rem; - } -} - -/* -
                                                                      <%:Exit%>
                                                                      -*/ -.button-71 { - background-color: #0078d0; - border: 0; - border-radius: 56px; - color: #fff; - cursor: pointer; - display: inline-block; - font-family: system-ui,-apple-system,system-ui,"Segoe UI",Roboto,Ubuntu,"Helvetica Neue",sans-serif; - font-size: 1.25rem; - font-weight: 600; - outline: 0; - padding: 16px 21px; - position: relative; - text-align: center; - text-decoration: none; - transition: all .3s; - user-select: none; - -webkit-user-select: none; - touch-action: manipulation; -} - -.button-71:before { - background-color: initial; - background-image: linear-gradient(#fff 0, rgba(255, 255, 255, 0) 100%); - border-radius: 125px; - content: ""; - height: 50%; - left: 4%; - opacity: .5; - position: absolute; - top: 0; - transition: all .3s; - width: 92%; -} - -.button-71:hover { - box-shadow: rgba(255, 255, 255, .2) 0 3px 15px inset, rgba(0, 0, 0, .1) 0 3px 5px, rgba(0, 0, 0, .1) 0 10px 13px; - transform: scale(1.05); -} - -@media (min-width: 768px) { - .button-71 { - padding: 16px 48px; - } -} - -/* -
                                                                      <%:Exit%>
                                                                      -*/ -.button-62 { - background: linear-gradient(to bottom right, #EF4765, #FF9A5A); - border: 0; - border-radius: 12px; - color: #FFFFFF; - cursor: pointer; - display: inline-block; - font-family: -apple-system,system-ui,"Segoe UI",Roboto,Helvetica,Arial,sans-serif; - font-size: 16px; - font-weight: 500; - line-height: 2.5; - outline: transparent; - padding: 0 1rem; - text-align: center; - text-decoration: none; - transition: box-shadow .2s ease-in-out; - user-select: none; - -webkit-user-select: none; - touch-action: manipulation; - white-space: nowrap; -} - -.button-62:not([disabled]):focus { - box-shadow: 0 0 .25rem rgba(0, 0, 0, 0.5), -.125rem -.125rem 1rem rgba(239, 71, 101, 0.5), .125rem .125rem 1rem rgba(255, 154, 90, 0.5); -} - -.button-62:not([disabled]):hover { - box-shadow: 0 0 .25rem rgba(0, 0, 0, 0.5), -.125rem -.125rem 1rem rgba(239, 71, 101, 0.5), .125rem .125rem 1rem rgba(255, 154, 90, 0.5); -} - -/* -
                                                                      - - - - Button 82 - -
                                                                      - - Red button -*/ - -.button-82-pushable { - position: relative; - border: none; - background: transparent; - padding: 0; - cursor: pointer; - outline-offset: 4px; - transition: filter 250ms; - user-select: none; - -webkit-user-select: none; - touch-action: manipulation; -} - -.button-82-shadow { - position: absolute; - top: 0; - left: 0; - width: 100%; - height: 100%; - border-radius: 12px; - background: hsl(0deg 0% 0% / 0.25); - will-change: transform; - transform: translateY(2px); - transition: - transform - 600ms - cubic-bezier(.3, .7, .4, 1); -} - -.button-82-edge { - position: absolute; - top: 0; - left: 0; - width: 100%; - height: 100%; - border-radius: 12px; - background: linear-gradient( - to left, - hsl(340deg 100% 16%) 0%, - hsl(340deg 100% 32%) 8%, - hsl(340deg 100% 32%) 92%, - hsl(340deg 100% 16%) 100% - ); -} - -.button-82-front { - display: block; - position: relative; - padding: 12px 27px; - border-radius: 12px; - font-size: 1.1rem; - color: white; - background: hsl(345deg 100% 47%); - will-change: transform; - transform: translateY(-4px); - transition: - transform - 600ms - cubic-bezier(.3, .7, .4, 1); -} - -@media (min-width: 768px) { - .button-82-front { - font-size: 1.25rem; - padding: 12px 42px; - } -} - -.button-82-pushable:hover { - filter: brightness(110%); - -webkit-filter: brightness(110%); -} - -.button-82-pushable:hover .button-82-front { - transform: translateY(-6px); - transition: - transform - 250ms - cubic-bezier(.3, .7, .4, 1.5); -} - -.button-82-pushable:active .button-82-front { - transform: translateY(-2px); - transition: transform 34ms; -} - -.button-82-pushable:hover .button-82-shadow { - transform: translateY(4px); - transition: - transform - 250ms - cubic-bezier(.3, .7, .4, 1.5); -} - -.button-82-pushable:active .button-82-shadow { - transform: translateY(1px); - transition: transform 34ms; -} - -.button-82-pushable:focus:not(:focus-visible) { - outline: none; -} - -/* -
                                                                      <%:Exit%>
                                                                      - Green button -*/ - -.button-33 { - background-color: #c2fbd7; - border-radius: 100px; - box-shadow: rgba(44,187,99, .2) 0 -25px 18px -14px inset,rgba(44,187,99, .15) 0 1px 2px,rgba(44,187,99, .15) 0 2px 4px,rgba(44,187,99, .15) 0 4px 8px,rgba(44,187,99, .15) 0 8px 16px,rgba(44,187,99, .15) 0 16px 32px; - color: green; - cursor: pointer; - display: inline-block; - font-family: CerebriSans-Regular,-apple-system,system-ui,Roboto,sans-serif; - padding: 7px 20px; - text-align: center; - text-decoration: none; - transition: all 250ms; - border: 0; - font-size: 20px; - user-select: none; - -webkit-user-select: none; - touch-action: manipulation; -} - -.button-33:hover { - box-shadow: rgba(44,187,99,.35) 0 -25px 18px -14px inset,rgba(44,187,99,.25) 0 1px 2px,rgba(44,187,99,.25) 0 2px 4px,rgba(44,187,99,.25) 0 4px 8px,rgba(44,187,99,.25) 0 8px 16px,rgba(44,187,99,.25) 0 16px 32px; - transform: scale(1.05) rotate(-1deg); -} - -/* Red button */ - -.button-34 { - background-color: var(--red-color); - border-radius: 100px; - box-shadow: rgba(218,42,42, .2) 0 -25px 18px -14px inset,rgba(218,42,42, .15) 0 1px 2px,rgba(218,42,42, .15) 0 2px 4px,rgba(218,42,42, .15) 0 4px 8px,rgba(218,42,42, .15) 0 8px 16px,rgba(218,42,42, .15) 0 16px 32px; - color: green; - cursor: pointer; - display: inline-block; - font-family: CerebriSans-Regular,-apple-system,system-ui,Roboto,sans-serif; - padding: 7px 20px; - text-align: center; - text-decoration: none; - transition: all 250ms; - border: 0; - font-size: 20px; - user-select: none; - -webkit-user-select: none; - touch-action: manipulation; -} - -.button-34:hover { - box-shadow: rgba(218,42,42,.35) 0 -25px 18px -14px inset,rgba(218,42,42,.25) 0 1px 2px,rgba(218,42,42,.25) 0 2px 4px,rgba(218,42,42,.25) 0 4px 8px,rgba(218,42,42,.25) 0 8px 16px,rgba(218,42,42,.25) 0 16px 32px; - transform: scale(1.05) rotate(-1deg); -} - - -.button-40 { - background-color: #0078d0; - border: 1px solid transparent; - border-radius: .75rem; - box-sizing: border-box; - color: #ffffff; - cursor: pointer; - flex: 0 0 auto; - font-family: "Inter var",ui-sans-serif,system-ui,-apple-system,system-ui,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji"; - font-size: 1.80rem; - font-weight: 600; - line-height: 1.5rem; - padding: .75rem 1.2rem; - text-align: center; - text-decoration: none #6B7280 solid; - text-decoration-thickness: auto; - transition-duration: .2s; - transition-property: background-color,border-color,color,fill,stroke; - transition-timing-function: cubic-bezier(.4, 0, 0.2, 1); - user-select: none; - -webkit-user-select: none; - touch-action: manipulation; - width: auto; -} - -.button-40:hover { - -} - -.button-40:focus { - box-shadow: none; - outline: 2px solid transparent; - outline-offset: 2px; -} - -@media (min-width: 768px) { - .button-40 { - padding: .75rem 1.5rem; - } -} - -/* -
                                                                      - -
                                                                      -*/ - -*, -*:before, -*:after { - box-sizing: border-box; -} - -.toggle { - cursor: pointer; - display: inline-block; -} - -.toggle-switch { - display: inline-block; - background: #ccc; - border-radius: 16px; - width: 58px; - height: 32px; - position: relative; - vertical-align: middle; - transition: background 0.25s; -} -.toggle-switch:before, .toggle-switch:after { - content: ""; -} -.toggle-switch:before { - display: block; - background: linear-gradient(to bottom, #fff 0%, #eee 100%); - border-radius: 50%; - box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25); - width: 24px; - height: 24px; - position: absolute; - top: 4px; - left: 4px; - transition: left 0.25s; -} -.toggle:hover .toggle-switch:before { - background: linear-gradient(to bottom, #fff 0%, #fff 100%); - box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5); -} -.toggle-checkbox:checked + .toggle-switch { - background: #56c080; -} -.toggle-checkbox:checked + .toggle-switch:before { - left: 30px; -} - -.toggle-checkbox { - position: absolute; - visibility: hidden; -} - -.toggle-label { - margin-left: 5px; - position: relative; - top: 2px; -} - -/* - -*/ -/* The switch - the box around the slider */ -.switch { - position: relative; - display: inline-block; - width: 60px; - height: 34px; -} - -/* Hide default HTML checkbox */ -.switch input { - opacity: 0; - width: 0; - height: 0; -} - -/* The slider */ -.slider { - position: absolute; - cursor: pointer; - top: 0; - left: 0; - right: 0; - bottom: 0; - background-color: #ccc; - -webkit-transition: .4s; - transition: .4s; -} - -.slider:before { - position: absolute; - content: ""; - height: 26px; - width: 26px; - left: 4px; - bottom: 4px; - background-color: white; - -webkit-transition: .4s; - transition: .4s; -} - -input:checked + .slider { - background-color: #2196F3; -} - -input:focus + .slider { - box-shadow: 0 0 1px #2196F3; -} - -input:checked + .slider:before { - -webkit-transform: translateX(26px); - -ms-transform: translateX(26px); - transform: translateX(26px); -} - -/* Rounded sliders */ -.slider.round { - border-radius: 34px; -} - -.slider.round:before { - border-radius: 50%; -} - -/* -
                                                                      -

                                                                      - -

                                                                      -

                                                                      - -

                                                                      -

                                                                      - -

                                                                      -

                                                                      - -

                                                                      -
                                                                      -*/ - - -/* Toggle Switch */ - -.toggleSwitch span span { - display: none; -} - -@media only screen { - .toggleSwitch { - display: inline-block; - height: 18px; - position: relative; - overflow: visible; - padding: 0; - margin-left: 50px; - cursor: pointer; - width: 40px; - user-select: none; - } - .toggleSwitch * { - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; - } - .toggleSwitch label, - .toggleSwitch > span { - line-height: 20px; - height: 20px; - vertical-align: middle; - } - .toggleSwitch input:focus ~ a, - .toggleSwitch input:focus + label { - outline: none; - } - .toggleSwitch label { - position: relative; - z-index: 3; - display: block; - width: 100%; - } - .toggleSwitch input { - position: absolute; - opacity: 0; - z-index: 5; - } - .toggleSwitch > span { - position: absolute; - left: -50px; - width: 100%; - margin: 0; - padding-right: 50px; - text-align: left; - white-space: nowrap; - } - .toggleSwitch > span span { - position: absolute; - top: 0; - left: 0; - z-index: 5; - display: block; - width: 50%; - margin-left: 50px; - text-align: left; - font-size: 0.9em; - width: 100%; - left: 15%; - top: -1px; - opacity: 0; - } - .toggleSwitch a { - position: absolute; - right: 50%; - z-index: 4; - display: block; - height: 100%; - padding: 0; - left: 2px; - width: 18px; - background-color: #fff; - border: 1px solid #CCC; - border-radius: 100%; - -webkit-transition: all 0.2s ease-out; - -moz-transition: all 0.2s ease-out; - transition: all 0.2s ease-out; - box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); - } - .toggleSwitch > span span:first-of-type { - color: #ccc; - opacity: 1; - left: 45%; - } - .toggleSwitch > span:before { - content: ''; - display: block; - width: 100%; - height: 100%; - position: absolute; - left: 50px; - top: -2px; - background-color: #fafafa; - border: 1px solid #ccc; - border-radius: 30px; - -webkit-transition: all 0.2s ease-out; - -moz-transition: all 0.2s ease-out; - transition: all 0.2s ease-out; - } - .toggleSwitch input:checked ~ a { - border-color: #fff; - left: 100%; - margin-left: -8px; - } - .toggleSwitch input:checked ~ span:before { - border-color: #0097D1; - box-shadow: inset 0 0 0 30px #0097D1; - } - .toggleSwitch input:checked ~ span span:first-of-type { - opacity: 0; - } - .toggleSwitch input:checked ~ span span:last-of-type { - opacity: 1; - color: #fff; - } - /* Switch Sizes */ - .toggleSwitch.large { - width: 60px; - height: 27px; - } - .toggleSwitch.large a { - width: 27px; - } - .toggleSwitch.large > span { - height: 29px; - line-height: 28px; - } - .toggleSwitch.large input:checked ~ a { - left: 41px; - } - .toggleSwitch.large > span span { - font-size: 1.1em; - } - .toggleSwitch.large > span span:first-of-type { - left: 50%; - } - .toggleSwitch.xlarge { - width: 80px; - height: 36px; - } - .toggleSwitch.xlarge a { - width: 36px; - } - .toggleSwitch.xlarge > span { - height: 38px; - line-height: 37px; - } - .toggleSwitch.xlarge input:checked ~ a { - left: 52px; - } - .toggleSwitch.xlarge > span span { - font-size: 1.4em; - } - .toggleSwitch.xlarge > span span:first-of-type { - left: 50%; - } -} - - -/* End Toggle Switch */ diff --git a/rooter/ext-rooter-basic/files/www/luci-static/resources/icons/lock1.png b/rooter/ext-rooter-basic/files/www/luci-static/resources/icons/lock1.png deleted file mode 100644 index 0e650f3..0000000 Binary files a/rooter/ext-rooter-basic/files/www/luci-static/resources/icons/lock1.png and /dev/null differ diff --git a/rooter/ext-rooter-basic/files/www/luci-static/resources/icons/unlock1.png b/rooter/ext-rooter-basic/files/www/luci-static/resources/icons/unlock1.png deleted file mode 100644 index 0839da5..0000000 Binary files a/rooter/ext-rooter-basic/files/www/luci-static/resources/icons/unlock1.png and /dev/null differ diff --git a/rooter/ext-rooter-basic/files/www/luci-static/resources/img/header.png b/rooter/ext-rooter-basic/files/www/luci-static/resources/img/header.png deleted file mode 100644 index aec18a2..0000000 Binary files a/rooter/ext-rooter-basic/files/www/luci-static/resources/img/header.png and /dev/null differ diff --git a/rooter/ext-rooter-basic/files/www/luci-static/resources/img/rooter.png b/rooter/ext-rooter-basic/files/www/luci-static/resources/img/rooter.png deleted file mode 100644 index 630f30d..0000000 Binary files a/rooter/ext-rooter-basic/files/www/luci-static/resources/img/rooter.png and /dev/null differ diff --git a/rooter/ext-rooter-basic/files/www/luci-static/resources/img/rosy.png b/rooter/ext-rooter-basic/files/www/luci-static/resources/img/rosy.png deleted file mode 100644 index 44c71ce..0000000 Binary files a/rooter/ext-rooter-basic/files/www/luci-static/resources/img/rosy.png and /dev/null differ diff --git a/sendat/Makefile b/sendat/Makefile deleted file mode 100644 index 6b25f0d..0000000 --- a/sendat/Makefile +++ /dev/null @@ -1,33 +0,0 @@ -include $(TOPDIR)/rules.mk#将openwrt顶层目录下的rules.mk文件中的内容导入进来 - -PKG_NAME:=sendat#软件包名 -PKG_VERSION:=6.8.2#软件包版本 -PKG_BUILD_DIR:= $(BUILD_DIR)/$(PKG_NAME)#真正编译当前软件包的目录 - - -include $(INCLUDE_DIR)/package.mk#将$(TOPDIR)/include目录下的package.mk文件中的内容导入进来 - -define Package/sendat - SECTION:=wrtnode#软件包类型 - CATEGORY:=Daocaoren#menuconfig中软件包所属的一级目录 - SUBMENU :=CPE#menuconfig中软件包所属的二级目录 - TITLE:=Sendat AT#软件包标题 - DEPENDS:=+libpthread#运行本软件依赖的其他包 -endef - -define Package/sendat/description #软件包描述 - A sample for sendat test -endef - -define Build/Prepare #编译之前的准备动作 - mkdir -p $(PKG_BUILD_DIR) - $(CP) ./src/* $(PKG_BUILD_DIR)/ -endef - - -define Package/sendat/install #软件包的安装方法,主要就是将一系列编译好的文件、启动脚本、UCI配置文件等拷贝到指定位置 - $(INSTALL_DIR) $(1)/bin - $(INSTALL_BIN) $(PKG_BUILD_DIR)/sendat $(1)/bin/ -endef - -$(eval $(call BuildPackage,sendat)) \ No newline at end of file diff --git a/sendat/README.md b/sendat/README.md deleted file mode 100644 index 00fe05c..0000000 --- a/sendat/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# sendat -AT 命令工具 -1简化使用AT命令请求方式 -使用命令说明 -sendat 2 'ATI' 2表示 /dev/ttyUSB2 'ATI' 为at命令 diff --git a/sendat/src/Makefile b/sendat/src/Makefile deleted file mode 100644 index 301b189..0000000 --- a/sendat/src/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -all:sendat - -OBJS = sendat.o - -sendat:$(OBJS) - $(CC) $(CFLAGS) -o $@ $(OBJS) -lpthread - -clean: - rm -f sendat *.o \ No newline at end of file diff --git a/sendat/src/pdu.c b/sendat/src/pdu.c deleted file mode 100644 index df7d9d4..0000000 --- a/sendat/src/pdu.c +++ /dev/null @@ -1,420 +0,0 @@ -/* - * 2017 - 2021 Cezary Jackiewicz - * 2014 lovewilliam - */ -// Copyright 2011 The Avalon Project Authors. All rights reserved. -// Use of this source code is governed by the Apache License 2.0 -// that can be found in the LICENSE file. -// -// SMS encoding/decoding functions, which are based on examples from: -// http://www.dreamfabric.com/sms/ - -#include "pdu.h" - -#include -#include - -enum { - BITMASK_7BITS = 0x7F, - BITMASK_8BITS = 0xFF, - BITMASK_HIGH_4BITS = 0xF0, - BITMASK_LOW_4BITS = 0x0F, - - TYPE_OF_ADDRESS_UNKNOWN = 0x81, - TYPE_OF_ADDRESS_INTERNATIONAL_PHONE = 0x91, - TYPE_OF_ADDRESS_NATIONAL_SUBSCRIBER = 0xC8, - TYPE_OF_ADDRESS_ALPHANUMERIC = 0xD0, - - SMS_DELIVER_ONE_MESSAGE = 0x04, - SMS_SUBMIT = 0x11, - - SMS_MAX_7BIT_TEXT_LENGTH = 160, -}; - -// Swap decimal digits of a number (e.g. 12 -> 21). -static unsigned char -SwapDecimalNibble(const unsigned char x) -{ - return (x / 16) + ((x % 16) * 10); -} - -// Encode/Decode PDU: Translate ASCII 7bit characters to 8bit buffer. -// SMS encoding example from: http://www.dreamfabric.com/sms/. -// -// 7-bit ASCII: "hellohello" -// [0]:h [1]:e [2]:l [3]:l [4]:o [5]:h [6]:e [7]:l [8]:l [9]:o -// 1101000 1100101 1101100 1101100 1101111 1101000 1100101 1101100 1101100 1101111 -// | ||| ||||| | ||||||| |||||| -// /-------------/ ///-------/// /////-///// \------------\ ||||||| \\\\\\ . -// | ||| ||||| | ||||||| |||||| -// input buffer position -// 10000000 22111111 33322222 44443333 55555333 66666655 77777776 98888888 --999999 -// | ||| ||||| | ||||||| |||||| -// 8bit encoded buffer -// 11101000 00110010 10011011 11111101 01000110 10010111 11011001 11101100 00110111 -// E8 32 9B FD 46 97 D9 EC 37 - - -// Encode PDU message by merging 7 bit ASCII characters into 8 bit octets. -int -EncodePDUMessage(const char* sms_text, int sms_text_length, unsigned char* output_buffer, int buffer_size) -{ - // Check if output buffer is big enough. - if ((sms_text_length * 7 + 7) / 8 > buffer_size) - return -1; - - int output_buffer_length = 0; - int carry_on_bits = 1; - int i = 0; - - for (; i < sms_text_length - 1; ++i) { - output_buffer[output_buffer_length++] = - ((sms_text[i] & BITMASK_7BITS) >> (carry_on_bits - 1)) | - ((sms_text[i + 1] & BITMASK_7BITS) << (8 - carry_on_bits)); - carry_on_bits++; - if (carry_on_bits == 8) { - carry_on_bits = 1; - ++i; - } - } - - if (i <= sms_text_length) - output_buffer[output_buffer_length++] = (sms_text[i] & BITMASK_7BITS) >> (carry_on_bits - 1); - - return output_buffer_length; -} - -// Decode PDU message by splitting 8 bit encoded buffer into 7 bit ASCII -// characters. -int -DecodePDUMessage_GSM_7bit(const unsigned char* buffer, int buffer_length, char* output_sms_text, int sms_text_length) -{ - int output_text_length = 0; - if (buffer_length > 0) - output_sms_text[output_text_length++] = BITMASK_7BITS & buffer[0]; - - if (sms_text_length > 1) { - int carry_on_bits = 1; - int i = 1; - for (; i < buffer_length; ++i) { - - output_sms_text[output_text_length++] = BITMASK_7BITS & ((buffer[i] << carry_on_bits) | (buffer[i - 1] >> (8 - carry_on_bits))); - - if (output_text_length == sms_text_length) break; - - carry_on_bits++; - - if (carry_on_bits == 8) { - carry_on_bits = 1; - output_sms_text[output_text_length++] = buffer[i] & BITMASK_7BITS; - if (output_text_length == sms_text_length) break; - } - - } - if (output_text_length < sms_text_length) // Add last remainder. - output_sms_text[output_text_length++] = buffer[i - 1] >> (8 - carry_on_bits); - } - - return output_text_length; -} - -#define GSM_7BITS_ESCAPE 0x1b - -static const unsigned char gsm7bits_to_latin1[128] = { - '@', 0xa3, '$', 0xa5, 0xe8, 0xe9, 0xf9, 0xec, 0xf2, 0xc7, '\n', 0xd8, 0xf8, '\r', 0xc5, 0xe5, - 0, '_', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xc6, 0xe6, 0xdf, 0xc9, - ' ', '!', '"', '#', 0xa4, '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/', - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', - 0xa1, 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', - 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 0xc4, 0xd6, 0xd1, 0xdc, 0xa7, - 0xbf, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', - 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 0xe4, 0xf6, 0xf1, 0xfc, 0xe0, -}; - -static const unsigned char gsm7bits_extend_to_latin1[128] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,'\f', 0, 0, 0, 0, 0, - 0, 0, 0, 0, '^', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, '{', '}', 0, 0, 0, 0, 0,'\\', - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '[', '~', ']', 0, - '|', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -}; - -static int -G7bitToAscii(char* buffer, int buffer_length) -{ - int i; - - for (i = 0; i buffer_size) - return -1; - - int i = 0; - for (; i < phone_number_length; ++i) { - - if (phone_number[i] < '0' && phone_number[i] > '9') - return -1; - - if (i % 2 == 0) { - output_buffer[output_buffer_length++] = BITMASK_HIGH_4BITS | (phone_number[i] - '0'); - } else { - output_buffer[output_buffer_length - 1] = - (output_buffer[output_buffer_length - 1] & BITMASK_LOW_4BITS) | - ((phone_number[i] - '0') << 4); - } - } - - return output_buffer_length; -} - -// Decode a digit based phone number for SMS based format. -static int -DecodePhoneNumber(const unsigned char* buffer, int phone_number_length, char* output_phone_number) -{ - int i = 0; - for (; i < phone_number_length; ++i) { - if (i % 2 == 0) - output_phone_number[i] = (buffer[i / 2] & BITMASK_LOW_4BITS) + '0'; - else - output_phone_number[i] = ((buffer[i / 2] & BITMASK_HIGH_4BITS) >> 4) + '0'; - } - output_phone_number[phone_number_length] = '\0'; // Terminate C string. - return phone_number_length; -} - -// Encode a SMS message to PDU -int -pdu_encode(const char* service_center_number, const char* phone_number, const char* sms_text, - unsigned char* output_buffer, int buffer_size) -{ - if (buffer_size < 2) - return -1; - - int output_buffer_length = 0; - - // 1. Set SMS center number. - int length = 0; - if (service_center_number && strlen(service_center_number) > 0) { - output_buffer[1] = TYPE_OF_ADDRESS_INTERNATIONAL_PHONE; - length = EncodePhoneNumber(service_center_number, - output_buffer + 2, buffer_size - 2); - if (length < 0 && length >= 254) - return -1; - length++; // Add type of address. - } - output_buffer[0] = length; - output_buffer_length = length + 1; - if (output_buffer_length + 4 > buffer_size) - return -1; // Check if it has space for four more bytes. - - // 2. Set type of message. - output_buffer[output_buffer_length++] = SMS_SUBMIT; - output_buffer[output_buffer_length++] = 0x00; // Message reference. - - // 3. Set phone number. - output_buffer[output_buffer_length] = strlen(phone_number); - - if (strlen(phone_number) < 6) { - output_buffer[output_buffer_length + 1] = TYPE_OF_ADDRESS_UNKNOWN; - } else { - output_buffer[output_buffer_length + 1] = TYPE_OF_ADDRESS_INTERNATIONAL_PHONE; - } - - length = EncodePhoneNumber(phone_number, - output_buffer + output_buffer_length + 2, - buffer_size - output_buffer_length - 2); - output_buffer_length += length + 2; - if (output_buffer_length + 4 > buffer_size) - return -1; // Check if it has space for four more bytes. - - - // 4. Protocol identifiers. - output_buffer[output_buffer_length++] = 0x00; // TP-PID: Protocol identifier. - output_buffer[output_buffer_length++] = 0x00; // TP-DCS: Data coding scheme. - output_buffer[output_buffer_length++] = 0xB0; // TP-VP: Validity: 10 days - - // 5. SMS message. - int sms_text_length = strlen(sms_text); - char sms_text_7bit[2*SMS_MAX_7BIT_TEXT_LENGTH]; - sms_text_length = AsciiToG7bit(sms_text, sms_text_length, sms_text_7bit); - if (sms_text_length > SMS_MAX_7BIT_TEXT_LENGTH) - return -1; - output_buffer[output_buffer_length++] = sms_text_length; - length = EncodePDUMessage(sms_text_7bit, sms_text_length, - output_buffer + output_buffer_length, - buffer_size - output_buffer_length); - if (length < 0) - return -1; - output_buffer_length += length; - - return output_buffer_length; -} - -int pdu_decode(const unsigned char* buffer, int buffer_length, - time_t* output_sms_time, - char* output_sender_phone_number, int sender_phone_number_size, - char* output_sms_text, int sms_text_size, - int* tp_dcs, - int* ref_number, - int* total_parts, - int* part_number, - int* skip_bytes) -{ - - if (buffer_length <= 0) - return -1; - - const int sms_deliver_start = 1 + buffer[0]; - if (sms_deliver_start + 1 > buffer_length) - return -2; - - const int user_data_header_length = (buffer[sms_deliver_start]>>4); - - const int sender_number_length = buffer[sms_deliver_start + 1]; - if (sender_number_length + 1 > sender_phone_number_size) - return -3; // Buffer too small to hold decoded phone number. - - const int sender_type_of_address = buffer[sms_deliver_start + 2]; - if (sender_type_of_address == TYPE_OF_ADDRESS_ALPHANUMERIC) { - DecodePDUMessage_GSM_7bit(buffer + sms_deliver_start + 3, (sender_number_length + 1) / 2, output_sender_phone_number, sender_number_length); - } else { - DecodePhoneNumber(buffer + sms_deliver_start + 3, sender_number_length, output_sender_phone_number); - } - - const int sms_pid_start = sms_deliver_start + 3 + (buffer[sms_deliver_start + 1] + 1) / 2; - - // Decode timestamp. - struct tm sms_broken_time; - sms_broken_time.tm_year = 100 + SwapDecimalNibble(buffer[sms_pid_start + 2]); - sms_broken_time.tm_mon = SwapDecimalNibble(buffer[sms_pid_start + 3]) - 1; - sms_broken_time.tm_mday = SwapDecimalNibble(buffer[sms_pid_start + 4]); - sms_broken_time.tm_hour = SwapDecimalNibble(buffer[sms_pid_start + 5]); - sms_broken_time.tm_min = SwapDecimalNibble(buffer[sms_pid_start + 6]); - sms_broken_time.tm_sec = SwapDecimalNibble(buffer[sms_pid_start + 7]); - (*output_sms_time) = timegm(&sms_broken_time); - - const int sms_start = sms_pid_start + 2 + 7; - if (sms_start + 1 > buffer_length) return -1; // Invalid input buffer. - - int tmp; - if((user_data_header_length&0x04)==0x04) { - tmp = buffer[sms_start + 1] + 1; - *skip_bytes = tmp; - *ref_number = 0x000000FF&buffer[sms_start + tmp - 2]; - *total_parts = 0x000000FF&buffer[sms_start + tmp - 1]; - *part_number = 0x000000FF&buffer[sms_start + tmp]; - } else { - tmp = 0; - *skip_bytes = tmp; - *ref_number = tmp; - *total_parts = tmp; - *part_number = tmp; - } - - int output_sms_text_length = buffer[sms_start]; - if (sms_text_size < output_sms_text_length) return -1; // Cannot hold decoded buffer. - - const int sms_tp_dcs_start = sms_pid_start + 1; - *tp_dcs = buffer[sms_tp_dcs_start]; - - switch((*tp_dcs / 4) % 4) - { - case 0: - { - // GSM 7 bit - int decoded_sms_text_size = DecodePDUMessage_GSM_7bit(buffer + sms_start + 1, buffer_length - (sms_start + 1), - output_sms_text, output_sms_text_length); - if (decoded_sms_text_size != output_sms_text_length) return -1; // Decoder length is not as expected. - output_sms_text_length = G7bitToAscii(output_sms_text, output_sms_text_length); - break; - } - case 2: - { - // UCS2 - memcpy(output_sms_text, buffer + sms_start + 1, output_sms_text_length); - break; - } - default: - break; - } - - // Add a C string end. - if (output_sms_text_length < sms_text_size) - output_sms_text[output_sms_text_length] = 0; - else - output_sms_text[sms_text_size-1] = 0; - - return output_sms_text_length; -} - diff --git a/sendat/src/pdu.h b/sendat/src/pdu.h deleted file mode 100644 index 734a393..0000000 --- a/sendat/src/pdu.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 2017 - 2021 Cezary Jackiewicz - * 2014 lovewilliam - */ -// Copyright 2011 The Avalon Project Authors. All rights reserved. -// Use of this source code is governed by the Apache License 2.0 -// that can be found in the LICENSE file. -#ifndef SMS_PDU_H_ -#define SMS_PDU_H_ - -#include - -enum { SMS_MAX_PDU_LENGTH = 256 }; - -/* - * Encode an SMS message. Output the encoded message into output pdu buffer. - * Returns the length of the SMS encoded message in the output buffer or - * a negative number in case encoding failed (for example provided output buffer - * does not have enough space). - */ -int pdu_encode(const char* service_center_number, const char* phone_number, const char* text, - unsigned char* pdu, int pdu_size); - -/* - * Decode an SMS message. Output the decoded message into the sms text buffer. - * Returns the length of the SMS dencoded message or a negative number in - * case encoding failed (for example provided output buffer has not enough - * space). - */ -int pdu_decode(const unsigned char* pdu, int pdu_len, - time_t* sms_time, - char* phone_number, int phone_number_size, - char* text, int text_size, - int* tp_dcs, - int* ref_number, - int* total_parts, - int* part_number, - int* skip_bytes); - -int ucs2_to_utf8 (int ucs2, unsigned char * utf8); - -int DecodePDUMessage_GSM_7bit(const unsigned char* buffer, - int buffer_length, - char* output_sms_text, - int sms_text_length); - -int EncodePDUMessage(const char* sms_text, - int sms_text_length, - unsigned char* output_buffer, - int buffer_size); - -#endif // SMS_SMS_H_ diff --git a/sendat/src/pdu_decoder.c b/sendat/src/pdu_decoder.c deleted file mode 100644 index 9e9e055..0000000 --- a/sendat/src/pdu_decoder.c +++ /dev/null @@ -1,107 +0,0 @@ -/* - * 2014 lovewilliam - * SMS PDU Decoder - */ -#include "pdu.h" - -#include -#include -#include -#include -#include - -int ucs2_to_utf8 (int ucs2, unsigned char * utf8); - -int sms_decode() -{ - char buffer[2*SMS_MAX_PDU_LENGTH+4]; - char *p = buffer; - char t[2]; - int d; - do - { - t[0] = getchar(); - if(t[0]=='\n') - { - break; - } - t[1] = getchar(); - if(t[1]=='\n') - { - break; - } - *p = strtol(t,NULL,16); - p++; - }while(1); - - time_t sms_time; - char sms_phone[40]; - char sms_text[161]; - int tp_dcs_type; - int ref_number; - int total_parts; - int part_number; - int skip_bytes; - - int sms_text_length = pdu_decode((const unsigned char*)buffer, - sizeof(buffer), - &sms_time, - sms_phone, sizeof(sms_phone), - sms_text, sizeof(sms_text), - &tp_dcs_type, - &ref_number, - &total_parts, - &part_number, - &skip_bytes); - - printf("From:%s\n",sms_phone); - printf("Textlen=%d\n",sms_text_length); - char time_data_str[64]; - strftime(time_data_str,64,"%D %T", localtime(&sms_time)); - printf("Date/Time:%s\n",time_data_str); - - if (total_parts > 0) { - printf("Reference number: %d\n", ref_number); - printf("SMS segment %d of %d\n", part_number, total_parts); - } - - switch((tp_dcs_type / 4) % 4) - { - case 0: - { - // GSM7 bit - int i = skip_bytes; - if(skip_bytes > 0) i = (skip_bytes*8+6)/7; - for(;i -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -// #include "pdu.h" - - -#define MAX_PORTS 4 -/*this array hold information about each port we have opened */ -struct PortInfo { - char name[16]; - int port_fd; -}; -int serial_init(int port, int spd, int databits, int parity, \ - int stopbits, int RTSCTS, int need_line_input); -int serial_write(int fd, void *src, int len); -int serial_read(int fd, char *buf, int len); -int serial_recv(int fd,char *rbuf,int rbuf_len, int timeout); -//串口常用初始化接口 -#define serial_com_init(port, spd, databits, parity, stopbits)\ - serial_init(port, spd, databits, parity, stopbits, 0, 0) -//串口默认初始化接口 -#define serial_def_init(port, spd) serial_init(port, spd, 8, 'n', 1, 0, 1) -#endif - - - -/* -** File: uart.c -** -** Description: -** Provides an RS-232 interface that is very similar to the CVI provided -** interface library -*/ -/*this array hold information about each port we have opened */ -struct PortInfo ports[13] = -{ - {"/dev/ttyUSB0", 0}, - {"/dev/ttyUSB1", 0}, - {"/dev/ttyUSB2", 0}, - {"/dev/ttyUSB3", 0}, - {"/dev/ttyUSB4", 0}, - {"/dev/ttyUSB5", 0}, - {"/dev/ttyUSB6", 0}, - {"/dev/ttyUSB7", 0}, - {"/dev/ttyUSB8", 0}, - {"/dev/ttyUSB9", 0}, - {"/dev/ttyUSB10", 0}, - {"/dev/ttyUSB11", 0}, - {"/dev/ttyUSB12", 0}, -}; -FILE* pf; -FILE* pfi; -int spd_arr[] = {B2000000, B1500000, B576000, B500000, B460800, B230400, B115200, B57600, B38400, B19200, B9600, B4800, B2400}; -int name_arr[] = { 2000000, 1500000, 576000, 500000, 460800, 230400, 115200, 57600, 38400, 19200, 9600, 4800, 2400 }; -/** -*@brief 设置串口通信速率 -*@param fd 类型 int 打开串口的文件句柄 -*@param speed 类型 int 串口速度 -*@return void -*/ -int set_speed(int fd, int speed) -{ - int i; - int status; - struct termios Opt; - tcgetattr(fd, &Opt); - for ( i= 0; i < sizeof(spd_arr) / sizeof(int); i++) { - if(speed == name_arr[i]) { - tcflush(fd, TCIOFLUSH); - cfsetispeed(&Opt, spd_arr[i]); - cfsetospeed(&Opt, spd_arr[i]); - status = tcsetattr(fd, TCSANOW, &Opt); - if (status != 0) { - printf("tcsetattr failed"); - return 1; - } - tcflush(fd,TCIOFLUSH); - } - } - // printf("set_speed\n"); - return 0; -} - -/** -*@brief 设置串口数据位,停止位和效验位 -*@param fd 类型 int 打开的串口文件句柄 -*@param databits 类型 int 数据位 取值为 7 或者8 -*@param stopbits 类型 int 停止位 取值为 1 或者2 -*@param parity 类型 int 效验类型 取值为N,E,O,,S -*/ -int set_Parity(int fd, int databits, int parity, int stopbits, int RTSCTS) -{ - struct termios options; - if ( tcgetattr( fd,&options) != 0) { - perror("SetupSerial 1"); - return -1; - } - options.c_cflag &= ~CSIZE; - switch (databits) /*设置数据位数*/ - { - case 7: - options.c_cflag |= CS7; - break; - case 8: - options.c_cflag |= CS8; - break; - default: - fprintf(stderr,"Unsupported data size\n"); - return -1; - } - - options.c_iflag |= INPCK; - cfmakeraw(&options); - //options.c_lflag |= (ICANON | ECHO | ECHOE); - //options.c_lflag &= ~(ICANON | ECHO | ECHOE); - //options.c_iflag &= ~(IXON | IXOFF); - switch (parity) - { - case 'n': - case 'N': - options.c_cflag &= ~PARENB; /* Clear parity enable */ - options.c_iflag &= ~INPCK; /* Enable parity checking */ - break; - case 'o': - case 'O': - options.c_cflag |= (PARODD | PARENB); /* 设置为奇效验*/ - break; - case 'e': - case 'E': - options.c_cflag |= PARENB; /* Enable parity */ - options.c_cflag &= ~PARODD; /* 转换为偶效验*/ - break; - case 'S': - case 's': /*as no parity*/ - options.c_cflag &= ~PARENB; - options.c_cflag &= ~CSTOPB; - break; - default: - fprintf(stderr,"Unsupported parity\n"); - return -1; - } - - /* 设置停止位*/ - switch (stopbits) - { - case 1: - options.c_cflag &= ~CSTOPB; - break; - case 2: - options.c_cflag |= CSTOPB; - break; - default: - fprintf(stderr,"Unsupported stop bits\n"); - return -1; - } - - /* Set rts/cts */ - if (RTSCTS) - { - printf("Set rts/cts"); - options.c_cflag |= CRTSCTS; - } - - tcflush(fd,TCIFLUSH); - options.c_cc[VTIME] = 150; /* 设置超时15 seconds*/ - options.c_cc[VMIN] = 0; /* Update the options and do it NOW */ - if (tcsetattr(fd,TCSANOW,&options) != 0) - { - printf("SetupSerial failed"); - return -1; - } - // printf("set_Parity\n"); - return 0; -} - -//接收消息结尾加换行符 -int serial_set_line_input(int fd) -{ - struct termios options; - if ( tcgetattr( fd,&options) != 0) { - perror("SetupSerial 1"); - return -1; - } - - options.c_lflag |= ICANON; - - tcflush(fd,TCIFLUSH); - options.c_cc[VTIME] = 150; /* 设置超时15 seconds*/ - options.c_cc[VMIN] = 0; /* Update the options and do it NOW */ - if (tcsetattr(fd,TCSANOW,&options) != 0) - { - perror("SetupSerial 3"); - return -1; - } - return 0; -} - -/** -*@brief -*@param port 串口端口号 -*@param spd 串口速度 -*@param databits,parity,stopbits,RTSCTS,分别为数据位,校验位,停止位,rtscts位 -*@param need_line_input接收数据结尾是否加换行符? -*/ -int serial_init(int port, int spd, int databits, int parity, int stopbits, int RTSCTS, int need_line_input) -{ - int fd; - if(port < 13) - { - // printf("open port:%d\n", port); - } - else { - printf("error: port:%d > MAX_PORTS\n", port); - return -1; - } - // - fd = open(ports[port].name, O_RDWR|O_NOCTTY);//O_NONBLOCK 非阻塞, O_WRONLY 只读写, O_RDONLY 只读, O_RDWR 读写,O_NOCTTY 阻塞 - - if (-1 == fd) { - printf("init %s failed\n", ports[port].name); - return -1; - } - pf = fdopen(port, "w"); - pfi = fdopen(port, "r"); - if (!pf || ! pfi) - fprintf(stderr,"open port failed\n"); - - - - set_speed(fd, spd); - - set_Parity(fd, databits, parity, stopbits, RTSCTS); - - if (need_line_input) { - serial_set_line_input(fd); - } - - ports[port].port_fd = fd; - - return fd; -} - -/** -*@brief -*@param fd 串口端口号文件描述符 -*@param src 需要通过串口发送的数据 -*@param len 需要发送的数据长度 -*@param 成功返回0, 否则返回-1 -*/ -int serial_write(int fd, void *src, int len) -{ - int ret = write(fd, src, len); - if (len != ret) { - perror("oh, write serial failed!"); - return -1; - } - return 0; -} - -/** -*@brief -*@param fd 串口端口号文件描述符 -*@param src 串口接收数据的指针 -*@param len 需要接收的数据长度 -*@param 成功返回0, 否则返回-1 -*/ -int serial_read(int fd, char *buf, int len) -{ - int ret = read(fd, buf, len-1); - if (-1 == ret) { - perror("oh, read serial failed!"); - return -1; - } - buf[ret] = '\0'; - return ret; -} - -int serial_recv(int fd,char *rbuf,int rbuf_len, int timeout) -{ - int retval; - fd_set rset; - struct timeval time_out; - if(!rbuf || rbuf_len <= 0) - { - // printf("serial_recv Invalid parameter.\n"); - return -1; - } - if(timeout) //指定延时等待 - { - time_out.tv_sec = (time_t)(timeout / 1000); - time_out.tv_usec = 0; - FD_ZERO(&rset); - FD_SET(fd,&rset); - - retval = select(fd,&rset,NULL,NULL,&time_out); - if(retval < 0) - { - // printf("%s,Select failed:%s\n",strerror(errno)); - return -2; - } - else if(0 == retval) - { - // printf("Time Out.\n"); - return 0; - } - - } - // usleep(1000); - retval = read(fd, rbuf, rbuf_len); - if( retval <= 0) - { - // printf("Read failed:%s\n",strerror(errno)); - return -3; - } - return retval; - -} - - -static void timeout() -{ - fprintf(stderr,"No response from modem.\n"); - exit(2); -} -/*字符包含判断*/ -static int starts_with(const char* prefix, const char* str) -{ - while(*prefix) - { - if (*prefix++ != *str++) - { - return 0; - } - } - return 1; -} -/*判断是否存在*/ -int FileExist(const char* filename) -{ - if (filename && access(filename, F_OK) == 0) { - return 1; - } - return 0; -} -/*字符转小写*/ -char* str_tolower(const char* str) -{ - size_t len = strlen(str); - char *lower = calloc(len+1, sizeof(char)); - for (size_t i = 0; i < len; ++i) { - lower[i] = tolower((unsigned char)str[i]); - } - /*free(upper);*/ - return lower; -} -/*字符转大写*/ -char* str_toupper(const char* str) -{ - size_t len = strlen(str); - char *upper = calloc(len+1, sizeof(char)); - for (size_t i = 0; i < len; ++i) { - upper[i] = toupper((unsigned char)str[i]); - } - /*free(upper);*/ - return upper; -} -/*char*转char[]*/ -char strx_tostrarr(const char* str) -{ - return 0; -} - - -int main(int argc, char **argv) -{ - if(argc<3) - { - printf("ERROR demo: sendat 2 'ATI'\n"); - exit(1); - return 0; - } - int debug = 1; - int port= 0; - sscanf(argv[1], "%d", &port); - if(FileExist(ports[port].name)==0) - { - printf("AT ERROR absent.\n"); - return 0; - } - char *message= argv[2]; - char *nty= "\r\n"; - char buff[1024]; - signal(SIGALRM,timeout); - alarm(2); - /*信号超时3秒自动退出*/ - int fd = serial_def_init(port, 1500000); - if(fd < 0) return 0; - char *send= strcat(message,nty); - serial_write(fd,send, strlen(send)); - while(1) { - int read = serial_read(fd, buff, sizeof(buff)); - if(starts_with("OK", buff)) { - if (debug == 1) - printf("%s", buff); - close(fd);//关闭串口 - exit(0); - } - if(starts_with("ERROR", buff)) { - if (debug == 1) - printf("%s", buff); - close(fd);//关闭串口 - exit(1); - } - if(starts_with("COMMAND NOT SUPPORT", buff)) { - if (debug == 1) - printf("%s", buff); - close(fd);//关闭串口 - exit(1); - } - if(starts_with("+CME ERROR", buff)) { - if (debug == 1) - printf("%s", buff); - close(fd);//关闭串口 - exit(1); - } - printf("%s", buff); - } - - exit(1); - return 0; -} diff --git a/sendat/src/ucs2_to_utf8.c b/sendat/src/ucs2_to_utf8.c deleted file mode 100644 index 5baa433..0000000 --- a/sendat/src/ucs2_to_utf8.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 2014 lovewilliam - * from http://www.lemoda.net/c/ucs2-to-utf8/ucs2-to-utf8.c - */ -/* Input: a Unicode code point, "ucs2". - - Output: UTF-8 characters in buffer "utf8". - - Return value: the number of bytes written into "utf8", or -1 if - there was an error. - - This adds a zero byte to the end of the string. It assumes that the - buffer "utf8" has at least four bytes of space to write to. */ - -#define UNICODE_SURROGATE_PAIR -2 -#define UNICODE_BAD_INPUT -1 - -int ucs2_to_utf8 (int ucs2, unsigned char * utf8) -{ - if (ucs2 < 0x80) { - utf8[0] = ucs2; - utf8[1] = '\0'; - return 1; - } - if (ucs2 >= 0x80 && ucs2 < 0x800) { - utf8[0] = (ucs2 >> 6) | 0xC0; - utf8[1] = (ucs2 & 0x3F) | 0x80; - utf8[2] = '\0'; - return 2; - } - if (ucs2 >= 0x800 && ucs2 < 0xFFFF) { - if (ucs2 >= 0xD800 && ucs2 <= 0xDFFF) { - /* Ill-formed. */ - return UNICODE_SURROGATE_PAIR; - } - utf8[0] = ((ucs2 >> 12) ) | 0xE0; - utf8[1] = ((ucs2 >> 6 ) & 0x3F) | 0x80; - utf8[2] = ((ucs2 ) & 0x3F) | 0x80; - utf8[3] = '\0'; - return 3; - } - if (ucs2 >= 0x10000 && ucs2 < 0x10FFFF) { - /* http://tidy.sourceforge.net/cgi-bin/lxr/source/src/utf8.c#L380 */ - utf8[0] = 0xF0 | (ucs2 >> 18); - utf8[1] = 0x80 | ((ucs2 >> 12) & 0x3F); - utf8[2] = 0x80 | ((ucs2 >> 6) & 0x3F); - utf8[3] = 0x80 | ((ucs2 & 0x3F)); - utf8[4] = '\0'; - return 4; - } - return UNICODE_BAD_INPUT; -} -